subselect bug (was Re: [GENERAL] DBLink: interesting issue) - Mailing list pgsql-hackers

From Joe Conway
Subject subselect bug (was Re: [GENERAL] DBLink: interesting issue)
Date
Msg-id 3D8FF93F.7090401@joeconway.com
Whole thread Raw
Responses Re: subselect bug (was Re: [GENERAL] DBLink: interesting issue)  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: subselect bug (was Re: [GENERAL] DBLink: interesting issue)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Joe Conway wrote:> Oleg Lebedev wrote:>>> Ok, here are all the files.>>

This dblink thread on GENERAL led me to a bug in the planner subselect code.
Here is an example query that triggers it (independent of dblink and/or table
functions):

replica=# create table foo(f1 int);
CREATE TABLE
replica=# SELECT * FROM foo t WHERE NOT EXISTS (SELECT remoteid FROM (SELECT
f1 as remoteid FROM foo WHERE f1 = t.f1) AS t1);
server closed the connection unexpectedly         This probably means the server terminated abnormally         before
orwhile processing the request.
 
The connection to the server was lost. Attempting reset: Failed.

It doesn't matter how foo is defined.

I'm just starting to dig in to this, but was hoping for any thoughts or
guidance I can get.

Thanks,

Joe

p.s. Below is a backtrace:

#3  0x081797a1 in ExceptionalCondition () at assert.c:46
#4  0x0810e102 in replace_var (var=0x82f73a8) at subselect.c:81
#5  0x0811293c in expression_tree_mutator (node=0x82f7438, mutator=0x810e96c
<replace_correlation_vars_mutator>,     context=0x0) at clauses.c:2314
#6  0x0810e9a5 in replace_correlation_vars_mutator (node=0x82f7438,
context=0x0) at subselect.c:540
#7  0x08112718 in expression_tree_mutator (node=0x82f7454, mutator=0x810e96c
<replace_correlation_vars_mutator>,     context=0x0) at clauses.c:2179
#8  0x0810e9a5 in replace_correlation_vars_mutator (node=0x82f7454,
context=0x0) at subselect.c:540
#9  0x0811293c in expression_tree_mutator (node=0x82f7480, mutator=0x810e96c
<replace_correlation_vars_mutator>,     context=0x0) at clauses.c:2314
#10 0x0810e9a5 in replace_correlation_vars_mutator (node=0x82f7480,
context=0x0) at subselect.c:540
#11 0x0810e968 in SS_replace_correlation_vars (expr=0x82f7480) at subselect.c:525
#12 0x0810cef5 in preprocess_expression (parse=0x82f6830, expr=0x82f7064,
kind=1) at planner.c:725
#13 0x0810cf7e in preprocess_qual_conditions (parse=0x82f6830,
jtnode=0x82f6d70) at planner.c:775
#14 0x0810c75c in subquery_planner (parse=0x82f6830, tuple_fraction=1) at
planner.c:168
#15 0x0810e260 in make_subplan (slink=0x82f6698) at subselect.c:185
#16 0x0811293c in expression_tree_mutator (node=0x82f6780, mutator=0x810e9bc
<process_sublinks_mutator>, context=0x0)     at clauses.c:2314
#17 0x0810ea35 in process_sublinks_mutator (node=0x82f6780, context=0x0) at
subselect.c:586
#18 0x08112718 in expression_tree_mutator (node=0x82f6754, mutator=0x810e9bc
<process_sublinks_mutator>, context=0x0)     at clauses.c:2179
#19 0x0810ea35 in process_sublinks_mutator (node=0x82f6754, context=0x0) at
subselect.c:586
#20 0x0811293c in expression_tree_mutator (node=0x82f679c, mutator=0x810e9bc
<process_sublinks_mutator>, context=0x0)     at clauses.c:2314
#21 0x0810ea35 in process_sublinks_mutator (node=0x82f679c, context=0x0) at
subselect.c:586
#22 0x0810e9b8 in SS_process_sublinks (expr=0x82f679c) at subselect.c:553
#23 0x0810cede in preprocess_expression (parse=0x82f46d4, expr=0x82fc164,
kind=1) at planner.c:721
#24 0x0810cf7e in preprocess_qual_conditions (parse=0x82f46d4,
jtnode=0x82fc36c) at planner.c:775
#25 0x0810c75c in subquery_planner (parse=0x82f46d4, tuple_fraction=-1) at
planner.c:168
#26 0x0810c68c in planner (parse=0x82f46d4) at planner.c:96




pgsql-hackers by date:

Previous
From: John Buckman
Date:
Subject: Re: Postgresql Automatic vacuum
Next
From: "Shridhar Daithankar"
Date:
Subject: Re: Postgresql Automatic vacuum