diff options
author | holyfoot/hf@mysql.com/hfmain.(none) <> | 2007-11-12 21:11:31 +0400 |
---|---|---|
committer | holyfoot/hf@mysql.com/hfmain.(none) <> | 2007-11-12 21:11:31 +0400 |
commit | 8085bed591b56ed4c0aaad81dec2bf43e622de56 (patch) | |
tree | ed73a583276c2f1abaf128909d01e69d8bf761ef /sql | |
parent | 84159db8f7458ef7873a3e850f52d8f7cb54f9b9 (diff) | |
download | mariadb-git-8085bed591b56ed4c0aaad81dec2bf43e622de56.tar.gz |
Bug #32067 Partitions: crash with timestamp column.
Partition handler fails updating tables with partitioning
based on timestamp field, as it calculates the timestamp field
AFTER it calculates the number of partition of a record.
Fixed by adding timestamp_field->set_time() call and disabling
such consequent calls
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_partition.cc | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 8afaab71160..a7638f5a357 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2783,16 +2783,28 @@ exit: int ha_partition::update_row(const uchar *old_data, uchar *new_data) { uint32 new_part_id, old_part_id; - int error; + int error= 0; longlong func_value; + timestamp_auto_set_type orig_timestamp_type= table->timestamp_field_type; DBUG_ENTER("ha_partition::update_row"); + /* + We need to set timestamp field once before we calculate + the partition. Then we disable timestamp calculations + inside m_file[*]->update_row() methods + */ + if (orig_timestamp_type & TIMESTAMP_AUTO_SET_ON_UPDATE) + { + table->timestamp_field->set_time(); + table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET; + } + if ((error= get_parts_for_update(old_data, new_data, table->record[0], m_part_info, &old_part_id, &new_part_id, &func_value))) { m_part_info->err_value= func_value; - DBUG_RETURN(error); + goto exit; } /* @@ -2804,23 +2816,27 @@ int ha_partition::update_row(const uchar *old_data, uchar *new_data) if (new_part_id == old_part_id) { DBUG_PRINT("info", ("Update in partition %d", new_part_id)); - DBUG_RETURN(m_file[new_part_id]->update_row(old_data, new_data)); + error= m_file[new_part_id]->update_row(old_data, new_data); + goto exit; } else { DBUG_PRINT("info", ("Update from partition %d to partition %d", old_part_id, new_part_id)); if ((error= m_file[new_part_id]->write_row(new_data))) - DBUG_RETURN(error); + goto exit; if ((error= m_file[old_part_id]->delete_row(old_data))) { #ifdef IN_THE_FUTURE (void) m_file[new_part_id]->delete_last_inserted_row(new_data); #endif - DBUG_RETURN(error); + goto exit; } } - DBUG_RETURN(0); + +exit: + table->timestamp_field_type= orig_timestamp_type; + DBUG_RETURN(error); } |