aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Korotkov <akorotkov@postgresql.org>2024-11-25 09:05:26 +0200
committerAlexander Korotkov <akorotkov@postgresql.org>2024-11-25 09:07:30 +0200
commitd4d11940df94ee13166dda70271ff3b97e43bc9b (patch)
treee356b807cf7df8ff93562199cc37f8048b1a6bb8
parentd05a387d9d78a65db2c960d4f309a2649d183066 (diff)
downloadpostgresql-d4d11940df94ee13166dda70271ff3b97e43bc9b.tar.gz
postgresql-d4d11940df94ee13166dda70271ff3b97e43bc9b.zip
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
-rw-r--r--src/backend/optimizer/path/indxpath.c2
-rw-r--r--src/test/regress/expected/create_index.out10
-rw-r--r--src/test/regress/sql/create_index.sql4
3 files changed, 8 insertions, 8 deletions
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c
index 5d8d0c389c9..e50b6fd56a0 100644
--- a/src/backend/optimizer/path/indxpath.c
+++ b/src/backend/optimizer/path/indxpath.c
@@ -3430,7 +3430,7 @@ match_orclause_to_indexcol(PlannerInfo *root,
elems = (Datum *) palloc(sizeof(Datum) * list_length(consts));
foreach_node(Const, value, consts)
{
- Assert(!value->constisnull && value->constvalue);
+ Assert(!value->constisnull);
elems[i++] = value->constvalue;
}
diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out
index b003492c5c8..1b0a5f0e9e1 100644
--- a/src/test/regress/expected/create_index.out
+++ b/src/test/regress/expected/create_index.out
@@ -1843,15 +1843,15 @@ DROP TABLE onek_with_null;
--
EXPLAIN (COSTS OFF)
SELECT * FROM tenk1
- WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42);
- QUERY PLAN
-------------------------------------------------------------------------------
+ WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42 OR tenthous = 0);
+ QUERY PLAN
+--------------------------------------------------------------------------------
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)
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
---------+---------+-----+------+-----+--------+---------+----------+-------------+-----------+----------+-----+------+----------+----------+---------
42 | 5530 | 0 | 2 | 2 | 2 | 42 | 42 | 42 | 42 | 42 | 84 | 85 | QBAAAA | SEIAAA | OOOOxx
diff --git a/src/test/regress/sql/create_index.sql b/src/test/regress/sql/create_index.sql
index 216bd9660c3..ddd0d9ad396 100644
--- a/src/test/regress/sql/create_index.sql
+++ b/src/test/regress/sql/create_index.sql
@@ -728,9 +728,9 @@ DROP TABLE onek_with_null;
EXPLAIN (COSTS OFF)
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
- 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)
SELECT * FROM tenk1