1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-20 00:42:27 +03:00

Remove the wrong assertion from match_orclause_to_indexcol()

Obviously, the constant could be zero.  Also, add the relevant check to
regression tests.

Reported-by: Richard Guo
Discussion: https://postgr.es/m/CAMbWs4-siKJdtWhcbqk4Y-xG12do2Ckm1qw672GNsSnDqL9FQg%40mail.gmail.com
This commit is contained in:
Alexander Korotkov 2024-11-25 09:05:26 +02:00
parent d05a387d9d
commit d4d11940df
3 changed files with 8 additions and 8 deletions

View File

@ -3430,7 +3430,7 @@ match_orclause_to_indexcol(PlannerInfo *root,
elems = (Datum *) palloc(sizeof(Datum) * list_length(consts)); elems = (Datum *) palloc(sizeof(Datum) * list_length(consts));
foreach_node(Const, value, consts) foreach_node(Const, value, consts)
{ {
Assert(!value->constisnull && value->constvalue); Assert(!value->constisnull);
elems[i++] = value->constvalue; elems[i++] = value->constvalue;
} }

View File

@ -1843,15 +1843,15 @@ DROP TABLE onek_with_null;
-- --
EXPLAIN (COSTS OFF) EXPLAIN (COSTS OFF)
SELECT * FROM tenk1 SELECT * FROM tenk1
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42); WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42 OR tenthous = 0);
QUERY PLAN QUERY PLAN
------------------------------------------------------------------------------ --------------------------------------------------------------------------------
Index Scan using tenk1_thous_tenthous on tenk1 Index Scan using tenk1_thous_tenthous on tenk1
Index Cond: ((thousand = 42) AND (tenthous = ANY ('{1,3,42}'::integer[]))) Index Cond: ((thousand = 42) AND (tenthous = ANY ('{1,3,42,0}'::integer[])))
(2 rows) (2 rows)
SELECT * FROM tenk1 SELECT * FROM tenk1
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42); WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42 OR tenthous = 0);
unique1 | unique2 | two | four | ten | twenty | hundred | thousand | twothousand | fivethous | tenthous | odd | even | stringu1 | stringu2 | string4 unique1 | unique2 | two | four | ten | twenty | hundred | thousand | twothousand | fivethous | tenthous | odd | even | stringu1 | stringu2 | string4
---------+---------+-----+------+-----+--------+---------+----------+-------------+-----------+----------+-----+------+----------+----------+--------- ---------+---------+-----+------+-----+--------+---------+----------+-------------+-----------+----------+-----+------+----------+----------+---------
42 | 5530 | 0 | 2 | 2 | 2 | 42 | 42 | 42 | 42 | 42 | 84 | 85 | QBAAAA | SEIAAA | OOOOxx 42 | 5530 | 0 | 2 | 2 | 2 | 42 | 42 | 42 | 42 | 42 | 84 | 85 | QBAAAA | SEIAAA | OOOOxx

View File

@ -728,9 +728,9 @@ DROP TABLE onek_with_null;
EXPLAIN (COSTS OFF) EXPLAIN (COSTS OFF)
SELECT * FROM tenk1 SELECT * FROM tenk1
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42); WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42 OR tenthous = 0);
SELECT * FROM tenk1 SELECT * FROM tenk1
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42); WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42 OR tenthous = 0);
EXPLAIN (COSTS OFF) EXPLAIN (COSTS OFF)
SELECT * FROM tenk1 SELECT * FROM tenk1