Skip to content

fix: truncated function signatures in GRANT statements (#275)#288

Merged
tianzhou merged 1 commit intomainfrom
fix/issue-275-truncated-function-grants
Feb 15, 2026
Merged

fix: truncated function signatures in GRANT statements (#275)#288
tianzhou merged 1 commit intomainfrom
fix/issue-275-truncated-function-grants

Conversation

@tianzhou
Copy link
Contributor

Summary

  • Function signatures in privilege GRANT statements were truncated to 63 characters due to PostgreSQL's name type (NAMEDATALEN-1) limit
  • In UNION ALL queries combining c.relname/t.typname (type name) with function signature text expressions, PostgreSQL resolved the result column to name, silently truncating longer values
  • Fix: cast relname and typname to text in the privilege UNION ALL queries (GetPrivilegesForSchema and GetRevokedDefaultPrivilegesForSchema)

Fixes #275

Test plan

  • Added dump test issue_275_truncated_function_grants with a function whose signature exceeds 63 characters
  • Test verifies full function signature preserved in both comment header and GRANT statement
  • All existing privilege tests pass (grant_function_execute, revoke_public_function, etc.)
  • Full test suite passes

Run the new test:

go test -v ./cmd/dump -run TestDumpCommand_Issue275

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings February 15, 2026 13:55
@tianzhou tianzhou force-pushed the fix/issue-275-truncated-function-grants branch from b2fb5dc to a437728 Compare February 15, 2026 13:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 GetPrivilegesForSchema and GetRevokedDefaultPrivilegesForSchema SQL queries by casting c.relname and t.typname to text in 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>
@tianzhou tianzhou force-pushed the fix/issue-275-truncated-function-grants branch from a437728 to 432264b Compare February 15, 2026 14:06
@tianzhou tianzhou merged commit 96929c9 into main Feb 15, 2026
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.

Truncated functions in grants

1 participant