The following bug has been logged online:
Bug reference: 5199
Logged by: Iliya Krapchatov
Email address: my_working@inbox.ru
PostgreSQL version: 8.4.1
Operating system: Windows XP
Description: Window frame clause wrong (?) behaviour
Details:
I am new at WINDOW clause using so maybe I've missed something. Following is
the sequence of steps to repeat the problem:
create table t( pk integer );
insert into t(pk) values( 1 );
insert into t(pk) values( 2 );
select first_value( pk ) OVER ( pkw ) FROM t
WINDOW pkw AS ( PARTITION BY pk ORDER BY pk RANGE BETWEEN UNBOUNDED
PRECEDING AND UNBOUNDED FOLLOWING );
I see following lines in response:
---
ERROR: cannot override frame clause of window "pkw"
LINE 1: select first_value( pk ) OVER ( pkw ) FROM t
^
********** Error **********
ERROR: cannot override frame clause of window "pkw"
SQL state: 42P20
ХаÑакÑеÑиÑÑика:31
---
I believe that is a bug because next two queries work fine:
select first_value( pk ) OVER ( PARTITION BY pk ORDER BY pk RANGE BETWEEN
UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t;
select first_value( pk ) OVER ( pkw ) FROM t
WINDOW pkw AS ( PARTITION BY pk ORDER BY pk );