Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-23.2: sql: allow dropping routines with UDT-typed parameters #115904

Merged
merged 1 commit into from Dec 11, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
63 changes: 63 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/drop_function
Expand Up @@ -187,3 +187,66 @@ SET search_path = public

statement ok
DROP SCHEMA sc1;

# Regression test for #114677 - it should be possible to drop a function with
# a UDT parameter
subtest udt_parameter

statement ok
CREATE TYPE t114677 AS (x INT, y INT);
CREATE TYPE t114677_2 AS (a INT, b INT);

# Create an overload with a composite type that has the same signature to verify
# that the correct overload is dropped.
statement ok
CREATE FUNCTION f114677(v t114677) RETURNS INT LANGUAGE SQL AS $$ SELECT 0; $$;
CREATE FUNCTION f114677(v t114677_2) RETURNS INT LANGUAGE SQL AS $$ SELECT 1; $$;

query T nosort
SELECT create_statement FROM [SHOW CREATE FUNCTION f114677] ORDER BY create_statement;
----
CREATE FUNCTION public.f114677(IN v T114677)
RETURNS INT8
VOLATILE
NOT LEAKPROOF
CALLED ON NULL INPUT
LANGUAGE SQL
AS $$
SELECT 0;
$$
CREATE FUNCTION public.f114677(IN v T114677_2)
RETURNS INT8
VOLATILE
NOT LEAKPROOF
CALLED ON NULL INPUT
LANGUAGE SQL
AS $$
SELECT 1;
$$

statement error pgcode 42725 pq: function name \"f114677\" is not unique
DROP FUNCTION f114677;

statement ok
DROP FUNCTION f114677(t114677);

query T
SELECT create_statement FROM [SHOW CREATE FUNCTION f114677];
----
CREATE FUNCTION public.f114677(IN v T114677_2)
RETURNS INT8
VOLATILE
NOT LEAKPROOF
CALLED ON NULL INPUT
LANGUAGE SQL
AS $$
SELECT 1;
$$

statement ok
DROP FUNCTION f114677;

statement error pgcode 42883 unknown function: f114677\(\)
SHOW CREATE FUNCTION f114677;

subtest end
15 changes: 15 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/drop_procedure
Expand Up @@ -167,3 +167,18 @@ SET search_path = public

statement ok
DROP SCHEMA sc1

# Regression test for #114677 - it should be possible to drop a procedure with
# a UDT parameter
subtest udt_parameter

statement ok
CREATE TYPE t114677 AS (x INT, y INT);

statement ok
CREATE PROCEDURE p114677(v t114677) LANGUAGE SQL AS $$ SELECT 0; $$;

statement ok
DROP PROCEDURE p114677(t114677);

subtest end
3 changes: 0 additions & 3 deletions pkg/sql/sem/tree/overload.go
Expand Up @@ -430,9 +430,6 @@ func (p ParamTypes) MatchAt(typ *types.T, i int) bool {

// MatchAtIdentical is part of the TypeList interface.
func (p ParamTypes) MatchAtIdentical(typ *types.T, i int) bool {
if typ.Family() == types.TupleFamily {
typ = types.AnyTuple
}
return i < len(p) && (typ.Family() == types.UnknownFamily || p[i].Typ.Identical(typ))
}

Expand Down