Add new functions, enums#16
Open
jnasbyupgrade wants to merge 67 commits intoPostgres-Extensions:masterfrom
Open
Add new functions, enums#16jnasbyupgrade wants to merge 67 commits intoPostgres-Extensions:masterfrom
jnasbyupgrade wants to merge 67 commits intoPostgres-Extensions:masterfrom
Conversation
Biggest change is that starting with Postgres 12 OID columns in catalog tables were no longer hidden, which required adjusting a few views and tests. Also update pgxntool.
Also, refactor common code between it and function__arg_types()
- Eliminate duplicate NULL array creation logic by restructuring CASE statement - Use pronargs instead of parsing proargtypes text for array size - Move data type definitions and mapping functions to beginning of file - Improve code organization and readability
- Add enum types equivalent to relation_relkind for pg_proc fields: * routine_prokind and routine_type (function/procedure/aggregate/window) * routine_proargmode and routine_argument_mode (in/out/inout/variadic/table) * routine_provolatile and routine_volatility (immutable/stable/volatile) * routine_proparallel and routine_parallel_safety (safe/restricted/unsafe) - Remove explicit type grants, rely on default privileges - Clean up redundant comments in mapping functions - Add comprehensive test suite for new enum types and permissions
54793a3 Merge branch 'master' into upstream/stable ab7f6e2 Stamp 1.0.0 3a571ba Add pg_tle support and modernize test infrastructure (Postgres-Extensions#11) b96ea6d Add support for Claude code; build and doc improvements (#9) e9c24de Fix pg_regress on versions > 12 (#5) git-subtree-dir: pgxntool git-subtree-split: 54793a39251290657767816d23b45d6297f3a671
Versioned files should now be kept in git. Also, fix missing .gitignore
3b8cb2a Stamp 1.1.0 550a901 Remove commit.md (maintained in pgxntool-test) d73ca93 Add unique test database names to prevent conflicts (Postgres-Extensions#13) 9b344be Add update-setup-files.sh for 3-way merging after pgxntool-sync (Postgres-Extensions#12) REVERT: 54793a3 Merge branch 'master' into upstream/stable REVERT: bed3604 Fix pg_regress on versions > 12 (#5) (#6) git-subtree-dir: pgxntool git-subtree-split: 3b8cb2a96c2611bb44b1d69fd533fd0f23fa8995
639756c Stamp 1.1.1 6ba3176 Fix pg_tle exception handler and empty upgrade files (Postgres-Extensions#15) git-subtree-dir: pgxntool git-subtree-split: 639756c43a64717347b82b46acfec5be478a7bbf
PostgreSQL 15 (commit 07eee5a0) moved "char" from TYPCATEGORY_STRING to
TYPCATEGORY_INTERNAL, which removed the implicit I/O coercion path that
allowed "char"::some_enum to work. Replace the "char" overloads for
routine__type, routine__argument_mode, routine__volatility, and
routine__parallel_safety with explicit CREATE CAST ... WITH INOUT AS
IMPLICIT entries.
Also fix two bugs in trigger__parse exposed by PG17:
- current_setting('server_version')::real fails when the version string
includes a distro suffix; switch to server_version_num::int
- pg_get_triggerdef renders temp functions as "pg_temp.f" while ::regproc
gives "pg_temp_N.f", breaking the regexp split on the EXECUTE clause;
replace the name-based pattern with a generic EXECUTE (FUNCTION|PROCEDURE)
regex
Fix PG15+ permission denied on public schema in object_type tests by
granting CREATE ON SCHEMA public to the test role (PG15 revoked this
from PUBLIC by default).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add all new types, casts, and functions to the upgrade file that were
previously only in the versioned install file:
- New routine enum types: routine_prokind, routine_type, routine_proargmode,
routine_argument_mode, routine_provolatile, routine_volatility,
routine_proparallel, routine_parallel_safety, and composite routine_argument
- CREATE CAST ("char" AS ...) WITH INOUT AS IMPLICIT for the four prokind/
proargmode/provolatile/proparallel enums (PG15+ compatibility)
- Functions: routine__type, routine__argument_mode, routine__volatility,
routine__parallel_safety, and trigger__parse(oid) with PG17 fixes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Resolve conflicts keeping new_functions branch changes: - CI: updated PG version matrix (18..10) and test command - pgxntool: version history, unique REGRESS_DBNAME - trigger__parse: generic EXECUTE regex pattern - Test expected output and setup for new functions
121f0b3 Stamp 2.0.0 ad3ca7e Remove .source support; add test/install, test/build, and verify-results (Postgres-Extensions#18) c010cf8 Fix bash 3.2 compatibility (#23) abeb9d3 Remove .source file support from pg_regress integration (#22) 08c1879 Stamp 1.1.2 6e0dad2 Fix double --dbname bug that defeated unique test database names git-subtree-dir: pgxntool git-subtree-split: 121f0b38fabd1d0ebd2c975254e59421553e2830
## Summary This PR fixes cat_tools so it installs and upgrades correctly on PostgreSQL 11 through 18+. ### Root causes fixed **1. `cat_tools.column` had extra columns in 0.2.0 and 0.2.1** `cat_tools.column` was built (via `_cat_tools.column`) with an unqualified `SELECT *` across a `LEFT JOIN pg_constraint`, which accidentally pulled in all ~24 `pg_constraint` columns (`conname`, `contype`, etc.) as view columns. This caused two problems: - The upgrade script could not use `CREATE OR REPLACE VIEW` to fix the column list (PostgreSQL does not allow dropping columns from a view this way) - Any user-created views or functions depending on `cat_tools.column` would have been built against this incorrect column set **2. PG 11: `attmissingval` (anyarray) broke `SELECT a.*` from `pg_attribute`** **3. PG 12+: `oid` became a regular visible column, causing "column oid specified more than once" on views using `SELECT e.*` alongside `e.oid`** ### Upgrade warning **If you have created any views, functions, or other objects that depend on `cat_tools.column`, you must drop them before running `ALTER EXTENSION cat_tools UPDATE` and recreate them afterward.** The upgrade will fail with an error if dependents exist — intentionally, to avoid silently breaking user-defined objects. ### Changes - **`cat_tools.column`**: Dropped and recreated with the correct column set (fixing the extra `pg_constraint` columns). Now exposes `attmissingval` as `text[]` (cast from `anyarray` on PG 11+, `NULL::text[]` on older versions). The underlying `_cat_tools.column` is rebuilt as well. - **`_cat_tools.pg_class_v`, `_cat_tools.pg_attribute_v`, `cat_tools.pg_class_v`**: Rebuilt using `omit_column()` to enumerate columns explicitly, avoiding both the `anyarray` and duplicate-`oid` issues. - **New `cat_tools--0.2.0--0.2.2.sql`** upgrade script: handles 0.2.0→0.2.2 in one step, including all 0.2.1 function additions (PostgreSQL picks the shorter path automatically). - **`GRANT SELECT ON cat_tools.pg_extension_v TO cat_tools__usage`** applied on the 0.2.0→0.2.2 path (was missing in 0.2.0). --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
# Conflicts: # .github/workflows/ci.yml # .gitignore # META.in.json # META.json # Makefile # cat_tools.control # pgxntool/HISTORY.asc # pgxntool/base.mk # pgxntool/lib.sh # pgxntool/pgtle.sh # sql/cat_tools--0.1.0.sql # sql/cat_tools.sql.in # test/deps.sql
Per CLAUDE.md rules: - Rule 0: if a .sql.in exists, track the .sql.in, not the .sql - Rule 4: the current version's .sql.in must be tracked even though make generates it Changes: - git rm cat_tools--0.2.1.sql and cat_tools--0.2.2.sql (have .sql.in counterparts) - Rename cat_tools--0.2.2--0.3.0.sql → .sql.in (matches pattern of all other upgrade scripts) - Add cat_tools--0.3.0.sql.in (copy of cat_tools.sql.in; make generates the .sql from it) - Makefile: remove explicit DATA lines for 0.2.1/0.2.2 (now covered by versioned_out) - Makefile: remove EXTRA_CLEAN of the 0.3.0.sql.in (it's now tracked, not generated) - Makefile: remove EXTENSION_VERSION_FILES exclusion from versioned_out EXTRA_CLEAN (the generated 0.3.0.sql should be cleaned; the tracked 0.3.0.sql.in is not in EXTRA_CLEAN) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
16de3b9 to
8f3cdbb
Compare
Keep 0.3.0 version in control/META files; incorporate master's 0.1.4--0.1.5 HISTORY entry. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Test changes: - Replace static permissions.sql + type__permissions.sql with a single dynamic permissions.sql that covers all cat_tools types (enum + composite) and all cat_tools functions, testing both denied (no_use_role) and granted (use_role) directions via has_function_privilege and actual casts - Delete orphan test/expected/table__is_temp.out (no matching .sql) - Regenerate test/expected/permissions.out (20 static tests → 158 dynamic) Bug fix: - Remove orphaned second %s in _cat_tools.pg_attribute_v format() call left by the 9af1f2e merge (kept the placeholder from 11fcb95 but took the 2-arg form from master's 3e290be, giving 3 %s with 2 args) CI changes: - Fix stale grep -q "0.2.2" in pg-upgrade-test (should be current version) - Add old-ext-pg-upgrade-test job: PG10 with cat_tools 0.2.0 → pg_upgradecluster to PG11/12 → ALTER EXTENSION UPDATE to current - Expand extension-update-test matrix from [10] to [10, 11, 12]; add 0.2.2→current step for all versions; gate 0.2.0/0.2.1 steps on PG10 - Read expected version dynamically from cat_tools.control instead of hardcoding, so tests remain correct as the version advances Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Three prompt files for handoff to other Claude sessions: - prompt-readme-api-contract.md: team analysis of README <-> pgTAP cross-referencing - prompt-language-choice.md: competing analysis of Perl/Python/Go/shell for utility scripts - prompt-layer3-implementation.md: implementation spec for the pg_dump drift test Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ALTER TYPE ... ADD VALUE in the 0.2.2→0.3.0 upgrade script cannot run inside an extension update script on PG10 (restriction lifted in PG12). CI changes: - Remove PG10 from all test matrices - Remove old-ext-pg-upgrade-test job (entirely PG10-specific) - Remove PG10-only extension-update steps (0.2.0/0.2.1 upgrade paths) - extension-update-test now covers pg: [11, 12] Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- CLAUDE.md: add Terminology section distinguishing extension updates
(ALTER EXTENSION ... UPDATE) from PostgreSQL cluster upgrades
(pg_upgrade/pg_upgradecluster); fix "upgrade script" → "update script"
and "upgrade paths" → "update paths" in CI section
- HISTORY.asc: add 0.3.0 release notes section; fix all extension update
references throughout ("upgrade" → "update") while preserving correct
use of "upgrade" for PostgreSQL cluster version changes
- ci.yml: fix extension-update-test comment and step names
("upgrade path" → "update path", "Test upgrade from" → "Test update from")
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3193b80 to
2d5179e
Compare
Makefile: remove TEST_BUILD_DIR block re-introduced by merge Commit 1763a93 had already removed this block and test/load_new.sql in favour of pgxntool's built-in test/build support, with extension loading moved to test/deps.sql. The e2525b0 merge brought the block back without restoring test/load_new.sql, causing make test to fail with "No rule to make target 'test/load_new.sql'". ci.yml: fix broken sed pattern in Set expected extension version steps The pattern s/^default_version = '//;s/'$//p matched every line in cat_tools.control that ends with a single quote (comment, schema, and default_version), writing three lines to GITHUB_ENV which the runner rejects as "Invalid format '0.3.0'". Replace with a single substitution s/^default_version = '\(.*\)'$/\1/p that matches and extracts the version from exactly the right line. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The TEST_BUILD_DIR block was removed from the Makefile; the directory is no longer generated so the ignore entry is now unreachable cruft. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
One new SELECT __cat_tools.create_function() call was added in commit 5400e68 without updating the expected output, causing the build test to fail with a diff of two extra blank lines. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PG11 has the same restriction as PG10: ALTER TYPE ... ADD VALUE cannot run inside an extension update script (PROCESS_UTILITY_QUERY context) or in a transaction block. This restriction was lifted in PG12. Affects the 0.2.2→0.3.0 update path which adds new enum values. - test/build/upgrade.sql: change version threshold from pg11plus (≥110000) to pg12plus (≥120000). On PG12+, run the update test as before (0.2.2 base, ALTER EXTENSION UPDATE inside BEGIN/ROLLBACK). On PG11 and below, skip entirely with a comment. Drop the dead PG10 branch (PG10 unsupported). - ci.yml: change extension-update-test matrix from pg:[11,12] to pg:[12]. Update comment to explain the real constraint (ALTER TYPE ... ADD VALUE restriction, not just install compatibility). - CLAUDE.md: update CI section to reflect pg:[12] matrix and correctly attribute the restriction to PG10 and PG11 (not just PG10). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
`relhasoids` was removed in PG12. Explicitly add it to the omit list so the view definition never references it, enabling binary pg_upgrade from PG10/PG11 to PG12+ without failure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Merge 8 single-function test files into 2 combined suites to reduce repeated setup and keep related tests together: - relation__.sql: relation_type + is_temp + is_catalog + column_names (41 tests) - routine__.sql: routine_type + argument_mode + volatility + parallel_safety (57 tests) Rename conflicting temp table names (test_temp_table → is_temp_test / is_catalog_test) to avoid collision within the merged relation__ suite. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
f6b076a to
312a11c
Compare
…orted ALTER TYPE ... ADD VALUE cannot run inside an extension update script on PG11 or earlier (restriction lifted in PG12). Per project policy, we do not support fresh installs on versions where the update path is broken. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nore The upgrade-drift feature was never implemented; the three files in test/upgrade-drift/ were Claude session-handoff prompts that should not have been committed. test/.gitignore contained a single `.build` entry that never matched anything (build generates test/build/, not test/.build/). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
All tests in function.sql cover routine__* functions and belong with the rest of the routine__ test suite. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
regprocedure(), deprecated function__arg_types() wrappers, and the _cat_tools helper security-definer checks do not belong in routine__.sql. Move them back to function.sql. Also: the relation_type tests were correctly merged into relation__.sql earlier — relation__kind() and relation__relkind() are relation__ functions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
# Conflicts: # .github/workflows/ci.yml # HISTORY.asc
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.
pg_procfields:routine_type,routine_argument_mode,routine_volatility,routine_parallel_safetyrelation__is_temp,relation__is_catalog,relation__column_namesrun-test-build.sh,verify-results-pgtap.sh, and more)attmissingvaland PG12+oidvisibility breakage in pre-0.2.2 scripts0.1.0,0.2.1,0.2.2) now tracked in git