aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Vondra <tomas.vondra@postgresql.org>2025-03-29 16:46:34 +0100
committerTomas Vondra <tomas.vondra@postgresql.org>2025-03-29 16:47:44 +0100
commitca738bdc4c9d32c05a6abd125ce495dfb82be492 (patch)
tree7650c50966803cf911242fdddc86e20b2d93d55b
parentec4327d106be745534592e8aff14effb716f4dc9 (diff)
downloadpostgresql-ca738bdc4c9d32c05a6abd125ce495dfb82be492.tar.gz
postgresql-ca738bdc4c9d32c05a6abd125ce495dfb82be492.zip
amcheck: Add a test with GIN index on JSONB data
Extend the existing test of GIN checks to also include an index on JSONB data, using the jsonb_path_ops opclass. This is a common enough usage of GIN that it makes sense to have better test coverage for it. Author: Mark Dilger <mark.dilger@enterprisedb.com> Reviewed-By: Tomas Vondra <tomas.vondra@enterprisedb.com> Reviewed-By: Kirill Reshke <reshkekirill@gmail.com> Discussion: https://postgr.es/m/BC221A56-977C-418E-A1B8-9EFC881D80C5%40enterprisedb.com
-rw-r--r--contrib/amcheck/expected/check_gin.out14
-rw-r--r--contrib/amcheck/sql/check_gin.sql12
2 files changed, 26 insertions, 0 deletions
diff --git a/contrib/amcheck/expected/check_gin.out b/contrib/amcheck/expected/check_gin.out
index bbcde80e627..93147de0ef1 100644
--- a/contrib/amcheck/expected/check_gin.out
+++ b/contrib/amcheck/expected/check_gin.out
@@ -62,3 +62,17 @@ SELECT gin_index_check('gin_check_text_array_idx');
-- cleanup
DROP TABLE gin_check_text_array;
+-- Test GIN over jsonb
+CREATE TABLE "gin_check_jsonb"("j" jsonb);
+INSERT INTO gin_check_jsonb values ('{"a":[["b",{"x":1}],["b",{"x":2}]],"c":3}');
+INSERT INTO gin_check_jsonb values ('[[14,2,3]]');
+INSERT INTO gin_check_jsonb values ('[1,[14,2,3]]');
+CREATE INDEX "gin_check_jsonb_idx" on gin_check_jsonb USING GIN("j" jsonb_path_ops);
+SELECT gin_index_check('gin_check_jsonb_idx');
+ gin_index_check
+-----------------
+
+(1 row)
+
+-- cleanup
+DROP TABLE gin_check_jsonb;
diff --git a/contrib/amcheck/sql/check_gin.sql b/contrib/amcheck/sql/check_gin.sql
index bbd9b9f8281..92ddbbc7a89 100644
--- a/contrib/amcheck/sql/check_gin.sql
+++ b/contrib/amcheck/sql/check_gin.sql
@@ -38,3 +38,15 @@ SELECT gin_index_check('gin_check_text_array_idx');
-- cleanup
DROP TABLE gin_check_text_array;
+
+-- Test GIN over jsonb
+CREATE TABLE "gin_check_jsonb"("j" jsonb);
+INSERT INTO gin_check_jsonb values ('{"a":[["b",{"x":1}],["b",{"x":2}]],"c":3}');
+INSERT INTO gin_check_jsonb values ('[[14,2,3]]');
+INSERT INTO gin_check_jsonb values ('[1,[14,2,3]]');
+CREATE INDEX "gin_check_jsonb_idx" on gin_check_jsonb USING GIN("j" jsonb_path_ops);
+
+SELECT gin_index_check('gin_check_jsonb_idx');
+
+-- cleanup
+DROP TABLE gin_check_jsonb;