summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authorLeonard Zhou <leonard@mysql.com>2009-03-24 08:45:05 +0800
committerLeonard Zhou <leonard@mysql.com>2009-03-24 08:45:05 +0800
commit5fdc5510ec1abcfe3f3f74a229ae3102533f46c4 (patch)
tree7bf3c31bd2c0fd5a64cef0cc9dc0f3fe2aa7687d /sql/sql_insert.cc
parentb4fdb8aec14b533db4a5ea2f99c1a9f3ce07946c (diff)
downloadmariadb-git-5fdc5510ec1abcfe3f3f74a229ae3102533f46c4.tar.gz
BUG#41719 delayed INSERT into timestamp col needs set time_zone for concurrent binlogging
When do 'insert delayed' operation, the time_zone info doesn't be keeped in the row info. So when we do insert sometime later, time_zone didn't write into binlog. This will cause wrong result for timestamp column in slave. Our solution is that adding time_zone info with the delayed-row and restoring time_zone from row-info when execute that row in the furture by another thread. So we can write correct time_zone info into binlog and got correct result in slave. mysql-test/r/rpl_timezone.result: Test result mysql-test/t/rpl_timezone.test: Add test for bug#41719 sql/sql_insert.cc: Add time_zone info in the delayed-row and restore time_zone when execute the row in the furture by another thread.
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc27
1 files changed, 26 insertions, 1 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 4eddcd17df1..ec16de318cc 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1605,10 +1605,11 @@ public:
ulong auto_increment_increment;
ulong auto_increment_offset;
timestamp_auto_set_type timestamp_field_type;
+ Time_zone *time_zone;
uint query_length;
delayed_row(enum_duplicates dup_arg, bool ignore_arg, bool log_query_arg)
- :record(0), query(0), dup(dup_arg), ignore(ignore_arg), log_query(log_query_arg) {}
+ :record(0), query(0), time_zone(0), dup(dup_arg), ignore(ignore_arg), log_query(log_query_arg) {}
~delayed_row()
{
x_free(record);
@@ -2062,6 +2063,19 @@ int write_delayed(THD *thd,TABLE *table,enum_duplicates duplic, bool ignore,
row->last_insert_id= thd->last_insert_id;
row->timestamp_field_type= table->timestamp_field_type;
+ /* Add session variable timezone
+ Time_zone object will not be freed even the thread is ended.
+ So we can get time_zone object from thread which handling delayed statement.
+ See the comment of my_tz_find() for detail.
+ */
+ if (thd->time_zone_used)
+ {
+ row->time_zone = thd->variables.time_zone;
+ }
+ else
+ {
+ row->time_zone = NULL;
+ }
/* The session variable settings can always be copied. */
row->auto_increment_increment= thd->variables.auto_increment_increment;
row->auto_increment_offset= thd->variables.auto_increment_offset;
@@ -2515,8 +2529,19 @@ bool Delayed_insert::handle_inserts(void)
}
if (row->query && row->log_query && using_bin_log)
{
+ bool backup_time_zone_used = thd.time_zone_used;
+ Time_zone *backup_time_zone = thd.variables.time_zone;
+ if (row->time_zone != NULL)
+ {
+ thd.time_zone_used = true;
+ thd.variables.time_zone = row->time_zone;
+ }
+
Query_log_event qinfo(&thd, row->query, row->query_length, 0, FALSE);
mysql_bin_log.write(&qinfo);
+
+ thd.time_zone_used = backup_time_zone_used;
+ thd.variables.time_zone = backup_time_zone;
}
if (table->s->blob_fields)
free_delayed_insert_blobs(table);