GROUP BY and inheritance issue

From: Manuel Rigger <rigger(dot)manuel(at)gmail(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: GROUP BY and inheritance issue
Date: 2019-07-02 12:47:03
Message-ID: CA+u7OA7VLKf_vEr6kLF3MnWSA9LToJYncgpNX2tQ-oWzYCBQAw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi everyone,

Consider the example below:

CREATE TABLE t0(c0 INT PRIMARY KEY, c1 INT);
CREATE TABLE t1(c0 INT) INHERITS (t0);
INSERT INTO t0(c0, c1) VALUES(0, 0);
INSERT INTO t1(c0, c1) VALUES(0, 1);
SELECT c0, c1 FROM t0 GROUP BY c0, c1; -- expected: 0|0 and 0|1, actual: 0|0

Note that column c0 in t0 and t1 are merged. The GROUP BY clause above
causes only one row to be fetched, while I'd expect that both are
fetched (which is the behavior when no GROUP BY is used). Section
5.9.1 [1] in the documentation mentions some caveats of using
inheritance, also stating that the PRIMARY KEY is not inherited. Is
this some implication of this or a bug?

Best,
Manuel

[1] https://www.postgresql.org/docs/11/ddl-inherit.html

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Rowley 2019-07-02 12:55:35 Re: BUG #15882: Select .... UNION ALL
Previous Message Manuel Rigger 2019-07-02 10:06:53 ALTER TABLE SET WITH OIDS fails after failed CONCURRENTLY index creation