appendStringInfoString(context->buf,
s->outerJoin ? " OUTER " : " INNER ");
get_json_table_plan(tf, s->child, context,
- IsA(s->child, JsonTableSiblingJoin));
+ IsA(s->child, JsonTableSiblingJoin) ||
+ castNode(JsonTablePathScan, s->child)->child);
}
}
else if (IsA(plan, JsonTableSiblingJoin))
DROP VIEW jsonb_table_view5;
DROP VIEW jsonb_table_view6;
DROP DOMAIN jsonb_test_domain;
+-- Parentheses around a nested parent/child plan must survive a dump, so the
+-- plan parses back to the same tree.
+CREATE VIEW jsonb_table_view_plan AS
+SELECT * FROM JSON_TABLE(
+ jsonb 'null', '$' AS p0
+ COLUMNS (
+ NESTED PATH '$.a[*]' AS p1 COLUMNS (
+ NESTED PATH '$.b[*]' AS p11 COLUMNS (b int PATH '$')
+ )
+ )
+ PLAN (p0 OUTER (p1 INNER p11))
+);
+\sv jsonb_table_view_plan
+CREATE OR REPLACE VIEW public.jsonb_table_view_plan AS
+ SELECT b
+ FROM JSON_TABLE(
+ 'null'::jsonb, '$' AS p0
+ COLUMNS (
+ NESTED PATH '$."a"[*]' AS p1
+ COLUMNS (
+ NESTED PATH '$."b"[*]' AS p11
+ COLUMNS (
+ b integer PATH '$'
+ )
+ )
+ )
+ PLAN (p0 OUTER (p1 INNER p11))
+ )
+DROP VIEW jsonb_table_view_plan;
-- JSON_TABLE: only one FOR ORDINALITY columns allowed
SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (id FOR ORDINALITY, id2 FOR ORDINALITY, a int PATH '$.a' ERROR ON EMPTY)) jt;
ERROR: only one FOR ORDINALITY column is allowed
DROP VIEW jsonb_table_view6;
DROP DOMAIN jsonb_test_domain;
+-- Parentheses around a nested parent/child plan must survive a dump, so the
+-- plan parses back to the same tree.
+CREATE VIEW jsonb_table_view_plan AS
+SELECT * FROM JSON_TABLE(
+ jsonb 'null', '$' AS p0
+ COLUMNS (
+ NESTED PATH '$.a[*]' AS p1 COLUMNS (
+ NESTED PATH '$.b[*]' AS p11 COLUMNS (b int PATH '$')
+ )
+ )
+ PLAN (p0 OUTER (p1 INNER p11))
+);
+\sv jsonb_table_view_plan
+DROP VIEW jsonb_table_view_plan;
+
-- JSON_TABLE: only one FOR ORDINALITY columns allowed
SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (id FOR ORDINALITY, id2 FOR ORDINALITY, a int PATH '$.a' ERROR ON EMPTY)) jt;
SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (id FOR ORDINALITY, a int PATH '$' ERROR ON EMPTY)) jt;