Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d4d1194

Browse files
committed
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 d05a387 commit d4d1194

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/backend/optimizer/path/indxpath.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3430,7 +3430,7 @@ match_orclause_to_indexcol(PlannerInfo *root,
34303430
elems = (Datum *) palloc(sizeof(Datum) * list_length(consts));
34313431
foreach_node(Const, value, consts)
34323432
{
3433-
Assert(!value->constisnull && value->constvalue);
3433+
Assert(!value->constisnull);
34343434

34353435
elems[i++] = value->constvalue;
34363436
}

src/test/regress/expected/create_index.out

+5-5
Original file line numberDiff line numberDiff line change
@@ -1843,15 +1843,15 @@ DROP TABLE onek_with_null;
18431843
--
18441844
EXPLAIN (COSTS OFF)
18451845
SELECT * FROM tenk1
1846-
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42);
1847-
QUERY PLAN
1848-
------------------------------------------------------------------------------
1846+
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42 OR tenthous = 0);
1847+
QUERY PLAN
1848+
--------------------------------------------------------------------------------
18491849
Index Scan using tenk1_thous_tenthous on tenk1
1850-
Index Cond: ((thousand = 42) AND (tenthous = ANY ('{1,3,42}'::integer[])))
1850+
Index Cond: ((thousand = 42) AND (tenthous = ANY ('{1,3,42,0}'::integer[])))
18511851
(2 rows)
18521852

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

src/test/regress/sql/create_index.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,9 @@ DROP TABLE onek_with_null;
728728

729729
EXPLAIN (COSTS OFF)
730730
SELECT * FROM tenk1
731-
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42);
731+
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42 OR tenthous = 0);
732732
SELECT * FROM tenk1
733-
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42);
733+
WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42 OR tenthous = 0);
734734

735735
EXPLAIN (COSTS OFF)
736736
SELECT * FROM tenk1

0 commit comments

Comments
 (0)