Re: [HACKERS] Backend crash during explain

2007-05-31 Thread Tom Lane
Grant Finnemore <[EMAIL PROTECTED]> writes:
> The query with no EXPLAIN (ANALYSE) completes fine.
> The query with EXPLAIN ANALYSE completes fine.
> However, with just EXPLAIN (no ANALYSE)

Need a complete test case please, not just the query.  All I get here is
ERROR:  relation "tagged_asset" does not exist

regards, tom lane

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [HACKERS] Backend crash during explain

2007-05-31 Thread Zdenek Kotala

Grant Finnemore napsal(a):

CrashReporter trace:

Date/Time:  2007-05-31 10:21:39.285 +0200
OS Version: 10.4.9 (Build 8P2137)
Report Version: 4

Command: postmaster
Path:./bin/postmaster
Parent:  postmaster [23091]

Version: ??? (???)

PID:23096
Thread: 0

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:  KERN_PROTECTION_FAILURE (0x0002) at 0x0018

Thread 0 Crashed:
0   postmaster 0x00116ec6 ExecSetSlotDescriptor + 77 (execTuples.c:344)
1   postmaster 0x001182f9 ExecAssignScanTypeFromOuterPlan + 33 
(execUtils.c:771)

2   postmaster 0x001240c8 ExecInitSort + 168 (nodeSort.c:211)


It looks that tupDesc contains invalid pointer. I found some strange 
assignment in ExecAssignScanTypeFromOuterPlan function. See comment 
bellow. OuterPlanState expects PlaneState structure instead ScanState.


00762 ExecAssignScanTypeFromOuterPlan(ScanState *scanstate)
00763 {
00764 PlanState  *outerPlan;
00765 TupleDesc   tupDesc;
00766
00767 outerPlan = outerPlanState(scanstate);
^
scanstate->ps ??

00768 tupDesc = ExecGetResultType(outerPlan);
00769
00770 ExecAssignScanType(scanstate, tupDesc);
00771 }


Zdenek

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
  choose an index scan if your joining column's datatypes do not
  match


[HACKERS] Backend crash during explain

2007-05-31 Thread Grant Finnemore

Hi,

This is on Intel OSX, anon CVS download today.

Build process:-

1. make distclean
2. ./configure --enable-debug --enable-cassert --enable-integer-datetimes 
--prefix=/Users/grant/Development/bin/pgsql --enable-depend

3. make all install

The query with no EXPLAIN (ANALYSE) completes fine.

The query with EXPLAIN ANALYSE completes fine.


foo=# explain analyse select this_.id as id6_2_, this_1_.created_at as 
created2_6_2_, this_1_.created_by as created3_6_2_, this_1_.updated_at as 
updated4_6_2_, this_1_.updated_by as updated5_6_2_, this_1_.from_date as 
from6_6_2_, this_1_.party_id as party8_6_2_, this_1_.thru_date as thru7_6_2_, 
this_1_.type_id as type9_6_2_, this_.tag as tag14_2_, this_.taggedBy_id as 
taggedBy4_14_2_, this_.taggedDate as taggedDate14_2_, partyrolet2_.id as 
id3_0_, partyrolet2_.created_at as created2_3_0_, partyrolet2_.created_by as 
created3_3_0_, partyrolet2_.updated_at as updated4_3_0_, 
partyrolet2_.updated_by as updated5_3_0_, partyrolet2_.description as 
descript6_3_0_, partyrolet2_.name as name3_0_, tagimplant3_.id as id6_1_, 
tagimplant3_1_.created_at as created2_6_1_, tagimplant3_1_.created_by as 
created3_6_1_, tagimplant3_1_.updated_at as updated4_6_1_, 
tagimplant3_1_.updated_by as updated5_6_1_, tagimplant3_1_.from_date as 
from6_6_1_, tagimplant3_1_.party_id as party8_6_1_, tagimplant

3_1_.thru_date as thru7_6_1_, tagimplant3_1_.type_id as type9_6_1_ from 
tagged_asset this_ inner join party_role this_1_ on this_.id=this_1_.id inner 
join party_role_type partyrolet2_ on this_1_.type_id=partyrolet2_.id left outer 
join tag_implanter tagimplant3_ on this_.taggedBy_id=tagimplant3_.id left outer 
join party_role tagimplant3_1_ on tagimplant3_.id=tagimplant3_1_.id where 
(lower(this_.tag) like '1f76%') limit 100;
  QUERY PLAN  
--

 Limit  (cost=8.31..24.50 rows=1 width=3748) (actual time=23.057..209.191 
rows=77 loops=1)
   ->  Nested Loop  (cost=8.31..24.50 rows=1 width=3748) (actual 
time=23.055..209.142 rows=77 loops=1)
 ->  Nested Loop Left Join  (cost=8.31..24.22 rows=1 width=2170) 
(actual time=23.036..208.326 rows=77 loops=1)
   ->  Nested Loop Left Join  (cost=8.31..18.62 rows=1 width=1098) 
(actual time=23.033..208.204 rows=77 loops=1)
 ->  Merge Join  (cost=8.31..10.34 rows=1 width=1094) 
(actual time=23.024..208.015 rows=77 loops=1)
   Merge Cond: (this_1_.id = this_.id)
   ->  Index Scan Backward using party_role_pkey on 
party_role this_1_  (cost=0.00..18672.18 rows=581325 width=1076) (actual 
time=0.102..142.963 rows=240384 loops=1)
   ->  Sort  (cost=8.31..8.32 rows=1 width=22) (actual 
time=0.856..0.902 rows=77 loops=1)
 Sort Key: this_.id
 Sort Method:  quicksort  Memory: 20kB
 ->  Index Scan using tagged_asset_tag_key on 
tagged_asset this_  (cost=0.01..8.30 rows=1 width=22) (actual time=0.109..0.739 
rows=77 loops=1)
   Index Cond: ((lower((tag)::text) >= 
'1f76'::text) AND (lower((tag)::text) < '1f77'::text))
   Filter: (lower((tag)::text) ~~ 
'1f76%'::text)
 ->  Index Scan using tag_implanter_pkey on tag_implanter 
tagimplant3_  (cost=0.00..8.27 rows=1 width=4) (actual time=0.001..0.001 rows=0 
loops=77)
   Index Cond: (this_.taggedby_id = tagimplant3_.id)
   ->  Index Scan using party_role_pkey on party_role 
tagimplant3_1_  (cost=0.00..5.59 rows=1 width=1076) (actual time=0.000..0.000 
rows=0 loops=77)
 Index Cond: (tagimplant3_.id = tagimplant3_1_.id)
 ->  Index Scan using party_role_type_pkey on party_role_type 
partyrolet2_  (cost=0.00..0.27 rows=1 width=1578) (actual time=0.008..0.009 rows=1 
loops=77)
   Index Cond: (partyrolet2_.id = this_1_.type_id)
 Total runtime: 209.699 ms
(20 rows)



However, with just EXPLAIN (no ANALYSE)


foo=# explain select this_.id as id6_2_, this_1_.created_at as created2_6_2_, 
this_1_.created_by as created3_6_2_, this_1_.updated_at as updated4_6_2_, 
this_1_.updated_by as updated5_6_2_, this_1_.from_date as from6_6_2_, 
this_1_.party_id as party8_6_2_, this_1_.thru_date as thru7_6_2_, 
this_1_.type_id as type9_6_2_, this_.tag as tag14_2_, this_.taggedBy_id as 
taggedBy4_14_2_, this_.taggedDate as taggedDate14_2_, partyrolet2_.id as 
id3_0_, partyrolet2_.created_at as created2_3_0_, partyrolet2_.created_by as 
created3_3_0_, partyrolet2_.updated_at as updated4_3_0_, 
partyrolet2_.u