From 71a3c19ba166945b94247c7e2c49ba97c729bb00 Mon Sep 17 00:00:00 2001 From: jian he Date: Fri, 29 Mar 2024 11:10:59 +0800 Subject: [PATCH v46 1/1] improve regress coverage test based on v46. --- .../regress/expected/sqljson_jsontable.out | 19 +++++++++++++++++++ src/test/regress/sql/sqljson_jsontable.sql | 9 +++++++++ 2 files changed, 28 insertions(+) diff --git a/src/test/regress/expected/sqljson_jsontable.out b/src/test/regress/expected/sqljson_jsontable.out index 4558f127..6d34d72f 100644 --- a/src/test/regress/expected/sqljson_jsontable.out +++ b/src/test/regress/expected/sqljson_jsontable.out @@ -11,12 +11,31 @@ LINE 1: SELECT * FROM JSON_TABLE(NULL, '$' COLUMNS ()); ^ SELECT * FROM JSON_TABLE (NULL::jsonb, '$' COLUMNS (v1 timestamp)) AS f (v1, v2); ERROR: JSON_TABLE function has 1 columns available but 2 columns specified +--duplicated column name +SELECT * FROM JSON_TABLE(jsonb'"1.23"', '$.a' COLUMNS (js2 int path '$', js2 int path '$')); +ERROR: duplicate JSON_TABLE column name: js2 +LINE 1: ...E(jsonb'"1.23"', '$.a' COLUMNS (js2 int path '$', js2 int pa... + ^ +--return composite data type. +create type comp as (a int, b int); +SELECT * FROM JSON_TABLE(jsonb '{"rec": "(1,2)"}', '$' COLUMNS (id FOR ORDINALITY, comp comp path '$.rec' omit quotes)) jt; + id | comp +----+------- + 1 | (1,2) +(1 row) + +drop type comp; -- NULL => empty table SELECT * FROM JSON_TABLE(NULL::jsonb, '$' COLUMNS (foo int)) bar; foo ----- (0 rows) +SELECT * FROM JSON_TABLE(jsonb'"1.23"', 'strict $.a' COLUMNS (js2 int PATH '$')); + js2 +----- +(0 rows) + -- SELECT * FROM JSON_TABLE(jsonb '123', '$' COLUMNS (item int PATH '$', foo int)) bar; diff --git a/src/test/regress/sql/sqljson_jsontable.sql b/src/test/regress/sql/sqljson_jsontable.sql index 2acc458a..10d4fc85 100644 --- a/src/test/regress/sql/sqljson_jsontable.sql +++ b/src/test/regress/sql/sqljson_jsontable.sql @@ -8,8 +8,17 @@ SELECT * FROM JSON_TABLE(NULL, '$' COLUMNS ()); SELECT * FROM JSON_TABLE (NULL::jsonb, '$' COLUMNS (v1 timestamp)) AS f (v1, v2); +--duplicated column name +SELECT * FROM JSON_TABLE(jsonb'"1.23"', '$.a' COLUMNS (js2 int path '$', js2 int path '$')); + +--return composite data type. +create type comp as (a int, b int); +SELECT * FROM JSON_TABLE(jsonb '{"rec": "(1,2)"}', '$' COLUMNS (id FOR ORDINALITY, comp comp path '$.rec' omit quotes)) jt; +drop type comp; + -- NULL => empty table SELECT * FROM JSON_TABLE(NULL::jsonb, '$' COLUMNS (foo int)) bar; +SELECT * FROM JSON_TABLE(jsonb'"1.23"', 'strict $.a' COLUMNS (js2 int PATH '$')); -- SELECT * FROM JSON_TABLE(jsonb '123', '$' base-commit: 0075d78947e3800c5a807f48fd901f16db91101b prerequisite-patch-id: ac36c2aa5bc95c1895cf2f75615eaad32efd31d4 -- 2.34.1