fix: truncated function signatures in GRANT statements (#275)#288
Merged
fix: truncated function signatures in GRANT statements (#275)#288
Conversation
b2fb5dc to
a437728
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where function signatures in GRANT EXECUTE statements were truncated to 63 characters due to PostgreSQL's name type limit. The issue occurred in UNION ALL queries where name-typed columns (c.relname, t.typname) were combined with text expressions (function signatures), causing PostgreSQL to resolve the result column type to name and silently truncate longer values.
Changes:
- Fixed
GetPrivilegesForSchemaandGetRevokedDefaultPrivilegesForSchemaSQL queries by castingc.relnameandt.typnametotextin UNION ALL queries - Added comprehensive integration test case with a function signature exceeding 63 characters to verify the fix
- Added Claude Code workflow documentation for bug fixing and refactoring
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
ir/queries/queries.sql |
Cast c.relname and t.typname to text type in privilege UNION ALL queries to prevent truncation |
ir/queries/queries.sql.go |
Regenerated Go code with updated SQL queries containing the type casts |
testdata/dump/issue_275_truncated_function_grants/raw.sql |
Test input SQL with function having 90-character signature |
testdata/dump/issue_275_truncated_function_grants/pgschema.sql |
Expected output verifying full signature preservation |
testdata/dump/issue_275_truncated_function_grants/pgdump.sql |
PostgreSQL pg_dump baseline for comparison |
testdata/dump/issue_275_truncated_function_grants/manifest.json |
Test case metadata and documentation |
cmd/dump/dump_integration_test.go |
Test registration for the new test case |
.claude/skills/refactor-pass/SKILL.md |
Claude Code workflow documentation for refactoring |
.claude/skills/fix_bug/SKILL.md |
Claude Code workflow documentation for bug fixing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Function signatures in privilege GRANT statements were truncated to 63 characters due to PostgreSQL's `name` type limit. In UNION ALL queries combining `relname`/`typname` (type `name`, 63 chars max) with function signature expressions (type `text`), the result column resolved to `name`, silently truncating longer function signatures. Fix: explicitly cast `relname` and `typname` to `text` in the privilege UNION ALL queries to ensure the result column type is `text`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
a437728 to
432264b
Compare
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.
Summary
nametype (NAMEDATALEN-1) limitc.relname/t.typname(typename) with function signature text expressions, PostgreSQL resolved the result column toname, silently truncating longer valuesrelnameandtypnametotextin the privilege UNION ALL queries (GetPrivilegesForSchemaandGetRevokedDefaultPrivilegesForSchema)Fixes #275
Test plan
issue_275_truncated_function_grantswith a function whose signature exceeds 63 charactersRun the new test:
go test -v ./cmd/dump -run TestDumpCommand_Issue275🤖 Generated with Claude Code