Changeset: 6a2511b13bd4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6a2511b13bd4 Modified Files: sql/server/rel_psm.c sql/test/miscellaneous/Tests/simple_selects.sql sql/test/miscellaneous/Tests/simple_selects.stable.err Branch: default Log Message:
Disallow creating aggregates and functions with the same name, schema and parameters simultaneously. That would lead to ambiguous calls diffs (44 lines): diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c --- a/sql/server/rel_psm.c +++ b/sql/server/rel_psm.c @@ -820,6 +820,9 @@ rel_create_func(sql_query *query, dlist return sql_error(sql, 02, SQLSTATE(3F000) "CREATE %s: no such schema '%s'", F, sname); type_list = create_type_list(sql, params, 1); + if ((type == F_FUNC || type == F_AGGR) && sql_bind_func_(sql->sa, s, fname, type_list, (type == F_FUNC) ? F_AGGR : F_FUNC)) + return sql_error(sql, 02, SQLSTATE(42000) "CREATE %s: there's %s with the name '%s' and the same parameters, which causes ambiguous calls", F, (type == F_FUNC) ? "an aggregate" : "a function", fname); + if ((sf = sql_bind_func_(sql->sa, s, fname, type_list, type)) != NULL && create) { if (replace) { sql_func *func = sf->func; diff --git a/sql/test/miscellaneous/Tests/simple_selects.sql b/sql/test/miscellaneous/Tests/simple_selects.sql --- a/sql/test/miscellaneous/Tests/simple_selects.sql +++ b/sql/test/miscellaneous/Tests/simple_selects.sql @@ -70,6 +70,9 @@ select substring('abc' from 1 for null); select substring('abc' from null for 2); select substring('abc' from null for null); +CREATE FUNCTION count(input INT) RETURNS INT BEGIN RETURN SELECT 1; END; --error, ambiguous, there's an aggregate named count with the same parameters +CREATE AGGREGATE sin(input REAL) RETURNS REAL EXTERNAL NAME "mmath"."sin"; --error, ambiguous, there's a function named sin with the same parameters + select length(myblob), octet_length(myblob), length(mystr), octet_length(mystr) from (values (cast(null as blob), cast(null as char(32)))) as my(myblob, mystr); select md5(null); diff --git a/sql/test/miscellaneous/Tests/simple_selects.stable.err b/sql/test/miscellaneous/Tests/simple_selects.stable.err --- a/sql/test/miscellaneous/Tests/simple_selects.stable.err +++ b/sql/test/miscellaneous/Tests/simple_selects.stable.err @@ -117,6 +117,14 @@ MAPI = (monetdb) /var/tmp/mtest-316445/ QUERY = select cast(true as interval month); --error, not possible ERROR = !types boolean(1,0) and month_interval(3,0) are not equal CODE = 42000 +MAPI = (monetdb) /var/tmp/mtest-416559/.s.monetdb.32222 +QUERY = CREATE FUNCTION count(input INT) RETURNS INT BEGIN RETURN SELECT 1; END; --error, ambiguous, there's an aggregate named count with the same parameters +ERROR = !CREATE FUNCTION: there's an aggregate with the name 'count' and the same parameters, which causes ambiguous calls +CODE = 42000 +MAPI = (monetdb) /var/tmp/mtest-416559/.s.monetdb.32222 +QUERY = CREATE AGGREGATE sin(input REAL) RETURNS REAL EXTERNAL NAME "mmath"."sin"; --error, ambiguous, there's a function named sin with the same parameters +ERROR = !CREATE AGGREGATE: there's a function with the name 'sin' and the same parameters, which causes ambiguous calls +CODE = 42000 # 17:31:38 > # 17:31:38 > "Done." _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list