Another bug in GROUP BY for INSERT - Mailing list pgsql-sql

From Pushkar Piggott
Subject Another bug in GROUP BY for INSERT
Date
Msg-id 199808270100.LAA13217@guava.citr.com.au
Whole thread Raw
List pgsql-sql
Apparently the ordering of columns affects the applicability of
GROUP BY for INSERT:

<pkp@cooloola> createdb pkptest
<pkp@cooloola> psql pkptest
Welcome to the POSTGRESQL interactive sql monitor:
  Please read the file COPYRIGHT for copyright terms of POSTGRESQL

   type \? for help on slash commands
   type \q to quit
   type \g or terminate with semicolon to execute query
 You are currently connected to the database: pkptest

pkptest=> CREATE TABLE a_foo (a_Index int4,
pkptest->                     bar int4);
CREATE
pkptest=> INSERT INTO a_foo
pkptest-> VALUES (1, 1);
INSERT 253866 1
pkptest=> INSERT INTO a_foo
pkptest-> VALUES (1, 2);
INSERT 253867 1
pkptest=> INSERT INTO a_foo
pkptest-> VALUES (2, 1);
INSERT 253868 1
pkptest=> CREATE TABLE b_foo (a_Index int4,
pkptest->                     count int4);
CREATE
pkptest=> INSERT INTO b_foo
pkptest->         SELECT a_Index, COUNT(*)
pkptest->         FROM a_foo
pkptest->         GROUP BY a_Index;
INSERT 0 2
pkptest=> SELECT * FROM b_foo;
a_index|count
-------+-----
      1|    2
      2|    1
(2 rows)

--------- Now try again with columns reversed in b_foo ---------

pkptest=> DELETE FROM b_foo;
DELETE 2
pkptest=> DROP TABLE b_foo;
DROP
pkptest=> CREATE TABLE b_foo (count int4,
pkptest->                     a_Index int4);
CREATE
pkptest=> INSERT INTO b_foo
pkptest->         SELECT COUNT(*), a_Index
pkptest->         FROM a_foo
pkptest->         GROUP BY a_Index;
ERROR:  parser: aggregates not allowed in GROUP BY clause

cheers
Pushkar
--
------------------------------------------------------------------------------
Dr Pushkar Piggott                         |
                                           | Phone: +61-7-3259-2369
CiTR Pty Ltd                               | Fax:   +61-7-3259-2259
John Oxley Centre                          |
339 Coronation Drive                       | Email: p.piggott@citr.com.au
MILTON                                     |
QLD 4064 AUSTRALIA                         | Postal: PO Box 1643
------------------------------------------------------------------------------

pgsql-sql by date:

Previous
From: Pushkar Piggott
Date:
Subject: Bug in GROUP BY for INSERT
Next
From: Herouth Maoz
Date:
Subject: Re: [SQL] parts of date_part()