diff options
author | Chad MILLER <chad@mysql.com> | 2009-04-14 13:20:13 -0400 |
---|---|---|
committer | Chad MILLER <chad@mysql.com> | 2009-04-14 13:20:13 -0400 |
commit | 978e8e06b00defd5c95c7eb88304333e7978a553 (patch) | |
tree | 55596b47965261462217616f8271d0c2b9d79ab0 /sql/sql_insert.cc | |
parent | 7e8cbe66dd4c9b4737abbf36d35c251ccc34f5ee (diff) | |
parent | c38338d76183458de2025548236f1ef1090c9e3a (diff) | |
download | mariadb-git-978e8e06b00defd5c95c7eb88304333e7978a553.tar.gz |
Merge 5.0.80 release and 5.0 community. Version left at 5.0.80.
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 3cba300fbc7..9c8aa196908 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1609,10 +1609,13 @@ 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), dup(dup_arg), ignore(ignore_arg), + log_query(log_query_arg), time_zone(0) + {} ~delayed_row() { x_free(record); @@ -1823,7 +1826,7 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list) pthread_mutex_lock(&LOCK_thread_count); thread_count++; pthread_mutex_unlock(&LOCK_thread_count); - di->thd.set_db(table_list->db, strlen(table_list->db)); + di->thd.set_db(table_list->db, (uint) strlen(table_list->db)); di->thd.query= my_strdup(table_list->table_name, MYF(MY_WME)); if (di->thd.db == NULL || di->thd.query == NULL) { @@ -2066,6 +2069,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; @@ -2519,8 +2535,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); |