Skip to content

Fix uninstall_extension dropping prefix-named sibling extensions - #319

Open
jim-mlodgenski wants to merge 2 commits into
mainfrom
fix/uninstall-prefix-collision
Open

Fix uninstall_extension dropping prefix-named sibling extensions#319
jim-mlodgenski wants to merge 2 commits into
mainfrom
fix/uninstall-prefix-collision

Conversation

@jim-mlodgenski

Copy link
Copy Markdown
Contributor

Supersedes #314 (rebased onto current main to resolve a conflict; #314's source branch lives on a fork we can't push to). Original work by @jnasbyupgrade.

What this does

pgtle.uninstall_extension() located registration functions to drop using LIKE '<extname>%.control' / '<extname>%.sql' patterns. Because % immediately follows the name, the patterns also matched artifacts of any other extension whose name has <extname> as a prefix — so uninstalling foo silently dropped foo_bar too. _ (a LIKE wildcard) widened the over-match further, and uninstall_extension('') matched %.control and tried to drop every registered extension.

Fix:

  • Match the control function by exact equality (<extname>.control).
  • Match script functions with an anchored regex on the -- separator (^<ext>--...\.sql$), regex-escaping the name/version so metacharacters are literal. This also lets the two-arg form express "version is one of the ---delimited tokens" precisely (removing a latent 1.1 vs 1.10 over-match).

Delivered in the (unreleased) 1.5.2 -> 1.5.3 upgrade script, alongside set_extension_schema (#311).

Conflict resolution vs #314

  • Combined both features into the single pg_tle--1.5.2--1.5.3.sql (1.5.3 is not yet tagged), rather than bumping to 1.5.4.
  • Corrected stale CONTEXT ... line numbers in pg_tle_functions_acl.out (23->29, 61->66) — the committed expected output predated the comment block added to uninstall_extension(text); pg_tle_management.out was already updated but this file was missed.

Testing

make installcheck on PG 17: passes with parity to main (the unrelated pg_tle_extension_schema flake reproduces on pristine main locally and is green in CI).

Co-authored-by: jnasbyupgrade jnasby@upgrade.com

jnasbyupgrade and others added 2 commits July 9, 2026 17:01
uninstall_extension() matched the functions to drop with LIKE patterns of
the forms <extname>%.control and <extname>%.sql. Because the % immediately
follows the name, the patterns also matched any other extension whose name
has <extname> as a prefix, so uninstalling 'foo' silently dropped the
registration of 'foo_bar'. Names may also contain '_' (a LIKE wildcard),
and uninstall_extension('') matched every extension's control function.

Match the control function by exact name and the script functions with an
anchored, metacharacter-escaped regular expression, delivered as a new
1.5.2 -> 1.5.3 upgrade script that replaces both uninstall_extension
overloads.

Co-Authored-By: Claude Opus 4.8 (1M context) <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.

2 participants