Skip to content

Reject extension names that overflow generated function names#310

Open
jim-mlodgenski wants to merge 1 commit into
aws:mainfrom
jim-mlodgenski:fix-long-extension-name-collision
Open

Reject extension names that overflow generated function names#310
jim-mlodgenski wants to merge 1 commit into
aws:mainfrom
jim-mlodgenski:fix-long-extension-name-collision

Conversation

@jim-mlodgenski

Copy link
Copy Markdown
Contributor

Issue #, if available: #100

Description of changes:

pg_tle represents each extension artifact as a function whose name is
derived from the extension name and version (".control",
"--.sql", "----.sql"). PostgreSQL
silently truncates identifiers at NAMEDATALEN, so a sufficiently long
extension name or version produced derived names that truncated to the
same identifier. The control and sql-string functions then collided:
the install appeared to succeed but left the extension invisible to
pgtle.available_extensions(), and a subsequent install failed with a
misleading "extension already installed" error.

This change adds check_generated_function_name() and calls it at each
install site (install_extension, install_extension_version_sql,
install_update_path) right after the name is built and before any
function is created. An over-long name now fails up front with a clear
ERRCODE_NAME_TOO_LONG error and nothing is created. The
pg_tle_management regression test is extended with coverage for the
name and version overflow cases, the update-path form, and a boundary
name that still fits.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

pg_tle derives a function name from the extension name and version for
each artifact. PostgreSQL truncates identifiers at NAMEDATALEN, so a
long enough name or version made these collide, leaving the extension
unusable and reporting a misleading "already installed" error.

Add check_generated_function_name() and call it at each install site
before any function is created, so an over-long name fails up front
with a clear error and nothing is created.

Fixes aws#100.
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