summaryrefslogtreecommitdiffstats
path: root/mysql-test/main/create_drop_function.test
blob: 3c4770e25e3bca9e834a13e9cd1e50f8349ec25c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
source include/have_log_bin.inc;

SET timestamp=UNIX_TIMESTAMP('2014-09-30 08:00:00');

CREATE FUNCTION f1(str char(20))
RETURNS CHAR(100)
RETURN CONCAT('Hello, ', str, '!');
SELECT * FROM mysql.proc WHERE name like 'f1';
SELECT f1('world');

--error ER_SP_ALREADY_EXISTS
CREATE FUNCTION f1(str char(20))
RETURNS TEXT
RETURN CONCAT('Hello2, ', str, '!');
SELECT body FROM mysql.proc WHERE name like 'f1';

CREATE FUNCTION IF NOT EXISTS f1(str char(20))
RETURNS CHAR(100)
RETURN CONCAT('Hello3, ', str, '!');
SELECT body FROM mysql.proc WHERE name like 'f1';

--error ER_WRONG_USAGE
CREATE OR REPLACE FUNCTION IF NOT EXISTS f1(str char(20))
RETURNS CHAR(100)
RETURN CONCAT('Hello4, ', str, '!');
SELECT body FROM mysql.proc WHERE name like 'f1';

CREATE OR REPLACE FUNCTION f1(str char(20))
RETURNS CHAR(100)
RETURN CONCAT('Hello5, ', str, '!');
SELECT body FROM mysql.proc WHERE name like 'f1';

DROP FUNCTION f1;
CREATE FUNCTION IF NOT EXISTS f1(str char(20))
RETURNS CHAR(100)
RETURN CONCAT('Hello6, ', str, '!');
SELECT body FROM mysql.proc WHERE name like 'f1';
SELECT f1('world');

DROP FUNCTION IF EXISTS f1;
SELECT body FROM mysql.proc WHERE name like 'f1';
DROP FUNCTION IF EXISTS f1;

--echo #
--echo # 10.1 Test
--echo #
--echo # MDEV-22654: Assertion `!is_set() || (m_status == DA_OK_BULK &&
--echo # is_bulk_op())' failed in Diagnostics_area::set_ok_status on FUNCTION replace
--echo #

SET GLOBAL log_bin_trust_function_creators=0;

CREATE FUNCTION f(c INT) RETURNS NUMERIC NO SQL RETURN 0;

--error ER_BINLOG_UNSAFE_ROUTINE
CREATE OR REPLACE FUNCTION f(c INT) RETURNS INT RETURN 0;

--error ER_TOO_LONG_IDENT
CREATE OR REPLACE FUNCTION sp1_thisisaveryverylongnamelongnameverylongname_thisisaveryverylongname234872934(a INT) RETURNS INT RETURN 0;

DROP FUNCTION IF EXISTS f;

SET GLOBAL log_bin_trust_function_creators=1;

--echo # End of 10.1 Test