diff options
author | Michael Widenius <monty@askmonty.org> | 2011-02-20 18:51:43 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-02-20 18:51:43 +0200 |
commit | 58bb0769bdf13a9747e900aa2f0955137738ce9d (patch) | |
tree | 1b46ea0f72dce27532f0c87c60ba8a1baa453fa0 /sql/ha_partition.cc | |
parent | 7e497abcfb3e761ba5a368316192ae930fb58f6b (diff) | |
parent | de3c4428b8c759e85631d8d70b5845c872de5400 (diff) | |
download | mariadb-git-58bb0769bdf13a9747e900aa2f0955137738ce9d.tar.gz |
Merge with MySQL 5.1.55
- Fixed some issues with partitions and connection_string, which also fixed lp:716890 "Pre- and post-recovery crash in Aria"
- Fixed wrong assert in Aria
Now need to merge with latest xtradb before pushing
sql/ha_partition.cc:
Ensure that m_ordered_rec_buffer is not freed before close.
sql/mysqld.cc:
Changed to use opt_stack_trace instead of opt_pstack.
Removed references to pstack
sql/partition_element.h:
Ensure that connect_string is initialized
storage/maria/ma_key_recover.c:
Fixed wrong assert
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r-- | sql/ha_partition.cc | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 286cb94c830..89d584ef5e1 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -290,6 +290,9 @@ ha_partition::~ha_partition() delete m_file[i]; } + my_free(m_ordered_rec_buffer, MYF(MY_ALLOW_ZERO_PTR)); + m_ordered_rec_buffer= NULL; + clear_handler_file(); free_root(&m_mem_root, MYF(0)); @@ -2228,15 +2231,15 @@ bool ha_partition::create_handler_file(const char *name) MYF(MY_WME | MY_NABP)) != 0; part_it.rewind(); - for (i= 0; i < no_parts; i++) + for (i= 0; i < no_parts && !result; i++) { uchar buffer[4]; part_elem= part_it++; uint length = part_elem->connect_string.length; int4store(buffer, length); - my_write(file, buffer, 4, MYF(MY_WME | MY_NABP)); - my_write(file, (uchar *) part_elem->connect_string.str, length, - MYF(MY_WME | MY_NABP)); + result= (my_write(file, buffer, 4, MYF(MY_WME | MY_NABP)) || + my_write(file, (uchar *) part_elem->connect_string.str, length, + MYF(MY_WME | MY_NABP))); } VOID(my_close(file, MYF(0))); } @@ -2264,7 +2267,6 @@ void ha_partition::clear_handler_file() m_file_buffer= NULL; m_engine_array= NULL; m_connect_string= NULL; - m_ordered_rec_buffer= NULL; } /* @@ -2568,7 +2570,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked) alloc_len+= table_share->max_key_length; if (!m_ordered_rec_buffer) { - if (!(m_ordered_rec_buffer= (uchar*) alloc_root(&m_mem_root, alloc_len))) + if (!(m_ordered_rec_buffer= (uchar*)my_malloc(alloc_len, MYF(MY_WME)))) { DBUG_RETURN(1); } @@ -3106,7 +3108,9 @@ int ha_partition::write_row(uchar * buf) my_bitmap_map *old_map; HA_DATA_PARTITION *ha_data= (HA_DATA_PARTITION*) table_share->ha_data; THD *thd= ha_thd(); - timestamp_auto_set_type orig_timestamp_type= table->timestamp_field_type; + timestamp_auto_set_type saved_timestamp_type= table->timestamp_field_type; + ulong saved_sql_mode= thd->variables.sql_mode; + bool saved_auto_inc_field_not_null= table->auto_increment_field_not_null; #ifdef NOT_NEEDED uchar *rec0= m_rec0; #endif @@ -3142,6 +3146,22 @@ int ha_partition::write_row(uchar * buf) */ if (error) goto exit; + + /* + Don't allow generation of auto_increment value the partitions handler. + If a partitions handler would change the value, then it might not + match the partition any longer. + This can occur if 'SET INSERT_ID = 0; INSERT (NULL)', + So allow this by adding 'MODE_NO_AUTO_VALUE_ON_ZERO' to sql_mode. + The partitions handler::next_insert_id must always be 0. Otherwise + we need to forward release_auto_increment, or reset it for all + partitions. + */ + if (table->next_number_field->val_int() == 0) + { + table->auto_increment_field_not_null= TRUE; + thd->variables.sql_mode|= MODE_NO_AUTO_VALUE_ON_ZERO; + } } old_map= dbug_tmp_use_all_columns(table, table->read_set); @@ -3175,7 +3195,9 @@ int ha_partition::write_row(uchar * buf) set_auto_increment_if_higher(table->next_number_field); reenable_binlog(thd); exit: - table->timestamp_field_type= orig_timestamp_type; + thd->variables.sql_mode= saved_sql_mode; + table->auto_increment_field_not_null= saved_auto_inc_field_not_null; + table->timestamp_field_type= saved_timestamp_type; DBUG_RETURN(error); } @@ -3242,11 +3264,24 @@ int ha_partition::update_row(const uchar *old_data, uchar *new_data) } else { + Field *saved_next_number_field= table->next_number_field; + /* + Don't allow generation of auto_increment value for update. + table->next_number_field is never set on UPDATE. + But is set for INSERT ... ON DUPLICATE KEY UPDATE, + and since update_row() does not generate or update an auto_inc value, + we cannot have next_number_field set when moving a row + to another partition with write_row(), since that could + generate/update the auto_inc value. + This gives the same behavior for partitioned vs non partitioned tables. + */ + table->next_number_field= NULL; DBUG_PRINT("info", ("Update from partition %d to partition %d", old_part_id, new_part_id)); tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */ error= m_file[new_part_id]->ha_write_row(new_data); reenable_binlog(thd); + table->next_number_field= saved_next_number_field; if (error) goto exit; |