Add new functions, enums#16
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
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
- Add test/helpers/enum_mapping.sql: Pattern A psql-variable helper for routine__ enum mapping tests; builds f/enum_type/char_enum_type from kind+char_col, uses greatest() for size-mismatch safety, unsets all variables at end - routine__.sql: replace 4 hand-rolled view+test blocks with 4 \set/\i calls; plan() uses array_length(enum_range()) directly; remove views - relation__.sql: add greatest() comment on kinds view; remove redundant per-function security checks (covered by permissions.sql); consolidate temp tables into one pre-plan() temp_test_table - function.sql: move critical security tests to top; remove redundant regprocedure permission check; label deprecated wrapper test descriptions - permissions.sql: make plan() comments consistent (no_use denied + use allowed) - Update all affected expected output files Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- enum_mapping.sql: rename internal vars to __f/__enum_type/__char_enum_type to avoid conflicts; move greatest() comment inside view; add Set 1/Set 2 section headers; improve count test description to mention both enums; only unset internal __ vars, not caller-provided vars; update top comment to describe both test sets - function.sql: introduce \set _s _cat_tools and use :'_s' in isnt_definer calls instead of hardcoded '_cat_tools' - relation__.sql: restore per-function security throws_ok tests and dedicated temp table creation tests that were incorrectly removed - routine__.sql: break down the +32 plan constant into labeled subsections - routine__.out: update 4 enum size check descriptions to match new wording - relation__.out: update to 1..41 with restored test output lines Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- enum_mapping.sql: correct Set 1/Set 2 labels — Set 1 is the individual example with a fully-specified expected value (rigorous correctness check); Set 2 is the all-values roundtrip (breadth over depth); size check is now a separate prerequisite comment - routine__.sql: reorder functional tests to group related functions together (types: parse_arg_types + isnt_definer × 2 + arg_types + arg_types_text; names: parse_arg_names + isnt_definer × 2 + arg_names + arg_names_text); pg_temp function creation moved to top of SET SESSION AUTH section so both functions are available to all test groups; isnt_definer checks inline with their respective function sections; fix args variable collision with _f_args for isnt_definer calls - permissions.sql: add _cat_tools schema USAGE checks (no_use denied, use allowed); document the defense-in-depth gap for function__arg_to_ regprocedure and function__drop_temp which carry an incidental PUBLIC execute grant but are protected by schema-level USAGE restriction Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
function__arg_to_regprocedure and function__drop_temp were missing an explicit REVOKE, so GRANT TO cat_tools__usage materialized a PUBLIC execute entry in their ACLs. Schema-level USAGE protection was already effective, but defense-in-depth is better. Also update permissions.out: the "char" overloads of routine__argument_mode, routine__parallel_safety, routine__type, and routine__volatility are now correctly reflected in the expected output (they were absent from the cached file). Update the _cat_tools comment in permissions.sql to reflect that the REVOKE is now in place. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ests - Use leading comma format in throws_ok call (trailing comma was wrong style) - Move CREATE FUNCTION pg_temp.test_function/named_function to just before the routine__arg_types tests where they are first used - Add \set named_args and use :'named_args' consistently throughout Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis pull request delivers cat_tools v0.3.0, a significant extension release that introduces new routine and partitioned relation introspection APIs while narrowing PostgreSQL version support to 12+. The release updates metadata and version strings, refactors the CI/build infrastructure to remove PG10/11 testing, implements two new SQL scripts (upgrade and fresh install), adds helper utilities for routine argument parsing and trigger introspection, and provides comprehensive test coverage including security boundary validation and functional behavior assertions. Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
…irst use Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@coderabbitai full review and please use the github review functionality |
There was a problem hiding this comment.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
sql/cat_tools.sql.in (1)
1785-1787:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winDon't feed an unescaped relation name into a regex split.
v_on_clauseincludesr_trigger.tgrelid::pg_catalog.regclass, then gets passed straight toregexp_split_to_array. Valid quoted identifiers can contain.,+,(, etc., sotrigger__parse()will mis-parse or fail on those names. Prefer literal slicing withstrpos/substr, or escape the pattern before calling the regex function. Please mirror the same fix intosql/cat_tools--0.2.2--0.3.0.sql.in, which embeds the same parser.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@sql/cat_tools.sql.in` around lines 1785 - 1787, The code builds v_on_clause using r_trigger.tgrelid::pg_catalog.regclass and then passes it into regexp_split_to_array, which can break on valid quoted relation names; update trigger__parse() to avoid using an unescaped regex pattern by either escaping v_on_clause before calling regexp_split_to_array or, preferably, replace the regex split with literal slicing using strpos/substr on v_work and v_on_clause to extract parts into v_array and events; apply the same change to the duplicate parser in sql/cat_tools--0.2.2--0.3.0.sql.in so both copies use safe literal splitting or properly escaped patterns.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/ci.yml:
- Around line 63-65: The EXPECTED_VERSION extraction using sed should be
hardened: after running the sed extraction that sets EXPECTED_VERSION in the
environment, add an explicit check that EXPECTED_VERSION is non-empty and fail
fast (exit non-zero) if empty; similarly, wherever you compare VERSION to
EXPECTED_VERSION (currently using grep -qF), replace those checks with explicit
non-empty validation of VERSION and an exact string equality comparison [
"$VERSION" = "$EXPECTED_VERSION" ] (i.e., ensure VERSION is not empty, then
compare exact equality), and remove the use of grep -qF to avoid partial
matches; reference the variables EXPECTED_VERSION and VERSION and the sed
extraction that writes to GITHUB_ENV when applying these changes.
In `@HISTORY.asc`:
- Line 17: Replace the "TODO" placeholder under the 0.3.0 release heading in
HISTORY.asc with the actual change bullets for version 0.3.0: list concise,
user-facing entries (bug fixes, new features, breaking changes, and notable
internal changes) as individual dash-prefixed lines so the release section is
complete and readable; ensure the bullets reference the corresponding
commits/PRs or short descriptions and keep formatting consistent with other
release sections in the file.
In `@META.in.json`:
- Line 17: Update the advertised PostgreSQL prerequisite to match the package
version: change the prereqs.build.requires.PostgreSQL value in META.in.json
(look for the JSON key path prereqs.build.requires.PostgreSQL) from "9.2.0" to
"12.0" so it aligns with "version": "0.3.0", then regenerate META.json from
META.in.json to propagate the change (ensure the updated value appears in the
generated META.json).
In `@README.asc`:
- Line 33: Remove the stray trailing backtick in the `routine_volatility` bullet
(the text currently reads "* `routine_volatility` - Volatility levels for
functions/procedures`") and correct the possessive on line 87 from "it's full
set of arguments" to "its full set of arguments"; update the README.asc entries
accordingly, keeping the backticks around `routine_volatility` but deleting the
extra backtick at the end and fixing the contraction to the possessive form
"its".
In `@sql/cat_tools--0.2.2--0.3.0.sql.in`:
- Around line 167-169: Revoke the default PUBLIC privileges for the _cat_tools
helpers before granting to cat_tools__usage: add statements to REVOKE USAGE ON
SCHEMA _cat_tools FROM PUBLIC and REVOKE EXECUTE ON FUNCTION for each helper
function (_cat_tools.function__arg_to_regprocedure(text,text,text) and
_cat_tools.function__drop_temp(pg_catalog.regprocedure,text)) from PUBLIC,
placed immediately before the existing GRANT lines so updated databases don't
retain broader ACLs.
In `@sql/cat_tools.sql.in`:
- Around line 372-414: The relkind mappings are wrong in the SQL functions
cat_tools.relation__kind and cat_tools.relation__relkind: swap the labels so
that 'c' maps to 'composite type', 'f' maps to 'foreign table', and 'm' maps to
'materialized view' in relation__kind, and reverse those mappings in
relation__relkind (i.e. kind 'composite type' -> 'c', 'foreign table' -> 'f',
'materialized view' -> 'm') so fresh installs match the 0.2.2→0.3.0 update path.
---
Outside diff comments:
In `@sql/cat_tools.sql.in`:
- Around line 1785-1787: The code builds v_on_clause using
r_trigger.tgrelid::pg_catalog.regclass and then passes it into
regexp_split_to_array, which can break on valid quoted relation names; update
trigger__parse() to avoid using an unescaped regex pattern by either escaping
v_on_clause before calling regexp_split_to_array or, preferably, replace the
regex split with literal slicing using strpos/substr on v_work and v_on_clause
to extract parts into v_array and events; apply the same change to the duplicate
parser in sql/cat_tools--0.2.2--0.3.0.sql.in so both copies use safe literal
splitting or properly escaped patterns.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: cb7a426f-c0df-4bf9-8378-d71916ce2b42
⛔ Files ignored due to path filters (8)
test/build/expected/build.outis excluded by!**/*.outtest/build/expected/upgrade.outis excluded by!**/*.outtest/expected/function.outis excluded by!**/*.outtest/expected/object_type.outis excluded by!**/*.outtest/expected/permissions.outis excluded by!**/*.outtest/expected/relation__.outis excluded by!**/*.outtest/expected/relation_type.outis excluded by!**/*.outtest/expected/routine__.outis excluded by!**/*.out
📒 Files selected for processing (26)
.github/workflows/ci.yml.gitignoreCLAUDE.mdHISTORY.ascLICENSEMETA.in.jsonMETA.jsonMakefileREADME.asccat_tools.controlcontrol.mksql/cat_tools--0.2.2--0.3.0.sql.insql/cat_tools--0.3.0.sql.insql/cat_tools.sql.intest/build/build.sqltest/build/upgrade.sqltest/deps.sqltest/helpers/enum_mapping.sqltest/load_new.sqltest/setup.sqltest/sql/function.sqltest/sql/object_type.sqltest/sql/permissions.sqltest/sql/relation__.sqltest/sql/relation_type.sqltest/sql/routine__.sql
💤 Files with no reviewable changes (3)
- test/load_new.sql
- test/sql/relation_type.sql
- .gitignore
| - name: Set expected extension version | ||
| run: | | ||
| echo "EXPECTED_VERSION=$(sed -n "s/^default_version = '\(.*\)'$/\1/p" cat_tools.control)" >> $GITHUB_ENV |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Verify parser returns a non-empty expected version from repo control file.
EXPECTED_VERSION="$(sed -n "s/^default_version = '\(.*\)'$/\1/p" cat_tools.control)"
printf 'Parsed EXPECTED_VERSION=<%s>\n' "$EXPECTED_VERSION"
if [ -z "$EXPECTED_VERSION" ]; then
echo "FAIL: EXPECTED_VERSION is empty (current grep check would false-pass)."
exit 1
fi
# Demonstrate why grep is unsafe for equality assertions.
VERSION_PARTIAL="${EXPECTED_VERSION}-extra"
if echo "$VERSION_PARTIAL" | grep -qF "$EXPECTED_VERSION"; then
echo "grep check passes on partial match: $VERSION_PARTIAL"
fi
# Exact check should fail for partials.
if [ "$VERSION_PARTIAL" = "$EXPECTED_VERSION" ]; then
echo "Unexpected exact match"
exit 1
else
echo "Exact equality check correctly rejects partial match."
fiRepository: Postgres-Extensions/cat_tools
Length of output: 207
🏁 Script executed:
cat -n .github/workflows/ci.yml | sed -n '50,150p'Repository: Postgres-Extensions/cat_tools
Length of output: 6322
Harden EXPECTED_VERSION parsing and use exact version equality checks.
Current checks can false-pass: empty EXPECTED_VERSION from parsing always passes grep -qF, and partial matches pass too. Fail fast if parsing returns empty, then compare exact strings.
- Lines 65, 131: Add empty value validation after
sedextractsdefault_version - Lines 102, 141: Replace
grep -qFwith exact equality[ "$VERSION" = "$EXPECTED_VERSION" ]and validateVERSIONis not empty
Suggested patch
- name: Set expected extension version
run: |
- echo "EXPECTED_VERSION=$(sed -n "s/^default_version = '\(.*\)'$/\1/p" cat_tools.control)" >> $GITHUB_ENV
+ EXPECTED_VERSION="$(sed -n "s/^default_version = '\(.*\)'$/\1/p" cat_tools.control)"
+ test -n "$EXPECTED_VERSION" || { echo "Failed to parse default_version from cat_tools.control"; exit 1; }
+ echo "EXPECTED_VERSION=$EXPECTED_VERSION" >> "$GITHUB_ENV"
@@
- name: Verify extension version after upgrade
run: |
VERSION=$(psql -tAc "SELECT extversion FROM pg_extension WHERE extname = 'cat_tools'")
echo "Extension version: ${VERSION:-<not found>}"
- echo "$VERSION" | grep -qF "$EXPECTED_VERSION"
+ test -n "$VERSION" || { echo "cat_tools extension version not found"; exit 1; }
+ [ "$VERSION" = "$EXPECTED_VERSION" ]
@@
- name: Set expected extension version
run: |
- echo "EXPECTED_VERSION=$(sed -n "s/^default_version = '\(.*\)'$/\1/p" cat_tools.control)" >> $GITHUB_ENV
+ EXPECTED_VERSION="$(sed -n "s/^default_version = '\(.*\)'$/\1/p" cat_tools.control)"
+ test -n "$EXPECTED_VERSION" || { echo "Failed to parse default_version from cat_tools.control"; exit 1; }
+ echo "EXPECTED_VERSION=$EXPECTED_VERSION" >> "$GITHUB_ENV"
@@
- name: Test update from 0.2.2 (0.2.2→current path)
run: |
createdb cat_tools_from_022
psql -d cat_tools_from_022 -c "CREATE EXTENSION cat_tools VERSION '0.2.2'"
psql -d cat_tools_from_022 -c "ALTER EXTENSION cat_tools UPDATE"
VERSION=$(psql -d cat_tools_from_022 -tAc "SELECT extversion FROM pg_extension WHERE extname = 'cat_tools'")
echo "Version after 0.2.2 update: ${VERSION:-<not found>}"
- echo "$VERSION" | grep -qF "$EXPECTED_VERSION"
+ test -n "$VERSION" || { echo "cat_tools extension version not found after update"; exit 1; }
+ [ "$VERSION" = "$EXPECTED_VERSION" ]🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/ci.yml around lines 63 - 65, The EXPECTED_VERSION
extraction using sed should be hardened: after running the sed extraction that
sets EXPECTED_VERSION in the environment, add an explicit check that
EXPECTED_VERSION is non-empty and fail fast (exit non-zero) if empty; similarly,
wherever you compare VERSION to EXPECTED_VERSION (currently using grep -qF),
replace those checks with explicit non-empty validation of VERSION and an exact
string equality comparison [ "$VERSION" = "$EXPECTED_VERSION" ] (i.e., ensure
VERSION is not empty, then compare exact equality), and remove the use of grep
-qF to avoid partial matches; reference the variables EXPECTED_VERSION and
VERSION and the sed extraction that writes to GITHUB_ENV when applying these
changes.
|
|
||
| ### Changes | ||
|
|
||
| // TODO |
There was a problem hiding this comment.
Replace placeholder TODO with actual 0.3.0 change bullets.
Line 17 leaves the release section incomplete, which blocks usable release notes for this version.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@HISTORY.asc` at line 17, Replace the "TODO" placeholder under the 0.3.0
release heading in HISTORY.asc with the actual change bullets for version 0.3.0:
list concise, user-facing entries (bug fixes, new features, breaking changes,
and notable internal changes) as individual dash-prefixed lines so the release
section is complete and readable; ensure the bullets reference the corresponding
commits/PRs or short descriptions and keep formatting consistent with other
release sections in the file.
|
|
||
| "X_comment": "REQUIRED. Version of the distribution. http://pgxn.org/spec/#version", | ||
| "version": "0.2.2", | ||
| "version": "0.3.0", |
There was a problem hiding this comment.
Update PGXN prerequisite version to PostgreSQL 12+ to match 0.3.0 support policy.
With 0.3.0 declared on Lines 17 and 40, keeping prereqs.build.requires.PostgreSQL at 9.2.0 (Line 75) advertises unsupported versions and can trigger broken installs. Please set the minimum to 12.0 in META.in.json and regenerate META.json.
Suggested fix
--- a/META.in.json
+++ b/META.in.json
@@
- "PostgreSQL": "9.2.0"
+ "PostgreSQL": "12.0"Based on learnings: “PostgreSQL 10 and 11 are dropped as of version 0.3.0… cat_tools 0.3.0 supports PG12+.”
Also applies to: 40-40
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@META.in.json` at line 17, Update the advertised PostgreSQL prerequisite to
match the package version: change the prereqs.build.requires.PostgreSQL value in
META.in.json (look for the JSON key path prereqs.build.requires.PostgreSQL) from
"9.2.0" to "12.0" so it aligns with "version": "0.3.0", then regenerate
META.json from META.in.json to propagate the change (ensure the updated value
appears in the generated META.json).
| * `relation_relkind` - Valid values for `pg_class.relkind` | ||
| * `routine_type` - Types of routines stored in `pg_proc` | ||
| * `routine_argument_mode` - Argument modes for function/procedure parameters | ||
| * `routine_volatility` - Volatility levels for functions/procedures` |
There was a problem hiding this comment.
Fix two user-facing documentation typos.
- Line 33 has an extra trailing backtick after
functions/procedures. - Line 87 should be “its full set of arguments,” not “it's full set of arguments.”
Also applies to: 87-87
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@README.asc` at line 33, Remove the stray trailing backtick in the
`routine_volatility` bullet (the text currently reads "* `routine_volatility` -
Volatility levels for functions/procedures`") and correct the possessive on line
87 from "it's full set of arguments" to "its full set of arguments"; update the
README.asc entries accordingly, keeping the backticks around
`routine_volatility` but deleting the extra backtick at the end and fixing the
contraction to the possessive form "its".
| GRANT USAGE ON SCHEMA _cat_tools TO cat_tools__usage; | ||
| GRANT EXECUTE ON FUNCTION _cat_tools.function__arg_to_regprocedure(text, text, text) TO cat_tools__usage; | ||
| GRANT EXECUTE ON FUNCTION _cat_tools.function__drop_temp(pg_catalog.regprocedure, text) TO cat_tools__usage; |
There was a problem hiding this comment.
Revoke the default PUBLIC execute grants here as well.
Fresh installs explicitly revoke PUBLIC on these helpers before granting cat_tools__usage, but the update path does not. That leaves updated databases with broader ACLs than new installs for the same release.
Suggested patch
GRANT USAGE ON SCHEMA _cat_tools TO cat_tools__usage;
+REVOKE EXECUTE ON FUNCTION _cat_tools.function__arg_to_regprocedure(text, text, text) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _cat_tools.function__arg_to_regprocedure(text, text, text) TO cat_tools__usage;
+REVOKE EXECUTE ON FUNCTION _cat_tools.function__drop_temp(pg_catalog.regprocedure, text) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION _cat_tools.function__drop_temp(pg_catalog.regprocedure, text) TO cat_tools__usage;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| GRANT USAGE ON SCHEMA _cat_tools TO cat_tools__usage; | |
| GRANT EXECUTE ON FUNCTION _cat_tools.function__arg_to_regprocedure(text, text, text) TO cat_tools__usage; | |
| GRANT EXECUTE ON FUNCTION _cat_tools.function__drop_temp(pg_catalog.regprocedure, text) TO cat_tools__usage; | |
| GRANT USAGE ON SCHEMA _cat_tools TO cat_tools__usage; | |
| REVOKE EXECUTE ON FUNCTION _cat_tools.function__arg_to_regprocedure(text, text, text) FROM PUBLIC; | |
| GRANT EXECUTE ON FUNCTION _cat_tools.function__arg_to_regprocedure(text, text, text) TO cat_tools__usage; | |
| REVOKE EXECUTE ON FUNCTION _cat_tools.function__drop_temp(pg_catalog.regprocedure, text) FROM PUBLIC; | |
| GRANT EXECUTE ON FUNCTION _cat_tools.function__drop_temp(pg_catalog.regprocedure, text) TO cat_tools__usage; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@sql/cat_tools--0.2.2--0.3.0.sql.in` around lines 167 - 169, Revoke the
default PUBLIC privileges for the _cat_tools helpers before granting to
cat_tools__usage: add statements to REVOKE USAGE ON SCHEMA _cat_tools FROM
PUBLIC and REVOKE EXECUTE ON FUNCTION for each helper function
(_cat_tools.function__arg_to_regprocedure(text,text,text) and
_cat_tools.function__drop_temp(pg_catalog.regprocedure,text)) from PUBLIC,
placed immediately before the existing GRANT lines so updated databases don't
retain broader ACLs.
| SELECT __cat_tools.create_function( | ||
| 'cat_tools.relation__kind' | ||
| , 'relkind cat_tools.relation_relkind' | ||
| , 'cat_tools.relation_type LANGUAGE sql STRICT IMMUTABLE' | ||
| , $body$ | ||
| SELECT CASE relkind | ||
| WHEN 'r' THEN 'table' | ||
| WHEN 'i' THEN 'index' | ||
| WHEN 'S' THEN 'sequence' | ||
| WHEN 't' THEN 'toast table' | ||
| WHEN 'v' THEN 'view' | ||
| WHEN 'c' THEN 'materialized view' -- composite type (but mapped to materialized view) | ||
| WHEN 'f' THEN 'composite type' -- foreign table (but mapped to composite type) | ||
| WHEN 'm' THEN 'foreign table' -- materialized view (but mapped to foreign table) | ||
| WHEN 'p' THEN 'partitioned table' | ||
| WHEN 'I' THEN 'partitioned index' | ||
| END::cat_tools.relation_type | ||
| $body$ | ||
| , 'cat_tools__usage' | ||
| , 'Mapping from <pg_class.relkind> to a <cat_tools.relation_type>' | ||
| ); | ||
|
|
||
| SELECT __cat_tools.create_function( | ||
| 'cat_tools.relation__relkind' | ||
| , 'kind cat_tools.relation_type' | ||
| , 'cat_tools.relation_relkind LANGUAGE sql STRICT IMMUTABLE' | ||
| , $body$ | ||
| SELECT CASE kind | ||
| WHEN 'table' THEN 'r' | ||
| WHEN 'index' THEN 'i' | ||
| WHEN 'sequence' THEN 'S' | ||
| WHEN 'toast table' THEN 't' | ||
| WHEN 'view' THEN 'v' | ||
| WHEN 'materialized view' THEN 'c' -- materialized view (mapped from c) | ||
| WHEN 'composite type' THEN 'f' -- composite type (mapped from f) | ||
| WHEN 'foreign table' THEN 'm' -- foreign table (mapped from m) | ||
| WHEN 'partitioned table' THEN 'p' | ||
| WHEN 'partitioned index' THEN 'I' | ||
| END::cat_tools.relation_relkind | ||
| $body$ | ||
| , 'cat_tools__usage' | ||
| , 'Mapping from <cat_tools.relation_type> to a <pg_class.relkind> value' | ||
| ); |
There was a problem hiding this comment.
Fix the swapped c / f / m relkind mappings.
These branches are backwards: c is composite type, f is foreign table, and m is materialized view. As written, fresh installs return different results from the 0.2.2→0.3.0 update path, which already maps them correctly.
Suggested patch
SELECT CASE relkind
WHEN 'r' THEN 'table'
WHEN 'i' THEN 'index'
WHEN 'S' THEN 'sequence'
WHEN 't' THEN 'toast table'
WHEN 'v' THEN 'view'
- WHEN 'c' THEN 'materialized view' -- composite type (but mapped to materialized view)
- WHEN 'f' THEN 'composite type' -- foreign table (but mapped to composite type)
- WHEN 'm' THEN 'foreign table' -- materialized view (but mapped to foreign table)
+ WHEN 'c' THEN 'composite type'
+ WHEN 'f' THEN 'foreign table'
+ WHEN 'm' THEN 'materialized view'
WHEN 'p' THEN 'partitioned table'
WHEN 'I' THEN 'partitioned index'
END::cat_tools.relation_type
@@
SELECT CASE kind
WHEN 'table' THEN 'r'
WHEN 'index' THEN 'i'
WHEN 'sequence' THEN 'S'
WHEN 'toast table' THEN 't'
WHEN 'view' THEN 'v'
- WHEN 'materialized view' THEN 'c' -- materialized view (mapped from c)
- WHEN 'composite type' THEN 'f' -- composite type (mapped from f)
- WHEN 'foreign table' THEN 'm' -- foreign table (mapped from m)
+ WHEN 'composite type' THEN 'c'
+ WHEN 'foreign table' THEN 'f'
+ WHEN 'materialized view' THEN 'm'
WHEN 'partitioned table' THEN 'p'
WHEN 'partitioned index' THEN 'I'
END::cat_tools.relation_relkind🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@sql/cat_tools.sql.in` around lines 372 - 414, The relkind mappings are wrong
in the SQL functions cat_tools.relation__kind and cat_tools.relation__relkind:
swap the labels so that 'c' maps to 'composite type', 'f' maps to 'foreign
table', and 'm' maps to 'materialized view' in relation__kind, and reverse those
mappings in relation__relkind (i.e. kind 'composite type' -> 'c', 'foreign
table' -> 'f', 'materialized view' -> 'm') so fresh installs match the
0.2.2→0.3.0 update path.
🧩 Analysis chain
🏁 Script executed: Length of output: 270551
🏁 Script executed: Length of output: 669 🏁 Script executed: Length of output: 3388 🏁 Script executed: Length of output: 5113 🏁 Script executed: Length of output: 194
🏁 Script executed: Length of output: 225
Blocking
Bugs
Docs
Style/minor
If you’d like, I can follow up by:
✅ Actions performedReview triggered.
|
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