Question on not-in and array-eq

Поиск
Список
Период
Сортировка
От Zhenghua Lyu
Тема Question on not-in and array-eq
Дата
Msg-id CO6PR05MB7506DFE29434911C9290F2DCB56F9@CO6PR05MB7506.namprd05.prod.outlook.com
обсуждение исходный текст
Ответы Re: Question on not-in and array-eq  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-hackers
Hi,
    
   I run the following SQL in Postgres (14_STABLE), and got the results:  
zlyu=# create table t1(a int, b int);
CREATE TABLE
zlyu=# create table t2(a int, b int);
CREATE TABLE
zlyu=# insert into t1 values (null, 1);
INSERT 0 1
zlyu=# insert into t2 values (1, 1);
INSERT 0 1
zlyu=# select * from t1 where (a, b) not in (select * from t2);
 a | b
---+---
(0 rows)

zlyu=# select * from t1 where (a, b) in (select * from t2);
 a | b
---+---
(0 rows)

zlyu=# select * from t1 where array[a, b] in (select array[a,b] from t2);
 a | b
---+---
(0 rows)

zlyu=# select * from t1 where array[a, b] not in (select array[a,b] from t2);
 a | b
---+---
   | 1
(1 row)

I run the SQL without array expr​ in other DBs(orcale, sqlite, ...), they all behave
the same as Postgres.

It seems a bit confusing for me that 'not in' and 'in' the same subquery both return 0
rows, but the table contains data.

Also, manually using array expression behaves differently from the first SQL. For not in case,
I step in the code, and find array_eq will consider null = null as true, however ExecSubPlan will
consider null as unprovable and exclude that row.

How to understand the result? It seems SQL standard does not mention array operation for null
value.

Thanks!

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Dagfinn Ilmari Mannsåker
Дата:
Сообщение: Re: Readd use of TAP subtests
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Appetite for Frama-C annotations?