diff options
Diffstat (limited to 'sql')
410 files changed, 2539 insertions, 1201 deletions
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index becd4e5caf6..4d8918d962e 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -12,7 +12,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA IF(WITH_WSREP AND NOT EMBEDDED_LIBRARY) diff --git a/sql/authors.h b/sql/authors.h index 609b77059f4..251ed2c38c3 100644 --- a/sql/authors.h +++ b/sql/authors.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Structure of the name list */ diff --git a/sql/bounded_queue.h b/sql/bounded_queue.h index d7c28215631..fd733caa019 100644 --- a/sql/bounded_queue.h +++ b/sql/bounded_queue.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef BOUNDED_QUEUE_INCLUDED #define BOUNDED_QUEUE_INCLUDED diff --git a/sql/client_settings.h b/sql/client_settings.h index 486862b276d..cc4981ec6ae 100644 --- a/sql/client_settings.h +++ b/sql/client_settings.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef CLIENT_SETTINGS_INCLUDED diff --git a/sql/compat56.cc b/sql/compat56.cc index 1285de9fd12..a500fcc46e1 100644 --- a/sql/compat56.cc +++ b/sql/compat56.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "compat56.h" diff --git a/sql/compat56.h b/sql/compat56.h index ff887ebf1bb..347d6145048 100644 --- a/sql/compat56.h +++ b/sql/compat56.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** MySQL56 routines and macros **/ diff --git a/sql/contributors.h b/sql/contributors.h index 69f8fa6bd4c..34f06087c8c 100644 --- a/sql/contributors.h +++ b/sql/contributors.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Structure of the name list */ diff --git a/sql/create_options.cc b/sql/create_options.cc index 7837beb516f..5adcb2f1e9e 100644 --- a/sql/create_options.cc +++ b/sql/create_options.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/create_options.h b/sql/create_options.h index 16be5affde0..ce64516794b 100644 --- a/sql/create_options.h +++ b/sql/create_options.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/custom_conf.h b/sql/custom_conf.h index 62fdb619c27..5847b939ca7 100644 --- a/sql/custom_conf.h +++ b/sql/custom_conf.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef __MYSQL_CUSTOM_BUILD_CONFIG__ #define __MYSQL_CUSTOM_BUILD_CONFIG__ diff --git a/sql/datadict.cc b/sql/datadict.cc index dae2de9b393..da8376d8b1a 100644 --- a/sql/datadict.cc +++ b/sql/datadict.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "datadict.h" diff --git a/sql/datadict.h b/sql/datadict.h index d4547a1f5f1..cbdf788deb6 100644 --- a/sql/datadict.h +++ b/sql/datadict.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "handler.h" diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc index 357d8f4ce60..bf721bddb85 100644 --- a/sql/debug_sync.cc +++ b/sql/debug_sync.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* see include/mysql/service_debug_sync.h for debug sync documentation */ diff --git a/sql/debug_sync.h b/sql/debug_sync.h index 70d28cb982b..7a63a52959c 100644 --- a/sql/debug_sync.h +++ b/sql/debug_sync.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/derror.cc b/sql/derror.cc index 011f8e1669c..a1150596ee3 100644 --- a/sql/derror.cc +++ b/sql/derror.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/derror.h b/sql/derror.h index a171a248190..34a71b731aa 100644 --- a/sql/derror.h +++ b/sql/derror.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef DERROR_INCLUDED #define DERROR_INCLUDED diff --git a/sql/des_key_file.cc b/sql/des_key_file.cc index 1f81fb9fd3f..bfbe04f6015 100644 --- a/sql/des_key_file.cc +++ b/sql/des_key_file.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" // HAVE_* #include "sql_priv.h" diff --git a/sql/des_key_file.h b/sql/des_key_file.h index 024a1715d47..847cd767b4b 100644 --- a/sql/des_key_file.h +++ b/sql/des_key_file.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef DES_KEY_FILE_INCLUDED #define DES_KEY_FILE_INCLUDED diff --git a/sql/discover.cc b/sql/discover.cc index afebce77bf9..3df777c19ba 100644 --- a/sql/discover.cc +++ b/sql/discover.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** diff --git a/sql/discover.h b/sql/discover.h index c3127c3bff3..f14be662dbc 100644 --- a/sql/discover.h +++ b/sql/discover.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef DISCOVER_INCLUDED #define DISCOVER_INCLUDED diff --git a/sql/encryption.cc b/sql/encryption.cc index 0d75fdacd8f..fc07623883e 100644 --- a/sql/encryption.cc +++ b/sql/encryption.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include <mysql/plugin_encryption.h> diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index 6327cd138de..d9ed0b633e4 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #define MYSQL_LEX 1 #include "mariadb.h" /* NO_EMBEDDED_ACCESS_CHECKS */ diff --git a/sql/event_data_objects.h b/sql/event_data_objects.h index 8afed7df4c9..e5e3e4eb087 100644 --- a/sql/event_data_objects.h +++ b/sql/event_data_objects.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @addtogroup Event_Scheduler diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc index 61b1c2de15d..dc47ed0b2e1 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/event_db_repository.h b/sql/event_db_repository.h index 34de3ec2c45..b89a1a15155 100644 --- a/sql/event_db_repository.h +++ b/sql/event_db_repository.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** diff --git a/sql/event_parse_data.cc b/sql/event_parse_data.cc index 00d625879de..e2f73cd2bb4 100644 --- a/sql/event_parse_data.cc +++ b/sql/event_parse_data.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/event_parse_data.h b/sql/event_parse_data.h index d2e14d74cf8..4e68295ab5d 100644 --- a/sql/event_parse_data.h +++ b/sql/event_parse_data.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef _EVENT_PARSE_DATA_H_ #define _EVENT_PARSE_DATA_H_ diff --git a/sql/event_queue.cc b/sql/event_queue.cc index 7cc3e50f235..6b3f5777df3 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/event_queue.h b/sql/event_queue.h index ad3809fe086..2b6a0a594cb 100644 --- a/sql/event_queue.h +++ b/sql/event_queue.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc index 99b3c9b93fb..8d90e8aed70 100644 --- a/sql/event_scheduler.cc +++ b/sql/event_scheduler.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/event_scheduler.h b/sql/event_scheduler.h index 6ec7dccefb9..59ac923cf6d 100644 --- a/sql/event_scheduler.h +++ b/sql/event_scheduler.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @addtogroup Event_Scheduler diff --git a/sql/events.cc b/sql/events.cc index 196c8df591d..166fa992f88 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" @@ -418,6 +418,12 @@ Events::create_event(THD *thd, Event_parse_data *parse_data) thd->restore_stmt_binlog_format(save_binlog_format); + if (!ret && Events::opt_event_scheduler == Events::EVENTS_OFF) + { + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, + "Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it."); + } + DBUG_RETURN(ret); #ifdef WITH_WSREP wsrep_error_label: diff --git a/sql/events.h b/sql/events.h index 4b4505b6a02..9e1651c767a 100644 --- a/sql/events.h +++ b/sql/events.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @defgroup Event_Scheduler Event Scheduler diff --git a/sql/field.cc b/sql/field.cc index 0de5c377703..a671195ba2b 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @@ -2431,7 +2431,7 @@ int Field::set_default() /* Copy constant value stored in s->default_values */ my_ptrdiff_t l_offset= (my_ptrdiff_t) (table->s->default_values - table->record[0]); - memcpy(ptr, ptr + l_offset, pack_length()); + memcpy(ptr, ptr + l_offset, pack_length_in_rec()); if (maybe_null_in_table()) *null_ptr= ((*null_ptr & (uchar) ~null_bit) | (null_ptr[l_offset] & null_bit)); @@ -4546,34 +4546,15 @@ String *Field_float::val_str(String *val_buffer, { DBUG_ASSERT(marked_for_read()); DBUG_ASSERT(!zerofill || field_length <= MAX_FIELD_CHARLENGTH); - float nr; - float4get(nr,ptr); - uint to_length= 70; - if (val_buffer->alloc(to_length)) + if (Float(ptr).to_string(val_buffer, dec)) { my_error(ER_OUT_OF_RESOURCES, MYF(0)); return val_buffer; } - char *to=(char*) val_buffer->ptr(); - size_t len; - - if (dec >= FLOATING_POINT_DECIMALS) - len= my_gcvt(nr, MY_GCVT_ARG_FLOAT, to_length - 1, to, NULL); - else - { - /* - We are safe here because the buffer length is 70, and - fabs(float) < 10^39, dec < FLOATING_POINT_DECIMALS. So the resulting string - will be not longer than 69 chars + terminating '\0'. - */ - len= my_fcvt(nr, dec, to, NULL); - } - val_buffer->length((uint) len); if (zerofill) prepend_zeros(val_buffer); - val_buffer->set_charset(&my_charset_numeric); return val_buffer; } @@ -7092,6 +7073,17 @@ int Field_str::store(double nr) } +bool Field_longstr:: + csinfo_change_allows_instant_alter(const Create_field *to) const +{ + Charset cs(field_charset); + const bool part_of_a_key= !to->field->part_of_key.is_clear_all(); + return part_of_a_key ? + cs.encoding_and_order_allow_reinterpret_as(to->charset) : + cs.encoding_allows_reinterpret_as(to->charset); +} + + uint Field_string::is_equal(Create_field *new_field) { DBUG_ASSERT(!compression_method()); @@ -7102,9 +7094,7 @@ uint Field_string::is_equal(Create_field *new_field) if (new_field->char_length < char_length()) return IS_EQUAL_NO; - const bool part_of_a_key= !new_field->field->part_of_key.is_clear_all(); - if (!Type_handler::Charsets_are_compatible(field_charset, new_field->charset, - part_of_a_key)) + if (!csinfo_change_allows_instant_alter(new_field)) return IS_EQUAL_NO; if (new_field->length == max_display_length()) @@ -7954,9 +7944,7 @@ uint Field_varstring::is_equal(Create_field *new_field) if (!new_field->compression_method() != !compression_method()) return IS_EQUAL_NO; - bool part_of_a_key= !new_field->field->part_of_key.is_clear_all(); - if (!Type_handler::Charsets_are_compatible(field_charset, new_field->charset, - part_of_a_key)) + if (!csinfo_change_allows_instant_alter(new_field)) return IS_EQUAL_NO; const Type_handler *new_type_handler= new_field->type_handler(); @@ -8751,12 +8739,8 @@ uint Field_blob::is_equal(Create_field *new_field) return IS_EQUAL_NO; } - bool part_of_a_key= !new_field->field->part_of_key.is_clear_all(); - if (!Type_handler::Charsets_are_compatible(field_charset, new_field->charset, - part_of_a_key)) - { + if (!csinfo_change_allows_instant_alter(new_field)) return IS_EQUAL_NO; - } if (field_charset != new_field->charset) { diff --git a/sql/field.h b/sql/field.h index 676c85abbef..ceb4a8bb93f 100644 --- a/sql/field.h +++ b/sql/field.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Because of the function make_new_field() all field classes that have static @@ -1926,6 +1926,7 @@ protected: CHARSET_INFO *cs, size_t nchars); String *uncompress(String *val_buffer, String *val_ptr, const uchar *from, uint from_length); + bool csinfo_change_allows_instant_alter(const Create_field *to) const; public: Field_longstr(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, @@ -4851,6 +4852,14 @@ public: } return 0; } + static Row_definition_list *make(MEM_ROOT *mem_root, Spvar_definition *var) + { + Row_definition_list *list; + if (!(list= new (mem_root) Row_definition_list())) + return NULL; + return list->push_back(var, mem_root) ? NULL : list; + } + bool append_uniq(MEM_ROOT *thd, Spvar_definition *var); bool adjust_formal_params_to_actual_params(THD *thd, List<Item> *args); bool adjust_formal_params_to_actual_params(THD *thd, Item **args, uint arg_count); diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 2f56be60dd6..bcd4c5fbb38 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** diff --git a/sql/filesort.cc b/sql/filesort.cc index 924e51b58cc..3f4291cfb1f 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** diff --git a/sql/filesort.h b/sql/filesort.h index 359f44a3907..5f79a5095cc 100644 --- a/sql/filesort.h +++ b/sql/filesort.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef FILESORT_INCLUDED #define FILESORT_INCLUDED diff --git a/sql/filesort_utils.cc b/sql/filesort_utils.cc index b39bb880c15..703db84495f 100644 --- a/sql/filesort_utils.cc +++ b/sql/filesort_utils.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "filesort_utils.h" diff --git a/sql/filesort_utils.h b/sql/filesort_utils.h index 544cd3e0f2b..1ab1ba2daa8 100644 --- a/sql/filesort_utils.h +++ b/sql/filesort_utils.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef FILESORT_UTILS_INCLUDED #define FILESORT_UTILS_INCLUDED diff --git a/sql/gcalc_slicescan.cc b/sql/gcalc_slicescan.cc index 3a5dc6410a8..4919e5b959b 100644 --- a/sql/gcalc_slicescan.cc +++ b/sql/gcalc_slicescan.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" diff --git a/sql/gcalc_slicescan.h b/sql/gcalc_slicescan.h index ebf173c1a57..54b12962d2a 100644 --- a/sql/gcalc_slicescan.h +++ b/sql/gcalc_slicescan.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef GCALC_SLICESCAN_INCLUDED diff --git a/sql/gcalc_tools.cc b/sql/gcalc_tools.cc index 832a52db522..14a7c6331f3 100644 --- a/sql/gcalc_tools.cc +++ b/sql/gcalc_tools.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" diff --git a/sql/gcalc_tools.h b/sql/gcalc_tools.h index 4d5aec0d443..77da791f0b9 100644 --- a/sql/gcalc_tools.h +++ b/sql/gcalc_tools.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef GCALC_TOOLS_INCLUDED diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 9241dd79113..98e6205ee0b 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/gen_lex_token.cc b/sql/gen_lex_token.cc index 7e0cfd097f9..0ca03b0bf7b 100644 --- a/sql/gen_lex_token.cc +++ b/sql/gen_lex_token.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include <string.h> diff --git a/sql/gen_win_tzname_data.ps1 b/sql/gen_win_tzname_data.ps1 new file mode 100644 index 00000000000..13b6ce6ffd0 --- /dev/null +++ b/sql/gen_win_tzname_data.ps1 @@ -0,0 +1,11 @@ +# Generates a header file for converting between Windows timezone names to tzdb names +# using CLDR data. +# Usage: powershell -File gen_win_tzname_data.ps1 > win_tzname_data.h + +write-output "/* This file was generated using gen_win_tzname_data.ps1 */" +$xdoc = new-object System.Xml.XmlDocument +$xdoc.load("https://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml") +$nodes = $xdoc.SelectNodes("//mapZone[@territory='001']") # use default territory (001) +foreach ($node in $nodes) { + write-output ('{L"'+ $node.other + '","'+ $node.type+'"},') +} diff --git a/sql/group_by_handler.cc b/sql/group_by_handler.cc index f18758a2d94..326aad439ef 100644 --- a/sql/group_by_handler.cc +++ b/sql/group_by_handler.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* This file implements the group_by_handler code. This interface diff --git a/sql/group_by_handler.h b/sql/group_by_handler.h index d3f48a15c24..108ebc989d9 100644 --- a/sql/group_by_handler.h +++ b/sql/group_by_handler.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* This file implements the group_by_handler interface. This interface diff --git a/sql/gstream.cc b/sql/gstream.cc index ff3604ac7a4..4678e85019e 100644 --- a/sql/gstream.cc +++ b/sql/gstream.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Functions to read and parse geometrical data. diff --git a/sql/gstream.h b/sql/gstream.h index b9310b716ba..c5c715393ac 100644 --- a/sql/gstream.h +++ b/sql/gstream.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include <my_sys.h> /* MY_ALLOW_ZERO_PTR */ diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 11f5bb5497f..733bc1953ba 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2005, 2017, Oracle and/or its affiliates. - Copyright (c) 2009, 2018, MariaDB + Copyright (c) 2005, 2019, Oracle and/or its affiliates. + Copyright (c) 2009, 2019, MariaDB 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 @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* @@ -8198,8 +8198,9 @@ int ha_partition::info(uint flag) stats.deleted= 0; stats.data_file_length= 0; stats.index_file_length= 0; - stats.check_time= 0; stats.delete_length= 0; + stats.check_time= 0; + stats.checksum= 0; for (i= bitmap_get_first_set(&m_part_info->read_partitions); i < m_tot_parts; i= bitmap_get_next_set(&m_part_info->read_partitions, i)) @@ -8213,6 +8214,7 @@ int ha_partition::info(uint flag) stats.delete_length+= file->stats.delete_length; if (file->stats.check_time > stats.check_time) stats.check_time= file->stats.check_time; + stats.checksum+= file->stats.checksum; } if (stats.records && stats.records < 2 && !(m_file[0]->ha_table_flags() & HA_STATS_RECORDS_IS_EXACT)) @@ -8368,10 +8370,7 @@ void ha_partition::get_dynamic_partition_info(PARTITION_STATS *stat_info, stat_info->create_time= file->stats.create_time; stat_info->update_time= file->stats.update_time; stat_info->check_time= file->stats.check_time; - stat_info->check_sum= 0; - if (file->ha_table_flags() & (HA_HAS_OLD_CHECKSUM | HA_HAS_NEW_CHECKSUM)) - stat_info->check_sum= file->checksum(); - return; + stat_info->check_sum= file->stats.checksum; } @@ -10113,7 +10112,12 @@ bool ha_partition::inplace_alter_table(TABLE *altered_table, for (index= 0; index < m_tot_parts && !error; index++) { - ha_alter_info->handler_ctx= part_inplace_ctx->handler_ctx_array[index]; + if ((ha_alter_info->handler_ctx= + part_inplace_ctx->handler_ctx_array[index]) != NULL + && index != 0) + ha_alter_info->handler_ctx->set_shared_data + (*part_inplace_ctx->handler_ctx_array[index - 1]); + if (m_file[index]->ha_inplace_alter_table(altered_table, ha_alter_info)) error= true; @@ -10583,27 +10587,6 @@ void ha_partition::init_table_handle_for_HANDLER() } -/** - Return the checksum of the table (all partitions) -*/ - -uint ha_partition::checksum() const -{ - ha_checksum sum= 0; - - DBUG_ENTER("ha_partition::checksum"); - if ((table_flags() & (HA_HAS_OLD_CHECKSUM | HA_HAS_NEW_CHECKSUM))) - { - handler **file= m_file; - do - { - sum+= (*file)->checksum(); - } while (*(++file)); - } - DBUG_RETURN(sum); -} - - /**************************************************************************** MODULE enable/disable indexes ****************************************************************************/ diff --git a/sql/ha_partition.h b/sql/ha_partition.h index caeff8a25aa..d538abc69ed 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "sql_partition.h" /* part_id_range, partition_element */ #include "queues.h" /* QUEUE */ @@ -1441,18 +1441,6 @@ public: void append_row_to_str(String &str); public: - /* - ------------------------------------------------------------------------- - Admin commands not supported currently (almost purely MyISAM routines) - This means that the following methods are not implemented: - ------------------------------------------------------------------------- - - virtual int backup(TD* thd, HA_CHECK_OPT *check_opt); - virtual int restore(THD* thd, HA_CHECK_OPT *check_opt); - virtual int dump(THD* thd, int fd = -1); - virtual int net_read_dump(NET* net); - */ - virtual uint checksum() const; /* Enabled keycache for performance reasons, WL#4571 */ virtual int assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt); virtual int preload_keys(THD* thd, HA_CHECK_OPT* check_opt); diff --git a/sql/handler.cc b/sql/handler.cc index 6309d2b77ec..b3487e69670 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -11,8 +11,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file handler.cc @@ -4893,10 +4893,7 @@ void handler::get_dynamic_partition_info(PARTITION_STATS *stat_info, stat_info->create_time= stats.create_time; stat_info->update_time= stats.update_time; stat_info->check_time= stats.check_time; - stat_info->check_sum= 0; - if (table_flags() & (HA_HAS_OLD_CHECKSUM | HA_HAS_NEW_CHECKSUM)) - stat_info->check_sum= checksum(); - return; + stat_info->check_sum= stats.checksum; } @@ -5018,6 +5015,98 @@ end: } +static void flush_checksum(ha_checksum *row_crc, uchar **checksum_start, + size_t *checksum_length) +{ + if (*checksum_start) + { + *row_crc= my_checksum(*row_crc, *checksum_start, *checksum_length); + *checksum_start= NULL; + *checksum_length= 0; + } +} + + +/* calculating table's checksum */ +int handler::calculate_checksum() +{ + int error; + THD *thd=ha_thd(); + DBUG_ASSERT(table->s->last_null_bit_pos < 8); + uchar null_mask= table->s->last_null_bit_pos + ? 256 - (1 << table->s->last_null_bit_pos) : 0; + + table->use_all_stored_columns(); + stats.checksum= 0; + + if ((error= ha_rnd_init(1))) + return error; + + for (;;) + { + if (thd->killed) + return HA_ERR_ABORTED_BY_USER; + + ha_checksum row_crc= 0; + error= table->file->ha_rnd_next(table->record[0]); + if (error) + break; + + if (table->s->null_bytes) + { + /* fix undefined null bits */ + table->record[0][table->s->null_bytes-1] |= null_mask; + if (!(table->s->db_create_options & HA_OPTION_PACK_RECORD)) + table->record[0][0] |= 1; + + row_crc= my_checksum(row_crc, table->record[0], table->s->null_bytes); + } + + uchar *checksum_start= NULL; + size_t checksum_length= 0; + for (uint i= 0; i < table->s->fields; i++ ) + { + Field *f= table->field[i]; + + if (! thd->variables.old_mode && f->is_real_null(0)) + { + flush_checksum(&row_crc, &checksum_start, &checksum_length); + continue; + } + /* + BLOB and VARCHAR have pointers in their field, we must convert + to string; GEOMETRY is implemented on top of BLOB. + BIT may store its data among NULL bits, convert as well. + */ + switch (f->type()) { + case MYSQL_TYPE_BLOB: + case MYSQL_TYPE_VARCHAR: + case MYSQL_TYPE_GEOMETRY: + case MYSQL_TYPE_BIT: + { + flush_checksum(&row_crc, &checksum_start, &checksum_length); + String tmp; + f->val_str(&tmp); + row_crc= my_checksum(row_crc, (uchar*) tmp.ptr(), tmp.length()); + break; + } + default: + if (!checksum_start) + checksum_start= f->ptr; + DBUG_ASSERT(checksum_start + checksum_length == f->ptr); + checksum_length+= f->pack_length(); + break; + } + } + flush_checksum(&row_crc, &checksum_start, &checksum_length); + + stats.checksum+= row_crc; + } + table->file->ha_rnd_end(); + return error == HA_ERR_END_OF_FILE ? 0 : error; +} + + /**************************************************************************** ** Some general functions that isn't in the handler class ****************************************************************************/ @@ -6347,8 +6436,8 @@ int handler::ha_reset() table->default_column_bitmaps(); pushed_cond= NULL; tracker= NULL; - mark_trx_read_write_done= check_table_binlog_row_based_done= - check_table_binlog_row_based_result= 0; + mark_trx_read_write_done= 0; + clear_cached_table_binlog_row_based_flag(); /* Reset information about pushed engine conditions */ cancel_pushed_idx_cond(); /* Reset information about pushed index conditions */ @@ -7336,8 +7425,9 @@ bool Table_scope_and_contents_source_st::vers_check_system_fields( { if (!(options & HA_VERSIONED_TABLE)) return false; - return vers_info.check_sys_fields(create_table.table_name, create_table.db, - alter_info); + return vers_info.check_sys_fields( + create_table.table_name, create_table.db, alter_info, + ha_check_storage_engine_flag(db_type, HTON_NATIVE_SYS_VERSIONING)); } @@ -7352,7 +7442,7 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info, if (DBUG_EVALUATE_IF("sysvers_force", 0, share->tmp_table)) { - my_error(ER_VERS_TEMPORARY, MYF(0)); + my_error(ER_VERS_NOT_SUPPORTED, MYF(0), "CREATE TEMPORARY TABLE"); return true; } @@ -7446,7 +7536,11 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info, if (alter_info->flags & ALTER_ADD_SYSTEM_VERSIONING) { - if (check_sys_fields(table_name, share->db, alter_info)) + const bool can_native= + ha_check_storage_engine_flag(create_info->db_type, + HTON_NATIVE_SYS_VERSIONING) || + create_info->db_type->db_type == DB_TYPE_PARTITION_DB; + if (check_sys_fields(table_name, share->db, alter_info, can_native)) return true; } @@ -7551,80 +7645,85 @@ bool Vers_parse_info::check_conditions(const Lex_table_name &table_name, return false; } +static bool is_versioning_timestamp(const Create_field *f) +{ + return f->type_handler() == &type_handler_timestamp2 && + f->length == MAX_DATETIME_FULL_WIDTH; +} + +static bool is_some_bigint(const Create_field *f) +{ + return f->type_handler() == &type_handler_longlong || + f->type_handler() == &type_handler_vers_trx_id; +} + +static bool is_versioning_bigint(const Create_field *f) +{ + return is_some_bigint(f) && f->flags & UNSIGNED_FLAG && + f->length == MY_INT64_NUM_DECIMAL_DIGITS - 1; +} + +static bool require_timestamp(const Create_field *f, Lex_table_name table_name) +{ + my_error(ER_VERS_FIELD_WRONG_TYPE, MYF(0), f->field_name.str, "TIMESTAMP(6)", + table_name.str); + return true; +} +static bool require_bigint(const Create_field *f, Lex_table_name table_name) +{ + my_error(ER_VERS_FIELD_WRONG_TYPE, MYF(0), f->field_name.str, + "BIGINT(20) UNSIGNED", table_name.str); + return true; +} + bool Vers_parse_info::check_sys_fields(const Lex_table_name &table_name, const Lex_table_name &db, - Alter_info *alter_info) + Alter_info *alter_info, + bool can_native) const { if (check_conditions(table_name, db)) return true; + const Create_field *row_start= NULL; + const Create_field *row_end= NULL; + List_iterator<Create_field> it(alter_info->create_list); - uint found_flag= 0; while (Create_field *f= it++) { - vers_sys_type_t f_check_unit= VERS_UNDEFINED; - uint sys_flag= f->flags & VERS_SYSTEM_FIELD; + if (!row_start && f->flags & VERS_SYS_START_FLAG) + row_start= f; + else if (!row_end && f->flags & VERS_SYS_END_FLAG) + row_end= f; + } - if (!sys_flag) - continue; + const bool expect_timestamp= + !can_native || !is_some_bigint(row_start) || !is_some_bigint(row_end); - if (sys_flag & found_flag) - { - my_error(ER_VERS_DUPLICATE_ROW_START_END, MYF(0), - found_flag & VERS_SYS_START_FLAG ? "START" : "END", - f->field_name.str); - return true; - } + if (expect_timestamp) + { + if (!is_versioning_timestamp(row_start)) + return require_timestamp(row_start, table_name); - sys_flag|= found_flag; + if (!is_versioning_timestamp(row_end)) + return require_timestamp(row_end, table_name); + } + else + { + if (!is_versioning_bigint(row_start)) + return require_bigint(row_start, table_name); - if ((f->type_handler() == &type_handler_datetime2 || - f->type_handler() == &type_handler_timestamp2) && - f->length == MAX_DATETIME_FULL_WIDTH) - { - f_check_unit= VERS_TIMESTAMP; - } - else if (f->type_handler() == &type_handler_longlong - && (f->flags & UNSIGNED_FLAG) - && f->length == (MY_INT64_NUM_DECIMAL_DIGITS - 1)) - { - f_check_unit= VERS_TRX_ID; - } - else - { - if (!check_unit) - check_unit= VERS_TIMESTAMP; - goto error; - } + if (!is_versioning_bigint(row_end)) + return require_bigint(row_end, table_name); + } - if (f_check_unit) - { - if (check_unit) - { - if (check_unit == f_check_unit) - { - if (check_unit == VERS_TRX_ID && !TR_table::use_transaction_registry) - { - my_error(ER_VERS_TRT_IS_DISABLED, MYF(0)); - return true; - } - return false; - } - error: - my_error(ER_VERS_FIELD_WRONG_TYPE, MYF(0), f->field_name.str, - check_unit == VERS_TIMESTAMP ? - "TIMESTAMP(6)" : - "BIGINT(20) UNSIGNED", - table_name.str); - return true; - } - check_unit= f_check_unit; - } + if (is_versioning_bigint(row_start) && is_versioning_bigint(row_end) && + !TR_table::use_transaction_registry) + { + my_error(ER_VERS_TRT_IS_DISABLED, MYF(0)); + return true; } - my_error(ER_MISSING, MYF(0), table_name.str, found_flag & VERS_SYS_START_FLAG ? - "ROW END" : found_flag ? "ROW START" : "ROW START/END"); - return true; + return false; } bool Table_period_info::check_field(const Create_field* f, diff --git a/sql/handler.h b/sql/handler.h index a54c556f6ae..476244f6325 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1,7 +1,7 @@ #ifndef HANDLER_INCLUDED #define HANDLER_INCLUDED /* - Copyright (c) 2000, 2016, Oracle and/or its affiliates. + Copyright (c) 2000, 2019, Oracle and/or its affiliates. Copyright (c) 2009, 2019, MariaDB This program is free software; you can redistribute it and/or @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Definitions for parameters to do with handler-routines */ @@ -2022,13 +2022,11 @@ struct Vers_parse_info: public Table_period_info { Vers_parse_info() : Table_period_info(STRING_WITH_LEN("SYSTEM_TIME")), - check_unit(VERS_UNDEFINED), versioned_fields(false), unversioned_fields(false) {} Table_period_info::start_end_t as_row; - vers_sys_type_t check_unit; protected: friend struct Table_scope_and_contents_source_st; @@ -2063,8 +2061,8 @@ public: bool fix_create_like(Alter_info &alter_info, HA_CREATE_INFO &create_info, TABLE_LIST &src_table, TABLE_LIST &table); bool check_sys_fields(const Lex_table_name &table_name, - const Lex_table_name &db, - Alter_info *alter_info); + const Lex_table_name &db, Alter_info *alter_info, + bool can_native) const; /** At least one field was specified 'WITH/WITHOUT SYSTEM VERSIONING'. @@ -2298,6 +2296,7 @@ public: inplace_alter_handler_ctx() {} virtual ~inplace_alter_handler_ctx() {} + virtual void set_shared_data(const inplace_alter_handler_ctx& ctx) {} }; @@ -2895,6 +2894,7 @@ public: time_t check_time; time_t update_time; uint block_size; /* index block size */ + ha_checksum checksum; /* number of buffer bytes that native mrr implementation needs, @@ -3939,7 +3939,7 @@ public: virtual uint max_supported_key_part_length() const { return 255; } virtual uint min_record_length(uint options) const { return 1; } - virtual uint checksum() const { return 0; } + virtual int calculate_checksum(); virtual bool is_crashed() const { return 0; } virtual bool auto_repair(int error) const { return 0; } @@ -4494,6 +4494,12 @@ protected: public: bool check_table_binlog_row_based(bool binlog_row); + inline void clear_cached_table_binlog_row_based_flag() + { + check_table_binlog_row_based_done= 0; + check_table_binlog_row_based_result= 0; + } +private: /* Cache result to avoid extra calls */ inline void mark_trx_read_write() { diff --git a/sql/hash_filo.cc b/sql/hash_filo.cc index 641d1a20f73..b359bd95786 100644 --- a/sql/hash_filo.cc +++ b/sql/hash_filo.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* diff --git a/sql/hash_filo.h b/sql/hash_filo.h index 4c8c7575efc..d815c428ac6 100644 --- a/sql/hash_filo.h +++ b/sql/hash_filo.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* diff --git a/sql/hostname.cc b/sql/hostname.cc index 00c780d9f35..968914fd56e 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** diff --git a/sql/hostname.h b/sql/hostname.h index 3e1669b29ed..3a371dceb92 100644 --- a/sql/hostname.h +++ b/sql/hostname.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef HOSTNAME_INCLUDED #define HOSTNAME_INCLUDED diff --git a/sql/init.cc b/sql/init.cc index 024cbb79d81..4735178707f 100644 --- a/sql/init.cc +++ b/sql/init.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** diff --git a/sql/init.h b/sql/init.h index 0bb67b293ed..b9d5053fc4d 100644 --- a/sql/init.h +++ b/sql/init.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef INIT_INCLUDED #define INIT_INCLUDED diff --git a/sql/innodb_priv.h b/sql/innodb_priv.h index b78724d04b0..bec63a839c8 100644 --- a/sql/innodb_priv.h +++ b/sql/innodb_priv.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef INNODB_PRIV_INCLUDED #define INNODB_PRIV_INCLUDED diff --git a/sql/item.cc b/sql/item.cc index 72231497a22..22bcbf39ab3 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_IMPLEMENTATION @@ -265,6 +265,40 @@ longlong Item::val_int_unsigned_typecast_from_str() } +longlong Item::val_int_signed_typecast_from_real() +{ + double nr= val_real(); + if (null_value) + return 0; + Converter_double_to_longlong conv(nr, false); + if (conv.error()) + { + THD *thd= current_thd; + push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, + ER_DATA_OVERFLOW, ER_THD(thd, ER_DATA_OVERFLOW), + ErrConvDouble(nr).ptr(), "SIGNED BIGINT"); + } + return conv.result(); +} + + +longlong Item::val_int_unsigned_typecast_from_real() +{ + double nr= val_real(); + if (null_value) + return 0; + Converter_double_to_longlong conv(nr, true); + if (conv.error()) + { + THD *thd= current_thd; + push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, + ER_DATA_OVERFLOW, ER_THD(thd, ER_DATA_OVERFLOW), + ErrConvDouble(nr).ptr(), "UNSIGNED BIGINT"); + } + return conv.result(); +} + + longlong Item::val_int_signed_typecast_from_int() { longlong value= val_int(); @@ -9929,7 +9963,7 @@ longlong Item_cache_real::val_int() } -String* Item_cache_real::val_str(String *str) +String* Item_cache_double::val_str(String *str) { if (!has_value()) return NULL; @@ -9938,6 +9972,15 @@ String* Item_cache_real::val_str(String *str) } +String* Item_cache_float::val_str(String *str) +{ + if (!has_value()) + return NULL; + Float(value).to_string(str, decimals); + return str; +} + + my_decimal *Item_cache_real::val_decimal(my_decimal *decimal_val) { if (!has_value()) diff --git a/sql/item.h b/sql/item.h index ec474b81a08..b0d3666ead7 100644 --- a/sql/item.h +++ b/sql/item.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_INTERFACE @@ -1247,12 +1247,14 @@ public: } longlong val_int_unsigned_typecast_from_int(); longlong val_int_unsigned_typecast_from_str(); + longlong val_int_unsigned_typecast_from_real(); /** Get a value for CAST(x AS UNSIGNED). Huge positive unsigned values are converted to negative complements. */ longlong val_int_signed_typecast_from_int(); + longlong val_int_signed_typecast_from_real(); /* This is just a shortcut to avoid the cast. You should still use @@ -6780,21 +6782,44 @@ public: class Item_cache_real: public Item_cache { +protected: double value; public: - Item_cache_real(THD *thd): Item_cache(thd, &type_handler_double), - value(0) {} - + Item_cache_real(THD *thd, const Type_handler *h) + :Item_cache(thd, h), + value(0) + {} double val_real(); longlong val_int(); - String* val_str(String *str); my_decimal *val_decimal(my_decimal *); bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) { return get_date_from_real(thd, ltime, fuzzydate); } bool cache_value(); Item *convert_to_basic_const_item(THD *thd); +}; + + +class Item_cache_double: public Item_cache_real +{ +public: + Item_cache_double(THD *thd) + :Item_cache_real(thd, &type_handler_double) + { } + String* val_str(String *str); + Item *get_copy(THD *thd) + { return get_item_copy<Item_cache_double>(thd, this); } +}; + + +class Item_cache_float: public Item_cache_real +{ +public: + Item_cache_float(THD *thd) + :Item_cache_real(thd, &type_handler_float) + { } + String* val_str(String *str); Item *get_copy(THD *thd) - { return get_item_copy<Item_cache_real>(thd, this); } + { return get_item_copy<Item_cache_float>(thd, this); } }; diff --git a/sql/item_buff.cc b/sql/item_buff.cc index 3467fda79c7..81949bcdae0 100644 --- a/sql/item_buff.cc +++ b/sql/item_buff.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index feb41940865..02fc7719fbc 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 5793dda9e9a..2af7ebdf231 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* compare and test functions */ diff --git a/sql/item_create.cc b/sql/item_create.cc index ba7a704e29b..9b949835e27 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file @@ -1982,6 +1982,19 @@ protected: }; +class Create_func_json_merge_patch : public Create_native_func +{ +public: + virtual Item *create_native(THD *thd, LEX_CSTRING *name, List<Item> *item_list); + + static Create_func_json_merge_patch s_singleton; + +protected: + Create_func_json_merge_patch() {} + virtual ~Create_func_json_merge_patch() {} +}; + + class Create_func_json_quote : public Create_func_arg1 { public: @@ -5552,6 +5565,30 @@ Create_func_json_merge::create_native(THD *thd, LEX_CSTRING *name, } +Create_func_json_merge_patch Create_func_json_merge_patch::s_singleton; + +Item* +Create_func_json_merge_patch::create_native(THD *thd, LEX_CSTRING *name, + List<Item> *item_list) +{ + Item *func; + int arg_count; + + if (item_list == NULL || + (arg_count= item_list->elements) < 2) // json, json + { + my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str); + func= NULL; + } + else + { + func= new (thd->mem_root) Item_func_json_merge_patch(thd, *item_list); + } + + return func; +} + + Create_func_json_contains Create_func_json_contains::s_singleton; Item* @@ -7222,6 +7259,8 @@ static Native_func_registry func_array[] = { { STRING_WITH_LEN("JSON_LENGTH") }, BUILDER(Create_func_json_length)}, { { STRING_WITH_LEN("JSON_LOOSE") }, BUILDER(Create_func_json_loose)}, { { STRING_WITH_LEN("JSON_MERGE") }, BUILDER(Create_func_json_merge)}, + { { STRING_WITH_LEN("JSON_MERGE_PATCH") }, BUILDER(Create_func_json_merge_patch)}, + { { STRING_WITH_LEN("JSON_MERGE_PRESERVE") }, BUILDER(Create_func_json_merge)}, { { STRING_WITH_LEN("JSON_QUERY") }, BUILDER(Create_func_json_query)}, { { STRING_WITH_LEN("JSON_QUOTE") }, BUILDER(Create_func_json_quote)}, { { STRING_WITH_LEN("JSON_OBJECT") }, BUILDER(Create_func_json_object)}, diff --git a/sql/item_create.h b/sql/item_create.h index 4fb3c07c4ae..5890e8ad057 100644 --- a/sql/item_create.h +++ b/sql/item_create.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Functions to create an item. Used by sql/sql_yacc.yy */ diff --git a/sql/item_func.cc b/sql/item_func.cc index 04fa20a8abf..46fdbd2a4a1 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file @@ -1022,19 +1022,26 @@ void Item_decimal_typecast::print(String *str, enum_query_type query_type) } -double Item_double_typecast::val_real() +double Item_real_typecast::val_real_with_truncate(double max_value) { int error; double tmp= args[0]->val_real(); if ((null_value= args[0]->null_value)) return 0.0; - if (unlikely((error= truncate_double(&tmp, max_length, decimals, 0, - DBL_MAX)))) + if (unlikely((error= truncate_double(&tmp, max_length, decimals, + false/*unsigned_flag*/, max_value)))) { + /* + We don't want automatic escalation from a warning to an error + in this scenario: + INSERT INTO t1 (float_field) VALUES (CAST(1e100 AS FLOAT)); + The above statement should work even in the strict mode. + So let's use a note rather than a warning. + */ THD *thd= current_thd; push_warning_printf(thd, - Sql_condition::WARN_LEVEL_WARN, + Sql_condition::WARN_LEVEL_NOTE, ER_WARN_DATA_OUT_OF_RANGE, ER_THD(thd, ER_WARN_DATA_OUT_OF_RANGE), name.str, (ulong) 1); @@ -1048,14 +1055,15 @@ double Item_double_typecast::val_real() } -void Item_double_typecast::print(String *str, enum_query_type query_type) +void Item_real_typecast::print(String *str, enum_query_type query_type) { char len_buf[20*3 + 1]; char *end; str->append(STRING_WITH_LEN("cast(")); args[0]->print(str, query_type); - str->append(STRING_WITH_LEN(" as double")); + str->append(STRING_WITH_LEN(" as ")); + str->append(type_handler()->name().ptr()); if (decimals != NOT_FIXED_DEC) { str->append('('); diff --git a/sql/item_func.h b/sql/item_func.h index 27cb245db6b..610adb4bb46 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* Function items used by mysql */ @@ -1235,25 +1235,66 @@ public: }; -class Item_double_typecast :public Item_real_func +class Item_real_typecast: public Item_real_func { +protected: + double val_real_with_truncate(double max_value); public: - Item_double_typecast(THD *thd, Item *a, uint len, uint dec): - Item_real_func(thd, a) + Item_real_typecast(THD *thd, Item *a, uint len, uint dec) + :Item_real_func(thd, a) { decimals= (uint8) dec; max_length= (uint32) len; } - double val_real(); + bool need_parentheses_in_default() { return true; } + void print(String *str, enum_query_type query_type); void fix_length_and_dec_generic() { maybe_null= 1; } +}; + + +class Item_float_typecast :public Item_real_typecast +{ +public: + Item_float_typecast(THD *thd, Item *a) + :Item_real_typecast(thd, a, MAX_FLOAT_STR_LENGTH, NOT_FIXED_DEC) + { } + const Type_handler *type_handler() const { return &type_handler_float; } + bool fix_length_and_dec() + { + return + args[0]->type_handler()->Item_float_typecast_fix_length_and_dec(this); + } + const char *func_name() const { return "float_typecast"; } + double val_real() + { + return (double) (float) val_real_with_truncate(FLT_MAX); + } + String *val_str(String*str) + { + Float nr(Item_float_typecast::val_real()); + if (null_value) + return 0; + nr.to_string(str, decimals); + return str; + } + Item *get_copy(THD *thd) + { return get_item_copy<Item_float_typecast>(thd, this); } +}; + + +class Item_double_typecast :public Item_real_typecast +{ +public: + Item_double_typecast(THD *thd, Item *a, uint len, uint dec): + Item_real_typecast(thd, a, len, dec) + { } bool fix_length_and_dec() { return args[0]->type_handler()->Item_double_typecast_fix_length_and_dec(this); } const char *func_name() const { return "double_typecast"; } - virtual void print(String *str, enum_query_type query_type); - bool need_parentheses_in_default() { return true; } + double val_real() { return val_real_with_truncate(DBL_MAX); } Item *get_copy(THD *thd) { return get_item_copy<Item_double_typecast>(thd, this); } }; @@ -2726,6 +2767,7 @@ public: void cleanup(); Item *get_copy(THD *thd) { return get_item_copy<Item_func_set_user_var>(thd, this); } + bool excl_dep_on_table(table_map tab_map) { return false; } }; diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index 1f1b5a6ceed..9e6c8ea9008 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index e6c198fb8b2..4e7cda137c2 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* This file defines all spatial functions */ diff --git a/sql/item_inetfunc.cc b/sql/item_inetfunc.cc index 379897ac8c1..082584181a4 100644 --- a/sql/item_inetfunc.cc +++ b/sql/item_inetfunc.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "item_inetfunc.h" diff --git a/sql/item_inetfunc.h b/sql/item_inetfunc.h index feeac9fa457..8cfb4cd278c 100644 --- a/sql/item_inetfunc.h +++ b/sql/item_inetfunc.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "item.h" diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 40237ab46a6..a90e7fb3a1a 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -2146,6 +2146,331 @@ null_return: } +static int copy_value_patch(String *str, json_engine_t *je) +{ + int first_key= 1; + + if (je->value_type != JSON_VALUE_OBJECT) + { + const uchar *beg, *end; + + beg= je->value_begin; + + if (!json_value_scalar(je)) + { + if (json_skip_level(je)) + return 1; + end= je->s.c_str; + } + else + end= je->value_end; + + if (append_simple(str, beg, end-beg)) + return 1; + + return 0; + } + /* JSON_VALUE_OBJECT */ + + if (str->append("{", 1)) + return 1; + while (json_scan_next(je) == 0 && je->state != JST_OBJ_END) + { + const uchar *key_start; + /* Loop through the Json_1 keys and compare with the Json_2 keys. */ + DBUG_ASSERT(je->state == JST_KEY); + key_start= je->s.c_str; + + if (json_read_value(je)) + return 1; + + if (je->value_type == JSON_VALUE_NULL) + continue; + + if (!first_key) + { + if (str->append(", ", 2)) + return 3; + } + else + first_key= 0; + + if (str->append("\"", 1) || + append_simple(str, key_start, je->value_begin - key_start) || + copy_value_patch(str, je)) + return 1; + } + if (str->append("}", 1)) + return 1; + + return 0; +} + + +static int do_merge_patch(String *str, json_engine_t *je1, json_engine_t *je2, + bool *empty_result) +{ + if (json_read_value(je1) || json_read_value(je2)) + return 1; + + if (je1->value_type == JSON_VALUE_OBJECT && + je2->value_type == JSON_VALUE_OBJECT) + { + json_engine_t sav_je1= *je1; + json_engine_t sav_je2= *je2; + + int first_key= 1; + json_string_t key_name; + size_t sav_len; + bool mrg_empty; + + *empty_result= FALSE; + json_string_set_cs(&key_name, je1->s.cs); + + if (str->append("{", 1)) + return 3; + while (json_scan_next(je1) == 0 && + je1->state != JST_OBJ_END) + { + const uchar *key_start, *key_end; + /* Loop through the Json_1 keys and compare with the Json_2 keys. */ + DBUG_ASSERT(je1->state == JST_KEY); + key_start= je1->s.c_str; + do + { + key_end= je1->s.c_str; + } while (json_read_keyname_chr(je1) == 0); + + if (je1->s.error) + return 1; + + sav_len= str->length(); + + if (!first_key) + { + if (str->append(", ", 2)) + return 3; + *je2= sav_je2; + } + + if (str->append("\"", 1) || + append_simple(str, key_start, key_end - key_start) || + str->append("\":", 2)) + return 3; + + while (json_scan_next(je2) == 0 && + je2->state != JST_OBJ_END) + { + int ires; + DBUG_ASSERT(je2->state == JST_KEY); + json_string_set_str(&key_name, key_start, key_end); + if (!json_key_matches(je2, &key_name)) + { + if (je2->s.error || json_skip_key(je2)) + return 2; + continue; + } + + /* Json_2 has same key as Json_1. Merge them. */ + if ((ires= do_merge_patch(str, je1, je2, &mrg_empty))) + return ires; + + if (mrg_empty) + str->length(sav_len); + else + first_key= 0; + + goto merged_j1; + } + + if (je2->s.error) + return 2; + + key_start= je1->s.c_str; + /* Just append the Json_1 key value. */ + if (json_skip_key(je1)) + return 1; + if (append_simple(str, key_start, je1->s.c_str - key_start)) + return 3; + first_key= 0; + +merged_j1: + continue; + } + + *je2= sav_je2; + /* + Now loop through the Json_2 keys. + Skip if there is same key in Json_1 + */ + while (json_scan_next(je2) == 0 && + je2->state != JST_OBJ_END) + { + const uchar *key_start, *key_end; + DBUG_ASSERT(je2->state == JST_KEY); + key_start= je2->s.c_str; + do + { + key_end= je2->s.c_str; + } while (json_read_keyname_chr(je2) == 0); + + if (je2->s.error) + return 1; + + *je1= sav_je1; + while (json_scan_next(je1) == 0 && + je1->state != JST_OBJ_END) + { + DBUG_ASSERT(je1->state == JST_KEY); + json_string_set_str(&key_name, key_start, key_end); + if (!json_key_matches(je1, &key_name)) + { + if (je1->s.error || json_skip_key(je1)) + return 2; + continue; + } + if (json_skip_key(je2) || + json_skip_level(je1)) + return 1; + goto continue_j2; + } + + if (je1->s.error) + return 2; + + + sav_len= str->length(); + + if (!first_key && str->append(", ", 2)) + return 3; + + if (str->append("\"", 1) || + append_simple(str, key_start, key_end - key_start) || + str->append("\":", 2)) + return 3; + + if (json_read_value(je2)) + return 1; + + if (je2->value_type == JSON_VALUE_NULL) + str->length(sav_len); + else + { + if (copy_value_patch(str, je2)) + return 1; + first_key= 0; + } + +continue_j2: + continue; + } + + if (str->append("}", 1)) + return 3; + } + else + { + if (!json_value_scalar(je1) && json_skip_level(je1)) + return 1; + + *empty_result= je2->value_type == JSON_VALUE_NULL; + if (!(*empty_result) && copy_value_patch(str, je2)) + return 1; + } + + return 0; +} + + +String *Item_func_json_merge_patch::val_str(String *str) +{ + DBUG_ASSERT(fixed == 1); + json_engine_t je1, je2; + String *js1= args[0]->val_json(&tmp_js1), *js2=NULL; + uint n_arg; + bool empty_result, merge_to_null; + + merge_to_null= args[0]->null_value; + + for (n_arg=1; n_arg < arg_count; n_arg++) + { + js2= args[n_arg]->val_json(&tmp_js2); + if (args[n_arg]->null_value) + { + merge_to_null= true; + goto cont_point; + } + + json_scan_start(&je2, js2->charset(),(const uchar *) js2->ptr(), + (const uchar *) js2->ptr() + js2->length()); + + if (merge_to_null) + { + if (json_read_value(&je2)) + goto error_return; + if (je2.value_type == JSON_VALUE_OBJECT) + { + merge_to_null= true; + goto cont_point; + } + merge_to_null= false; + str->set(js2->ptr(), js2->length(), js2->charset()); + goto cont_point; + } + + str->set_charset(js1->charset()); + str->length(0); + + + json_scan_start(&je1, js1->charset(),(const uchar *) js1->ptr(), + (const uchar *) js1->ptr() + js1->length()); + + if (do_merge_patch(str, &je1, &je2, &empty_result)) + goto error_return; + + if (empty_result) + str->append("null"); + +cont_point: + { + /* Swap str and js1. */ + if (str == &tmp_js1) + { + str= js1; + js1= &tmp_js1; + } + else + { + js1= str; + str= &tmp_js1; + } + } + } + + if (merge_to_null) + goto null_return; + + json_scan_start(&je1, js1->charset(),(const uchar *) js1->ptr(), + (const uchar *) js1->ptr() + js1->length()); + str->length(0); + str->set_charset(js1->charset()); + if (json_nice(&je1, str, Item_func_json_format::LOOSE)) + goto error_return; + + null_value= 0; + return str; + +error_return: + if (je1.s.error) + report_json_error(js1, &je1, 0); + if (je2.s.error) + report_json_error(js2, &je2, n_arg); +null_return: + null_value= 1; + return NULL; +} + + bool Item_func_json_length::fix_length_and_dec() { if (arg_count > 1) diff --git a/sql/item_jsonfunc.h b/sql/item_jsonfunc.h index a4705f012f2..e9b77502e80 100644 --- a/sql/item_jsonfunc.h +++ b/sql/item_jsonfunc.h @@ -289,11 +289,21 @@ public: Item_func_json_array(thd, list) {} String *val_str(String *); bool is_json_type() { return true; } - const char *func_name() const { return "json_merge"; } + const char *func_name() const { return "json_merge_preserve"; } Item *get_copy(THD *thd) { return get_item_copy<Item_func_json_merge>(thd, this); } }; +class Item_func_json_merge_patch: public Item_func_json_merge +{ +public: + Item_func_json_merge_patch(THD *thd, List<Item> &list): + Item_func_json_merge(thd, list) {} + const char *func_name() const { return "json_merge_patch"; } + String *val_str(String *); + Item *get_copy(THD *thd) + { return get_item_copy<Item_func_json_merge_patch>(thd, this); } +}; class Item_func_json_length: public Item_long_func { diff --git a/sql/item_row.cc b/sql/item_row.cc index 665c900cb3a..150d57263b6 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/item_row.h b/sql/item_row.h index 4f60a33ab9f..ea5a0f21d8b 100644 --- a/sql/item_row.h +++ b/sql/item_row.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** Row items used for comparing rows and IN operations on rows: diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 818914e8df3..190df1b9f5a 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 6207e1a7754..3ed5a7036c3 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* This file defines all string functions */ diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index e32a730214a..9f58999d4cc 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file @@ -275,7 +275,7 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref) { if (sl->tvc) { - wrap_tvc_in_derived_table(thd, sl); + wrap_tvc_into_select(thd, sl); } } @@ -720,11 +720,14 @@ bool Item_subselect::exec() DBUG_ASSERT(fixed); DBUG_EXECUTE_IF("Item_subselect", - push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, - ER_UNKNOWN_ERROR, "DBUG: Item_subselect::exec %s", - Item::Print(this, - enum_query_type(QT_TO_SYSTEM_CHARSET | - QT_WITHOUT_INTRODUCERS)).ptr());); + Item::Print print(this, + enum_query_type(QT_TO_SYSTEM_CHARSET | + QT_WITHOUT_INTRODUCERS)); + + push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, + ER_UNKNOWN_ERROR, "DBUG: Item_subselect::exec %.*s", + print.length(),print.ptr()); + ); /* Do not execute subselect in case of a fatal error or if the query has been killed. @@ -2906,7 +2909,6 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg) !upper_not->is_top_level_item())) || first_select->is_part_of_union() || first_select->group_list.elements || - first_select->order_list.elements || join->having || first_select->with_sum_func || !first_select->leaf_tables.elements|| @@ -2914,8 +2916,31 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg) with_recursive_reference) DBUG_RETURN(FALSE); - DBUG_ASSERT(first_select->order_list.elements == 0 && - first_select->group_list.elements == 0 && + /* + EXISTS-to-IN coversion and ORDER BY ... LIMIT clause: + + - "[ORDER BY ...] LIMIT n" clause with a non-zero n does not affect + the result of the EXISTS(...) predicate, and so we can discard + it during the conversion. + - "[ORDER BY ...] LIMIT m, n" can turn a non-empty resultset into empty + one, so it affects tthe EXISTS(...) result and cannot be discarded. + + Disallow exists-to-in conversion if + (1). three is a LIMIT which is not a basic constant + (1a) or is a "LIMIT 0" (see MDEV-19429) + (2). there is an OFFSET clause + */ + if ((first_select->select_limit && // (1) + (!first_select->select_limit->basic_const_item() || // (1) + first_select->select_limit->val_uint() == 0)) || // (1a) + first_select->offset_limit) // (2) + { + DBUG_RETURN(FALSE); + } + + /* Disallow the conversion if offset + limit exists */ + + DBUG_ASSERT(first_select->group_list.elements == 0 && first_select->having == NULL); if (find_inner_outer_equalities(&join->conds, eqs)) @@ -2946,9 +2971,6 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg) if ((uint)eqs.elements() > (first_select->item_list.elements + first_select->select_n_reserved)) goto out; - /* It is simple query */ - DBUG_ASSERT(first_select->join->all_fields.elements == - first_select->item_list.elements); arena= thd->activate_stmt_arena_if_needed(&backup); @@ -3204,21 +3226,6 @@ Item_in_subselect::select_in_like_transformer(JOIN *join) DBUG_ENTER("Item_in_subselect::select_in_like_transformer"); DBUG_ASSERT(thd == join->thd); - - /* - IN/SOME/ALL/ANY subqueries aren't support LIMIT clause. Without it - ORDER BY clause becomes meaningless thus we drop it here. - */ - for (SELECT_LEX *sl= current->master_unit()->first_select(); - sl; sl= sl->next_select()) - { - if (sl->join) - { - sl->join->order= 0; - sl->join->skip_sort_order= 1; - } - } - thd->where= "IN/ALL/ANY subquery"; /* diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 6b66ccc8fe7..dc8417495c5 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* subselect Item */ @@ -273,7 +273,7 @@ public: Item* build_clone(THD *thd) { return 0; } Item* get_copy(THD *thd) { return 0; } - bool wrap_tvc_in_derived_table(THD *thd, st_select_lex *tvc_sl); + bool wrap_tvc_into_select(THD *thd, st_select_lex *tvc_sl); friend class select_result_interceptor; friend class Item_in_optimizer; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index e1c8af98dd7..e03778be2a3 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @@ -3697,6 +3697,7 @@ Item_func_group_concat::Item_func_group_concat(THD *thd, tmp_table_param(item->tmp_table_param), separator(item->separator), tree(item->tree), + tree_len(item->tree_len), unique_filter(item->unique_filter), table(item->table), context(item->context), @@ -3809,7 +3810,10 @@ void Item_func_group_concat::clear() if (row_limit) copy_row_limit= row_limit->val_int(); if (tree) + { reset_tree(tree); + tree_len= 0; + } if (unique_filter) unique_filter->reset(); if (table && table->blob_storage) @@ -3817,6 +3821,62 @@ void Item_func_group_concat::clear() /* No need to reset the table as we never call write_row */ } +struct st_repack_tree { + TREE tree; + TABLE *table; + size_t len, maxlen; +}; + +extern "C" +int copy_to_tree(void* key, element_count count __attribute__((unused)), + void* arg) +{ + struct st_repack_tree *st= (struct st_repack_tree*)arg; + TABLE *table= st->table; + Field* field= table->field[0]; + const uchar *ptr= field->ptr_in_record((uchar*)key - table->s->null_bytes); + size_t len= (size_t)field->val_int(ptr); + + DBUG_ASSERT(count == 1); + if (!tree_insert(&st->tree, key, 0, st->tree.custom_arg)) + return 1; + + st->len += len; + return st->len > st->maxlen; +} + +bool Item_func_group_concat::repack_tree(THD *thd) +{ + struct st_repack_tree st; + + init_tree(&st.tree, (size_t) MY_MIN(thd->variables.max_heap_table_size, + thd->variables.sortbuff_size/16), 0, + tree->size_of_element, group_concat_key_cmp_with_order, NULL, + (void*) this, MYF(MY_THREAD_SPECIFIC)); + st.table= table; + st.len= 0; + st.maxlen= (size_t)thd->variables.group_concat_max_len; + tree_walk(tree, ©_to_tree, &st, left_root_right); + if (st.len <= st.maxlen) // Copying aborted. Must be OOM + { + delete_tree(&st.tree, 0); + return 1; + } + delete_tree(tree, 0); + *tree= st.tree; + tree_len= st.len; + return 0; +} + +/* + Repacking the tree is expensive. But it keeps the tree small, and + inserting into an unnecessary large tree is also waste of time. + + The following number is best-by-test. Test execution time slowly + decreases up to N=10 (that is, factor=1024) and then starts to increase, + again, very slowly. +*/ +#define GCONCAT_REPACK_FACTOR (1 << 10) bool Item_func_group_concat::add() { @@ -3826,6 +3886,9 @@ bool Item_func_group_concat::add() if (copy_funcs(tmp_table_param->items_to_copy, table->in_use)) return TRUE; + size_t row_str_len= 0; + StringBuffer<MAX_FIELD_WIDTH> buf; + String *res; for (uint i= 0; i < arg_count_field; i++) { Item *show_item= args[i]; @@ -3833,8 +3896,13 @@ bool Item_func_group_concat::add() continue; Field *field= show_item->get_tmp_table_field(); - if (field && field->is_null_in_record((const uchar*) table->record[0])) - return 0; // Skip row if it contains null + if (field) + { + if (field->is_null_in_record((const uchar*) table->record[0])) + return 0; // Skip row if it contains null + if (tree && (res= field->val_str(&buf))) + row_str_len+= res->length(); + } } null_value= FALSE; @@ -3852,11 +3920,18 @@ bool Item_func_group_concat::add() TREE_ELEMENT *el= 0; // Only for safety if (row_eligible && tree) { + THD *thd= table->in_use; + table->field[0]->store(row_str_len, FALSE); + if (tree_len > thd->variables.group_concat_max_len * GCONCAT_REPACK_FACTOR + && tree->elements_in_tree > 1) + if (repack_tree(thd)) + return 1; el= tree_insert(tree, table->record[0] + table->s->null_bytes, 0, tree->custom_arg); /* check if there was enough memory to insert the row */ if (!el) return 1; + tree_len+= row_str_len; } /* If the row is not a duplicate (el->count == 1) @@ -3988,10 +4063,19 @@ bool Item_func_group_concat::setup(THD *thd) if (setup_order(thd, Ref_ptr_array(ref_pointer_array, n_elems), context->table_list, list, all_fields, *order)) DBUG_RETURN(TRUE); + /* + Prepend the field to store the length of the string representation + of this row. Used to detect when the tree goes over group_concat_max_len + */ + Item *item= new (thd->mem_root) + Item_uint(thd, thd->variables.group_concat_max_len); + if (!item || all_fields.push_front(item, thd->mem_root)) + DBUG_RETURN(TRUE); } count_field_types(select_lex, tmp_table_param, all_fields, 0); tmp_table_param->force_copy_fields= force_copy_fields; + tmp_table_param->hidden_field_count= (arg_count_order > 0); DBUG_ASSERT(table == 0); if (order_or_distinct) { @@ -4051,10 +4135,11 @@ bool Item_func_group_concat::setup(THD *thd) create this tree. */ init_tree(tree, (size_t)MY_MIN(thd->variables.max_heap_table_size, - thd->variables.sortbuff_size/16), 0, - tree_key_length, + thd->variables.sortbuff_size/16), 0, + tree_key_length, group_concat_key_cmp_with_order, NULL, (void*) this, MYF(MY_THREAD_SPECIFIC)); + tree_len= 0; } if (distinct) diff --git a/sql/item_sum.h b/sql/item_sum.h index abe6192fcd1..59b8f824c72 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* classes for sum functions */ @@ -1799,6 +1799,7 @@ class Item_func_group_concat : public Item_sum String *separator; TREE tree_base; TREE *tree; + size_t tree_len; Item **ref_pointer_array; /** @@ -1845,6 +1846,9 @@ class Item_func_group_concat : public Item_sum friend int dump_leaf_key(void* key_arg, element_count count __attribute__((unused)), void* item_arg); + + bool repack_tree(THD *thd); + public: // Methods used by ColumnStore bool get_distinct() const { return distinct; } @@ -1909,8 +1913,8 @@ public: String* val_str(String* str); Item *copy_or_same(THD* thd); void no_rows_in_result() {} - virtual void print(String *str, enum_query_type query_type); - virtual bool change_context_processor(void *cntx) + void print(String *str, enum_query_type query_type); + bool change_context_processor(void *cntx) { context= (Name_resolution_context *)cntx; return FALSE; } Item *get_copy(THD *thd) { return get_item_copy<Item_func_group_concat>(thd, this); } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 2627d5413a2..81d5bfed981 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index d9ab45ed46d..987bd1c8595 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* Function items used by mysql */ diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index 146c5aa57fe..d879c6c2abc 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/item_xmlfunc.h b/sql/item_xmlfunc.h index 6846063aab7..9a0f1d53609 100644 --- a/sql/item_xmlfunc.h +++ b/sql/item_xmlfunc.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* This file defines all XML functions */ diff --git a/sql/key.cc b/sql/key.cc index 9ad1103fbe8..bf50094a9e4 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Functions to handle keys and fields in forms */ diff --git a/sql/key.h b/sql/key.h index 523d0b7f10b..45f58c75655 100644 --- a/sql/key.h +++ b/sql/key.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef KEY_INCLUDED #define KEY_INCLUDED diff --git a/sql/keycaches.cc b/sql/keycaches.cc index 9db51ee1801..f38a43f83cf 100644 --- a/sql/keycaches.cc +++ b/sql/keycaches.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "keycaches.h" diff --git a/sql/keycaches.h b/sql/keycaches.h index ff0380ba09a..9da93e5f7ba 100644 --- a/sql/keycaches.h +++ b/sql/keycaches.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "sql_list.h" #include <keycache.h> diff --git a/sql/lex.h b/sql/lex.h index bb57f308475..ec657ff48df 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* This file includes all reserved words and functions */ diff --git a/sql/lex_symbol.h b/sql/lex_symbol.h index d48ca57df85..e7819cd4e2f 100644 --- a/sql/lex_symbol.h +++ b/sql/lex_symbol.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* This struct includes all reserved words and functions */ diff --git a/sql/lock.cc b/sql/lock.cc index 01e0f418179..94e0d2733c7 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** diff --git a/sql/lock.h b/sql/lock.h index e9324c80d89..e5036ea032c 100644 --- a/sql/lock.h +++ b/sql/lock.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef LOCK_INCLUDED #define LOCK_INCLUDED diff --git a/sql/log.cc b/sql/log.cc index 22b4e1852f0..30a966ed95f 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @@ -8687,14 +8687,14 @@ void sql_perror(const char *message) redirect stdout and stderr to a file. The streams are reopened only for appending (writing at end of file). */ -extern "C" my_bool reopen_fstreams(const char *filename, - FILE *outstream, FILE *errstream) +bool reopen_fstreams(const char *filename, FILE *outstream, FILE *errstream) { - if (outstream && !my_freopen(filename, "a", outstream)) - return TRUE; - - if (errstream && !my_freopen(filename, "a", errstream)) + if ((outstream && !my_freopen(filename, "a", outstream)) || + (errstream && !my_freopen(filename, "a", errstream))) + { + my_error(ER_CANT_CREATE_FILE, MYF(0), filename, errno); return TRUE; + } /* The error stream must be unbuffered. */ if (errstream) diff --git a/sql/log.h b/sql/log.h index 4cdbf300fb9..52bab149381 100644 --- a/sql/log.h +++ b/sql/log.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef LOG_H #define LOG_H @@ -25,6 +25,7 @@ class Relay_log_info; class Format_description_log_event; +bool reopen_fstreams(const char *filename, FILE *outstream, FILE *errstream); void setup_log_handling(); bool trans_has_updated_trans_table(const THD* thd); bool stmt_has_updated_trans_table(const THD *thd); diff --git a/sql/log_event.cc b/sql/log_event.cc index d1d7576af6c..471b5780c3b 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" diff --git a/sql/log_event.h b/sql/log_event.h index 339db756aab..274182af841 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @addtogroup Replication diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index b5381ec6d74..829a278f215 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2007, 2018, Oracle and/or its affiliates. - Copyright (c) 2009, 2018, MariaDB +/* Copyright (c) 2007, 2019, Oracle and/or its affiliates. + Copyright (c) 2009, 2019, MariaDB 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 @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" @@ -101,21 +101,20 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, rpl_group_info *rgi) if (unlikely(open_and_lock_tables(ev_thd, rgi->tables_to_lock, FALSE, 0))) { - uint actual_error= ev_thd->get_stmt_da()->sql_errno(); - if (ev_thd->is_slave_error || ev_thd->is_fatal_error) + if (ev_thd->is_error()) { /* Error reporting borrowed from Query_log_event with many excessive - simplifications (we don't honour --slave-skip-errors) + simplifications. + We should not honour --slave-skip-errors at this point as we are + having severe errors which should not be skipped. */ - rli->report(ERROR_LEVEL, actual_error, NULL, + rli->report(ERROR_LEVEL, ev_thd->get_stmt_da()->sql_errno(), NULL, "Error '%s' on opening tables", - (actual_error ? ev_thd->get_stmt_da()->message() : - "unexpected success or fatal error")); + ev_thd->get_stmt_da()->message()); ev_thd->is_slave_error= 1; } - rgi->slave_close_thread_tables(thd); - DBUG_RETURN(actual_error); + DBUG_RETURN(1); } /* diff --git a/sql/log_event_old.h b/sql/log_event_old.h index d18c980bdfe..3a11313a31f 100644 --- a/sql/log_event_old.h +++ b/sql/log_event_old.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef LOG_EVENT_OLD_H #define LOG_EVENT_OLD_H diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 85e5e88f758..58531e011f7 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2018, Oracle and/or its affiliates. + Copyright (c) 2000, 2019, Oracle and/or its affiliates. Copyright (c) 2009, 2019, MariaDB This program is free software; you can redistribute it and/or modify @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" @@ -46,6 +46,7 @@ #include "transaction.h" #include <my_dir.h> #include "sql_show.h" // append_identifier +#include "debug_sync.h" // debug_sync #include <mysql/psi/mysql_statement.h> #include <strfunc.h> #include "compat56.h" @@ -5161,6 +5162,12 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) /* A small test to verify that objects have consistent types */ DBUG_ASSERT(sizeof(thd->variables.option_bits) == sizeof(OPTION_RELAXED_UNIQUE_CHECKS)); + DBUG_EXECUTE_IF("rows_log_event_before_open_table", + { + const char action[] = "now SIGNAL before_open_table WAIT_FOR go_ahead_sql"; + DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(action))); + };); + if (slave_run_triggers_for_rbr) { LEX *lex= thd->lex; @@ -5185,7 +5192,6 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) } if (unlikely(open_and_lock_tables(thd, rgi->tables_to_lock, FALSE, 0))) { - uint actual_error= thd->get_stmt_da()->sql_errno(); #ifdef WITH_WSREP if (WSREP(thd)) { @@ -5198,23 +5204,22 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) (long long) wsrep_thd_trx_seqno(thd)); } #endif /* WITH_WSREP */ - if ((thd->is_slave_error || thd->is_fatal_error) && - !is_parallel_retry_error(rgi, actual_error)) + if (thd->is_error() && + !is_parallel_retry_error(rgi, error= thd->get_stmt_da()->sql_errno())) { /* Error reporting borrowed from Query_log_event with many excessive - simplifications. + simplifications. We should not honour --slave-skip-errors at this point as we are - having severe errors which should not be skiped. + having severe errors which should not be skipped. */ - rli->report(ERROR_LEVEL, actual_error, rgi->gtid_info(), + rli->report(ERROR_LEVEL, error, rgi->gtid_info(), "Error executing row event: '%s'", - (actual_error ? thd->get_stmt_da()->message() : + (error ? thd->get_stmt_da()->message() : "unexpected success or fatal error")); thd->is_slave_error= 1; } /* remove trigger's tables */ - error= actual_error; goto err; } diff --git a/sql/log_slow.h b/sql/log_slow.h index 8322f94ee3c..c6b3407a811 100644 --- a/sql/log_slow.h +++ b/sql/log_slow.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* Defining what to log to slow log */ diff --git a/sql/main.cc b/sql/main.cc index 10141c132a6..957efb8fa2e 100644 --- a/sql/main.cc +++ b/sql/main.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* main() for mysqld. diff --git a/sql/mdl.cc b/sql/mdl.cc index ccd7a71e9f4..591127dc1d8 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" diff --git a/sql/mdl.h b/sql/mdl.h index 3d0c86f8f1c..b084670e5c6 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "sql_plist.h" #include <my_sys.h> diff --git a/sql/mem_root_array.h b/sql/mem_root_array.h index bf266a60334..3d03a5a5db2 100644 --- a/sql/mem_root_array.h +++ b/sql/mem_root_array.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef MEM_ROOT_ARRAY_INCLUDED diff --git a/sql/mf_iocache.cc b/sql/mf_iocache.cc index 495d78804b0..c9cff6ad930 100644 --- a/sql/mf_iocache.cc +++ b/sql/mf_iocache.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/mf_iocache_encr.cc b/sql/mf_iocache_encr.cc index d2e6d554ba7..b27f10c7d72 100644 --- a/sql/mf_iocache_encr.cc +++ b/sql/mf_iocache_encr.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /************************************************************************* Limitation of encrypted IO_CACHEs diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index 027d2f71d85..8c6b0de368d 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_parse.h" diff --git a/sql/multi_range_read.h b/sql/multi_range_read.h index 56761e3623f..85578aa312c 100644 --- a/sql/multi_range_read.h +++ b/sql/multi_range_read.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @defgroup DS-MRR declarations diff --git a/sql/my_apc.cc b/sql/my_apc.cc index 9a0310234a2..e0feabab8e2 100644 --- a/sql/my_apc.cc +++ b/sql/my_apc.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef MY_APC_STANDALONE diff --git a/sql/my_apc.h b/sql/my_apc.h index a04e09257b9..cc98e36bbe4 100644 --- a/sql/my_apc.h +++ b/sql/my_apc.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* Interface diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc index b57ac234fdc..b974026bb65 100644 --- a/sql/my_decimal.cc +++ b/sql/my_decimal.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/my_decimal.h b/sql/my_decimal.h index c196d43e001..9910f436e05 100644 --- a/sql/my_decimal.h +++ b/sql/my_decimal.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/my_json_writer.cc b/sql/my_json_writer.cc index 3755f8d4bcb..4bd80f106ba 100644 --- a/sql/my_json_writer.cc +++ b/sql/my_json_writer.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/my_json_writer.h b/sql/my_json_writer.h index 8f86212ac30..2c27043e74e 100644 --- a/sql/my_json_writer.h +++ b/sql/my_json_writer.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef JSON_WRITER_INCLUDED #define JSON_WRITER_INCLUDED diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc index 93a3b54bdc2..85507a0abde 100644 --- a/sql/mysql_install_db.cc +++ b/sql/mysql_install_db.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* mysql_install_db creates a new database instance (optionally as service) diff --git a/sql/mysql_upgrade_service.cc b/sql/mysql_upgrade_service.cc index 58383df9c56..6a15364c849 100644 --- a/sql/mysql_upgrade_service.cc +++ b/sql/mysql_upgrade_service.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* mysql_upgrade_service upgrades mysql service on Windows. @@ -159,8 +159,9 @@ static void die(const char *fmt, ...) #define WRITE_LOG(fmt,...) {\ char log_buf[1024]; \ + DWORD nbytes; \ snprintf(log_buf,sizeof(log_buf), fmt, __VA_ARGS__);\ - WriteFile(logfile_handle,log_buf, (DWORD)strlen(log_buf), 0 , 0);\ + WriteFile(logfile_handle,log_buf, (DWORD)strlen(log_buf), &nbytes , 0);\ } /* diff --git a/sql/mysqld.cc b/sql/mysqld.cc index cf0e7bad9c8..d3eb76f22f0 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "sql_plugin.h" // Includes mariadb.h #include "sql_priv.h" @@ -215,9 +215,6 @@ typedef fp_except fp_except_t; #define fcntl(X,Y,Z) 0 #endif -extern "C" my_bool reopen_fstreams(const char *filename, - FILE *outstream, FILE *errstream); - inline void setup_fpu() { #if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H) && !defined(HAVE_FEDISABLEEXCEPT) @@ -3776,6 +3773,39 @@ static int init_early_variables() return 0; } +#ifdef _WIN32 +static void get_win_tzname(char* buf, size_t size) +{ + static struct + { + const wchar_t* windows_name; + const char* tzdb_name; + } + tz_data[] = + { +#include "win_tzname_data.h" + {0,0} + }; + DYNAMIC_TIME_ZONE_INFORMATION tzinfo; + if (GetDynamicTimeZoneInformation(&tzinfo) == TIME_ZONE_ID_UNKNOWN) + { + strncpy(buf, "unknown", size); + return; + } + + for (size_t i= 0; tz_data[i].windows_name; i++) + { + if (wcscmp(tzinfo.TimeZoneKeyName, tz_data[i].windows_name) == 0) + { + strncpy(buf, tz_data[i].tzdb_name, size); + return; + } + } + wcstombs(buf, tzinfo.TimeZoneKeyName, size); + buf[size-1]= 0; + return; +} +#endif static int init_common_variables() { @@ -3831,22 +3861,13 @@ static int init_common_variables() if (ignore_db_dirs_init()) exit(1); -#ifdef HAVE_TZNAME +#ifdef _WIN32 + get_win_tzname(system_time_zone, sizeof(system_time_zone)); +#elif defined(HAVE_TZNAME) struct tm tm_tmp; localtime_r(&server_start_time,&tm_tmp); const char *tz_name= tzname[tm_tmp.tm_isdst != 0 ? 1 : 0]; -#ifdef _WIN32 - /* - Time zone name may be localized and contain non-ASCII characters, - Convert from ANSI encoding to UTF8. - */ - wchar_t wtz_name[sizeof(system_time_zone)]; - mbstowcs(wtz_name, tz_name, sizeof(system_time_zone)-1); - WideCharToMultiByte(CP_UTF8,0, wtz_name, -1, system_time_zone, - sizeof(system_time_zone) - 1, NULL, NULL); -#else strmake_buf(system_time_zone, tz_name); -#endif /* _WIN32 */ #endif /* HAVE_TZNAME */ /* @@ -6915,7 +6936,6 @@ struct my_option my_long_options[]= MYSQL_TO_BE_IMPLEMENTED_OPTION("optimizer-trace-features"), // OPTIMIZER_TRACE MYSQL_TO_BE_IMPLEMENTED_OPTION("optimizer-trace-offset"), // OPTIMIZER_TRACE MYSQL_TO_BE_IMPLEMENTED_OPTION("optimizer-trace-limit"), // OPTIMIZER_TRACE - MYSQL_TO_BE_IMPLEMENTED_OPTION("eq-range-index-dive-limit"), MYSQL_COMPATIBILITY_OPTION("server-id-bits"), MYSQL_TO_BE_IMPLEMENTED_OPTION("slave-rows-search-algorithms"), // HAVE_REPLICATION MYSQL_TO_BE_IMPLEMENTED_OPTION("slave-allow-batching"), // HAVE_REPLICATION @@ -7548,7 +7568,7 @@ SHOW_VAR status_vars[]= { {"Memory_used", (char*) &show_memory_used, SHOW_SIMPLE_FUNC}, {"Memory_used_initial", (char*) &start_memory_used, SHOW_LONGLONG}, {"Not_flushed_delayed_rows", (char*) &delayed_rows_in_use, SHOW_LONG_NOFLUSH}, - {"Open_files", (char*) &my_file_opened, SHOW_LONG_NOFLUSH}, + {"Open_files", (char*) &my_file_opened, SHOW_SINT}, {"Open_streams", (char*) &my_stream_opened, SHOW_LONG_NOFLUSH}, {"Open_table_definitions", (char*) &show_table_definitions, SHOW_SIMPLE_FUNC}, {"Open_tables", (char*) &show_open_tables, SHOW_SIMPLE_FUNC}, diff --git a/sql/mysqld.h b/sql/mysqld.h index ec14455201f..4ef8102495b 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef MYSQLD_INCLUDED #define MYSQLD_INCLUDED @@ -59,7 +59,7 @@ typedef struct st_mysql_show_var SHOW_VAR; #define OPT_SESSION SHOW_OPT_SESSION #define OPT_GLOBAL SHOW_OPT_GLOBAL -extern MY_TIMER_INFO sys_timer_info; +extern MYSQL_PLUGIN_IMPORT MY_TIMER_INFO sys_timer_info; /* Values for --slave-parallel-mode @@ -791,26 +791,6 @@ inline void table_case_convert(char * name, uint length) name, length, name, length); } -inline void thread_safe_increment32(int32 *value) -{ - (void) my_atomic_add32_explicit(value, 1, MY_MEMORY_ORDER_RELAXED); -} - -inline void thread_safe_decrement32(int32 *value) -{ - (void) my_atomic_add32_explicit(value, -1, MY_MEMORY_ORDER_RELAXED); -} - -inline void thread_safe_increment64(int64 *value) -{ - (void) my_atomic_add64_explicit(value, 1, MY_MEMORY_ORDER_RELAXED); -} - -inline void thread_safe_decrement64(int64 *value) -{ - (void) my_atomic_add64_explicit(value, -1, MY_MEMORY_ORDER_RELAXED); -} - extern void set_server_version(char *buf, size_t size); #define current_thd _current_thd() diff --git a/sql/mysqld_suffix.h b/sql/mysqld_suffix.h index fd515ac5998..3c36ba2bc91 100644 --- a/sql/mysqld_suffix.h +++ b/sql/mysqld_suffix.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/net_serv.cc b/sql/net_serv.cc index c289fb2bc85..4fecf8bffd0 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/opt_index_cond_pushdown.cc b/sql/opt_index_cond_pushdown.cc index 60312b470b3..a87d5664e29 100644 --- a/sql/opt_index_cond_pushdown.cc +++ b/sql/opt_index_cond_pushdown.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_select.h" diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 0eaebfe9dc3..7e432aca42a 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* TODO: @@ -3381,7 +3381,7 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) if (thd->variables.optimizer_use_condition_selectivity > 2 && !bitmap_is_clear_all(used_fields) && - thd->variables.use_stat_tables > 0) + thd->variables.use_stat_tables > 0 && table->stats_is_read) { PARAM param; MEM_ROOT alloc; diff --git a/sql/opt_range.h b/sql/opt_range.h index 2dab90b9f69..98f6284da0f 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* classes to use when handling where clause */ diff --git a/sql/opt_range_mrr.cc b/sql/opt_range_mrr.cc index 2981c8182ea..3a25da3edb2 100644 --- a/sql/opt_range_mrr.cc +++ b/sql/opt_range_mrr.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /**************************************************************************** MRR Range Sequence Interface implementation that walks a SEL_ARG* tree. diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 2d99b4d72be..d80603c5ebc 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file @@ -594,7 +594,8 @@ int check_and_do_in_subquery_rewrites(JOIN *join) { Item_in_subselect *in_subs= NULL; Item_allany_subselect *allany_subs= NULL; - switch (subselect->substype()) { + Item_subselect::subs_type substype= subselect->substype(); + switch (substype) { case Item_subselect::IN_SUBS: in_subs= (Item_in_subselect *)subselect; break; @@ -606,6 +607,26 @@ int check_and_do_in_subquery_rewrites(JOIN *join) break; } + /* + Try removing "ORDER BY" or even "ORDER BY ... LIMIT" from certain kinds + of subqueries. The removal might enable further transformations. + */ + if (substype == Item_subselect::IN_SUBS || + substype == Item_subselect::EXISTS_SUBS || + substype == Item_subselect::ANY_SUBS || + substype == Item_subselect::ALL_SUBS) + { + // (1) - ORDER BY without LIMIT can be removed from IN/EXISTS subqueries + // (2) - for EXISTS, can also remove "ORDER BY ... LIMIT n", + // but cannot remove "ORDER BY ... LIMIT n OFFSET m" + if (!select_lex->select_limit || // (1) + (substype == Item_subselect::EXISTS_SUBS && // (2) + !select_lex->offset_limit)) // (2) + { + select_lex->join->order= 0; + select_lex->join->skip_sort_order= 1; + } + } /* Resolve expressions and perform semantic analysis for IN query */ if (in_subs != NULL) diff --git a/sql/opt_subselect.h b/sql/opt_subselect.h index 7af818bd62d..65131f6bc89 100644 --- a/sql/opt_subselect.h +++ b/sql/opt_subselect.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* Semi-join subquery optimization code definitions diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index ecede5903a2..0a3c30a176d 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** diff --git a/sql/opt_table_elimination.cc b/sql/opt_table_elimination.cc index 422b21cb541..3958797ec44 100644 --- a/sql/opt_table_elimination.cc +++ b/sql/opt_table_elimination.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/parse_file.cc b/sql/parse_file.cc index 751ca180f97..59b4027a352 100644 --- a/sql/parse_file.cc +++ b/sql/parse_file.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/parse_file.h b/sql/parse_file.h index 19c7883f8cc..cbd41d16cbc 100644 --- a/sql/parse_file.h +++ b/sql/parse_file.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef _PARSE_FILE_H_ #define _PARSE_FILE_H_ diff --git a/sql/partition_element.h b/sql/partition_element.h index 2c89562adda..a3eb6953be1 100644 --- a/sql/partition_element.h +++ b/sql/partition_element.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "my_base.h" /* ha_rows */ #include "handler.h" /* UNDEF_NODEGROUP */ diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 34ccdbc1686..ba6fc8a49ec 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Some general useful functions */ diff --git a/sql/partition_info.h b/sql/partition_info.h index c7d8e16dfeb..a2320c34048 100644 --- a/sql/partition_info.h +++ b/sql/partition_info.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ @@ -401,11 +401,20 @@ public: DBUG_ASSERT(part_type == VERSIONING_PARTITION); vers_info->interval.type= int_type; vers_info->interval.start= start; - return get_interval_value(thd, item, int_type, &vers_info->interval.step) || + if (item->fix_fields_if_needed_for_scalar(thd, &item)) + return true; + bool error= get_interval_value(thd, item, int_type, &vers_info->interval.step) || vers_info->interval.step.neg || vers_info->interval.step.second_part || !(vers_info->interval.step.year || vers_info->interval.step.month || vers_info->interval.step.day || vers_info->interval.step.hour || vers_info->interval.step.minute || vers_info->interval.step.second); + if (error) + { + my_error(ER_PART_WRONG_VALUE, MYF(0), + thd->lex->create_last_non_select_table->table_name.str, + "INTERVAL"); + } + return error; } bool vers_set_limit(ulonglong limit) { diff --git a/sql/password.c b/sql/password.c index 75ac210acd3..d824e61586a 100644 --- a/sql/password.c +++ b/sql/password.c @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* password checking routines */ /***************************************************************************** diff --git a/sql/plistsort.c b/sql/plistsort.c index e66bd7c7276..6efea273963 100644 --- a/sql/plistsort.c +++ b/sql/plistsort.c @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* diff --git a/sql/procedure.cc b/sql/procedure.cc index d5b93433f92..92df43bb0e3 100644 --- a/sql/procedure.cc +++ b/sql/procedure.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Procedures (functions with changes output of select) */ diff --git a/sql/procedure.h b/sql/procedure.h index 2bbdd906151..15fd525ec65 100644 --- a/sql/procedure.h +++ b/sql/procedure.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* When using sql procedures */ diff --git a/sql/protocol.cc b/sql/protocol.cc index ffed17634c0..83b4dc80ae2 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file @@ -1228,7 +1228,7 @@ bool Protocol_text::store(float from, uint32 decimals, String *buffer) DBUG_ASSERT(valid_handler(field_pos, PROTOCOL_SEND_FLOAT)); field_pos++; #endif - buffer->set_real((double) from, decimals, thd->charset()); + Float(from).to_string(buffer, decimals); return net_store_data((uchar*) buffer->ptr(), buffer->length()); } diff --git a/sql/protocol.h b/sql/protocol.h index 70a097c9e32..3b2c905ed9e 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ diff --git a/sql/records.cc b/sql/records.cc index 59601ae99f3..3decb8f1d24 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_INTERFACE #pragma implementation /* gcc class implementation */ diff --git a/sql/records.h b/sql/records.h index f6a5069840d..4f8e14da9ac 100644 --- a/sql/records.h +++ b/sql/records.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index e7873b185c5..18fc3d9431a 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/repl_failsafe.h b/sql/repl_failsafe.h index 7f81b98303e..6f8bdfc5216 100644 --- a/sql/repl_failsafe.h +++ b/sql/repl_failsafe.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef HAVE_REPLICATION diff --git a/sql/replication.h b/sql/replication.h index d8672310110..49d896ff1a7 100644 --- a/sql/replication.h +++ b/sql/replication.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef REPLICATION_H #define REPLICATION_H diff --git a/sql/rpl_constants.h b/sql/rpl_constants.h index 0a7fde439dd..f319d08303c 100644 --- a/sql/rpl_constants.h +++ b/sql/rpl_constants.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef RPL_CONSTANTS_H #define RPL_CONSTANTS_H diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc index 3fda2761430..b167b849923 100644 --- a/sql/rpl_filter.cc +++ b/sql/rpl_filter.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/rpl_filter.h b/sql/rpl_filter.h index f24ece30a80..f22ec8a0ce4 100644 --- a/sql/rpl_filter.h +++ b/sql/rpl_filter.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef RPL_FILTER_H #define RPL_FILTER_H diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc index 17f474c2acf..6ab216188ee 100644 --- a/sql/rpl_gtid.cc +++ b/sql/rpl_gtid.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Definitions for MariaDB global transaction ID (GTID). */ @@ -877,6 +877,7 @@ rpl_slave_state::gtid_delete_pending(THD *thd, handler::Table_flags direct_pos; list_element *cur, **cur_ptr_ptr; bool table_opened= false; + bool index_inited= false; void *hton= (*list_ptr)->hton; thd->reset_for_next_command(); @@ -915,10 +916,14 @@ rpl_slave_state::gtid_delete_pending(THD *thd, bitmap_set_bit(table->read_set, table->field[0]->field_index); bitmap_set_bit(table->read_set, table->field[1]->field_index); - if (!direct_pos && (err= table->file->ha_index_init(0, 0))) + if (!direct_pos) { - table->file->print_error(err, MYF(0)); - goto end; + if ((err= table->file->ha_index_init(0, 0))) + { + table->file->print_error(err, MYF(0)); + goto end; + } + index_inited= true; } cur = *list_ptr; @@ -977,7 +982,14 @@ rpl_slave_state::gtid_delete_pending(THD *thd, end: if (table_opened) { - if (!direct_pos) + DBUG_ASSERT(direct_pos || index_inited || err); + /* + Index may not be initialized if there was a failure during + 'ha_index_init'. Hence check if index initialization is successful and + then invoke ha_index_end(). Ending an index which is not initialized + will lead to assert. + */ + if (index_inited) table->file->ha_index_end(); if (err || (err= ha_commit_trans(thd, FALSE))) diff --git a/sql/rpl_gtid.h b/sql/rpl_gtid.h index 60d822f7b0d..167d7461a7e 100644 --- a/sql/rpl_gtid.h +++ b/sql/rpl_gtid.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef RPL_GTID_H #define RPL_GTID_H diff --git a/sql/rpl_injector.cc b/sql/rpl_injector.cc index 3c0ec34f352..597a357e4e2 100644 --- a/sql/rpl_injector.cc +++ b/sql/rpl_injector.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/rpl_injector.h b/sql/rpl_injector.h index bfb53a38d90..ecf16ba28cf 100644 --- a/sql/rpl_injector.h +++ b/sql/rpl_injector.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef INJECTOR_H #define INJECTOR_H diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index 8d3e146f4c5..785a5b61b5f 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" // For HAVE_REPLICATION #include "sql_priv.h" diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h index 5de73254ed9..4d47689ac18 100644 --- a/sql/rpl_mi.h +++ b/sql/rpl_mi.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef RPL_MI_H #define RPL_MI_H diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc index 84661fa513d..5a4b9516690 100644 --- a/sql/rpl_record.cc +++ b/sql/rpl_record.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/rpl_record.h b/sql/rpl_record.h index 8d565845c4b..357dc7619f9 100644 --- a/sql/rpl_record.h +++ b/sql/rpl_record.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef RPL_RECORD_H #define RPL_RECORD_H diff --git a/sql/rpl_record_old.cc b/sql/rpl_record_old.cc index 523049cf959..496e781d2eb 100644 --- a/sql/rpl_record_old.cc +++ b/sql/rpl_record_old.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/rpl_record_old.h b/sql/rpl_record_old.h index 34ef9f11c47..0b2dd432138 100644 --- a/sql/rpl_record_old.h +++ b/sql/rpl_record_old.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef RPL_RECORD_OLD_H #define RPL_RECORD_OLD_H diff --git a/sql/rpl_reporting.cc b/sql/rpl_reporting.cc index 800682fab91..738ae52782d 100644 --- a/sql/rpl_reporting.cc +++ b/sql/rpl_reporting.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/rpl_reporting.h b/sql/rpl_reporting.h index 17748f587b1..62b934c1527 100644 --- a/sql/rpl_reporting.h +++ b/sql/rpl_reporting.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef RPL_REPORTING_H #define RPL_REPORTING_H diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 2d91620c898..69c57b2959c 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index b8b153c34be..0e2e42fcb08 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef RPL_RLI_H #define RPL_RLI_H diff --git a/sql/rpl_tblmap.cc b/sql/rpl_tblmap.cc index 02543a429b8..b2da9092e3a 100644 --- a/sql/rpl_tblmap.cc +++ b/sql/rpl_tblmap.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/rpl_tblmap.h b/sql/rpl_tblmap.h index 05b298e6053..63bac5e68a8 100644 --- a/sql/rpl_tblmap.h +++ b/sql/rpl_tblmap.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef TABLE_MAPPING_H #define TABLE_MAPPING_H diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index e170b4772c1..b36838b9b22 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include <my_bit.h> diff --git a/sql/rpl_utility.h b/sql/rpl_utility.h index ed0ce16363b..b42b11231e0 100644 --- a/sql/rpl_utility.h +++ b/sql/rpl_utility.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef RPL_UTILITY_H #define RPL_UTILITY_H diff --git a/sql/scheduler.cc b/sql/scheduler.cc index a4b9dd0c34a..7380b134f13 100644 --- a/sql/scheduler.cc +++ b/sql/scheduler.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Implementation for the thread scheduler diff --git a/sql/scheduler.h b/sql/scheduler.h index 6d0bc91d68a..676262f6454 100644 --- a/sql/scheduler.h +++ b/sql/scheduler.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Classes for the thread scheduler diff --git a/sql/semisync.cc b/sql/semisync.cc index a8a11f091db..e3638d8bf7a 100644 --- a/sql/semisync.cc +++ b/sql/semisync.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include <my_global.h> diff --git a/sql/semisync.h b/sql/semisync.h index 9deb6c5fd01..44f236606fd 100644 --- a/sql/semisync.h +++ b/sql/semisync.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SEMISYNC_H diff --git a/sql/semisync_master.h b/sql/semisync_master.h index 517175b5b06..74f6c24c8ea 100644 --- a/sql/semisync_master.h +++ b/sql/semisync_master.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SEMISYNC_MASTER_H diff --git a/sql/session_tracker.cc b/sql/session_tracker.cc index 1566c2d7ade..1aca3243f2b 100644 --- a/sql/session_tracker.cc +++ b/sql/session_tracker.cc @@ -354,6 +354,7 @@ bool Session_sysvars_tracker::enable(THD *thd) m_parsed= false; m_enabled= thd->variables.session_track_system_variables && *thd->variables.session_track_system_variables; + reset_changed(); return false; } diff --git a/sql/set_var.cc b/sql/set_var.cc index ae4e712c77d..4b0257871ac 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* variable declarations are in sys_vars.cc now !!! */ diff --git a/sql/set_var.h b/sql/set_var.h index 5f9720f0d5a..7f551875c97 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/share/CMakeLists.txt b/sql/share/CMakeLists.txt index 2980e6153f5..55f39e5e22b 100644 --- a/sql/share/CMakeLists.txt +++ b/sql/share/CMakeLists.txt @@ -12,7 +12,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA SET (dirs danish diff --git a/sql/share/charsets/Index.xml b/sql/share/charsets/Index.xml index 912d196cc3c..058f48ace15 100644 --- a/sql/share/charsets/Index.xml +++ b/sql/share/charsets/Index.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <description> diff --git a/sql/share/charsets/armscii8.xml b/sql/share/charsets/armscii8.xml index c1eb93b1f91..161d469c3bc 100644 --- a/sql/share/charsets/armscii8.xml +++ b/sql/share/charsets/armscii8.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="armscii8"> diff --git a/sql/share/charsets/ascii.xml b/sql/share/charsets/ascii.xml index c516a68516c..0f90f4983e3 100644 --- a/sql/share/charsets/ascii.xml +++ b/sql/share/charsets/ascii.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="ascii"> diff --git a/sql/share/charsets/cp1250.xml b/sql/share/charsets/cp1250.xml index e6681a625a2..55379ef6618 100644 --- a/sql/share/charsets/cp1250.xml +++ b/sql/share/charsets/cp1250.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="cp1250"> diff --git a/sql/share/charsets/cp1251.xml b/sql/share/charsets/cp1251.xml index 4cd584c0bf5..33a36289e5e 100644 --- a/sql/share/charsets/cp1251.xml +++ b/sql/share/charsets/cp1251.xml @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="cp1251"> diff --git a/sql/share/charsets/cp1256.xml b/sql/share/charsets/cp1256.xml index ab0ba855f3b..4584b30c0c3 100644 --- a/sql/share/charsets/cp1256.xml +++ b/sql/share/charsets/cp1256.xml @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="cp1256"> diff --git a/sql/share/charsets/cp1257.xml b/sql/share/charsets/cp1257.xml index 61d1d276b0a..d2f3d59fefa 100644 --- a/sql/share/charsets/cp1257.xml +++ b/sql/share/charsets/cp1257.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="cp1257"> diff --git a/sql/share/charsets/cp850.xml b/sql/share/charsets/cp850.xml index 06465540a75..32eb37e3c80 100644 --- a/sql/share/charsets/cp850.xml +++ b/sql/share/charsets/cp850.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="cp850"> diff --git a/sql/share/charsets/cp852.xml b/sql/share/charsets/cp852.xml index e0c574d2ea1..f038fa92d9b 100644 --- a/sql/share/charsets/cp852.xml +++ b/sql/share/charsets/cp852.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="cp852"> diff --git a/sql/share/charsets/cp866.xml b/sql/share/charsets/cp866.xml index 9cd8c8c504b..3245326afc2 100644 --- a/sql/share/charsets/cp866.xml +++ b/sql/share/charsets/cp866.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="cp866"> diff --git a/sql/share/charsets/dec8.xml b/sql/share/charsets/dec8.xml index 68949309ced..2569713318a 100644 --- a/sql/share/charsets/dec8.xml +++ b/sql/share/charsets/dec8.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="dec8"> diff --git a/sql/share/charsets/geostd8.xml b/sql/share/charsets/geostd8.xml index 822cc083724..bcb3148feb8 100644 --- a/sql/share/charsets/geostd8.xml +++ b/sql/share/charsets/geostd8.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="geostd8"> diff --git a/sql/share/charsets/greek.xml b/sql/share/charsets/greek.xml index cbbe22e675a..9ab0cb68338 100644 --- a/sql/share/charsets/greek.xml +++ b/sql/share/charsets/greek.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="greek"> diff --git a/sql/share/charsets/hebrew.xml b/sql/share/charsets/hebrew.xml index 562fa4f4748..295440b4e3e 100644 --- a/sql/share/charsets/hebrew.xml +++ b/sql/share/charsets/hebrew.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="hebrew"> diff --git a/sql/share/charsets/hp8.xml b/sql/share/charsets/hp8.xml index b17f75ed73e..628ebe7f34c 100644 --- a/sql/share/charsets/hp8.xml +++ b/sql/share/charsets/hp8.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="hp8"> diff --git a/sql/share/charsets/keybcs2.xml b/sql/share/charsets/keybcs2.xml index 7c2775ba5c3..a6079319628 100644 --- a/sql/share/charsets/keybcs2.xml +++ b/sql/share/charsets/keybcs2.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="keybcs2"> diff --git a/sql/share/charsets/koi8r.xml b/sql/share/charsets/koi8r.xml index 25264d4f9ce..7a8a936f7a7 100644 --- a/sql/share/charsets/koi8r.xml +++ b/sql/share/charsets/koi8r.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="koi8r"> diff --git a/sql/share/charsets/koi8u.xml b/sql/share/charsets/koi8u.xml index a2f5de9feb2..83e85b84360 100644 --- a/sql/share/charsets/koi8u.xml +++ b/sql/share/charsets/koi8u.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="koi8u"> diff --git a/sql/share/charsets/languages.html b/sql/share/charsets/languages.html index 3263d6a2ae2..9adce32f393 100644 --- a/sql/share/charsets/languages.html +++ b/sql/share/charsets/languages.html @@ -14,7 +14,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA #<pre> ( diff --git a/sql/share/charsets/latin1.xml b/sql/share/charsets/latin1.xml index 68307847d91..f88a2840f56 100644 --- a/sql/share/charsets/latin1.xml +++ b/sql/share/charsets/latin1.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="latin1"> diff --git a/sql/share/charsets/latin2.xml b/sql/share/charsets/latin2.xml index 29ff4cb974b..20e7803cefe 100644 --- a/sql/share/charsets/latin2.xml +++ b/sql/share/charsets/latin2.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="latin2"> diff --git a/sql/share/charsets/latin5.xml b/sql/share/charsets/latin5.xml index ca7dd106de5..727019ccd94 100644 --- a/sql/share/charsets/latin5.xml +++ b/sql/share/charsets/latin5.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="latin5"> diff --git a/sql/share/charsets/latin7.xml b/sql/share/charsets/latin7.xml index 81866c23bbd..78b7dda61f2 100644 --- a/sql/share/charsets/latin7.xml +++ b/sql/share/charsets/latin7.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="latin7"> diff --git a/sql/share/charsets/macce.xml b/sql/share/charsets/macce.xml index 4fa46301d2e..2a601b7b668 100644 --- a/sql/share/charsets/macce.xml +++ b/sql/share/charsets/macce.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="macce"> diff --git a/sql/share/charsets/macroman.xml b/sql/share/charsets/macroman.xml index 4ee8dc1f952..711a391457c 100644 --- a/sql/share/charsets/macroman.xml +++ b/sql/share/charsets/macroman.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="macroman"> diff --git a/sql/share/charsets/swe7.xml b/sql/share/charsets/swe7.xml index d881f1e7d62..513c3eeb8d7 100644 --- a/sql/share/charsets/swe7.xml +++ b/sql/share/charsets/swe7.xml @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA </copyright> <charset name="swe7"> diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index e30fe877dcf..139ef3c5634 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -6134,8 +6134,8 @@ ER_EVENT_RECURSION_FORBIDDEN eng "Recursion of EVENT DDL statements is forbidden when body is present" ger "Rekursivität von EVENT-DDL-Anweisungen ist unzulässig wenn ein Hauptteil (Body) existiert" ER_EVENTS_DB_ERROR - eng "Cannot proceed because system tables used by Event Scheduler were found damaged at server start" - ger "Kann nicht weitermachen, weil die Tabellen, die von Events verwendet werden, beim Serverstart als beschädigt markiert wurden" + eng "Cannot proceed, because event scheduler is disabled" + ger "Die Operation kann nicht fortgesetzt werden, da Event Scheduler deaktiviert ist." ER_ONLY_INTEGERS_ALLOWED eng "Only integers allowed as number here" ger "An dieser Stelle sind nur Ganzzahlen zulässig" @@ -7869,7 +7869,7 @@ ER_DROP_VERSIONING_SYSTEM_TIME_PARTITION eng "Can not DROP SYSTEM VERSIONING for table %`s partitioned BY SYSTEM_TIME" ER_VERS_DB_NOT_SUPPORTED - eng "System versioning tables in the %`s database are not suported" + eng "System-versioned tables in the %`s database are not suported" ER_VERS_TRT_IS_DISABLED eng "Transaction registry is disabled" @@ -7883,11 +7883,11 @@ ER_VERS_ALREADY_VERSIONED ER_UNUSED_24 eng "You should never see it" -ER_VERS_TEMPORARY - eng "TEMPORARY tables do not support system versioning" +ER_VERS_NOT_SUPPORTED + eng "System-versioned tables do not support %s" ER_VERS_TRX_PART_HISTORIC_ROW_NOT_SUPPORTED - eng "Transaction-precise system versioned tables do not support partitioning by ROW START or ROW END" + eng "Transaction-precise system-versioned tables do not support partitioning by ROW START or ROW END" ER_INDEX_FILE_FULL eng "The index file for table '%-.192s' is full" ER_UPDATED_COLUMN_ONLY_ONCE diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc index ca9985c172e..51b9d7a2c51 100644 --- a/sql/signal_handler.cc +++ b/sql/signal_handler.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include <signal.h> diff --git a/sql/slave.cc b/sql/slave.cc index 1430c9fa153..a3776c0a580 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** diff --git a/sql/slave.h b/sql/slave.h index 646fa178f81..5ca6054a178 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SLAVE_H #define SLAVE_H diff --git a/sql/sp.cc b/sql/sp.cc index 6b38a0ddeb5..8568bc16c00 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef _SP_H_ #define _SP_H_ diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index 38d601431c9..99e68cd2595 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/sp_cache.h b/sql/sp_cache.h index a045ff5d3c5..7506edff814 100644 --- a/sql/sp_cache.h +++ b/sql/sp_cache.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef _SP_CACHE_H_ #define _SP_CACHE_H_ diff --git a/sql/sp_head.cc b/sql/sp_head.cc index f996c057908..48bd8ac8221 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" /* NO_EMBEDDED_ACCESS_CHECKS */ #include "sql_priv.h" @@ -1486,7 +1486,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success) NULL. In this case, mysql_change_db() would generate an error. */ - err_status|= mysql_change_db(thd, (LEX_CSTRING*) &saved_cur_db_name, TRUE); + err_status|= mysql_change_db(thd, (LEX_CSTRING*)&saved_cur_db_name, TRUE) != 0; } m_flags&= ~IS_INVOKED; if (m_parent) diff --git a/sql/sp_head.h b/sql/sp_head.h index 3365bf4883f..3085c248924 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef _SP_HEAD_H_ #define _SP_HEAD_H_ diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc index b0fee18ef05..433efda479b 100644 --- a/sql/sp_pcontext.cc +++ b/sql/sp_pcontext.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h index 7b38177236a..b1d77234f54 100644 --- a/sql/sp_pcontext.h +++ b/sql/sp_pcontext.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef _SP_PCONTEXT_H_ #define _SP_PCONTEXT_H_ diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index e71a529bc07..17b4c83b7bc 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" @@ -119,6 +119,19 @@ sp_rcontext *sp_rcontext::create(THD *thd, } +bool Row_definition_list::append_uniq(MEM_ROOT *mem_root, Spvar_definition *var) +{ + DBUG_ASSERT(elements); + uint unused; + if (unlikely(find_row_field_by_name(&var->field_name, &unused))) + { + my_error(ER_DUP_FIELDNAME, MYF(0), var->field_name.str); + return true; + } + return push_back(var, mem_root); +} + + bool Row_definition_list:: adjust_formal_params_to_actual_params(THD *thd, List<Item> *args) { diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h index b02ba14b99b..0e0e8921f86 100644 --- a/sql/sp_rcontext.h +++ b/sql/sp_rcontext.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef _SP_RCONTEXT_H_ #define _SP_RCONTEXT_H_ diff --git a/sql/spatial.cc b/sql/spatial.cc index 3514a519db7..bba9ae45f58 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/spatial.h b/sql/spatial.h index 5818607de26..fa4e40b5aa5 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef _spatial_h #define _spatial_h diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 2841e11d46c..aab41dd00ef 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* @@ -1257,6 +1257,13 @@ class User_table_tabular: public User_table int setup_sysvars() const { + if (num_fields() < 13) // number of columns in 3.21 + { + sql_print_error("Fatal error: mysql.user table is damaged or in " + "unsupported 3.20 format."); + return 1; + } + username_char_length= MY_MIN(m_table->field[1]->char_length(), USERNAME_CHAR_LENGTH); using_global_priv_table= false; @@ -1815,6 +1822,8 @@ class Grant_tables { tl->init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_TABLE_NAME[i], NULL, lock_type); + tl->open_type= OT_BASE_ONLY; + tl->i_s_requested_object= OPEN_TABLE_ONLY; tl->updating= lock_type >= TL_WRITE_ALLOW_WRITE; if (i >= FIRST_OPTIONAL_TABLE) tl->open_strategy= TABLE_LIST::OPEN_IF_EXISTS; @@ -1835,6 +1844,8 @@ class Grant_tables TABLE_LIST *tl= tables + USER_TABLE; tl->init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_TABLE_NAME_USER, NULL, lock_type); + tl->open_type= OT_BASE_ONLY; + tl->i_s_requested_object= OPEN_TABLE_ONLY; tl->updating= lock_type >= TL_WRITE_ALLOW_WRITE; p_user_table= &m_user_table_tabular; counter++; @@ -12464,7 +12475,7 @@ struct MPVIO_EXT :public MYSQL_PLUGIN_VIO }; /** - a helper function to report an access denied error in all the proper places + a helper function to report an access denied error in most proper places */ static void login_failed_error(THD *thd) { @@ -13980,10 +13991,26 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len) /* Change a database if necessary */ if (mpvio.db.length) { - if (mysql_change_db(thd, &mpvio.db, FALSE)) + uint err = mysql_change_db(thd, &mpvio.db, FALSE); + if(err) { - /* mysql_change_db() has pushed the error message. */ - status_var_increment(thd->status_var.access_denied_errors); + if (err == ER_DBACCESS_DENIED_ERROR) + { + /* + Got an "access denied" error, which must be handled + other access denied errors (see login_failed_error()). + mysql_change_db() already sent error to client, and + wrote to general log, we only need to increment the counter + and maybe write a warning to error log. + */ + status_var_increment(thd->status_var.access_denied_errors); + if (global_system_variables.log_warnings > 1) + { + Security_context* sctx = thd->security_ctx; + sql_print_warning(ER_THD(thd, err), + sctx->priv_user, sctx->priv_host, mpvio.db.str); + } + } DBUG_RETURN(1); } } diff --git a/sql/sql_acl.h b/sql/sql_acl.h index cb49172a90c..7989367ec44 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "violite.h" /* SSL_type */ #include "sql_class.h" /* LEX_COLUMN */ diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index cf45f443a07..d004bcd974a 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_class.h" // THD diff --git a/sql/sql_admin.h b/sql/sql_admin.h index e7f4086540a..d31726d32a4 100644 --- a/sql/sql_admin.h +++ b/sql/sql_admin.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_TABLE_MAINTENANCE_H #define SQL_TABLE_MAINTENANCE_H diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc index 1d2b5c3449b..fd39113a44b 100644 --- a/sql/sql_alter.cc +++ b/sql/sql_alter.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_parse.h" // check_access diff --git a/sql/sql_alter.h b/sql/sql_alter.h index 14242015bd2..a40c980b692 100644 --- a/sql/sql_alter.h +++ b/sql/sql_alter.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_ALTER_TABLE_H #define SQL_ALTER_TABLE_H diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index fa24ea142b1..edcc8aeeda6 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* Analyse database */ diff --git a/sql/sql_analyse.h b/sql/sql_analyse.h index a76e1409659..9cdb93f4d6f 100644 --- a/sql/sql_analyse.h +++ b/sql/sql_analyse.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Analyse database */ diff --git a/sql/sql_analyze_stmt.cc b/sql/sql_analyze_stmt.cc index 61ca7c9a7af..f1c6e2c73ea 100644 --- a/sql/sql_analyze_stmt.cc +++ b/sql/sql_analyze_stmt.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation diff --git a/sql/sql_analyze_stmt.h b/sql/sql_analyze_stmt.h index ceda8b4f416..eec52822ae5 100644 --- a/sql/sql_analyze_stmt.h +++ b/sql/sql_analyze_stmt.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* diff --git a/sql/sql_array.h b/sql/sql_array.h index 30fbb140748..bcfbb98ef19 100644 --- a/sql/sql_array.h +++ b/sql/sql_array.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include <my_sys.h> diff --git a/sql/sql_audit.cc b/sql/sql_audit.cc index 793e3a801b3..e8a00abf30b 100644 --- a/sql/sql_audit.cc +++ b/sql/sql_audit.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/sql_audit.h b/sql/sql_audit.h index 5c66138b466..327fe6052ab 100644 --- a/sql/sql_audit.h +++ b/sql/sql_audit.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include <mysql/plugin_audit.h> diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 0e7059918c2..60371813280 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* Basic functions needed by many modules */ @@ -699,6 +699,12 @@ bool close_cached_connection_tables(THD *thd, LEX_CSTRING *connection) Marks all tables in the list which were used by current substatement (they are marked by its query_id) as free for reuse. + Clear 'check_table_binlog_row_based_done' flag. For tables which were used + by current substatement the flag is cleared as part of 'ha_reset()' call. + For the rest of the open tables not used by current substament if this + flag is enabled as part of current substatement execution, clear the flag + explicitly. + NOTE The reason we reset query_id is that it's not enough to just test if table->query_id != thd->query_id to know if a table is in use. @@ -721,6 +727,8 @@ static void mark_used_tables_as_free_for_reuse(THD *thd, TABLE *table) table->query_id= 0; table->file->ha_reset(); } + else if (table->file->check_table_binlog_row_based_done) + table->file->clear_cached_table_binlog_row_based_flag(); } DBUG_VOID_RETURN; } @@ -3498,6 +3506,47 @@ open_and_process_routine(THD *thd, Query_tables_list *prelocking_ctx, DBUG_RETURN(FALSE); } +/* + If we are not already in prelocked mode and extended table list is not + yet built we might have to build the prelocking set for this statement. + + Since currently no prelocking strategy prescribes doing anything for + tables which are only read, we do below checks only if table is going + to be changed. +*/ +bool extend_table_list(THD *thd, TABLE_LIST *tables, + Prelocking_strategy *prelocking_strategy, + bool has_prelocking_list) +{ + bool error= false; + LEX *lex= thd->lex; + bool maybe_need_prelocking= + (tables->updating && tables->lock_type >= TL_WRITE_ALLOW_WRITE) + || thd->lex->default_used; + + if (thd->locked_tables_mode <= LTM_LOCK_TABLES && + ! has_prelocking_list && maybe_need_prelocking) + { + bool need_prelocking= FALSE; + TABLE_LIST **save_query_tables_last= lex->query_tables_last; + /* + Extend statement's table list and the prelocking set with + tables and routines according to the current prelocking + strategy. + + For example, for DML statements we need to add tables and routines + used by triggers which are going to be invoked for this element of + table list and also add tables required for handling of foreign keys. + */ + error= prelocking_strategy->handle_table(thd, lex, tables, + &need_prelocking); + + if (need_prelocking && ! lex->requires_prelocking()) + lex->mark_as_requiring_prelocking(save_query_tables_last); + } + return error; +} + /** Handle table list element by obtaining metadata lock, opening table or view @@ -3524,14 +3573,13 @@ open_and_process_routine(THD *thd, Query_tables_list *prelocking_ctx, */ static bool -open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables, - uint *counter, uint flags, +open_and_process_table(THD *thd, TABLE_LIST *tables, uint *counter, uint flags, Prelocking_strategy *prelocking_strategy, - bool has_prelocking_list, - Open_table_context *ot_ctx) + bool has_prelocking_list, Open_table_context *ot_ctx) { bool error= FALSE; bool safe_to_ignore_table= FALSE; + LEX *lex= thd->lex; DBUG_ENTER("open_and_process_table"); DEBUG_SYNC(thd, "open_and_process_table"); @@ -3590,8 +3638,7 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables, Check whether the information schema contains a table whose name is tables->schema_table_name */ - ST_SCHEMA_TABLE *schema_table; - schema_table= find_schema_table(thd, &tables->schema_table_name); + ST_SCHEMA_TABLE *schema_table= tables->schema_table; if (!schema_table || (schema_table->hidden && ((sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) == 0 || @@ -3602,7 +3649,7 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables, lex->sql_command == SQLCOM_SHOW_KEYS))) { my_error(ER_UNKNOWN_TABLE, MYF(0), - tables->schema_table_name.str, INFORMATION_SCHEMA_NAME.str); + tables->table_name.str, INFORMATION_SCHEMA_NAME.str); DBUG_RETURN(1); } } @@ -3806,38 +3853,9 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables, if (tables->open_strategy && !tables->table) goto end; - /* - If we are not already in prelocked mode and extended table list is not - yet built we might have to build the prelocking set for this statement. - - Since currently no prelocking strategy prescribes doing anything for - tables which are only read, we do below checks only if table is going - to be changed. - */ - if (thd->locked_tables_mode <= LTM_LOCK_TABLES && - ! has_prelocking_list && - (tables->lock_type >= TL_WRITE_ALLOW_WRITE || thd->lex->default_used)) - { - bool need_prelocking= FALSE; - TABLE_LIST **save_query_tables_last= lex->query_tables_last; - /* - Extend statement's table list and the prelocking set with - tables and routines according to the current prelocking - strategy. - - For example, for DML statements we need to add tables and routines - used by triggers which are going to be invoked for this element of - table list and also add tables required for handling of foreign keys. - */ - error= prelocking_strategy->handle_table(thd, lex, tables, - &need_prelocking); - - if (need_prelocking && ! lex->requires_prelocking()) - lex->mark_as_requiring_prelocking(save_query_tables_last); - - if (unlikely(error)) - goto end; - } + error= extend_table_list(thd, tables, prelocking_strategy, has_prelocking_list); + if (unlikely(error)) + goto end; /* Copy grant information from TABLE_LIST instance to TABLE one. */ tables->table->grant= tables->grant; @@ -4170,7 +4188,8 @@ open_tables_check_upgradable_mdl(THD *thd, TABLE_LIST *tables_start, */ bool open_tables(THD *thd, const DDL_options_st &options, - TABLE_LIST **start, uint *counter, uint flags, + TABLE_LIST **start, uint *counter, + Sroutine_hash_entry **sroutine_to_open_list, uint flags, Prelocking_strategy *prelocking_strategy) { /* @@ -4209,7 +4228,7 @@ restart: has_prelocking_list= thd->lex->requires_prelocking(); table_to_open= start; - sroutine_to_open= (Sroutine_hash_entry**) &thd->lex->sroutines_list.first; + sroutine_to_open= sroutine_to_open_list; *counter= 0; THD_STAGE_INFO(thd, stage_opening_tables); @@ -4279,9 +4298,9 @@ restart: for (tables= *table_to_open; tables; table_to_open= &tables->next_global, tables= tables->next_global) { - error= open_and_process_table(thd, thd->lex, tables, counter, - flags, prelocking_strategy, - has_prelocking_list, &ot_ctx); + error= open_and_process_table(thd, tables, counter, flags, + prelocking_strategy, has_prelocking_list, + &ot_ctx); if (unlikely(error)) { @@ -8809,8 +8828,7 @@ my_bool mysql_rm_tmp_tables(void) { file=dirp->dir_entry+idx; - if (!memcmp(file->name, tmp_file_prefix, - tmp_file_prefix_length)) + if (!strncmp(file->name, tmp_file_prefix, tmp_file_prefix_length)) { char *ext= fn_ext(file->name); size_t ext_len= strlen(ext); diff --git a/sql/sql_base.h b/sql/sql_base.h index 7bcbc5d7a23..54c26fb595a 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_BASE_INCLUDED #define SQL_BASE_INCLUDED @@ -247,8 +247,19 @@ lock_table_names(THD *thd, TABLE_LIST *table_list, table_list_end, lock_wait_timeout, flags); } bool open_tables(THD *thd, const DDL_options_st &options, - TABLE_LIST **tables, uint *counter, uint flags, + TABLE_LIST **tables, uint *counter, + Sroutine_hash_entry **sroutine_to_open, uint flags, Prelocking_strategy *prelocking_strategy); + +static inline bool +open_tables(THD *thd, const DDL_options_st &options, TABLE_LIST **tables, + uint *counter, uint flags, Prelocking_strategy *prelocking_strategy) +{ + return open_tables(thd, options, tables, counter, + &thd->lex->sroutines_list.first, flags, + prelocking_strategy); +} + static inline bool open_tables(THD *thd, TABLE_LIST **tables, uint *counter, uint flags, Prelocking_strategy *prelocking_strategy) @@ -505,6 +516,10 @@ inline bool open_and_lock_tables(THD *thd, TABLE_LIST *tables, bool restart_trans_for_tables(THD *thd, TABLE_LIST *table); +bool extend_table_list(THD *thd, TABLE_LIST *tables, + Prelocking_strategy *prelocking_strategy, + bool has_prelocking_list); + /** A context of open_tables() function, used to recover from a failed open_table() or open_routine() attempt. diff --git a/sql/sql_basic_types.h b/sql/sql_basic_types.h index a790b68fc0c..170e93741ef 100644 --- a/sql/sql_basic_types.h +++ b/sql/sql_basic_types.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* File that includes common types used globally in MariaDB */ diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index 97b8e2e4f91..44a885bf0eb 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/sql_binlog.h b/sql/sql_binlog.h index 3a6d561701a..d10d78e1e3e 100644 --- a/sql/sql_binlog.h +++ b/sql/sql_binlog.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_BINLOG_INCLUDED #define SQL_BINLOG_INCLUDED diff --git a/sql/sql_bitmap.h b/sql/sql_bitmap.h index 236554764b0..93c5056a8fb 100644 --- a/sql/sql_bitmap.h +++ b/sql/sql_bitmap.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Implementation of a bitmap type. diff --git a/sql/sql_bootstrap.cc b/sql/sql_bootstrap.cc index 9fb22c6b4d4..a8c930820a7 100644 --- a/sql/sql_bootstrap.cc +++ b/sql/sql_bootstrap.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" diff --git a/sql/sql_bootstrap.h b/sql/sql_bootstrap.h index b8a302a8646..f12d66a522e 100644 --- a/sql/sql_bootstrap.h +++ b/sql/sql_bootstrap.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_BOOTSTRAP_H diff --git a/sql/sql_builtin.cc.in b/sql/sql_builtin.cc.in index 6a491a3e7bb..5ac044afd5d 100644 --- a/sql/sql_builtin.cc.in +++ b/sql/sql_builtin.cc.in @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 73bb4d7b7f7..54f7db3e684 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* Description of the query cache: diff --git a/sql/sql_cache.h b/sql/sql_cache.h index 0ed45a9ed81..92635ecacc7 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef _SQL_CACHE_H #define _SQL_CACHE_H diff --git a/sql/sql_callback.h b/sql/sql_callback.h index 316f94a0213..1f798ad5ac7 100644 --- a/sql/sql_callback.h +++ b/sql/sql_callback.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_CALLBACK_INCLUDED diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 9ee1cfe044d..c17718bcff2 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ diff --git a/sql/sql_class.h b/sql/sql_class.h index 9fc0f9f216c..f963560d01f 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_CLASS_INCLUDED #define SQL_CLASS_INCLUDED @@ -39,6 +39,7 @@ #include "thr_timer.h" #include "thr_malloc.h" #include "log_slow.h" /* LOG_SLOW_DISABLE_... */ +#include <my_tree.h> #include "sql_digest_stream.h" // sql_digest_state #include <mysql/psi/mysql_stage.h> #include <mysql/psi/mysql_statement.h> diff --git a/sql/sql_client.cc b/sql/sql_client.cc index 0e17360915c..b4a22c34e99 100644 --- a/sql/sql_client.cc +++ b/sql/sql_client.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* This files defines some MySQL C API functions that are server specific diff --git a/sql/sql_cmd.h b/sql/sql_cmd.h index 8ff26b09015..6c12a6689b3 100644 --- a/sql/sql_cmd.h +++ b/sql/sql_cmd.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file Representation of an SQL command. diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index f76f4c76505..c119a111eed 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* diff --git a/sql/sql_connect.h b/sql/sql_connect.h index f0e717286f0..4d62834a6f9 100644 --- a/sql/sql_connect.h +++ b/sql/sql_connect.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_CONNECT_INCLUDED #define SQL_CONNECT_INCLUDED diff --git a/sql/sql_const.h b/sql/sql_const.h index d4e40cd551e..1f9353cdef3 100644 --- a/sql/sql_const.h +++ b/sql/sql_const.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/sql_crypt.cc b/sql/sql_crypt.cc index 19cd780e9c3..edff85a0f9d 100644 --- a/sql/sql_crypt.cc +++ b/sql/sql_crypt.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ diff --git a/sql/sql_crypt.h b/sql/sql_crypt.h index e61776713b6..3c90550c944 100644 --- a/sql/sql_crypt.h +++ b/sql/sql_crypt.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_INTERFACE diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc index 4f3b15c3254..8f41fe7c70d 100644 --- a/sql/sql_cursor.cc +++ b/sql/sql_cursor.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation /* gcc class implementation */ #endif diff --git a/sql/sql_cursor.h b/sql/sql_cursor.h index 740a658b7c0..00b9cd4e67a 100644 --- a/sql/sql_cursor.h +++ b/sql/sql_cursor.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef _sql_cursor_h_ #define _sql_cursor_h_ diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 67cf89aef70..756955c6f94 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* create and drop of databases */ @@ -1490,12 +1490,12 @@ static void backup_current_db_name(THD *thd, a stack pointer set by Stored Procedures was used by replication after the stack address was long gone. - @return Operation status - @retval FALSE Success - @retval TRUE Error + @return error code (ER_XXX) + @retval 0 Success + @retval >0 Error */ -bool mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name, +uint mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name, bool force_switch) { LEX_CSTRING new_db_file_name; @@ -1526,7 +1526,7 @@ bool mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name, { my_message(ER_NO_DB_ERROR, ER_THD(thd, ER_NO_DB_ERROR), MYF(0)); - DBUG_RETURN(TRUE); + DBUG_RETURN(ER_NO_DB_ERROR); } } DBUG_PRINT("enter",("name: '%s'", new_db_name->str)); @@ -1552,7 +1552,7 @@ bool mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name, new_db_file_name.length= new_db_name->length; if (new_db_file_name.str == NULL) - DBUG_RETURN(TRUE); /* the error is set */ + DBUG_RETURN(ER_OUT_OF_RESOURCES); /* the error is set */ /* NOTE: if check_db_name() fails, we should throw an error in any case, @@ -1572,7 +1572,7 @@ bool mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name, if (force_switch) mysql_change_db_impl(thd, NULL, 0, thd->variables.collation_server); - DBUG_RETURN(TRUE); + DBUG_RETURN(ER_WRONG_DB_NAME); } DBUG_PRINT("info",("Use database: %s", new_db_file_name.str)); @@ -1602,7 +1602,7 @@ bool mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name, general_log_print(thd, COM_INIT_DB, ER_THD(thd, ER_DBACCESS_DENIED_ERROR), sctx->priv_user, sctx->priv_host, new_db_file_name.str); my_free(const_cast<char*>(new_db_file_name.str)); - DBUG_RETURN(TRUE); + DBUG_RETURN(ER_DBACCESS_DENIED_ERROR); } #endif @@ -1636,7 +1636,7 @@ bool mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name, /* The operation failed. */ - DBUG_RETURN(TRUE); + DBUG_RETURN(ER_BAD_DB_ERROR); } } @@ -1652,7 +1652,7 @@ bool mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name, done: SESSION_TRACKER_CHANGED(thd, CURRENT_SCHEMA_TRACKER, NULL); SESSION_TRACKER_CHANGED(thd, SESSION_STATE_CHANGE_TRACKER, NULL); - DBUG_RETURN(FALSE); + DBUG_RETURN(0); } @@ -1900,7 +1900,7 @@ bool mysql_upgrade_db(THD *thd, const LEX_CSTRING *old_db) /* Step9: Let's do "use newdb" if we renamed the current database */ if (change_to_newdb) - error|= mysql_change_db(thd, & new_db, FALSE); + error|= mysql_change_db(thd, & new_db, FALSE) != 0; exit: DBUG_RETURN(error); diff --git a/sql/sql_db.h b/sql/sql_db.h index c0646bd65f0..c9f1ed068e6 100644 --- a/sql/sql_db.h +++ b/sql/sql_db.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_DB_INCLUDED #define SQL_DB_INCLUDED @@ -26,7 +26,7 @@ bool mysql_alter_db(THD *thd, const LEX_CSTRING *db, const Schema_specification_st *create); bool mysql_rm_db(THD *thd, const LEX_CSTRING *db, bool if_exists); bool mysql_upgrade_db(THD *thd, const LEX_CSTRING *old_db); -bool mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name, +uint mysql_change_db(THD *thd, const LEX_CSTRING *new_db_name, bool force_switch); bool mysql_opt_change_db(THD *thd, diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index d2e511b1d86..26646d5c73f 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Delete of records tables. @@ -298,12 +298,7 @@ int TABLE::delete_row() store_record(this, record[1]); vers_update_end(); - int res; - if ((res= file->extra(HA_EXTRA_REMEMBER_POS))) - return res; - if ((res= file->ha_update_row(record[1], record[0]))) - return res; - return file->extra(HA_EXTRA_RESTORE_POS); + return file->ha_update_row(record[1], record[0]); } diff --git a/sql/sql_delete.h b/sql/sql_delete.h index 54d6cf146b5..7af8564abf9 100644 --- a/sql/sql_delete.h +++ b/sql/sql_delete.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_DELETE_INCLUDED #define SQL_DELETE_INCLUDED diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 102999c42d7..06e82263524 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* diff --git a/sql/sql_derived.h b/sql/sql_derived.h index 2454d40ba79..403277d65c9 100644 --- a/sql/sql_derived.h +++ b/sql/sql_derived.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_DERIVED_INCLUDED #define SQL_DERIVED_INCLUDED diff --git a/sql/sql_digest.cc b/sql/sql_digest.cc index a8afd33c46a..10a9547d80f 100644 --- a/sql/sql_digest.cc +++ b/sql/sql_digest.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* This code needs extra visibility in the lexer structures diff --git a/sql/sql_digest.h b/sql/sql_digest.h index 81fe809b59d..cc786a3b6fa 100644 --- a/sql/sql_digest.h +++ b/sql/sql_digest.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_DIGEST_H #define SQL_DIGEST_H diff --git a/sql/sql_digest_stream.h b/sql/sql_digest_stream.h index 55f7e2293c6..75e534e8350 100644 --- a/sql/sql_digest_stream.h +++ b/sql/sql_digest_stream.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_DIGEST_STREAM_H #define SQL_DIGEST_STREAM_H diff --git a/sql/sql_do.cc b/sql/sql_do.cc index 1652b313909..5a7bca2774c 100644 --- a/sql/sql_do.cc +++ b/sql/sql_do.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Execute DO statement */ diff --git a/sql/sql_do.h b/sql/sql_do.h index 35130cc5836..5280a4a52e1 100644 --- a/sql/sql_do.h +++ b/sql/sql_do.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_DO_INCLUDED #define SQL_DO_INCLUDED diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 8d639f9271d..a11a0f454a2 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /********************************************************************** This file contains the implementation of error and warnings related diff --git a/sql/sql_error.h b/sql/sql_error.h index 6586c49a125..bb83d8af800 100644 --- a/sql/sql_error.h +++ b/sql/sql_error.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_ERROR_H #define SQL_ERROR_H diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index b14cffdc466..51412aedaf2 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation diff --git a/sql/sql_explain.h b/sql/sql_explain.h index 9478cd56a9b..35388416908 100644 --- a/sql/sql_explain.h +++ b/sql/sql_explain.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* diff --git a/sql/sql_expression_cache.cc b/sql/sql_expression_cache.cc index 3b6b5993073..351ec258ddb 100644 --- a/sql/sql_expression_cache.cc +++ b/sql/sql_expression_cache.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_base.h" diff --git a/sql/sql_expression_cache.h b/sql/sql_expression_cache.h index 05ac51f81f2..61e0c4c69b3 100644 --- a/sql/sql_expression_cache.h +++ b/sql/sql_expression_cache.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_EXPRESSION_CACHE_INCLUDED #define SQL_EXPRESSION_CACHE_INCLUDED diff --git a/sql/sql_get_diagnostics.cc b/sql/sql_get_diagnostics.cc index b7da889340f..b3ae423b914 100644 --- a/sql/sql_get_diagnostics.cc +++ b/sql/sql_get_diagnostics.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_list.h" // Sql_alloc, List, List_iterator diff --git a/sql/sql_get_diagnostics.h b/sql/sql_get_diagnostics.h index 6f1652bb146..f283aa5b2c6 100644 --- a/sql/sql_get_diagnostics.h +++ b/sql/sql_get_diagnostics.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_GET_DIAGNOSTICS_H #define SQL_GET_DIAGNOSTICS_H diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 9da1d314393..36a879fc5cd 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* HANDLER ... commands - direct access to ISAM */ diff --git a/sql/sql_handler.h b/sql/sql_handler.h index 16063bb1f35..4ac0d09e7a1 100644 --- a/sql/sql_handler.h +++ b/sql/sql_handler.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 95bc6ade366..e5f1e958d99 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/sql_help.h b/sql/sql_help.h index b6ae490e757..cb3314b756c 100644 --- a/sql/sql_help.h +++ b/sql/sql_help.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_HELP_INCLUDED #define SQL_HELP_INCLUDED diff --git a/sql/sql_hset.h b/sql/sql_hset.h index dfaf17cf55c..7834349a2f7 100644 --- a/sql/sql_hset.h +++ b/sql/sql_hset.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "hash.h" diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index e5d33b91804..d25d831cac1 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Insert of records */ diff --git a/sql/sql_insert.h b/sql/sql_insert.h index 6efd680d188..a37ed1f31e5 100644 --- a/sql/sql_insert.h +++ b/sql/sql_insert.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_INSERT_INCLUDED #define SQL_INSERT_INCLUDED diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 53c5e992ca9..8986e4c42ac 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/sql_join_cache.h b/sql/sql_join_cache.h index c4ba08496d0..7b8b942180f 100644 --- a/sql/sql_join_cache.h +++ b/sql/sql_join_cache.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* This file contains declarations for implementations diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index b0544300f1d..9550350cc44 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* A lexical scanner on a temporary buffer with a yacc interface */ @@ -2365,6 +2365,7 @@ void st_select_lex_unit::init_query() with_element= 0; columns_are_renamed= false; intersect_mark= NULL; + with_wrapped_tvc= false; } void st_select_lex::init_query() @@ -3509,6 +3510,19 @@ bool st_select_lex_unit::union_needs_tmp_table() { if (with_element && with_element->is_recursive) return true; + if (!with_wrapped_tvc) + { + for (st_select_lex *sl= first_select(); sl; sl=sl->next_select()) + { + if (sl->tvc && sl->tvc->to_be_wrapped_as_with_tail()) + { + with_wrapped_tvc= true; + break; + } + } + } + if (with_wrapped_tvc) + return true; return union_distinct != NULL || global_parameters()->order_list.elements != 0 || thd->lex->sql_command == SQLCOM_INSERT_SELECT || @@ -8798,36 +8812,6 @@ bool LEX::last_field_generated_always_as_row_end() } -bool LEX::tvc_finalize() -{ - mysql_init_select(this); - if (unlikely(!(current_select->tvc= - new (thd->mem_root) - table_value_constr(many_values, - current_select, - current_select->options)))) - return true; - many_values.empty(); - return false; -} - - -bool LEX::tvc_finalize_derived() -{ - derived_tables|= DERIVED_SUBQUERY; - if (unlikely(!expr_allows_subselect)) - { - thd->parse_error(); - return true; - } - if (current_select->get_linkage() == GLOBAL_OPTIONS_TYPE || - unlikely(mysql_new_select(this, 1, NULL))) - return true; - current_select->set_linkage(DERIVED_TABLE_TYPE); - return tvc_finalize(); -} - - void st_select_lex_unit::reset_distinct() { union_distinct= NULL; @@ -8926,12 +8910,12 @@ void Lex_select_lock::set_to(SELECT_LEX *sel) if (update_lock) { sel->lock_type= TL_WRITE; - sel->set_lock_for_tables(TL_WRITE); + sel->set_lock_for_tables(TL_WRITE, false); } else { sel->lock_type= TL_READ_WITH_SHARED_LOCKS; - sel->set_lock_for_tables(TL_READ_WITH_SHARED_LOCKS); + sel->set_lock_for_tables(TL_READ_WITH_SHARED_LOCKS, false); } } } @@ -9262,10 +9246,26 @@ SELECT_LEX_UNIT *LEX::parsed_select_expr_cont(SELECT_LEX_UNIT *unit, SELECT_LEX_UNIT *LEX::parsed_body_select(SELECT_LEX *sel, Lex_order_limit_lock * l) { + if (sel->braces && l && l->lock.defined_lock) + { + my_error(ER_WRONG_USAGE, MYF(0), "lock options", + "SELECT in brackets"); + return NULL; + } if (!(sel= parsed_select(sel, l))) return NULL; SELECT_LEX_UNIT *res= create_unit(sel); + if (res && sel->tvc && sel->order_list.elements) + { + if (res->add_fake_select_lex(thd)) + return NULL; + SELECT_LEX *fake= res->fake_select_lex; + fake->order_list= sel->order_list; + fake->explicit_limit= sel->explicit_limit; + fake->select_limit= sel->select_limit; + fake->offset_limit= sel->offset_limit; + } return res; } @@ -9476,6 +9476,12 @@ bool LEX::select_finalize(st_select_lex_unit *expr) } +bool LEX::select_finalize(st_select_lex_unit *expr, Lex_select_lock l) +{ + return expr->set_lock_to_the_last_select(l) || + select_finalize(expr); +} + /* "IN" and "EXISTS" subselect can appear in two statement types: @@ -9519,7 +9525,7 @@ bool SELECT_LEX_UNIT::set_lock_to_the_last_select(Lex_select_lock l) if (sel->braces) { my_error(ER_WRONG_USAGE, MYF(0), "lock options", - "End SELECT expression"); + "SELECT in brackets"); return TRUE; } l.set_to(sel); @@ -10422,3 +10428,19 @@ bool LEX::stmt_create_stored_function_start(const DDL_options_st &options, return true; return false; } + + +Spvar_definition *LEX::row_field_name(THD *thd, const Lex_ident_sys_st &name) +{ + Spvar_definition *res; + if (unlikely(check_string_char_length(&name, 0, NAME_CHAR_LEN, + system_charset_info, 1))) + { + my_error(ER_TOO_LONG_IDENT, MYF(0), name.str); + return NULL; + } + if (unlikely(!(res= new (thd->mem_root) Spvar_definition()))) + return NULL; + init_last_field(res, &name, thd->variables.collation_database); + return res; +} diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 58c1dd3dfae..b205207f64d 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @defgroup Semantic_Analysis Semantic Analysis @@ -873,6 +873,12 @@ public: */ Item_int *intersect_mark; /** + TRUE if the unit contained TVC at the top level that has been wrapped + into SELECT: + VALUES (v1) ... (vn) => SELECT * FROM (VALUES (v1) ... (vn)) as tvc + */ + bool with_wrapped_tvc; + /** Pointer to 'last' select, or pointer to select where we stored global parameters for union. @@ -1347,7 +1353,7 @@ public: TABLE_LIST *convert_right_join(); List<Item>* get_item_list(); ulong get_table_join_options(); - void set_lock_for_tables(thr_lock_type lock_type); + void set_lock_for_tables(thr_lock_type lock_type, bool for_update); /* This method created for reiniting LEX in mysql_admin_table() and can be used only if you are going remove all SELECT_LEX & units except belonger @@ -4390,8 +4396,6 @@ public: many_values.empty(); insert_list= 0; } - bool tvc_finalize(); - bool tvc_finalize_derived(); bool make_select_in_brackets(SELECT_LEX* dummy_select, SELECT_LEX *nselect, bool automatic); @@ -4448,6 +4452,7 @@ public: LEX_CSTRING *alias); bool parsed_create_view(SELECT_LEX_UNIT *unit, int check); bool select_finalize(st_select_lex_unit *expr); + bool select_finalize(st_select_lex_unit *expr, Lex_select_lock l); void relink_hack(st_select_lex *select_lex); bool stmt_install_plugin(const DDL_options_st &opt, @@ -4502,6 +4507,7 @@ public: const Lex_ident_sys_st &name, Item_result return_type, const LEX_CSTRING &soname); + Spvar_definition *row_field_name(THD *thd, const Lex_ident_sys_st &name); }; diff --git a/sql/sql_lifo_buffer.h b/sql/sql_lifo_buffer.h index 62b23e7773a..0347030e4c6 100644 --- a/sql/sql_lifo_buffer.h +++ b/sql/sql_lifo_buffer.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @defgroup Bi-directional LIFO buffers used by DS-MRR implementation diff --git a/sql/sql_list.cc b/sql/sql_list.cc index 3512c7fc2ef..92664898718 100644 --- a/sql/sql_list.cc +++ b/sql/sql_list.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_IMPLEMENTATION diff --git a/sql/sql_list.h b/sql/sql_list.h index 60ec8ab4177..f5d8ed98b02 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ diff --git a/sql/sql_load.cc b/sql/sql_load.cc index ba1403837b8..3fa6e095f10 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Copy data from a textfile to table */ diff --git a/sql/sql_load.h b/sql/sql_load.h index ce5ada0dcc1..8413d27805c 100644 --- a/sql/sql_load.h +++ b/sql/sql_load.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_LOAD_INCLUDED #define SQL_LOAD_INCLUDED diff --git a/sql/sql_locale.cc b/sql/sql_locale.cc index f8b96279378..45f81da80c9 100644 --- a/sql/sql_locale.cc +++ b/sql/sql_locale.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* The beginnings of locale(7) support. diff --git a/sql/sql_locale.h b/sql/sql_locale.h index d1009832e0c..87145a106cc 100644 --- a/sql/sql_locale.h +++ b/sql/sql_locale.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_LOCALE_INCLUDED #define SQL_LOCALE_INCLUDED diff --git a/sql/sql_manager.cc b/sql/sql_manager.cc index f787d39b774..2ad8d8a914a 100644 --- a/sql/sql_manager.cc +++ b/sql/sql_manager.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* * sql_manager.cc diff --git a/sql/sql_manager.h b/sql/sql_manager.h index 8debbe6ead9..9c6c84450ed 100644 --- a/sql/sql_manager.h +++ b/sql/sql_manager.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_MANAGER_INCLUDED #define SQL_MANAGER_INCLUDED diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7ceb336ab78..fbeb3bc8b19 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #define MYSQL_LEX 1 #include "mariadb.h" @@ -3427,9 +3427,6 @@ mysql_execute_command(THD *thd) my_message(ER_SLAVE_IGNORED_TABLE, ER_THD(thd, ER_SLAVE_IGNORED_TABLE), MYF(0)); } - - for (table=all_tables; table; table=table->next_global) - table->updating= TRUE; } /* @@ -4662,6 +4659,16 @@ end_with_restore_list: res= 0; unit->set_limit(select_lex); + /* + We can not use mysql_explain_union() because of parameters of + mysql_select in mysql_multi_update so just set the option if needed + */ + if (thd->lex->describe) + { + select_lex->set_explain_type(FALSE); + select_lex->options|= SELECT_DESCRIBE; + } + res= mysql_multi_update_prepare(thd); #ifdef HAVE_REPLICATION @@ -8742,9 +8749,8 @@ bool st_select_lex::add_window_spec(THD *thd, query */ -void st_select_lex::set_lock_for_tables(thr_lock_type lock_type) +void st_select_lex::set_lock_for_tables(thr_lock_type lock_type, bool for_update) { - bool for_update= lock_type >= TL_READ_NO_INSERT; DBUG_ENTER("set_lock_for_tables"); DBUG_PRINT("enter", ("lock_type: %d for_update: %d", lock_type, for_update)); diff --git a/sql/sql_parse.h b/sql/sql_parse.h index 7c8ba37f1de..1d25b898ca4 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_PARSE_INCLUDED #define SQL_PARSE_INCLUDED diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 746a030a7ab..811d7fd2529 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* This file is a container for general functionality related diff --git a/sql/sql_partition.h b/sql/sql_partition.h index 83cac8f24ba..ea197a6fc2c 100644 --- a/sql/sql_partition.h +++ b/sql/sql_partition.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index 11276aa5a64..de85826d132 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_parse.h" // check_one_table_access diff --git a/sql/sql_partition_admin.h b/sql/sql_partition_admin.h index 9c53744d9bc..4be9e56e359 100644 --- a/sql/sql_partition_admin.h +++ b/sql/sql_partition_admin.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_PARTITION_ADMIN_H #define SQL_PARTITION_ADMIN_H diff --git a/sql/sql_plist.h b/sql/sql_plist.h index 4d279af7a0d..7f75208ca09 100644 --- a/sql/sql_plist.h +++ b/sql/sql_plist.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ template <typename T, typename L> diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index a6c7bb76055..a6672e2be2c 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "sql_plugin.h" // SHOW_MY_BOOL #include "sql_priv.h" diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h index 01ec0563050..b60fe0f13eb 100644 --- a/sql/sql_plugin.h +++ b/sql/sql_plugin.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef _sql_plugin_h #define _sql_plugin_h diff --git a/sql/sql_plugin_compat.h b/sql/sql_plugin_compat.h index e0b184c9b2f..01b79c5eb61 100644 --- a/sql/sql_plugin_compat.h +++ b/sql/sql_plugin_compat.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* old plugin api structures, used for backward compatibility */ diff --git a/sql/sql_plugin_services.ic b/sql/sql_plugin_services.ic index 955b9a0ce3a..c7ecfcd482e 100644 --- a/sql/sql_plugin_services.ic +++ b/sql/sql_plugin_services.ic @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* support for Services */ #include <service_versions.h> diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index fc4aaa82f33..8088b6923f2 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/sql_prepare.h b/sql/sql_prepare.h index ca040da341f..f1c4e5e4be9 100644 --- a/sql/sql_prepare.h +++ b/sql/sql_prepare.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "sql_error.h" diff --git a/sql/sql_priv.h b/sql/sql_priv.h index 4332a6961d9..0d1c9881c17 100644 --- a/sql/sql_priv.h +++ b/sql/sql_priv.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc index 6ca21aebb37..f36805012b2 100644 --- a/sql/sql_profile.cc +++ b/sql/sql_profile.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** diff --git a/sql/sql_profile.h b/sql/sql_profile.h index cb553d2f757..5b03acf59c0 100644 --- a/sql/sql_profile.h +++ b/sql/sql_profile.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef _SQL_PROFILE_H #define _SQL_PROFILE_H diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index 7a5cabc8880..0e166b169aa 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_reload.h" @@ -124,14 +124,7 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, if (options & REFRESH_ERROR_LOG) if (unlikely(flush_error_log())) - { - /* - When flush_error_log() failed, my_error() has not been called. - So, we have to do it here to keep the protocol. - */ - my_error(ER_UNKNOWN_ERROR, MYF(0)); result= 1; - } if ((options & REFRESH_SLOW_LOG) && global_system_variables.sql_log_slow) logger.flush_slow_log(); diff --git a/sql/sql_reload.h b/sql/sql_reload.h index 33ca022dc14..699912e0398 100644 --- a/sql/sql_reload.h +++ b/sql/sql_reload.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ class THD; struct TABLE_LIST; diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 0f7bb7748c1..ada373546be 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Atomic rename of table; RENAME TABLE t1 to t2, tmp to t1 [,...] diff --git a/sql/sql_rename.h b/sql/sql_rename.h index aaf09a8d030..1b9fcfb12bc 100644 --- a/sql/sql_rename.h +++ b/sql/sql_rename.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_RENAME_INCLUDED #define SQL_RENAME_INCLUDED diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index a058c366f60..f9ec262e0b8 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/sql_repl.h b/sql/sql_repl.h index 18aba0c9623..18aa7ea3fce 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_REPL_INCLUDED #define SQL_REPL_INCLUDED diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c360796132d..28e4e6bd1f0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file @@ -1315,8 +1315,9 @@ JOIN::prepare(TABLE_LIST *tables_init, item->max_length))) real_order= TRUE; - if (item->with_sum_func() && item->type() != Item::SUM_FUNC_ITEM) - item->split_sum_func(thd, ref_ptrs, all_fields, 0); + if ((item->with_sum_func() && item->type() != Item::SUM_FUNC_ITEM) || + item->with_window_func) + item->split_sum_func(thd, ref_ptrs, all_fields, SPLIT_SUM_SELECT); } if (!real_order) order= NULL; @@ -9961,7 +9962,7 @@ JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab, } /* If no more JOIN_TAB's on the top level */ - if (++tab == join->join_tab + join->top_join_tab_count + join->aggr_tables) + if (++tab >= join->join_tab + join->exec_join_tab_cnt() + join->aggr_tables) return NULL; if (include_bush_roots == WITHOUT_BUSH_ROOTS && tab->bush_children) @@ -10568,31 +10569,35 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, j->ref.null_rejecting|= (key_part_map)1 << i; keyuse_uses_no_tables= keyuse_uses_no_tables && !keyuse->used_tables; /* - Todo: we should remove this check for thd->lex->describe on the next - line. With SHOW EXPLAIN code, EXPLAIN printout code no longer depends - on it. However, removing the check caused change in lots of query - plans! Does the optimizer depend on the contents of - table_ref->key_copy ? If yes, do we produce incorrect EXPLAINs? + We don't want to compute heavy expressions in EXPLAIN, an example would + select * from t1 where t1.key=(select thats very heavy); + + (select thats very heavy) => is a constant here + eg: (select avg(order_cost) from orders) => constant but expensive */ if (!keyuse->val->used_tables() && !thd->lex->describe) { // Compare against constant - store_key_item tmp(thd, + store_key_item tmp(thd, keyinfo->key_part[i].field, key_buff + maybe_null, maybe_null ? key_buff : 0, keyinfo->key_part[i].length, keyuse->val, FALSE); - if (unlikely(thd->is_fatal_error)) - DBUG_RETURN(TRUE); - tmp.copy(); + if (unlikely(thd->is_fatal_error)) + DBUG_RETURN(TRUE); + tmp.copy(); j->ref.const_ref_part_map |= key_part_map(1) << i ; } else - *ref_key++= get_store_key(thd, - keyuse,join->const_table_map, - &keyinfo->key_part[i], - key_buff, maybe_null); + { + *ref_key++= get_store_key(thd, + keyuse,join->const_table_map, + &keyinfo->key_part[i], + key_buff, maybe_null); + if (!keyuse->val->used_tables()) + j->ref.const_ref_part_map |= key_part_map(1) << i ; + } /* Remember if we are going to use REF_OR_NULL But only if field _really_ can be null i.e. we force JT_REF @@ -17409,7 +17414,11 @@ Field *Item::tmp_table_field_from_field_type_maybe_null(TABLE *table, const Tmp_field_param *param, bool is_explicit_null) { - DBUG_ASSERT(!param->make_copy_field()); + /* + item->type() == CONST_ITEM excluded due to making fields for counter + With help of Item_uint + */ + DBUG_ASSERT(!param->make_copy_field() || type() == CONST_ITEM); DBUG_ASSERT(!is_result_field()); Field *result; if ((result= tmp_table_field_from_field_type(table))) @@ -23859,6 +23868,10 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0)); return 1; } + if (from_window_spec && (*order->item)->with_sum_func() && + (*order->item)->type() != Item::SUM_FUNC_ITEM) + (*order->item)->split_sum_func(thd, ref_pointer_array, + all_fields, SPLIT_SUM_SELECT); } return 0; } @@ -23926,6 +23939,10 @@ setup_group(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0)); return 1; } + if (from_window_spec && (*ord->item)->with_sum_func() && + (*ord->item)->type() != Item::SUM_FUNC_ITEM) + (*ord->item)->split_sum_func(thd, ref_pointer_array, + all_fields, SPLIT_SUM_SELECT); } if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY && context_analysis_place == IN_GROUP_BY) @@ -25912,6 +25929,15 @@ bool JOIN_TAB::save_explain_data(Explain_table_access *eta, { if (!(eta->ref_list.append_str(thd->mem_root, "const"))) return 1; + /* + create_ref_for_key() handles keypart=const equalities as follows: + - non-EXPLAIN execution will copy the "const" to lookup tuple + immediately and will not add an element to ref.key_copy + - EXPLAIN will put an element into ref.key_copy. Since we've + just printed "const" for it, we should skip it here + */ + if (thd->lex->describe) + key_ref++; } else { @@ -27648,7 +27674,15 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table, */ if (ref_key >= 0 && ref_key != MAX_KEY && tab->type == JT_REF) { - if (table->quick_keys.is_set(ref_key)) + /* + If ref access uses keypart=const for all its key parts, + and quick select uses the same # of key parts, then they are equivalent. + Reuse #rows estimate from quick select as it is more precise. + */ + if (tab->ref.const_ref_part_map == + make_prev_keypart_map(tab->ref.key_parts) && + table->quick_keys.is_set(ref_key) && + table->quick_key_parts[ref_key] == tab->ref.key_parts) refkey_rows_estimate= table->quick_rows[ref_key]; else { @@ -28260,27 +28294,6 @@ AGGR_OP::end_send() } else { - /* - In case we have window functions present, an extra step is required - to compute all the fields from the temporary table. - In case we have a compound expression such as: expr + expr, - where one of the terms has a window function inside it, only - after computing window function values we actually know the true - final result of the compounded expression. - - Go through all the func items and save their values once again in the - corresponding temp table fields. Do this for each row in the table. - */ - if (join_tab->window_funcs_step) - { - Item **func_ptr= join_tab->tmp_table_param->items_to_copy; - Item *func; - for (; (func = *func_ptr) ; func_ptr++) - { - if (func->with_window_func) - func->save_in_result_field(true); - } - } rc= evaluate_join_record(join, join_tab, 0); } } diff --git a/sql/sql_select.h b/sql/sql_select.h index 482b4ff9608..b7f870bf797 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc index da2a91e5880..8f0f08da075 100644 --- a/sql/sql_servers.cc +++ b/sql/sql_servers.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* diff --git a/sql/sql_servers.h b/sql/sql_servers.h index b2fa40cef27..cb5703ef35d 100644 --- a/sql/sql_servers.h +++ b/sql/sql_servers.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "slave.h" // for tables_ok(), rpl_filter diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 54a1d379bb9..d76e2deef99 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Function with list databases, tables or fields */ @@ -5682,7 +5682,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, } if (file->ha_table_flags() & (HA_HAS_OLD_CHECKSUM | HA_HAS_NEW_CHECKSUM)) { - table->field[18]->store((longlong) file->checksum(), TRUE); + table->field[18]->store((longlong) file->stats.checksum, TRUE); table->field[18]->set_notnull(); } } @@ -8565,7 +8565,6 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list) table->alias_name_used= my_strcasecmp(table_alias_charset, table_list->schema_table_name.str, table_list->alias.str); - table_list->table_name= table->s->table_name; table_list->table= table; table->next= thd->derived_tables; thd->derived_tables= table; diff --git a/sql/sql_show.h b/sql/sql_show.h index e9facf8dde2..39cbc35230a 100644 --- a/sql/sql_show.h +++ b/sql/sql_show.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_SHOW_H #define SQL_SHOW_H diff --git a/sql/sql_signal.cc b/sql/sql_signal.cc index 359b5e45f01..320a954711a 100644 --- a/sql/sql_signal.cc +++ b/sql/sql_signal.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_priv.h" diff --git a/sql/sql_signal.h b/sql/sql_signal.h index 4d4601a5ec1..bf42cdb5f07 100644 --- a/sql/sql_signal.h +++ b/sql/sql_signal.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_SIGNAL_H #define SQL_SIGNAL_H diff --git a/sql/sql_sort.h b/sql/sql_sort.h index 231bc93ce75..7abbc808632 100644 --- a/sql/sql_sort.h +++ b/sql/sql_sort.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "my_base.h" /* ha_rows */ #include <my_sys.h> /* qsort2_cmp */ diff --git a/sql/sql_state.c b/sql/sql_state.c index 046868a78a7..66c63dca2d6 100644 --- a/sql/sql_state.c +++ b/sql/sql_state.c @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* Functions to map mysqld errno to sql_state */ diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index e4cc00f45ba..5c8d85c2cc1 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file @@ -2229,6 +2229,9 @@ inline bool statistics_for_command_is_needed(THD *thd) case SQLCOM_DELETE_MULTI: case SQLCOM_REPLACE: case SQLCOM_REPLACE_SELECT: + case SQLCOM_CREATE_TABLE: + case SQLCOM_SET_OPTION: + case SQLCOM_DO: break; default: return FALSE; @@ -3369,12 +3372,13 @@ int read_statistics_for_tables_if_needed(THD *thd, TABLE_LIST *tables) if (table_share->stats_cb.stats_is_read) tl->table->stats_is_read= TRUE; if (thd->variables.optimizer_use_condition_selectivity > 3 && - table_share && !table_share->stats_cb.histograms_are_read) + table_share && table_share->stats_cb.stats_can_be_read && + !table_share->stats_cb.histograms_are_read) { (void) read_histograms_for_table(thd, tl->table, stat_tables); table_share->stats_cb.histograms_are_read= TRUE; } - if (table_share->stats_cb.stats_is_read) + if (table_share->stats_cb.histograms_are_read) tl->table->histograms_are_read= TRUE; } } @@ -4144,6 +4148,14 @@ bool is_stat_table(const LEX_CSTRING *db, LEX_CSTRING *table) bool is_eits_usable(Field *field) { + Column_statistics* col_stats= field->read_stats; + + // check if column_statistics was allocated for this field + if (!col_stats) + return false; + + DBUG_ASSERT(field->table->stats_is_read); + /* (1): checks if we have EITS statistics for a particular column (2): Don't use EITS for GEOMETRY columns @@ -4151,12 +4163,9 @@ bool is_eits_usable(Field *field) partition list of a table. We assume the selecticivity for such columns would be handled during partition pruning. */ -#if 0 /* Work around MDEV-19334 */ - DBUG_ASSERT(field->table->stats_is_read); -#endif - Column_statistics* col_stats= field->read_stats; - return col_stats && !col_stats->no_stat_values_provided() && //(1) - field->type() != MYSQL_TYPE_GEOMETRY && //(2) + + return !col_stats->no_stat_values_provided() && //(1) + field->type() != MYSQL_TYPE_GEOMETRY && //(2) #ifdef WITH_PARTITION_STORAGE_ENGINE (!field->table->part_info || !field->table->part_info->field_in_partition_expr(field)) && //(3) diff --git a/sql/sql_statistics.h b/sql/sql_statistics.h index 3ed4006efd3..c0734c0f6ba 100644 --- a/sql/sql_statistics.h +++ b/sql/sql_statistics.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_STATISTICS_H #define SQL_STATISTICS_H diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 45af08f8966..410f52a8c74 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* This file is originally from the mysql distribution. Coded by monty */ @@ -941,6 +941,27 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length) (void) from->realloc(from_length); return from; } + if (from->uses_buffer_owned_by(to)) + { + DBUG_ASSERT(!from->is_alloced()); + DBUG_ASSERT(to->is_alloced()); + /* + "from" is a constant string pointing to a fragment of alloced string "to": + to= xxxFFFyyy + - FFF is the part of "to" pointed by "from" + - xxx is the part of "to" before "from" + - yyy is the part of "to" after "from" + */ + uint32 xxx_length= (uint32) (from->ptr() - to->ptr()); + uint32 yyy_length= (uint32) (to->end() - from->end()); + DBUG_ASSERT(to->length() >= yyy_length); + to->length(to->length() - yyy_length); // Remove the "yyy" part + DBUG_ASSERT(to->length() >= xxx_length); + to->replace(0, xxx_length, "", 0); // Remove the "xxx" part + to->realloc(from_length); + to->set_charset(from->charset()); + return to; + } if (to->alloc(from_length)) return from; // Actually an error if ((to->str_length=MY_MIN(from->str_length,from_length))) diff --git a/sql/sql_string.h b/sql/sql_string.h index 39555020696..caefee7ec09 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* This file is originally from the mysql distribution. Coded by monty */ @@ -159,6 +159,14 @@ public: { swap_variables(CHARSET_INFO*, m_charset, other.m_charset); } + /* + Collation name without the character set name. + For example, in case of "latin1_swedish_ci", + this method returns "_swedish_ci". + */ + LEX_CSTRING collation_specific_name() const; + bool encoding_allows_reinterpret_as(CHARSET_INFO *cs) const; + bool encoding_and_order_allow_reinterpret_as(CHARSET_INFO *cs) const; }; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e94541b5711..a025bca286b 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* drop and alter of tables */ @@ -6543,8 +6543,16 @@ Compare_keys compare_keys_but_name(const KEY *table_key, const KEY *new_key, *new_part= new_key->key_part; key_part < end; key_part++, new_part++) { + /* + For prefix keys KEY_PART_INFO::field points to cloned Field + object with adjusted length. So below we have to check field + indexes instead of simply comparing pointers to Field objects. + */ Create_field *new_field= alter_info->create_list.elem(new_part->fieldnr); - const Field *old_field= table->field[key_part->fieldnr - 1]; + if (!new_field->field || + new_field->field->field_index != key_part->fieldnr - 1) + return Compare_keys::NotEqual; + /* If there is a change in index length due to column expansion like varchar(X) changed to varchar(X + N) and has a compatible @@ -6554,6 +6562,7 @@ Compare_keys compare_keys_but_name(const KEY *table_key, const KEY *new_key, Key definition has changed if we are using a different field or if the user key part length is different. */ + const Field *old_field= table->field[key_part->fieldnr - 1]; auto old_field_len= old_field->pack_length(); if (old_field->type() == MYSQL_TYPE_VARCHAR) @@ -6571,15 +6580,6 @@ Compare_keys compare_keys_but_name(const KEY *table_key, const KEY *new_key, } else if (key_part->length != new_part->length) return Compare_keys::NotEqual; - - /* - For prefix keys KEY_PART_INFO::field points to cloned Field - object with adjusted length. So below we have to check field - indexes instead of simply comparing pointers to Field objects. - */ - if (!new_field->field || - new_field->field->field_index != key_part->fieldnr - 1) - return Compare_keys::NotEqual; } /* @@ -8992,6 +8992,52 @@ static bool fk_prepare_copy_alter_table(THD *thd, TABLE *table, } } + /* + Normally, an attempt to modify an FK parent table will cause + FK children to be prelocked, so the table-being-altered cannot + be modified by a cascade FK action, because ALTER holds a lock + and prelocking will wait. + + But if a new FK is being added by this very ALTER, then the target + table is not locked yet (it's a temporary table). So, we have to + lock FK parents explicitly. + */ + if (alter_info->flags & ALTER_ADD_FOREIGN_KEY) + { + List_iterator<Key> fk_list_it(alter_info->key_list); + + while (Key *key= fk_list_it++) + { + if (key->type != Key::FOREIGN_KEY) + continue; + + Foreign_key *fk= static_cast<Foreign_key*>(key); + char dbuf[NAME_LEN]; + char tbuf[NAME_LEN]; + const char *ref_db= (fk->ref_db.str ? + fk->ref_db.str : + alter_ctx->new_db.str); + const char *ref_table= fk->ref_table.str; + MDL_request mdl_request; + + if (lower_case_table_names) + { + strmake_buf(dbuf, ref_db); + my_casedn_str(system_charset_info, dbuf); + strmake_buf(tbuf, ref_table); + my_casedn_str(system_charset_info, tbuf); + ref_db= dbuf; + ref_table= tbuf; + } + + mdl_request.init(MDL_key::TABLE, ref_db, ref_table, MDL_SHARED_NO_WRITE, + MDL_TRANSACTION); + if (thd->mdl_context.acquire_lock(&mdl_request, + thd->variables.lock_wait_timeout)) + DBUG_RETURN(true); + } + } + DBUG_RETURN(false); } @@ -10039,6 +10085,7 @@ do_continue:; /* Mark that we have created table in storage engine. */ no_ha_table= false; + DEBUG_SYNC(thd, "alter_table_intermediate_table_created"); /* Open the table since we need to copy the data. */ new_table= thd->create_and_open_tmp_table(&frm, @@ -10054,54 +10101,6 @@ do_continue:; /* in case of alter temp table send the tracker in OK packet */ SESSION_TRACKER_CHANGED(thd, SESSION_STATE_CHANGE_TRACKER, NULL); } - else - { - /* - Normally, an attempt to modify an FK parent table will cause - FK children to be prelocked, so the table-being-altered cannot - be modified by a cascade FK action, because ALTER holds a lock - and prelocking will wait. - - But if a new FK is being added by this very ALTER, then the target - table is not locked yet (it's a temporary table). So, we have to - lock FK parents explicitly. - */ - if (alter_info->flags & ALTER_ADD_FOREIGN_KEY) - { - List <FOREIGN_KEY_INFO> fk_list; - List_iterator<FOREIGN_KEY_INFO> fk_list_it(fk_list); - FOREIGN_KEY_INFO *fk; - - /* tables_opened can be > 1 only for MERGE tables */ - DBUG_ASSERT(tables_opened == 1); - DBUG_ASSERT(&table_list->next_global == thd->lex->query_tables_last); - - new_table->file->get_foreign_key_list(thd, &fk_list); - while ((fk= fk_list_it++)) - { - MDL_request mdl_request; - - if (lower_case_table_names) - { - char buf[NAME_LEN]; - size_t len; - strmake_buf(buf, fk->referenced_db->str); - len = my_casedn_str(files_charset_info, buf); - thd->make_lex_string(fk->referenced_db, buf, len); - strmake_buf(buf, fk->referenced_table->str); - len = my_casedn_str(files_charset_info, buf); - thd->make_lex_string(fk->referenced_table, buf, len); - } - - mdl_request.init(MDL_key::TABLE, - fk->referenced_db->str, fk->referenced_table->str, - MDL_SHARED_NO_WRITE, MDL_TRANSACTION); - if (thd->mdl_context.acquire_lock(&mdl_request, - thd->variables.lock_wait_timeout)) - goto err_new_table_cleanup; - } - } - } /* Note: In case of MERGE table, we do not attach children. We do not @@ -10925,18 +10924,6 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy) } -static void flush_checksum(ha_checksum *row_crc, uchar **checksum_start, - size_t *checksum_length) -{ - if (*checksum_start) - { - *row_crc= my_checksum(*row_crc, *checksum_start, *checksum_length); - *checksum_start= NULL; - *checksum_length= 0; - } -} - - bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) { @@ -11013,96 +11000,31 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, if (!(check_opt->flags & T_EXTEND) && (((t->file->ha_table_flags() & HA_HAS_OLD_CHECKSUM) && thd->variables.old_mode) || ((t->file->ha_table_flags() & HA_HAS_NEW_CHECKSUM) && !thd->variables.old_mode))) - protocol->store((ulonglong)t->file->checksum()); + { + if (t->file->info(HA_STATUS_VARIABLE)) + protocol->store_null(); + else + protocol->store((longlong)t->file->stats.checksum); + } else if (check_opt->flags & T_QUICK) protocol->store_null(); else { - /* calculating table's checksum */ - ha_checksum crc= 0; - DBUG_ASSERT(t->s->last_null_bit_pos < 8); - uchar null_mask= (t->s->last_null_bit_pos ? - (256 - (1 << t->s->last_null_bit_pos)): - 0); - - t->use_all_stored_columns(); - - if (t->file->ha_rnd_init(1)) - protocol->store_null(); - else + int error= t->file->calculate_checksum(); + if (thd->killed) { - for (;;) - { - if (thd->killed) - { - /* - we've been killed; let handler clean up, and remove the - partial current row from the recordset (embedded lib) - */ - t->file->ha_rnd_end(); - thd->protocol->remove_last_row(); - goto err; - } - ha_checksum row_crc= 0; - int error= t->file->ha_rnd_next(t->record[0]); - if (unlikely(error)) - { - break; - } - if (t->s->null_bytes) - { - /* fix undefined null bits */ - t->record[0][t->s->null_bytes-1] |= null_mask; - if (!(t->s->db_create_options & HA_OPTION_PACK_RECORD)) - t->record[0][0] |= 1; - - row_crc= my_checksum(row_crc, t->record[0], t->s->null_bytes); - } - - uchar *checksum_start= NULL; - size_t checksum_length= 0; - for (uint i= 0; i < t->s->fields; i++ ) - { - Field *f= t->field[i]; - - if (! thd->variables.old_mode && f->is_real_null(0)) - { - flush_checksum(&row_crc, &checksum_start, &checksum_length); - continue; - } - /* - BLOB and VARCHAR have pointers in their field, we must convert - to string; GEOMETRY is implemented on top of BLOB. - BIT may store its data among NULL bits, convert as well. - */ - switch (f->type()) { - case MYSQL_TYPE_BLOB: - case MYSQL_TYPE_VARCHAR: - case MYSQL_TYPE_GEOMETRY: - case MYSQL_TYPE_BIT: - { - flush_checksum(&row_crc, &checksum_start, &checksum_length); - String tmp; - f->val_str(&tmp); - row_crc= my_checksum(row_crc, (uchar*) tmp.ptr(), - tmp.length()); - break; - } - default: - if (!checksum_start) - checksum_start= f->ptr; - DBUG_ASSERT(checksum_start + checksum_length == f->ptr); - checksum_length+= f->pack_length(); - break; - } - } - flush_checksum(&row_crc, &checksum_start, &checksum_length); - - crc+= row_crc; - } - protocol->store((ulonglong)crc); + /* + we've been killed; let handler clean up, and remove the + partial current row from the recordset (embedded lib) + */ t->file->ha_rnd_end(); + thd->protocol->remove_last_row(); + goto err; } + if (error) + protocol->store_null(); + else + protocol->store((longlong)t->file->stats.checksum); } trans_rollback_stmt(thd); close_thread_tables(thd); diff --git a/sql/sql_table.h b/sql/sql_table.h index 50085bba9a6..5b6349fc0bf 100644 --- a/sql/sql_table.h +++ b/sql/sql_table.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_TABLE_INCLUDED #define SQL_TABLE_INCLUDED diff --git a/sql/sql_tablespace.cc b/sql/sql_tablespace.cc index d97d50912e6..d912fabe8c8 100644 --- a/sql/sql_tablespace.cc +++ b/sql/sql_tablespace.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* drop and alter of tablespaces */ diff --git a/sql/sql_tablespace.h b/sql/sql_tablespace.h index ae77d15cbcb..0760935edfc 100644 --- a/sql/sql_tablespace.h +++ b/sql/sql_tablespace.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_TABLESPACE_INCLUDED #define SQL_TABLESPACE_INCLUDED diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 93085251711..68d30d5fecb 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Write some debug info */ @@ -596,13 +596,13 @@ update: %10lu\n", tmp.ha_update_count); printf("\nTable status:\n\ Opened tables: %10lu\n\ -Open tables: %10lu\n\ -Open files: %10lu\n\ +Open tables: %10u\n\ +Open files: %10u\n\ Open streams: %10lu\n", tmp.opened_tables, - (ulong) tc_records(), - (ulong) my_file_opened, - (ulong) my_stream_opened); + tc_records(), + my_file_opened, + my_stream_opened); #ifndef DONT_USE_THR_ALARM ALARM_INFO alarm_info; diff --git a/sql/sql_test.h b/sql/sql_test.h index cbef581b784..2ab305acd66 100644 --- a/sql/sql_test.h +++ b/sql/sql_test.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_TEST_INCLUDED #define SQL_TEST_INCLUDED diff --git a/sql/sql_time.cc b/sql/sql_time.cc index fea23020d7e..c64995fa3d6 100644 --- a/sql/sql_time.cc +++ b/sql/sql_time.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Functions to handle date and time */ diff --git a/sql/sql_time.h b/sql/sql_time.h index 161d08c80b8..25980d6417c 100644 --- a/sql/sql_time.h +++ b/sql/sql_time.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_TIME_INCLUDED #define SQL_TIME_INCLUDED diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 96f21bc47a7..64bf24aa4fc 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #define MYSQL_LEX 1 diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h index 210e52887f1..ae3d1738b16 100644 --- a/sql/sql_trigger.h +++ b/sql/sql_trigger.h @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include <mysqld_error.h> diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index 389276d0bcf..bfcdda6e0e9 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "debug_sync.h" // DEBUG_SYNC @@ -147,15 +147,11 @@ fk_truncate_illegal_if_parent(THD *thd, TABLE *table) /* Loop over the set of foreign keys for which this table is a parent. */ while ((fk_info= it++)) { - DBUG_ASSERT(!lex_string_cmp(system_charset_info, - fk_info->referenced_db, - &table->s->db)); - - DBUG_ASSERT(!lex_string_cmp(system_charset_info, - fk_info->referenced_table, - &table->s->table_name)); - - if (lex_string_cmp(system_charset_info, fk_info->foreign_db, + if (lex_string_cmp(system_charset_info, fk_info->referenced_db, + &table->s->db) || + lex_string_cmp(system_charset_info, fk_info->referenced_table, + &table->s->table_name) || + lex_string_cmp(system_charset_info, fk_info->foreign_db, &table->s->db) || lex_string_cmp(system_charset_info, fk_info->foreign_table, &table->s->table_name)) @@ -275,6 +271,9 @@ Sql_cmd_truncate_table::handler_truncate(THD *thd, TABLE_LIST *table_ref, bool Sql_cmd_truncate_table::lock_table(THD *thd, TABLE_LIST *table_ref, bool *hton_can_recreate) { + handlerton *hton; + bool versioned; + bool sequence= false; TABLE *table= NULL; DBUG_ENTER("Sql_cmd_truncate_table::lock_table"); @@ -302,43 +301,43 @@ bool Sql_cmd_truncate_table::lock_table(THD *thd, TABLE_LIST *table_ref, table_ref->table_name.str, NULL))) DBUG_RETURN(TRUE); - *hton_can_recreate= ha_check_storage_engine_flag(table->file->ht, - HTON_CAN_RECREATE); + versioned= table->versioned(); + hton= table->file->ht; table_ref->mdl_request.ticket= table->mdl_ticket; } else { - handlerton *hton; - bool is_sequence; - - /* Acquire an exclusive lock. */ DBUG_ASSERT(table_ref->next_global == NULL); if (lock_table_names(thd, table_ref, NULL, thd->variables.lock_wait_timeout, 0)) DBUG_RETURN(TRUE); - if (!ha_table_exists(thd, &table_ref->db, &table_ref->table_name, - &hton, &is_sequence) || - hton == view_pseudo_hton) + TABLE_SHARE *share= tdc_acquire_share(thd, table_ref, GTS_TABLE | GTS_VIEW); + if (share == NULL) + DBUG_RETURN(TRUE); + DBUG_ASSERT(share != UNUSABLE_TABLE_SHARE); + + versioned= share->versioned; + sequence= share->table_type == TABLE_TYPE_SEQUENCE; + hton= share->db_type(); + + tdc_release_share(share); + + if (hton == view_pseudo_hton) { my_error(ER_NO_SUCH_TABLE, MYF(0), table_ref->db.str, table_ref->table_name.str); DBUG_RETURN(TRUE); } + } - if (!hton) - { - /* - The table exists, but its storage engine is unknown, perhaps not - loaded at the moment. We need to open and parse the frm to know the - storage engine in question, so let's proceed with the truncation and - try to open the table. This will produce the correct error message - about unknown engine. - */ - *hton_can_recreate= false; - } - else - *hton_can_recreate= !is_sequence && hton->flags & HTON_CAN_RECREATE; + *hton_can_recreate= !sequence + && ha_check_storage_engine_flag(hton, HTON_CAN_RECREATE); + + if (versioned) + { + my_error(ER_VERS_NOT_SUPPORTED, MYF(0), "TRUNCATE TABLE"); + DBUG_RETURN(TRUE); } /* diff --git a/sql/sql_truncate.h b/sql/sql_truncate.h index b8525fd6abb..7d2ff4b6050 100644 --- a/sql/sql_truncate.h +++ b/sql/sql_truncate.h @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ class THD; struct TABLE_LIST; diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc index f16d34e8041..ef8e15df838 100644 --- a/sql/sql_tvc.cc +++ b/sql/sql_tvc.cc @@ -262,6 +262,35 @@ bool table_value_constr::prepare(THD *thd, SELECT_LEX *sl, if (result && result->prepare(sl->item_list, unit_arg)) DBUG_RETURN(true); + /* + setup_order() for a TVC is not called when the following is true + (thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW) + */ + + thd->where="order clause"; + ORDER *order= sl->order_list.first; + for (; order; order=order->next) + { + Item *order_item= *order->item; + if (order_item->is_order_clause_position()) + { + uint count= 0; + if (order->counter_used) + count= order->counter; // counter was once resolved + else + count= (uint) order_item->val_int(); + if (!count || count > first_elem->elements) + { + my_error(ER_BAD_FIELD_ERROR, MYF(0), + order_item->full_name(), thd->where); + DBUG_RETURN(true); + } + order->in_field_list= 1; + order->counter= count; + order->counter_used= 1; + } + } + select_lex->in_tvc= false; DBUG_RETURN(false); } @@ -343,6 +372,7 @@ bool table_value_constr::exec(SELECT_LEX *sl) DBUG_ENTER("table_value_constr::exec"); List_iterator_fast<List_item> li(lists_of_values); List_item *elem; + ha_rows send_records= 0; if (select_options & SELECT_DESCRIBE) DBUG_RETURN(false); @@ -356,7 +386,13 @@ bool table_value_constr::exec(SELECT_LEX *sl) while ((elem= li++)) { - result->send_data(*elem); + if (send_records >= sl->master_unit()->select_limit_cnt) + break; + int rc= result->send_data(*elem); + if (!rc) + send_records++; + else if (rc > 0) + DBUG_RETURN(true); } if (result->send_eof()) @@ -435,6 +471,12 @@ void table_value_constr::print(THD *thd, String *str, print_list_item(str, list, query_type); } + if (select_lex->order_list.elements) + { + str->append(STRING_WITH_LEN(" order by ")); + select_lex->print_order(str, select_lex->order_list.first, query_type); + } + select_lex->print_limit(thd, str, query_type); } @@ -532,7 +574,8 @@ static bool create_tvc_name(THD *thd, st_select_lex *parent_select, char buff[6]; alias->length= my_snprintf(buff, sizeof(buff), - "tvc_%u", parent_select->curr_tvc_name); + "tvc_%u", + parent_select ? parent_select->curr_tvc_name : 0); alias->str= thd->strmake(buff, alias->length); if (!alias->str) return true; @@ -541,19 +584,57 @@ static bool create_tvc_name(THD *thd, st_select_lex *parent_select, } -bool Item_subselect::wrap_tvc_in_derived_table(THD *thd, - st_select_lex *tvc_sl) +/** + @brief + Check whether TVC used in unit is to be wrapped into select + + @details + TVC used in unit that contains more than one members is to be wrapped + into select if it is tailed with ORDER BY ... LIMIT n [OFFSET m] + + @retval + true if TVC is to be wrapped + false otherwise +*/ + +bool table_value_constr::to_be_wrapped_as_with_tail() +{ + return select_lex->master_unit()->first_select()->next_select() && + select_lex->order_list.elements && select_lex->explicit_limit; +} + + +/** + @brief + Wrap table value constructor into a select + + @param thd The context handler + @param tvc_sl The TVC to wrap + @parent_select The parent select if tvc_sl used in a subquery + + @details + The function wraps the TVC tvc_sl into a select: + the function transforms the TVC of the form VALUES (v1), ... (vn) into + the select of the form + SELECT * FROM (VALUES (v1), ... (vn)) tvc_x + + @retval pointer to the result of of the transformation if successful + NULL - otherwise +*/ + +static +st_select_lex *wrap_tvc(THD *thd, st_select_lex *tvc_sl, + st_select_lex *parent_select) { LEX *lex= thd->lex; - /* SELECT_LEX object where the transformation is performed */ - SELECT_LEX *parent_select= lex->current_select; + select_result *save_result= thd->lex->result; uint8 save_derived_tables= lex->derived_tables; + thd->lex->result= NULL; Query_arena backup; Query_arena *arena= thd->activate_stmt_arena_if_needed(&backup); - /* - Create SELECT_LEX of the subquery SQ used in the result of transformation + Create SELECT_LEX of the select used in the result of transformation */ lex->current_select= tvc_sl; if (mysql_new_select(lex, 0, NULL)) @@ -561,15 +642,15 @@ bool Item_subselect::wrap_tvc_in_derived_table(THD *thd, mysql_init_select(lex); /* Create item list as '*' for the subquery SQ */ Item *item; - SELECT_LEX *sq_select; // select for IN subquery; - sq_select= lex->current_select; - sq_select->set_linkage(tvc_sl->get_linkage()); - sq_select->parsing_place= SELECT_LIST; - item= new (thd->mem_root) Item_field(thd, &sq_select->context, + SELECT_LEX *wrapper_sl; + wrapper_sl= lex->current_select; + wrapper_sl->set_linkage(tvc_sl->get_linkage()); + wrapper_sl->parsing_place= SELECT_LIST; + item= new (thd->mem_root) Item_field(thd, &wrapper_sl->context, NULL, NULL, &star_clex_str); if (item == NULL || add_item_to_list(thd, item)) goto err; - (sq_select->with_wild)++; + (wrapper_sl->with_wild)++; /* Exclude SELECT with TVC */ tvc_sl->exclude(); @@ -584,11 +665,11 @@ bool Item_subselect::wrap_tvc_in_derived_table(THD *thd, derived_unit= tvc_select->master_unit(); tvc_select->set_linkage(DERIVED_TABLE_TYPE); - lex->current_select= sq_select; + lex->current_select= wrapper_sl; /* Create the name of the wrapping derived table and - add it to the FROM list of the subquery SQ + add it to the FROM list of the wrapper */ Table_ident *ti; LEX_CSTRING alias; @@ -597,35 +678,120 @@ bool Item_subselect::wrap_tvc_in_derived_table(THD *thd, create_tvc_name(thd, parent_select, &alias)) goto err; if (!(derived_tab= - sq_select->add_table_to_list(thd, - ti, &alias, 0, - TL_READ, MDL_SHARED_READ))) + wrapper_sl->add_table_to_list(thd, + ti, &alias, 0, + TL_READ, MDL_SHARED_READ))) goto err; - sq_select->add_joined_table(derived_tab); - sq_select->add_where_field(derived_unit->first_select()); - sq_select->context.table_list= sq_select->table_list.first; - sq_select->context.first_name_resolution_table= sq_select->table_list.first; - sq_select->table_list.first->derived_type= DTYPE_TABLE | DTYPE_MATERIALIZE; + wrapper_sl->add_joined_table(derived_tab); + wrapper_sl->add_where_field(derived_unit->first_select()); + wrapper_sl->context.table_list= wrapper_sl->table_list.first; + wrapper_sl->context.first_name_resolution_table= wrapper_sl->table_list.first; + wrapper_sl->table_list.first->derived_type= DTYPE_TABLE | DTYPE_MATERIALIZE; lex->derived_tables|= DERIVED_SUBQUERY; - sq_select->where= 0; - sq_select->set_braces(false); + wrapper_sl->where= 0; + wrapper_sl->set_braces(false); derived_unit->set_with_clause(0); - if (engine->engine_type() == subselect_engine::SINGLE_SELECT_ENGINE) - ((subselect_single_select_engine *) engine)->change_select(sq_select); - if (arena) thd->restore_active_arena(arena, &backup); - lex->current_select= sq_select; - return false; + thd->lex->result= save_result; + return wrapper_sl; err: if (arena) thd->restore_active_arena(arena, &backup); + thd->lex->result= save_result; lex->derived_tables= save_derived_tables; - lex->current_select= parent_select; - return true; + return 0; +} + + +/** + @brief + Wrap TVC with ORDER BY ... LIMIT tail into a select + + @param thd The context handler + @param tvc_sl The TVC to wrap + + @details + The function wraps the TVC tvc_sl into a select: + the function transforms the TVC with tail of the form + VALUES (v1), ... (vn) ORDER BY ... LIMIT n [OFFSET m] + into the select with the same tail of the form + SELECT * FROM (VALUES (v1), ... (vn)) tvc_x + ORDER BY ... LIMIT n [OFFSET m] + + @retval pointer to the result of of the transformation if successful + NULL - otherwise +*/ + +st_select_lex *wrap_tvc_with_tail(THD *thd, st_select_lex *tvc_sl) +{ + st_select_lex *wrapper_sl= wrap_tvc(thd, tvc_sl, NULL); + if (!wrapper_sl) + return NULL; + + wrapper_sl->order_list= tvc_sl->order_list; + wrapper_sl->select_limit= tvc_sl->select_limit; + wrapper_sl->offset_limit= tvc_sl->offset_limit; + wrapper_sl->braces= tvc_sl->braces; + wrapper_sl->explicit_limit= tvc_sl->explicit_limit; + tvc_sl->order_list.empty(); + tvc_sl->select_limit= NULL; + tvc_sl->offset_limit= NULL; + tvc_sl->braces= 0; + tvc_sl->explicit_limit= false; + if (tvc_sl->select_number == 1) + { + tvc_sl->select_number= wrapper_sl->select_number; + wrapper_sl->select_number= 1; + } + if (tvc_sl->master_unit()->union_distinct == tvc_sl) + { + wrapper_sl->master_unit()->union_distinct= wrapper_sl; + } + thd->lex->current_select= wrapper_sl; + return wrapper_sl; +} + + +/** + @brief + Wrap TVC in a subselect into a select + + @param thd The context handler + @param tvc_sl The TVC to wrap + + @details + The function wraps the TVC tvc_sl used in a subselect into a select + the function transforms the TVC of the form VALUES (v1), ... (vn) + into the select the form + SELECT * FROM (VALUES (v1), ... (vn)) tvc_x + and replaces the subselect with the result of the transformation. + + @retval false if successfull + true otherwise +*/ + +bool Item_subselect::wrap_tvc_into_select(THD *thd, st_select_lex *tvc_sl) +{ + LEX *lex= thd->lex; + /* SELECT_LEX object where the transformation is performed */ + SELECT_LEX *parent_select= lex->current_select; + SELECT_LEX *wrapper_sl= wrap_tvc(thd, tvc_sl, parent_select); + if (wrapper_sl) + { + if (engine->engine_type() == subselect_engine::SINGLE_SELECT_ENGINE) + ((subselect_single_select_engine *) engine)->change_select(wrapper_sl); + lex->current_select= wrapper_sl; + return false; + } + else + { + lex->current_select= parent_select; + return true; + } } diff --git a/sql/sql_tvc.h b/sql/sql_tvc.h index 128cc883dd8..594a77af65c 100644 --- a/sql/sql_tvc.h +++ b/sql/sql_tvc.h @@ -57,6 +57,8 @@ public: select_result *tmp_result, st_select_lex_unit *unit_arg); + bool to_be_wrapped_as_with_tail(); + int save_explain_data_intern(THD *thd_arg, Explain_query *output); bool optimize(THD *thd_arg); @@ -64,4 +66,7 @@ public: void print(THD *thd_arg, String *str, enum_query_type query_type); }; + +st_select_lex *wrap_tvc_with_tail(THD *thd, st_select_lex *tvc_sl); + #endif /* SQL_TVC_INCLUDED */ diff --git a/sql/sql_type.cc b/sql/sql_type.cc index 94b0ab9a6c1..fc33b6d1427 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "sql_type.h" @@ -134,6 +134,32 @@ bool Type_handler_data::init() Type_handler_data *type_handler_data= NULL; +bool Float::to_string(String *val_buffer, uint dec) const +{ + uint to_length= 70; + if (val_buffer->alloc(to_length)) + return true; + + char *to=(char*) val_buffer->ptr(); + size_t len; + + if (dec >= FLOATING_POINT_DECIMALS) + len= my_gcvt(m_value, MY_GCVT_ARG_FLOAT, to_length - 1, to, NULL); + else + { + /* + We are safe here because the buffer length is 70, and + fabs(float) < 10^39, dec < FLOATING_POINT_DECIMALS. So the resulting string + will be not longer than 69 chars + terminating '\0'. + */ + len= my_fcvt(m_value, (int) dec, to, NULL); + } + val_buffer->length((uint) len); + val_buffer->set_charset(&my_charset_numeric); + return false; +} + + String_ptr::String_ptr(Item *item, String *buffer) :m_string_ptr(item->val_str(buffer)) { } @@ -3747,9 +3773,15 @@ Type_handler_year::Item_get_cache(THD *thd, const Item *item) const } Item_cache * -Type_handler_real_result::Item_get_cache(THD *thd, const Item *item) const +Type_handler_double::Item_get_cache(THD *thd, const Item *item) const +{ + return new (thd->mem_root) Item_cache_double(thd); +} + +Item_cache * +Type_handler_float::Item_get_cache(THD *thd, const Item *item) const { - return new (thd->mem_root) Item_cache_real(thd); + return new (thd->mem_root) Item_cache_float(thd); } Item_cache * @@ -4490,7 +4522,7 @@ void Type_handler_temporal_result::Item_get_date(THD *thd, Item *item, longlong Type_handler_real_result:: Item_val_int_signed_typecast(Item *item) const { - return item->val_int_signed_typecast_from_int(); + return item->val_int_signed_typecast_from_real(); } longlong Type_handler_int_result:: @@ -4502,7 +4534,7 @@ longlong Type_handler_int_result:: longlong Type_handler_decimal_result:: Item_val_int_signed_typecast(Item *item) const { - return item->val_int(); + return VDec(item).to_longlong(false); } longlong Type_handler_temporal_result:: @@ -4522,7 +4554,7 @@ longlong Type_handler_string_result:: longlong Type_handler_real_result:: Item_val_int_unsigned_typecast(Item *item) const { - return item->val_int_unsigned_typecast_from_int(); + return item->val_int_unsigned_typecast_from_real(); } longlong Type_handler_int_result:: @@ -4537,6 +4569,32 @@ longlong Type_handler_temporal_result:: return item->val_int_unsigned_typecast_from_int(); } +longlong Type_handler_time_common:: + Item_val_int_unsigned_typecast(Item *item) const +{ + /* + TODO: this should eventually be fixed to do rounding + when TIME_ROUND_FRACTIONAL is enabled, together with + Field_{tiny|short|long|longlong}::store_time_dec(). + See MDEV-19502. + */ + THD *thd= current_thd; + Time tm(thd, item); + DBUG_ASSERT(!tm.is_valid_time() == item->null_value); + if (!tm.is_valid_time()) + return 0; + longlong res= tm.to_longlong(); + if (res < 0) + { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, + ER_DATA_OVERFLOW, ER_THD(thd, ER_DATA_OVERFLOW), + ErrConvTime(tm.get_mysql_time()).ptr(), + "UNSIGNED BIGINT"); + return 0; + } + return res; +} + longlong Type_handler_string_result:: Item_val_int_unsigned_typecast(Item *item) const { @@ -4704,13 +4762,24 @@ Type_handler_int_result::Item_func_hybrid_field_type_get_date( /***************************************************************************/ String * -Type_handler_real_result::Item_func_hybrid_field_type_val_str( +Type_handler_double::Item_func_hybrid_field_type_val_str( Item_func_hybrid_field_type *item, String *str) const { return item->val_str_from_real_op(str); } +String * +Type_handler_float::Item_func_hybrid_field_type_val_str( + Item_func_hybrid_field_type *item, + String *str) const +{ + Float nr(item->real_op()); + if (item->null_value) + return 0; + nr.to_string(str, item->decimals); + return str; +} double Type_handler_real_result::Item_func_hybrid_field_type_val_real( @@ -5234,13 +5303,24 @@ String *Type_handler_decimal_result:: } -String *Type_handler_real_result:: +String *Type_handler_double:: Item_func_min_max_val_str(Item_func_min_max *func, String *str) const { return func->val_string_from_real(str); } +String *Type_handler_float:: + Item_func_min_max_val_str(Item_func_min_max *func, String *str) const +{ + Float nr(func->val_real()); + if (func->null_value) + return 0; + nr.to_string(str, func->decimals); + return str; +} + + double Type_handler_string_result:: Item_func_min_max_val_real(Item_func_min_max *func) const { @@ -5863,6 +5943,14 @@ bool Type_handler:: bool Type_handler:: + Item_float_typecast_fix_length_and_dec(Item_float_typecast *item) const +{ + item->fix_length_and_dec_generic(); + return false; +} + + +bool Type_handler:: Item_decimal_typecast_fix_length_and_dec(Item_decimal_typecast *item) const { item->fix_length_and_dec_generic(); @@ -5952,6 +6040,13 @@ bool Type_handler_geometry:: bool Type_handler_geometry:: + Item_float_typecast_fix_length_and_dec(Item_float_typecast *item) const +{ + return Item_func_or_sum_illegal_param(item); +} + + +bool Type_handler_geometry:: Item_decimal_typecast_fix_length_and_dec(Item_decimal_typecast *item) const { return Item_func_or_sum_illegal_param(item); @@ -6997,6 +7092,15 @@ Item *Type_handler_double:: } +Item *Type_handler_float:: + create_typecast_item(THD *thd, Item *item, + const Type_cast_attributes &attr) const +{ + DBUG_ASSERT(!attr.length_specified()); + return new (thd->mem_root) Item_float_typecast(thd, item); +} + + Item *Type_handler_long_blob:: create_typecast_item(THD *thd, Item *item, const Type_cast_attributes &attr) const @@ -8219,48 +8323,60 @@ Type_handler_timestamp_common::Item_param_val_native(THD *thd, TIME_to_native(thd, <ime, to, item->datetime_precision(thd)); } -static bool charsets_are_compatible(const char *old_cs_name, - const CHARSET_INFO *new_ci) -{ - const char *new_cs_name= new_ci->csname; - if (!strcmp(old_cs_name, new_cs_name)) - return true; +LEX_CSTRING Charset::collation_specific_name() const +{ + /* + User defined collations can provide arbitrary names + for character sets and collations, so a collation + name not necessarily starts with the character set name. + */ + size_t csname_length= strlen(m_charset->csname); + if (strncmp(m_charset->name, m_charset->csname, csname_length)) + return {NULL, 0}; + const char *ptr= m_charset->name + csname_length; + return {ptr, strlen(ptr) }; +} - if (!strcmp(old_cs_name, MY_UTF8MB3) && !strcmp(new_cs_name, MY_UTF8MB4)) - return true; - if (!strcmp(old_cs_name, "ascii") && !(new_ci->state & MY_CS_NONASCII)) +bool +Charset::encoding_allows_reinterpret_as(const CHARSET_INFO *cs) const +{ + if (!strcmp(m_charset->csname, cs->csname)) return true; - if (!strcmp(old_cs_name, "ucs2") && !strcmp(new_cs_name, "utf16")) + if (!strcmp(m_charset->csname, MY_UTF8MB3) && + !strcmp(cs->csname, MY_UTF8MB4)) return true; + /* + Originally we allowed here instat ALTER for ASCII-to-LATIN1 + and UCS2-to-UTF16, but this was wrong: + - MariaDB's ascii is not a subset for 8-bit character sets + like latin1, because it allows storing bytes 0x80..0xFF as + "unassigned" characters (see MDEV-19285). + - MariaDB's ucs2 (as in Unicode-1.1) is not a subset for UTF16, + because they treat surrogate codes differently (MDEV-19284). + */ return false; } -bool Type_handler::Charsets_are_compatible(const CHARSET_INFO *old_ci, - const CHARSET_INFO *new_ci, - bool part_of_a_key) -{ - const char *old_cs_name= old_ci->csname; - const char *new_cs_name= new_ci->csname; - - if (!charsets_are_compatible(old_cs_name, new_ci)) - { - return false; - } - if (!part_of_a_key) - { +bool +Charset::encoding_and_order_allow_reinterpret_as(CHARSET_INFO *cs) const +{ + /* + Test quickly if we have two exactly equal CHARSET_INFO pointers. + This also handles a special case with my_charset_bin: + it does not have a collation name specific part in CHARSET_INFO::name, + which is just "binary" (without a character set name prefix), + so the code with collation_specific_name() below won't work for it. + */ + if (m_charset == cs) return true; - } - - if (strcmp(old_ci->name + strlen(old_cs_name), - new_ci->name + strlen(new_cs_name))) - { + if (!encoding_allows_reinterpret_as(cs)) return false; - } - - return true; + LEX_CSTRING name0= collation_specific_name(); + LEX_CSTRING name1= Charset(cs).collation_specific_name(); + return name0.length && !cmp(&name0, &name1); } diff --git a/sql/sql_type.h b/sql/sql_type.h index 569e8742d2f..6d9d802913f 100644 --- a/sql/sql_type.h +++ b/sql/sql_type.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ @@ -25,6 +25,7 @@ #include "sql_array.h" #include "sql_const.h" #include "sql_time.h" +#include "sql_type_real.h" #include "compat56.h" class Field; @@ -55,6 +56,7 @@ class Item_func_neg; class Item_func_signed; class Item_func_unsigned; class Item_double_typecast; +class Item_float_typecast; class Item_decimal_typecast; class Item_char_typecast; class Item_time_typecast; @@ -3682,6 +3684,8 @@ public: virtual bool Item_double_typecast_fix_length_and_dec(Item_double_typecast *item) const; virtual bool + Item_float_typecast_fix_length_and_dec(Item_float_typecast *item) const; + virtual bool Item_decimal_typecast_fix_length_and_dec(Item_decimal_typecast *item) const; virtual bool Item_char_typecast_fix_length_and_dec(Item_char_typecast *item) const; @@ -3705,10 +3709,6 @@ public: virtual bool Vers_history_point_resolve_unit(THD *thd, Vers_history_point *point) const; - - static bool Charsets_are_compatible(const CHARSET_INFO *old_ci, - const CHARSET_INFO *new_ci, - bool part_of_a_key); }; @@ -4025,6 +4025,11 @@ public: DBUG_ASSERT(0); return true; } + bool Item_float_typecast_fix_length_and_dec(Item_float_typecast *) const + { + DBUG_ASSERT(0); + return true; + } bool Item_decimal_typecast_fix_length_and_dec(Item_decimal_typecast *) const { DBUG_ASSERT(0); @@ -4119,7 +4124,6 @@ public: void Item_update_null_value(Item *item) const; int Item_save_in_field(Item *item, Field *field, bool no_conversions) const; Item *make_const_item_for_comparison(THD *, Item *src, const Item *cmp) const; - Item_cache *Item_get_cache(THD *thd, const Item *item) const; bool set_comparator_func(Arg_comparator *cmp) const; bool Item_hybrid_func_fix_attributes(THD *thd, const char *name, @@ -4140,8 +4144,6 @@ public: longlong Item_val_int_signed_typecast(Item *item) const; longlong Item_val_int_unsigned_typecast(Item *item) const; String *Item_func_hex_val_str_ascii(Item_func_hex *item, String *str) const; - String *Item_func_hybrid_field_type_val_str(Item_func_hybrid_field_type *, - String *) const; double Item_func_hybrid_field_type_val_real(Item_func_hybrid_field_type *) const; longlong Item_func_hybrid_field_type_val_int(Item_func_hybrid_field_type *) @@ -4154,7 +4156,6 @@ public: Temporal::Warn *, MYSQL_TIME *, date_mode_t fuzzydate) const; - String *Item_func_min_max_val_str(Item_func_min_max *, String *) const; longlong Item_func_between_val_int(Item_func_between *func) const; cmp_item *make_cmp_item(THD *thd, CHARSET_INFO *cs) const; in_vector *make_in_vector(THD *, const Item_func_in *, uint nargs) const; @@ -5089,6 +5090,8 @@ public: bool type_can_have_auto_increment_attribute() const { return true; } uint32 max_display_length(const Item *item) const { return 25; } uint32 calc_pack_length(uint32 length) const { return sizeof(float); } + Item *create_typecast_item(THD *thd, Item *item, + const Type_cast_attributes &attr) const; bool Item_send(Item *item, Protocol *protocol, st_value *buf) const { return Item_send_float(item, protocol, buf); @@ -5114,6 +5117,11 @@ public: uint32 flags) const; void Item_param_set_param_func(Item_param *param, uchar **pos, ulong len) const; + + Item_cache *Item_get_cache(THD *thd, const Item *item) const; + String *Item_func_hybrid_field_type_val_str(Item_func_hybrid_field_type *, + String *) const; + String *Item_func_min_max_val_str(Item_func_min_max *, String *) const; }; @@ -5157,6 +5165,11 @@ public: uint32 flags) const; void Item_param_set_param_func(Item_param *param, uchar **pos, ulong len) const; + + Item_cache *Item_get_cache(THD *thd, const Item *item) const; + String *Item_func_hybrid_field_type_val_str(Item_func_hybrid_field_type *, + String *) const; + String *Item_func_min_max_val_str(Item_func_min_max *, String *) const; }; @@ -5203,6 +5216,7 @@ public: int Item_save_in_field(Item *item, Field *field, bool no_conversions) const; String *print_item_value(THD *thd, Item *item, String *str) const; Item_cache *Item_get_cache(THD *thd, const Item *item) const; + longlong Item_val_int_unsigned_typecast(Item *item) const; bool Item_hybrid_func_fix_attributes(THD *thd, const char *name, Type_handler_hybrid_field_type *, @@ -6112,6 +6126,7 @@ public: bool Item_func_signed_fix_length_and_dec(Item_func_signed *) const; bool Item_func_unsigned_fix_length_and_dec(Item_func_unsigned *) const; bool Item_double_typecast_fix_length_and_dec(Item_double_typecast *) const; + bool Item_float_typecast_fix_length_and_dec(Item_float_typecast *) const; bool Item_decimal_typecast_fix_length_and_dec(Item_decimal_typecast *) const; bool Item_char_typecast_fix_length_and_dec(Item_char_typecast *) const; bool Item_time_typecast_fix_length_and_dec(Item_time_typecast *) const; diff --git a/sql/sql_type_int.h b/sql/sql_type_int.h index c7fcd3f793b..054a861d190 100644 --- a/sql/sql_type_int.h +++ b/sql/sql_type_int.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_TYPE_INT_INCLUDED #define SQL_TYPE_INT_INCLUDED diff --git a/sql/sql_type_real.h b/sql/sql_type_real.h new file mode 100644 index 00000000000..5a484fbeffb --- /dev/null +++ b/sql/sql_type_real.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2019 MariaDB + + 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 + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +#ifndef SQL_TYPE_REAL_INCLUDED +#define SQL_TYPE_REAL_INCLUDED + +#include <cmath> + +class Float +{ + float m_value; +public: + Float(float nr) + :m_value(nr) + { + DBUG_ASSERT(!std::isnan(nr)); + DBUG_ASSERT(!std::isinf(nr)); + } + Float(double nr) + :m_value((float) nr) + { + DBUG_ASSERT(!std::isnan(nr)); + DBUG_ASSERT(!std::isinf(nr)); + DBUG_ASSERT(nr <= FLT_MAX); + DBUG_ASSERT(nr >= -FLT_MAX); + } + Float(const uchar *ptr) + { + float4get(m_value, ptr); + } + bool to_string(String *to, uint dec) const; +}; + + +#endif // SQL_TYPE_REAL_INCLUDED diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index aee4869bd40..35c799d4a86 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* This implements 'user defined functions' */ diff --git a/sql/sql_udf.h b/sql/sql_udf.h index 4fa75759269..ac58a176fed 100644 --- a/sql/sql_udf.h +++ b/sql/sql_udf.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* This file defines structures needed by udf functions */ diff --git a/sql/sql_union.cc b/sql/sql_union.cc index c32a6ee852f..41f4234c13d 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* @@ -831,7 +831,8 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg, bool is_union_select; bool have_except= FALSE, have_intersect= FALSE; bool instantiate_tmp_table= false; - bool single_tvc= !first_sl->next_select() && first_sl->tvc; + bool single_tvc= !first_sl->next_select() && first_sl->tvc && + !fake_select_lex; DBUG_ENTER("st_select_lex_unit::prepare"); DBUG_ASSERT(thd == current_thd); @@ -981,12 +982,45 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg, types= first_sl->item_list; goto cont; } - + + if (sl->tvc && sl->order_list.elements && + !sl->tvc->to_be_wrapped_as_with_tail()) + { + if (thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW) + { + sl->master_unit()->fake_select_lex= 0; + sl->master_unit()->saved_fake_select_lex= 0; + } + else + { + sl->order_list.empty(); + sl->explicit_limit= 0; + sl->select_limit= 0; + sl->offset_limit= 0; + } + } + for (;sl; sl= sl->next_select(), union_part_count++) { if (sl->tvc) { - if (sl->tvc->prepare(thd, sl, tmp_result, this)) + if (sl->tvc->to_be_wrapped_as_with_tail() && + !(thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW)) + + { + st_select_lex *wrapper_sl= wrap_tvc_with_tail(thd, sl); + if (!wrapper_sl) + goto err; + + if (sl == first_sl) + first_sl= wrapper_sl; + sl= wrapper_sl; + + if (prepare_join(thd, sl, tmp_result, additional_options, + is_union_select)) + goto err; + } + else if (sl->tvc->prepare(thd, sl, tmp_result, this)) goto err; } else if (prepare_join(thd, sl, tmp_result, additional_options, diff --git a/sql/sql_union.h b/sql/sql_union.h index d5659e5d947..3776831bdd7 100644 --- a/sql/sql_union.h +++ b/sql/sql_union.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_UNION_INCLUDED #define SQL_UNION_INCLUDED diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 723a3f26dc9..fe021e27505 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* @@ -1642,6 +1642,9 @@ int mysql_multi_update_prepare(THD *thd) List<Item> *fields= &lex->first_select_lex()->item_list; table_map tables_for_update; bool update_view= 0; + DML_prelocking_strategy prelocking_strategy; + bool has_prelocking_list= thd->lex->requires_prelocking(); + /* if this multi-update was converted from usual update, here is table counter else junk will be assigned here, but then replaced with real @@ -1662,10 +1665,10 @@ int mysql_multi_update_prepare(THD *thd) keep prepare of multi-UPDATE compatible with concurrent LOCK TABLES WRITE and global read lock. */ - if ((original_multiupdate && - open_tables(thd, &table_list, &table_count, - (thd->stmt_arena->is_stmt_prepare() ? - MYSQL_OPEN_FORCE_SHARED_MDL : 0))) || + if ((original_multiupdate && open_tables(thd, &table_list, &table_count, + thd->stmt_arena->is_stmt_prepare() + ? MYSQL_OPEN_FORCE_SHARED_MDL : 0, + &prelocking_strategy)) || mysql_handle_derived(lex, DT_INIT)) DBUG_RETURN(TRUE); /* @@ -1727,6 +1730,9 @@ int mysql_multi_update_prepare(THD *thd) tables_for_update)) DBUG_RETURN(true); + TABLE_LIST **new_tables= lex->query_tables_last; + DBUG_ASSERT(*new_tables== NULL); + /* Setup timestamp handling and locking mode */ @@ -1754,6 +1760,11 @@ int mysql_multi_update_prepare(THD *thd) If table will be updated we should not downgrade lock for it and leave it as is. */ + tl->updating= 1; + if (tl->belong_to_view) + tl->belong_to_view->updating= 1; + if (extend_table_list(thd, tl, &prelocking_strategy, has_prelocking_list)) + DBUG_RETURN(TRUE); } else { @@ -1776,7 +1787,6 @@ int mysql_multi_update_prepare(THD *thd) tl->lock_type= lock_type; else tl->set_lock_type(thd, lock_type); - tl->updating= 0; } } @@ -1785,6 +1795,20 @@ int mysql_multi_update_prepare(THD *thd) Note that unlike in the above loop we need to iterate here not only through all leaf tables but also through all view hierarchy. */ + + uint addon_table_count= 0; + if (*new_tables) + { + Sroutine_hash_entry **new_routines= thd->lex->sroutines_list.next; + DBUG_ASSERT(*new_routines == NULL); + if (open_tables(thd, thd->lex->create_info, new_tables, + &addon_table_count, new_routines, + thd->stmt_arena->is_stmt_prepare() + ? MYSQL_OPEN_FORCE_SHARED_MDL : 0, + &prelocking_strategy)) + DBUG_RETURN(TRUE); + } + for (tl= table_list; tl; tl= tl->next_local) { bool not_used= false; @@ -1813,7 +1837,7 @@ int mysql_multi_update_prepare(THD *thd) /* now lock and fill tables */ if (!thd->stmt_arena->is_stmt_prepare() && - lock_tables(thd, table_list, table_count, 0)) + lock_tables(thd, table_list, table_count + addon_table_count, 0)) { DBUG_RETURN(TRUE); } diff --git a/sql/sql_update.h b/sql/sql_update.h index 8457fe8f154..65e44d112a4 100644 --- a/sql/sql_update.h +++ b/sql/sql_update.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef SQL_UPDATE_INCLUDED #define SQL_UPDATE_INCLUDED diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 13b5caba539..b130fbc099b 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #define MYSQL_LEX 1 @@ -442,7 +442,7 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, */ if (lex->current_select->lock_type != TL_READ_DEFAULT) { - lex->current_select->set_lock_for_tables(TL_READ_DEFAULT); + lex->current_select->set_lock_for_tables(TL_READ_DEFAULT, false); view->mdl_request.set_type(MDL_EXCLUSIVE); } @@ -1565,6 +1565,7 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table, if (!tbl->sequence) tbl->lock_type= table->lock_type; tbl->mdl_request.set_type(table->mdl_request.type); + tbl->updating= table->updating; } /* If the view is mergeable, we might want to diff --git a/sql/sql_view.h b/sql/sql_view.h index 08d79b8e4a5..c1e5dc49da3 100644 --- a/sql/sql_view.h +++ b/sql/sql_view.h @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "sql_class.h" /* Required by sql_lex.h */ diff --git a/sql/sql_window.cc b/sql/sql_window.cc index 86c40b5f58f..487242933d4 100644 --- a/sql/sql_window.cc +++ b/sql/sql_window.cc @@ -2710,11 +2710,38 @@ bool save_window_function_values(List<Item_window_func>& window_functions, TABLE *tbl, uchar *rowid_buf) { List_iterator_fast<Item_window_func> iter(window_functions); + JOIN_TAB *join_tab= tbl->reginfo.join_tab; tbl->file->ha_rnd_pos(tbl->record[0], rowid_buf); store_record(tbl, record[1]); while (Item_window_func *item_win= iter++) item_win->save_in_field(item_win->result_field, true); + /* + In case we have window functions present, an extra step is required + to compute all the fields from the temporary table. + In case we have a compound expression such as: expr + expr, + where one of the terms has a window function inside it, only + after computing window function values we actually know the true + final result of the compounded expression. + + Go through all the func items and save their values once again in the + corresponding temp table fields. Do this for each row in the table. + + This needs to be done earlier because ORDER BY clause can also have + a window function, so we need to make sure all the fields of the temp.table + are updated before we do the filesort. So is best to update the other fields + that contain the window functions along with the computation of window + functions. + */ + + Item **func_ptr= join_tab->tmp_table_param->items_to_copy; + Item *func; + for (; (func = *func_ptr) ; func_ptr++) + { + if (func->with_window_func && func->type() != Item::WINDOW_FUNC_ITEM) + func->save_in_result_field(true); + } + int err= tbl->file->ha_update_row(tbl->record[1], tbl->record[0]); if (err && err != HA_ERR_RECORD_IS_THE_SAME) return true; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 73e3b9682de..10c45f4eb4d 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* sql_yacc.yy */ @@ -3509,12 +3509,8 @@ optionally_qualified_column_ident: row_field_name: ident { - if (unlikely(check_string_char_length(&$1, 0, NAME_CHAR_LEN, - system_charset_info, 1))) - my_yyabort_error((ER_TOO_LONG_IDENT, MYF(0), $1.str)); - if (unlikely(!($$= new (thd->mem_root) Spvar_definition()))) + if (!($$= Lex->row_field_name(thd, $1))) MYSQL_YYABORT; - Lex->init_last_field($$, &$1, thd->variables.collation_database); } ; @@ -3525,17 +3521,12 @@ row_field_definition: row_field_definition_list: row_field_definition { - if (unlikely(!($$= new (thd->mem_root) Row_definition_list())) || - unlikely($$->push_back($1, thd->mem_root))) + if (!($$= Row_definition_list::make(thd->mem_root, $1))) MYSQL_YYABORT; } | row_field_definition_list ',' row_field_definition { - uint unused; - if (unlikely($1->find_row_field_by_name(&$3->field_name, &unused))) - my_yyabort_error((ER_DUP_FIELDNAME, MYF(0), $3->field_name.str)); - $$= $1; - if (unlikely($$->push_back($3, thd->mem_root))) + if (($$= $1)->append_uniq(thd->mem_root, $3)) MYSQL_YYABORT; } ; @@ -5984,12 +5975,7 @@ opt_versioning_rotation: { partition_info *part_info= Lex->part_info; if (unlikely(part_info->vers_set_interval(thd, $2, $3, $4))) - { - my_error(ER_PART_WRONG_VALUE, MYF(0), - Lex->create_last_non_select_table->table_name.str, - "INTERVAL"); MYSQL_YYABORT; - } } | LIMIT ulonglong_num { @@ -6361,7 +6347,7 @@ versioning_option: { if (DBUG_EVALUATE_IF("sysvers_force", 0, 1)) { - my_error(ER_VERS_TEMPORARY, MYF(0)); + my_error(ER_VERS_NOT_SUPPORTED, MYF(0), "CREATE TEMPORARY TABLE"); MYSQL_YYABORT; } } @@ -9155,9 +9141,7 @@ select: opt_procedure_or_into { Lex->pop_select(); - if ($1->set_lock_to_the_last_select($3)) - MYSQL_YYABORT; - if (Lex->select_finalize($1)) + if (Lex->select_finalize($1, $3)) MYSQL_YYABORT; } | with_clause query_expression_body @@ -9172,9 +9156,7 @@ select: Lex->pop_select(); $2->set_with_clause($1); $1->attach_to($2->first_select()); - if ($2->set_lock_to_the_last_select($4)) - MYSQL_YYABORT; - if (Lex->select_finalize($2)) + if (Lex->select_finalize($2, $4)) MYSQL_YYABORT; } ; @@ -11759,6 +11741,7 @@ cast_type_numeric: | UNSIGNED { $$.set(&type_handler_ulonglong); } | UNSIGNED INT_SYM { $$.set(&type_handler_ulonglong); } | DECIMAL_SYM float_options { $$.set(&type_handler_newdecimal, $2); } + | FLOAT_SYM { $$.set(&type_handler_float); } | DOUBLE_SYM opt_precision { $$.set(&type_handler_double, $2); } ; @@ -13313,7 +13296,7 @@ insert: insert_lock_option opt_ignore insert2 { - Select->set_lock_for_tables($3); + Select->set_lock_for_tables($3, true); Lex->current_select= Lex->first_select_lex(); } insert_field_spec opt_insert_update @@ -13337,7 +13320,7 @@ replace: } replace_lock_option insert2 { - Select->set_lock_for_tables($3); + Select->set_lock_for_tables($3, true); Lex->current_select= Lex->first_select_lex(); } insert_field_spec @@ -13610,15 +13593,14 @@ update: opt_low_priority opt_ignore update_table_list SET update_list { - LEX *lex= Lex; - if (lex->first_select_lex()->table_list.elements > 1) - lex->sql_command= SQLCOM_UPDATE_MULTI; - else if (lex->first_select_lex()->get_table_list()->derived) + SELECT_LEX *slex= Lex->first_select_lex(); + if (slex->table_list.elements > 1) + Lex->sql_command= SQLCOM_UPDATE_MULTI; + else if (slex->get_table_list()->derived) { /* it is single table update and it is update of derived table */ my_error(ER_NON_UPDATABLE_TABLE, MYF(0), - lex->first_select_lex()->get_table_list()->alias.str, - "UPDATE"); + slex->get_table_list()->alias.str, "UPDATE"); MYSQL_YYABORT; } /* @@ -13626,7 +13608,7 @@ update: be too pessimistic. We will decrease lock level if possible in mysql_multi_update(). */ - Select->set_lock_for_tables($3); + slex->set_lock_for_tables($3, slex->table_list.elements == 1); } opt_where_clause opt_order_clause delete_limit_clause { @@ -16718,13 +16700,16 @@ table_lock: { thr_lock_type lock_type= (thr_lock_type) $3; bool lock_for_write= (lock_type >= TL_WRITE_ALLOW_WRITE); + ulong table_options= lock_for_write ? TL_OPTION_UPDATING : 0; + enum_mdl_type mdl_type= !lock_for_write + ? MDL_SHARED_READ + : lock_type == TL_WRITE_CONCURRENT_INSERT + ? MDL_SHARED_WRITE + : MDL_SHARED_NO_READ_WRITE; + if (unlikely(!Select-> - add_table_to_list(thd, $1, $2, 0, lock_type, - (lock_for_write ? - lock_type == TL_WRITE_CONCURRENT_INSERT ? - MDL_SHARED_WRITE : - MDL_SHARED_NO_READ_WRITE : - MDL_SHARED_READ)))) + add_table_to_list(thd, $1, $2, table_options, + lock_type, mdl_type))) MYSQL_YYABORT; } ; diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index 2f9f721774c..8086ede3fef 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -3412,12 +3412,8 @@ optionally_qualified_column_ident: row_field_name: ident_directly_assignable { - if (unlikely(check_string_char_length(&$1, 0, NAME_CHAR_LEN, - system_charset_info, 1))) - my_yyabort_error((ER_TOO_LONG_IDENT, MYF(0), $1.str)); - if (unlikely(!($$= new (thd->mem_root) Spvar_definition()))) + if (!($$= Lex->row_field_name(thd, $1))) MYSQL_YYABORT; - Lex->init_last_field($$, &$1, thd->variables.collation_database); } ; @@ -3428,17 +3424,12 @@ row_field_definition: row_field_definition_list: row_field_definition { - if (unlikely(!($$= new (thd->mem_root) Row_definition_list())) || - unlikely($$->push_back($1, thd->mem_root))) + if (!($$= Row_definition_list::make(thd->mem_root, $1))) MYSQL_YYABORT; } | row_field_definition_list ',' row_field_definition { - uint unused; - if (unlikely($1->find_row_field_by_name(&$3->field_name, &unused))) - my_yyabort_error((ER_DUP_FIELDNAME, MYF(0), $3->field_name.str)); - $$= $1; - if (unlikely($$->push_back($3, thd->mem_root))) + if (($$= $1)->append_uniq(thd->mem_root, $3)) MYSQL_YYABORT; } ; @@ -6009,12 +6000,7 @@ opt_versioning_rotation: { partition_info *part_info= Lex->part_info; if (unlikely(part_info->vers_set_interval(thd, $2, $3, $4))) - { - my_error(ER_PART_WRONG_VALUE, MYF(0), - Lex->create_last_non_select_table->table_name.str, - "INTERVAL"); MYSQL_YYABORT; - } } | LIMIT ulonglong_num { @@ -6386,7 +6372,7 @@ versioning_option: { if (DBUG_EVALUATE_IF("sysvers_force", 0, 1)) { - my_error(ER_VERS_TEMPORARY, MYF(0)); + my_error(ER_VERS_NOT_SUPPORTED, MYF(0), "CREATE TEMPORARY TABLE"); MYSQL_YYABORT; } } @@ -9272,7 +9258,7 @@ select: opt_procedure_or_into { Lex->pop_select(); - if (Lex->select_finalize($1)) + if (Lex->select_finalize($1, $3)) MYSQL_YYABORT; } | with_clause query_expression_body @@ -9287,7 +9273,7 @@ select: Lex->pop_select(); $2->set_with_clause($1); $1->attach_to($2->first_select()); - if (Lex->select_finalize($2)) + if (Lex->select_finalize($2, $4)) MYSQL_YYABORT; } ; @@ -11881,6 +11867,7 @@ cast_type_numeric: | UNSIGNED { $$.set(&type_handler_ulonglong); } | UNSIGNED INT_SYM { $$.set(&type_handler_ulonglong); } | DECIMAL_SYM float_options { $$.set(&type_handler_newdecimal, $2); } + | FLOAT_SYM { $$.set(&type_handler_float); } | DOUBLE_SYM opt_precision { $$.set(&type_handler_double, $2); } ; @@ -13451,7 +13438,7 @@ insert: insert_lock_option opt_ignore insert2 { - Select->set_lock_for_tables($3); + Select->set_lock_for_tables($3, true); Lex->current_select= Lex->first_select_lex(); } insert_field_spec opt_insert_update @@ -13475,7 +13462,7 @@ replace: } replace_lock_option insert2 { - Select->set_lock_for_tables($3); + Select->set_lock_for_tables($3, true); Lex->current_select= Lex->first_select_lex(); } insert_field_spec @@ -13748,15 +13735,14 @@ update: opt_low_priority opt_ignore update_table_list SET update_list { - LEX *lex= Lex; - if (lex->first_select_lex()->table_list.elements > 1) - lex->sql_command= SQLCOM_UPDATE_MULTI; - else if (lex->first_select_lex()->get_table_list()->derived) + SELECT_LEX *slex= Lex->first_select_lex(); + if (slex->table_list.elements > 1) + Lex->sql_command= SQLCOM_UPDATE_MULTI; + else if (slex->get_table_list()->derived) { /* it is single table update and it is update of derived table */ my_error(ER_NON_UPDATABLE_TABLE, MYF(0), - lex->first_select_lex()->get_table_list()->alias.str, - "UPDATE"); + slex->get_table_list()->alias.str, "UPDATE"); MYSQL_YYABORT; } /* @@ -13764,7 +13750,7 @@ update: be too pessimistic. We will decrease lock level if possible in mysql_multi_update(). */ - Select->set_lock_for_tables($3); + slex->set_lock_for_tables($3, slex->table_list.elements == 1); } opt_where_clause opt_order_clause delete_limit_clause { @@ -16948,13 +16934,16 @@ table_lock: { thr_lock_type lock_type= (thr_lock_type) $3; bool lock_for_write= (lock_type >= TL_WRITE_ALLOW_WRITE); + ulong table_options= lock_for_write ? TL_OPTION_UPDATING : 0; + enum_mdl_type mdl_type= !lock_for_write + ? MDL_SHARED_READ + : lock_type == TL_WRITE_CONCURRENT_INSERT + ? MDL_SHARED_WRITE + : MDL_SHARED_NO_READ_WRITE; + if (unlikely(!Select-> - add_table_to_list(thd, $1, $2, 0, lock_type, - (lock_for_write ? - lock_type == TL_WRITE_CONCURRENT_INSERT ? - MDL_SHARED_WRITE : - MDL_SHARED_NO_READ_WRITE : - MDL_SHARED_READ)))) + add_table_to_list(thd, $1, $2, table_options, + lock_type, mdl_type))) MYSQL_YYABORT; } ; diff --git a/sql/strfunc.cc b/sql/strfunc.cc index f457f6b29be..99ff9c50588 100644 --- a/sql/strfunc.cc +++ b/sql/strfunc.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* Some useful string utility functions used by the MySQL server */ diff --git a/sql/strfunc.h b/sql/strfunc.h index 1bf3cbf47b3..d66d4c63444 100644 --- a/sql/strfunc.h +++ b/sql/strfunc.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef STRFUNC_INCLUDED #define STRFUNC_INCLUDED diff --git a/sql/structs.h b/sql/structs.h index 48de99ddced..0c00aeec33a 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 2e92838ad3a..1160e936a2b 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file @@ -1570,7 +1570,7 @@ static Sys_var_uint Sys_default_password_lifetime( "This defines the global password expiration policy. 0 means " "automatic password expiration is disabled. If the value is a " "positive integer N, the passwords must be changed every N days. This " - "behavior can be overriden using the password expiration options in " + "behavior can be overridden using the password expiration options in " "ALTER USER.", GLOBAL_VAR(default_password_lifetime), CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1)); diff --git a/sql/sys_vars.ic b/sql/sys_vars.ic index 440890bccfd..aefae6d5703 100644 --- a/sql/sys_vars.ic +++ b/sql/sys_vars.ic @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/sys_vars_shared.h b/sql/sys_vars_shared.h index 69382974175..bc48d1f7fff 100644 --- a/sql/sys_vars_shared.h +++ b/sql/sys_vars_shared.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file diff --git a/sql/table.cc b/sql/table.cc index 7641c9a023f..52cb0a57edd 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* Some general useful functions */ @@ -2315,7 +2315,6 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, switch (handler->real_field_type()) { case MYSQL_TYPE_TIMESTAMP2: - case MYSQL_TYPE_DATETIME2: break; case MYSQL_TYPE_LONGLONG: if (vers_can_native) @@ -6516,7 +6515,8 @@ const char *Field_iterator_table_ref::get_table_name() return natural_join_it.column_ref()->safe_table_name(); DBUG_ASSERT(!strcmp(table_ref->table_name.str, - table_ref->table->s->table_name.str)); + table_ref->table->s->table_name.str) || + table_ref->schema_table); return table_ref->table_name.str; } diff --git a/sql/table.h b/sql/table.h index 865824bf36f..42c017d63af 100644 --- a/sql/table.h +++ b/sql/table.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "sql_plist.h" #include "sql_list.h" /* Sql_alloc */ @@ -1025,6 +1025,8 @@ struct TABLE_SHARE void set_overlapped_keys(); }; +/* not NULL, but cannot be dereferenced */ +#define UNUSABLE_TABLE_SHARE ((TABLE_SHARE*)1) /** Class is used as a BLOB field value storage for @@ -2021,6 +2023,7 @@ struct TABLE_LIST table_name= *table_name_arg; alias= (alias_arg ? *alias_arg : *table_name_arg); lock_type= lock_type_arg; + updating= lock_type >= TL_WRITE_ALLOW_WRITE; mdl_request.init(MDL_key::TABLE, db.str, table_name.str, mdl_type, MDL_TRANSACTION); } diff --git a/sql/table_cache.cc b/sql/table_cache.cc index 7a555d53558..0743525b944 100644 --- a/sql/table_cache.cc +++ b/sql/table_cache.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file @@ -945,7 +945,7 @@ end: table existed? Let's return an invalid pointer here to catch dereferencing attempts. */ - share= (TABLE_SHARE*) 1; + share= UNUSABLE_TABLE_SHARE; } DBUG_RETURN(share); diff --git a/sql/table_cache.h b/sql/table_cache.h index 148edc84223..611980c615f 100644 --- a/sql/table_cache.h +++ b/sql/table_cache.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ struct Share_free_tables diff --git a/sql/thr_malloc.cc b/sql/thr_malloc.cc index fd33ee4c32b..d43e7c4c9b5 100644 --- a/sql/thr_malloc.cc +++ b/sql/thr_malloc.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Mallocs for used in threads */ diff --git a/sql/thr_malloc.h b/sql/thr_malloc.h index b56b7175ed1..a6ab5477d41 100644 --- a/sql/thr_malloc.h +++ b/sql/thr_malloc.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef THR_MALLOC_INCLUDED #define THR_MALLOC_INCLUDED diff --git a/sql/threadpool.h b/sql/threadpool.h index 57750b73e42..6299510d002 100644 --- a/sql/threadpool.h +++ b/sql/threadpool.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #define MAX_THREAD_GROUPS 100000 diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc index 06b74cfe1a6..3628ceb9112 100644 --- a/sql/threadpool_common.cc +++ b/sql/threadpool_common.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include <violite.h> diff --git a/sql/threadpool_generic.cc b/sql/threadpool_generic.cc index 74c359a4153..1998b8d281b 100644 --- a/sql/threadpool_generic.cc +++ b/sql/threadpool_generic.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include <violite.h> diff --git a/sql/threadpool_win.cc b/sql/threadpool_win.cc index 5c12d53ab0e..2751d8baeb0 100644 --- a/sql/threadpool_win.cc +++ b/sql/threadpool_win.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef _WIN32_WINNT #undef _WIN32_WINNT diff --git a/sql/transaction.cc b/sql/transaction.cc index 2887ae763df..aecee04c364 100644 --- a/sql/transaction.cc +++ b/sql/transaction.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_IMPLEMENTATION diff --git a/sql/transaction.h b/sql/transaction.h index 5eaa2b00027..fe0129fa8bc 100644 --- a/sql/transaction.h +++ b/sql/transaction.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef TRANSACTION_H #define TRANSACTION_H diff --git a/sql/tzfile.h b/sql/tzfile.h index 4feba612b36..aa0308645d1 100644 --- a/sql/tzfile.h +++ b/sql/tzfile.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* This file is based on public domain code from ftp://elsie.ncih.nist.gov/ diff --git a/sql/tztime.cc b/sql/tztime.cc index fb158480b21..09d775e7e51 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Most of the following code and structures were derived from diff --git a/sql/tztime.h b/sql/tztime.h index 7ffc36011e1..d24a379e634 100644 --- a/sql/tztime.h +++ b/sql/tztime.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #ifdef USE_PRAGMA_INTERFACE diff --git a/sql/udf_example.c b/sql/udf_example.c index bdc995b51fc..e4757de880d 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* ** example file of UDF (user definable functions) that are dynamicly loaded diff --git a/sql/uniques.cc b/sql/uniques.cc index 6bc870133ff..fafb44b56a0 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* Function to handle quick removal of duplicates diff --git a/sql/unireg.cc b/sql/unireg.cc index 02d876e1455..d019b5f8a75 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ /* diff --git a/sql/unireg.h b/sql/unireg.h index d038de7a88f..8e9fa27ea6a 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include <mysql_version.h> /* FRM_VER */ diff --git a/sql/win_tzname_data.h b/sql/win_tzname_data.h new file mode 100644 index 00000000000..28a14ab7c11 --- /dev/null +++ b/sql/win_tzname_data.h @@ -0,0 +1,136 @@ +/* This file was generated using gen_win_tzname_data.ps1 */ +{L"Dateline Standard Time","Etc/GMT+12"}, +{L"UTC-11","Etc/GMT+11"}, +{L"Aleutian Standard Time","America/Adak"}, +{L"Hawaiian Standard Time","Pacific/Honolulu"}, +{L"Marquesas Standard Time","Pacific/Marquesas"}, +{L"Alaskan Standard Time","America/Anchorage"}, +{L"UTC-09","Etc/GMT+9"}, +{L"Pacific Standard Time (Mexico)","America/Tijuana"}, +{L"UTC-08","Etc/GMT+8"}, +{L"Pacific Standard Time","America/Los_Angeles"}, +{L"US Mountain Standard Time","America/Phoenix"}, +{L"Mountain Standard Time (Mexico)","America/Chihuahua"}, +{L"Mountain Standard Time","America/Denver"}, +{L"Central America Standard Time","America/Guatemala"}, +{L"Central Standard Time","America/Chicago"}, +{L"Easter Island Standard Time","Pacific/Easter"}, +{L"Central Standard Time (Mexico)","America/Mexico_City"}, +{L"Canada Central Standard Time","America/Regina"}, +{L"SA Pacific Standard Time","America/Bogota"}, +{L"Eastern Standard Time (Mexico)","America/Cancun"}, +{L"Eastern Standard Time","America/New_York"}, +{L"Haiti Standard Time","America/Port-au-Prince"}, +{L"Cuba Standard Time","America/Havana"}, +{L"US Eastern Standard Time","America/Indianapolis"}, +{L"Paraguay Standard Time","America/Asuncion"}, +{L"Atlantic Standard Time","America/Halifax"}, +{L"Venezuela Standard Time","America/Caracas"}, +{L"Central Brazilian Standard Time","America/Cuiaba"}, +{L"SA Western Standard Time","America/La_Paz"}, +{L"Pacific SA Standard Time","America/Santiago"}, +{L"Turks And Caicos Standard Time","America/Grand_Turk"}, +{L"Newfoundland Standard Time","America/St_Johns"}, +{L"Tocantins Standard Time","America/Araguaina"}, +{L"E. South America Standard Time","America/Sao_Paulo"}, +{L"SA Eastern Standard Time","America/Cayenne"}, +{L"Argentina Standard Time","America/Buenos_Aires"}, +{L"Greenland Standard Time","America/Godthab"}, +{L"Montevideo Standard Time","America/Montevideo"}, +{L"Magallanes Standard Time","America/Punta_Arenas"}, +{L"Saint Pierre Standard Time","America/Miquelon"}, +{L"Bahia Standard Time","America/Bahia"}, +{L"UTC-02","Etc/GMT+2"}, +{L"Azores Standard Time","Atlantic/Azores"}, +{L"Cape Verde Standard Time","Atlantic/Cape_Verde"}, +{L"UTC","Etc/GMT"}, +{L"GMT Standard Time","Europe/London"}, +{L"Greenwich Standard Time","Atlantic/Reykjavik"}, +{L"W. Europe Standard Time","Europe/Berlin"}, +{L"Central Europe Standard Time","Europe/Budapest"}, +{L"Romance Standard Time","Europe/Paris"}, +{L"Morocco Standard Time","Africa/Casablanca"}, +{L"Sao Tome Standard Time","Africa/Sao_Tome"}, +{L"Central European Standard Time","Europe/Warsaw"}, +{L"W. Central Africa Standard Time","Africa/Lagos"}, +{L"Jordan Standard Time","Asia/Amman"}, +{L"GTB Standard Time","Europe/Bucharest"}, +{L"Middle East Standard Time","Asia/Beirut"}, +{L"Egypt Standard Time","Africa/Cairo"}, +{L"E. Europe Standard Time","Europe/Chisinau"}, +{L"Syria Standard Time","Asia/Damascus"}, +{L"West Bank Standard Time","Asia/Hebron"}, +{L"South Africa Standard Time","Africa/Johannesburg"}, +{L"FLE Standard Time","Europe/Kiev"}, +{L"Israel Standard Time","Asia/Jerusalem"}, +{L"Kaliningrad Standard Time","Europe/Kaliningrad"}, +{L"Sudan Standard Time","Africa/Khartoum"}, +{L"Libya Standard Time","Africa/Tripoli"}, +{L"Namibia Standard Time","Africa/Windhoek"}, +{L"Arabic Standard Time","Asia/Baghdad"}, +{L"Turkey Standard Time","Europe/Istanbul"}, +{L"Arab Standard Time","Asia/Riyadh"}, +{L"Belarus Standard Time","Europe/Minsk"}, +{L"Russian Standard Time","Europe/Moscow"}, +{L"E. Africa Standard Time","Africa/Nairobi"}, +{L"Iran Standard Time","Asia/Tehran"}, +{L"Arabian Standard Time","Asia/Dubai"}, +{L"Astrakhan Standard Time","Europe/Astrakhan"}, +{L"Azerbaijan Standard Time","Asia/Baku"}, +{L"Russia Time Zone 3","Europe/Samara"}, +{L"Mauritius Standard Time","Indian/Mauritius"}, +{L"Saratov Standard Time","Europe/Saratov"}, +{L"Georgian Standard Time","Asia/Tbilisi"}, +{L"Caucasus Standard Time","Asia/Yerevan"}, +{L"Afghanistan Standard Time","Asia/Kabul"}, +{L"West Asia Standard Time","Asia/Tashkent"}, +{L"Ekaterinburg Standard Time","Asia/Yekaterinburg"}, +{L"Pakistan Standard Time","Asia/Karachi"}, +{L"India Standard Time","Asia/Calcutta"}, +{L"Sri Lanka Standard Time","Asia/Colombo"}, +{L"Nepal Standard Time","Asia/Katmandu"}, +{L"Central Asia Standard Time","Asia/Almaty"}, +{L"Bangladesh Standard Time","Asia/Dhaka"}, +{L"Omsk Standard Time","Asia/Omsk"}, +{L"Myanmar Standard Time","Asia/Rangoon"}, +{L"SE Asia Standard Time","Asia/Bangkok"}, +{L"Altai Standard Time","Asia/Barnaul"}, +{L"W. Mongolia Standard Time","Asia/Hovd"}, +{L"North Asia Standard Time","Asia/Krasnoyarsk"}, +{L"N. Central Asia Standard Time","Asia/Novosibirsk"}, +{L"Tomsk Standard Time","Asia/Tomsk"}, +{L"China Standard Time","Asia/Shanghai"}, +{L"North Asia East Standard Time","Asia/Irkutsk"}, +{L"Singapore Standard Time","Asia/Singapore"}, +{L"W. Australia Standard Time","Australia/Perth"}, +{L"Taipei Standard Time","Asia/Taipei"}, +{L"Ulaanbaatar Standard Time","Asia/Ulaanbaatar"}, +{L"Aus Central W. Standard Time","Australia/Eucla"}, +{L"Transbaikal Standard Time","Asia/Chita"}, +{L"Tokyo Standard Time","Asia/Tokyo"}, +{L"North Korea Standard Time","Asia/Pyongyang"}, +{L"Korea Standard Time","Asia/Seoul"}, +{L"Yakutsk Standard Time","Asia/Yakutsk"}, +{L"Cen. Australia Standard Time","Australia/Adelaide"}, +{L"AUS Central Standard Time","Australia/Darwin"}, +{L"E. Australia Standard Time","Australia/Brisbane"}, +{L"AUS Eastern Standard Time","Australia/Sydney"}, +{L"West Pacific Standard Time","Pacific/Port_Moresby"}, +{L"Tasmania Standard Time","Australia/Hobart"}, +{L"Vladivostok Standard Time","Asia/Vladivostok"}, +{L"Lord Howe Standard Time","Australia/Lord_Howe"}, +{L"Bougainville Standard Time","Pacific/Bougainville"}, +{L"Russia Time Zone 10","Asia/Srednekolymsk"}, +{L"Magadan Standard Time","Asia/Magadan"}, +{L"Norfolk Standard Time","Pacific/Norfolk"}, +{L"Sakhalin Standard Time","Asia/Sakhalin"}, +{L"Central Pacific Standard Time","Pacific/Guadalcanal"}, +{L"Russia Time Zone 11","Asia/Kamchatka"}, +{L"New Zealand Standard Time","Pacific/Auckland"}, +{L"UTC+12","Etc/GMT-12"}, +{L"Fiji Standard Time","Pacific/Fiji"}, +{L"Chatham Islands Standard Time","Pacific/Chatham"}, +{L"UTC+13","Etc/GMT-13"}, +{L"Tonga Standard Time","Pacific/Tongatapu"}, +{L"Samoa Standard Time","Pacific/Apia"}, +{L"Line Islands Standard Time","Pacific/Kiritimati"}, diff --git a/sql/winservice.c b/sql/winservice.c index 5e021c0e297..3c9d07822be 100644 --- a/sql/winservice.c +++ b/sql/winservice.c @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* Get Properties of an existing mysqld Windows service diff --git a/sql/winservice.h b/sql/winservice.h index fe3fe526548..f9ab3eda332 100644 --- a/sql/winservice.h +++ b/sql/winservice.h @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /* Extract properties of a windows service binary path diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc index 39cdef77be2..fd51dbf9439 100644 --- a/sql/wsrep_applier.cc +++ b/sql/wsrep_applier.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. */ #include "mariadb.h" #include "mysql/service_wsrep.h" diff --git a/sql/wsrep_applier.h b/sql/wsrep_applier.h index a8da2acbb9a..70361987cc7 100644 --- a/sql/wsrep_applier.h +++ b/sql/wsrep_applier.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef WSREP_APPLIER_H #define WSREP_APPLIER_H diff --git a/sql/wsrep_binlog.cc b/sql/wsrep_binlog.cc index 80790ca604c..ecab4664d7b 100644 --- a/sql/wsrep_binlog.cc +++ b/sql/wsrep_binlog.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. */ #include "mariadb.h" #include "mysql/service_wsrep.h" diff --git a/sql/wsrep_binlog.h b/sql/wsrep_binlog.h index 1e0e1e3cb2d..4e29b30baca 100644 --- a/sql/wsrep_binlog.h +++ b/sql/wsrep_binlog.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. */ #ifndef WSREP_BINLOG_H #define WSREP_BINLOG_H diff --git a/sql/wsrep_check_opts.cc b/sql/wsrep_check_opts.cc index 7b8067ef238..935bacffffc 100644 --- a/sql/wsrep_check_opts.cc +++ b/sql/wsrep_check_opts.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "mysqld.h" diff --git a/sql/wsrep_dummy.cc b/sql/wsrep_dummy.cc index 01f2ad88ed5..75ee9b04cdf 100644 --- a/sql/wsrep_dummy.cc +++ b/sql/wsrep_dummy.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. */ #include "mariadb.h" #include <sql_class.h> diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 63b8974734e..d96eb6a1a36 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "sql_plugin.h" /* wsrep_plugins_pre_init() */ #include "my_global.h" diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index f71d998ed4e..37301afa7be 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef WSREP_MYSQLD_H #define WSREP_MYSQLD_H diff --git a/sql/wsrep_mysqld_c.h b/sql/wsrep_mysqld_c.h index 235a871c113..603f2c29ad1 100644 --- a/sql/wsrep_mysqld_c.h +++ b/sql/wsrep_mysqld_c.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #ifndef WSREP_MYSQLD_C_H #define WSREP_MYSQLD_C_H diff --git a/sql/wsrep_notify.cc b/sql/wsrep_notify.cc index ef9dd872075..1d6d13ea6d2 100644 --- a/sql/wsrep_notify.cc +++ b/sql/wsrep_notify.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include <mysqld.h> diff --git a/sql/wsrep_priv.h b/sql/wsrep_priv.h index 68773d27948..e480331ba65 100644 --- a/sql/wsrep_priv.h +++ b/sql/wsrep_priv.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ //! @file declares symbols private to wsrep integration layer diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index d79b7771571..3181415dad1 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "mariadb.h" #include "wsrep_sst.h" diff --git a/sql/wsrep_sst.h b/sql/wsrep_sst.h index 46059a7f436..eb218647bc0 100644 --- a/sql/wsrep_sst.h +++ b/sql/wsrep_sst.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. */ #ifndef WSREP_SST_H #define WSREP_SST_H diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index b849bc256cb..6173506385d 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. */ #include "mariadb.h" #include "wsrep_thd.h" diff --git a/sql/wsrep_thd.h b/sql/wsrep_thd.h index 3114e02e1b8..2eceb3223a8 100644 --- a/sql/wsrep_thd.h +++ b/sql/wsrep_thd.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. */ #ifndef WSREP_THD_H #define WSREP_THD_H diff --git a/sql/wsrep_utils.cc b/sql/wsrep_utils.cc index 8db0f7be99a..52949a95e5d 100644 --- a/sql/wsrep_utils.cc +++ b/sql/wsrep_utils.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ //! @file some utility functions and classes not directly related to replication diff --git a/sql/wsrep_utils.h b/sql/wsrep_utils.h index 488b455938b..4b010816a40 100644 --- a/sql/wsrep_utils.h +++ b/sql/wsrep_utils.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. */ #ifndef WSREP_UTILS_H #define WSREP_UTILS_H diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index 288d4cdf134..de558af6abb 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "wsrep_var.h" diff --git a/sql/wsrep_var.h b/sql/wsrep_var.h index 0acb61432f0..481df02f2d5 100644 --- a/sql/wsrep_var.h +++ b/sql/wsrep_var.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. */ #ifndef WSREP_VAR_H #define WSREP_VAR_H diff --git a/sql/wsrep_xid.cc b/sql/wsrep_xid.cc index a1c454d9d65..d8f6e013820 100644 --- a/sql/wsrep_xid.cc +++ b/sql/wsrep_xid.cc @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ //! @file some utility functions and classes not directly related to replication diff --git a/sql/wsrep_xid.h b/sql/wsrep_xid.h index e41f6fba420..a1b9afc1817 100644 --- a/sql/wsrep_xid.h +++ b/sql/wsrep_xid.h @@ -11,7 +11,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. */ #ifndef WSREP_XID_H #define WSREP_XID_H |