1
0
mirror of https://github.com/MariaDB/server.git synced 2025-05-02 19:25:03 +03:00
mariadb/mysql-test/t/log_bin_trust_function_creators_func.test
Luis Soares 14d4576bfe merge: 5.1 -> 5.1-rpl
conflicts:
  Text conflict in client/mysqltest.cc
  Text conflict in mysql-test/include/wait_until_connected_again.inc
  Text conflict in mysql-test/lib/mtr_report.pm
  Text conflict in mysql-test/mysql-test-run.pl
  Text conflict in mysql-test/r/events_bugs.result
  Text conflict in mysql-test/r/log_state.result
  Text conflict in mysql-test/r/myisam_data_pointer_size_func.result
  Text conflict in mysql-test/r/mysqlcheck.result
  Text conflict in mysql-test/r/query_cache.result
  Text conflict in mysql-test/r/status.result
  Text conflict in mysql-test/suite/binlog/r/binlog_index.result
  Text conflict in mysql-test/suite/binlog/r/binlog_innodb.result
  Text conflict in mysql-test/suite/rpl/r/rpl_packet.result
  Text conflict in mysql-test/suite/rpl/t/rpl_packet.test
  Text conflict in mysql-test/t/disabled.def
  Text conflict in mysql-test/t/events_bugs.test
  Text conflict in mysql-test/t/log_state.test
  Text conflict in mysql-test/t/myisam_data_pointer_size_func.test
  Text conflict in mysql-test/t/mysqlcheck.test
  Text conflict in mysql-test/t/query_cache.test
  Text conflict in mysql-test/t/rpl_init_slave_func.test
  Text conflict in mysql-test/t/status.test
2009-01-23 13:22:05 +01:00

152 lines
4.8 KiB
Plaintext

############## mysql-test\t\log_bin_trust_function_creators_func.test #########
# #
# Variable Name: log_bin_trust_function_creators #
# Scope: GLOBAL | SESSION #
# Access Type: Dynamic #
# Data Type: boolean #
# Default Value: False #
# Range: #
# #
# #
# Creation Date: 2008-03-11 #
# Author: Salman Rawala #
# #
# Description: Test Cases of Dynamic System Variable #
# log_bin_trust_function_creators that checks the functionality #
# of this variable in the following ways #
# #
# Reference: http://dev.mysql.com/doc/refman/5.1/en/server-system #
# -variables.html#option_mysqld_log-bin-trust-function-ceators #
# #
###############################################################################
source include/have_log_bin.inc;
--disable_warnings
drop table if exists t1;
--enable_warnings
--echo '#--------------------FN_DYNVARS_063_01-------------------------#'
########################################################################
# Setting initial value of variable to 0 and verifying whether user
# is allowed to create function or not.
########################################################################
SET @start_value= @@global.log_bin_trust_function_creators;
--echo ## Creating new user tt ##
CREATE USER tt@localhost;
--echo ## Setting value of variable to 0 ##
SET @@global.log_bin_trust_function_creators = 0;
--echo ## Creating new table t2 ##
CREATE TABLE t2 (a INT);
--echo ## Creating & connecting with new connection test_con1 ##
connect (test_con1,localhost,tt,,);
connection test_con1;
SELECT @@log_bin_trust_function_creators;
--echo ## Creating new function f1 fails because no DETERMINISTIC ###
delimiter |;
--error ER_BINLOG_UNSAFE_ROUTINE
CREATE FUNCTION f1(a INT) RETURNS INT
BEGIN
IF (a < 3) THEN
INSERT INTO t2 VALUES (a);
END IF;
RETURN 1;
END|
delimiter ;|
--echo ## Creating new function f1 fails because non-super user ##
delimiter |;
--error ER_BINLOG_CREATE_ROUTINE_NEED_SUPER
CREATE FUNCTION f1(a INT) RETURNS INT DETERMINISTIC
BEGIN
IF (a < 3) THEN
INSERT INTO t2 VALUES (a);
END IF;
RETURN 1;
END|
delimiter ;|
connection default;
--echo ## Creating new function f1 succeeds ##
delimiter |;
CREATE FUNCTION f1(a INT) RETURNS INT DETERMINISTIC
BEGIN
IF (a < 3) THEN
INSERT INTO t2 VALUES (a);
END IF;
RETURN 1;
END|
delimiter ;|
--echo ## Creating new table t1 ##
CREATE TABLE t1 (a INT);
--echo ## Inserting some records in t1 ##
INSERT INTO t1 VALUES (1),(2),(3);
SELECT f1(a) FROM t1;
--echo ## Dropping function f1 & table t1 ##
DROP FUNCTION f1;
DROP TABLE t1;
--echo '#--------------------FN_DYNVARS_063_02-------------------------#'
########################################################################
# Setting initial value of variable to 1 and verifying whether user
# is allowed to create function or not.
########################################################################
--echo ## Switching to default connection ##
connection default;
--echo ## Setting value of variable to 1 ##
SET @@global.log_bin_trust_function_creators = 1;
--echo ## Creating and connecting to new connection test_con2 ##
connect (test_con2,localhost,tt,,);
connection test_con2;
--echo ## Verifying value of variable ##
SELECT @@log_bin_trust_function_creators;
SELECT @@sql_log_bin;
--echo ## Creating new function f1 ##
delimiter |;
CREATE FUNCTION f1(a INT) RETURNS INT
BEGIN
IF (a < 3) THEN
INSERT INTO t2 VALUES (a);
END IF;
RETURN 1;
END|
delimiter ;|
--echo ## Creating new table t1 ##
CREATE TABLE t1 (a INT);
--echo ## Inserting values in table t1 ##
INSERT INTO t1 VALUES (1),(2),(3);
SELECT f1(a) FROM t1;
--echo ## Dropping function f1 ##
DROP FUNCTION f1;
--echo ## Dropping table t1 & t2 ##
DROP TABLE t1,t2;
--echo ## Disconnecting test_con2##
disconnect test_con2;
connection default;
DROP USER tt@localhost;
SET @@global.log_bin_trust_function_creators= @start_value;