| 1 |
drop table if exists t1; |
| 2 |
'#--------------------FN_DYNVARS_063_01-------------------------#' |
| 3 |
SET @start_value= @@global.log_bin_trust_function_creators; |
| 4 |
Warnings: |
| 5 |
Warning 1287 '@@log_bin_trust_function_creators' is deprecated and will be removed in a future release. |
| 6 |
## Creating new user tt ## |
| 7 |
CREATE USER tt@localhost; |
| 8 |
## Setting value of variable to 0 ## |
| 9 |
SET @@global.log_bin_trust_function_creators = 0; |
| 10 |
Warnings: |
| 11 |
Warning 1287 '@@log_bin_trust_function_creators' is deprecated and will be removed in a future release. |
| 12 |
## Creating new table t2 ## |
| 13 |
CREATE TABLE t2 (a INT); |
| 14 |
## Creating & connecting with new connection test_con1 ## |
| 15 |
SELECT @@log_bin_trust_function_creators; |
| 16 |
@@log_bin_trust_function_creators |
| 17 |
0 |
| 18 |
Warnings: |
| 19 |
Warning 1287 '@@log_bin_trust_function_creators' is deprecated and will be removed in a future release. |
| 20 |
## Creating new function f1 fails because no DETERMINISTIC ### |
| 21 |
CREATE FUNCTION f1(a INT) RETURNS INT |
| 22 |
BEGIN |
| 23 |
IF (a < 3) THEN |
| 24 |
INSERT INTO t2 VALUES (a); |
| 25 |
END IF; |
| 26 |
RETURN 1; |
| 27 |
END| |
| 28 |
ERROR HY000: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable) |
| 29 |
## Creating new function f1 fails because non-super user ## |
| 30 |
CREATE FUNCTION f1(a INT) RETURNS INT DETERMINISTIC |
| 31 |
BEGIN |
| 32 |
IF (a < 3) THEN |
| 33 |
INSERT INTO t2 VALUES (a); |
| 34 |
END IF; |
| 35 |
RETURN 1; |
| 36 |
END| |
| 37 |
ERROR HY000: You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable) |
| 38 |
## Creating new function f1 succeeds ## |
| 39 |
CREATE FUNCTION f1(a INT) RETURNS INT DETERMINISTIC |
| 40 |
BEGIN |
| 41 |
IF (a < 3) THEN |
| 42 |
INSERT INTO t2 VALUES (a); |
| 43 |
END IF; |
| 44 |
RETURN 1; |
| 45 |
END| |
| 46 |
## Creating new table t1 ## |
| 47 |
CREATE TABLE t1 (a INT); |
| 48 |
## Inserting some records in t1 ## |
| 49 |
INSERT INTO t1 VALUES (1),(2),(3); |
| 50 |
SELECT f1(a) FROM t1; |
| 51 |
f1(a) |
| 52 |
1 |
| 53 |
1 |
| 54 |
1 |
| 55 |
## Dropping function f1 & table t1 ## |
| 56 |
DROP FUNCTION f1; |
| 57 |
DROP TABLE t1; |
| 58 |
'#--------------------FN_DYNVARS_063_02-------------------------#' |
| 59 |
## Switching to default connection ## |
| 60 |
## Setting value of variable to 1 ## |
| 61 |
SET @@global.log_bin_trust_function_creators = 1; |
| 62 |
Warnings: |
| 63 |
Warning 1287 '@@log_bin_trust_function_creators' is deprecated and will be removed in a future release. |
| 64 |
## Creating and connecting to new connection test_con2 ## |
| 65 |
## Verifying value of variable ## |
| 66 |
SELECT @@log_bin_trust_function_creators; |
| 67 |
@@log_bin_trust_function_creators |
| 68 |
1 |
| 69 |
Warnings: |
| 70 |
Warning 1287 '@@log_bin_trust_function_creators' is deprecated and will be removed in a future release. |
| 71 |
SELECT @@sql_log_bin; |
| 72 |
@@sql_log_bin |
| 73 |
1 |
| 74 |
## Creating new function f1 ## |
| 75 |
CREATE FUNCTION f1(a INT) RETURNS INT |
| 76 |
BEGIN |
| 77 |
IF (a < 3) THEN |
| 78 |
INSERT INTO t2 VALUES (a); |
| 79 |
END IF; |
| 80 |
RETURN 1; |
| 81 |
END| |
| 82 |
## Creating new table t1 ## |
| 83 |
CREATE TABLE t1 (a INT); |
| 84 |
## Inserting values in table t1 ## |
| 85 |
INSERT INTO t1 VALUES (1),(2),(3); |
| 86 |
SELECT f1(a) FROM t1; |
| 87 |
f1(a) |
| 88 |
1 |
| 89 |
1 |
| 90 |
1 |
| 91 |
## Dropping function f1 ## |
| 92 |
DROP FUNCTION f1; |
| 93 |
## Dropping table t1 & t2 ## |
| 94 |
DROP TABLE t1,t2; |
| 95 |
## Disconnecting test_con2## |
| 96 |
DROP USER tt@localhost; |
| 97 |
SET @@global.log_bin_trust_function_creators= @start_value; |
| 98 |
Warnings: |
| 99 |
Warning 1287 '@@log_bin_trust_function_creators' is deprecated and will be removed in a future release. |