pgsql: Remove the restriction originally coded into

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Remove the restriction originally coded into
Date: 2006-04-28 20:57:59
Message-ID: 20060428205800.0179011F61BF@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Remove the restriction originally coded into optimize_minmax_aggregates() that
MIN/MAX not be converted to use an index if the query WHERE clause contains
any volatile functions or subplans.

I had originally feared that the conversion might alter the behavior of such a
query with respect to a volatile function. Well, so it might, but only in the
sense that the function would get evaluated at a subset of the table rows
rather than all of them --- and we have never made any such guarantee anyway.
(For instance, we don't refuse to use an index for an ordinary non-aggregate
query when one of the non-indexable filter conditions contains a volatile
function.)

The prohibition against subplans was because of worry that that case wasn't
adequately tested, which it wasn't, but it turns out to be possible to make
8.1 fail anyway:

regression=# select o.ten, (select max(unique2) from tenk1 i where ten = o.ten
or ten = (select f1 from int4_tbl limit 1)) from tenk1 o;
ERROR: direct correlated subquery unsupported as initplan

This is due to bogus code in SS_make_initplan_from_plan (it's an initplan,
ergo it can't have any parParams). Having fixed that, we might as well allow
subplans as well as initplans.

Tags:
----
REL8_1_STABLE

Modified Files:
--------------
pgsql/src/backend/optimizer/plan:
planagg.c (r1.10.2.1 -> r1.10.2.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/planagg.c.diff?r1=1.10.2.1&r2=1.10.2.2)
subselect.c (r1.100.2.1 -> r1.100.2.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/subselect.c.diff?r1=1.100.2.1&r2=1.100.2.2)

Browse pgsql-committers by date

  From Date Subject
Next Message Kris Jurka 2006-04-28 21:18:49 Re: Solaris ASM problem
Previous Message Tom Lane 2006-04-28 20:57:50 pgsql: Remove the restriction originally coded into