Masahiko Sawada <sawada.m...@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