Re: [HACKERS] views and group by (formerly: create view as selec

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jwieck(at)debis(dot)com (Jan Wieck)
Cc: michael(dot)j(dot)davis(at)tvguide(dot)com (Michael J Davis), pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] views and group by (formerly: create view as selec
Date: 1999-04-27 14:50:55
Message-ID: 8449.925224655@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

jwieck(at)debis(dot)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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-04-27 14:59:58 Re: [HACKERS] numeric data type on 6.5
Previous Message Thomas Lockhart 1999-04-27 14:42:46 Re: [HACKERS] RE: Mysql comparison