Skip to content

Release cat_tools 0.2.2: fix PG11+ and PG12+ compatibility#7

Open
jnasbyupgrade wants to merge 21 commits intoPostgres-Extensions:masterfrom
jnasbyupgrade:v0.2.2
Open

Release cat_tools 0.2.2: fix PG11+ and PG12+ compatibility#7
jnasbyupgrade wants to merge 21 commits intoPostgres-Extensions:masterfrom
jnasbyupgrade:v0.2.2

Conversation

@jnasbyupgrade
Copy link
Copy Markdown
Contributor

Summary

  • Fixes cat_tools 0.2.1 incompatibility with PostgreSQL 11+ and 12+
  • Adds 0.2.1 → 0.2.2 upgrade script for existing installations
  • Provides the stepping stone needed for the 0.2.1 → 0.2.2 → 0.3.0 upgrade chain

Root Causes Fixed

PG11+: _cat_tools.pg_attribute_v used SELECT a.* from pg_attribute. PG11 added attmissingval with pseudo-type anyarray, which cannot be a view column. Fix: use omit_column() to enumerate columns explicitly, and include attmissingval cast to text::text[].

PG12+: _cat_tools.pg_class_v and cat_tools.pg_extension_v used SELECT c.oid AS reloid, c.* / SELECT e.oid, e.*. PG12 made system catalog oid columns visible as regular columns, causing duplicate column names. Fix: use omit_column() to exclude oid from the wildcard expansion.

Changes

  • sql/cat_tools.sql.in: Added __cat_tools.omit_column() helper; replaced three static views with dynamic exec(format(...)) calls; added ALTER DEFAULT PRIVILEGES IN SCHEMA cat_tools GRANT USAGE ON TYPES TO cat_tools__usage; drops omit_column at end of install
  • sql/cat_tools--0.2.1--0.2.2.sql: New upgrade script — temporarily recreates exec, create_function, and omit_column; applies all view fixes; drops temporaries
  • cat_tools.control: default_version = '0.2.2'
  • control.mk: EXTENSION_cat_tools_VERSION := 0.2.2
  • META.json / META.in.json: Version bumped to 0.2.2

Verified

  • PG11: CREATE EXTENSION cat_tools VERSION '0.2.1' fails as expected; VERSION '0.2.2' installs and upgrades to 0.3.0 cleanly
  • PG17: VERSION '0.2.2' installs and upgrades to 0.3.0 cleanly

Closes #2

🤖 Generated with Claude Code

jnasbyupgrade and others added 21 commits November 6, 2024 12:23
bed3604 Fix pg_regress on versions > 12 (#5) (#6)

git-subtree-dir: pgxntool
git-subtree-split: bed36044679d6b53ad7cd2875272552a4ad6508a
- Add __cat_tools.omit_column() helper to list catalog columns dynamically
- Add ALTER DEFAULT PRIVILEGES IN SCHEMA cat_tools GRANT USAGE ON TYPES
- Fix _cat_tools.pg_class_v: use omit_column to exclude duplicate oid (PG12+)
- Fix _cat_tools.pg_attribute_v: omit attmissingval (anyarray, PG11+), include it
  cast to text::text[] so the column is preserved across PG versions
- Fix cat_tools.pg_extension_v: use omit_column to exclude duplicate oid (PG12+)
- Add control.mk to drive version file generation
- Add sql/cat_tools--0.2.1--0.2.2.sql upgrade script

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Use /* */ block comments (was --)
- pg_attribute_v always includes attmissingval column as text[]:
  NULL::text[] on PG10 (column absent), a.attmissingval::text::text[]
  on PG11+. Uses hardcoded OID 1249 (pg_catalog.pg_attribute).
- Add committed sql/cat_tools--0.2.1.sql for upgrade test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pgxntool/run-test-build.sh uses rsync to sync test/build/*.sql into
test/build/sql/ for pg_regress. The pgxn/pgxn-tools container doesn't
include rsync, so install it explicitly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- trigger__parse: handle EXECUTE FUNCTION (PG11+) and pg_temp schema alias mismatch
- extension.sql test: avoid duplicate oid column (e.oid, e.*) on PG12+
- attribute.sql test: skip anyarray column (attmissingval) in results_eq comparison
- object_type.sql test: grant CREATE on public schema for PG15+ compatibility
- general.out: update expected output (test count was stale)
- zzz_build.out: update expected output for new exec() calls
- Add CLAUDE.md with SQL block comment style standard
- Update .gitignore to track .claude/ but ignore *.local.json and worktrees/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Version-specific upgrade scripts are now committed directly as .sql files
rather than generated from .sql.in sources. Remove the versioned_in/versioned_out
machinery and switch DATA to pick up all historical install scripts via wildcard,
filtering out files already provided by pgxntool/base.mk (EXTENSION_VERSION_FILES
and sql/*--*--*.sql upgrade scripts).

Note: pgxs DATA is not cleaned by `make clean` (only DATA_built is), so static
committed SQL files are safe to include in DATA.

Also add explanatory comment to sql/.gitignore.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace DROP VIEW ... CASCADE with CREATE OR REPLACE VIEW throughout the
0.2.1→0.2.2 upgrade script. On PG < 12 the column lists for pg_class_v
and pg_extension_v are unchanged, so CREATE OR REPLACE VIEW works with no
disruption to dependents. For pg_attribute_v, attmissingval is moved to the
end of the column list (matching the new install script) so it can be added
as a trailing column without invalidating any existing dependent views.

Also removes the now-unnecessary recreation of pg_extension__get and the
__cat_tools.create_function helper.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…icts

Kept pgext/master's Makefile approach (versioned_in/versioned_out) since
sql/cat_tools--0.2.0.sql.in and sql/cat_tools--0.2.1.sql.in exist.
Merged both sets of .gitignore additions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pgxntool 2.0 added -include control.mk to base.mk. Having it again in
the Makefile caused control.mk to be processed twice, doubling up
EXTENSION_VERSION_FILES (duplicate sql/cat_tools--0.2.2.sql in DATA)
and triggering "overriding recipe" warnings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
::regnamespace was hardcoded but that type only exists on PG 9.5+.
The upgrade script is pre-built SQL (no SED processing), so use the
same runtime EXISTS check pattern as the attmissingval fix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The upgrade script is now SED-processed like the install scripts.
Replaces the runtime EXISTS/regnamespace check with proper
-- SED: REQUIRES 9.5! / -- SED: PRIOR TO 9.5! markers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add LT11 and LT12 SED variables to Makefile. Replace the CASE-in-format
EXISTS check for attmissingval with -- SED: REQUIRES 11! / PRIOR TO 11!
markers in both the install and upgrade scripts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Restore -- SED: PRIOR TO 9.5! on nspname line; it had been left in
already-processed form (-- Not used prior to 9.5:).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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