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

Поиск
Список
Период
Сортировка
От jwieck@debis.com (Jan Wieck)
Тема Re: [HACKERS] views and group by (formerly: create view as selec
Дата
Msg-id m10c2A5-000EBcC@orion.SAPserv.Hamburg.dsh.de
обсуждение исходный текст
Ответ на RE: [HACKERS] views and group by (formerly: create view as selec t distinct)  (Michael J Davis <michael.j.davis@tvguide.com>)
Ответы Re: [HACKERS] views and group by (formerly: create view as selec  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: [HACKERS] views and group by (formerly: create view as selec  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Michael J Davis wrote:

>
> This implies that the "group by" clause is not supported in views.  I have
> created views that use the group by clause and they appear to work.  I have
> not verified the content of the records.  I would like to know more about
> what Jan means when he says that "group by" is not supported in views?  Does
> it mean that the content of the results could be unexpected or are they
> conditions where they may work and other conditions where they don't work?
> More info would be greatly appreciated.

    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!

    If  you have a view that uses GROUP BY and do a simple SELECT
    * from it, then it will work and return the correct  results.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#======================================== jwieck@debis.com (Jan Wieck) #

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Thomas Lockhart
Дата:
Сообщение: Re: [HACKERS] RE: Mysql comparison
Следующее
От: jwieck@debis.com (Jan Wieck)
Дата:
Сообщение: Re: [HACKERS] numeric data type on 6.5