public inbox for [email protected]
help / color / mirror / Atom feedFrom: Aleksander Alekseev <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: [PATCH] Cover get_json_table_plan() with tests
Date: Fri, 10 Jul 2026 16:44:06 +0300
Message-ID: <CAJ7c6TP0kgaN1Hjtj1PYtQVF0vyr+ce01oAx9Li_UpGDG2NMmA@mail.gmail.com> (raw)
Hi,
I noticed that get_json_table_plan() is never executed by the existing
tests. The proposed patch fixes this.
--
Best regards,
Aleksander Alekseev
Attachments:
[text/x-patch] v1-0001-Cover-get_json_table_plan-with-tests.patch (3.8K, ../CAJ7c6TP0kgaN1Hjtj1PYtQVF0vyr+ce01oAx9Li_UpGDG2NMmA@mail.gmail.com/2-v1-0001-Cover-get_json_table_plan-with-tests.patch)
download | inline diff:
From a99b5e95dd095a04886b81f4ae3a7de94664fb70 Mon Sep 17 00:00:00 2001
From: Aleksander Alekseev <[email protected]>
Date: Fri, 10 Jul 2026 16:27:54 +0300
Subject: [PATCH v1] Cover get_json_table_plan() with tests
Function get_json_table() executes get_json_table_plan() only when
json_table_plan_is_default() == false. For this reason the existing tests
didn't cover get_json_table_plan() before.
Author: Aleksander Alekseev <[email protected]>
Reviewed-by: TODO FIXME
Discussion: TODO FIXME
---
.../regress/expected/sqljson_jsontable.out | 55 +++++++++++++++++++
src/test/regress/sql/sqljson_jsontable.sql | 22 ++++++++
2 files changed, 77 insertions(+)
diff --git a/src/test/regress/expected/sqljson_jsontable.out b/src/test/regress/expected/sqljson_jsontable.out
index 1530ef8afe0..fc8e8d7e1a7 100644
--- a/src/test/regress/expected/sqljson_jsontable.out
+++ b/src/test/regress/expected/sqljson_jsontable.out
@@ -1847,3 +1847,58 @@ CREATE OR REPLACE VIEW public.json_table_view9 AS
)
)
DROP VIEW json_table_view8, json_table_view9;
+-- Test get_json_table_plan()
+-- covers the INNER branch and the UNION branch
+CREATE VIEW jt_plan_inner_union AS
+SELECT * FROM JSON_TABLE(
+ jsonb 'null', '$' AS p
+ COLUMNS (NESTED PATH '$[*]' AS p1 COLUMNS (a int),
+ NESTED PATH '$[*]' AS p2 COLUMNS (b int))
+ PLAN (p INNER (p1 UNION p2))
+);
+\sv jt_plan_inner_union
+CREATE OR REPLACE VIEW public.jt_plan_inner_union AS
+ SELECT a,
+ b
+ FROM JSON_TABLE(
+ 'null'::jsonb, '$' AS p
+ COLUMNS (
+ NESTED PATH '$[*]' AS p1
+ COLUMNS (
+ a integer PATH '$."a"'
+ ),
+ NESTED PATH '$[*]' AS p2
+ COLUMNS (
+ b integer PATH '$."b"'
+ )
+ )
+ PLAN (p INNER (p1 UNION p2))
+ )
+DROP VIEW jt_plan_inner_union;
+-- covers the OUTER branch and the CROSS branch
+CREATE VIEW jt_plan_outer_cross AS
+SELECT * FROM JSON_TABLE(
+ jsonb 'null', '$' AS p
+ COLUMNS (NESTED PATH '$[*]' AS p1 COLUMNS (a int),
+ NESTED PATH '$[*]' AS p2 COLUMNS (b int))
+ PLAN (p OUTER (p1 CROSS p2))
+);
+\sv jt_plan_outer_cross
+CREATE OR REPLACE VIEW public.jt_plan_outer_cross AS
+ SELECT a,
+ b
+ FROM JSON_TABLE(
+ 'null'::jsonb, '$' AS p
+ COLUMNS (
+ NESTED PATH '$[*]' AS p1
+ COLUMNS (
+ a integer PATH '$."a"'
+ ),
+ NESTED PATH '$[*]' AS p2
+ COLUMNS (
+ b integer PATH '$."b"'
+ )
+ )
+ PLAN (p OUTER (p1 CROSS p2))
+ )
+DROP VIEW jt_plan_outer_cross;
diff --git a/src/test/regress/sql/sqljson_jsontable.sql b/src/test/regress/sql/sqljson_jsontable.sql
index d71d57e99b2..74903a75fc8 100644
--- a/src/test/regress/sql/sqljson_jsontable.sql
+++ b/src/test/regress/sql/sqljson_jsontable.sql
@@ -1004,3 +1004,25 @@ CREATE VIEW json_table_view9 AS SELECT * from JSON_TABLE('"a"', '$' COLUMNS (a t
\sv json_table_view9;
DROP VIEW json_table_view8, json_table_view9;
+
+-- Test get_json_table_plan()
+-- covers the INNER branch and the UNION branch
+CREATE VIEW jt_plan_inner_union AS
+SELECT * FROM JSON_TABLE(
+ jsonb 'null', '$' AS p
+ COLUMNS (NESTED PATH '$[*]' AS p1 COLUMNS (a int),
+ NESTED PATH '$[*]' AS p2 COLUMNS (b int))
+ PLAN (p INNER (p1 UNION p2))
+);
+\sv jt_plan_inner_union
+DROP VIEW jt_plan_inner_union;
+-- covers the OUTER branch and the CROSS branch
+CREATE VIEW jt_plan_outer_cross AS
+SELECT * FROM JSON_TABLE(
+ jsonb 'null', '$' AS p
+ COLUMNS (NESTED PATH '$[*]' AS p1 COLUMNS (a int),
+ NESTED PATH '$[*]' AS p2 COLUMNS (b int))
+ PLAN (p OUTER (p1 CROSS p2))
+);
+\sv jt_plan_outer_cross
+DROP VIEW jt_plan_outer_cross;
--
2.43.0
view thread (3+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: [PATCH] Cover get_json_table_plan() with tests
In-Reply-To: <CAJ7c6TP0kgaN1Hjtj1PYtQVF0vyr+ce01oAx9Li_UpGDG2NMmA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox