Re: Failure assertion in GROUPS mode of window function in current HEAD

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Failure assertion in GROUPS mode of window function in current HEAD
Date: 2018-07-09 22:24:28
Message-ID: 13102.1531175068@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2018-07-09 22:49:10 Re: Locking B-tree leafs immediately in exclusive mode
Previous Message Alexander Korotkov 2018-07-09 22:23:08 Re: Locking B-tree leafs immediately in exclusive mode