From: | Xiong He <iihero(at)qq(dot)com> |
---|---|
To: | pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Possible wrong result with some "in" subquery with non-existing columns |
Date: | 2023-01-17 08:00:09 |
Message-ID: | tencent_E8F863DB3246FD47EBEE85FFF5E56B020508@qq.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Dear All,
This is a common scenario in below query. I just verified in the pg14.x.
mydb=# create table test1(id1 int primary key, col2 varchar(32));
CREATE TABLE
mydb=# create table test2(id2 int primary key, col2 varchar(32));
CREATE TABLE
mydb=# insert into test1 values(1, 'wang');
INSERT 0 1
mydb=# insert into test2 values(2, 'tttt');
INSERT 0 1
mydb=# select * from test1 where id1 in (select id1 from test2 where id2 = 2);
id1 | col2
-----+------
1 | wang
(1 row)
mydb=# insert into test1 values(3, 'wang');
INSERT 0 1
mydb=# select * from test1 where id1 in (select id1 from test2 where id2 = 2);
id1 | col2
-----+------
1 | wang
3 | wang
(2 rows)
In the above query: id1 is not a column of table test2.
Should not we expect this should be en error instead of it thinking it's a column from the table : test1?
Regards,
Xiong
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2023-01-17 08:04:18 | Re: Possible wrong result with some "in" subquery with non-existing columns |
Previous Message | Amit Kapila | 2023-01-17 00:53:45 | Re: DROP DATABASE deadlocks with logical replication worker in PG 15.1 |