Commit 177ef90b authored by unknown's avatar unknown

Fixed BUG#4902: Stored procedure with SHOW WARNINGS leads to packet error,

  and tried to do it properly this time, digging out all show commands that
  need the multi results flag set.


mysql-test/r/sp.result:
  New test case for BUG#4902, with lots of other show commands as well.
mysql-test/t/sp.test:
  New test case for BUG#4902, with lots of other show commands as well.
sql/sp_head.cc:
  The check for possible multiple result commands was becomming unwieldly,
  so we moved it to a separate function, and added loads of new command codes
  to the test.
sql/sp_head.h:
  The check for possible multiple result commands was becomming unwieldly,
  so we moved it to a separate function.
sql/sql_yacc.yy:
  The check for possible multiple result commands was becomming unwieldly,
  so we moved it to a separate function.
parent 9bd52409
This diff is collapsed.
......@@ -1675,6 +1675,48 @@ handler t3 close|
drop procedure bug4318|
drop table t3|
#
# BUG#4902: Stored procedure with SHOW WARNINGS leads to packet error
#
# Added tests for most other show commands we could find too.
# (Skipping those already tested, and the ones depending on optional handlers.)
#
# Note: This will return a large number of results of different formats,
# which makes it impossible to filter with --replace_column.
# It's possible that some of these are not deterministic across
# platforms. If so, just remove the offending command.
#
create procedure bug4902()
begin
show binlog events;
show charset like 'foo';
show collation like 'foo';
show column types;
show create table t1;
show create database test;
show databases like 'foo';
show errors;
show columns from t1;
show grants for 'root'@'localhost';
show keys from t1;
show master status;
show open tables like 'foo';
show privileges;
show processlist;
show slave hosts;
show slave status;
show status like 'foo';
show tables like 'foo';
show variables like 'foo';
show warnings;
end|
#show storage engines;
call bug4902()|
call bug4902()|
drop procedure bug4902|
#
# Some "real" examples
......
......@@ -45,6 +45,54 @@ sp_map_result_type(enum enum_field_types type)
}
}
/*
* Returns TRUE if the 'cmd' is a command that might result in
* multiple result sets being sent back.
* Note: This does not include SQLCOM_SELECT which is treated
* separately in sql_yacc.yy.
*/
bool
sp_multi_results_command(enum enum_sql_command cmd)
{
switch (cmd) {
case SQLCOM_ANALYZE:
case SQLCOM_HA_READ:
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_CREATE:
case SQLCOM_SHOW_CREATE_DB:
case SQLCOM_SHOW_CREATE_FUNC:
case SQLCOM_SHOW_CREATE_PROC:
case SQLCOM_SHOW_DATABASES:
case SQLCOM_SHOW_ERRORS:
case SQLCOM_SHOW_FIELDS:
case SQLCOM_SHOW_GRANTS:
case SQLCOM_SHOW_INNODB_STATUS:
case SQLCOM_SHOW_KEYS:
case SQLCOM_SHOW_LOGS:
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_SLAVE_HOSTS:
case SQLCOM_SHOW_SLAVE_STAT:
case SQLCOM_SHOW_STATUS:
case SQLCOM_SHOW_STATUS_FUNC:
case SQLCOM_SHOW_STATUS_PROC:
case SQLCOM_SHOW_STORAGE_ENGINES:
case SQLCOM_SHOW_TABLES:
case SQLCOM_SHOW_VARIABLES:
case SQLCOM_SHOW_WARNS:
return TRUE;
default:
return FALSE;
}
}
/* Evaluate a (presumed) func item. Always returns an item, the parameter
** if nothing else.
*/
......
......@@ -32,6 +32,9 @@
Item_result
sp_map_result_type(enum enum_field_types type);
bool
sp_multi_results_command(enum enum_sql_command cmd);
struct sp_label;
class sp_instr;
struct sp_cond_type;
......
......@@ -1706,15 +1706,8 @@ sp_proc_stmt:
{
LEX *lex= Lex;
/* QQ What else? This doesn't seem to be a practical way,
but at the moment we can't think of anything better... */
if ((lex->sql_command == SQLCOM_SELECT && !lex->result) ||
lex->sql_command == SQLCOM_SHOW_CREATE_PROC ||
lex->sql_command == SQLCOM_SHOW_CREATE_FUNC ||
lex->sql_command == SQLCOM_SHOW_STATUS_PROC ||
lex->sql_command == SQLCOM_SHOW_STATUS_FUNC ||
lex->sql_command == SQLCOM_ANALYZE ||
lex->sql_command == SQLCOM_HA_READ)
sp_multi_results_command(lex->sql_command))
{
/* We maybe have one or more SELECT without INTO */
lex->sphead->m_multi_results= TRUE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment