subselect bug (was Re: [GENERAL] DBLink: interesting issue)

From: Joe Conway <mail(at)joeconway(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgreSQL(dot)org>
Cc: Oleg Lebedev <oleg(dot)lebedev(at)waterford(dot)org>
Subject: subselect bug (was Re: [GENERAL] DBLink: interesting issue)
Date: 2002-09-24 05:33:51
Message-ID: 3D8FF93F.7090401@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general 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 or while 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Shridhar Daithankar 2002-09-24 06:16:58 Re: Postgresql Automatic vacuum
Previous Message Mr. Tomcat 2002-09-24 04:14:32 Design question: Using Array datatypes

Browse pgsql-hackers by date

  From Date Subject
Next Message Shridhar Daithankar 2002-09-24 06:16:58 Re: Postgresql Automatic vacuum
Previous Message John Buckman 2002-09-24 05:18:02 Re: Postgresql Automatic vacuum