Re: CTEs and re-use

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Rob Sargent <robjsargent(at)gmail(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: CTEs and re-use
Date: 2017-04-12 01:47:02
Message-ID: CAKFQuwaaCewCWEL0ojyzjgS7db09hATgT77SZquoF1CzPSC3bg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, Apr 11, 2017 at 5:41 PM, Rob Sargent <robjsargent(at)gmail(dot)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.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Rob Sargent 2017-04-12 02:47:45 Re: CTEs and re-use
Previous Message Rob Sargent 2017-04-12 00:41:22 CTEs and re-use