From ecc5a07874d44307b835ff5dbd091343961fbc93 Mon Sep 17 00:00:00 2001 From: Shishir Jaiswal Date: Sat, 2 Dec 2017 15:12:32 +0530 Subject: Bug#26585560 - MYSQL DAEMON SHOULD CREATE ITS PID FILE AS ROOT DESCRIPTION =========== If the .pid file is created at a world-writable location, it can be compromised by replacing the server's pid with another running server's (or some other non-mysql process) PID causing abnormal behaviour. ANALYSIS ======== In such a case, user should be warned that .pid file is being created at a world-writable location. FIX === A new function is_file_or_dir_world_writable() is defined and it is called in create_pid_file() before .pid file creation. If the location is world-writable, a relevant warning is thrown. NOTE ==== 1. PID file is always created with permission bit 0664, so for outside world its read-only. 2. Ignoring the case when permission is denied to get the dir stats since the .pid file creation would fail anyway in such a case. --- sql/CMakeLists.txt | 2 +- sql/mysqld.cc | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) (limited to 'sql') diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 531561ac36d..aa7e0312e05 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -78,7 +78,7 @@ SET (SQL_SOURCE sql_profile.cc event_parse_data.cc sql_alter.cc sql_signal.cc rpl_handler.cc mdl.cc sql_admin.cc transaction.cc sys_vars.cc sql_truncate.cc datadict.cc - sql_reload.cc + sql_reload.cc ../sql-common/my_path_permissions.cc ${GEN_SOURCES} ${CONF_SOURCES} ${MYSYS_LIBWRAP_SOURCE}) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index c969fd8a62a..fd39e252c26 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights +/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify @@ -7996,6 +7996,40 @@ static int test_if_case_insensitive(const char *dir_name) static void create_pid_file() { File file; + bool check_parent_path= 1, is_path_accessible= 1; + char pid_filepath[FN_REFLEN], *pos= NULL; + /* Copy pid file name to get pid file path */ + strcpy(pid_filepath, pidfile_name); + + /* Iterate through the entire path to check if even one of the sub-dirs + is world-writable */ + while (check_parent_path && (pos= strrchr(pid_filepath, FN_LIBCHAR)) + && (pos != pid_filepath)) /* shouldn't check root */ + { + *pos= '\0'; /* Trim the inner-most dir */ + switch (is_file_or_dir_world_writable(pid_filepath)) + { + case -2: + is_path_accessible= 0; + break; + case -1: + sql_perror("Can't start server: can't check PID filepath"); + exit(1); + case 1: + sql_print_warning("Insecure configuration for --pid-file: Location " + "'%s' in the path is accessible to all OS users. " + "Consider choosing a different directory.", + pid_filepath); + check_parent_path= 0; + break; + case 0: + continue; /* Keep checking the parent dir */ + } + } + if (!is_path_accessible) + { + sql_print_warning("Few location(s) are inaccessible while checking PID filepath."); + } if ((file= mysql_file_create(key_file_pid, pidfile_name, 0664, O_WRONLY | O_TRUNC, MYF(MY_WME))) >= 0) { -- cgit v1.2.1 From 9e1035c64f2db233995082397921f553810bdfbc Mon Sep 17 00:00:00 2001 From: Karthik Kamath Date: Tue, 5 Dec 2017 19:49:59 +0530 Subject: BUG#26881798: SERVER EXITS WHEN PRIMARY KEY IN MYSQL.PROC IS DROPPED ANALYSIS: ========= It is advised not to tamper with the system tables. When primary key is dropped from a system table, certain operations on the table which tries to access the table key information may lead to server exit. FIX: ==== An appropriate error is now reported in such a case. --- sql/event_db_repository.cc | 4 +++- sql/sp.cc | 4 ++-- sql/sql_acl.cc | 4 +++- sql/sql_plugin.cc | 12 +++++++++++- sql/table.cc | 16 ++++++++++++++-- sql/table.h | 5 +++-- 6 files changed, 36 insertions(+), 9 deletions(-) (limited to 'sql') diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc index 74da4d8f587..96d1279573d 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -174,6 +174,8 @@ protected: error_log_print(ERROR_LEVEL, fmt, args); va_end(args); } +public: + Event_db_intact() { has_keys= TRUE; } }; /** In case of an error, a message is printed to the error log. */ diff --git a/sql/sp.cc b/sql/sp.cc index 56a439481f5..82d25880168 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -351,7 +351,7 @@ private: bool m_print_once; public: - Proc_table_intact() : m_print_once(TRUE) {} + Proc_table_intact() : m_print_once(TRUE) { has_keys= TRUE; } protected: void report_error(uint code, const char *fmt, ...); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index b48b8562679..385484f2b01 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -949,6 +949,8 @@ protected: va_end(args); } } +public: + Acl_table_intact() { has_keys= TRUE; } }; #define IP_ADDR_STRLEN (3 + 1 + 3 + 1 + 3 + 1 + 3) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 9ec0390483a..3af9136d37f 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1899,6 +1899,16 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name) if (! (table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT))) DBUG_RETURN(TRUE); + if (!table->key_info) + { + my_printf_error(ER_UNKNOWN_ERROR, + "The table '%s.%s' does not have the necessary key(s) " + "defined on it. Please check the table definition and " + "create index(s) accordingly.", MYF(0), + table->s->db.str, table->s->table_name.str); + DBUG_RETURN(TRUE); + } + /* Pre-acquire audit plugins for events that may potentially occur during [UN]INSTALL PLUGIN. diff --git a/sql/table.cc b/sql/table.cc index 5bc3ccdbf39..46397b794ee 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -3013,7 +3013,7 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def) /* Whether the table definition has already been validated. */ if (table->s->table_field_def_cache == table_def) - DBUG_RETURN(FALSE); + goto end; if (table->s->fields != table_def->count) { @@ -3129,6 +3129,18 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def) if (! error) table->s->table_field_def_cache= table_def; +end: + + if (has_keys && !error && !table->key_info) + { + my_printf_error(ER_UNKNOWN_ERROR, + "The table '%s.%s' does not have the necessary key(s) " + "defined on it. Please check the table definition and " + "create index(s) accordingly.", MYF(0), + table->s->db.str, table->s->table_name.str); + error= TRUE; + } + DBUG_RETURN(error); } diff --git a/sql/table.h b/sql/table.h index ac3533dc5d7..31cd385ef35 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1,7 +1,7 @@ #ifndef TABLE_INCLUDED #define TABLE_INCLUDED -/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -484,10 +484,11 @@ typedef struct st_ha_data_partition class Table_check_intact { protected: + bool has_keys; virtual void report_error(uint code, const char *fmt, ...)= 0; public: - Table_check_intact() {} + Table_check_intact() : has_keys(FALSE) {} virtual ~Table_check_intact() {} /** Checks whether a table is intact. */ -- cgit v1.2.1 From 2af9e8af6efba951e33e148d0b1a34beb25be831 Mon Sep 17 00:00:00 2001 From: Karthik Kamath Date: Thu, 11 Jan 2018 19:48:12 +0530 Subject: BUG#27160888: MISSING FILE PRIVILEDGE CHECKS ON SOME STATEMENTS ANALYSIS: ========= A user not having FILE privilege is not allowed to create custom data/index directories for a table or for its partitions via CREATE TABLE but is allowed to do so via ALTER TABLE statement. ALTER TABLE ignores DATA DIRECTORY and INDEX DIRECTORY when given as table options. The issue occurs during the creation of partitions for a table via ALTER TABLE statement with the DATA DIRECTORY and/or INDEX DIRECTORY options. The issue exists because of the absence of FILE privilege check for the user. FIX: ==== A FILE privilege check has been introduced for resolving the above scenario. --- sql/sql_alter.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc index 6247d581830..660efe2d177 100644 --- a/sql/sql_alter.cc +++ b/sql/sql_alter.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,6 +18,8 @@ // mysql_exchange_partition #include "sql_alter.h" +bool has_external_data_or_index_dir(partition_info &pi); + bool Alter_table_statement::execute(THD *thd) { LEX *lex= thd->lex; @@ -42,6 +44,16 @@ bool Alter_table_statement::execute(THD *thd) if (thd->is_fatal_error) /* out of memory creating a copy of alter_info */ DBUG_RETURN(TRUE); + +#ifdef WITH_PARTITION_STORAGE_ENGINE + { + partition_info *part_info= thd->lex->part_info; + if (part_info != NULL && has_external_data_or_index_dir(*part_info) && + check_access(thd, FILE_ACL, any_db, NULL, NULL, FALSE, FALSE)) + + DBUG_RETURN(TRUE); + } +#endif /* We also require DROP priv for ALTER TABLE ... DROP PARTITION, as well as for RENAME TO, as being done by SQLCOM_RENAME_TABLE -- cgit v1.2.1 From 3fb2f8db179c2ea9a15fcc2f142c5b98c5aab17a Mon Sep 17 00:00:00 2001 From: Joao Gramacho Date: Fri, 2 Feb 2018 11:45:56 +0000 Subject: BUG#24365972 BINLOG DECODING ISN'T RESILIENT TO CORRUPT BINLOG FILES Problem ======= When facing decoding of corrupt binary log files, server may misbehave without detecting the events corruption. This patch makes MySQL server more resilient to binary log decoding. Fixes for events de-serialization and apply =========================================== @sql/log_event.cc Query_log_event::Query_log_event: added a check to ensure query length is respecting event buffer limits. Query_log_event::do_apply_event: extended a debug print, added a check to character set to determine if it is "parseable" or not, verified if database name is valid for system collation. Start_log_event_v3::do_apply_event: report an error on applying a non-supported binary log version. Load_log_event::copy_log_event: added a check to table_name length. User_var_log_event::User_var_log_event: added checks to avoid reading out of buffer limits. User_var_log_event::do_apply_event: reported an sanity check error properly and added individual sanity checks for variable types that expect fixed (or minimum) amount of bytes to be read. Rows_log_event::Rows_log_event: added checks to avoid reading out of buffer limits. @sql/log_event_old.cc Old_rows_log_event::Old_rows_log_event: added a sanity check to avoid reading out of buffer limits. @sql/sql_priv.h Added a sanity check to available_buffer() function. --- sql/log_event.cc | 126 ++++++++++++++++++++++++++++++++++++++++++++++++--- sql/log_event_old.cc | 11 ++++- sql/sql_priv.h | 7 ++- 3 files changed, 136 insertions(+), 8 deletions(-) (limited to 'sql') diff --git a/sql/log_event.cc b/sql/log_event.cc index 5dbeb1eb4b9..ac1e105be8c 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -3024,6 +3024,25 @@ Query_log_event::Query_log_event(const char* buf, uint event_len, db= (char *)start; query= (char *)(start + db_len + 1); q_len= data_len - db_len -1; + + if (data_len && (data_len < db_len || + data_len < q_len || + data_len != (db_len + q_len + 1))) + { + q_len= 0; + query= NULL; + DBUG_VOID_RETURN; + } + + unsigned int max_length; + max_length= (event_len - ((const char*)(end + db_len + 1) - + (buf - common_header_len))); + if (q_len != max_length) + { + q_len= 0; + query= NULL; + DBUG_VOID_RETURN; + } /** Append the db length at the end of the buffer. This will be used by Query_cache::send_result_to_client() in case the query cache is On. @@ -3278,6 +3297,26 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli, you. */ thd->catalog= catalog_len ? (char *) catalog : (char *)""; + + size_t valid_len; + bool len_error; + bool is_invalid_db_name= validate_string(system_charset_info, db, db_len, + &valid_len, &len_error); + + DBUG_PRINT("debug",("is_invalid_db_name= %s, valid_len=%zu, len_error=%s", + is_invalid_db_name ? "true" : "false", + valid_len, + len_error ? "true" : "false")); + + if (is_invalid_db_name || len_error) + { + rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + ER_THD(thd, ER_SLAVE_FATAL_ERROR), + "Invalid database name in Query event."); + thd->is_slave_error= true; + goto end; + } + new_db.length= db_len; new_db.str= (char *) rpl_filter->get_rewrite_db(db, &new_db.length); thd->set_db(new_db.str, new_db.length); /* allocates a copy of 'db' */ @@ -3454,7 +3493,23 @@ int Query_log_event::do_apply_event(Relay_log_info const *rli, } else thd->variables.collation_database= thd->db_charset; - + + { + const CHARSET_INFO *cs= thd->charset(); + /* + We cannot ask for parsing a statement using a character set + without state_maps (parser internal data). + */ + if (!cs->state_map) + { + rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + ER_THD(thd, ER_SLAVE_FATAL_ERROR), + "character_set cannot be parsed"); + thd->is_slave_error= true; + goto end; + } + } + thd->table_map_for_update= (table_map)table_map_for_update; thd->set_invoker(&user, &host); /* @@ -3898,7 +3953,13 @@ int Start_log_event_v3::do_apply_event(Relay_log_info const *rli) */ break; default: - /* this case is impossible */ + /* + This case is not expected. It can be either an event corruption or an + unsupported binary log version. + */ + rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + ER_THD(thd, ER_SLAVE_FATAL_ERROR), + "Binlog version not supported"); DBUG_RETURN(1); } DBUG_RETURN(error); @@ -4724,6 +4785,9 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len, fields = (char*)field_lens + num_fields; table_name = fields + field_block_len; + if (strlen(table_name) > NAME_LEN) + goto err; + db = table_name + table_name_len + 1; DBUG_EXECUTE_IF ("simulate_invalid_address", db_len = data_len;); @@ -5889,6 +5953,13 @@ User_var_log_event(const char* buf, uint event_len, buf+= description_event->common_header_len + description_event->post_header_len[USER_VAR_EVENT-1]; name_len= uint4korr(buf); + /* Avoid reading out of buffer */ + if ((buf - buf_start) + UV_NAME_LEN_SIZE + name_len > event_len) + { + error= true; + goto err; + } + name= (char *) buf + UV_NAME_LEN_SIZE; /* @@ -5948,8 +6019,11 @@ User_var_log_event(const char* buf, uint event_len, we keep the flags set to UNDEF_F. */ uint bytes_read= ((val + val_len) - start); - DBUG_ASSERT(bytes_read==data_written || - bytes_read==(data_written-1)); + if (bytes_read > event_len) + { + error= true; + goto err; + } if ((data_written - bytes_read) > 0) { flags= (uint) *(buf + UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE + @@ -6165,7 +6239,12 @@ int User_var_log_event::do_apply_event(Relay_log_info const *rli) } if (!(charset= get_charset(charset_number, MYF(MY_WME)))) + { + rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + ER_THD(thd, ER_SLAVE_FATAL_ERROR), + "Invalid character set for User var event"); return 1; + } LEX_STRING user_var_name; user_var_name.str= name; user_var_name.length= name_len; @@ -6186,12 +6265,26 @@ int User_var_log_event::do_apply_event(Relay_log_info const *rli) { switch (type) { case REAL_RESULT: + if (val_len != 8) + { + rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + ER_THD(thd, ER_SLAVE_FATAL_ERROR), + "Invalid variable length at User var event"); + return 1; + } float8get(real_val, val); it= new Item_float(real_val, 0); val= (char*) &real_val; // Pointer to value in native format val_len= 8; break; case INT_RESULT: + if (val_len != 8) + { + rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + ER_THD(thd, ER_SLAVE_FATAL_ERROR), + "Invalid variable length at User var event"); + return 1; + } int_val= (longlong) uint8korr(val); it= new Item_int(int_val); val= (char*) &int_val; // Pointer to value in native format @@ -6199,6 +6292,13 @@ int User_var_log_event::do_apply_event(Relay_log_info const *rli) break; case DECIMAL_RESULT: { + if (val_len < 3) + { + rli->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, + ER_THD(thd, ER_SLAVE_FATAL_ERROR), + "Invalid variable length at User var event"); + return 1; + } Item_decimal *dec= new Item_decimal((uchar*) val+2, val[0], val[1]); it= dec; val= (char *)dec->val_decimal(NULL); @@ -7646,6 +7746,15 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len, DBUG_PRINT("debug", ("Reading from %p", ptr_after_width)); m_width = net_field_length(&ptr_after_width); DBUG_PRINT("debug", ("m_width=%lu", m_width)); + /* Avoid reading out of buffer */ + if (static_cast((ptr_after_width + + (m_width + 7) / 8) - + (uchar*)buf) > event_len) + { + m_cols.bitmap= NULL; + DBUG_VOID_RETURN; + } + /* if bitmap_init fails, catched in is_valid() */ if (likely(!bitmap_init(&m_cols, m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL, @@ -7694,7 +7803,12 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len, const uchar* const ptr_rows_data= (const uchar*) ptr_after_width; - size_t const data_size= event_len - (ptr_rows_data - (const uchar *) buf); + size_t const read_size= ptr_rows_data - (const unsigned char *) buf; + if (read_size > event_len) + { + DBUG_VOID_RETURN; + } + size_t const data_size= event_len - read_size; DBUG_PRINT("info",("m_table_id: %lu m_flags: %d m_width: %lu data_size: %lu", m_table_id, m_flags, m_width, (ulong) data_size)); diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index eb9678ddaa5..6be4e086925 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1357,6 +1357,15 @@ Old_rows_log_event::Old_rows_log_event(const char *buf, uint event_len, DBUG_PRINT("debug", ("Reading from %p", ptr_after_width)); m_width = net_field_length(&ptr_after_width); DBUG_PRINT("debug", ("m_width=%lu", m_width)); + /* Avoid reading out of buffer */ + if (static_cast(m_width + + (ptr_after_width - + (const uchar *)buf)) > event_len) + { + m_cols.bitmap= NULL; + DBUG_VOID_RETURN; + } + /* if bitmap_init fails, catched in is_valid() */ if (likely(!bitmap_init(&m_cols, m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL, diff --git a/sql/sql_priv.h b/sql/sql_priv.h index 523220b3c03..b12d22e3fc7 100644 --- a/sql/sql_priv.h +++ b/sql/sql_priv.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -191,6 +191,11 @@ template T available_buffer(const char* buf_start, const char* buf_current, T buf_len) { + /* Sanity check */ + if (buf_current < buf_start || + buf_len < static_cast(buf_current - buf_start)) + return static_cast(0); + return buf_len - (buf_current - buf_start); } -- cgit v1.2.1 From c0b4d74b52e7eec9b13af732193f7f8d7abe05de Mon Sep 17 00:00:00 2001 From: Nisha Gopalakrishnan Date: Mon, 26 Feb 2018 14:37:39 +0530 Subject: BUG#27216817: INNODB: FAILING ASSERTION: PREBUILT->TABLE->N_MYSQL_HANDLES_OPENED == 1 ANALYSIS: ========= Adding unique index to a InnoDB table which is locked as mutliple instances may trigger an InnoDB assert. When we add a primary key or an unique index, we need to drop the original table and rebuild all indexes. InnoDB expects that only the instance of the table that is being rebuilt, is open during the process. In the current scenario we have opened multiple instances of the table. This triggers an assert during table rebuild. 'Locked_tables_list' encapsulates a list of all instances of tables locked by LOCK TABLES statement. FIX: === We are now temporarily closing all the instances of the table except the one which is being altered and later reopen them via Locked_tables_list::reopen_tables(). --- sql/sql_admin.cc | 4 ++-- sql/sql_base.cc | 18 +++++++++++++----- sql/sql_base.h | 5 +++-- sql/sql_partition.cc | 6 +++--- sql/sql_table.cc | 22 ++++++++++++++++++---- sql/sql_trigger.cc | 4 ++-- sql/sql_truncate.cc | 4 ++-- 7 files changed, 43 insertions(+), 20 deletions(-) (limited to 'sql') diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index efdb67d01c4..bfe4edb67c4 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights +/* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify @@ -168,7 +168,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list, */ if (wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN)) goto end; - close_all_tables_for_name(thd, table_list->table->s, FALSE); + close_all_tables_for_name(thd, table_list->table->s, FALSE, NULL); table_list->table= 0; } /* diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 27dcbee7b8f..e9ce652cdb1 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1096,7 +1096,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, result= TRUE; goto err_with_reopen; } - close_all_tables_for_name(thd, table->s, FALSE); + close_all_tables_for_name(thd, table->s, FALSE, NULL); } } @@ -1367,13 +1367,16 @@ static void close_open_tables(THD *thd) In that case the documented behaviour is to implicitly remove the table from LOCK TABLES list. + @param[in] skip_table + TABLE instance that should be kept open. @pre Must be called with an X MDL lock on the table. */ void close_all_tables_for_name(THD *thd, TABLE_SHARE *share, - bool remove_from_locked_tables) + bool remove_from_locked_tables, + TABLE *skip_table) { char key[MAX_DBKEY_LENGTH]; uint key_length= share->table_cache_key.length; @@ -1388,7 +1391,8 @@ close_all_tables_for_name(THD *thd, TABLE_SHARE *share, TABLE *table= *prev; if (table->s->table_cache_key.length == key_length && - !memcmp(table->s->table_cache_key.str, key, key_length)) + !memcmp(table->s->table_cache_key.str, key, key_length) && + table != skip_table) { thd->locked_tables_list.unlink_from_list(thd, table->pos_in_locked_tables, @@ -1401,7 +1405,8 @@ close_all_tables_for_name(THD *thd, TABLE_SHARE *share, mysql_lock_remove(thd, thd->lock, table); /* Inform handler that table will be dropped after close */ - if (table->db_stat) /* Not true for partitioned tables. */ + if (table->db_stat && /* Not true for partitioned tables. */ + skip_table == NULL) table->file->extra(HA_EXTRA_PREPARE_FOR_DROP); close_thread_table(thd, prev); } @@ -1411,9 +1416,12 @@ close_all_tables_for_name(THD *thd, TABLE_SHARE *share, prev= &table->next; } } + + if (skip_table == NULL) { /* Remove the table share from the cache. */ tdc_remove_table(thd, TDC_RT_REMOVE_ALL, db, table_name, FALSE); + } } diff --git a/sql/sql_base.h b/sql/sql_base.h index b118c93ac28..28568acc081 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -306,7 +306,8 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool wait_for_refresh, ulong timeout); bool close_cached_connection_tables(THD *thd, LEX_STRING *connect_string); void close_all_tables_for_name(THD *thd, TABLE_SHARE *share, - bool remove_from_locked_tables); + bool remove_from_locked_tables, + TABLE *skip_table); OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild); void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type, const char *db, const char *table_name, diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 65d4da0f2f6..bd76a92dc68 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -6512,7 +6512,7 @@ static void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt) THD *thd= lpt->thd; if (lpt->old_table) - close_all_tables_for_name(thd, lpt->old_table->s, FALSE); + close_all_tables_for_name(thd, lpt->old_table->s, FALSE, NULL); if (lpt->table) { /* @@ -6549,7 +6549,7 @@ static int alter_close_tables(ALTER_PARTITION_PARAM_TYPE *lpt, bool close_old) } if (close_old && lpt->old_table) { - close_all_tables_for_name(lpt->thd, lpt->old_table->s, FALSE); + close_all_tables_for_name(lpt->thd, lpt->old_table->s, FALSE, NULL); lpt->old_table= 0; } DBUG_RETURN(0); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 58bcf5ca1d4..6d02140cfcb 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2165,7 +2165,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, error= -1; goto err; } - close_all_tables_for_name(thd, table->table->s, TRUE); + close_all_tables_for_name(thd, table->table->s, TRUE, NULL); table->table= 0; } @@ -6168,7 +6168,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, */ if (wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN)) goto err; - close_all_tables_for_name(thd, table->s, TRUE); + close_all_tables_for_name(thd, table->s, TRUE, NULL); /* Then, we want check once again that target table does not exist. Actually the order of these two steps does not matter since @@ -6305,6 +6305,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, changes only" means also that the handler for the table does not change. The table is open and locked. The handler can be accessed. */ + if (need_copy_table == ALTER_TABLE_INDEX_CHANGED) { int pk_changed= 0; @@ -6606,6 +6607,19 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, thd->count_cuted_fields= CHECK_FIELD_WARN; // calc cuted fields thd->cuted_fields=0L; copied=deleted=0; + + if (thd->locked_tables_mode == LTM_LOCK_TABLES || + thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES) + { + /* + Temporarily close the TABLE instances belonging to this + thread except the one to be used for ALTER TABLE. + + This is mostly needed to satisfy InnoDB assumptions/asserts. + */ + close_all_tables_for_name(thd, table->s, false, table); + } + /* We do not copy data for MERGE tables. Only the children have data. MERGE tables have HA_NO_COPY_ON_ALTER set. @@ -6877,7 +6891,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, } close_all_tables_for_name(thd, table->s, - new_name != table_name || new_db != db); + new_name != table_name || new_db != db, NULL); error=0; table_list->table= table= 0; /* Safety */ diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 0a4f549a052..fe1131c4164 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -568,7 +568,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) if (result) goto end; - close_all_tables_for_name(thd, table->s, FALSE); + close_all_tables_for_name(thd, table->s, FALSE, NULL); /* Reopen the table if we were under LOCK TABLES. Ignore the return value for now. It's better to diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index 4f250e6e7a0..d8a0205a495 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -394,7 +394,7 @@ bool Truncate_statement::lock_table(THD *thd, TABLE_LIST *table_ref, m_ticket_downgrade= table->mdl_ticket; /* Close if table is going to be recreated. */ if (*hton_can_recreate) - close_all_tables_for_name(thd, table->s, FALSE); + close_all_tables_for_name(thd, table->s, FALSE, NULL); } else { -- cgit v1.2.1 From 6beb08c7b67ed7610e95c0350f9f93005db1e055 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 4 Apr 2018 09:12:14 +0400 Subject: MDEV-15624 Changing the default character set to utf8mb4 changes query evaluation in a very surprising way --- sql/item_func.h | 2 ++ sql/item_strfunc.h | 1 + 2 files changed, 3 insertions(+) (limited to 'sql') diff --git a/sql/item_func.h b/sql/item_func.h index 60122f03e0b..57818228b98 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -2133,6 +2133,8 @@ public: Item_func_uuid_short() :Item_int_func() {} const char *func_name() const { return "uuid_short"; } longlong val_int(); + bool const_item() const { return false; } + table_map used_tables() const { return RAND_TABLE_BIT; } void fix_length_and_dec() { max_length= 21; unsigned_flag=1; } bool check_vcol_func_processor(uchar *int_arg) diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 006b1b90081..c1138c2a930 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -997,6 +997,7 @@ public: DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); fix_char_length(MY_UUID_STRING_LENGTH); } + bool const_item() const { return false; } table_map used_tables() const { return RAND_TABLE_BIT; } const char *func_name() const{ return "uuid"; } String *val_str(String *); -- cgit v1.2.1 From d6f3a0064be73cd134fd474e5ddc63646e09938a Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Sat, 7 Apr 2018 21:51:15 +0400 Subject: MDEV-14185 CREATE TEMPORARY TABLE AS SELECT causes error 1290 with read_only and InnoDB. handler::ha_create_handler_files shouldn't call the mark_trx_read_write() for the temporary table. --- sql/handler.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/handler.cc b/sql/handler.cc index dc40e34bc3d..d8a9ac6b05a 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3770,7 +3770,8 @@ int handler::ha_create_handler_files(const char *name, const char *old_name, int action_flag, HA_CREATE_INFO *info) { - mark_trx_read_write(); + if (!info || !(info->options & HA_LEX_CREATE_TMP_TABLE)) + mark_trx_read_write(); return create_handler_files(name, old_name, action_flag, info); } -- cgit v1.2.1 From 3eb2a265eac53050089bc5d563e65161717a2983 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Sun, 8 Apr 2018 09:05:00 +0400 Subject: MDEV-14185 CREATE TEMPORARY TABLE AS SELECT causes error 1290 with read_only and InnoDB. condition fixed. --- sql/handler.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/handler.cc b/sql/handler.cc index d8a9ac6b05a..ab4d9fd37c9 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3770,7 +3770,7 @@ int handler::ha_create_handler_files(const char *name, const char *old_name, int action_flag, HA_CREATE_INFO *info) { - if (!info || !(info->options & HA_LEX_CREATE_TMP_TABLE)) + if (!opt_readonly || !info || !(info->options & HA_LEX_CREATE_TMP_TABLE)) mark_trx_read_write(); return create_handler_files(name, old_name, action_flag, info); -- cgit v1.2.1 From 5e61e1716e763315009318081fba5994b8910242 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Mon, 16 Apr 2018 16:59:19 -0700 Subject: MDEV-14515 ifnull result depends on number of rows in joined table Any expensive WHERE condition for a table-less query with implicit aggregation was lost. As a result the used aggregate functions were calculated over a non-empty set of rows even in the case when the condition was false. --- sql/opt_subselect.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'sql') diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index c21541c4b97..1bda84bacd7 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -5903,5 +5903,6 @@ bool JOIN::choose_tableless_subquery_plan() tmp_having= having; } } + exec_const_cond= conds; return FALSE; } -- cgit v1.2.1 From 4f5dd1d40eca3cd128023a9bf636e83489430c78 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 17 Apr 2018 00:44:46 +0200 Subject: ASAN error in main.statistics_index_crash-7362 one cannot do keyread on spatial indexes. --- sql/sql_statistics.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 6c42efd6068..ce320e87a4f 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -2475,7 +2475,7 @@ int collect_statistics_for_index(THD *thd, TABLE *table, uint index) DBUG_ENTER("collect_statistics_for_index"); /* No statistics for FULLTEXT indexes. */ - if (key_info->flags & HA_FULLTEXT) + if (key_info->flags & (HA_FULLTEXT|HA_SPATIAL)) DBUG_RETURN(rc); Index_prefix_calc index_prefix_calc(table, key_info); -- cgit v1.2.1 From bcb36ee21e2515d17dcf03b760487e64eb780f2b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 20 Apr 2018 10:10:33 +0200 Subject: MDEV-15456 Server crashes upon adding or dropping a partition in ALTER under LOCK TABLE after ER_SAME_NAME_PARTITION ALTER TABLE ... ADD PARTITION modifies the open TABLE structure, and sets table->need_reopen=1 to reset these modifications in case of an error. But under LOCK TABLES the table isn't get reopened, despite need_reopen. Fixed by reopening need_reopen tables under LOCK TABLE. --- sql/sql_admin.cc | 2 +- sql/sql_base.cc | 23 +++++++++++++++++++---- sql/sql_class.h | 2 +- sql/sql_partition.cc | 4 ++-- sql/sql_partition_admin.cc | 2 +- sql/sql_table.cc | 8 ++++---- sql/sql_trigger.cc | 2 +- sql/sql_truncate.cc | 2 +- 8 files changed, 30 insertions(+), 15 deletions(-) (limited to 'sql') diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 3aac41d6e41..6ba6f8a912e 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -238,7 +238,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list, if (thd->locked_tables_list.locked_tables()) { - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) goto end; /* Restore the table in the table list with the new opened table */ table_list->table= pos_in_locked_tables->table; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 964f82e7331..7d27e87180c 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -568,7 +568,7 @@ err_with_reopen: old locks. This should always succeed (unless some external process has removed the tables) */ - thd->locked_tables_list.reopen_tables(thd); + thd->locked_tables_list.reopen_tables(thd, false); /* Since downgrade_lock() won't do anything with shared metadata lock it is much simpler to go through all open tables rather @@ -952,7 +952,10 @@ void close_thread_tables(THD *thd) we will exit this function a few lines below. */ if (! thd->lex->requires_prelocking()) + { + thd->locked_tables_list.reopen_tables(thd, true); DBUG_VOID_RETURN; + } /* We are in the top-level statement of a prelocked statement, @@ -2973,7 +2976,7 @@ unlink_all_closed_tables(THD *thd, MYSQL_LOCK *lock, size_t reopen_count) */ bool -Locked_tables_list::reopen_tables(THD *thd) +Locked_tables_list::reopen_tables(THD *thd, bool need_reopen) { Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN); size_t reopen_count= 0; @@ -2984,8 +2987,20 @@ Locked_tables_list::reopen_tables(THD *thd) for (TABLE_LIST *table_list= m_locked_tables; table_list; table_list= table_list->next_global) { - if (table_list->table) /* The table was not closed */ - continue; + if (need_reopen) + { + if (!table_list->table || !table_list->table->needs_reopen()) + continue; + /* no need to remove the table from the TDC here, thus (TABLE*)1 */ + close_all_tables_for_name(thd, table_list->table->s, + HA_EXTRA_NOT_USED, (TABLE*)1); + DBUG_ASSERT(table_list->table == NULL); + } + else + { + if (table_list->table) /* The table was not closed */ + continue; + } /* Links into thd->open_tables upon success */ if (open_table(thd, table_list, thd->mem_root, &ot_ctx)) diff --git a/sql/sql_class.h b/sql/sql_class.h index 518e88fcd1c..ec94f6c45d2 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1603,7 +1603,7 @@ public: void unlink_all_closed_tables(THD *thd, MYSQL_LOCK *lock, size_t reopen_count); - bool reopen_tables(THD *thd); + bool reopen_tables(THD *thd, bool need_reopen); bool restore_lock(THD *thd, TABLE_LIST *dst_table_list, TABLE *table, MYSQL_LOCK *lock); void add_back_last_deleted_lock(TABLE_LIST *dst_table_list); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 1c270521a12..fa7e68305d8 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -6558,7 +6558,7 @@ static void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt) thd->set_stmt_da(&tmp_stmt_da); } - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) sql_print_warning("We failed to reacquire LOCKs in ALTER TABLE"); if (stmt_da) @@ -6762,7 +6762,7 @@ err_exclusive_lock: thd->set_stmt_da(&tmp_stmt_da); } - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) sql_print_warning("We failed to reacquire LOCKs in ALTER TABLE"); if (stmt_da) diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index 9b471f97521..39b7f4c49f6 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -630,7 +630,7 @@ bool Sql_cmd_alter_table_exchange_partition:: better to keep master/slave in consistent state. Alternative would be to try to revert the exchange operation and issue error. */ - (void) thd->locked_tables_list.reopen_tables(thd); + (void) thd->locked_tables_list.reopen_tables(thd, false); if ((error= write_bin_log(thd, TRUE, thd->query(), thd->query_length()))) { diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 607f20d2396..5e6385d3bc5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5059,7 +5059,7 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, This should always work as we have a meta lock on the table. */ thd->locked_tables_list.add_back_last_deleted_lock(pos_in_locked_tables); - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) { thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); result= 1; @@ -5408,7 +5408,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, This should always work as we have a meta lock on the table. */ thd->locked_tables_list.add_back_last_deleted_lock(pos_in_locked_tables); - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) { thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); res= 1; // We got an error @@ -7239,7 +7239,7 @@ static bool mysql_inplace_alter_table(THD *thd, HA_EXTRA_PREPARE_FOR_RENAME : HA_EXTRA_NOT_USED, NULL); - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); /* QQ; do something about metadata locks ? */ } @@ -9224,7 +9224,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, end_inplace: - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) goto err_with_mdl_after_alter; THD_STAGE_INFO(thd, stage_end); diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index b17775abb7c..d26afdefcf9 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -574,7 +574,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) Ignore the return value for now. It's better to keep master/slave in consistent state. */ - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) thd->clear_error(); /* diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index 05869b70c8f..ff373f2f29a 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -494,7 +494,7 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref) */ error= dd_recreate_table(thd, table_ref->db, table_ref->table_name); - if (thd->locked_tables_mode && thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_mode && thd->locked_tables_list.reopen_tables(thd, false)) thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); /* No need to binlog a failed truncate-by-recreate. */ -- cgit v1.2.1 From f2433b8dd3c10b1e26a6f0b98dfbaa45b22fe0af Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 21 Apr 2018 13:13:19 +0200 Subject: MDEV-10824 - Crash in CREATE OR REPLACE TABLE t1 AS SELECT spfunc() followup for a3c980b381ea same change in Locked_tables_list::unlink_from_list(), otherwise thd->locked_tables_list will keep pointers to a free'd TABLE if prelocked under lock tables. This fixes a crash in main.create_or_replace on debug Win builds after bcb36ee21e25 --- sql/sql_base.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 7d27e87180c..f7de4e4f3c2 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2872,7 +2872,8 @@ void Locked_tables_list::unlink_from_list(THD *thd, If mode is not LTM_LOCK_TABLES, we needn't do anything. Moreover, outside this mode pos_in_locked_tables value is not trustworthy. */ - if (thd->locked_tables_mode != LTM_LOCK_TABLES) + if (thd->locked_tables_mode != LTM_LOCK_TABLES && + thd->locked_tables_mode != LTM_PRELOCKED_UNDER_LOCK_TABLES) return; /* -- cgit v1.2.1 From 39a4985520ebeb8c77d657e4624359a484ad330f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 24 Apr 2018 12:14:35 +0300 Subject: Remove most 'register' use in C++ Modern compilers (such as GCC 8) emit warnings that the 'register' keyword is deprecated and not valid C++17. Let us remove most use of the 'register' keyword. Code in 'extra/' is not touched. --- sql/field.h | 2 +- sql/filesort.cc | 9 ++++----- sql/gen_lex_hash.cc | 30 +++++++++++++++--------------- sql/handler.cc | 2 +- sql/item_cmpfunc.cc | 12 ++++++------ sql/item_func.cc | 4 ++-- sql/item_strfunc.cc | 14 +++++++------- sql/key.cc | 2 +- sql/log.cc | 3 +-- sql/mf_iocache.cc | 3 +-- sql/password.c | 4 ++-- sql/plistsort.c | 10 +++++----- sql/slave.cc | 2 +- sql/sql_db.cc | 2 +- sql/sql_insert.cc | 8 ++++---- sql/sql_parse.cc | 2 +- sql/sql_select.cc | 2 +- sql/sql_string.cc | 12 ++++++------ sql/table.cc | 4 ++-- sql/uniques.cc | 2 +- sql/uniques.h | 2 +- 21 files changed, 64 insertions(+), 67 deletions(-) (limited to 'sql') diff --git a/sql/field.h b/sql/field.h index b2ef3839846..7074a636ff9 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1504,7 +1504,7 @@ public: /* Mark field in read map. Updates also virtual fields */ void register_field_in_read_map(); - friend int cre_myisam(char * name, register TABLE *form, uint options, + friend int cre_myisam(char * name, TABLE *form, uint options, ulonglong auto_increment_value); friend class Copy_field; friend class Item_avg_field; diff --git a/sql/filesort.cc b/sql/filesort.cc index d6bdebee3d3..db52debe957 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -1165,8 +1165,7 @@ Type_handler_real_result::make_sort_key(uchar *to, Item *item, /** Make a sort-key from record. */ -static void make_sortkey(register Sort_param *param, - register uchar *to, uchar *ref_pos) +static void make_sortkey(Sort_param *param, uchar *to, uchar *ref_pos) { reg3 Field *field; reg1 SORT_FIELD *sort_field; @@ -1458,7 +1457,7 @@ bool check_if_pq_applicable(Sort_param *param, int merge_many_buff(Sort_param *param, uchar *sort_buffer, BUFFPEK *buffpek, uint *maxbuffer, IO_CACHE *t_file) { - register uint i; + uint i; IO_CACHE t_file2,*from_file,*to_file,*temp; BUFFPEK *lastbuff; DBUG_ENTER("merge_many_buff"); @@ -1513,7 +1512,7 @@ cleanup: uint read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek, uint rec_length) { - register uint count; + uint count; uint length; if ((count=(uint) MY_MIN((ha_rows) buffpek->max_keys,buffpek->count))) @@ -1817,7 +1816,7 @@ int merge_buffers(Sort_param *param, IO_CACHE *from_file, } else { - register uchar *end; + uchar *end; src= buffpek->key+offset; for (end= src+buffpek->mem_count*rec_length ; src != end ; diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 3a3273d279b..05ac7e4fa42 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -403,8 +403,8 @@ int main(int argc,char **argv) static SYMBOL *get_hash_symbol(const char *s,\n\ unsigned int len,bool function)\n\ {\n\ - register uchar *hash_map;\n\ - register const char *cur_str= s;\n\ + uchar *hash_map;\n\ + const char *cur_str= s;\n\ \n\ if (len == 0) {\n\ DBUG_PRINT(\"warning\", (\"get_hash_symbol() received a request for a zero-length symbol, which is probably a mistake.\"));\ @@ -416,25 +416,25 @@ static SYMBOL *get_hash_symbol(const char *s,\n\ if (function){\n\ if (len>sql_functions_max_len) return 0;\n\ hash_map= sql_functions_map;\n\ - register uint32 cur_struct= uint4korr(hash_map+((len-1)*4));\n\ + uint32 cur_struct= uint4korr(hash_map+((len-1)*4));\n\ \n\ for (;;){\n\ - register uchar first_char= (uchar)cur_struct;\n\ + uchar first_char= (uchar)cur_struct;\n\ \n\ if (first_char == 0)\n\ {\n\ - register int16 ires= (int16)(cur_struct>>16);\n\ + int16 ires= (int16)(cur_struct>>16);\n\ if (ires==array_elements(symbols)) return 0;\n\ - register SYMBOL *res;\n\ + SYMBOL *res;\n\ if (ires>=0) \n\ res= symbols+ires;\n\ else\n\ res= sql_functions-ires-1;\n\ - register uint count= (uint) (cur_str - s);\n\ + uint count= (uint) (cur_str - s);\n\ return lex_casecmp(cur_str,res->name+count,len-count) ? 0 : res;\n\ }\n\ \n\ - register uchar cur_char= (uchar)to_upper_lex[(uchar)*cur_str];\n\ + uchar cur_char= (uchar)to_upper_lex[(uchar)*cur_str];\n\ if (cur_char>=8;\n\ if (cur_char>(uchar)cur_struct) return 0;\n\ @@ -450,20 +450,20 @@ static SYMBOL *get_hash_symbol(const char *s,\n\ }else{\n\ if (len>symbols_max_len) return 0;\n\ hash_map= symbols_map;\n\ - register uint32 cur_struct= uint4korr(hash_map+((len-1)*4));\n\ + uint32 cur_struct= uint4korr(hash_map+((len-1)*4));\n\ \n\ for (;;){\n\ - register uchar first_char= (uchar)cur_struct;\n\ + uchar first_char= (uchar)cur_struct;\n\ \n\ - if (first_char==0){\n\ - register int16 ires= (int16)(cur_struct>>16);\n\ + if (first_char==0) {\n\ + int16 ires= (int16)(cur_struct>>16);\n\ if (ires==array_elements(symbols)) return 0;\n\ - register SYMBOL *res= symbols+ires;\n\ - register uint count= (uint) (cur_str - s);\n\ + SYMBOL *res= symbols+ires;\n\ + uint count= (uint) (cur_str - s);\n\ return lex_casecmp(cur_str,res->name+count,len-count)!=0 ? 0 : res;\n\ }\n\ \n\ - register uchar cur_char= (uchar)to_upper_lex[(uchar)*cur_str];\n\ + uchar cur_char= (uchar)to_upper_lex[(uchar)*cur_str];\n\ if (cur_char>=8;\n\ if (cur_char>(uchar)cur_struct) return 0;\n\ diff --git a/sql/handler.cc b/sql/handler.cc index cd2ad06bb70..06c407b572a 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2798,7 +2798,7 @@ int handler::ha_rnd_init_with_error(bool scan) */ int handler::read_first_row(uchar * buf, uint primary_key) { - register int error; + int error; DBUG_ENTER("handler::read_first_row"); /* diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index bb71a11c986..44cc4f3cae9 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -5810,8 +5810,8 @@ void Item_func_like::turboBM_compute_bad_character_shifts() bool Item_func_like::turboBM_matches(const char* text, int text_len) const { - register int bcShift; - register int turboShift; + int bcShift; + int turboShift; int shift = pattern_len; int j = 0; int u = 0; @@ -5825,7 +5825,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const { while (j <= tlmpl) { - register int i= plm1; + int i= plm1; while (i >= 0 && pattern[i] == text[i + j]) { i--; @@ -5835,7 +5835,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const if (i < 0) return 1; - register const int v = plm1 - i; + const int v= plm1 - i; turboShift = u - v; bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i; shift = MY_MAX(turboShift, bcShift); @@ -5856,7 +5856,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const { while (j <= tlmpl) { - register int i = plm1; + int i= plm1; while (i >= 0 && likeconv(cs,pattern[i]) == likeconv(cs,text[i + j])) { i--; @@ -5866,7 +5866,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const if (i < 0) return 1; - register const int v = plm1 - i; + const int v= plm1 - i; turboShift = u - v; bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i; shift = MY_MAX(turboShift, bcShift); diff --git a/sql/item_func.cc b/sql/item_func.cc index f54e79a9f2d..0c239b54f30 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3244,8 +3244,8 @@ longlong Item_func_ord::val_int() #ifdef USE_MB if (use_mb(res->charset())) { - register const char *str=res->ptr(); - register uint32 n=0, l=my_ismbchar(res->charset(),str,str+res->length()); + const char *str=res->ptr(); + uint32 n=0, l=my_ismbchar(res->charset(),str,str+res->length()); if (!l) return (longlong)((uchar) *str); while (l--) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 7d7614171b5..3d543c8c390 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1038,7 +1038,7 @@ String *Item_func_reverse::val_str(String *str) #ifdef USE_MB if (use_mb(res->charset())) { - register uint32 l; + uint32 l; while (ptr < end) { if ((l= my_ismbchar(res->charset(),ptr,end))) @@ -1087,7 +1087,7 @@ String *Item_func_replace::val_str(String *str) bool alloced=0; #ifdef USE_MB const char *ptr,*end,*strend,*search,*search_end; - register uint32 l; + uint32 l; bool binary_cmp; #endif THD *thd= 0; @@ -1140,7 +1140,7 @@ redo: { if (*ptr == *search) { - register char *i,*j; + char *i,*j; i=(char*) ptr+1; j=(char*) search+1; while (j != search_end) if (*i++ != *j++) goto skip; @@ -1748,14 +1748,14 @@ String *Item_func_substr_index::val_str(String *str) const char *search= delimiter->ptr(); const char *search_end= search+delimiter_length; int32 n=0,c=count,pass; - register uint32 l; + uint32 l; for (pass=(count>0);pass<2;++pass) { while (ptr < end) { if (*ptr == *search) { - register char *i,*j; + char *i,*j; i=(char*) ptr+1; j=(char*) search+1; while (j != search_end) if (*i++ != *j++) goto skip; @@ -1923,7 +1923,7 @@ String *Item_func_rtrim::val_str(String *str) end= ptr+res->length(); #ifdef USE_MB char *p=ptr; - register uint32 l; + uint32 l; #endif if (remove_length == 1) { @@ -2008,7 +2008,7 @@ String *Item_func_trim::val_str(String *str) if (use_mb(collation.collation)) { char *p=ptr; - register uint32 l; + uint32 l; loop: while (ptr + remove_length < end) { diff --git a/sql/key.cc b/sql/key.cc index 4453a97dee4..4abba249af1 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -497,7 +497,7 @@ int key_cmp(KEY_PART_INFO *key_part, const uchar *key, uint key_length) if (key_part->null_bit) { /* This key part allows null values; NULL is lower than everything */ - register bool field_is_null= key_part->field->is_null(); + bool field_is_null= key_part->field->is_null(); if (*key) // If range key is null { /* the range is expecting a null value */ diff --git a/sql/log.cc b/sql/log.cc index 7241aa68fec..a480db7d79d 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -8480,8 +8480,7 @@ void MYSQL_BIN_LOG::set_max_size(ulong max_size_arg) 0 String is not a number */ -static bool test_if_number(register const char *str, - ulong *res, bool allow_wildcards) +static bool test_if_number(const char *str, ulong *res, bool allow_wildcards) { reg2 int flag; const char *start; diff --git a/sql/mf_iocache.cc b/sql/mf_iocache.cc index 6535f16445b..8337c93fe70 100644 --- a/sql/mf_iocache.cc +++ b/sql/mf_iocache.cc @@ -49,8 +49,7 @@ extern "C" { */ -int _my_b_net_read(register IO_CACHE *info, uchar *Buffer, - size_t Count __attribute__((unused))) +int _my_b_net_read(IO_CACHE *info, uchar *Buffer, size_t) { ulong read_length; NET *net= &(current_thd)->net; diff --git a/sql/password.c b/sql/password.c index 1f0a55a10fe..debdf598189 100644 --- a/sql/password.c +++ b/sql/password.c @@ -90,7 +90,7 @@ void hash_password(ulong *result, const char *password, uint password_len) { - register ulong nr=1345345333L, add=7, nr2=0x12345671L; + ulong nr=1345345333L, add=7, nr2=0x12345671L; ulong tmp; const char *password_end= password + password_len; for (; password < password_end; password++) @@ -325,7 +325,7 @@ hex2octet(uint8 *to, const char *str, uint len) const char *str_end= str + len; while (str < str_end) { - register char tmp= char_val(*str++); + char tmp= char_val(*str++); *to++= (tmp << 4) | char_val(*str++); } } diff --git a/sql/plistsort.c b/sql/plistsort.c index 99657410fe0..e66bd7c7276 100644 --- a/sql/plistsort.c +++ b/sql/plistsort.c @@ -91,7 +91,7 @@ recursion_point: } { - register struct LS_STRUCT_NAME *sp0= sp++; + struct LS_STRUCT_NAME *sp0= sp++; sp->list_len= sp0->list_len >> 1; sp0->list_len-= sp->list_len; sp->return_point= 0; @@ -100,7 +100,7 @@ recursion_point: return_point0: sp->list1= sorted_list; { - register struct LS_STRUCT_NAME *sp0= sp++; + struct LS_STRUCT_NAME *sp0= sp++; list= list_end; sp->list_len= sp0->list_len; sp->return_point= 1; @@ -108,9 +108,9 @@ return_point0: goto recursion_point; return_point1: { - register LS_LIST_ITEM **hook= &sorted_list; - register LS_LIST_ITEM *list1= sp->list1; - register LS_LIST_ITEM *list2= sorted_list; + LS_LIST_ITEM **hook= &sorted_list; + LS_LIST_ITEM *list1= sp->list1; + LS_LIST_ITEM *list2= sorted_list; if (LS_COMPARE_FUNC_CALL(list1, list2)) { diff --git a/sql/slave.cc b/sql/slave.cc index 9c6e8ebc200..b90fd47af83 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -218,7 +218,7 @@ static void set_slave_max_allowed_packet(THD *thd, MYSQL *mysql) void init_thread_mask(int* mask,Master_info* mi,bool inverse) { bool set_io = mi->slave_running, set_sql = mi->rli.slave_running; - register int tmp_mask=0; + int tmp_mask=0; DBUG_ENTER("init_thread_mask"); if (set_io) diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 073e351d895..e3f0506e65a 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -338,7 +338,7 @@ static void del_dbopt(const char *path) static bool write_db_opt(THD *thd, const char *path, Schema_specification_st *create) { - register File file; + File file; char buf[256]; // Should be enough for one option bool error=1; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 682f4b07ffa..f9843dd6418 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -89,7 +89,7 @@ static int write_delayed(THD *thd, TABLE *table, enum_duplicates duplic, LEX_STRING query, bool ignore, bool log_on); static void end_delayed_insert(THD *thd); pthread_handler_t handle_delayed_insert(void *arg); -static void unlink_blobs(register TABLE *table); +static void unlink_blobs(TABLE *table); #endif static bool check_view_insertability(THD *thd, TABLE_LIST *view); @@ -3103,7 +3103,7 @@ pthread_handler_t handle_delayed_insert(void *arg) /* Remove all pointers to data for blob fields so that original table doesn't try to free them */ -static void unlink_blobs(register TABLE *table) +static void unlink_blobs(TABLE *table) { for (Field **ptr=table->field ; *ptr ; ptr++) { @@ -3114,7 +3114,7 @@ static void unlink_blobs(register TABLE *table) /* Free blobs stored in current row */ -static void free_delayed_insert_blobs(register TABLE *table) +static void free_delayed_insert_blobs(TABLE *table) { for (Field **ptr=table->field ; *ptr ; ptr++) { @@ -3126,7 +3126,7 @@ static void free_delayed_insert_blobs(register TABLE *table) /* set value field for blobs to point to data in record */ -static void set_delayed_insert_blobs(register TABLE *table) +static void set_delayed_insert_blobs(TABLE *table) { for (Field **ptr=table->field ; *ptr ; ptr++) { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 886a16f803b..bc74cf358e2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -8066,7 +8066,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, List *partition_names, LEX_STRING *option) { - register TABLE_LIST *ptr; + TABLE_LIST *ptr; TABLE_LIST *UNINIT_VAR(previous_table_ref); /* The table preceding the current one. */ char *alias_str; LEX *lex= thd->lex; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6450eb03d4d..57c82a2d7dc 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -345,7 +345,7 @@ bool handle_select(THD *thd, LEX *lex, select_result *result, ulong setup_tables_done_option) { bool res; - register SELECT_LEX *select_lex = &lex->select_lex; + SELECT_LEX *select_lex = &lex->select_lex; DBUG_ENTER("handle_select"); MYSQL_SELECT_START(thd->query()); diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 9808c081a54..64661f46a49 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -613,8 +613,8 @@ int String::strstr(const String &s,uint32 offset) if (!s.length()) return ((int) offset); // Empty string is always found - register const char *str = Ptr+offset; - register const char *search=s.ptr(); + const char *str = Ptr+offset; + const char *search=s.ptr(); const char *end=Ptr+str_length-s.length()+1; const char *search_end=s.ptr()+s.length(); skip: @@ -622,7 +622,7 @@ skip: { if (*str++ == *search) { - register char *i,*j; + char *i,*j; i=(char*) str; j=(char*) search+1; while (j != search_end) if (*i++ != *j++) goto skip; @@ -643,8 +643,8 @@ int String::strrstr(const String &s,uint32 offset) { if (!s.length()) return offset; // Empty string is always found - register const char *str = Ptr+offset-1; - register const char *search=s.ptr()+s.length()-1; + const char *str = Ptr+offset-1; + const char *search=s.ptr()+s.length()-1; const char *end=Ptr+s.length()-2; const char *search_end=s.ptr()-1; @@ -653,7 +653,7 @@ skip: { if (*str-- == *search) { - register char *i,*j; + char *i,*j; i=(char*) str; j=(char*) search-1; while (j != search_end) if (*i-- != *j--) goto skip; diff --git a/sql/table.cc b/sql/table.cc index 18bc4bf17bc..4e9aa5caff2 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3409,7 +3409,7 @@ partititon_err: table TABLE object to free */ -int closefrm(register TABLE *table) +int closefrm(TABLE *table) { int error=0; DBUG_ENTER("closefrm"); @@ -3446,7 +3446,7 @@ int closefrm(register TABLE *table) /* Deallocate temporary blob storage */ -void free_blobs(register TABLE *table) +void free_blobs(TABLE *table) { uint *ptr, *end; for (ptr= table->s->blob_field, end=ptr + table->s->blob_fields ; diff --git a/sql/uniques.cc b/sql/uniques.cc index 7def2d79ad7..86622b41351 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -209,7 +209,7 @@ static double get_merge_many_buffs_cost(uint *buffer, uint last_n_elems, int elem_size, uint compare_factor) { - register int i; + int i; double total_cost= 0.0; uint *buff_elems= buffer; /* #s of elements in each of merged sequences */ diff --git a/sql/uniques.h b/sql/uniques.h index efc79953bb6..654b3692aaa 100644 --- a/sql/uniques.h +++ b/sql/uniques.h @@ -77,7 +77,7 @@ public: inline static int get_cost_calc_buff_size(size_t nkeys, uint key_size, size_t max_in_memory_size) { - register size_t max_elems_in_tree= + size_t max_elems_in_tree= max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+key_size); return (int) (sizeof(uint)*(1 + nkeys/max_elems_in_tree)); } -- cgit v1.2.1 From 7b2bdd898450dbade97d803bb07a8846ad533d07 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Wed, 27 Dec 2017 16:03:16 +0300 Subject: register keyword c++17 warning --- sql/field.cc | 2 +- sql/filesort.cc | 8 ++++---- sql/key.cc | 4 ++-- sql/lock.cc | 4 ++-- sql/log.cc | 4 ++-- sql/records.cc | 2 +- sql/sql_acl.cc | 2 +- sql/sql_base.cc | 2 +- sql/sql_lex.cc | 6 +++--- sql/sql_prepare.cc | 2 +- 10 files changed, 18 insertions(+), 18 deletions(-) (limited to 'sql') diff --git a/sql/field.cc b/sql/field.cc index 60df918bd63..a8d82170d52 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2797,7 +2797,7 @@ int Field_decimal::store(double nr) return 1; } - reg4 uint i; + uint i; size_t length; uchar fyllchar,*to; char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; diff --git a/sql/filesort.cc b/sql/filesort.cc index db52debe957..2bab4390309 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -1167,9 +1167,9 @@ Type_handler_real_result::make_sort_key(uchar *to, Item *item, static void make_sortkey(Sort_param *param, uchar *to, uchar *ref_pos) { - reg3 Field *field; - reg1 SORT_FIELD *sort_field; - reg5 uint length; + Field *field; + SORT_FIELD *sort_field; + uint length; for (sort_field=param->local_sortorder ; sort_field != param->end ; @@ -1258,7 +1258,7 @@ static void make_sortkey(Sort_param *param, uchar *to, uchar *ref_pos) static void register_used_fields(Sort_param *param) { - reg1 SORT_FIELD *sort_field; + SORT_FIELD *sort_field; TABLE *table=param->sort_form; for (sort_field= param->local_sortorder ; diff --git a/sql/key.cc b/sql/key.cc index 4abba249af1..08bd6e8f65d 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -52,8 +52,8 @@ int find_ref_key(KEY *key, uint key_count, uchar *record, Field *field, uint *key_length, uint *keypart) { - reg2 int i; - reg3 KEY *key_info; + int i; + KEY *key_info; uint fieldpos; fieldpos= field->offset(record); diff --git a/sql/lock.cc b/sql/lock.cc index 79ce27b9937..85a32b54081 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -378,7 +378,7 @@ end: static int lock_external(THD *thd, TABLE **tables, uint count) { - reg1 uint i; + uint i; int lock_type,error; DBUG_ENTER("lock_external"); @@ -530,7 +530,7 @@ void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table) { if (locked) { - reg1 uint i; + uint i; for (i=0; i < locked->table_count; i++) { if (locked->table[i] == table) diff --git a/sql/log.cc b/sql/log.cc index a480db7d79d..973aecb16e8 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2419,7 +2419,7 @@ static int find_uniq_filename(char *name, ulong next_log_number) uint i; char buff[FN_REFLEN], ext_buf[FN_REFLEN]; struct st_my_dir *dir_info; - reg1 struct fileinfo *file_info; + struct fileinfo *file_info; ulong max_found, next, UNINIT_VAR(number); size_t buf_length, length; char *start, *end; @@ -8482,7 +8482,7 @@ void MYSQL_BIN_LOG::set_max_size(ulong max_size_arg) static bool test_if_number(const char *str, ulong *res, bool allow_wildcards) { - reg2 int flag; + int flag; const char *start; DBUG_ENTER("test_if_number"); diff --git a/sql/records.cc b/sql/records.cc index f16bdcff6e6..7d36d52228b 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -631,7 +631,7 @@ static int init_rr_cache(THD *thd, READ_RECORD *info) static int rr_from_cache(READ_RECORD *info) { - reg1 uint i; + uint i; ulong length; my_off_t rest_of_file; int16 error; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index b3059248ac0..29f181320c7 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -11346,7 +11346,7 @@ int fill_schema_applicable_roles(THD *thd, TABLE_LIST *tables, COND *cond) int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr) { - reg3 int flag; + int flag; DBUG_ENTER("wild_case_compare"); DBUG_PRINT("enter",("str: '%s' wildstr: '%s'",str,wildstr)); while (*wildstr) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index cc34b103a15..e20ad15ae51 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -7014,7 +7014,7 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, List *sum_func_list, List *pre_fix, bool allow_sum_func) { - reg2 Item *item; + Item *item; enum_mark_columns save_mark_used_columns= thd->mark_used_columns; nesting_map save_allow_sum_func= thd->lex->allow_sum_func; List_iterator it(fields); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 4c8ac42ab98..3e36cac96b9 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1008,7 +1008,7 @@ Lex_input_stream::unescape(CHARSET_INFO *cs, char *to, bool Lex_input_stream::get_text(LEX_STRING *dst, uint sep, int pre_skip, int post_skip) { - reg1 uchar c; + uchar c; uint found_escape=0; CHARSET_INFO *cs= m_thd->charset(); @@ -1188,7 +1188,7 @@ static inline uint int_token(const char *str,uint length) */ bool consume_comment(Lex_input_stream *lip, int remaining_recursions_permitted) { - reg1 uchar c; + uchar c; while (! lip->eof()) { c= lip->yyGet(); @@ -1286,7 +1286,7 @@ int MYSQLlex(YYSTYPE *yylval, THD *thd) static int lex_one_token(YYSTYPE *yylval, THD *thd) { - reg1 uchar UNINIT_VAR(c); + uchar UNINIT_VAR(c); bool comment_closed; int tokval, result_state; uint length; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index ee92df7c6b8..d0dbf90f093 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -427,7 +427,7 @@ static bool send_prep_stmt(Prepared_statement *stmt, static ulong get_param_length(uchar **packet, ulong len) { - reg1 uchar *pos= *packet; + uchar *pos= *packet; if (len < 1) return 0; if (*pos < 251) -- cgit v1.2.1