From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | luy70(at)psu(dot)edu |
Subject: | BUG #17150: Unexpected outputs from the query |
Date: | 2021-08-17 16:30:10 |
Message-ID: | 17150-d22e14860d93d32e@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 17150
Logged by: Yu Liang
Email address: luy70(at)psu(dot)edu
PostgreSQL version: 14beta3
Operating system: Ubuntu 20.04 LTS
Description:
For query
```SQL
CREATE TABLE v0 ( v1 INT );
CREATE VIEW v2 AS SELECT * FROM v0 WHERE v1 = 0;
SELECT SUM(result) FROM ( SELECT ALL( true )::INT as result FROM v2 ORDER BY
( SELECT COUNT ( v1 ) ) ) as res;
-- Expected sum = "0", returns sum = "1"
```
Detailed outputs:
```
1: sum (typeid = 20, len = 8, typmod = -1, byval = t)
----
1: sum = "1" (typeid = 20, len = 8, typmod = -1, byval = t)
----
```
In the query above, given TABLE v0 has no data inserted, and v2 is a view
that observes on v0, we expect the SELECT statement that tries to sum up the
entries of v2 would output sum = "0". However, sum = "1" is returned. This
unexpected return can be fixed by removing "ORDER BY ( SELECT COUNT ( v1 )
)", then the query returns sum="0" as expected.
This behavior can be reproduced with an empty database, using Postgres
single mode. Postgres version = "PostgreSQL 14beta3 on x86_64-pc-linux-gnu,
compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit".
From | Date | Subject | |
---|---|---|---|
Next Message | Euler Taveira | 2021-08-17 17:00:15 | Re: BUG #17148: About --no-strict-names option and --quiet option of pg_amcheck command |
Previous Message | Daniel Gustafsson | 2021-08-17 15:57:36 | Re: BUG #17148: About --no-strict-names option and --quiet option of pg_amcheck command |