From b5ac35fa17c9b7cfce42676d6ea032c3d9318fdf Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Thu, 2 Aug 2007 12:35:05 +0300 Subject: [PATCH 1/8] Addendum to bug 29325 keep_files_on_create made a startup option --- sql/mysqld.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 61980fa1887..0a860f84b57 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4828,7 +4828,8 @@ enum options_mysqld OPT_PORT_OPEN_TIMEOUT, OPT_MERGE, OPT_INNODB_ROLLBACK_ON_TIMEOUT, - OPT_SECURE_FILE_PRIV + OPT_SECURE_FILE_PRIV, + OPT_KEEP_FILES_ON_CREATE }; @@ -5830,6 +5831,11 @@ log and this option does nothing anymore.", (gptr*) &max_system_variables.join_buff_size, 0, GET_ULONG, REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, IO_SIZE, 0}, + {"keep_files_on_create", OPT_KEEP_FILES_ON_CREATE, + "Don't overwrite stale .MYD and .MYI even if no directory is specified.", + (gptr*) &global_system_variables.keep_files_on_create, + (gptr*) &max_system_variables.keep_files_on_create, + 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"key_buffer_size", OPT_KEY_BUFFER_SIZE, "The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.", (gptr*) &dflt_key_cache_var.param_buff_size, From fed7ee340b77b8d634ec073b330f4928ccd3486b Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Thu, 2 Aug 2007 17:11:35 +0300 Subject: [PATCH 2/8] Bug #30193: crash during drop table and kill When DROP TABLE detects that it has been killed by another thread it must unlock the table names it locked. Fixed by backporting the 5.1 error handling code. --- sql/sql_table.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index d83100aa439..e0104f11be5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -256,8 +256,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, drop_locked_tables(thd, db, table->table_name); if (thd->killed) { - thd->no_warnings_for_error= 0; - DBUG_RETURN(-1); + error=-1; + goto err_with_placeholders; } alias= (lower_case_table_names == 2) ? table->alias : table->table_name; /* remove form file and isam files */ @@ -338,6 +338,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, } } +err_with_placeholders: if (!drop_temporary) unlock_table_names(thd, tables, (TABLE_LIST*) 0); thd->no_warnings_for_error= 0; From b63f8f8985cf2339d21ff676a5a996286bd6c5f6 Mon Sep 17 00:00:00 2001 From: "gshchepa/uchum@gleb.loc" <> Date: Fri, 3 Aug 2007 01:58:21 +0500 Subject: [PATCH 3/8] Fixed bug #27352. The SELECT query with more than 31 nested dependent SELECT queries returned wrong result. New error message has been added: ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT. It will be reported as: "Too high level of nesting for select". --- mysql-test/r/select.result | 10 ++++++++++ mysql-test/t/select.test | 30 ++++++++++++++++++++++++++++++ sql/share/errmsg.txt | 2 ++ sql/sql_parse.cc | 5 +++++ sql/unireg.h | 2 ++ 5 files changed, 49 insertions(+) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index bfe0b9d19df..5930c36029f 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -3995,4 +3995,14 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE f1 index inx inx 10 NULL 7 Using where; Using index 1 SIMPLE f2 ref inx inx 5 test.f1.b 1 Using where; Using index DROP TABLE t1; +CREATE TABLE t1 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2)))))))))))))))))))))))))))))))) > 0; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +31 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +32 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used +EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) > 0; +ERROR HY000: Too high level of nesting for select +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 56b2f1b02b8..8bfa12539fa 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3370,4 +3370,34 @@ EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 WHERE 1 AND f1.b NOT IN (100,2232,3343,51111); DROP TABLE t1; +# +# Bug #27352: Incorrect result of nested selects instead of error reporting +# + +CREATE TABLE t1 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); + +let $n= 31; +let $q= COUNT(c2); +while ($n) +{ + let $q= (SELECT $q); + dec $n; +} +--disable_warnings +eval EXPLAIN SELECT c1 FROM t1 WHERE $q > 0; +--enable_warnings + +let $n= 64; +let $q= COUNT(c2); +while ($n) +{ + let $q= (SELECT $q); + dec $n; +} +--error ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT +eval EXPLAIN SELECT c1 FROM t1 WHERE $q > 0; + +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index a52ffa8216c..6d4ca33ccc7 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5635,3 +5635,5 @@ ER_NON_INSERTABLE_TABLE eng "The target table %-.100s of the %s is not insertable-into" ER_ADMIN_WRONG_MRG_TABLE eng "Table '%-.64s' is differently defined or of non-MyISAM type or doesn't exist" +ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT + eng "Too high level of nesting for select" diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ae3bc0f5597..78b3904a207 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5889,6 +5889,11 @@ mysql_new_select(LEX *lex, bool move_down) select_lex->init_query(); select_lex->init_select(); lex->nest_level++; + if (lex->nest_level > (int) MAX_SELECT_NESTING) + { + my_error(ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT,MYF(0),MAX_SELECT_NESTING); + DBUG_RETURN(1); + } select_lex->nest_level= lex->nest_level; /* Don't evaluate this subquery during statement prepare even if diff --git a/sql/unireg.h b/sql/unireg.h index 81ca18c1d32..d8301060cc4 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -81,6 +81,8 @@ RAND_TABLE_BIT) #define MAX_FIELDS 4096 /* Limit in the .frm file */ +#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1) + #define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD) #define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD) From 2bfbe2cd84e0895b2462c811e8eb3015953b503f Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Fri, 3 Aug 2007 14:14:33 +0300 Subject: [PATCH 4/8] Bug #25228: rpl_relayspace.test fails on powermacg5, vm-win2003-32-a A test case was waiting for a fixed number of seconds for a specific state of the slave IO thread to take place. Fixed by waiting in a loop for that specific thread state instead (or timeout). --- mysql-test/t/rpl_relayspace.test | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mysql-test/t/rpl_relayspace.test b/mysql-test/t/rpl_relayspace.test index 70315c14f34..d4ef2fe59bd 100644 --- a/mysql-test/t/rpl_relayspace.test +++ b/mysql-test/t/rpl_relayspace.test @@ -14,6 +14,22 @@ connection slave; reset slave; start slave io_thread; # Give the I/O thread time to block. +let $run= 1; +let $counter= 300; +while ($run) +{ + let $io_state= query_get_value("SHOW SLAVE STATUS", Slave_IO_State, 1); + if (`SELECT '$io_state' = 'Waiting for the slave SQL thread to free enough relay log space'`){ + let $run= 0; + } + sleep 0.1; + if (!$counter){ + --echo "Failed while waiting for slave IO thread block" + SHOW SLAVE STATUS; + exit; + } + dec $counter; +} sleep 2; # A bug caused the I/O thread to refuse stopping. stop slave io_thread; From 5f6df1b2326e9050dfcc8c1d5f13cf6a3be3bd43 Mon Sep 17 00:00:00 2001 From: "igor@olga.mysql.com" <> Date: Sun, 5 Aug 2007 14:16:49 -0700 Subject: [PATCH 5/8] Fix bug #30219. This bug manifested itself for queries with grouping by columns of the BIT type. It led to wrong comparisons of bit-field values and wrong result sets. Bit-field values never cannot be compared as binary values. Yet the class Field_bit had an implementation of the cmp method that compared bit-fields values as binary values. Also the get_image and set_image methods of the base class Field cannot be used for objects of the Field_bit class. Now these methods are declared as virtual and specific implementations of the methods are provided for the class Field_bit. --- mysql-test/r/type_bit.result | 32 ++++++++++++++++++++++++++++++++ mysql-test/t/type_bit.test | 24 ++++++++++++++++++++++++ sql/field.h | 13 ++++++++++--- 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result index fad0e1f7974..324dcc2775b 100644 --- a/mysql-test/r/type_bit.result +++ b/mysql-test/r/type_bit.result @@ -618,4 +618,36 @@ bit_field int_field  2 handler t1 close; drop table t1; +CREATE TABLE t1 (b BIT(2)); +INSERT INTO t1 (b) VALUES (1), (3), (0), (3); +SELECT b+0, COUNT(DISTINCT b) FROM t1 GROUP BY b; +b+0 COUNT(DISTINCT b) +0 1 +1 1 +3 1 +DROP TABLE t1; +CREATE TABLE t1 (b BIT(2), a VARCHAR(5)); +INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z"); +SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b; +b+0 COUNT(DISTINCT a) +0 1 +1 1 +3 2 +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(5), b BIT(2)); +INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z"); +SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b; +b+0 COUNT(DISTINCT a) +0 1 +1 1 +3 2 +DROP TABLE t1; +CREATE TABLE t1 (a INT, b BIT(2)); +INSERT INTO t1 (b, a) VALUES (1, 1), (3, 2), (0, 3), (3, 4); +SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b; +b+0 COUNT(DISTINCT a) +0 1 +1 1 +3 2 +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index 48ad24ff6b7..2c7f87f342d 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -272,4 +272,28 @@ handler t1 read a=(1); handler t1 close; drop table t1; +# +# Bug #30219: GROUP BY a column of the BIT type +# + +CREATE TABLE t1 (b BIT(2)); +INSERT INTO t1 (b) VALUES (1), (3), (0), (3); +SELECT b+0, COUNT(DISTINCT b) FROM t1 GROUP BY b; +DROP TABLE t1; + +CREATE TABLE t1 (b BIT(2), a VARCHAR(5)); +INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z"); +SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b; +DROP TABLE t1; + +CREATE TABLE t1 (a CHAR(5), b BIT(2)); +INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z"); +SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b; +DROP TABLE t1; + +CREATE TABLE t1 (a INT, b BIT(2)); +INSERT INTO t1 (b, a) VALUES (1, 1), (3, 2), (0, 3), (3, 4); +SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b; +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/sql/field.h b/sql/field.h index fbf402ab5c3..92705b9aac4 100644 --- a/sql/field.h +++ b/sql/field.h @@ -231,9 +231,9 @@ public: if (null_ptr) null_ptr=ADD_TO_PTR(null_ptr,ptr_diff,uchar*); } - inline void get_image(char *buff,uint length, CHARSET_INFO *cs) + virtual void get_image(char *buff, uint length, CHARSET_INFO *cs) { memcpy(buff,ptr,length); } - inline void set_image(char *buff,uint length, CHARSET_INFO *cs) + virtual void set_image(char *buff,uint length, CHARSET_INFO *cs) { memcpy(ptr,buff,length); } @@ -1430,13 +1430,20 @@ public: String *val_str(String*, String *); my_decimal *val_decimal(my_decimal *); int cmp(const char *a, const char *b) - { return cmp_binary(a, b); } + { + DBUG_ASSERT(ptr == a); + return Field_bit::key_cmp(b, bytes_in_rec+test(bit_len)); + } int key_cmp(const byte *a, const byte *b) { return cmp_binary((char *) a, (char *) b); } int key_cmp(const byte *str, uint length); int cmp_offset(uint row_offset); int cmp_binary_offset(uint row_offset) { return cmp_offset(row_offset); } + void get_image(char *buff, uint length, CHARSET_INFO *cs) + { get_key_image(buff, length, itRAW); } + void set_image(char *buff,uint length, CHARSET_INFO *cs) + { Field_bit::store(buff, length, cs); } uint get_key_image(char *buff, uint length, imagetype type); void set_key_image(char *buff, uint length) { Field_bit::store(buff, length, &my_charset_bin); } From 88703939ad6dc32a802dbcec13af5ce37b474d0e Mon Sep 17 00:00:00 2001 From: "igor@olga.mysql.com" <> Date: Sun, 5 Aug 2007 17:12:57 -0700 Subject: [PATCH 6/8] Fixed compiler error for Windows in the patch for bug 30219. --- sql/field.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/field.h b/sql/field.h index 92705b9aac4..4fcdb50f8c7 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1432,7 +1432,7 @@ public: int cmp(const char *a, const char *b) { DBUG_ASSERT(ptr == a); - return Field_bit::key_cmp(b, bytes_in_rec+test(bit_len)); + return Field_bit::key_cmp((const byte *) b, bytes_in_rec+test(bit_len)); } int key_cmp(const byte *a, const byte *b) { return cmp_binary((char *) a, (char *) b); } From b8e85da37b2c7fdb8cdaeecc1c4848b7c2fe4174 Mon Sep 17 00:00:00 2001 From: "igor@olga.mysql.com" <> Date: Mon, 6 Aug 2007 01:01:22 -0700 Subject: [PATCH 7/8] Removed a query from the test case for bug 39219 that displayed in valgrind a problem for BIT type values different from the one reported for the bug. --- mysql-test/r/type_bit.result | 8 -------- mysql-test/t/type_bit.test | 5 ----- 2 files changed, 13 deletions(-) diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result index 324dcc2775b..7c765d6d50b 100644 --- a/mysql-test/r/type_bit.result +++ b/mysql-test/r/type_bit.result @@ -618,14 +618,6 @@ bit_field int_field  2 handler t1 close; drop table t1; -CREATE TABLE t1 (b BIT(2)); -INSERT INTO t1 (b) VALUES (1), (3), (0), (3); -SELECT b+0, COUNT(DISTINCT b) FROM t1 GROUP BY b; -b+0 COUNT(DISTINCT b) -0 1 -1 1 -3 1 -DROP TABLE t1; CREATE TABLE t1 (b BIT(2), a VARCHAR(5)); INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z"); SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b; diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index 2c7f87f342d..6423d017afb 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -276,11 +276,6 @@ drop table t1; # Bug #30219: GROUP BY a column of the BIT type # -CREATE TABLE t1 (b BIT(2)); -INSERT INTO t1 (b) VALUES (1), (3), (0), (3); -SELECT b+0, COUNT(DISTINCT b) FROM t1 GROUP BY b; -DROP TABLE t1; - CREATE TABLE t1 (b BIT(2), a VARCHAR(5)); INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z"); SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b; From 117c3ff9d7f52b2a84227412e0a88699754607b4 Mon Sep 17 00:00:00 2001 From: "gkodinov/kgeorge@magare.gmz" <> Date: Mon, 6 Aug 2007 04:57:28 -0700 Subject: [PATCH 8/8] Bug #29536: timestamp inconsistent in replication around 1970 MySQL replicates the time zone only when operations that involve it are performed. This is controlled by a flag. But this flag is set only on successful operation. The flag must be set also when there is an error that involves a timezone (so the master would replicate the error to the slaves). Fixed by moving the setting of the flag before the operation (so it apples to errors as well). --- mysql-test/r/rpl_timezone.result | 18 ++++++++++++++++++ mysql-test/t/rpl_timezone.test | 29 +++++++++++++++++++++++++++-- sql/field.cc | 6 +++--- sql/time.cc | 2 +- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/rpl_timezone.result b/mysql-test/r/rpl_timezone.result index 10dc8eb7e3c..7a18a26afd3 100644 --- a/mysql-test/r/rpl_timezone.result +++ b/mysql-test/r/rpl_timezone.result @@ -130,3 +130,21 @@ t 2005-01-01 08:00:00 drop table t1, t2; set global time_zone= @my_time_zone; +End of 4.1 tests +CREATE TABLE t1 (a INT, b TIMESTAMP); +INSERT INTO t1 VALUES (1, NOW()); +SET @@session.time_zone='Japan'; +UPDATE t1 SET b= '1970-01-01 08:59:59' WHERE a= 1; +Warnings: +Warning 1264 Out of range value adjusted for column 'b' at row 1 +SELECT * FROM t1 ORDER BY a; +a b +1 0000-00-00 00:00:00 +SET @@session.time_zone='Japan'; +SELECT * FROM t1 ORDER BY a; +a b +1 0000-00-00 00:00:00 +SET @@session.time_zone = default; +DROP TABLE t1; +SET @@session.time_zone = default; +End of 5.0 tests diff --git a/mysql-test/t/rpl_timezone.test b/mysql-test/t/rpl_timezone.test index 6ed5b21ace0..28ca250340e 100644 --- a/mysql-test/t/rpl_timezone.test +++ b/mysql-test/t/rpl_timezone.test @@ -126,8 +126,33 @@ connection master; drop table t1, t2; sync_slave_with_master; -# End of 4.1 tests - # Restore original timezone connection master; set global time_zone= @my_time_zone; + +--echo End of 4.1 tests + +# +# Bug #29536: timestamp inconsistent in replication around 1970 +# +connection master; + +CREATE TABLE t1 (a INT, b TIMESTAMP); +INSERT INTO t1 VALUES (1, NOW()); + +SET @@session.time_zone='Japan'; +UPDATE t1 SET b= '1970-01-01 08:59:59' WHERE a= 1; +SELECT * FROM t1 ORDER BY a; + +sync_slave_with_master; +SET @@session.time_zone='Japan'; +# must procdure the same result as the SELECT on the master +SELECT * FROM t1 ORDER BY a; + +SET @@session.time_zone = default; +connection master; +DROP TABLE t1; +SET @@session.time_zone = default; + + +--echo End of 5.0 tests diff --git a/sql/field.cc b/sql/field.cc index 3f74210807b..8191d885a27 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4462,6 +4462,7 @@ longlong Field_timestamp::val_int(void) MYSQL_TIME time_tmp; THD *thd= table ? table->in_use : current_thd; + thd->time_zone_used= 1; #ifdef WORDS_BIGENDIAN if (table && table->s->db_low_byte_first) temp=uint4korr(ptr); @@ -4473,7 +4474,6 @@ longlong Field_timestamp::val_int(void) return(0); /* purecov: inspected */ thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp, (my_time_t)temp); - thd->time_zone_used= 1; return time_tmp.year * LL(10000000000) + time_tmp.month * LL(100000000) + time_tmp.day * 1000000L + time_tmp.hour * 10000L + @@ -4492,6 +4492,7 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr) to= (char*) val_buffer->ptr(); val_buffer->length(field_length); + thd->time_zone_used= 1; #ifdef WORDS_BIGENDIAN if (table && table->s->db_low_byte_first) temp=uint4korr(ptr); @@ -4507,7 +4508,6 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr) val_buffer->set_charset(&my_charset_bin); // Safety thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp,(my_time_t)temp); - thd->time_zone_used= 1; temp= time_tmp.year % 100; if (temp < YY_PART_YEAR - 1) @@ -4557,6 +4557,7 @@ bool Field_timestamp::get_date(MYSQL_TIME *ltime, uint fuzzydate) { long temp; THD *thd= table ? table->in_use : current_thd; + thd->time_zone_used= 1; #ifdef WORDS_BIGENDIAN if (table && table->s->db_low_byte_first) temp=uint4korr(ptr); @@ -4572,7 +4573,6 @@ bool Field_timestamp::get_date(MYSQL_TIME *ltime, uint fuzzydate) else { thd->variables.time_zone->gmt_sec_to_TIME(ltime, (my_time_t)temp); - thd->time_zone_used= 1; } return 0; } diff --git a/sql/time.cc b/sql/time.cc index b4a8b047998..fb8a51fd0eb 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -228,11 +228,11 @@ my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *in_dst_time_ my_time_t timestamp; *in_dst_time_gap= 0; + thd->time_zone_used= 1; timestamp= thd->variables.time_zone->TIME_to_gmt_sec(t, in_dst_time_gap); if (timestamp) { - thd->time_zone_used= 1; return timestamp; }