diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/events.cc | 21 | ||||
-rw-r--r-- | sql/item.cc | 25 | ||||
-rw-r--r-- | sql/item.h | 6 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 15 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 13 | ||||
-rw-r--r-- | sql/item_func.cc | 23 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 5 | ||||
-rw-r--r-- | sql/log_event.cc | 2 | ||||
-rw-r--r-- | sql/net_serv.cc | 2 | ||||
-rw-r--r-- | sql/sp.cc | 16 | ||||
-rw-r--r-- | sql/sql_acl.cc | 45 | ||||
-rw-r--r-- | sql/sql_class.cc | 9 | ||||
-rw-r--r-- | sql/sql_class.h | 1 | ||||
-rw-r--r-- | sql/sql_delete.cc | 15 | ||||
-rw-r--r-- | sql/sql_parse.cc | 27 | ||||
-rw-r--r-- | sql/sql_partition.cc | 7 | ||||
-rw-r--r-- | sql/sql_partition.h | 3 | ||||
-rw-r--r-- | sql/sql_rename.cc | 7 | ||||
-rw-r--r-- | sql/sql_select.cc | 18 | ||||
-rw-r--r-- | sql/sql_tablespace.cc | 6 | ||||
-rw-r--r-- | sql/sql_trigger.cc | 9 | ||||
-rw-r--r-- | sql/sql_udf.cc | 14 | ||||
-rw-r--r-- | sql/sql_view.cc | 7 | ||||
-rw-r--r-- | sql/table.cc | 13 |
24 files changed, 114 insertions, 195 deletions
diff --git a/sql/events.cc b/sql/events.cc index 7838972a5d6..2d1b3c59a4c 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -425,12 +425,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, event_queue->create_event(thd, new_element, &created); /* Binlog the create event. */ DBUG_ASSERT(thd->query && thd->query_length); - if (mysql_bin_log.is_open()) - { - thd->clear_error(); - thd->binlog_query(THD::MYSQL_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } + write_bin_log(thd, TRUE, thd->query, thd->query_length); } } pthread_mutex_unlock(&LOCK_event_metadata); @@ -551,12 +546,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, new_element); /* Binlog the alter event. */ DBUG_ASSERT(thd->query && thd->query_length); - if (mysql_bin_log.is_open()) - { - thd->clear_error(); - thd->binlog_query(THD::MYSQL_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } + write_bin_log(thd, TRUE, thd->query, thd->query_length); } } pthread_mutex_unlock(&LOCK_event_metadata); @@ -631,12 +621,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists) event_queue->drop_event(thd, dbname, name); /* Binlog the drop event. */ DBUG_ASSERT(thd->query && thd->query_length); - if (mysql_bin_log.is_open()) - { - thd->clear_error(); - thd->binlog_query(THD::MYSQL_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } + write_bin_log(thd, TRUE, thd->query, thd->query_length); } pthread_mutex_unlock(&LOCK_event_metadata); DBUG_RETURN(ret); diff --git a/sql/item.cc b/sql/item.cc index 4638a1d044d..4fa6a2a8517 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1974,10 +1974,11 @@ bool Item_field::val_bool_result() bool Item_field::eq(const Item *item, bool binary_cmp) const { - if (item->type() != FIELD_ITEM) + Item *real_item= ((Item *) item)->real_item(); + if (real_item->type() != FIELD_ITEM) return 0; - Item_field *item_field= (Item_field*) item; + Item_field *item_field= (Item_field*) real_item; if (item_field->field && field) return item_field->field == field; /* @@ -5592,6 +5593,21 @@ void Item_ref::make_field(Send_field *field) } +Item *Item_ref::get_tmp_table_item(THD *thd) +{ + if (!result_field) + return (*ref)->get_tmp_table_item(thd); + + Item_field *item= new Item_field(result_field); + if (item) + { + item->table_name= table_name; + item->db_name= db_name; + } + return item; +} + + void Item_ref_null_helper::print(String *str) { str->append(STRING_WITH_LEN("<ref_null_helper>(")); @@ -5718,8 +5734,7 @@ bool Item_outer_ref::fix_fields(THD *thd, Item **reference) DESCRIPTION A view column reference is considered equal to another column reference if the second one is a view column and if both column - references resolve to the same item. It is assumed that both - items are of the same type. + references resolve to the same item. RETURN TRUE Referenced item is equal to given item @@ -5735,8 +5750,6 @@ bool Item_direct_view_ref::eq(const Item *item, bool binary_cmp) const if (item_ref->ref_type() == VIEW_REF) { Item *item_ref_ref= *(item_ref->ref); - DBUG_ASSERT((*ref)->real_item()->type() == - item_ref_ref->real_item()->type()); return ((*ref)->real_item() == item_ref_ref->real_item()); } } diff --git a/sql/item.h b/sql/item.h index c79107e04bd..82fafe6cd20 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2031,11 +2031,7 @@ public: enum_field_types field_type() const { return (*ref)->field_type(); } Field *get_tmp_table_field() { return result_field ? result_field : (*ref)->get_tmp_table_field(); } - Item *get_tmp_table_item(THD *thd) - { - return (result_field ? new Item_field(result_field) : - (*ref)->get_tmp_table_item(thd)); - } + Item *get_tmp_table_item(THD *thd); table_map used_tables() const { return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables(); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 543bc827c48..3477ce84b21 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2586,6 +2586,21 @@ void Item_func_case::print(String *str) str->append(STRING_WITH_LEN("end)")); } + +void Item_func_case::cleanup() +{ + uint i; + DBUG_ENTER("Item_func_case::cleanup"); + Item_func::cleanup(); + for (i= 0; i <= (uint)DECIMAL_RESULT; i++) + { + delete cmp_items[i]; + cmp_items[i]= 0; + } + DBUG_VOID_RETURN; +} + + /* Coalesce - return first not NULL argument. */ diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 60f2ac6321d..1bc52ea093c 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1142,18 +1142,7 @@ public: Item *find_item(String *str); CHARSET_INFO *compare_collation() { return cmp_collation.collation; } bool check_partition_func_processor(uchar *bool_arg) { return FALSE;} - void cleanup() - { - uint i; - DBUG_ENTER("Item_func_case::cleanup"); - Item_func::cleanup(); - for (i= 0; i <= (uint)DECIMAL_RESULT; i++) - { - delete cmp_items[i]; - cmp_items[i]= 0; - } - DBUG_VOID_RETURN; - } + void cleanup(); }; /* diff --git a/sql/item_func.cc b/sql/item_func.cc index d2485c012a1..5a41aa3e9da 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1521,16 +1521,20 @@ void Item_func_neg::fix_length_and_dec() Use val() to get value as arg_type doesn't mean that item is Item_int or Item_real due to existence of Item_param. */ - if (hybrid_type == INT_RESULT && - args[0]->type() == INT_ITEM && - ((ulonglong) args[0]->val_int() > (ulonglong) LONGLONG_MIN)) + if (hybrid_type == INT_RESULT && args[0]->const_item()) { - /* - Ensure that result is converted to DECIMAL, as longlong can't hold - the negated number - */ - hybrid_type= DECIMAL_RESULT; - DBUG_PRINT("info", ("Type changed: DECIMAL_RESULT")); + longlong val= args[0]->val_int(); + if ((ulonglong) val >= (ulonglong) LONGLONG_MIN && + ((ulonglong) val != (ulonglong) LONGLONG_MIN || + args[0]->type() != INT_ITEM)) + { + /* + Ensure that result is converted to DECIMAL, as longlong can't hold + the negated number + */ + hybrid_type= DECIMAL_RESULT; + DBUG_PRINT("info", ("Type changed: DECIMAL_RESULT")); + } } unsigned_flag= 0; DBUG_VOID_RETURN; @@ -2500,7 +2504,6 @@ longlong Item_func_coercibility::val_int() void Item_func_locate::fix_length_and_dec() { - maybe_null= 0; max_length= MY_INT32_NUM_DECIMAL_DIGITS; agg_arg_charsets(cmp_collation, args, 2, MY_COLL_CMP_CONV, 1); } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 3dc352338a4..a376504512f 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1143,8 +1143,9 @@ String *Item_func_substr::val_str(String *str) (arg_count == 3 && args[2]->null_value)))) return 0; /* purecov: inspected */ - /* Negative length, will return empty string. */ - if ((arg_count == 3) && (length <= 0) && !args[2]->unsigned_flag) + /* Negative or zero length, will return empty string. */ + if ((arg_count == 3) && (length <= 0) && + (length == 0 || !args[2]->unsigned_flag)) return &my_empty_string; /* Assumes that the maximum length of a String is < INT_MAX32. */ diff --git a/sql/log_event.cc b/sql/log_event.cc index 658f33e7bed..1f5013a8ef6 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1132,7 +1132,6 @@ void Log_event::print_header(IO_CACHE* file, } *c= '\0'; - /* Non-full last line */ if (hex_string[0]) { char emit_buf[256]; @@ -2138,6 +2137,7 @@ Default database: '%s'. Query: '%s'", { DBUG_PRINT("info",("error ignored")); clear_all_errors(thd, const_cast<RELAY_LOG_INFO*>(rli)); + thd->killed= THD::NOT_KILLED; } /* Other cases: mostly we expected no error and get one. diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 959418df87b..bd273145782 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -116,13 +116,13 @@ static my_bool net_write_buff(NET *net,const uchar *packet,ulong len); my_bool my_net_init(NET *net, Vio* vio) { DBUG_ENTER("my_net_init"); + net->vio = vio; my_net_local_init(net); /* Set some limits */ if (!(net->buff=(uchar*) my_malloc((size_t) net->max_packet+ NET_HEADER_SIZE + COMP_HEADER_SIZE, MYF(MY_WME)))) DBUG_RETURN(1); net->buff_end=net->buff+net->max_packet; - net->vio = vio; net->no_send_ok= net->no_send_eof= net->no_send_error= 0; net->error=0; net->return_errno=0; net->return_status=0; net->pkt_nr=net->compress_pkt_nr=0; diff --git a/sql/sp.cc b/sql/sp.cc index a8e6c2844a2..6e890f638d0 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -654,13 +654,7 @@ sp_drop_routine(THD *thd, int type, sp_name *name) if (ret == SP_OK) { - if (mysql_bin_log.is_open()) - { - thd->clear_error(); - thd->binlog_query(THD::MYSQL_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } - + write_bin_log(thd, TRUE, thd->query, thd->query_length); sp_cache_invalidate(); } @@ -727,13 +721,7 @@ sp_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics) if (ret == SP_OK) { - if (mysql_bin_log.is_open()) - { - thd->clear_error(); - thd->binlog_query(THD::MYSQL_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } - + write_bin_log(thd, TRUE, thd->query, thd->query_length); sp_cache_invalidate(); } diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index dfdd6f5c5b4..8f0af8af3ed 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3143,12 +3143,7 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list, if (!result) /* success */ { - if (mysql_bin_log.is_open()) - { - thd->clear_error(); - thd->binlog_query(THD::MYSQL_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } + write_bin_log(thd, TRUE, thd->query, thd->query_length); } rw_unlock(&LOCK_grant); @@ -3315,12 +3310,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, pthread_mutex_unlock(&acl_cache->lock); if (!result && !no_error) { - if (mysql_bin_log.is_open()) - { - thd->clear_error(); - thd->binlog_query(THD::MYSQL_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } + write_bin_log(thd, TRUE, thd->query, thd->query_length); } rw_unlock(&LOCK_grant); @@ -3435,12 +3425,7 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list, if (!result) { - if (mysql_bin_log.is_open()) - { - thd->clear_error(); - thd->binlog_query(THD::MYSQL_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } + write_bin_log(thd, TRUE, thd->query, thd->query_length); } rw_unlock(&LOCK_grant); @@ -5469,11 +5454,7 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list) VOID(pthread_mutex_unlock(&acl_cache->lock)); - if (mysql_bin_log.is_open()) - { - thd->binlog_query(THD::MYSQL_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } + write_bin_log(thd, FALSE, thd->query, thd->query_length); rw_unlock(&LOCK_grant); close_thread_tables(thd); @@ -5545,11 +5526,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list) DBUG_PRINT("info", ("thd->net.last_errno: %d", thd->net.last_errno)); DBUG_PRINT("info", ("thd->net.last_error: %s", thd->net.last_error)); - if (mysql_bin_log.is_open()) - { - thd->binlog_query(THD::MYSQL_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } + write_bin_log(thd, FALSE, thd->query, thd->query_length); rw_unlock(&LOCK_grant); close_thread_tables(thd); @@ -5626,11 +5603,7 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list) VOID(pthread_mutex_unlock(&acl_cache->lock)); - if (mysql_bin_log.is_open()) - { - thd->binlog_query(THD::MYSQL_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } + write_bin_log(thd, FALSE, thd->query, thd->query_length); rw_unlock(&LOCK_grant); close_thread_tables(thd); @@ -5814,11 +5787,7 @@ bool mysql_revoke_all(THD *thd, List <LEX_USER> &list) VOID(pthread_mutex_unlock(&acl_cache->lock)); - if (mysql_bin_log.is_open()) - { - thd->binlog_query(THD::MYSQL_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } + write_bin_log(thd, FALSE, thd->query, thd->query_length); rw_unlock(&LOCK_grant); close_thread_tables(thd); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 119583cab95..40b37ed7405 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -3076,15 +3076,6 @@ int THD::binlog_flush_pending_rows_event(bool stmt_end) } -void THD::binlog_delete_pending_rows_event() -{ - if (Rows_log_event *pending= binlog_get_pending_rows_event()) - { - delete pending; - binlog_set_pending_rows_event(0); - } -} - /* Member function that will log query, either row-based or statement-based depending on the value of the 'current_stmt_binlog_row_based' diff --git a/sql/sql_class.h b/sql/sql_class.h index a52ec55f040..1c0d6e4c258 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1100,7 +1100,6 @@ public: Rows_log_event* binlog_get_pending_rows_event() const; void binlog_set_pending_rows_event(Rows_log_event* ev); int binlog_flush_pending_rows_event(bool stmt_end); - void binlog_delete_pending_rows_event(); private: uint binlog_table_maps; // Number of table maps currently in the binlog diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 4fa4705062a..7c868092921 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -987,16 +987,11 @@ end: { if (!error) { - if (mysql_bin_log.is_open()) - { - /* - TRUNCATE must always be statement-based binlogged (not row-based) so - we don't test current_stmt_binlog_row_based. - */ - thd->clear_error(); - thd->binlog_query(THD::STMT_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } + /* + TRUNCATE must always be statement-based binlogged (not row-based) so + we don't test current_stmt_binlog_row_based. + */ + write_bin_log(thd, TRUE, thd->query, thd->query_length); send_ok(thd); // This should return record count } VOID(pthread_mutex_lock(&LOCK_open)); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 80a60b3366d..4845f45948f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2507,12 +2507,7 @@ end_with_restore_list: /* Presumably, REPAIR and binlog writing doesn't require synchronization */ - if (mysql_bin_log.is_open()) - { - thd->clear_error(); // No binlog error generated - thd->binlog_query(THD::STMT_QUERY_TYPE, - thd->query, thd->query_length, 0, FALSE); - } + write_bin_log(thd, TRUE, thd->query, thd->query_length); } select_lex->table_list.first= (uchar*) first_table; lex->query_tables=all_tables; @@ -2542,12 +2537,7 @@ end_with_restore_list: /* Presumably, ANALYZE and binlog writing doesn't require synchronization */ - if (mysql_bin_log.is_open()) - { - thd->clear_error(); // No binlog error generated - thd->binlog_query(THD::STMT_QUERY_TYPE, - thd->query, thd->query_length, 0, FALSE); - } + write_bin_log(thd, TRUE, thd->query, thd->query_length); } select_lex->table_list.first= (uchar*) first_table; lex->query_tables=all_tables; @@ -2569,12 +2559,7 @@ end_with_restore_list: /* Presumably, OPTIMIZE and binlog writing doesn't require synchronization */ - if (mysql_bin_log.is_open()) - { - thd->clear_error(); // No binlog error generated - thd->binlog_query(THD::STMT_QUERY_TYPE, - thd->query, thd->query_length, 0, FALSE); - } + write_bin_log(thd, TRUE, thd->query, thd->query_length); } select_lex->table_list.first= (uchar*) first_table; lex->query_tables=all_tables; @@ -3474,11 +3459,7 @@ end_with_restore_list: */ if (!lex->no_write_to_binlog && write_to_binlog) { - if (mysql_bin_log.is_open()) - { - thd->binlog_query(THD::STMT_QUERY_TYPE, - thd->query, thd->query_length, 0, FALSE); - } + write_bin_log(thd, FALSE, thd->query, thd->query_length); } send_ok(thd); } diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 407a0b3dcf2..ad3cf2d3e7a 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -3663,6 +3663,8 @@ void get_partition_set(const TABLE *table, uchar *buf, const uint index, table Table object of partitioned table create_table_ind Is it called from CREATE TABLE default_db_type What is the default engine of the table + work_part_info_used Flag is raised if we don't create new + part_info, but used thd->work_part_info RETURN VALUE TRUE Error @@ -3683,7 +3685,8 @@ bool mysql_unpack_partition(THD *thd, const char *part_buf, uint part_info_len, const char *part_state, uint part_state_len, TABLE* table, bool is_create_table_ind, - handlerton *default_db_type) + handlerton *default_db_type, + bool *work_part_info_used) { bool result= TRUE; partition_info *part_info; @@ -3698,6 +3701,7 @@ bool mysql_unpack_partition(THD *thd, Lex_input_stream lip(thd, part_buf, part_info_len); lex_start(thd); + *work_part_info_used= false; /* We need to use the current SELECT_LEX since I need to keep the Name_resolution_context object which is referenced from the @@ -3782,6 +3786,7 @@ bool mysql_unpack_partition(THD *thd, thd->free_items(); part_info= thd->work_part_info; table->s->version= 0UL; + *work_part_info_used= true; } } table->part_info= part_info; diff --git a/sql/sql_partition.h b/sql/sql_partition.h index d0c66083768..56f24181b93 100644 --- a/sql/sql_partition.h +++ b/sql/sql_partition.h @@ -81,7 +81,8 @@ bool mysql_unpack_partition(THD *thd, const char *part_buf, uint part_info_len, const char *part_state, uint part_state_len, TABLE *table, bool is_create_table_ind, - handlerton *default_db_type); + handlerton *default_db_type, + bool *work_part_info_used); void make_used_partitions_str(partition_info *part_info, String *parts_str); uint32 get_list_array_idx_for_endpoint(partition_info *part_info, bool left_endpoint, diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index f34ec83b29c..866d82377c0 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -174,12 +174,7 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent) /* Lets hope this doesn't fail as the result will be messy */ if (!silent && !error) { - if (mysql_bin_log.is_open()) - { - thd->clear_error(); - thd->binlog_query(THD::STMT_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } + write_bin_log(thd, TRUE, thd->query, thd->query_length); send_ok(thd); } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9ca44d588a4..9cb59d957de 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1356,8 +1356,7 @@ JOIN::optimize() there are aggregate functions, because in all these cases we need all result rows. */ - ha_rows tmp_rows_limit= ((order == 0 || skip_sort_order || - test(select_options & OPTION_BUFFER_RESULT)) && + ha_rows tmp_rows_limit= ((order == 0 || skip_sort_order) && !tmp_group && !thd->lex->current_select->with_sum_func) ? select_limit : HA_POS_ERROR; @@ -12842,10 +12841,14 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order, /* When there is SQL_BIG_RESULT do not sort using index for GROUP BY, - and thus force sorting on disk. + and thus force sorting on disk unless a group min-max optimization + is going to be used as it is applied now only for one table queries + with covering indexes. */ if ((order != join->group_list || - !(join->select_options & SELECT_BIG_RESULT)) && + !(join->select_options & SELECT_BIG_RESULT) || + select && select->quick && + select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) && test_if_skip_sort_order(tab,order,select_limit,0, is_order_by ? &table->keys_in_use_for_order_by : &table->keys_in_use_for_group_by)) @@ -14543,6 +14546,13 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array, if (!item_field) DBUG_RETURN(TRUE); // Fatal error item_field->name= item->name; + if (item->type() == Item::REF_ITEM) + { + Item_field *ifield= (Item_field *) item_field; + Item_ref *iref= (Item_ref *) item; + ifield->table_name= iref->table_name; + ifield->db_name= iref->db_name; + } #ifndef DBUG_OFF if (!item_field->name) { diff --git a/sql/sql_tablespace.cc b/sql/sql_tablespace.cc index b4a03a370ba..9fec0e3bc63 100644 --- a/sql/sql_tablespace.cc +++ b/sql/sql_tablespace.cc @@ -66,10 +66,6 @@ int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info) ha_resolve_storage_engine_name(hton), "TABLESPACE or LOGFILE GROUP"); } - if (mysql_bin_log.is_open()) - { - thd->binlog_query(THD::STMT_QUERY_TYPE, - thd->query, thd->query_length, FALSE, TRUE); - } + write_bin_log(thd, FALSE, thd->query, thd->query_length); DBUG_RETURN(FALSE); } diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 7433a3f45cd..7c28dff850a 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -307,14 +307,7 @@ end: if (!result) { - if (mysql_bin_log.is_open()) - { - thd->clear_error(); - - /* Such a statement can always go directly to binlog, no trans cache. */ - thd->binlog_query(THD::STMT_QUERY_TYPE, - stmt_query.ptr(), stmt_query.length(), FALSE, FALSE); - } + write_bin_log(thd, TRUE, stmt_query.ptr(), stmt_query.length()); } VOID(pthread_mutex_unlock(&LOCK_open)); diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 20ce614f361..8361fc64f33 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -493,12 +493,7 @@ int mysql_create_function(THD *thd,udf_func *udf) rw_unlock(&THR_LOCK_udf); /* Binlog the create function. */ - if (mysql_bin_log.is_open()) - { - thd->clear_error(); - thd->binlog_query(THD::MYSQL_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } + write_bin_log(thd, TRUE, thd->query, thd->query_length); DBUG_RETURN(0); @@ -569,12 +564,7 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name) rw_unlock(&THR_LOCK_udf); /* Binlog the drop function. */ - if (mysql_bin_log.is_open()) - { - thd->clear_error(); - thd->binlog_query(THD::MYSQL_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } + write_bin_log(thd, TRUE, thd->query, thd->query_length); DBUG_RETURN(0); err: diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 58e74d132d5..ef87d226549 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1467,12 +1467,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) DBUG_RETURN(TRUE); } - if (mysql_bin_log.is_open()) - { - thd->clear_error(); - thd->binlog_query(THD::STMT_QUERY_TYPE, - thd->query, thd->query_length, FALSE, FALSE); - } + write_bin_log(thd, TRUE, thd->query, thd->query_length); send_ok(thd); VOID(pthread_mutex_unlock(&LOCK_open)); diff --git a/sql/table.cc b/sql/table.cc index eab4d175fd8..45ca17afce4 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1589,21 +1589,30 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, thd->set_n_backup_active_arena(&part_func_arena, &backup_arena); thd->stmt_arena= &part_func_arena; bool tmp; + bool work_part_info_used; tmp= mysql_unpack_partition(thd, share->partition_info, share->partition_info_len, share->part_state, share->part_state_len, outparam, is_create_table, - share->default_part_db_type); + share->default_part_db_type, + &work_part_info_used); outparam->part_info->is_auto_partitioned= share->auto_partitioned; DBUG_PRINT("info", ("autopartitioned: %u", share->auto_partitioned)); - if (!tmp) + /* we should perform the fix_partition_func in either local or + caller's arena depending on work_part_info_used value + */ + if (!tmp && !work_part_info_used) tmp= fix_partition_func(thd, outparam, is_create_table); thd->stmt_arena= backup_stmt_arena_ptr; thd->restore_active_arena(&part_func_arena, &backup_arena); if (!tmp) + { + if (work_part_info_used) + tmp= fix_partition_func(thd, outparam, is_create_table); outparam->part_info->item_free_list= part_func_arena.free_list; + } if (tmp) { if (is_create_table) |