Fix pg_upgrade update-path bug (omit_column != ANY -> != ALL; rebuild pg_class_v)#42
Open
jnasbyupgrade wants to merge 1 commit into
Open
Fix pg_upgrade update-path bug (omit_column != ANY -> != ALL; rebuild pg_class_v)#42jnasbyupgrade wants to merge 1 commit into
jnasbyupgrade wants to merge 1 commit into
Conversation
… pg_class_v The __cat_tools.omit_column helper in the 0.2.0->0.2.2 and 0.2.1->0.2.2 update scripts used `attname != ANY(omit)`, which is a no-op for a multi-element omit list: a row is kept as long as it differs from *any* single element, so relhasoids/relhaspkey were never stripped from _cat_tools.pg_class_v. A database updated along that path and later binary-pg_upgraded to PG12+ (where pg_class no longer has relhasoids/relhaspkey) ends up with a view referencing non-existent catalog columns, and pg_upgrade fails. Fixes: - Correct the predicate to `attname != ALL(omit)` in all three update scripts so multi-element omit lists actually drop every listed column. - In 0.2.0->0.2.2 and 0.2.1->0.2.2, force a full DROP+CREATE rebuild of the _cat_tools.pg_class_v dependency chain (in reverse dependency order, no CASCADE) with the corrected column list. CREATE OR REPLACE VIEW cannot drop columns, so the chain must be rebuilt. - Add a field-repair rebuild block to 0.2.2->0.2.3 so an already-broken published-0.2.2 database is repaired when it updates to 0.2.3. On a correct 0.2.2 (fresh install, or a PG major where those columns never existed) it is a harmless no-op rebuild. Verified via the new_functions branch's 10->18 bridge pg_upgrade leg, which exercises the 0.2.0->0.2.2->pg_upgrade path and passes with this fix. Master's own CI has no bridge leg, so it cannot exercise that path directly; master's extension-update-test (PG10) does exercise the fixed 0.2.0->0.2.2 / 0.2.1->0.2.2 scripts (CREATE 0.2.0, ALTER UPDATE). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Summary
The
__cat_tools.omit_columnhelper in the0.2.0->0.2.2and0.2.1->0.2.2update scripts usedattname != ANY(omit). For a multi-element omit list this is a no-op: a row is kept as long as it differs from any single element, sorelhasoids/relhaspkeywere never stripped from_cat_tools.pg_class_v.A database updated along that path and later binary-pg_upgraded to PG12+ (where
pg_classno longer hasrelhasoids/relhaspkey) ends up with a view referencing non-existent catalog columns, andpg_upgradefails.Fix
attname != ALL(omit)in all three update scripts so multi-element omit lists actually drop every listed column.0.2.0->0.2.2and0.2.1->0.2.2, force a fullDROP+CREATErebuild of the_cat_tools.pg_class_vdependency chain (reverse dependency order, noCASCADE) with the corrected column list.CREATE OR REPLACE VIEWcannot drop columns, so the chain must be rebuilt.0.2.2->0.2.3so an already-broken published-0.2.2database is repaired when it updates to0.2.3. On a correct0.2.2(fresh install, or a PG major where those columns never existed) it is a harmless no-op rebuild.Verification
This fix is verified via the
new_functionsbranch's10->18bridge pg_upgrade leg, which exercises the0.2.0->0.2.2->pg_upgradepath and passes with this change.Master's own CI has no bridge leg, so it cannot exercise the
0.2.0->0.2.2->pg_upgradepath directly. However, master'sextension-update-test(PG10) does exercise the fixed0.2.0->0.2.2/0.2.1->0.2.2scripts (CREATE 0.2.0, ALTER EXTENSION UPDATE), confirming the DROP+CREATE rebuild installs/updates cleanly.The three update scripts are the only files changed and are identical to the CI-verified versions on
new_functions.🤖 Generated with Claude Code