Reject extension names that overflow generated function names#310
Open
jim-mlodgenski wants to merge 1 commit into
Open
Reject extension names that overflow generated function names#310jim-mlodgenski wants to merge 1 commit into
jim-mlodgenski wants to merge 1 commit into
Conversation
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.
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.
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.