diff options
author | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2010-04-30 00:33:06 +0400 |
---|---|---|
committer | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2010-04-30 00:33:06 +0400 |
commit | 940ad61b712cb2f10bf5ff62330b0c9c4d8473ba (patch) | |
tree | a2457e79f43173dfb97236266c5bb7a47fdbf65f /sql | |
parent | 72ae25b11ea922c018953053e3c3cdd5fd80f971 (diff) | |
parent | e287445d416044a7004ba2da289350f5c6dfb546 (diff) | |
download | mariadb-git-940ad61b712cb2f10bf5ff62330b0c9c4d8473ba.tar.gz |
Manual merge of mysql-5.1-bugteam to mysql-trunk-merge.
Conflicts:
Text conflict in configure.in
Text conflict in dbug/dbug.c
Text conflict in mysql-test/r/ps.result
Text conflict in mysql-test/t/ps.test
Text conflict in sql/CMakeLists.txt
Text conflict in sql/ha_ndbcluster.cc
Text conflict in sql/mysqld.cc
Text conflict in sql/sql_plugin.cc
Text conflict in sql/sql_table.cc
Diffstat (limited to 'sql')
-rwxr-xr-x | sql/CMakeLists.txt | 4 | ||||
-rw-r--r-- | sql/field.cc | 12 | ||||
-rw-r--r-- | sql/handler.cc | 12 | ||||
-rw-r--r-- | sql/handler.h | 2 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 14 | ||||
-rw-r--r-- | sql/mysqld.cc | 21 | ||||
-rw-r--r-- | sql/sql_acl.cc | 10 | ||||
-rw-r--r-- | sql/sql_class.cc | 31 | ||||
-rw-r--r-- | sql/sql_class.h | 6 | ||||
-rw-r--r-- | sql/sql_load.cc | 4 | ||||
-rw-r--r-- | sql/sql_parse.cc | 10 | ||||
-rw-r--r-- | sql/sql_plugin.cc | 12 | ||||
-rw-r--r-- | sql/sql_table.cc | 9 | ||||
-rw-r--r-- | sql/sql_update.cc | 10 |
14 files changed, 131 insertions, 26 deletions
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 396c8b1fd27..f86ad9b4e47 100755 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -47,7 +47,7 @@ SET (SQL_SOURCE hostname.cc init.cc item.cc item_buff.cc item_cmpfunc.cc item_create.cc item_func.cc item_geofunc.cc item_row.cc item_strfunc.cc item_subselect.cc item_sum.cc item_timefunc.cc - key.cc log.cc lock.cc message.rc + key.cc log.cc lock.cc log_event.cc rpl_record.cc rpl_reporting.cc log_event_old.cc rpl_record_old.cc message.h mf_iocache.cc my_decimal.cc ../sql-common/my_time.c @@ -92,7 +92,7 @@ TARGET_LINK_LIBRARIES(sql ${MYSQLD_STATIC_PLUGIN_LIBS} IF(WIN32) - SET(MYSQLD_SOURCE main.cc nt_servc.cc nt_servc.h) + SET(MYSQLD_SOURCE main.cc nt_servc.cc nt_servc.h message.rc) ELSE() SET(MYSQLD_SOURCE main.cc ${DTRACE_PROBES_ALL}) ENDIF() diff --git a/sql/field.cc b/sql/field.cc index bd091f7eb57..fcabaeaa74d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -8464,14 +8464,20 @@ bool Field_num::eq_def(Field *field) } +/** + Check whether two numeric fields can be considered 'equal' for table + alteration purposes. Fields are equal if they are of the same type + and retain the same pack length. +*/ + uint Field_num::is_equal(Create_field *new_field) { return ((new_field->sql_type == real_type()) && - ((new_field->flags & UNSIGNED_FLAG) == (uint) (flags & - UNSIGNED_FLAG)) && + ((new_field->flags & UNSIGNED_FLAG) == + (uint) (flags & UNSIGNED_FLAG)) && ((new_field->flags & AUTO_INCREMENT_FLAG) == (uint) (flags & AUTO_INCREMENT_FLAG)) && - (new_field->length <= max_display_length())); + (new_field->pack_length == pack_length())); } diff --git a/sql/handler.cc b/sql/handler.cc index ee02441e7ff..d641133c57a 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -174,7 +174,7 @@ redo: } -plugin_ref ha_lock_engine(THD *thd, handlerton *hton) +plugin_ref ha_lock_engine(THD *thd, const handlerton *hton) { if (hton) { @@ -642,9 +642,13 @@ static my_bool closecon_handlerton(THD *thd, plugin_ref plugin, there's no need to rollback here as all transactions must be rolled back already */ - if (hton->state == SHOW_OPTION_YES && hton->close_connection && - thd_get_ha_data(thd, hton)) - hton->close_connection(hton, thd); + if (hton->state == SHOW_OPTION_YES && thd_get_ha_data(thd, hton)) + { + if (hton->close_connection) + hton->close_connection(hton, thd); + /* make sure ha_data is reset and ha_data_lock is released */ + thd_set_ha_data(thd, hton, NULL); + } return FALSE; } diff --git a/sql/handler.h b/sql/handler.h index 9f21cb0f25d..4464f4f3920 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2066,7 +2066,7 @@ extern ulong total_ha, total_ha_2pc; /* lookups */ handlerton *ha_default_handlerton(THD *thd); plugin_ref ha_resolve_by_name(THD *thd, const LEX_STRING *name); -plugin_ref ha_lock_engine(THD *thd, handlerton *hton); +plugin_ref ha_lock_engine(THD *thd, const handlerton *hton); handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type); handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc, handlerton *db_type); diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index afd25688e79..a0b3f2c29a1 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -60,9 +60,9 @@ public: /* Allow owner function to use string buffers. */ String value1, value2; - Arg_comparator(): thd(0), a_cache(0), b_cache(0), set_null(TRUE), + Arg_comparator(): comparators(0), thd(0), a_cache(0), b_cache(0), set_null(TRUE), get_value_a_func(0), get_value_b_func(0) {}; - Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), thd(0), + Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), comparators(0), thd(0), a_cache(0), b_cache(0), set_null(TRUE), get_value_a_func(0), get_value_b_func(0) {}; @@ -118,6 +118,11 @@ public: return (owner->type() == Item::FUNC_ITEM && ((Item_func*)owner)->functype() == Item_func::EQUAL_FUNC); } + void cleanup() + { + delete [] comparators; + comparators= 0; + } friend class Item_func; }; @@ -371,6 +376,11 @@ public: CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; } uint decimal_precision() const { return 1; } void top_level_item() { abort_on_null= TRUE; } + void cleanup() + { + Item_int_func::cleanup(); + cmp.cleanup(); + } friend class Arg_comparator; }; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e209c698f9a..2c90aa8fbf5 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -7771,10 +7771,25 @@ static int fix_paths(void) */ if (opt_secure_file_priv) { - convert_dirname(buff, opt_secure_file_priv, NullS); - x_free(opt_secure_file_priv); - opt_secure_file_priv= my_strdup(buff, MYF(MY_FAE)); + if (*opt_secure_file_priv == 0) + { + opt_secure_file_priv= 0; + } + else + { + convert_dirname(buff, opt_secure_file_priv, NullS); + char *secure_file_real_path= (char *)my_malloc(FN_REFLEN, MYF(MY_FAE)); + if (secure_file_real_path == 0 || + my_realpath(secure_file_real_path, buff, 0)) + { + sql_print_warning("Failed to normalize the argument for --secure-file-priv."); + return 1; + } + my_free(opt_secure_file_priv, MYF(0)); + opt_secure_file_priv= secure_file_real_path; + } } + return 0; } diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index f8be3ff6d4a..5a7fb7f154a 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -6255,21 +6255,21 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list) mysql_mutex_unlock(&acl_cache->lock); - int binlog_error= + if (result) + my_message(ER_REVOKE_GRANTS, ER(ER_REVOKE_GRANTS), MYF(0)); + + result= result | write_bin_log(thd, FALSE, thd->query(), thd->query_length()); mysql_rwlock_unlock(&LOCK_grant); close_thread_tables(thd); - /* error for writing binary log has already been reported */ - if (result && !binlog_error) - my_message(ER_REVOKE_GRANTS, ER(ER_REVOKE_GRANTS), MYF(0)); /* Restore the state of binlog format */ DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row()); if (save_binlog_row_based) thd->set_current_stmt_binlog_format_row(); - DBUG_RETURN(result || binlog_error); + DBUG_RETURN(result); } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 0010ce088d5..0f0ce605b54 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -305,6 +305,37 @@ void **thd_ha_data(const THD *thd, const struct handlerton *hton) return (void **) &thd->ha_data[hton->slot].ha_ptr; } + +/** + Provide a handler data getter to simplify coding +*/ +extern "C" +void *thd_get_ha_data(const THD *thd, const struct handlerton *hton) +{ + return *thd_ha_data(thd, hton); +} + + +/** + Provide a handler data setter to simplify coding + @see thd_set_ha_data() definition in plugin.h +*/ +extern "C" +void thd_set_ha_data(THD *thd, const struct handlerton *hton, + const void *ha_data) +{ + plugin_ref *lock= &thd->ha_data[hton->slot].lock; + if (ha_data && !*lock) + *lock= ha_lock_engine(NULL, (handlerton*) hton); + else if (!ha_data && *lock) + { + plugin_unlock(NULL, *lock); + *lock= NULL; + } + *thd_ha_data(thd, hton)= (void*) ha_data; +} + + extern "C" long long thd_test_options(const THD *thd, long long test_options) { diff --git a/sql/sql_class.h b/sql/sql_class.h index 7a77f9172b7..3a1f83fc9e5 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1470,7 +1470,11 @@ struct Ha_data @sa trans_register_ha() */ Ha_trx_info ha_info[2]; - + /** + NULL: engine is not bound to this thread + non-NULL: engine is bound to this thread, engine shutdown forbidden + */ + plugin_ref lock; Ha_data() :ha_ptr(NULL) {} }; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 89bb8a9634c..d264c61c36c 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -396,9 +396,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, } else if (opt_secure_file_priv) { - char secure_file_real_path[FN_REFLEN]; - (void) my_realpath(secure_file_real_path, opt_secure_file_priv, 0); - if (strncmp(secure_file_real_path, name, strlen(secure_file_real_path))) + if (strncmp(opt_secure_file_priv, name, strlen(opt_secure_file_priv))) { /* Read only allowed from within dir specified by secure_file_priv */ my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv"); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 058c6844d15..f83ab95042a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1160,8 +1160,16 @@ bool dispatch_command(enum enum_server_command command, THD *thd, We have name + wildcard in packet, separated by endzero */ arg_end= strend(packet); + uint arg_length= arg_end - packet; + + /* Check given table name length. */ + if (arg_length >= packet_length || arg_length > NAME_LEN) + { + my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0)); + break; + } thd->convert_string(&conv_name, system_charset_info, - packet, (uint) (arg_end - packet), thd->charset()); + packet, arg_length, thd->charset()); table_list.alias= table_list.table_name= conv_name.str; packet= arg_end + 1; diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 31e0cced207..0282053ce7e 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1755,6 +1755,12 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl struct st_plugin_int *tmp; DBUG_ENTER("mysql_install_plugin"); + if (opt_noacl) + { + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables"); + DBUG_RETURN(TRUE); + } + tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE); if (check_table_access(thd, INSERT_ACL, &tables, FALSE, 1, FALSE)) DBUG_RETURN(TRUE); @@ -1829,6 +1835,12 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name) struct st_plugin_int *plugin; DBUG_ENTER("mysql_uninstall_plugin"); + if (opt_noacl) + { + my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--skip-grant-tables"); + DBUG_RETURN(TRUE); + } + tables.init_one_table("mysql", 5, "plugin", 6, "plugin", TL_WRITE); if (check_table_access(thd, DELETE_ACL, &tables, FALSE, 1, FALSE)) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c752905d14c..03976e2784a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -6935,7 +6935,14 @@ view_err: &index_add_buffer, &index_add_count, &candidate_key_count)) goto err; - + + DBUG_EXECUTE_IF("alter_table_only_metadata_change", { + if (need_copy_table_res != ALTER_TABLE_METADATA_ONLY) + goto err; }); + DBUG_EXECUTE_IF("alter_table_only_index_change", { + if (need_copy_table_res != ALTER_TABLE_INDEX_CHANGED) + goto err; }); + if (need_copy_table == ALTER_TABLE_METADATA_ONLY) need_copy_table= need_copy_table_res; } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 41737b33fb6..a4c7d665b8a 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1337,6 +1337,16 @@ int multi_update::prepare(List<Item> ¬_used_values, { table->read_set= &table->def_read_set; bitmap_union(table->read_set, &table->tmp_set); + /* + If a timestamp field settable on UPDATE is present then to avoid wrong + update force the table handler to retrieve write-only fields to be able + to compare records and detect data change. + */ + if (table->file->ha_table_flags() & HA_PARTIAL_COLUMN_READ && + table->timestamp_field && + (table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_UPDATE || + table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH)) + bitmap_union(table->read_set, table->write_set); } } |