From 45f2e0a7aad762af94eedd70b6fc0b91ae8e3376 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Tue, 15 Dec 2009 23:52:47 +0400 Subject: Backport from 6.0-codebase. WL#3771 "Audit Plugin Interface" Implement new plug-in type - AUDIT New plug-in: audit_null simply increments counter for how many times it was called. include/Makefile.am: wl3771 add new headers to distribution include/mysql/plugin.h: wl3771 define new AUDIT plugin type Split out fulltext plugin type into its own header include/mysql/plugin.h.pp: wl3771 no real API change, just re-arranged some code include/mysql/plugin_audit.h: wl3771 pluggable audit interface include/mysql/plugin_ftparser.h: wl3771 Split out fulltext plugin type into its own header libmysqld/CMakeLists.txt: wl3771 add sql_audit.cc to build libmysqld/Makefile.am: wl3771 add sql_audit.cc to build plugin/audit_null: wl3771 an example plugin for testing pluggable audit interface plugin/audit_null/Makefile.am: wl3771 an example plugin for testing pluggable audit interface plugin/audit_null/audit_null.c: wl3771 an example plugin for testing pluggable audit interface plugin/audit_null/plug.in: wl3771 an example plugin for testing pluggable audit interface sql/CMakeLists.txt: wl3771 add sql_audit.cc to build sql/Makefile.am: wl3771 add sql_audit.cc to build sql/event_queue.cc: wl3771 release audit resources before waiting sql/log.cc: wl3771 add general audit call for log sql/mysqld.cc: wl3771 add audit initialize/finalize add general audit call for error sql/sql_audit.cc: wl3771 pluggable audit interface implementation sql/sql_audit.h: wl3771 pluggable audit interface implementation sql/sql_class.cc: wl3771 add thd audit init/deinit calls sql/sql_class.h: wl3771 add required data structures for audit to THD sql/sql_connect.cc: wl3771 release audit resources before waiting sql/sql_insert.cc: wl3771 release audit plugins before waiting sql/sql_parse.cc: wl3771 add general audit call for results sql/sql_plugin.cc: wl3771 add declarations for audit plugin type --- sql/sql_parse.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index fe31b880d1c..9328b29f182 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -28,6 +28,7 @@ #include "sp_cache.h" #include "events.h" #include "sql_trigger.h" +#include "sql_audit.h" #include "sql_prepare.h" #include "probes_mysql.h" @@ -1483,6 +1484,15 @@ bool dispatch_command(enum enum_server_command command, THD *thd, /* Free tables */ close_thread_tables(thd); + if (!thd->is_error() && !thd->killed_errno()) + { + mysql_audit_general(thd,MYSQL_AUDIT_GENERAL_RESULT,0,my_time(0), + 0,0,0,0, + thd->query(), thd->query_length(), + thd->variables.character_set_client, + thd->warning_info->current_row_for_warning()); + } + log_slow_statement(thd); thd_proc_info(thd, "cleaning up"); -- cgit v1.2.1 From 9130563708cbdbb488e5361af79eb9f4b9dab0ea Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Wed, 16 Dec 2009 15:56:36 +0400 Subject: Backport from 6.0-codebase. Bug #36098 Audit plugin (wl 3771) feature disabled in 6.0 avoid recusrive locking of LOCK_plugin include/mysql/plugin_audit.h: fix incorrect version sql/log.cc: move the common code to a shared header sql/mysqld.cc: restore the deleted functionality sql/set_var.cc: remove unused parameter sql/sql_audit.h: two inline convenience functions sql/sql_parse.cc: use a simplified convenience call sql/sql_plugin.cc: unlock LOCK_plugin for plugin->init() call, add missing OOM check, issue "unknown variable" error in find_sys_var, not down the stack --- sql/sql_parse.cc | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9328b29f182..eeaefde6588 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1485,13 +1485,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, close_thread_tables(thd); if (!thd->is_error() && !thd->killed_errno()) - { - mysql_audit_general(thd,MYSQL_AUDIT_GENERAL_RESULT,0,my_time(0), - 0,0,0,0, - thd->query(), thd->query_length(), - thd->variables.character_set_client, - thd->warning_info->current_row_for_warning()); - } + mysql_audit_general(thd, MYSQL_AUDIT_GENERAL_RESULT, 0, 0); log_slow_statement(thd); -- cgit v1.2.1 From 06a1df91813ea2c39f7312bcf8af972c7e8a926f Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Thu, 17 Dec 2009 15:58:38 -0200 Subject: Bug#48983: Bad strmake calls (length one too long) The problem is a somewhat common misusage of the strmake function. The strmake(dst, src, len) function writes at most /len/ bytes to the string pointed to by src, not including the trailing null byte. Hence, if /len/ is the exact length of the destination buffer, a one byte buffer overflow can occur if the length of the source string is equal to or greater than /len/. client/mysqldump.c: Make room for the trailing null byte. libmysql/libmysql.c: Add comment, there is enough room in the buffer. Increase buffer length, two strings are concatenated. libmysqld/lib_sql.cc: Make room for the trailing null byte. mysys/default.c: Make room for the trailing null bytes. mysys/mf_pack.c: Make room for the trailing null byte. server-tools/instance-manager/commands.cc: Copy only if overflow isn't possible in both cases. server-tools/instance-manager/listener.cc: Make room for the trailing null byte. sql/log.cc: Make room for the trailing null byte. sql/sp_pcontext.h: Cosmetic fix. sql/sql_acl.cc: MAX_HOSTNAME already specifies space for the trailing null byte. sql/sql_parse.cc: Make room for the trailing null byte. sql/sql_table.cc: Make room for the trailing null byte. --- sql/sql_parse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f34aa3c3bad..48df40f2614 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -917,7 +917,7 @@ static int check_connection(THD *thd) vio_keepalive(net->vio, TRUE); { /* buff[] needs to big enough to hold the server_version variable */ - char buff[SERVER_VERSION_LENGTH + SCRAMBLE_LENGTH + 64]; + char buff[SERVER_VERSION_LENGTH + 1 + SCRAMBLE_LENGTH + 1 + 64]; ulong client_flags = (CLIENT_LONG_FLAG | CLIENT_CONNECT_WITH_DB | CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION); -- cgit v1.2.1 From 2b2ce3d6cb01a36cd35191e8670dcb023420c84e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 Dec 2009 11:33:10 +0800 Subject: Bug #49137 Replication failure on SBR/MBR + multi-table DROP TEMPORARY TABLE In statement-based or mixed-mode replication, use DROP TEMPORARY TABLE to drop multiple tables causes different errors on master and slave, when one or more of these tables do not exist. Because when executed on slave, it would automatically add IF EXISTS to the query to ignore all ER_BAD_TABLE_ERROR errors. To fix the problem, do not add IF EXISTS when executing DROP TEMPORARY TABLE on the slave, and clear the ER_BAD_TABLE_ERROR error after execution if the query does not expect any errors. mysql-test/r/rpl_drop_temp.result: Updated for the patch of bug#49137. mysql-test/t/rpl_drop_temp.test: Added the test file to verify if DROP MULTI TEMPORARY TABLE will cause different errors on master and slave, when one or more of these tables do not exist. sql/log_event.cc: Added code to handle above cases which are removed from sql_parse.cc sql/sql_parse.cc: Remove the code to issue the 'Unknown table' error, if the temporary table does not exist when dropping it on slave. The above cases decribed in comments will be handled later in log_event.cc. --- sql/sql_parse.cc | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 48df40f2614..61c2d70a563 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4038,17 +4038,6 @@ end_with_restore_list: } else { - /* - If this is a slave thread, we may sometimes execute some - DROP / * 40005 TEMPORARY * / TABLE - that come from parts of binlogs (likely if we use RESET SLAVE or CHANGE - MASTER TO), while the temporary table has already been dropped. - To not generate such irrelevant "table does not exist errors", - we silently add IF EXISTS if TEMPORARY was used. - */ - if (thd->slave_thread) - lex->drop_if_exists= 1; - /* So that DROP TEMPORARY TABLE gets to binlog at commit/rollback */ thd->transaction.all.modified_non_trans_table= TRUE; } -- cgit v1.2.1 From c8b5804f295ea109f56f29de8c350133f9070a6a Mon Sep 17 00:00:00 2001 From: Martin Hansson Date: Tue, 12 Jan 2010 15:16:26 +0100 Subject: Bug#48157: crash in Item_field::used_tables MySQL handles the join syntax "JOIN ... USING( field1, ... )" and natural joins by building the same parse tree as a corresponding join with an "ON t1.field1 = t2.field1 ..." expression would produce. This parse tree was not cleaned up properly in the following scenario. If a thread tries to lock some tables and finds that the tables were dropped and re-created while waiting for the lock, it cleans up column references in the statement by means a per-statement free list. But if the statement was part of a stored procedure, column references on the stored procedure's free list weren't cleaned up and thus contained pointers to freed objects. Fixed by adding a call to clean up the current prepared statement's free list. mysql-test/r/sp_sync.result: Bug#48157: Test case mysql-test/t/sp_sync.test: Bug#48157: Test result sql/item.h: Bug#48157: Commented field. sql/sql_parse.cc: Bug#48157: Commented function. sql/sql_update.cc: Bug#48157: fix --- sql/sql_parse.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 69c9ddc7806..48743a2d48f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -615,8 +615,10 @@ void free_items(Item *item) DBUG_VOID_RETURN; } -/* This works because items are allocated with sql_alloc() */ - +/** + This works because items are allocated with sql_alloc(). + @note The function also handles null pointers (empty list). +*/ void cleanup_items(Item *item) { DBUG_ENTER("cleanup_items"); -- cgit v1.2.1 From b3dd4d9486ca00e555823f81185fe9db83a44db5 Mon Sep 17 00:00:00 2001 From: Kristofer Pettersson Date: Wed, 13 Jan 2010 12:39:00 +0100 Subject: Bug#33982 debug assertion and crash reloading grant tables after sighup or kill In certain rare cases when a process was interrupted during a FLUSH PRIVILEGES operation the diagnostic area would be set to an error state but the function responsible for the operation would still signal success. This would lead to a debug assertion error later on when the server would attempt to reset the DA before sending the error message. This patch fixes the issue by assuring that reload_acl_and_cache() always fails if an error condition is raised. The second issue was that a KILL could cause a console error message which referred to a DA state without first making sure that such a state existed. This patch fixes this issue in two different palces by first checking DA state before fetching the error message. sql/sql_acl.cc: * Make sure that there is an error to print before attempting to do so. * Minor style change: change 1 to TRUE for clarity. sql/sql_parse.cc: * Always fail reload_acl_and_cache() if the query was killed. sql/sql_servers.cc: * Make sure that there is an error to print before attempting to do so. --- sql/sql_parse.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 69c9ddc7806..2c466d31e7c 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -6787,13 +6787,13 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, thd->store_globals(); lex_start(thd); } - + if (thd) { bool reload_acl_failed= acl_reload(thd); bool reload_grants_failed= grant_reload(thd); bool reload_servers_failed= servers_reload(thd); - + if (reload_acl_failed || reload_grants_failed || reload_servers_failed) { result= 1; @@ -6949,7 +6949,10 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, if (options & REFRESH_USER_RESOURCES) reset_mqh((LEX_USER *) NULL, 0); /* purecov: inspected */ *write_to_binlog= tmp_write_to_binlog; - return result; + /* + If the query was killed then this function must fail. + */ + return result || thd->killed; } -- cgit v1.2.1 From 377d710296c3b0c85ea4cdc018d1d8e08bfa022a Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 16 Jan 2010 15:44:24 +0800 Subject: BUG#47418 RBR fails, failure with mixup of base/temporary/view 'CREATE TABLE IF NOT EXISTS ... SELECT' statement were causing 'CREATE TEMPORARY TABLE ...' to be written to the binary log in row-based mode (a.k.a. RBR), when there was a temporary table with the same name. Because the 'CREATE TABLE ... SELECT' statement was executed as 'INSERT ... SELECT' into the temporary table. Since in RBR mode no other statements related to temporary tables are written into binary log, this sometimes broke replication. This patch changes behavior of 'CREATE TABLE [IF NOT EXISTS] ... SELECT ...'. it ignores existence of temporary table with the same name as table being created and is interpreted as attempt to create/insert into base table. This makes behavior of 'CREATE TABLE [IF NOT EXISTS] ... SELECT' consistent with how ordinary 'CREATE TABLE' and 'CREATE TABLE ... LIKE' behave. --- sql/sql_parse.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index eaea6e55b09..c3070c4a756 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2659,6 +2659,8 @@ mysql_execute_command(THD *thd) { lex->link_first_table_back(create_table, link_to_local); create_table->create= TRUE; + /* Base table and temporary table are not in the same name space. */ + create_table->skip_temporary= 1; } if (!(res= open_and_lock_tables(thd, lex->query_tables))) -- cgit v1.2.1 From eab2be0aeed0459c505578a716f8b0ae88a8f365 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Mon, 18 Jan 2010 17:49:18 +0100 Subject: Bug#47343: InnoDB fails to clean-up after lock wait timeout on REORGANIZE PARTITION There were several problems which lead to this this, all related to bad error handling. 1) There was several bugs preventing the ddl-log to be used for cleaning up created files on error. 2) The error handling after the copy partition rows did not close and unlock the tables, resulting in deletion of partitions which were in use, which lead InnoDB to put the partition to drop in a background queue. sql/ha_partition.cc: Bug#47343: InnoDB fails to clean-up after lock wait timeout on REORGANIZE PARTITION Better error handling, if partition has been created/opened/locked then make sure it is unlocked and closed before returning error. The delete of the newly created partition is handled by the ddl-log. sql/sql_parse.cc: Bug#47343: InnoDB fails to clean-up after lock wait timeout on REORGANIZE PARTITION Fix a bug found when experimenting, thd could really be NULL here, as mentioned in the function header. sql/sql_partition.cc: Bug#47343: InnoDB fails to clean-up after lock wait timeout on REORGANIZE PARTITION Used the correct .frm shadow name to put into the ddl-log. Really use the ddl-log to handle errors. sql/sql_table.cc: Bug#47343: InnoDB fails to clean-up after lock wait timeout on REORGANIZE PARTITION Fixes of the ddl-log when used as error recovery (no crash). When executing an entry from memory (not read from disk) the name_len was not set correctly. --- sql/sql_parse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index eaea6e55b09..7eabc1887f9 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -6954,7 +6954,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, /* If the query was killed then this function must fail. */ - return result || thd->killed; + return result || (thd ? thd->killed : 0); } -- cgit v1.2.1 From 81391bd00c5b3e577fc88e142406eb288a26a0ff Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Tue, 19 Jan 2010 13:03:40 +0400 Subject: Bug#49501 Inefficient information_schema check (system collation) added check_length optimization for I_S_NAME comparison sql/event_data_objects.cc: added check_length optimization for I_S_NAME comparison sql/events.cc: added check_length optimization for I_S_NAME comparison sql/mysql_priv.h: added check_length optimization for I_S_NAME comparison sql/repl_failsafe.cc: added check_length optimization for I_S_NAME comparison sql/sql_db.cc: added check_length optimization for I_S_NAME comparison sql/sql_parse.cc: added check_length optimization for I_S_NAME comparison sql/sql_show.cc: added check_length optimization for I_S_NAME comparison sql/sql_view.cc: added check_length optimization for I_S_NAME comparison sql/table.cc: added check_length optimization for I_S_NAME comparison --- sql/sql_parse.cc | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c3070c4a756..f0fb58e9c3e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1305,8 +1305,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, table_list.alias= table_list.table_name= conv_name.str; packet= arg_end + 1; - if (!my_strcasecmp(system_charset_info, table_list.db, - INFORMATION_SCHEMA_NAME.str)) + if (is_schema_db(table_list.db, table_list.db_length)) { ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, table_list.alias); if (schema_table) @@ -1368,7 +1367,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, break; } if (check_access(thd, CREATE_ACL, db.str , 0, 1, 0, - is_schema_db(db.str))) + is_schema_db(db.str, db.length))) break; general_log_print(thd, command, "%.*s", db.length, db.str); bzero(&create_info, sizeof(create_info)); @@ -1387,7 +1386,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, my_error(ER_WRONG_DB_NAME, MYF(0), db.str ? db.str : "NULL"); break; } - if (check_access(thd, DROP_ACL, db.str, 0, 1, 0, is_schema_db(db.str))) + if (check_access(thd, DROP_ACL, db.str, 0, 1, 0, + is_schema_db(db.str, db.length))) break; if (thd->locked_tables || thd->active_transaction()) { @@ -2852,7 +2852,7 @@ end_with_restore_list: &first_table->grant.privilege, 0, 0, test(first_table->schema_table)) || check_access(thd,INSERT_ACL | CREATE_ACL,select_lex->db,&priv,0,0, - is_schema_db(select_lex->db))|| + is_schema_db(select_lex->db, strlen(select_lex->db)))|| check_merge_table_access(thd, first_table->db, (TABLE_LIST *) create_info.merge_list.first)) @@ -3590,7 +3590,7 @@ end_with_restore_list: } #endif if (check_access(thd,CREATE_ACL,lex->name.str, 0, 1, 0, - is_schema_db(lex->name.str))) + is_schema_db(lex->name.str, lex->name.length))) break; res= mysql_create_db(thd,(lower_case_table_names == 2 ? alias : lex->name.str), &create_info, 0); @@ -3625,7 +3625,7 @@ end_with_restore_list: } #endif if (check_access(thd,DROP_ACL,lex->name.str,0,1,0, - is_schema_db(lex->name.str))) + is_schema_db(lex->name.str, lex->name.length))) break; if (thd->locked_tables || thd->active_transaction()) { @@ -3659,9 +3659,12 @@ end_with_restore_list: my_error(ER_WRONG_DB_NAME, MYF(0), db->str); break; } - if (check_access(thd, ALTER_ACL, db->str, 0, 1, 0, is_schema_db(db->str)) || - check_access(thd, DROP_ACL, db->str, 0, 1, 0, is_schema_db(db->str)) || - check_access(thd, CREATE_ACL, db->str, 0, 1, 0, is_schema_db(db->str))) + if (check_access(thd, ALTER_ACL, db->str, 0, 1, 0, + is_schema_db(db->str, db->length)) || + check_access(thd, DROP_ACL, db->str, 0, 1, 0, + is_schema_db(db->str, db->length)) || + check_access(thd, CREATE_ACL, db->str, 0, 1, 0, + is_schema_db(db->str, db->length))) { res= 1; break; @@ -3704,7 +3707,8 @@ end_with_restore_list: break; } #endif - if (check_access(thd, ALTER_ACL, db->str, 0, 1, 0, is_schema_db(db->str))) + if (check_access(thd, ALTER_ACL, db->str, 0, 1, 0, + is_schema_db(db->str, db->length))) break; if (thd->locked_tables || thd->active_transaction()) { @@ -3860,7 +3864,8 @@ end_with_restore_list: first_table ? &first_table->grant.privilege : 0, first_table ? 0 : 1, 0, first_table ? (bool) first_table->schema_table : - select_lex->db ? is_schema_db(select_lex->db) : 0)) + select_lex->db ? + is_schema_db(select_lex->db, strlen(select_lex->db)) : 0)) goto error; if (thd->security_ctx->user) // If not replication @@ -4203,7 +4208,8 @@ end_with_restore_list: } if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str, 0, 0, 0, - is_schema_db(lex->sphead->m_db.str))) + is_schema_db(lex->sphead->m_db.str, + lex->sphead->m_db.length))) goto create_sp_error; if (end_active_trans(thd)) @@ -4858,7 +4864,8 @@ create_sp_error: res= mysql_xa_recover(thd); break; case SQLCOM_ALTER_TABLESPACE: - if (check_access(thd, ALTER_ACL, thd->db, 0, 1, 0, thd->db ? is_schema_db(thd->db) : 0)) + if (check_access(thd, ALTER_ACL, thd->db, 0, 1, 0, + thd->db ? is_schema_db(thd->db, thd->db_length) : 0)) break; if (!(res= mysql_alter_tablespace(thd, lex->alter_tablespace_info))) my_ok(thd); @@ -5297,7 +5304,7 @@ static bool check_show_access(THD *thd, TABLE_LIST *table) if (check_access(thd, SELECT_ACL, dst_db_name, &thd->col_access, FALSE, FALSE, - is_schema_db(dst_db_name))) + is_schema_db(dst_db_name, strlen(dst_db_name)))) return TRUE; if (!thd->col_access && check_grant_db(thd, dst_db_name)) @@ -6262,8 +6269,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, ptr->force_index= test(table_options & TL_OPTION_FORCE_INDEX); ptr->ignore_leaves= test(table_options & TL_OPTION_IGNORE_LEAVES); ptr->derived= table->sel; - if (!ptr->derived && !my_strcasecmp(system_charset_info, ptr->db, - INFORMATION_SCHEMA_NAME.str)) + if (!ptr->derived && is_schema_db(ptr->db, ptr->db_length)) { ST_SCHEMA_TABLE *schema_table= find_schema_table(thd, ptr->table_name); if (!schema_table || -- cgit v1.2.1 From 4a10f7b46c9ebbd9af89f37f64df40981459b788 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Fri, 22 Jan 2010 14:58:21 +0400 Subject: Bug#49501 Inefficient information_schema check (system collation), addon removed wrongly introduced strlen calls sql/events.cc: removed wrongly introduced strlen calls sql/mysql_priv.h: removed wrongly introduced strlen calls sql/repl_failsafe.cc: removed wrongly introduced strlen calls sql/sql_db.cc: removed wrongly introduced strlen calls sql/sql_parse.cc: removed wrongly introduced strlen calls sql/sql_show.cc: removed wrongly introduced strlen calls --- sql/sql_parse.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 3c404a984bf..a2a1494141c 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2852,7 +2852,7 @@ end_with_restore_list: &first_table->grant.privilege, 0, 0, test(first_table->schema_table)) || check_access(thd,INSERT_ACL | CREATE_ACL,select_lex->db,&priv,0,0, - is_schema_db(select_lex->db, strlen(select_lex->db)))|| + is_schema_db(select_lex->db))|| check_merge_table_access(thd, first_table->db, (TABLE_LIST *) create_info.merge_list.first)) @@ -3865,7 +3865,7 @@ end_with_restore_list: first_table ? 0 : 1, 0, first_table ? (bool) first_table->schema_table : select_lex->db ? - is_schema_db(select_lex->db, strlen(select_lex->db)) : 0)) + is_schema_db(select_lex->db) : 0)) goto error; if (thd->security_ctx->user) // If not replication @@ -5304,7 +5304,7 @@ static bool check_show_access(THD *thd, TABLE_LIST *table) if (check_access(thd, SELECT_ACL, dst_db_name, &thd->col_access, FALSE, FALSE, - is_schema_db(dst_db_name, strlen(dst_db_name)))) + is_schema_db(dst_db_name))) return TRUE; if (!thd->col_access && check_grant_db(thd, dst_db_name)) -- cgit v1.2.1 From 2b16517522afad76bc94b07bdaa8af64091e713b Mon Sep 17 00:00:00 2001 From: He Zhenxing Date: Sun, 24 Jan 2010 15:03:23 +0800 Subject: Backport Bug#37148 to 5.1 --- sql/sql_parse.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a2a1494141c..a114d92b124 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2987,7 +2987,7 @@ end_with_restore_list: /* Presumably, REPAIR and binlog writing doesn't require synchronization */ - write_bin_log(thd, TRUE, thd->query(), thd->query_length()); + res= write_bin_log(thd, TRUE, thd->query(), thd->query_length()); } select_lex->table_list.first= (uchar*) first_table; lex->query_tables=all_tables; @@ -3019,7 +3019,7 @@ end_with_restore_list: /* Presumably, ANALYZE and binlog writing doesn't require synchronization */ - write_bin_log(thd, TRUE, thd->query(), thd->query_length()); + res= write_bin_log(thd, TRUE, thd->query(), thd->query_length()); } select_lex->table_list.first= (uchar*) first_table; lex->query_tables=all_tables; @@ -3042,7 +3042,7 @@ end_with_restore_list: /* Presumably, OPTIMIZE and binlog writing doesn't require synchronization */ - write_bin_log(thd, TRUE, thd->query(), thd->query_length()); + res= write_bin_log(thd, TRUE, thd->query(), thd->query_length()); } select_lex->table_list.first= (uchar*) first_table; lex->query_tables=all_tables; @@ -3159,7 +3159,7 @@ end_with_restore_list: if (incident) { Incident_log_event ev(thd, incident); - mysql_bin_log.write(&ev); + (void) mysql_bin_log.write(&ev); /* error is ignored */ mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE); } DBUG_PRINT("debug", ("Just after generate_incident()")); @@ -3988,7 +3988,8 @@ end_with_restore_list: */ if (!lex->no_write_to_binlog && write_to_binlog) { - write_bin_log(thd, FALSE, thd->query(), thd->query_length()); + if (res= write_bin_log(thd, FALSE, thd->query(), thd->query_length())) + break; } my_ok(thd); } @@ -4566,12 +4567,12 @@ create_sp_error: case SP_KEY_NOT_FOUND: if (lex->drop_if_exists) { - write_bin_log(thd, TRUE, thd->query(), thd->query_length()); + res= write_bin_log(thd, TRUE, thd->query(), thd->query_length()); push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST), SP_COM_STRING(lex), lex->spname->m_name.str); - res= FALSE; - my_ok(thd); + if (!res) + my_ok(thd); break; } my_error(ER_SP_DOES_NOT_EXIST, MYF(0), -- cgit v1.2.1 From c3a73a8f6d674de1e9efcb498f3343db802d6a6c Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Thu, 28 Jan 2010 19:51:40 -0200 Subject: Fix for compiler warnings: Rename method as to not hide a base. Reorder attributes initialization. Remove unused variable. Rework code to silence a warning due to assignment used as truth value. sql/item_strfunc.cc: Rename method as to not hide a base. sql/item_strfunc.h: Rename method as to not hide a base. sql/log_event.cc: Reorder attributes initialization. sql/rpl_injector.cc: Rework code to silence a warning due to assignment used as truth value. sql/rpl_record.cc: Remove unused variable. sql/sql_db.cc: Rework code to silence a warning due to assignment used as truth value. sql/sql_parse.cc: Rework code to silence a warning due to assignment used as truth value. sql/sql_table.cc: Rework code to silence a warning due to assignment used as truth value. --- sql/sql_parse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a114d92b124..2dd71b2214a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3988,7 +3988,7 @@ end_with_restore_list: */ if (!lex->no_write_to_binlog && write_to_binlog) { - if (res= write_bin_log(thd, FALSE, thd->query(), thd->query_length())) + if ((res= write_bin_log(thd, FALSE, thd->query(), thd->query_length()))) break; } my_ok(thd); -- cgit v1.2.1 From 443003a467ab11b2d34e8d67658338659348325b Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 29 Jan 2010 11:36:28 +0200 Subject: Bug #49552 : sql_buffer_result cause crash + not found records in multitable delete/subquery SQL_BUFFER_RESULT should not have an effect on non-SELECT statements according to our documentation. Fixed by not passing it through to multi-table DELETE (similarly to how it's done for multi-table UPDATE). --- sql/sql_parse.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 2dd71b2214a..df2c1854914 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3352,9 +3352,9 @@ end_with_restore_list: select_lex->where, 0, (ORDER *)NULL, (ORDER *)NULL, (Item *)NULL, (ORDER *)NULL, - select_lex->options | thd->options | + (select_lex->options | thd->options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK | - OPTION_SETUP_TABLES_DONE, + OPTION_SETUP_TABLES_DONE) & ~OPTION_BUFFER_RESULT, del_result, unit, select_lex); res|= thd->is_error(); if (res) -- cgit v1.2.1