Add persisted JSON_TABLE PLAN views for dump/restore round-trip tests#67
Draft
NikolayS wants to merge 1 commit into
Draft
Add persisted JSON_TABLE PLAN views for dump/restore round-trip tests#67NikolayS wants to merge 1 commit into
NikolayS wants to merge 1 commit into
Conversation
The JSON_TABLE regression tests exercised the tricky PLAN-clause deparse
paths (nested parent/child joins, sibling UNION/CROSS joins, PLAN DEFAULT,
generated-vs-user path name collisions, per-column and table-level ON
ERROR/ON EMPTY) only through views that are dropped before the end of the
file, or through bare SELECTs. A construct is only truly round-trip tested
if it is persisted as a view in the regression database, because
pg_upgrade's 002_pg_upgrade.pl dump-compares every surviving object across a
dump/restore and upgrade cycle. None of the JSON_TABLE PLAN views survived,
so the recent deparse fixes had no dump/restore coverage.
Add a block of views at the end of sqljson_jsontable.sql that are left in
place, each covering a distinct PLAN construct:
- jsonb_table_view_pc_plan: nested parent/child two levels deep with an
explicit parenthesized child join, PLAN (p0 OUTER (p1 INNER p11)); the
parentheses must survive deparsing or the plan reparses to a different
tree.
- jsonb_table_view_sibling_plan: sibling paths joined with explicit CROSS
under a parent/child OUTER join.
- jsonb_table_view_mixed_plan: the trickiest shape,
PLAN (p OUTER ((pb INNER pb1) CROSS (pc OUTER pc1))), plus a
deparse-reparse fixed-point check that recreates the view from its own
pg_get_viewdef() output and asserts the two definitions are identical.
- jsonb_table_view_default_plan: PLAN DEFAULT (INNER, UNION), which
normalizes to an explicit PLAN over generated path names.
- jsonb_table_view_name_collision: user column/path names deliberately
matching the generated json_table_path_N pattern mixed with unnamed
paths, verifying no column is silently dropped.
- jsonb_table_view_on_behavior: per-column and table-level ON ERROR/ON
EMPTY, verifying a column's explicit behavior is preserved and the
table-level ERROR ON ERROR does not cascade.
Each view pins its pg_get_viewdef() output and runs a SELECT that checks the
resulting rows, so a regression that drops a column or mangles a plan is
caught both here and by the pg_upgrade dump comparison.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PtxA6B4d47ietk5dGsseuP
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a block of persisted (not dropped) views over JSON_TABLE
PLAN-clause variants at the end ofsrc/test/regress/sql/sqljson_jsontable.sql, with expected output updated.Why
Three JSON_TABLE
PLAN-clause deparse bugs were recently fixed:160ef27— deparse lost the parentheses around a nested parent/child join (PLAN (p0 OUTER (p1 INNER p11))was emitted asPLAN (p0 OUTER p1 INNER p11)), a dump/restore hazard.cd5fd08— generatedjson_table_path_Nnames could collide with user-supplied path names, silently dropping a sibling path and its columns.af6fad8— reverted the ON ERROR cascade, restoring per-column ON ERROR/ON EMPTY deparse.Structural gap: a construct is only truly round-trip tested if it is persisted as a view in the regression database, because
pg_upgrade/t/002_pg_upgrade.pldump-compares every surviving object across a dump/restore + upgrade cycle. The existing JSON_TABLE PLAN views are all dropped before end-of-file, so these fixes had no dump/restore coverage. Every added view is left in place.Views added
jsonb_table_view_pc_planPLAN (p0 OUTER (p1 INNER p11))— parenthesized child join (160ef27)jsonb_table_view_sibling_planCROSSunder parent/childOUTERjsonb_table_view_mixed_planPLAN (p OUTER ((pb INNER pb1) CROSS (pc OUTER pc1)))— trickiest shape; plus in-test deparse-reparse fixed-point checkjsonb_table_view_default_planPLAN DEFAULT (INNER, UNION)→ normalized explicit PLAN over generated namesjsonb_table_view_name_collisionjson_table_path_Npattern + unnamed paths, verifying no column is silently dropped (cd5fd08)jsonb_table_view_on_behaviorERROR ON ERRORdoes not cascade (af6fad8)Each view pins its
pg_get_viewdef()output and runs aSELECTthat checks the resulting rows (e.g.jsonb_table_view_name_collisionreturns all three columns' rows — the cd5fd08 failure mode would drop one).The
jsonb_table_view_mixed_planblock also proves round-trip stability inside the test itself: it recreates a second view from the first view's exactpg_get_viewdef()output (via\gexec) and asserts the two definitions are byte-for-byte identical (deparse_roundtrip_stable = t).Test evidence
sqljson_jsontableregression test: passing (ok 1 - sqljson_jsontable,All 1 tests passed).t.json_table_path_1.Test-only change; no backend code is modified.
Closes #61
🤖 Generated with Claude Code
https://claude.ai/code/session_01PtxA6B4d47ietk5dGsseuP
Generated by Claude Code