Re: Writeable CTEs and empty relations

From: Marko Tiikkaja <marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Writeable CTEs and empty relations
Date: 2010-02-11 00:13:19
Message-ID: 4B734B9F.3010400@cs.helsinki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2010-02-11 01:58 +0200, Robert Haas wrote:
> On Wed, Feb 10, 2010 at 6:25 PM, Marko Tiikkaja
> <marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi> wrote:
>> On 2010-02-11 00:50 +0200, Marko Tiikkaja wrote:
>> Ok, what about the following:
>> - after planning the original query, standard_planner() goes through
>> the list of top-level CTEs and assigns a running number for each of
>> the DML WITHs, in the order they will be executed and returns a
>> list of PlannedStmts. all necessary statements wi have a flag
>> signaling that the result should be stored in a tuplestore.
>> - the portal keeps the list of tuplestores around and passes that
>> list to every query through PlannedStmt. it keeps on executing
>> the statements until it finds a PlannedStmt that doesn't want its
>> results stored anywhere and then frees the list of tuplestores
>
> Wouldn't you'd want to stop when you ran out of PlannedStmts, not when
> you hit one that didn't need its results stored? What happens if
> there's an unreferenced CTE in the middle of the list?

Right, of course.

>> Does this sound reasonable? And more importantly, am I going to be
>> wasting my time implementing this? The 15th isn't that far away..
>
> I have to admit I've been starting to have a feeling over the last
> couple of days that this patch isn't going to make it for 9.0... but
> obviously I'm in no position to guarantee anything one way or the
> other. Please do keep us up to date on your plans, though.

Unfortunately, so have I. I'll take a shot at implementing this, but if
I come across any problems, I have to give up.

Regards,
Marko Tiikkaja

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2010-02-11 00:21:25 Re: psql tab completion for DO blocks
Previous Message Jim Nasby 2010-02-11 00:07:51 Re: Odd cruft in .psql_history in HEAD