aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Geoghegan <pg@bowt.ie>2020-04-30 14:33:13 -0700
committerPeter Geoghegan <pg@bowt.ie>2020-04-30 14:33:13 -0700
commitd9c501da70b079a7138f8b339339169d5bd24143 (patch)
tree3d9213df300e75160768d5d33942329f543003d9
parentdd1f645cc8831f55591e466c56b3953b9d100993 (diff)
downloadpostgresql-d9c501da70b079a7138f8b339339169d5bd24143.tar.gz
postgresql-d9c501da70b079a7138f8b339339169d5bd24143.zip
Add nbtree ScalarArrayOpExpr tests.
Add test coverage for the nbtutils.c routines concerned with IndexScans that have native ScalarArrayOpExpr quals. The ScalarArrayOpExpr specialized mark and restore routines, and the "find extreme element" routine now have some test coverage. These functions are probably infrequently exercised by real world queries, so having some coverage seems like a good idea. The mark and restore routines were originally added by a bugfix that came several weeks after the first stable release of Postgres 9.2 (see commit 70bc5833195).
-rw-r--r--src/test/regress/expected/join.out47
-rw-r--r--src/test/regress/sql/join.sql18
2 files changed, 65 insertions, 0 deletions
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out
index 761376b0079..a46b1573bd4 100644
--- a/src/test/regress/expected/join.out
+++ b/src/test/regress/expected/join.out
@@ -6176,6 +6176,53 @@ where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1;
1 | 2 | 1 | 2
(2 rows)
+-- Exercise array keys mark/restore B-Tree code
+explain (costs off) select * from j1
+inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
+where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 = any (array[1]);
+ QUERY PLAN
+----------------------------------------------------
+ Merge Join
+ Merge Cond: (j1.id1 = j2.id1)
+ Join Filter: (j1.id2 = j2.id2)
+ -> Index Scan using j1_id1_idx on j1
+ -> Index Scan using j2_id1_idx on j2
+ Index Cond: (id1 = ANY ('{1}'::integer[]))
+(6 rows)
+
+select * from j1
+inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
+where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 = any (array[1]);
+ id1 | id2 | id1 | id2
+-----+-----+-----+-----
+ 1 | 1 | 1 | 1
+ 1 | 2 | 1 | 2
+(2 rows)
+
+-- Exercise array keys "find extreme element" B-Tree code
+explain (costs off) select * from j1
+inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
+where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 >= any (array[1,5]);
+ QUERY PLAN
+-------------------------------------------------------
+ Merge Join
+ Merge Cond: (j1.id1 = j2.id1)
+ Join Filter: (j1.id2 = j2.id2)
+ -> Index Scan using j1_id1_idx on j1
+ -> Index Only Scan using j2_pkey on j2
+ Index Cond: (id1 >= ANY ('{1,5}'::integer[]))
+ Filter: ((id1 % 1000) = 1)
+(7 rows)
+
+select * from j1
+inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
+where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 >= any (array[1,5]);
+ id1 | id2 | id1 | id2
+-----+-----+-----+-----
+ 1 | 1 | 1 | 1
+ 1 | 2 | 1 | 2
+(2 rows)
+
reset enable_nestloop;
reset enable_hashjoin;
reset enable_sort;
diff --git a/src/test/regress/sql/join.sql b/src/test/regress/sql/join.sql
index 5fc66173690..1403e0ffe7b 100644
--- a/src/test/regress/sql/join.sql
+++ b/src/test/regress/sql/join.sql
@@ -2124,6 +2124,24 @@ select * from j1
inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1;
+-- Exercise array keys mark/restore B-Tree code
+explain (costs off) select * from j1
+inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
+where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 = any (array[1]);
+
+select * from j1
+inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
+where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 = any (array[1]);
+
+-- Exercise array keys "find extreme element" B-Tree code
+explain (costs off) select * from j1
+inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
+where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 >= any (array[1,5]);
+
+select * from j1
+inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
+where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 >= any (array[1,5]);
+
reset enable_nestloop;
reset enable_hashjoin;
reset enable_sort;