Hi, > The patch needs a rebase after today's commits. I will figure it out > and submit the updated version.
Rebased. > I also tried running the same JSON_TABLE ... PLAN (...) query manually > in psql and got the same syntax error. Works for me. Make sure you are using the latest version of the `master` branch. -- Best regards, Aleksander Alekseev
From e448384c6b3dd8516fb8fca62e417777af9a9f77 Mon Sep 17 00:00:00 2001 From: Aleksander Alekseev <[email protected]> Date: Fri, 10 Jul 2026 16:27:54 +0300 Subject: [PATCH v2] 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: https://postgr.es/m/caj7c6tp0kgan1hjtj1pytqvf0vyr+ce01oax9li_upgdg2n...@mail.gmail.com --- .../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 ae64dbed303..98e020f0221 100644 --- a/src/test/regress/expected/sqljson_jsontable.out +++ b/src/test/regress/expected/sqljson_jsontable.out @@ -1926,3 +1926,58 @@ CREATE OR REPLACE VIEW public.json_table_view_on_empty AS ) ERROR ON ERROR ) DROP VIEW json_table_view_on_empty; +-- 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 2a33aaec57f..ae833eec32d 100644 --- a/src/test/regress/sql/sqljson_jsontable.sql +++ b/src/test/regress/sql/sqljson_jsontable.sql @@ -1052,3 +1052,25 @@ SELECT * FROM JSON_TABLE(jsonb '{}', '$' AS p0 \sv json_table_view_on_empty; DROP VIEW json_table_view_on_empty; + +-- 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
