Below is the list of changes that have just been committed into a local
5.1 repository of andrey. When andrey does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-08-22 15:40:26+02:00, andrey@stripped +11 -0
Fix for bug #20665 All commands supported in Stored Procedures
should work in Prepared Statements. Post-review changeset.
Problem: There are some commands which are avaiable to be executed in SP
but cannot be prepared. This patch fixes this and makes it possible
prepare these statements.
Changes: The commands later are made available in PS. RESET has been forbidden
in SF/Trigger.
Solution: All current server commands where checked and those missing (see later)
we added. Tests for all of the commands with repeated executions were
added - testing with SP, SF and PS.
SHOW BINLOG EVENTS
SHOW (MASTER | SLAVE) STATUS
SHOW (MASTER | BINARY) LOGS
SHOW (PROCEDURE | FUNCTION) CODE (parsable only in debug builds)
SHOW CREATE (PROCEDURE | FUNCTION | EVENT | TABLE | VIEW)
SHOW (AUTHORS | CONTRIBUTORS | WARNINGS | ERRORS)
CHANGE MASTER
RESET (MASTER | SLAVE | QUERY CACHE)
SLAVE (START | STOP)
CHECKSUM (TABLE | TABLES)
INSTALL PLUGIN
UNINSTALL PLUGIN
CACHE INDEX
LOAD INDEX INTO CACHE
GRANT
REVOKE
KILL
(CREATE | RENAME | DROP) DATABASE
(CREATE | RENAME | DROP) USER
FLUSH (TABLE | TABLES | TABLES WITH READ LOCK | HOSTS | PRIVILEGES |
LOGS | STATUS | MASTER | SLAVE | DES_KEY_FILE | USER_RESOURCES)
mysql-test/r/ps.result@stripped, 2006-08-22 15:40:17+02:00, andrey@stripped +901 -0
update result
mysql-test/r/ps_1general.result@stripped, 2006-08-22 15:40:17+02:00, andrey@stripped +0
-12
update result
mysql-test/r/ps_grant.result@stripped, 2006-08-22 15:40:17+02:00, andrey@stripped +0 -3
update result
mysql-test/r/sp-dynamic.result@stripped, 2006-08-22 15:40:17+02:00, andrey@stripped +2 -2
update result
mysql-test/t/ps.test@stripped, 2006-08-22 15:40:17+02:00, andrey@stripped +872 -0
Add more statements, probably all currently missing which are possible in
a SP but not preparable.
Every statement is tested in a SP, in a SF and attempted to prepare.
mysql-test/t/ps_1general.test@stripped, 2006-08-22 15:40:17+02:00, andrey@stripped +6 -18
- Enable some of the statements, which are already possible in SP.
- 1295 -> ER_UNSUPPORTED_PS
mysql-test/t/ps_grant.test@stripped, 2006-08-22 15:40:17+02:00, andrey@stripped +0 -3
Enable statements already possible in SP.
sql/sp_head.cc@stripped, 2006-08-22 15:40:17+02:00, andrey@stripped +7 -5
- Reorder to keep some alphabet order.
- Add missing SHOW_SCHEDULER_STATUS.
sql/sql_parse.cc@stripped, 2006-08-22 15:40:18+02:00, andrey@stripped +1 -0
Add missing SHOW_SCHEDULER_STATUS
sql/sql_prepare.cc@stripped, 2006-08-22 15:40:18+02:00, andrey@stripped +33 -0
Add possibility to prepare statements, which are already allowed in SP.
sql/sql_yacc.yy@stripped, 2006-08-22 15:40:18+02:00, andrey@stripped +14 -2
Forbid RESET as it is treated as FLUSH in the server. Otherwise
the call of the function will fail.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: andrey
# Host: example.com
# Root: /work/mysql-5.1-runtime
--- 1.580/sql/sql_parse.cc 2006-08-22 15:40:36 +02:00
+++ 1.581/sql/sql_parse.cc 2006-08-22 15:40:36 +02:00
@@ -673,6 +673,7 @@ void init_update_queries(void)
sql_command_flags[SQLCOM_SHOW_DATABASES]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_TRIGGERS]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_EVENTS]= CF_STATUS_COMMAND;
+ sql_command_flags[SQLCOM_SHOW_SCHEDULER_STATUS]=CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_OPEN_TABLES]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_PLUGINS]= CF_STATUS_COMMAND;
sql_command_flags[SQLCOM_SHOW_FIELDS]= CF_STATUS_COMMAND;
--- 1.492/sql/sql_yacc.yy 2006-08-22 15:40:36 +02:00
+++ 1.493/sql/sql_yacc.yy 2006-08-22 15:40:37 +02:00
@@ -8628,8 +8628,20 @@ reset:
RESET_SYM
{
LEX *lex=Lex;
- lex->sql_command= SQLCOM_RESET; lex->type=0;
- } reset_options
+ if (lex->sphead && lex->sphead->m_type != TYPE_ENUM_PROCEDURE)
+ {
+ /*
+ Note that both FLUSH TABLES and FLUSH PRIVILEGES will break
+ execution in prelocked mode. So it is better to disable both
+ RESET and FLUSH in stored functions and triggers completely.
+ */
+ my_error(ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0), "RESET");
+ YYABORT;
+ }
+ lex->sql_command= SQLCOM_RESET;
+ lex->type= 0;
+ }
+ reset_options
{}
;
--- 1.60/mysql-test/r/ps_1general.result 2006-08-22 15:40:37 +02:00
+++ 1.61/mysql-test/r/ps_1general.result 2006-08-22 15:40:37 +02:00
@@ -308,17 +308,11 @@ prepare stmt4 from ' show engine bdb log
execute stmt4;
prepare stmt4 from ' show grants for user ';
prepare stmt4 from ' show create table t2 ';
-ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt4 from ' show master status ';
-ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt4 from ' show master logs ';
-ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt4 from ' show slave status ';
-ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt4 from ' show warnings limit 20 ';
-ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt4 from ' show errors limit 20 ';
-ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt4 from ' show storage engines ';
execute stmt4;
drop table if exists t5;
@@ -387,10 +381,8 @@ ERROR 42000: You have an error in your S
prepare stmt4 from ' use test ' ;
ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt3 from ' create database mysqltest ';
-ERROR HY000: This command is not supported in the prepared statement protocol yet
create database mysqltest ;
prepare stmt3 from ' drop database mysqltest ';
-ERROR HY000: This command is not supported in the prepared statement protocol yet
drop database mysqltest ;
prepare stmt3 from ' describe t2 ';
execute stmt3;
@@ -412,7 +404,6 @@ execute stmt1 ;
prepare stmt1 from ' optimize table t1 ' ;
prepare stmt1 from ' analyze table t1 ' ;
prepare stmt1 from ' checksum table t1 ' ;
-ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt1 from ' repair table t1 ' ;
prepare stmt1 from ' restore table t1 from ''data.txt'' ' ;
ERROR HY000: This command is not supported in the prepared statement protocol yet
@@ -440,11 +431,8 @@ execute stmt5;
1
SET sql_mode="";
prepare stmt1 from ' flush local privileges ' ;
-ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt1 from ' reset query cache ' ;
-ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt1 from ' KILL 0 ';
-ERROR HY000: This command is not supported in the prepared statement protocol yet
prepare stmt1 from ' explain select a from t1 order by b ';
execute stmt1;
Catalog Database Table Table_alias Column Column_alias Type Length Max
length Is_null Flags Decimals Charsetnr
--- 1.34/mysql-test/t/ps_1general.test 2006-08-22 15:40:37 +02:00
+++ 1.35/mysql-test/t/ps_1general.test 2006-08-22 15:40:37 +02:00
@@ -330,17 +330,11 @@ prepare stmt4 from ' show engine bdb log
execute stmt4;
--enable_result_log
prepare stmt4 from ' show grants for user ';
---error 1295
prepare stmt4 from ' show create table t2 ';
---error 1295
prepare stmt4 from ' show master status ';
---error 1295
prepare stmt4 from ' show master logs ';
---error 1295
prepare stmt4 from ' show slave status ';
---error 1295
prepare stmt4 from ' show warnings limit 20 ';
---error 1295
prepare stmt4 from ' show errors limit 20 ';
prepare stmt4 from ' show storage engines ';
# The output depends upon the precise order in which
@@ -427,14 +421,12 @@ prepare stmt1 from ' execute stmt2 ' ;
prepare stmt1 from ' deallocate prepare never_prepared ' ;
## switch the database connection
---error 1295
+--error ER_UNSUPPORTED_PS
prepare stmt4 from ' use test ' ;
## create/drop database
---error 1295
prepare stmt3 from ' create database mysqltest ';
create database mysqltest ;
---error 1295
prepare stmt3 from ' drop database mysqltest ';
drop database mysqltest ;
@@ -446,12 +438,12 @@ drop table t2 ;
--error 1146
execute stmt3;
## lock/unlock
---error 1295
+--error ER_UNSUPPORTED_PS
prepare stmt3 from ' lock tables t1 read ' ;
---error 1295
+--error ER_UNSUPPORTED_PS
prepare stmt3 from ' unlock tables ' ;
## Load/Unload table contents
---error 1295
+--error ER_UNSUPPORTED_PS
prepare stmt1 from ' load data infile ''data.txt''
into table t1 fields terminated by ''\t'' ';
prepare stmt1 from ' select * into outfile ''data.txt'' from t1 ';
@@ -459,13 +451,12 @@ execute stmt1 ;
##
prepare stmt1 from ' optimize table t1 ' ;
prepare stmt1 from ' analyze table t1 ' ;
---error 1295
prepare stmt1 from ' checksum table t1 ' ;
prepare stmt1 from ' repair table t1 ' ;
---error 1295
+--error ER_UNSUPPORTED_PS
prepare stmt1 from ' restore table t1 from ''data.txt'' ' ;
## handler
---error 1295
+--error ER_UNSUPPORTED_PS
prepare stmt1 from ' handler t1 open ';
@@ -491,11 +482,8 @@ SET sql_mode=ansi;
execute stmt5;
SET sql_mode="";
---error 1295
prepare stmt1 from ' flush local privileges ' ;
---error 1295
prepare stmt1 from ' reset query cache ' ;
---error 1295
prepare stmt1 from ' KILL 0 ';
## simple explain
--- 1.10/mysql-test/r/ps_grant.result 2006-08-22 15:40:37 +02:00
+++ 1.11/mysql-test/r/ps_grant.result 2006-08-22 15:40:37 +02:00
@@ -78,13 +78,10 @@ ERROR 42000: There is no such grant defi
drop database mysqltest;
prepare stmt3 from ' grant all on test.t1 to drop_user@localhost
identified by ''looser'' ';
-ERROR HY000: This command is not supported in the prepared statement protocol yet
grant all on test.t1 to drop_user@localhost
identified by 'looser' ;
prepare stmt3 from ' revoke all privileges on test.t1 from
drop_user@localhost ';
-ERROR HY000: This command is not supported in the prepared statement protocol yet
revoke all privileges on test.t1 from drop_user@localhost ;
prepare stmt3 from ' drop user drop_user@localhost ';
-ERROR HY000: This command is not supported in the prepared statement protocol yet
drop user drop_user@localhost;
--- 1.6/mysql-test/t/ps_grant.test 2006-08-22 15:40:37 +02:00
+++ 1.7/mysql-test/t/ps_grant.test 2006-08-22 15:40:37 +02:00
@@ -117,15 +117,12 @@ drop database mysqltest;
#
# grant/revoke + drop user
#
---error 1295
prepare stmt3 from ' grant all on test.t1 to drop_user@localhost
identified by ''looser'' ';
grant all on test.t1 to drop_user@localhost
identified by 'looser' ;
---error 1295
prepare stmt3 from ' revoke all privileges on test.t1 from
drop_user@localhost ';
revoke all privileges on test.t1 from drop_user@localhost ;
---error 1295
prepare stmt3 from ' drop user drop_user@localhost ';
drop user drop_user@localhost;
--- 1.5/mysql-test/r/sp-dynamic.result 2006-08-22 15:40:37 +02:00
+++ 1.6/mysql-test/r/sp-dynamic.result 2006-08-22 15:40:37 +02:00
@@ -284,11 +284,11 @@ call p1()|
select * from t1|
id stmt_text status
1 select 1 supported
-2 flush tables not supported
+2 flush tables supported
3 handler t1 open as ha not supported
4 analyze table t1 supported
5 check table t1 not supported
-6 checksum table t1 not supported
+6 checksum table t1 supported
7 check table t1 not supported
8 optimize table t1 supported
9 repair table t1 supported
--- 1.232/sql/sp_head.cc 2006-08-22 15:40:37 +02:00
+++ 1.233/sql/sp_head.cc 2006-08-22 15:40:37 +02:00
@@ -161,17 +161,20 @@ sp_get_flags_for_command(LEX *lex)
}
/* fallthrough */
case SQLCOM_ANALYZE:
+ case SQLCOM_BACKUP_TABLE:
case SQLCOM_OPTIMIZE:
case SQLCOM_PRELOAD_KEYS:
case SQLCOM_ASSIGN_TO_KEYCACHE:
case SQLCOM_CHECKSUM:
case SQLCOM_CHECK:
case SQLCOM_HA_READ:
+ case SQLCOM_SHOW_AUTHORS:
case SQLCOM_SHOW_BINLOGS:
case SQLCOM_SHOW_BINLOG_EVENTS:
case SQLCOM_SHOW_CHARSETS:
case SQLCOM_SHOW_COLLATIONS:
case SQLCOM_SHOW_COLUMN_TYPES:
+ case SQLCOM_SHOW_CONTRIBUTORS:
case SQLCOM_SHOW_CREATE:
case SQLCOM_SHOW_CREATE_DB:
case SQLCOM_SHOW_CREATE_FUNC:
@@ -180,16 +183,20 @@ sp_get_flags_for_command(LEX *lex)
case SQLCOM_SHOW_DATABASES:
case SQLCOM_SHOW_ERRORS:
case SQLCOM_SHOW_FIELDS:
+ case SQLCOM_SHOW_FUNC_CODE:
case SQLCOM_SHOW_GRANTS:
case SQLCOM_SHOW_ENGINE_STATUS:
case SQLCOM_SHOW_ENGINE_LOGS:
case SQLCOM_SHOW_ENGINE_MUTEX:
+ case SQLCOM_SHOW_EVENTS:
case SQLCOM_SHOW_KEYS:
case SQLCOM_SHOW_MASTER_STAT:
case SQLCOM_SHOW_NEW_MASTER:
case SQLCOM_SHOW_OPEN_TABLES:
case SQLCOM_SHOW_PRIVILEGES:
case SQLCOM_SHOW_PROCESSLIST:
+ case SQLCOM_SHOW_PROC_CODE:
+ case SQLCOM_SHOW_SCHEDULER_STATUS:
case SQLCOM_SHOW_SLAVE_HOSTS:
case SQLCOM_SHOW_SLAVE_STAT:
case SQLCOM_SHOW_STATUS:
@@ -199,12 +206,7 @@ sp_get_flags_for_command(LEX *lex)
case SQLCOM_SHOW_TABLES:
case SQLCOM_SHOW_VARIABLES:
case SQLCOM_SHOW_WARNS:
- case SQLCOM_SHOW_PROC_CODE:
- case SQLCOM_SHOW_FUNC_CODE:
- case SQLCOM_SHOW_AUTHORS:
- case SQLCOM_SHOW_CONTRIBUTORS:
case SQLCOM_REPAIR:
- case SQLCOM_BACKUP_TABLE:
case SQLCOM_RESTORE_TABLE:
flags= sp_head::MULTI_RESULTS;
break;
--- 1.71/mysql-test/r/ps.result 2006-08-22 15:40:37 +02:00
+++ 1.72/mysql-test/r/ps.result 2006-08-22 15:40:37 +02:00
@@ -1277,3 +1277,904 @@ ERROR 3D000: No database selected
create temporary table t1 (i int);
ERROR 3D000: No database selected
use test;
+create procedure proc_1() reset query cache;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+create function func_1() returns int begin reset query cache; return 1; end|
+ERROR 0A000: RESET is not allowed in stored function or trigger
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "reset query cache";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+create procedure proc_1() reset master;
+drop procedure proc_1;
+create function func_1() returns int begin reset master; return 1; end|
+ERROR 0A000: RESET is not allowed in stored function or trigger
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "reset master";
+deallocate prepare abc;
+create procedure proc_1() reset slave;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+create function func_1() returns int begin reset slave; return 1; end|
+ERROR 0A000: RESET is not allowed in stored function or trigger
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "reset slave";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+create procedure proc_1(a integer) kill a;
+call proc_1(0);
+ERROR HY000: Unknown thread id: 0
+call proc_1(0);
+ERROR HY000: Unknown thread id: 0
+call proc_1(0);
+ERROR HY000: Unknown thread id: 0
+drop procedure proc_1;
+create function func_1() returns int begin kill 0; return 1; end|
+select func_1() from dual;
+ERROR HY000: Unknown thread id: 0
+select func_1() from dual;
+ERROR HY000: Unknown thread id: 0
+select func_1() from dual;
+ERROR HY000: Unknown thread id: 0
+drop function func_1;
+prepare abc from "kill 0";
+execute abc;
+ERROR HY000: Unknown thread id: 0
+execute abc;
+ERROR HY000: Unknown thread id: 0
+execute abc;
+ERROR HY000: Unknown thread id: 0
+deallocate prepare abc;
+create procedure proc_1() flush hosts;
+call proc_1();
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+create function func_1() returns int begin flush hosts; return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "flush hosts";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+create procedure proc_1() flush privileges;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+create function func_1() returns int begin flush privileges; return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "flush privileges";
+deallocate prepare abc;
+create procedure proc_1() flush tables with read lock;
+call proc_1();
+unlock tables;
+call proc_1();
+unlock tables;
+call proc_1();
+unlock tables;
+drop procedure proc_1;
+create function func_1() returns int begin flush tables with read lock; return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+prepare abc from "flush tables with read lock";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+unlock tables;
+create procedure proc_1() flush tables;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+create function func_1() returns int begin flush tables; return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "flush tables";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+create procedure proc_1() flush tables;
+flush tables;
+show open tables from mysql;
+Database Table In_use Name_locked
+mysql general_log 1 0
+select Host, User from mysql.user limit 0;
+Host User
+select Host, Db from mysql.host limit 0;
+Host Db
+show open tables from mysql;
+Database Table In_use Name_locked
+mysql user 0 0
+mysql general_log 1 0
+mysql host 0 0
+call proc_1();
+show open tables from mysql;
+Database Table In_use Name_locked
+mysql general_log 1 0
+select Host, User from mysql.user limit 0;
+Host User
+select Host, Db from mysql.host limit 0;
+Host Db
+show open tables from mysql;
+Database Table In_use Name_locked
+mysql user 0 0
+mysql general_log 1 0
+mysql host 0 0
+call proc_1();
+show open tables from mysql;
+Database Table In_use Name_locked
+mysql general_log 1 0
+select Host, User from mysql.user limit 0;
+Host User
+select Host, Db from mysql.host limit 0;
+Host Db
+show open tables from mysql;
+Database Table In_use Name_locked
+mysql user 0 0
+mysql general_log 1 0
+mysql host 0 0
+call proc_1();
+show open tables from mysql;
+Database Table In_use Name_locked
+mysql general_log 1 0
+select Host, User from mysql.user limit 0;
+Host User
+select Host, Db from mysql.host limit 0;
+Host Db
+show open tables from mysql;
+Database Table In_use Name_locked
+mysql user 0 0
+mysql general_log 1 0
+mysql host 0 0
+flush tables;
+drop procedure proc_1;
+create function func_1() returns int begin flush tables; return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+flush tables;
+select Host, User from mysql.user limit 0;
+Host User
+select Host, Db from mysql.host limit 0;
+Host Db
+show open tables from mysql;
+Database Table In_use Name_locked
+mysql user 0 0
+mysql general_log 1 0
+mysql host 0 0
+prepare abc from "flush tables";
+execute abc;
+show open tables from mysql;
+Database Table In_use Name_locked
+mysql general_log 1 0
+select Host, User from mysql.user limit 0;
+Host User
+select Host, Db from mysql.host limit 0;
+Host Db
+show open tables from mysql;
+Database Table In_use Name_locked
+mysql user 0 0
+mysql general_log 1 0
+mysql host 0 0
+execute abc;
+show open tables from mysql;
+Database Table In_use Name_locked
+mysql general_log 1 0
+select Host, User from mysql.user limit 0;
+Host User
+select Host, Db from mysql.host limit 0;
+Host Db
+show open tables from mysql;
+Database Table In_use Name_locked
+mysql user 0 0
+mysql general_log 1 0
+mysql host 0 0
+execute abc;
+show open tables from mysql;
+Database Table In_use Name_locked
+mysql general_log 1 0
+select Host, User from mysql.user limit 0;
+Host User
+select Host, Db from mysql.host limit 0;
+Host Db
+show open tables from mysql;
+Database Table In_use Name_locked
+mysql user 0 0
+mysql general_log 1 0
+mysql host 0 0
+flush tables;
+deallocate prepare abc;
+create procedure proc_1() flush logs;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+create function func_1() returns int begin flush logs; return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "flush logs";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+create procedure proc_1() flush status;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+create function func_1() returns int begin flush status; return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "flush status";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+create procedure proc_1() flush slave;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+create function func_1() returns int begin flush slave; return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "flush slave";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+create procedure proc_1() flush master;
+drop procedure proc_1;
+create function func_1() returns int begin flush master; return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "flush master";
+deallocate prepare abc;
+create procedure proc_1() flush des_key_file;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+create function func_1() returns int begin flush des_key_file; return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "flush des_key_file";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+create procedure proc_1() flush user_resources;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+create function func_1() returns int begin flush user_resources; return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "flush user_resources";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+create procedure proc_1() start slave;
+drop procedure proc_1;
+create function func_1() returns int begin start slave; return 1; end|
+drop function func_1;
+prepare abc from "start slave";
+deallocate prepare abc;
+create procedure proc_1() stop slave;
+drop procedure proc_1;
+create function func_1() returns int begin stop slave; return 1; end|
+drop function func_1;
+prepare abc from "stop slave";
+deallocate prepare abc;
+create procedure proc_1() show binlog events;
+drop procedure proc_1;
+create function func_1() returns int begin show binlog events; return 1; end|
+ERROR 0A000: Not allowed to return a result set from a function
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "show binlog events";
+deallocate prepare abc;
+create procedure proc_1() show slave status;
+drop procedure proc_1;
+create function func_1() returns int begin show slave status; return 1; end|
+ERROR 0A000: Not allowed to return a result set from a function
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "show slave status";
+deallocate prepare abc;
+create procedure proc_1() show master status;
+drop procedure proc_1;
+create function func_1() returns int begin show master status; return 1; end|
+ERROR 0A000: Not allowed to return a result set from a function
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "show master status";
+deallocate prepare abc;
+create procedure proc_1() show master logs;
+drop procedure proc_1;
+create function func_1() returns int begin show master logs; return 1; end|
+ERROR 0A000: Not allowed to return a result set from a function
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "show master logs";
+deallocate prepare abc;
+create procedure proc_1() show events;
+call proc_1();
+Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
+call proc_1();
+Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
+call proc_1();
+Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
+drop procedure proc_1;
+create function func_1() returns int begin show events; return 1; end|
+ERROR 0A000: Not allowed to return a result set from a function
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "show events";
+execute abc;
+Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
+execute abc;
+Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
+execute abc;
+Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
+deallocate prepare abc;
+create procedure proc_1() show scheduler status;
+drop procedure proc_1;
+create function func_1() returns int begin show scheduler status; return 1; end|
+ERROR 0A000: Not allowed to return a result set from a function
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "show scheduler status";
+deallocate prepare abc;
+drop procedure if exists a;
+create procedure a() select 42;
+create procedure proc_1(a char(2)) show create procedure a;
+call proc_1("bb");
+Procedure sql_mode Create Procedure
+a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`()
+select 42
+call proc_1("bb");
+Procedure sql_mode Create Procedure
+a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`()
+select 42
+call proc_1("bb");
+Procedure sql_mode Create Procedure
+a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`()
+select 42
+drop procedure proc_1;
+create function func_1() returns int begin show create procedure a; return 1; end|
+ERROR 0A000: Not allowed to return a result set from a function
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "show create procedure a";
+execute abc;
+Procedure sql_mode Create Procedure
+a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`()
+select 42
+execute abc;
+Procedure sql_mode Create Procedure
+a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`()
+select 42
+execute abc;
+Procedure sql_mode Create Procedure
+a CREATE DEFINER=`root`@`localhost` PROCEDURE `a`()
+select 42
+deallocate prepare abc;
+drop procedure a;
+drop function if exists a;
+create function a() returns int return 42+13;
+create procedure proc_1(a char(2)) show create function a;
+call proc_1("bb");
+Function sql_mode Create Function
+a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11)
+return 42+13
+call proc_1("bb");
+Function sql_mode Create Function
+a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11)
+return 42+13
+call proc_1("bb");
+Function sql_mode Create Function
+a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11)
+return 42+13
+drop procedure proc_1;
+create function func_1() returns int begin show create function a; return 1; end|
+ERROR 0A000: Not allowed to return a result set from a function
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "show create function a";
+execute abc;
+Function sql_mode Create Function
+a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11)
+return 42+13
+execute abc;
+Function sql_mode Create Function
+a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11)
+return 42+13
+execute abc;
+Function sql_mode Create Function
+a CREATE DEFINER=`root`@`localhost` FUNCTION `a`() RETURNS int(11)
+return 42+13
+deallocate prepare abc;
+drop function a;
+drop table if exists tab1;
+create table tab1(a int, b char(1), primary key(a,b));
+create procedure proc_1() show create table tab1;
+call proc_1();
+Table Create Table
+tab1 CREATE TABLE `tab1` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` char(1) NOT NULL DEFAULT '',
+ PRIMARY KEY (`a`,`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+call proc_1();
+Table Create Table
+tab1 CREATE TABLE `tab1` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` char(1) NOT NULL DEFAULT '',
+ PRIMARY KEY (`a`,`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+call proc_1();
+Table Create Table
+tab1 CREATE TABLE `tab1` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` char(1) NOT NULL DEFAULT '',
+ PRIMARY KEY (`a`,`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop procedure proc_1;
+create function func_1() returns int begin show create table tab1; return 1; end|
+ERROR 0A000: Not allowed to return a result set from a function
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "show create table tab1";
+execute abc;
+Table Create Table
+tab1 CREATE TABLE `tab1` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` char(1) NOT NULL DEFAULT '',
+ PRIMARY KEY (`a`,`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+execute abc;
+Table Create Table
+tab1 CREATE TABLE `tab1` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` char(1) NOT NULL DEFAULT '',
+ PRIMARY KEY (`a`,`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+execute abc;
+Table Create Table
+tab1 CREATE TABLE `tab1` (
+ `a` int(11) NOT NULL DEFAULT '0',
+ `b` char(1) NOT NULL DEFAULT '',
+ PRIMARY KEY (`a`,`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+deallocate prepare abc;
+drop table tab1;
+drop view if exists v1;
+drop table if exists t1;
+create table t1(a int, b char(5));
+insert into t1 values (1, "one"), (1, "edno"), (2, "two"), (2, "dve");
+create view v1 as
+(select a, count(*) from t1 group by a)
+union all
+(select b, count(*) from t1 group by b);
+create procedure proc_1() show create view v1;
+call proc_1();
+View Create View
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1`
AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all
(select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`)
+call proc_1();
+View Create View
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1`
AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all
(select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`)
+call proc_1();
+View Create View
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1`
AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all
(select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`)
+drop procedure proc_1;
+create function func_1() returns int begin show create view v1; return 1; end|
+ERROR 0A000: Not allowed to return a result set from a function
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "show create view v1";
+execute abc;
+View Create View
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1`
AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all
(select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`)
+execute abc;
+View Create View
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1`
AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all
(select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`)
+execute abc;
+View Create View
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1`
AS (select `t1`.`a` AS `a`,count(0) AS `count(*)` from `t1` group by `t1`.`a`) union all
(select `t1`.`b` AS `b`,count(0) AS `count(*)` from `t1` group by `t1`.`b`)
+deallocate prepare abc;
+drop view v1;
+drop table t1;
+create procedure proc_1() install plugin my_plug soname '/root/some_plugin.so';
+call proc_1();
+ERROR HY000: No paths allowed for shared library
+call proc_1();
+ERROR HY000: No paths allowed for shared library
+call proc_1();
+ERROR HY000: No paths allowed for shared library
+drop procedure proc_1;
+create procedure proc_1() install plugin my_plug soname 'some_plugin.so';
+call proc_1();
+ERROR HY000: Can't open shared library
'/work/mysql-5.1-runtime/mysql-test/lib/mysql/some_plugin.so' (errno: 0 cannot open
shared object file: No such file or directory)
+call proc_1();
+ERROR HY000: Can't open shared library
'/work/mysql-5.1-runtime/mysql-test/lib/mysql/some_plugin.so' (errno: 22 cannot open
shared object file: No such file or directory)
+call proc_1();
+ERROR HY000: Can't open shared library
'/work/mysql-5.1-runtime/mysql-test/lib/mysql/some_plugin.so' (errno: 22 cannot open
shared object file: No such file or directory)
+drop procedure proc_1;
+create function func_1() returns int begin install plugin my_plug soname '/tmp/plugin';
return 1; end|
+"This is not what we want. Once Bug#21777 is fixed, the following"
+"statements have to be ajusted"
+select func_1(), func_1(), func_1() from dual;
+ERROR HY000: Table 'plugin' was not locked with LOCK TABLES
+drop function func_1;
+prepare abc from "install plugin my_plug soname '/root/some_plugin.so'";
+execute abc;
+ERROR HY000: No paths allowed for shared library
+execute abc;
+ERROR HY000: No paths allowed for shared library
+deallocate prepare abc;
+prepare abc from "install plugin my_plug soname 'some_plugin.so'";
+deallocate prepare abc;
+create procedure proc_1() uninstall plugin my_plug;
+call proc_1();
+ERROR 42000: PLUGIN my_plug does not exist
+call proc_1();
+ERROR 42000: PLUGIN my_plug does not exist
+call proc_1();
+ERROR 42000: PLUGIN my_plug does not exist
+drop procedure proc_1;
+create function func_1() returns int begin uninstall plugin my_plug; return 1; end|
+"This is not what we want. Once Bug#21777 is fixed, the following"
+"statements have to be ajusted"
+select func_1(), func_1(), func_1() from dual;
+ERROR HY000: Table 'plugin' was not locked with LOCK TABLES
+drop function func_1;
+prepare abc from "uninstall plugin my_plug";
+execute abc;
+ERROR 42000: PLUGIN my_plug does not exist
+execute abc;
+ERROR 42000: PLUGIN my_plug does not exist
+execute abc;
+ERROR 42000: PLUGIN my_plug does not exist
+deallocate prepare abc;
+drop database if exists mysqltest_xyz;
+create procedure proc_1() create database mysqltest_xyz;
+call proc_1();
+drop database if exists mysqltest_xyz;
+call proc_1();
+call proc_1();
+ERROR HY000: Can't create database 'mysqltest_xyz'; database exists
+drop database if exists mysqltest_xyz;
+call proc_1();
+drop database if exists mysqltest_xyz;
+drop procedure proc_1;
+create function func_1() returns int begin create database mysqltest_xyz; return 1; end|
+ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "create database mysqltest_xyz";
+execute abc;
+drop database if exists mysqltest_xyz;
+execute abc;
+execute abc;
+ERROR HY000: Can't create database 'mysqltest_xyz'; database exists
+drop database if exists mysqltest_xyz;
+execute abc;
+drop database if exists mysqltest_xyz;
+deallocate prepare abc;
+drop table if exists t1;
+create table t1 (a int, b char(5));
+insert into t1 values (1, "one"), (2, "two"), (3, "three");
+create procedure proc_1() checksum table xyz;
+call proc_1();
+Table Checksum
+test.xyz NULL
+Warnings:
+Error 1146 Table 'test.xyz' doesn't exist
+call proc_1();
+Table Checksum
+test.xyz NULL
+Warnings:
+Error 1146 Table 'test.xyz' doesn't exist
+call proc_1();
+Table Checksum
+test.xyz NULL
+Warnings:
+Error 1146 Table 'test.xyz' doesn't exist
+drop procedure proc_1;
+create function func_1() returns int begin checksum table t1; return 1; end|
+ERROR 0A000: Not allowed to return a result set from a function
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "checksum table t1";
+execute abc;
+Table Checksum
+test.t1 645809265
+execute abc;
+Table Checksum
+test.t1 645809265
+execute abc;
+Table Checksum
+test.t1 645809265
+deallocate prepare abc;
+create procedure proc_1() create user pstest_xyz@localhost;
+call proc_1();
+drop user pstest_xyz@localhost;
+call proc_1();
+call proc_1();
+ERROR HY000: Operation CREATE USER failed for 'pstest_xyz'@'localhost'
+drop user pstest_xyz@localhost;
+call proc_1();
+drop user pstest_xyz@localhost;
+drop procedure proc_1;
+create function func_1() returns int begin create user pstest_xyz@localhost; return 1;
end|
+ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "create user pstest_xyz@localhost";
+execute abc;
+drop user pstest_xyz@localhost;
+execute abc;
+execute abc;
+ERROR HY000: Operation CREATE USER failed for 'pstest_xyz'@'localhost'
+drop user pstest_xyz@localhost;
+execute abc;
+drop user pstest_xyz@localhost;
+deallocate prepare abc;
+drop event if exists xyz;
+create procedure proc_1() create event xyz on schedule every 5 minute disable do select
123;
+call proc_1();
+123
+123
+drop event xyz;
+call proc_1();
+123
+123
+call proc_1();
+123
+123
+ERROR HY000: Event 'xyz' already exists
+drop event xyz;
+call proc_1();
+123
+123
+drop event xyz;
+drop procedure proc_1;
+create function func_1() returns int begin create event xyz on schedule at now() do
select 123; return 1; end|
+ERROR 0A000: Not allowed to return a result set from a function
+select func_1(), func_1(), func_1() from dual;
+ERROR 42000: FUNCTION test.func_1 does not exist
+drop function func_1;
+ERROR 42000: FUNCTION test.func_1 does not exist
+prepare abc from "create event xyz on schedule at now() do select 123";
+ERROR HY000: This command is not supported in the prepared statement protocol yet
+deallocate prepare abc;
+ERROR HY000: Unknown prepared statement handler (abc) given to DEALLOCATE PREPARE
+drop event if exists xyz;
+create event xyz on schedule every 5 minute disable do select 123;
+create procedure proc_1() alter event xyz comment 'xyz';
+call proc_1();
+drop event xyz;
+create event xyz on schedule every 5 minute disable do select 123;
+call proc_1();
+drop event xyz;
+create event xyz on schedule every 5 minute disable do select 123;
+call proc_1();
+drop event xyz;
+drop procedure proc_1;
+create function func_1() returns int begin alter event xyz comment 'xyz'; return 1; end|
+ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
+prepare abc from "alter event xyz comment 'xyz'";
+ERROR HY000: This command is not supported in the prepared statement protocol yet
+deallocate prepare abc;
+ERROR HY000: Unknown prepared statement handler (abc) given to DEALLOCATE PREPARE
+drop event if exists xyz;
+create event xyz on schedule every 5 minute disable do select 123;
+create procedure proc_1() drop event xyz;
+call proc_1();
+create event xyz on schedule every 5 minute disable do select 123;
+call proc_1();
+call proc_1();
+ERROR HY000: Unknown event 'xyz'
+drop procedure proc_1;
+create function func_1() returns int begin drop event xyz; return 1; end|
+ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
+prepare abc from "drop event xyz";
+ERROR HY000: This command is not supported in the prepared statement protocol yet
+deallocate prepare abc;
+ERROR HY000: Unknown prepared statement handler (abc) given to DEALLOCATE PREPARE
+drop table if exists t1;
+create table t1 (a int, b char(5)) engine=myisam;
+insert into t1 values (1, "one"), (2, "two"), (3, "three");
+SET GLOBAL new_cache.key_buffer_size=128*1024;
+create procedure proc_1() cache index t1 in new_cache;
+call proc_1();
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+call proc_1();
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+call proc_1();
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+drop procedure proc_1;
+SET GLOBAL second_cache.key_buffer_size=128*1024;
+prepare abc from "cache index t1 in second_cache";
+execute abc;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+execute abc;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+execute abc;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+deallocate prepare abc;
+drop table t1;
+drop table if exists t1;
+drop table if exists t2;
+create table t1 (a int, b char(5)) engine=myisam;
+insert into t1 values (1, "one"), (2, "two"), (3, "three");
+create table t2 (a int, b char(5)) engine=myisam;
+insert into t2 values (1, "one"), (2, "two"), (3, "three");
+create procedure proc_1() load index into cache t1 ignore leaves;
+call proc_1();
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+call proc_1();
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+call proc_1();
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+drop procedure proc_1;
+create function func_1() returns int begin load index into cache t1 ignore leaves; return
1; end|
+ERROR 0A000: Not allowed to return a result set from a function
+prepare abc from "load index into cache t2 ignore leaves";
+execute abc;
+Table Op Msg_type Msg_text
+test.t2 preload_keys status OK
+execute abc;
+Table Op Msg_type Msg_text
+test.t2 preload_keys status OK
+execute abc;
+Table Op Msg_type Msg_text
+test.t2 preload_keys status OK
+deallocate prepare abc;
+drop table t1, t2;
+create procedure proc_1() show errors;
+call proc_1();
+Level Code Message
+call proc_1();
+Level Code Message
+call proc_1();
+Level Code Message
+drop procedure proc_1;
+create function func_1() returns int begin show errors; return 1; end|
+ERROR 0A000: Not allowed to return a result set from a function
+prepare abc from "show errors";
+deallocate prepare abc;
+drop table if exists t1;
+drop table if exists t2;
+create procedure proc_1() show warnings;
+drop table if exists t1;
+Warnings:
+Note 1051 Unknown table 't1'
+call proc_1();
+Level Code Message
+drop table if exists t2;
+Warnings:
+Note 1051 Unknown table 't2'
+call proc_1();
+Level Code Message
+drop table if exists t1, t2;
+Warnings:
+Note 1051 Unknown table 't1'
+Note 1051 Unknown table 't2'
+call proc_1();
+Level Code Message
+drop procedure proc_1;
+create function func_1() returns int begin show warnings; return 1; end|
+ERROR 0A000: Not allowed to return a result set from a function
+prepare abc from "show warnings";
+drop table if exists t1;
+Warnings:
+Note 1051 Unknown table 't1'
+execute abc;
+Level Code Message
+Note 1051 Unknown table 't1'
+drop table if exists t2;
+Warnings:
+Note 1051 Unknown table 't2'
+execute abc;
+Level Code Message
+Note 1051 Unknown table 't2'
+drop table if exists t1, t2;
+Warnings:
+Note 1051 Unknown table 't1'
+Note 1051 Unknown table 't2'
+execute abc;
+Level Code Message
+Note 1051 Unknown table 't1'
+Note 1051 Unknown table 't2'
+deallocate prepare abc;
--- 1.69/mysql-test/t/ps.test 2006-08-22 15:40:37 +02:00
+++ 1.70/mysql-test/t/ps.test 2006-08-22 15:40:37 +02:00
@@ -1330,3 +1330,875 @@ create temporary table t1 (i int);
#
use test;
# End of 5.0 tests
+
+
+#
+# Bug #20665: All commands supported in Stored Procedures should work in
+# Prepared Statements
+#
+create procedure proc_1() reset query cache;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin reset query cache; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "reset query cache";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+
+
+create procedure proc_1() reset master;
+drop procedure proc_1;
+delimiter |;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin reset master; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "reset master";
+deallocate prepare abc;
+
+
+create procedure proc_1() reset slave;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin reset slave; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "reset slave";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+
+
+create procedure proc_1(a integer) kill a;
+--error ER_NO_SUCH_THREAD
+call proc_1(0);
+--error ER_NO_SUCH_THREAD
+call proc_1(0);
+--error ER_NO_SUCH_THREAD
+call proc_1(0);
+drop procedure proc_1;
+delimiter |;
+create function func_1() returns int begin kill 0; return 1; end|
+delimiter ;|
+--error ER_NO_SUCH_THREAD
+select func_1() from dual;
+--error ER_NO_SUCH_THREAD
+select func_1() from dual;
+--error ER_NO_SUCH_THREAD
+select func_1() from dual;
+drop function func_1;
+prepare abc from "kill 0";
+--error ER_NO_SUCH_THREAD
+execute abc;
+--error ER_NO_SUCH_THREAD
+execute abc;
+--error ER_NO_SUCH_THREAD
+execute abc;
+deallocate prepare abc;
+
+
+create procedure proc_1() flush hosts;
+call proc_1();
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin flush hosts; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "flush hosts";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+
+
+create procedure proc_1() flush privileges;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin flush privileges; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "flush privileges";
+deallocate prepare abc;
+
+
+create procedure proc_1() flush tables with read lock;
+call proc_1();
+unlock tables;
+call proc_1();
+unlock tables;
+call proc_1();
+unlock tables;
+drop procedure proc_1;
+delimiter |;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin flush tables with read lock; return 1; end|
+delimiter ;|
+prepare abc from "flush tables with read lock";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+unlock tables;
+
+
+create procedure proc_1() flush tables;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin flush tables; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "flush tables";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+
+
+create procedure proc_1() flush tables;
+flush tables;
+show open tables from mysql;
+select Host, User from mysql.user limit 0;
+select Host, Db from mysql.host limit 0;
+show open tables from mysql;
+call proc_1();
+show open tables from mysql;
+select Host, User from mysql.user limit 0;
+select Host, Db from mysql.host limit 0;
+show open tables from mysql;
+call proc_1();
+show open tables from mysql;
+select Host, User from mysql.user limit 0;
+select Host, Db from mysql.host limit 0;
+show open tables from mysql;
+call proc_1();
+show open tables from mysql;
+select Host, User from mysql.user limit 0;
+select Host, Db from mysql.host limit 0;
+show open tables from mysql;
+flush tables;
+drop procedure proc_1;
+delimiter |;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin flush tables; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+flush tables;
+select Host, User from mysql.user limit 0;
+select Host, Db from mysql.host limit 0;
+show open tables from mysql;
+prepare abc from "flush tables";
+execute abc;
+show open tables from mysql;
+select Host, User from mysql.user limit 0;
+select Host, Db from mysql.host limit 0;
+show open tables from mysql;
+execute abc;
+show open tables from mysql;
+select Host, User from mysql.user limit 0;
+select Host, Db from mysql.host limit 0;
+show open tables from mysql;
+execute abc;
+show open tables from mysql;
+select Host, User from mysql.user limit 0;
+select Host, Db from mysql.host limit 0;
+show open tables from mysql;
+flush tables;
+deallocate prepare abc;
+
+
+create procedure proc_1() flush logs;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin flush logs; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "flush logs";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+
+
+create procedure proc_1() flush status;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin flush status; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "flush status";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+
+
+create procedure proc_1() flush slave;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin flush slave; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "flush slave";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+
+
+create procedure proc_1() flush master;
+drop procedure proc_1;
+delimiter |;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin flush master; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "flush master";
+deallocate prepare abc;
+
+
+create procedure proc_1() flush des_key_file;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin flush des_key_file; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "flush des_key_file";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+
+
+create procedure proc_1() flush user_resources;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin flush user_resources; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "flush user_resources";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+
+
+create procedure proc_1() start slave;
+drop procedure proc_1;
+delimiter |;
+create function func_1() returns int begin start slave; return 1; end|
+delimiter ;|
+drop function func_1;
+prepare abc from "start slave";
+deallocate prepare abc;
+
+
+create procedure proc_1() stop slave;
+drop procedure proc_1;
+delimiter |;
+create function func_1() returns int begin stop slave; return 1; end|
+delimiter ;|
+drop function func_1;
+prepare abc from "stop slave";
+deallocate prepare abc;
+
+
+create procedure proc_1() show binlog events;
+drop procedure proc_1;
+delimiter |;
+--error ER_SP_NO_RETSET
+create function func_1() returns int begin show binlog events; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "show binlog events";
+deallocate prepare abc;
+
+
+create procedure proc_1() show slave status;
+drop procedure proc_1;
+delimiter |;
+--error ER_SP_NO_RETSET
+create function func_1() returns int begin show slave status; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "show slave status";
+deallocate prepare abc;
+
+
+create procedure proc_1() show master status;
+drop procedure proc_1;
+delimiter |;
+--error ER_SP_NO_RETSET
+create function func_1() returns int begin show master status; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "show master status";
+deallocate prepare abc;
+
+
+create procedure proc_1() show master logs;
+drop procedure proc_1;
+delimiter |;
+--error ER_SP_NO_RETSET
+create function func_1() returns int begin show master logs; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "show master logs";
+deallocate prepare abc;
+
+
+create procedure proc_1() show events;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_SP_NO_RETSET
+create function func_1() returns int begin show events; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "show events";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+
+
+create procedure proc_1() show scheduler status;
+drop procedure proc_1;
+delimiter |;
+--error ER_SP_NO_RETSET
+create function func_1() returns int begin show scheduler status; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "show scheduler status";
+deallocate prepare abc;
+
+
+--disable_warnings
+drop procedure if exists a;
+--enable_warnings
+create procedure a() select 42;
+create procedure proc_1(a char(2)) show create procedure a;
+call proc_1("bb");
+call proc_1("bb");
+call proc_1("bb");
+drop procedure proc_1;
+delimiter |;
+--error ER_SP_NO_RETSET
+create function func_1() returns int begin show create procedure a; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "show create procedure a";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+drop procedure a;
+
+
+--disable_warnings
+drop function if exists a;
+--enable_warnings
+create function a() returns int return 42+13;
+create procedure proc_1(a char(2)) show create function a;
+call proc_1("bb");
+call proc_1("bb");
+call proc_1("bb");
+drop procedure proc_1;
+delimiter |;
+--error ER_SP_NO_RETSET
+create function func_1() returns int begin show create function a; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "show create function a";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+drop function a;
+
+
+--disable_warnings
+drop table if exists tab1;
+--enable_warnings
+create table tab1(a int, b char(1), primary key(a,b));
+create procedure proc_1() show create table tab1;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_SP_NO_RETSET
+create function func_1() returns int begin show create table tab1; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "show create table tab1";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+drop table tab1;
+
+
+--disable_warnings
+drop view if exists v1;
+drop table if exists t1;
+--enable_warnings
+create table t1(a int, b char(5));
+insert into t1 values (1, "one"), (1, "edno"), (2, "two"), (2, "dve");
+create view v1 as
+ (select a, count(*) from t1 group by a)
+ union all
+ (select b, count(*) from t1 group by b);
+create procedure proc_1() show create view v1;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_SP_NO_RETSET
+create function func_1() returns int begin show create view v1; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "show create view v1";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+drop view v1;
+drop table t1;
+
+
+create procedure proc_1() install plugin my_plug soname '/root/some_plugin.so';
+--error ER_UDF_NO_PATHS
+call proc_1();
+--error ER_UDF_NO_PATHS
+call proc_1();
+--error ER_UDF_NO_PATHS
+call proc_1();
+drop procedure proc_1;
+create procedure proc_1() install plugin my_plug soname 'some_plugin.so';
+--error ER_CANT_OPEN_LIBRARY
+call proc_1();
+--error ER_CANT_OPEN_LIBRARY
+call proc_1();
+--error ER_CANT_OPEN_LIBRARY
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+create function func_1() returns int begin install plugin my_plug soname '/tmp/plugin';
return 1; end|
+delimiter ;|
+--echo "This is not what we want. Once Bug#21777 is fixed, the following"
+--echo "statements have to be ajusted"
+--error ER_TABLE_NOT_LOCKED
+select func_1(), func_1(), func_1() from dual;
+drop function func_1;
+prepare abc from "install plugin my_plug soname '/root/some_plugin.so'";
+--error ER_UDF_NO_PATHS
+execute abc;
+--error ER_UDF_NO_PATHS
+execute abc;
+deallocate prepare abc;
+prepare abc from "install plugin my_plug soname 'some_plugin.so'";
+deallocate prepare abc;
+
+
+create procedure proc_1() uninstall plugin my_plug;
+--error ER_SP_DOES_NOT_EXIST
+call proc_1();
+--error ER_SP_DOES_NOT_EXIST
+call proc_1();
+--error ER_SP_DOES_NOT_EXIST
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+create function func_1() returns int begin uninstall plugin my_plug; return 1; end|
+delimiter ;|
+--echo "This is not what we want. Once Bug#21777 is fixed, the following"
+--echo "statements have to be ajusted"
+--error ER_TABLE_NOT_LOCKED
+select func_1(), func_1(), func_1() from dual;
+drop function func_1;
+prepare abc from "uninstall plugin my_plug";
+--error ER_SP_DOES_NOT_EXIST
+execute abc;
+--error ER_SP_DOES_NOT_EXIST
+execute abc;
+--error ER_SP_DOES_NOT_EXIST
+execute abc;
+deallocate prepare abc;
+
+
+--disable_warnings
+drop database if exists mysqltest_xyz;
+--enable_warnings
+create procedure proc_1() create database mysqltest_xyz;
+call proc_1();
+drop database if exists mysqltest_xyz;
+call proc_1();
+--error ER_DB_CREATE_EXISTS
+call proc_1();
+drop database if exists mysqltest_xyz;
+call proc_1();
+drop database if exists mysqltest_xyz;
+drop procedure proc_1;
+delimiter |;
+--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin create database mysqltest_xyz; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "create database mysqltest_xyz";
+execute abc;
+drop database if exists mysqltest_xyz;
+execute abc;
+--error ER_DB_CREATE_EXISTS
+execute abc;
+drop database if exists mysqltest_xyz;
+execute abc;
+drop database if exists mysqltest_xyz;
+deallocate prepare abc;
+
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (a int, b char(5));
+insert into t1 values (1, "one"), (2, "two"), (3, "three");
+create procedure proc_1() checksum table xyz;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_SP_NO_RETSET
+create function func_1() returns int begin checksum table t1; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "checksum table t1";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+
+
+create procedure proc_1() create user pstest_xyz@localhost;
+call proc_1();
+drop user pstest_xyz@localhost;
+call proc_1();
+--error ER_CANNOT_USER
+call proc_1();
+drop user pstest_xyz@localhost;
+call proc_1();
+drop user pstest_xyz@localhost;
+drop procedure proc_1;
+delimiter |;
+--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin create user pstest_xyz@localhost; return 1;
end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+prepare abc from "create user pstest_xyz@localhost";
+execute abc;
+drop user pstest_xyz@localhost;
+execute abc;
+--error ER_CANNOT_USER
+execute abc;
+drop user pstest_xyz@localhost;
+execute abc;
+drop user pstest_xyz@localhost;
+deallocate prepare abc;
+
+
+--disable_warnings
+drop event if exists xyz;
+--enable_warnings
+#create procedure proc_1() create event xyz on schedule every 5 minute disable do select
123;
+#call proc_1();
+#drop event xyz;
+#call proc_1();
+#--error ER_EVENT_ALREADY_EXISTS
+#call proc_1();
+#drop event xyz;
+#call proc_1();
+#drop event xyz;
+#drop procedure proc_1;
+delimiter |;
+--error ER_SP_NO_RETSET
+create function func_1() returns int begin create event xyz on schedule at now() do
select 123; return 1; end|
+delimiter ;|
+--error ER_SP_DOES_NOT_EXIST
+select func_1(), func_1(), func_1() from dual;
+--error ER_SP_DOES_NOT_EXIST
+drop function func_1;
+--error ER_UNSUPPORTED_PS
+prepare abc from "create event xyz on schedule at now() do select 123";
+--error ER_UNKNOWN_STMT_HANDLER
+deallocate prepare abc;
+
+
+--disable_warnings
+drop event if exists xyz;
+create event xyz on schedule every 5 minute disable do select 123;
+--enable_warnings
+create procedure proc_1() alter event xyz comment 'xyz';
+call proc_1();
+drop event xyz;
+create event xyz on schedule every 5 minute disable do select 123;
+call proc_1();
+drop event xyz;
+create event xyz on schedule every 5 minute disable do select 123;
+call proc_1();
+drop event xyz;
+drop procedure proc_1;
+delimiter |;
+--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin alter event xyz comment 'xyz'; return 1; end|
+delimiter ;|
+--error ER_UNSUPPORTED_PS
+prepare abc from "alter event xyz comment 'xyz'";
+--error ER_UNKNOWN_STMT_HANDLER
+deallocate prepare abc;
+
+
+--disable_warnings
+drop event if exists xyz;
+create event xyz on schedule every 5 minute disable do select 123;
+--enable_warnings
+create procedure proc_1() drop event xyz;
+call proc_1();
+create event xyz on schedule every 5 minute disable do select 123;
+call proc_1();
+--error ER_EVENT_DOES_NOT_EXIST
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
+create function func_1() returns int begin drop event xyz; return 1; end|
+delimiter ;|
+--error ER_UNSUPPORTED_PS
+prepare abc from "drop event xyz";
+--error ER_UNKNOWN_STMT_HANDLER
+deallocate prepare abc;
+
+
+--disable_warnings
+drop table if exists t1;
+create table t1 (a int, b char(5)) engine=myisam;
+insert into t1 values (1, "one"), (2, "two"), (3, "three");
+--enable_warnings
+SET GLOBAL new_cache.key_buffer_size=128*1024;
+create procedure proc_1() cache index t1 in new_cache;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+SET GLOBAL second_cache.key_buffer_size=128*1024;
+prepare abc from "cache index t1 in second_cache";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+drop table t1;
+
+--disable_warnings
+drop table if exists t1;
+drop table if exists t2;
+create table t1 (a int, b char(5)) engine=myisam;
+insert into t1 values (1, "one"), (2, "two"), (3, "three");
+create table t2 (a int, b char(5)) engine=myisam;
+insert into t2 values (1, "one"), (2, "two"), (3, "three");
+--enable_warnings
+create procedure proc_1() load index into cache t1 ignore leaves;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_SP_NO_RETSET
+create function func_1() returns int begin load index into cache t1 ignore leaves; return
1; end|
+delimiter ;|
+prepare abc from "load index into cache t2 ignore leaves";
+execute abc;
+execute abc;
+execute abc;
+deallocate prepare abc;
+drop table t1, t2;
+
+#
+# Bug #21422: GRANT/REVOKE possible inside stored function, probably in a trigger
+# This is disabled for now till it is resolved in 5.0
+#
+
+#create procedure proc_1() grant all on *.* to abc@host;
+#drop procedure proc_1;
+#delimiter |;
+#--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
+#create function func_1() returns int begin grant all on *.* to abc@host; return 1; end|
+#delimiter ;|
+#prepare abc from "grant all on *.* to abc@host";
+#
+#create procedure proc_1() revoke all on *.* from abc@host;
+#drop procedure proc_1;
+#delimiter |;#--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
+#create function func_1() returns int begin revoke all on *.* from abc@host; return 1;
end|
+#delimiter ;|
+#prepare abc from "revoke all on *.* from abc@host";
+
+create procedure proc_1() show errors;
+call proc_1();
+call proc_1();
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_SP_NO_RETSET
+create function func_1() returns int begin show errors; return 1; end|
+delimiter ;|
+prepare abc from "show errors";
+deallocate prepare abc;
+
+--disable_warnings
+drop table if exists t1;
+drop table if exists t2;
+--enable_warnings
+create procedure proc_1() show warnings;
+drop table if exists t1;
+call proc_1();
+drop table if exists t2;
+call proc_1();
+drop table if exists t1, t2;
+call proc_1();
+drop procedure proc_1;
+delimiter |;
+--error ER_SP_NO_RETSET
+create function func_1() returns int begin show warnings; return 1; end|
+delimiter ;|
+prepare abc from "show warnings";
+drop table if exists t1;
+execute abc;
+drop table if exists t2;
+execute abc;
+drop table if exists t1, t2;
+execute abc;
+deallocate prepare abc;
+
--- 1.175/sql/sql_prepare.cc 2006-08-22 15:40:37 +02:00
+++ 1.176/sql/sql_prepare.cc 2006-08-22 15:40:37 +02:00
@@ -1740,6 +1740,20 @@ static bool check_prepared_statement(Pre
case SQLCOM_SHOW_ENGINE_MUTEX:
case SQLCOM_SHOW_CREATE_DB:
case SQLCOM_SHOW_GRANTS:
+ case SQLCOM_SHOW_BINLOG_EVENTS:
+ case SQLCOM_SHOW_MASTER_STAT:
+ case SQLCOM_SHOW_SLAVE_STAT:
+ case SQLCOM_SHOW_CREATE_PROC:
+ case SQLCOM_SHOW_CREATE_FUNC:
+ case SQLCOM_SHOW_CREATE_EVENT:
+ case SQLCOM_SHOW_CREATE:
+ case SQLCOM_SHOW_PROC_CODE:
+ case SQLCOM_SHOW_FUNC_CODE:
+ case SQLCOM_SHOW_AUTHORS:
+ case SQLCOM_SHOW_CONTRIBUTORS:
+ case SQLCOM_SHOW_WARNS:
+ case SQLCOM_SHOW_ERRORS:
+ case SQLCOM_SHOW_BINLOGS:
case SQLCOM_DROP_TABLE:
case SQLCOM_RENAME_TABLE:
case SQLCOM_ALTER_TABLE:
@@ -1754,6 +1768,25 @@ static bool check_prepared_statement(Pre
case SQLCOM_REPAIR:
case SQLCOM_ANALYZE:
case SQLCOM_OPTIMIZE:
+ case SQLCOM_CHANGE_MASTER:
+ case SQLCOM_RESET:
+ case SQLCOM_FLUSH:
+ case SQLCOM_SLAVE_START:
+ case SQLCOM_SLAVE_STOP:
+ case SQLCOM_INSTALL_PLUGIN:
+ case SQLCOM_UNINSTALL_PLUGIN:
+ case SQLCOM_CREATE_DB:
+ case SQLCOM_DROP_DB:
+ case SQLCOM_RENAME_DB:
+ case SQLCOM_CHECKSUM:
+ case SQLCOM_CREATE_USER:
+ case SQLCOM_RENAME_USER:
+ case SQLCOM_DROP_USER:
+ case SQLCOM_ASSIGN_TO_KEYCACHE:
+ case SQLCOM_PRELOAD_KEYS:
+ case SQLCOM_GRANT:
+ case SQLCOM_REVOKE:
+ case SQLCOM_KILL:
break;
default:
| Thread |
|---|
| • bk commit into 5.1 tree (andrey:1.2279) BUG#20665 | ahristov | 22 Aug |