Re: [HACKERS] views and group by (formerly: create view as selec - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] views and group by (formerly: create view as selec
Date
Msg-id 8449.925224655@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] views and group by (formerly: create view as selec  (jwieck@debis.com (Jan Wieck))
Responses Re: [HACKERS] views and group by (formerly: create view as selec  (jwieck@debis.com (Jan Wieck))
List pgsql-hackers
jwieck@debis.com (Jan Wieck) writes:
>     I tried to make it and it works partially. The problems arise
>     if you have a view with a group by clause but do  not  select
>     the attributes the group by clause uses:

>       CREATE TABLE t1 (a int4, b int4);
>       CREATE VIEW v1 AS SELECT b, count(b) FROM t1 GROUP BY b;

>       SELECT count FROM v1;
>       SELECT count(*) FROM v1;

>     Both selects crash the backend!

Hmm, this sounds very similar to a problem I was looking at on Sunday:

select sum(quantity), ID+1 from aggtest1 group by ID+1;
ERROR:  replace_agg_clause: variable not in target list

The error message is new as of Sunday; with code older than that this
will crash the backend.  And, in fact, what I get from Jan's example
above is:

SELECT count FROM v1;
ERROR:  replace_agg_clause: variable not in target list

In both situations, it's necessary to add variables to the target list
that aren't in the list produced by the parser.  We have code that does
that sort of thing, but it's evidently not getting applied...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Thomas Lockhart
Date:
Subject: Re: [HACKERS] RE: Mysql comparison
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] numeric data type on 6.5