From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Anybody using mutate_eclass_expressions() from add-on code? |
Date: | 2012-11-26 03:51:59 |
Message-ID: | 16197.1353901919@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I looked into the problem reported in bug #7703, namely that queries
such as
select distinct min(x) from tab;
fail if "tab" is an inheritance tree and an index-optimized plan
using MergeAppend is possible. What's happening is that
(1) the use of DISTINCT causes us to create an EquivalenceClass
containing min(x), which is needed since we may have to reason about
sorting on that expression;
(2) expansion of the inheritance tree causes us to add child
EquivalenceClass members representing min() applied to each of tab's
child tables;
(3) when planagg.c tries to replace min(x) with a Param, the
mutate_eclass_expressions(..., replace_aggs_with_params_mutator, ...)
call spits up because it doesn't know what to do with the child-table
min() expressions.
I thought about fixing this by just changing
replace_aggs_with_params_mutator to not complain about unmatched
aggregate expressions, but that seems awfully likely to obscure future
bugs. What seems like a better fix is to change the processing so that
child EquivalenceClass members aren't processed when doing the Param
replacement --- this should be OK since we won't need them after this
point. However, that requires changing the behavior of
mutate_eclass_expressions(). In the attached proposed patch I added a
new bool parameter to control whether child expressions are mutated.
This needs to be back-patched to 9.1, but I'm slightly worried about
whether changing the function's API in back branches would break any
add-on code. It seems fairly unlikely that anything outside the core
planner is calling this function, but I thought I'd better ask.
Comments?
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
bug-7703.patch | text/x-patch | 7.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Chen Huajun | 2012-11-26 06:04:05 | Re: fix ecpg core dump when there's a very long struct variable name in .pgc file |
Previous Message | Tom Lane | 2012-11-26 03:30:41 | Re: Removing PD_ALL_VISIBLE |