Re: Common Table Expressions applied; some issues remain - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Common Table Expressions applied; some issues remain
Date
Msg-id 2500.1223219973@sss.pgh.pa.us
Whole thread Raw
In response to Re: Common Table Expressions applied; some issues remain  (Gregory Stark <stark@enterprisedb.com>)
Responses Re: Common Table Expressions applied; some issues remain
List pgsql-hackers
Gregory Stark <stark@enterprisedb.com> writes:
> Peter Eisentraut <peter_e@gmx.net> writes:
>> Tom Lane wrote:
>>> 2. The patch didn't touch the implicit-RTE code, which means that
>>> 
>>> WITH q AS ( SELECT ... )
>>> SELECT q.*
>>>
>>> will fail even if you've got add_missing_from enabled. 
>> 
>> Yes, it's legacy.  I wouldn't bother.

> The results would be even more suprising if there *is* a table named "q"
> though...

Yeah, the real problem is not so much that it might fail as that it
might silently do something quite different from what you would expect.

CVS HEAD documentation states
 (In fact, the WITH query hides any real table of the same name for the purposes of the primary query. If necessary,
youcan refer to a real table of the same name by schema-qualifying the table's name.)
 

If we don't fix this, I think we'd have to add some disclaimer about
how WITH clauses *don't* hide real tables in the case of implicit RTE
additions.  That seems much uglier than fixing it.

(Hmm, memo to self: I'll bet ruleutils.c's decision about whether it
needs to schema-qualify a reverse-listed table name doesn't take this
into account.)
        regards, tom lane


pgsql-hackers by date:

Previous
From: Gregory Stark
Date:
Subject: Re: Common Table Expressions applied; some issues remain
Next
From: Tom Lane
Date:
Subject: Re: CYCLE and SEARCH [was Re: Common Table Expressions (WITH RECURSIVE) patch]