Re: [SQL] CTEs and re-use - Mailing list pgsql-sql

From David G. Johnston
Subject Re: [SQL] CTEs and re-use
Date
Msg-id CAKFQuwaaCewCWEL0ojyzjgS7db09hATgT77SZquoF1CzPSC3bg@mail.gmail.com
Whole thread Raw
In response to [SQL] CTEs and re-use  (Rob Sargent <robjsargent@gmail.com>)
List pgsql-sql
On Tue, Apr 11, 2017 at 5:41 PM, Rob Sargent <robjsargent@gmail.com> wrote:
The gripe is that the function puts the results of the CTE/select into a temp table for the follow-on query.  That mean I have a name collision and have to drop the temp table.
​[...]​

What am I missing here in building the fence and losing the neighbours?

​Best guess:​

​​CREATE TEMP TABLE ... ON COMMIT DROP AS

or

DROP TABLE IF EXISTS​ ..

You show a lot of detail in the function but its not useful.  Given the stated problem your queries or "SELECT '1'::text" both will exhibit the same behavior.  What you don't show or describe, however, is how and when the function is called.

​David J.

pgsql-sql by date:

Previous
From: Rob Sargent
Date:
Subject: [SQL] CTEs and re-use
Next
From: Rob Sargent
Date:
Subject: Re: [SQL] CTEs and re-use