Re: Fold NOT IN / <> ALL expressions containing NULL to FALSE - Mailing list pgsql-hackers

From Rustam ALLAKOV
Subject Re: Fold NOT IN / <> ALL expressions containing NULL to FALSE
Date
Msg-id 178931595876.1175.14939651707100946419.pgcf@coridan.postgresql.org
Whole thread
In response to Fold NOT IN / <> ALL expressions containing NULL to FALSE  (Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>)
Responses Re: Fold NOT IN / <> ALL expressions containing NULL to FALSE
List pgsql-hackers
The following review has been posted through the commitfest application:
make installcheck-world:  tested, passed
Implements feature:       tested, failed
Spec compliant:           tested, passed
Documentation:            tested, passed

Hi Ilia,

Denis Smirnov and I reviewed v2 and found these issues:

1. Multidimensional arrays

  CREATE TEMP TABLE mda (a int[]);
  INSERT INTO mda VALUES (NULL::int[]);
  SELECT * FROM mda WHERE 1 <> ALL (ARRAY[NULL::int[], a]);

  master: 1 row
  v2:     0 rows

2. ON CONFLICT with a partial index

  CREATE TEMP TABLE t (a int, b int);
  CREATE UNIQUE INDEX ti ON t (a) WHERE b <> ALL (ARRAY[1, NULL]);
  INSERT INTO t VALUES (1, 5)
    ON CONFLICT (a) WHERE b <> ALL (ARRAY[1, NULL]) DO NOTHING;

  master: succeeds
  v2:     ERROR: there is no unique or exclusion constraint matching
                 the ON CONFLICT specification

3. No folding under AND/OR

  CREATE TEMP TABLE s (x int);

  -- Plans with v2:
  EXPLAIN (COSTS OFF) SELECT * FROM s
    WHERE x NOT IN (42, NULL);              -- One-Time Filter: false
  EXPLAIN (COSTS OFF) SELECT * FROM s
    WHERE x NOT IN (42, NULL) AND x = 1;    -- Seq Scan
  EXPLAIN (COSTS OFF) SELECT * FROM s
    WHERE x NOT IN (42, NULL) OR false;     -- Seq Scan

Perhaps this could be handled in canonicalize_qual().

Regards,
--
Rustam Allakov
Denis Smirnov

The new status of this patch is: Waiting on Author

pgsql-hackers by date:

Previous
From: Vaibhav Dalvi
Date:
Subject: Re: Add PRODUCT() aggregate function
Next
From: Oleg Bartunov
Date:
Subject: Re: Support for 8-byte TOAST values, round two