agora inbox for pgsql-hackers@postgresql.org  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Surafel Temesgen <surafel3000@gmail.com>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>
Subject: Re: FETCH FIRST clause WITH TIES option
Date: Thu, 28 Nov 2019 11:49:03 -0300
Message-ID: <20191128144903.GA30772@alvherre.pgsql> (raw)
In-Reply-To: <CALAY4q82MDk1cehn-n2sSPu0iOLttXGk4A_CdXHnUSnQpK5sFA@mail.gmail.com>

On 2019-Nov-28, Surafel Temesgen wrote:

> On Thu, Nov 28, 2019 at 12:36 AM Alvaro Herrera <alvherre@2ndquadrant.com>
> wrote:
> 
> > I think you should add a /* fall-though */ comment after changing state.
> > Like this (this flow seems clearer; also DRY):
> >
> >                 if (!node->noCount &&
> >                     node->position - node->offset >= node->count)
> >                 {
> >                     if (node->limitOption == LIMIT_OPTION_COUNT)
> >                     {
> >                         node->lstate = LIMIT_WINDOWEND;
> >                         return NULL;
> >                     }
> >                     else
> >                     {
> >                         node->lstate = LIMIT_WINDOWEND_TIES;
> >                         /* fall-through */
> >                     }
> >                 }
> >                 else
> >                     ...
>
> changed

But you did not read my code snippet, did you ...?

> > I think you need to stare a that thing a little harder.
>
> This is because the new state didn't know about backward scan
> and there was off by one error it scan one position past to detect
> ties. The attached patch fix both

Oh, thanks, glad it was that easy.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services





view thread (61+ messages)  latest in thread

Message-ID: <20191128144903.GA30772@alvherre.pgsql>
Permalink:  ../20191128144903.GA30772@alvherre.pgsql/
Also on:    postgresql.org/message-id/20191128144903.GA30772@alvherre.pgsql

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: alvherre@2ndquadrant.com, surafel3000@gmail.com, tomas.vondra@2ndquadrant.com, andrew@tao11.riddles.org.uk
  Subject: Re: FETCH FIRST clause WITH TIES option
  In-Reply-To: <20191128144903.GA30772@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox