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
3 changes: 3 additions & 0 deletions internal/diff/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ func functionsEqualExceptAttributes(old, new *ir.Function) bool {
if old.IsSecurityDefiner != new.IsSecurityDefiner {
return false
}
if old.SearchPath != new.SearchPath {
return false
}
// Note: We intentionally do NOT compare IsLeakproof or Parallel here
// That's the whole point - we want to detect when only those attributes changed

Expand Down
13 changes: 13 additions & 0 deletions testdata/diff/create_function/alter_function_attributes/diff.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,16 @@ ALTER FUNCTION calculate_total(numeric, numeric) LEAKPROOF;
ALTER FUNCTION process_data(text) PARALLEL SAFE;

ALTER FUNCTION process_data(text) LEAKPROOF;

CREATE OR REPLACE FUNCTION secure_lookup(
id integer
)
RETURNS text
LANGUAGE plpgsql
VOLATILE
SET search_path = pg_catalog
AS $$
BEGIN
RETURN 'result';
END;
$$;
10 changes: 10 additions & 0 deletions testdata/diff/create_function/alter_function_attributes/new.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,13 @@ LEAKPROOF
AS $$
SELECT amount * (1 + tax_rate);
$$;

CREATE FUNCTION secure_lookup(id integer)
RETURNS text
LANGUAGE plpgsql
SET search_path = pg_catalog
AS $$
BEGIN
RETURN 'result';
END;
$$;
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ STABLE
AS $$
SELECT amount * (1 + tax_rate);
$$;

CREATE FUNCTION secure_lookup(id integer)
RETURNS text
LANGUAGE plpgsql
AS $$
BEGIN
RETURN 'result';
END;
$$;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"pgschema_version": "1.6.0",
"created_at": "1970-01-01T00:00:00Z",
"source_fingerprint": {
"hash": "d3760381c0e30abb35769924c7ae22d0868a81496ec73d6c427a39d4a3abe131"
"hash": "1f121ae09b8a9c9a88444396c16c27b8690f6ff7a123cf72c204103111a49649"
},
"groups": [
{
Expand Down Expand Up @@ -31,6 +31,12 @@
"type": "function",
"operation": "alter",
"path": "public.process_data"
},
{
"sql": "CREATE OR REPLACE FUNCTION secure_lookup(\n id integer\n)\nRETURNS text\nLANGUAGE plpgsql\nVOLATILE\nSET search_path = pg_catalog\nAS $$\nBEGIN\n RETURN 'result';\nEND;\n$$;",
"type": "function",
"operation": "alter",
"path": "public.secure_lookup"
}
]
}
Expand Down
13 changes: 13 additions & 0 deletions testdata/diff/create_function/alter_function_attributes/plan.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,16 @@ ALTER FUNCTION calculate_total(numeric, numeric) LEAKPROOF;
ALTER FUNCTION process_data(text) PARALLEL SAFE;

ALTER FUNCTION process_data(text) LEAKPROOF;

CREATE OR REPLACE FUNCTION secure_lookup(
id integer
)
RETURNS text
LANGUAGE plpgsql
VOLATILE
SET search_path = pg_catalog
AS $$
BEGIN
RETURN 'result';
END;
$$;
18 changes: 16 additions & 2 deletions testdata/diff/create_function/alter_function_attributes/plan.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
Plan: 4 to modify.
Plan: 5 to modify.

Summary by type:
functions: 4 to modify
functions: 5 to modify

Functions:
~ calculate_total
~ calculate_total
~ process_data
~ process_data
~ secure_lookup

DDL to be executed:
--------------------------------------------------
Expand All @@ -19,3 +20,16 @@ ALTER FUNCTION calculate_total(numeric, numeric) LEAKPROOF;
ALTER FUNCTION process_data(text) PARALLEL SAFE;

ALTER FUNCTION process_data(text) LEAKPROOF;

CREATE OR REPLACE FUNCTION secure_lookup(
id integer
)
RETURNS text
LANGUAGE plpgsql
VOLATILE
SET search_path = pg_catalog
AS $$
BEGIN
RETURN 'result';
END;
$$;