Re: [HACKERS] (Comment)Bug in CteScanNext

2016-09-07 Thread Jim Nasby
On 9/6/16 12:00 PM, Tom Lane wrote: On the other hand, if eof_cte is true, then what happened on the last call is that we tried to fetch forwards, reached EOF on the underlying query, and returned NULL. In that case, a backwards fetch *should* produce the last row in the tuplestore. Patch

Re: [HACKERS] (Comment)Bug in CteScanNext

2016-09-06 Thread Tom Lane
Jim Nasby writes: > On 9/3/16 1:30 PM, Tom Lane wrote: >> Or we could add something like "But first, we must deal with the special >> case of reversing direction after reaching EOF." > I'm working on that, but one thing isn't clear to me... why do we only > skip past

Re: [HACKERS] (Comment)Bug in CteScanNext

2016-09-06 Thread Jim Nasby
On 9/3/16 1:30 PM, Tom Lane wrote: Or we could add something like "But first, we must deal with the special case of reversing direction after reaching EOF." I'm working on that, but one thing isn't clear to me... why do we only skip past the last tuple if (!node->leader->eof_cte)? Even if

Re: [HACKERS] (Comment)Bug in CteScanNext

2016-09-03 Thread Tom Lane
Jim Nasby writes: > In CteScanNext(): > /* >* If we are not at the end of the tuplestore, or are going > backwards, try >* to fetch a tuple from tuplestore. >*/ > eof_tuplestore = tuplestore_ateof(tuplestorestate); > if

[HACKERS] (Comment)Bug in CteScanNext

2016-09-02 Thread Jim Nasby
In CteScanNext(): /* * If we are not at the end of the tuplestore, or are going backwards, try * to fetch a tuple from tuplestore. */ eof_tuplestore = tuplestore_ateof(tuplestorestate); if (!forward && eof_tuplestore) For the comment to be