Skip to content

Fix pg_upgrade update-path bug (omit_column != ANY -> != ALL; rebuild pg_class_v)#42

Open
jnasbyupgrade wants to merge 1 commit into
Postgres-Extensions:masterfrom
jnasbyupgrade:reroll-023-fix
Open

Fix pg_upgrade update-path bug (omit_column != ANY -> != ALL; rebuild pg_class_v)#42
jnasbyupgrade wants to merge 1 commit into
Postgres-Extensions:masterfrom
jnasbyupgrade:reroll-023-fix

Conversation

@jnasbyupgrade

Copy link
Copy Markdown
Contributor

Summary

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). For a multi-element omit list this is a no-op: 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.

Fix

  • 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 (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.

Verification

This fix is 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 change.

Master's own CI has no bridge leg, so it cannot exercise the 0.2.0->0.2.2->pg_upgrade path directly. However, 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 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

… 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>
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c2d63e84-c8ce-43a4-8f6c-14dfa4cc0566

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant