From: | Richard Guo <guofenglinux(at)gmail(dot)com> |
---|---|
To: | bajinsheng(at)u(dot)nus(dot)edu, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #18091: Unexpected Result by enable_material |
Date: | 2023-09-07 07:51:29 |
Message-ID: | CAMbWs49OsEPutOcYaWXUrph3Z-F0p_QsrF_P1kxGBPT5rc+vgA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Thu, Sep 7, 2023 at 3:10 PM PG Bug reporting form <noreply(at)postgresql(dot)org>
wrote:
> Hello,
>
> The same query returns different results when enable_material is changed:
>
> CREATE TABLE t2(c1 DECIMAL, c2 serial);
> CREATE TABLE t4(c0 TEXT);
> INSERT INTO t2(c2) VALUES(1), (2);
> INSERT INTO t2(c1) VALUES(0.1);
> INSERT INTO t4(c0) VALUES('a'), ('b'), ('c');
>
> SET enable_material=true;
> SELECT DISTINCT ON (t2.c1) t2.c2 FROM t2, t4; -- {1}, {1}
> SET enable_material=false;
> SELECT DISTINCT ON (t2.c1) t2.c2 FROM t2, t4; -- {1}, {2}
With DISTINCT ON, only the first row of each set is kept, which is
unpredictable. Usually you're supposed to use ORDER BY to get the
desired row.
Thanks
Richard
From | Date | Subject | |
---|---|---|---|
Next Message | Lepikhov Andrei | 2023-09-07 08:25:36 | Re: BUG #18077: PostgreSQL server subprocess crashed by a SELECT statement with WITH clause |
Previous Message | Francisco Olarte | 2023-09-07 07:35:16 | Re: BUG #18092: Unexpected Result by enable_seqscan |