aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorAmit Langote <amitlan@postgresql.org>2024-06-28 13:59:13 +0900
committerAmit Langote <amitlan@postgresql.org>2024-06-28 14:01:43 +0900
commite3c1393efc31ac70de7b68e9a283ec3f2d7f9bd2 (patch)
tree501b572b01bbf7e85cd0096d20207612c9fd71ae /src/test
parent0ad8153c1f4c7129ff19e8a41d142001d35c8514 (diff)
downloadpostgresql-e3c1393efc31ac70de7b68e9a283ec3f2d7f9bd2.tar.gz
postgresql-e3c1393efc31ac70de7b68e9a283ec3f2d7f9bd2.zip
SQL/JSON: Prevent ON EMPTY for EXISTS columns in JSON_TABLE()
Due to an oversight in de3600452b61, the ON EMPTY clause was incorrectly allowed in the EXISTS column. Fix the grammar to prevent this. Discussion: https://postgr.es/m/CA%2BHiwqHh3YDXTpccgAo4CdfV9Mhy%2Bmg%3Doh6t8rfM5uLW1BJN4g%40mail.gmail.com
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/sqljson_jsontable.out5
-rw-r--r--src/test/regress/sql/sqljson_jsontable.sql3
2 files changed, 8 insertions, 0 deletions
diff --git a/src/test/regress/expected/sqljson_jsontable.out b/src/test/regress/expected/sqljson_jsontable.out
index cee90cead13..73039ea65eb 100644
--- a/src/test/regress/expected/sqljson_jsontable.out
+++ b/src/test/regress/expected/sqljson_jsontable.out
@@ -1067,3 +1067,8 @@ CREATE OR REPLACE VIEW public.jsonb_table_view7 AS
) sub
DROP VIEW jsonb_table_view7;
DROP TABLE s;
+-- Prevent ON EMPTY specification on EXISTS columns
+SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int exists empty object on empty));
+ERROR: syntax error at or near "empty"
+LINE 1: ...sonb '1', '$' COLUMNS (a int exists empty object on empty));
+ ^
diff --git a/src/test/regress/sql/sqljson_jsontable.sql b/src/test/regress/sql/sqljson_jsontable.sql
index a1f924146e0..bda57981481 100644
--- a/src/test/regress/sql/sqljson_jsontable.sql
+++ b/src/test/regress/sql/sqljson_jsontable.sql
@@ -518,3 +518,6 @@ SELECT sub.* FROM s,
\sv jsonb_table_view7
DROP VIEW jsonb_table_view7;
DROP TABLE s;
+
+-- Prevent ON EMPTY specification on EXISTS columns
+SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int exists empty object on empty));