summaryrefslogtreecommitdiff
path: root/sql/sql_db.cc
diff options
context:
space:
mode:
authorRohit Kalhans <rohit.kalhans@oracle.com>2012-09-22 18:07:04 +0530
committerRohit Kalhans <rohit.kalhans@oracle.com>2012-09-22 18:07:04 +0530
commit4802faad3f67e5950858c2eba04271d836c1edb1 (patch)
treee8c9feb9d583b378ecdda8db05f6871ea6cefdbd /sql/sql_db.cc
parent02ee112f9ab9d8451755df35a1c3edc9bb3fd75e (diff)
parent5530c5e38dbefac8e5d2c333c0f35ed9f73946a4 (diff)
downloadmariadb-git-4802faad3f67e5950858c2eba04271d836c1edb1.tar.gz
upmerge to bug#14548159
Diffstat (limited to 'sql/sql_db.cc')
-rw-r--r--sql/sql_db.cc34
1 files changed, 23 insertions, 11 deletions
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 99cb8cf4b3a..c0a0a4d5522 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -37,6 +37,7 @@
#include <my_dir.h>
#include <m_ctype.h>
#include "log.h"
+#include "log_event.h"
#ifdef __WIN__
#include <direct.h>
#endif
@@ -619,12 +620,17 @@ not_silent:
{
char *query;
uint query_length;
+ char db_name_quoted[2 * FN_REFLEN + sizeof("create database ") + 2];
+ int id_len= 0;
if (!thd->query()) // Only in replication
{
- query= tmp_query;
- query_length= (uint) (strxmov(tmp_query,"create database `",
- db, "`", NullS) - tmp_query);
+ id_len= my_strmov_quoted_identifier(thd, (char *) db_name_quoted, db,
+ 0);
+ db_name_quoted[id_len]= '\0';
+ query= tmp_query;
+ query_length= (uint) (strxmov(tmp_query,"create database ",
+ db_name_quoted, NullS) - tmp_query);
}
else
{
@@ -761,7 +767,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
{
ulong deleted_tables= 0;
bool error= true;
- char path[FN_REFLEN+16];
+ char path[2 * FN_REFLEN + 16];
MY_DIR *dirp;
uint length;
bool found_other_files= false;
@@ -883,11 +889,16 @@ update_binlog:
{
const char *query;
ulong query_length;
+ // quoted db name + wraping quote
+ char buffer_temp [2 * FN_REFLEN + 2];
+ int id_len= 0;
if (!thd->query())
{
/* The client used the old obsolete mysql_drop_db() call */
query= path;
- query_length= (uint) (strxmov(path, "drop database `", db, "`",
+ id_len= my_strmov_quoted_identifier(thd, buffer_temp, db, strlen(db));
+ buffer_temp[id_len] ='\0';
+ query_length= (uint) (strxmov(path, "DROP DATABASE ", buffer_temp, "",
NullS) - path);
}
else
@@ -925,12 +936,13 @@ update_binlog:
else if (mysql_bin_log.is_open() && !silent)
{
char *query, *query_pos, *query_end, *query_data_start;
+ char temp_identifier[ 2 * FN_REFLEN + 2];
TABLE_LIST *tbl;
- uint db_len;
+ uint db_len, id_length=0;
if (!(query= (char*) thd->alloc(MAX_DROP_TABLE_Q_LEN)))
goto exit; /* not much else we can do */
- query_pos= query_data_start= strmov(query,"drop table ");
+ query_pos= query_data_start= strmov(query,"DROP TABLE ");
query_end= query + MAX_DROP_TABLE_Q_LEN;
db_len= strlen(db);
@@ -963,10 +975,10 @@ update_binlog:
}
query_pos= query_data_start;
}
-
- *query_pos++ = '`';
- query_pos= strmov(query_pos,tbl->table_name);
- *query_pos++ = '`';
+ id_length= my_strmov_quoted_identifier(thd, (char *)temp_identifier,
+ tbl->table_name, 0);
+ temp_identifier[id_length]= '\0';
+ query_pos= strmov(query_pos,(char *)&temp_identifier);
*query_pos++ = ',';
}