#At file:///work/bzr/5.1-bugteam-37076/
2661 Gleb Shchepa 2008-06-09
Fixed bug #37076: TIMESTAMP/DATETIME/DATE values are not
replicated correctly between machines with
mixed endiannes
modified:
mysql-test/extra/rpl_tests/rpl_row_basic.test
mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result
mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result
mysql-test/suite/rpl_ndb/r/rpl_row_basic_7ndb.result
sql/field.h
per-file messages:
mysql-test/extra/rpl_tests/rpl_row_basic.test
Added regression test for bug#37076.
mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result
Added regression test for bug#37076.
mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result
Added regression test for bug#37076.
mysql-test/suite/rpl_ndb/r/rpl_row_basic_7ndb.result
Added regression test for bug#37076.
sql/field.h
Fixed bug #37076: TIMESTAMP/DATETIME/DATE values are not
replicated correctly between machines with
mixed endiannes
pack and unpack virtual methods have been reloaded for
Field_timestamp (TIMESTAMP domain), Field_datetime (DATETIME
domain) and Field_date (DATE domain) classes to replicate data
between platforms with different endiannes in a correct way
like in Field_long and Field_longlong classes.
Common code have been moved to private pack_int32, pack_int64,
unpack_int32 and unpack_int64 private methods.
=== modified file 'mysql-test/extra/rpl_tests/rpl_row_basic.test'
--- a/mysql-test/extra/rpl_tests/rpl_row_basic.test 2007-12-12 19:12:29 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_row_basic.test 2008-06-09 14:33:44 +0000
@@ -265,6 +265,22 @@ eval SELECT "$last_error" AS Last_SQL_Er
enable_query_log;
query_vertical SELECT COUNT(*) FROM t1 ORDER BY c1,c2;
+# BUG#37076: TIMESTAMP/DATETIME values are not replicated correctly
+# between machines with mixed endiannes
+# (regression test)
+
+--echo **** Test for BUG#37076 ****
+--echo **** On Master ****
+connection master;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a TIMESTAMP, b DATETIME, c DATE);
+INSERT INTO t1 VALUES(
+ '2005-11-14 01:01:01', '2005-11-14 01:01:02', '2005-11-14');
+
+--echo **** On Slave ****
+sync_slave_with_master slave;
+SELECT * FROM t1;
+
#
# cleanup
#
=== modified file 'mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result'
--- a/mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result 2007-12-12 19:12:29 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_basic_2myisam.result 2008-06-09 14:33:44 +0000
@@ -440,4 +440,14 @@ Last_SQL_Error
0
SELECT COUNT(*) FROM t1 ORDER BY c1,c2;
COUNT(*) 0
+**** Test for BUG#37076 ****
+**** On Master ****
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a TIMESTAMP, b DATETIME, c DATE);
+INSERT INTO t1 VALUES(
+'2005-11-14 01:01:01', '2005-11-14 01:01:02', '2005-11-14');
+**** On Slave ****
+SELECT * FROM t1;
+a b c
+2005-11-14 01:01:01 2005-11-14 01:01:02 2005-11-14
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8;
=== modified file 'mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result'
--- a/mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result 2007-12-12 19:12:29 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_basic_3innodb.result 2008-06-09 14:33:44 +0000
@@ -440,4 +440,14 @@ Last_SQL_Error
0
SELECT COUNT(*) FROM t1 ORDER BY c1,c2;
COUNT(*) 0
+**** Test for BUG#37076 ****
+**** On Master ****
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a TIMESTAMP, b DATETIME, c DATE);
+INSERT INTO t1 VALUES(
+'2005-11-14 01:01:01', '2005-11-14 01:01:02', '2005-11-14');
+**** On Slave ****
+SELECT * FROM t1;
+a b c
+2005-11-14 01:01:01 2005-11-14 01:01:02 2005-11-14
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8;
=== modified file 'mysql-test/suite/rpl_ndb/r/rpl_row_basic_7ndb.result'
--- a/mysql-test/suite/rpl_ndb/r/rpl_row_basic_7ndb.result 2007-12-19 17:51:46 +0000
+++ b/mysql-test/suite/rpl_ndb/r/rpl_row_basic_7ndb.result 2008-06-09 14:33:44 +0000
@@ -440,4 +440,14 @@ Last_SQL_Error
0
SELECT COUNT(*) FROM t1 ORDER BY c1,c2;
COUNT(*) 0
+**** Test for BUG#37076 ****
+**** On Master ****
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a TIMESTAMP, b DATETIME, c DATE);
+INSERT INTO t1 VALUES(
+'2005-11-14 01:01:01', '2005-11-14 01:01:02', '2005-11-14');
+**** On Slave ****
+SELECT * FROM t1;
+a b c
+2005-11-14 01:01:01 2005-11-14 01:01:02 2005-11-14
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8;
=== modified file 'sql/field.h'
--- a/sql/field.h 2008-05-13 12:01:02 +0000
+++ b/sql/field.h 2008-06-09 14:33:44 +0000
@@ -529,6 +529,87 @@ private:
*/
virtual int do_save_field_metadata(uchar *metadata_ptr)
{ return 0; }
+
+protected:
+ uchar *pack_int32(uchar *to, const uchar *from,
+ uint max_length, bool low_byte_first)
+ {
+ int32 val;
+#ifdef WORDS_BIGENDIAN
+ if (table->s->db_low_byte_first)
+ val = sint4korr(from);
+ else
+#endif
+ longget(val, from);
+
+#ifdef WORDS_BIGENDIAN
+ if (low_byte_first)
+ int4store(to, val);
+ else
+#endif
+ longstore(to, val);
+ return to + sizeof(val);
+ }
+
+ const uchar *unpack_int32(uchar* to, const uchar *from,
+ uint param_data, bool low_byte_first)
+ {
+ int32 val;
+#ifdef WORDS_BIGENDIAN
+ if (low_byte_first)
+ val = sint4korr(from);
+ else
+#endif
+ longget(val, from);
+
+#ifdef WORDS_BIGENDIAN
+ if (table->s->db_low_byte_first)
+ int4store(to, val);
+ else
+#endif
+ longstore(to, val);
+ return from + sizeof(val);
+ }
+
+ uchar *pack_int64(uchar* to, const uchar *from,
+ uint max_length, bool low_byte_first)
+ {
+ int64 val;
+#ifdef WORDS_BIGENDIAN
+ if (table->s->db_low_byte_first)
+ val = sint8korr(from);
+ else
+#endif
+ longlongget(val, from);
+
+#ifdef WORDS_BIGENDIAN
+ if (low_byte_first)
+ int8store(to, val);
+ else
+#endif
+ longlongstore(to, val);
+ return to + sizeof(val);
+ }
+
+ const uchar *unpack_int64(uchar* to, const uchar *from,
+ uint param_data, bool low_byte_first)
+ {
+ int64 val;
+#ifdef WORDS_BIGENDIAN
+ if (low_byte_first)
+ val = sint8korr(from);
+ else
+#endif
+ longlongget(val, from);
+
+#ifdef WORDS_BIGENDIAN
+ if (table->s->db_low_byte_first)
+ int8store(to, val);
+ else
+#endif
+ longlongstore(to, val);
+ return from + sizeof(val);
+ }
};
@@ -918,41 +999,12 @@ public:
virtual uchar *pack(uchar* to, const uchar *from,
uint max_length, bool low_byte_first)
{
- int32 val;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- val = sint4korr(from);
- else
-#endif
- longget(val, from);
-
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first)
- int4store(to, val);
- else
-#endif
- longstore(to, val);
- return to + sizeof(val);
+ return pack_int32(to, from, max_length, low_byte_first);
}
-
virtual const uchar *unpack(uchar* to, const uchar *from,
uint param_data, bool low_byte_first)
{
- int32 val;
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first)
- val = sint4korr(from);
- else
-#endif
- longget(val, from);
-
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- int4store(to, val);
- else
-#endif
- longstore(to, val);
- return from + sizeof(val);
+ return unpack_int32(to, from, param_data, low_byte_first);
}
};
@@ -999,41 +1051,12 @@ public:
virtual uchar *pack(uchar* to, const uchar *from,
uint max_length, bool low_byte_first)
{
- int64 val;
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- val = sint8korr(from);
- else
-#endif
- longlongget(val, from);
-
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first)
- int8store(to, val);
- else
-#endif
- longlongstore(to, val);
- return to + sizeof(val);
+ return pack_int64(to, from, max_length, low_byte_first);
}
-
virtual const uchar *unpack(uchar* to, const uchar *from,
uint param_data, bool low_byte_first)
{
- int64 val;
-#ifdef WORDS_BIGENDIAN
- if (low_byte_first)
- val = sint8korr(from);
- else
-#endif
- longlongget(val, from);
-
-#ifdef WORDS_BIGENDIAN
- if (table->s->db_low_byte_first)
- int8store(to, val);
- else
-#endif
- longlongstore(to, val);
- return from + sizeof(val);
+ return unpack_int64(to, from, param_data, low_byte_first);
}
};
#endif
@@ -1207,6 +1230,16 @@ public:
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
bool get_time(MYSQL_TIME *ltime);
timestamp_auto_set_type get_auto_set_type() const;
+ uchar *pack(uchar *to, const uchar *from,
+ uint max_length, bool low_byte_first)
+ {
+ return pack_int32(to, from, max_length, low_byte_first);
+ }
+ const uchar *unpack(uchar* to, const uchar *from,
+ uint param_data, bool low_byte_first)
+ {
+ return unpack_int32(to, from, param_data, low_byte_first);
+ }
};
@@ -1261,6 +1294,16 @@ public:
void sql_type(String &str) const;
bool can_be_compared_as_longlong() const { return TRUE; }
bool zero_pack() const { return 1; }
+ uchar *pack(uchar* to, const uchar *from,
+ uint max_length, bool low_byte_first)
+ {
+ return pack_int32(to, from, max_length, low_byte_first);
+ }
+ const uchar *unpack(uchar* to, const uchar *from,
+ uint param_data, bool low_byte_first)
+ {
+ return unpack_int32(to, from, param_data, low_byte_first);
+ }
};
@@ -1374,6 +1417,16 @@ public:
bool zero_pack() const { return 1; }
bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
bool get_time(MYSQL_TIME *ltime);
+ uchar *pack(uchar* to, const uchar *from,
+ uint max_length, bool low_byte_first)
+ {
+ return pack_int64(to, from, max_length, low_byte_first);
+ }
+ const uchar *unpack(uchar* to, const uchar *from,
+ uint param_data, bool low_byte_first)
+ {
+ return unpack_int64(to, from, param_data, low_byte_first);
+ }
};
| Thread |
|---|
| • bzr commit into mysql-5.1 branch (gshchepa:2661) Bug#37076 | Gleb Shchepa | 9 Jun |