Skip to content

Require cat_tools 0.3.0 or later, with a clear error otherwise - #48

Merged
jnasbyupgrade merged 2 commits into
Postgres-Extensions:masterfrom
jnasbyupgrade:require-cat_tools-0.3.0
Nov 4, 2026
Merged

jnasbyupgrade merged 2 commits into
Postgres-Extensions:masterfrom
jnasbyupgrade:require-cat_tools-0.3.0

Conversation

@jnasbyupgrade

Copy link
Copy Markdown
Contributor

object_reference needs cat_tools 0.3.0 or later; an older cat_tools now fails CREATE EXTENSION/ALTER EXTENSION UPDATE up front instead of at first use.

  • sql/object_reference.sql and the 0.1.0 update script check the installed cat_tools version and raise object_not_in_prerequisite_state with a hint to ALTER EXTENSION cat_tools UPDATE. A non-numeric version such as stable (a development build) is let through.
  • META.in.json declares the runtime requirement as cat_tools 0.3.0 (the control file's requires can't carry a version).
  • README states the requirement.
  • test/build/expected/build.out changes only in the line numbers of the script warnings it records.

Tested: fresh install and 0.1.0 update on PG17; faking cat_tools 0.2.1 produces the error on install. The update-script check is the same text and its failure path isn't separately exercised.

The code calls cat_tools.routine__parse_arg_types_text(), which only exists
from cat_tools 0.3.0, so an older cat_tools failed obscurely at use time.
Check the installed version up front in the install and 0.1.0 update
scripts, and declare the floor in META.in.json.
@coderabbitai

coderabbitai Bot commented Nov 4, 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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 896f0106-5448-439c-8e36-6c4628d42dbe

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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Claude finished @jnasbyupgrade's task in 11s —— View job


Code review: PR #48

No blocking issues found. I read the diff but didn't run the tests.

Minor, non-blocking

  • sql/object_reference.sql:34 and sql/object_reference--0.1.0--stable.sql:13 compare string_to_array(...)::int[] < '{0,3,0}'. PostgreSQL treats a shorter array as less than a longer one with the same prefix. A two-component version such as 0.3 would therefore be rejected, although it is numerically 0.3.0. cat_tools uses three-part versions, so this is theoretical. If you want to be safe, pad the version first, for example string_to_array(c_version || '.0.0', '.')::int[], and compare only the first three elements.
  • The update-script check is the same text as the install check but its failure path isn't exercised, as the PR description says. The duplication is acceptable, since update scripts can't share code with the main script.

Looks good

  • A version that isn't purely numeric (such as stable) is let through, and a missing cat_tools row gives NULL, so nothing is raised. CREATE EXTENSION then fails normally on the missing dependency.
  • The error uses the right SQLSTATE and includes a useful hint.
  • The META.in.json and META.json changes agree, and the README wording matches.

Comment thread sql/object_reference--0.1.0--stable.sql Outdated
DECLARE
c_version CONSTANT text := (SELECT extversion FROM pg_catalog.pg_extension WHERE extname = 'cat_tools');
BEGIN
IF c_version ~ '^[0-9]+(\.[0-9]+)*$' AND string_to_array(c_version, '.')::int[] < '{0,3,0}' THEN

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't care about the last digit, and that's what's most likely to contain non-number. Ignore it.

@jnasbyupgrade
jnasbyupgrade marked this pull request as draft November 4, 2026 18:47
@jnasbyupgrade
jnasbyupgrade marked this pull request as ready for review November 4, 2026 18:51
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Claude finished @jnasbyupgrade's task in 12s —— View job


Code review: PR #48

No blocking issues found. I read the diff but didn't run the tests.

  • The latest commit (2094658) already acts on the review comment about the last version digit. Both checks in sql/object_reference.sql and sql/object_reference--0.1.0--stable.sql now extract only ^[0-9]+\.[0-9]+ and compare it with '{0,3}'. A trailing non-numeric component such as 0.3.0dev can no longer break the ::int[] cast. This also removes the earlier two-component (0.3) concern.
  • A version with no numeric major.minor (such as stable) gives a NULL c_major_minor, so the check is skipped. A missing cat_tools row also gives NULL and is skipped, and CREATE EXTENSION then fails normally on the missing dependency.
  • The error uses object_not_in_prerequisite_state and has a useful DETAIL and HINT.
  • The META.in.json and README wording agree.

Minor, non-blocking: the update-script check is the same text as the install check, and its failure path isn't exercised, as the PR description says. Update scripts can't share code with the main script, so I think the duplication is acceptable.

@jnasbyupgrade
jnasbyupgrade merged commit bd380a4 into Postgres-Extensions:master Nov 4, 2026
13 checks passed
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