Skip to content

Commit e290dc5

Browse files
akorotkovpashkinelfe
authored andcommitted
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
1 parent d4b2625 commit e290dc5

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/backend/optimizer/path/indxpath.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3468,8 +3468,7 @@ match_orclause_to_indexcol(PlannerInfo *root,
34683468
{
34693469
Const *value = (Const *) lfirst(lc);
34703470

3471-
Assert(!value->constisnull && value->constvalue);
3472-
3471+
Assert(!value->constisnull);
34733472
elems[i++] = value->constvalue;
34743473
}
34753474

src/test/regress/expected/create_index.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,15 +1837,15 @@ DROP TABLE onek_with_null;
18371837
--
18381838
EXPLAIN (COSTS OFF)
18391839
SELECT * FROM tenk1
1840-
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42);
1841-
QUERY PLAN
1842-
------------------------------------------------------------------------------
1840+
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42 OR tenthous = 0);
1841+
QUERY PLAN
1842+
--------------------------------------------------------------------------------
18431843
Index Scan using tenk1_thous_tenthous on tenk1
1844-
Index Cond: ((thousand = 42) AND (tenthous = ANY ('{1,3,42}'::integer[])))
1844+
Index Cond: ((thousand = 42) AND (tenthous = ANY ('{1,3,42,0}'::integer[])))
18451845
(2 rows)
18461846

18471847
SELECT * FROM tenk1
1848-
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42);
1848+
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42 OR tenthous = 0);
18491849
unique1 | unique2 | two | four | ten | twenty | hundred | thousand | twothousand | fivethous | tenthous | odd | even | stringu1 | stringu2 | string4
18501850
---------+---------+-----+------+-----+--------+---------+----------+-------------+-----------+----------+-----+------+----------+----------+---------
18511851
42 | 5530 | 0 | 2 | 2 | 2 | 42 | 42 | 42 | 42 | 42 | 84 | 85 | QBAAAA | SEIAAA | OOOOxx

src/test/regress/sql/create_index.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,9 @@ DROP TABLE onek_with_null;
727727

728728
EXPLAIN (COSTS OFF)
729729
SELECT * FROM tenk1
730-
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42);
730+
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42 OR tenthous = 0);
731731
SELECT * FROM tenk1
732-
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42);
732+
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42 OR tenthous = 0);
733733

734734
EXPLAIN (COSTS OFF)
735735
SELECT * FROM tenk1

0 commit comments

Comments
 (0)