Skip site navigation (1) Skip section navigation (2)

pgsql: Make UtilityContainsQuery recurse until it finds a non-utilityQ

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Make UtilityContainsQuery recurse until it finds a non-utilityQ
Date: 2012-06-28 03:19:00
Message-ID: E1Sk5G0-0004xN-Ut@gemulon.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Make UtilityContainsQuery recurse until it finds a non-utility Query.

The callers of UtilityContainsQuery want it to return a non-utility Query
if it returns anything at all.  However, since we made CREATE TABLE
AS/SELECT INTO into a utility command instead of a variant of SELECT,
a command like "EXPLAIN SELECT INTO" results in two nested utility
statements.  So what we need UtilityContainsQuery to do is drill down
to the bottom non-utility Query.

I had thought of this possibility in setrefs.c, and fixed it there by
looping around the UtilityContainsQuery call; but overlooked that the call
sites in plancache.c have a similar issue.  In those cases it's
notationally inconvenient to provide an external loop, so let's redefine
UtilityContainsQuery as recursing down to a non-utility Query instead.

Noted by Rushabh Lathia.  This is a somewhat cleaned-up version of his
proposed patch.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/bde689f809027422d4c0baaa3e63b69ce5762e2c

Modified Files
--------------
src/backend/optimizer/plan/setrefs.c |    2 +-
src/backend/tcop/utility.c           |   26 ++++++++++++++++++++------
2 files changed, 21 insertions(+), 7 deletions(-)

pgsql-committers by date

Next:From: Robert HaasDate: 2012-06-28 12:16:04
Subject: pgsql: Add missing space in event_source GUC description.
Previous:From: Peter EisentrautDate: 2012-06-27 18:23:11
Subject: pgsql: Fix install program detection

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group