1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Fix for bug #6081 "Call to deprecated mysql_create_db() function crashes

server".

Altough mysql_create_db()/mysql_drop_db() API calls are deprecated
since 4.0, they should not crash server and should not stall connection
in case of errors. 


sql/sql_parse.cc:
  Handling of COM_CREATE_DB, COM_DROP_DB:
    mysql_create_db() requires from its second parameter to be non-zero.
    We also should call send_error() if mysql_create_db or mysql_drop_db
    return error (like we do it for SQL versions of these commands).
tests/client_test.c:
  Added test for bug #6081 "Execution of deprecated mysql_create_db()
  crashes server".
This commit is contained in:
unknown
2004-10-17 13:59:46 +04:00
parent 221d51ebb1
commit 07c7aadf44
2 changed files with 36 additions and 2 deletions

View File

@ -1556,6 +1556,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
case COM_CREATE_DB: // QQ: To be removed
{
char *db=thd->strdup(packet), *alias;
HA_CREATE_INFO create_info;
statistic_increment(com_stat[SQLCOM_CREATE_DB],&LOCK_status);
// null test to handle EOM
@ -1567,7 +1568,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (check_access(thd,CREATE_ACL,db,0,1,0))
break;
mysql_log.write(thd,command,packet);
mysql_create_db(thd,(lower_case_table_names == 2 ? alias : db),0,0);
bzero(&create_info, sizeof(create_info));
if (mysql_create_db(thd, (lower_case_table_names == 2 ? alias : db),
&create_info, 0) < 0)
send_error(thd, thd->killed ? ER_SERVER_SHUTDOWN : 0);
break;
}
case COM_DROP_DB: // QQ: To be removed
@ -1588,7 +1592,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
break;
}
mysql_log.write(thd,command,db);
mysql_rm_db(thd, (lower_case_table_names == 2 ? alias : db), 0, 0);
if (mysql_rm_db(thd, (lower_case_table_names == 2 ? alias : db),
0, 0) < 0)
send_error(thd, thd->killed ? ER_SERVER_SHUTDOWN : 0);
break;
}
#ifndef EMBEDDED_LIBRARY