set @old_concurrent_insert= @@global.concurrent_insert;
set @@global.concurrent_insert= 0;
drop table if exists t1,t3;
drop procedure if exists bug4902|
create procedure bug4902()
begin
show grants for 'root'@'localhost';
end|
call bug4902()|
Grants for root@localhost
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION
call bug4902()|
Grants for root@localhost
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION
drop procedure bug4902|
drop procedure if exists bug4902_2|
create procedure bug4902_2()
begin
show processlist;
end|
call bug4902_2()|
show warnings|
Level	Code	Message
call bug4902_2()|
show warnings|
Level	Code	Message
drop procedure bug4902_2|
drop table if exists t1|
create table t1 (
id   char(16) not null default '',
data int not null
)|
drop procedure if exists bug3583|
drop procedure if exists bug3583|
create procedure bug3583()
begin
declare c int;
select * from t1;
select count(*) into c from t1;
select c;
end|
insert into t1 values ("x", 3), ("y", 5)|
set @x = @@query_cache_size|
Warnings:
Warning	1287	'@@query_cache_size' is deprecated and will be removed in a future release.
set global query_cache_size = 10*1024*1024|
Warnings:
Warning	1287	'@@query_cache_size' is deprecated and will be removed in a future release.
flush status|
flush query cache|
Warnings:
Warning	1681	'FLUSH QUERY CACHE' is deprecated and will be removed in a future release.
show status like 'Qcache_hits'|
Variable_name	Value
Qcache_hits	0
call bug3583()|
id	data
x	3
y	5
c
2
show status like 'Qcache_hits'|
Variable_name	Value
Qcache_hits	0
call bug3583()|
id	data
x	3
y	5
c
2
call bug3583()|
id	data
x	3
y	5
c
2
show status like 'Qcache_hits'|
Variable_name	Value
Qcache_hits	2
set global query_cache_size = @x|
Warnings:
Warning	1287	'@@query_cache_size' is deprecated and will be removed in a future release.
flush status|
flush query cache|
Warnings:
Warning	1681	'FLUSH QUERY CACHE' is deprecated and will be removed in a future release.
delete from t1|
drop procedure bug3583|
drop table t1|
drop procedure if exists bug6807|
create procedure bug6807()
begin
declare id int;
set id = connection_id();
kill query id;
select 'Not reached';
end|
call bug6807()|
ERROR 70100: Query execution was interrupted
call bug6807()|
ERROR 70100: Query execution was interrupted
drop procedure bug6807|
SET sql_mode = 'NO_ENGINE_SUBSTITUTION'|
Warnings:
Warning	3090	Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
drop function if exists bug10100f|
drop procedure if exists bug10100p|
drop procedure if exists bug10100t|
drop procedure if exists bug10100pt|
drop procedure if exists bug10100pv|
drop procedure if exists bug10100pd|
drop procedure if exists bug10100pc|
create function bug10100f(prm int) returns int
begin
if prm > 1 then
return prm * bug10100f(prm - 1);
end if;
return 1;
end|
create procedure bug10100p(prm int, inout res int)
begin
set res = res * prm;
if prm > 1 then
call bug10100p(prm - 1, res);
end if;
end|
create procedure bug10100t(prm int)
begin
declare res int;
set res = 1;
call bug10100p(prm, res);
select res;
end|
create table t3 (a int)|
insert into t3 values (0)|
create view v1 as select a from t3;
create procedure bug10100pt(level int, lim int)
begin
if level < lim then
update t3 set a=level;
FLUSH TABLES;
call bug10100pt(level+1, lim);
else
select * from t3;
end if;
end|
create procedure bug10100pv(level int, lim int)
begin
if level < lim then
update v1 set a=level;
FLUSH TABLES;
call bug10100pv(level+1, lim);
else
select * from v1;
end if;
end|
prepare stmt2 from "select * from t3;";
create procedure bug10100pd(level int, lim int)
begin
if level < lim then
select level;
prepare stmt1 from "update t3 set a=a+2";
execute stmt1;
FLUSH TABLES;
execute stmt1;
FLUSH TABLES;
execute stmt1;
FLUSH TABLES;
deallocate prepare stmt1;
execute stmt2;
select * from t3;
call bug10100pd(level+1, lim);
else
execute stmt2;
end if;
end|
create procedure bug10100pc(level int, lim int)
begin
declare lv int;
declare c cursor for select a from t3;
open c;
if level < lim then
select level;
fetch c into lv;
select lv;
update t3 set a=level+lv;
FLUSH TABLES;
call bug10100pc(level+1, lim);
else
select * from t3;
end if;
close c;
end|
set @@max_sp_recursion_depth=255|
set @var=1|
call bug10100p(255, @var)|
call bug10100pt(1,255)|
call bug10100pv(1,255)|
call bug10100pd(1,255)|
call bug10100pc(1,255)|
set @@max_sp_recursion_depth=0|
deallocate prepare stmt2|
drop function bug10100f|
drop procedure bug10100p|
drop procedure bug10100t|
drop procedure bug10100pt|
drop procedure bug10100pv|
drop procedure bug10100pd|
drop procedure bug10100pc|
drop view v1|
drop table t3|
SET sql_mode = default;
drop procedure if exists bug15298_1;
drop procedure if exists bug15298_2;
set @orig_sql_mode= @@sql_mode;
set sql_mode= (select replace(@@sql_mode,'NO_AUTO_CREATE_USER',''));
Warnings:
Warning	3090	Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
grant all privileges on test.* to 'mysqltest_1'@'localhost';
Warnings:
Warning	1287	Using GRANT for creating new user is deprecated and will be removed in future release. Create new user with CREATE USER statement.
set sql_mode= @orig_sql_mode;
Warnings:
Warning	3090	Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
create procedure 15298_1 () sql security definer show grants for current_user;
create procedure 15298_2 () sql security definer show grants;
call 15298_1();
Grants for root@localhost
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION
call 15298_2();
Grants for root@localhost
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION
drop user mysqltest_1@localhost;
drop procedure 15298_1;
drop procedure 15298_2;
drop table if exists t1;
drop procedure if exists p1;
create table t1 (value varchar(15));
create procedure p1() update t1 set value='updated' where value='old';
call p1();
insert into t1 (value) values ("old");
select get_lock('b26162',120);
get_lock('b26162',120)
1
select 'rl_acquirer', value from t1 where get_lock('b26162',120);;
set session low_priority_updates=on;
call p1();;
select 'rl_contender', value from t1;
rl_contender	value
rl_contender	old
select release_lock('b26162');
release_lock('b26162')
1
rl_acquirer	value
rl_acquirer	old
drop procedure p1;
drop table t1;
set session low_priority_updates=default;
INSERT INTO mysql.user (Host, User, Select_priv, Insert_priv, Update_priv,
Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv,
Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv,
Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv,
Create_view_priv, Show_view_priv, Create_routine_priv, Alter_routine_priv,
Create_user_priv, ssl_type, ssl_cipher, x509_issuer, x509_subject, max_questions,
max_updates, max_connections, max_user_connections) 
VALUES('%', 'mysqltest_1', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'N',
'N', 'N', 'N', 'Y', 'Y', 'N', 'N', 'Y', 'Y', 'N', 'N', 'N', 'N', 'N', 'Y', 'Y', 'N', '',
'', '', '', '0', '0', '0', '0');
FLUSH PRIVILEGES;
CREATE PROCEDURE p1(i INT) BEGIN END;
DROP PROCEDURE p1;
DELETE FROM mysql.user WHERE User='mysqltest_1';
FLUSH PRIVILEGES;
#
# Bug#44521 Prepared Statement: CALL p() - crashes: `! thd->main_da.is_sent' failed et.al.
#
SELECT GET_LOCK('Bug44521', 0);
GET_LOCK('Bug44521', 0)
1
** Connection con1
CREATE PROCEDURE p()
BEGIN
SELECT 1;
SELECT GET_LOCK('Bug44521', 100);
SELECT 2;
END$
CALL p();;
** Default connection
SELECT RELEASE_LOCK('Bug44521');
RELEASE_LOCK('Bug44521')
1
DROP PROCEDURE p;
CREATE TABLE t1(a int);
INSERT INTO t1 VALUES (1);
CREATE FUNCTION f1 (inp TEXT) RETURNS INT NO SQL RETURN GET_LOCK('Bug47736', 200);
CREATE VIEW v1 AS SELECT f1('a') FROM t1;
SELECT GET_LOCK('Bug47736', 0);
GET_LOCK('Bug47736', 0)
1
SELECT * FROM v1;;
KILL QUERY ID;
ERROR 70100: Query execution was interrupted
DROP VIEW v1;
DROP TABLE t1;
DROP FUNCTION f1;
# ------------------------------------------------------------------
# -- End of 5.1 tests
# ------------------------------------------------------------------
#
# Test for bug#11763757 "56510: ERROR 42000: FUNCTION DOES NOT EXIST
# IF NOT-PRIV USER RECONNECTS ".
#
# The real problem was that server was unable handle properly stored
# functions in databases which names contained dot.
#
DROP DATABASE IF EXISTS `my.db`;
create database `my.db`;
use `my.db`;
CREATE FUNCTION f1(a int) RETURNS INT RETURN a;
# Create new connection.
USE `my.db`;
SELECT f1(1);
f1(1)
1
SELECT `my.db`.f1(2);
`my.db`.f1(2)
2
# Switching to default connection.
DROP DATABASE `my.db`;
USE test;
#
# Bug#11763507 - 56224: FUNCTION NAME IS CASE-SENSITIVE
#
SET @@SQL_MODE = '';
Warnings:
Warning	3090	Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
CREATE EVENT teste_bug11763507 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR 
DO SELECT 1 $
SHOW EVENTS LIKE 'teste_bug11763507';
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator	character_set_client	collation_connection	Database Collation
test	teste_bug11763507	root@localhost	SYSTEM	ONE TIME	#	#	#	#	NULL	ENABLED	1	latin1	latin1_swedish_ci	latin1_swedish_ci
SHOW EVENTS LIKE 'TESTE_bug11763507';
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator	character_set_client	collation_connection	Database Collation
test	teste_bug11763507	root@localhost	SYSTEM	ONE TIME	#	#	#	#	NULL	ENABLED	1	latin1	latin1_swedish_ci	latin1_swedish_ci
SHOW CREATE EVENT teste_bug11763507;
Event	sql_mode	time_zone	Create Event	character_set_client	collation_connection	Database Collation
teste_bug11763507		SYSTEM	#	latin1	latin1_swedish_ci	latin1_swedish_ci
SHOW CREATE EVENT TESTE_bug11763507;
Event	sql_mode	time_zone	Create Event	character_set_client	collation_connection	Database Collation
teste_bug11763507		SYSTEM	#	latin1	latin1_swedish_ci	latin1_swedish_ci
DROP EVENT teste_bug11763507;
#END OF BUG#11763507 test.

# WL#4179: Stored programs: validation of stored program statements
#
# Test handle of metadata changes with events.

CREATE TABLE t1 (a INT, b INT);
CREATE TABLE t2 (a INT, b INT);
CREATE TABLE t3 (a INT);
INSERT INTO t1 VALUES (1, 2);
SET GLOBAL EVENT_SCHEDULER = ON;
SELECT GET_LOCK('e1_lock', 60);
GET_LOCK('e1_lock', 60)
1
CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND STARTS NOW() DO
BEGIN
DECLARE EXIT HANDLER FOR 1136 BEGIN
INSERT INTO t3 VALUES (1);
END; -- ER_WRONG_VALUE_COUNT_ON_ROW
SELECT GET_LOCK('e1_lock', 60);
SELECT RELEASE_LOCK('e1_lock');
INSERT INTO t2 SELECT * FROM t1;
END|
SELECT RELEASE_LOCK('e1_lock');
RELEASE_LOCK('e1_lock')
1
SELECT GET_LOCK('e1_lock', 60);
GET_LOCK('e1_lock', 60)
1
ALTER TABLE t1 ADD COLUMN (c INT);
SELECT RELEASE_LOCK('e1_lock');
RELEASE_LOCK('e1_lock')
1
# Wait for new rows in t3. That means, the even has been executed,
# and INSERT INTO t2 failed because now t1 has 3 columns.
DROP EVENT e1;
DROP TABLE t1, t2, t3;
SET GLOBAL EVENT_SCHEDULER = OFF;
set @@global.concurrent_insert= @old_concurrent_insert;
#
# WL#2284: Increase the length of a user name
#
CREATE DATABASE test1;
CREATE TABLE test1.t1 (
int_field INTEGER UNSIGNED NOT NULL,
char_field CHAR(10),
INDEX(`int_field`)
);
CREATE USER user_name_len_16@localhost;
CREATE USER user_name_len_22_01234@localhost;
CREATE USER user_name_len_32_012345678901234@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_name_len_16@localhost;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user_name_len_22_01234@localhost;
# Check that user_name_len16 has no SELECT permission ON t1
SELECT * FROM test1.t1;
ERROR 42000: SELECT command denied to user 'user_name_len_16'@'localhost' for table 't1'
# Check that user_name_len_22_01234 has no SELECT permission ON t1
SELECT * FROM test1.t1;
ERROR 42000: SELECT command denied to user 'user_name_len_22_01234'@'localhost' for table 't1'
GRANT SELECT ON test1.t1 TO user_name_len_22_01234@localhost;
# Check that user_name_len_22_01234 has *now* SELECT permission ON t1
SELECT * FROM test1.t1;
int_field	char_field
CREATE DEFINER=user_name_len_22_01234@localhost PROCEDURE test1.p1_len22()
SELECT * FROM test1.t1;
GRANT EXECUTE ON PROCEDURE test1.p1_len22 TO user_name_len_22_01234@localhost;
GRANT EXECUTE ON PROCEDURE test1.p1_len22 TO user_name_len_16@localhost;
# Now user_name_len_16 should be able to SELECT FROM t1 by calling
# p1_len22 procedure
CALL test1.p1_len22();
int_field	char_field
CREATE DEFINER=user_name_len_33_0123456789012345@localhost PROCEDURE test1.p1_len33()
SELECT * FROM test1.t1;
ERROR HY000: String 'user_name_len_33_0123456789012345' is too long for user name (should be no longer than 32)
# REVOKE the SELECT permission from user_name_len_22_01234
REVOKE SELECT ON test1.t1 FROM user_name_len_22_01234@localhost;
# and GRANT it to user_name_len_32_012345678901234
GRANT SELECT ON test1.t1 TO user_name_len_32_012345678901234@localhost;
CREATE DEFINER = user_name_len_32_012345678901234@localhost FUNCTION test1.f1_len32() RETURNS INT
RETURN (SELECT COUNT(*) FROM test1.t1);
GRANT EXECUTE ON FUNCTION test1.f1_len32 TO user_name_len_32_012345678901234@localhost;
GRANT EXECUTE ON FUNCTION test1.f1_len32 TO user_name_len_22_01234@localhost;
GRANT SELECT ON test1.t1 TO user_name_len_22_01234@localhost;
# Now user_name_len_22_01234 should be able to SELECT COUNT(*) FROM t1
# by calling f1_len32 function
SELECT test1.f1_len32();
test1.f1_len32()
0
# Recreate test1.p1_len22, this time with Security Context set to INVOKER
DROP PROCEDURE test1.p1_len22;
# Make sure user_name_len_22_01234 has SELECT privileges on test.t1
SELECT * FROM test1.t1;
int_field	char_field
CREATE DEFINER=user_name_len_22_01234@localhost PROCEDURE test1.p1_len22()
SQL SECURITY INVOKER
SELECT * FROM test1.t1;
GRANT EXECUTE ON PROCEDURE test1.p1_len22 TO user_name_len_22_01234@localhost;
GRANT EXECUTE ON PROCEDURE test1.p1_len22 TO user_name_len_16@localhost;
# Now user_name_len_16 should *NOT* be able to SELECT COUNT(*) FROM t1
# by calling f1_len22 function as this function is using the INVOKER
# security context
CALL test1.p1_len22();
ERROR 42000: SELECT command denied to user 'user_name_len_16'@'localhost' for table 't1'
CREATE DEFINER=user_name_len_33_0123456789012345@localhost FUNCTION test1.f1_len33() RETURNS INT
RETURN (SELECT COUNT(*) FROM test1.t1);
ERROR HY000: String 'user_name_len_33_0123456789012345' is too long for user name (should be no longer than 32)
DROP DATABASE test1;
DROP USER user_name_len_16@localhost;
DROP USER user_name_len_22_01234@localhost;
DROP USER user_name_len_32_012345678901234@localhost;
