Re: (Comment)Bug in CteScanNext - Mailing list pgsql-hackers

From Tom Lane
Subject Re: (Comment)Bug in CteScanNext
Date
Msg-id 20931.1472927453@sss.pgh.pa.us
Whole thread Raw
In response to (Comment)Bug in CteScanNext  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
Responses Re: (Comment)Bug in CteScanNext  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
List pgsql-hackers
Jim Nasby <Jim.Nasby@BlueTreble.com> 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 (!forward && eof_tuplestore)

> For the comment to be correct, wouldn't the condition need to be 
> (!forward || !eof_tuplestore)?

No.  The comment is describing the overall strategy for the next ~30
lines.  That first if-test is dealing with a sub-case, ie reversing
direction after reaching EOF.  The code's fine, and the comments are
okay as far as they go, but maybe some rearrangement would be in order.
Or we could add something like "But first, we must deal with the special
case of reversing direction after reaching EOF."
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [sqlsmith] Failed assertion in numeric aggregate
Next
From: Vik Fearing
Date:
Subject: Re: sequence data type