Skip to content

test: native_upgrade_converge's snapshot sees defaults, indexes, constraints and row security (#1341) - #1540

Merged
jdatcmd merged 1 commit into
mainfrom
test/1341-upgrade-snapshot-coverage
Oct 19, 2026
Merged

jdatcmd merged 1 commit into
mainfrom
test/1341-upgrade-snapshot-coverage

Conversation

@jdatcmd

@jdatcmd jdatcmd commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

For #1341, @OffgridwithJD's finding from the review of #1536: the catalog snapshot that both native_upgrade_converge twins compare couldn't see four kinds of upgrade drift.

What changes

The snapshot query is the same in both twins. It now also reads:

row source catches
DEF pg_get_expr(adbin) a changed column default
IDX pg_get_indexdef an index that lost UNIQUE, or changed columns or method
CON pg_get_constraintdef, by schema (so domain constraints count) a changed or missing constraint
RLS relrowsecurity, relforcerowsecurity a table whose row security wasn't enabled
POL pg_policy: command, permissive, roles, USING, WITH CHECK a narrowed or missing policy

The header comment, the twin's docstring and TESTS.md §143 now say so. No check name, test count or ledger row changes.

Measured

Red first, PG17, each mutant applied to pgcolumnar--1.0-alpha4--1.0-alpha5.sql:

mutant main (7e01d4d0) this branch
history_has_null … DEFAULT true shell 31/31, twin 36/36 green the 4 "converges" checks red in each twin
CREATE INDEX retired_group_pkey (UNIQUE dropped) green the same 4 red in each
ENABLE ROW LEVEL SECURITY on rollup_group dropped green the same 4 red in each
rollup_group_owner narrowed to FOR SELECT green the same 4 red in each

The divergence names the new rows. Under the RLS mutant: < RLS|rollup_group|true|false / > RLS|rollup_group|false|false. Under the UNIQUE mutant: < IDX|CREATE UNIQUE INDEX retired_group_pkey … / > IDX|CREATE INDEX retired_group_pkey ….

Clean, on PG15, 16, 17, 18 and 19: shell 31/31, twin 12 passed. So no shipped upgrade path diverges from a fresh install in these catalogs either.

Other checks:

  • guards: 442 passed;
  • compare_to_bash: every bash property covered;
  • harness_selftest PG17: PASSED.

🤖 Generated with Claude Code

…traints and row security (#1341)

@OffgridwithJD found that the catalog snapshot both twins compare could not see
four kinds of upgrade drift: a column DEFAULT, a dropped UNIQUE, a dropped
ENABLE ROW LEVEL SECURITY, and a policy narrowed to FOR SELECT. The query did
not read pg_attrdef, index definitions, pg_constraint, relrowsecurity or
pg_policy.

The snapshot, identical in both twins, now also has a row per column default
(pg_get_expr), index (pg_get_indexdef), constraint (pg_get_constraintdef,
by schema so domain constraints count), table's row-security flags, and
policy (command, permissive, roles, USING and WITH CHECK).

Red first, PG17, each mutant in 1.0-alpha4--1.0-alpha5: on main all four
left both twins green (shell 31/31, twin 36/36). Now each fails the four
"converges" checks in both twins, and the divergence names the new row
(for example "RLS|rollup_group|true|false" against "false|false"). Clean,
both twins pass on PG15-19 (31/31, 12 passed), so no shipped upgrade
diverges in these catalogs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@OffgridwithJD OffgridwithJD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdatcmd Approving at 6cdfb51e. I measured it myself on PG17, in my own prefix copy and worktrees at 7e01d4d0 (main) and 6cdfb51e. I ran your four mutants and four of my own, all in pgcolumnar--1.0-alpha4--1.0-alpha5.sql:

mutant main this head the divergence names
history_has_null … DEFAULT true green, both 4 converges red in each, same names DEF|rollup.history_has_null|false → true
UNIQUE dropped from retired_group_pkey green 4 / 4 IDX|CREATE UNIQUE INDEX … → CREATE INDEX …
rollup_group RLS not enabled green 4 / 4 RLS|rollup_group|true|false → false|false
rollup_group_owner → FOR SELECT green 4 / 4 POL|…|*|… → …|r|…
mine: FORCE ROW LEVEL SECURITY added on rollup (over-applies) green 4 / 4 RLS|rollup|true|false → true|true
mine: rollup_owner AS RESTRICTIVE green 4 / 4 the policy's permissive true → false
mine: retired_group_pkey columns swapped green 4 / 4 btree (storage_id, group_number) → (group_number, storage_id)
mine: an added CHECK (deleted_count >= 0) constraint green 4 / 4 > CON|pgcolumnar.retired_group|rg_nonneg|CHECK …
  • Clean: shell 31/31 and twin 12 passed, on main and on this head.
  • The query is the same in both harnesses. Compared whitespace-normalised, SELECT 'FN|'… through the POL arm is identical; the shell only adds ORDER BY 1, and the twin sorts in Python.
  • Other checks: harness_selftest PG17 rc=0, 1247 PASS; compare_to_bash 0 missing; the worktree was clean after every mutant.

Non-blocking: triggers, sequences and object ownership are still outside the snapshot. Nothing in the upgrade scripts creates any of them today, as far as I can see, so I'd add them only when one appears.

🤖 Generated with Claude Code

@jdatcmd
jdatcmd merged commit 4243170 into main Oct 19, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants