Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/dump/dump_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ func TestDumpCommand_Issue183GeneratedColumn(t *testing.T) {
runExactMatchTest(t, "issue_183_generated_column")
}

func TestDumpCommand_Issue275TruncatedFunctionGrants(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
runExactMatchTest(t, "issue_275_truncated_function_grants")
}

func runExactMatchTest(t *testing.T, testDataDir string) {
runExactMatchTestWithContext(t, context.Background(), testDataDir)
}
Expand Down
6 changes: 3 additions & 3 deletions ir/queries/queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ WITH acl_data AS (
-- Tables and Views
SELECT
n.nspname AS schema_name,
c.relname AS object_name,
c.relname::text AS object_name,
CASE c.relkind
WHEN 'r' THEN 'TABLE'
WHEN 'v' THEN 'VIEW'
Expand Down Expand Up @@ -1287,7 +1287,7 @@ WITH acl_data AS (
-- Types (ENUM, COMPOSITE, DOMAIN)
SELECT
n.nspname AS schema_name,
t.typname AS object_name,
t.typname::text AS object_name,
'TYPE' AS object_type,
t.typacl AS acl,
pg_get_userbyid(t.typowner) AS owner
Expand Down Expand Up @@ -1337,7 +1337,7 @@ WITH objects_with_acl AS (

-- Types
SELECT
t.typname AS object_name,
t.typname::text AS object_name,
'TYPE' AS object_type,
t.typacl AS acl
FROM pg_type t
Expand Down
6 changes: 3 additions & 3 deletions ir/queries/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions testdata/dump/issue_275_truncated_function_grants/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "issue_275_truncated_function_grants",
"description": "Test case for truncated function signatures in GRANT statements (GitHub issue #275)",
"source": "https://github.com/pgplex/pgschema/issues/275",
"notes": [
"Reproduces the bug where function signatures in GRANT EXECUTE statements are truncated to 63 characters",
"The truncation is caused by PostgreSQL name type (63 char limit) in UNION ALL type resolution",
"Tests that function signatures longer than 63 characters are preserved in full in GRANT statements"
]
}
41 changes: 41 additions & 0 deletions testdata/dump/issue_275_truncated_function_grants/pgdump.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
--
-- PostgreSQL database dump
--

SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;

-- Create test role
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'api_role') THEN
CREATE ROLE api_role;
END IF;
END $$;

--
-- Name: process_user_data(uuid, text, text, boolean); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.process_user_data(user_id uuid, user_name text, user_email text, is_active boolean) RETURNS void
LANGUAGE plpgsql
AS $$
BEGIN
-- no-op
END;
$$;

--
-- Name: FUNCTION process_user_data(user_id uuid, user_name text, user_email text, is_active boolean); Type: ACL; Schema: public; Owner: -
--

GRANT EXECUTE ON FUNCTION public.process_user_data(user_id uuid, user_name text, user_email text, is_active boolean) TO api_role;

--
-- PostgreSQL database dump complete
--
33 changes: 33 additions & 0 deletions testdata/dump/issue_275_truncated_function_grants/pgschema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--
-- pgschema database dump
--

-- Dumped from database version PostgreSQL 18.0
-- Dumped by pgschema version 1.5.1


--
-- Name: process_user_data(uuid, text, text, boolean); Type: FUNCTION; Schema: -; Owner: -
--

CREATE OR REPLACE FUNCTION process_user_data(
user_id uuid,
user_name text,
user_email text,
is_active boolean
)
RETURNS void
LANGUAGE plpgsql
VOLATILE
AS $$
BEGIN
-- no-op
END;
$$;

--
-- Name: process_user_data(user_id uuid, user_name text, user_email text, is_active boolean); Type: PRIVILEGE; Schema: privileges; Owner: -
--

GRANT EXECUTE ON FUNCTION process_user_data(user_id uuid, user_name text, user_email text, is_active boolean) TO api_role;

27 changes: 27 additions & 0 deletions testdata/dump/issue_275_truncated_function_grants/raw.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--
-- Test case for GitHub issue #275: Truncated functions in grants
--
-- This test case reproduces a bug where function signatures in GRANT EXECUTE
-- statements are truncated to 63 characters (PostgreSQL name type limit).
--
-- The function signature "process_user_data(user_id uuid, user_name text, user_email text, is_active boolean)"
-- gets truncated to 63 chars without the fix.
--

DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'api_role') THEN
CREATE ROLE api_role;
END IF;
END $$;

CREATE FUNCTION process_user_data(user_id uuid, user_name text, user_email text, is_active boolean)
RETURNS void
LANGUAGE plpgsql
AS $$
BEGIN
-- no-op
END;
$$;

GRANT EXECUTE ON FUNCTION process_user_data(uuid, text, text, boolean) TO api_role;