Re: Failure assertion in GROUPS mode of window function in current HEAD - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Failure assertion in GROUPS mode of window function in current HEAD
Date
Msg-id 13102.1531175068@sss.pgh.pa.us
Whole thread Raw
In response to Failure assertion in GROUPS mode of window function in current HEAD  (Masahiko Sawada <sawada.mshk@gmail.com>)
Responses Re: Failure assertion in GROUPS mode of window function in current HEAD  (Masahiko Sawada <sawada.mshk@gmail.com>)
List pgsql-hackers
Masahiko Sawada <sawada.mshk@gmail.com> writes:
> I got an assertion failure when I use GROUPS mode and specifies offset
> without ORDER BY clause. The reproduction steps and the backtrace I
> got are following.

> =# create table test as select 1 as c;
> =# select sum(c) over (partition by c groups between 1 preceding and
> current row) from test;
> TRAP: FailedAssertion("!(ptr >= 0 && ptr < state->readptrcount)",
> File: "tuplestore.c", Line: 478)

Hm.  Shouldn't we reject this case?  I don't see how GROUPS mode makes
any sense with no ORDER BY.  Maybe you could define it as working with
"groups" of one row each, but the standard seems to think not:

   c) If GROUPS is specified, then:

      i) Either WDEF shall contain a <window order clause>, or WDEF shall
      specify an <existing window name> that identifies a window structure
      descriptor that includes a window ordering clause.

The fact that you got an assertion failure is not very nice, maybe we
need some more code defenses there; but probably the whole thing
should be rejected at parse time.

            regards, tom lane


pgsql-hackers by date:

Previous
From: Alexander Korotkov
Date:
Subject: Re: Locking B-tree leafs immediately in exclusive mode
Next
From: Peter Geoghegan
Date:
Subject: Re: Locking B-tree leafs immediately in exclusive mode