Re: Failure assertion in GROUPS mode of window function in current HEAD
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2018-07-09T22:24:28Z
Lists: 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
Commits
-
Fix bugs with degenerate window ORDER BY clauses in GROUPS/RANGE mode.
- 8893d48e7fbf 11.0 landed
- ff4f8891648c 12.0 landed