Re: Common Table Expressions (WITH RECURSIVE) patch - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Common Table Expressions (WITH RECURSIVE) patch
Date
Msg-id 3794.1223063756@sss.pgh.pa.us
Whole thread Raw
In response to Re: Common Table Expressions (WITH RECURSIVE) patch  ("Greg Stark" <stark@enterprisedb.com>)
Responses CYCLE and SEARCH [was Re: Common Table Expressions (WITH RECURSIVE) patch]
List pgsql-hackers
I've successfully taught the WITH patch to do single evaluation of WITH
queries.  I've also been through all of the planner and executor code
for it and am now feeling pretty happy with the whole thing.  There are
still a small number of loose ends (see XXX in the patch), but I don't
believe any of them represent significant work --- I just left them
undone because they weren't in the way of testing anything else.

One point of interest (at least to Hitoshi-san) is that my first cut
at the multiple-readout tuplestore turned out to be not quite the right
thing.  In the original code, if the read pointer was "at eof" (meaning
the previous gettuple call had returned null), then a puttuple call
would move the read pointer forward over the added tuple, keeping it
"at eof".  This was done because nodeMaterial.c wanted it and no other
callers cared particularly.  I had generalized that to the idea that
*all* read pointers that are "at eof" should get moved; but this turns
out to be a really bad idea, at least for nodeCtescan's usage.  What
seems to be the right thing is for only the "active" read pointer to
be moved forward, with inactive ones dropping out of "at eof" state.
This seems reasonable because the point is to not have to reprocess
a tuple you know you just stuck into the tuplestore --- but the other
readers of the tuplestore won't know that, and need to see the tuple
you added.  But it might be that we need to make the behavior
configurable somehow, if the window-functions patch turns out to
need something different.

Barring surprises in the loose ends, I expect to be able to commit
this in a couple of days.

            regards, tom lane


Attachment

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: parallel restore test results
Next
From: "Robert Haas"
Date:
Subject: Re: patch: Add columns via CREATE OR REPLACE VIEW