diff options
author | unknown <knielsen@knielsen-hq.org> | 2012-08-24 15:29:01 +0200 |
---|---|---|
committer | unknown <knielsen@knielsen-hq.org> | 2012-08-24 15:29:01 +0200 |
commit | ced3907c02dfa3b237e14d79aa800b3a0769e94a (patch) | |
tree | 1189a55392ca290d6c9e8446250b7a9384feafb6 /sql/sql_db.cc | |
parent | caa535eb9fa97bd7c2190292bb4a3a3c1aaa71e3 (diff) | |
parent | fc666a0df6c69a620d3cffacd78e2569fb0ac410 (diff) | |
download | mariadb-git-ced3907c02dfa3b237e14d79aa800b3a0769e94a.tar.gz |
Merge from 5.3
Diffstat (limited to 'sql/sql_db.cc')
-rw-r--r-- | sql/sql_db.cc | 41 |
1 files changed, 12 insertions, 29 deletions
diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 052616f6965..5704b6d51b6 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -544,7 +544,6 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, bool silent) { char path[FN_REFLEN+16]; - char tmp_query[FN_REFLEN+16]; long result= 1; int error= 0; MY_STAT stat_info; @@ -622,17 +621,9 @@ not_silent: char *query; uint query_length; - if (!thd->query()) // Only in replication - { - query= tmp_query; - query_length= (uint) (strxmov(tmp_query,"create database `", - db, "`", NullS) - tmp_query); - } - else - { - query= thd->query(); - query_length= thd->query_length(); - } + query= thd->query(); + query_length= thd->query_length(); + DBUG_ASSERT(query); ha_binlog_log_query(thd, 0, LOGCOM_CREATE_DB, query, query_length, @@ -885,18 +876,11 @@ update_binlog: { const char *query; ulong query_length; - if (!thd->query()) - { - /* The client used the old obsolete mysql_drop_db() call */ - query= path; - query_length= (uint) (strxmov(path, "drop database `", db, "`", - NullS) - path); - } - else - { - query= thd->query(); - query_length= thd->query_length(); - } + + query= thd->query(); + query_length= thd->query_length(); + DBUG_ASSERT(query); + if (mysql_bin_log.is_open()) { int errcode= query_error_code(thd, TRUE); @@ -940,6 +924,7 @@ update_binlog: { uint tbl_name_len; bool exists; + char quoted_name[FN_REFLEN+3]; // Only write drop table to the binlog for tables that no longer exist. if (check_if_table_exists(thd, tbl, &exists)) @@ -950,8 +935,8 @@ update_binlog: if (exists) continue; - /* 3 for the quotes and the comma*/ - tbl_name_len= strlen(tbl->table_name) + 3; + my_snprintf(quoted_name, sizeof(quoted_name), "%`s", tbl->table_name); + tbl_name_len= strlen(quoted_name) + 1; /* +1 for the comma */ if (query_pos + tbl_name_len + 1 >= query_end) { /* @@ -966,9 +951,7 @@ update_binlog: query_pos= query_data_start; } - *query_pos++ = '`'; - query_pos= strmov(query_pos,tbl->table_name); - *query_pos++ = '`'; + query_pos= strmov(query_pos, quoted_name); *query_pos++ = ','; } |