diff --git a/localtests/datetime-1970/create.sql b/localtests/datetime-1970/create.sql new file mode 100644 index 0000000..9fcf9ef --- /dev/null +++ b/localtests/datetime-1970/create.sql @@ -0,0 +1,23 @@ +drop table if exists gh_ost_test; +create table gh_ost_test ( + id int auto_increment, + create_time timestamp NULL DEFAULT '0000-00-00 00:00:00', + update_time timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + counter int(10) unsigned DEFAULT NULL, + primary key(id) +) auto_increment=1; + +insert into gh_ost_test values (1, '0000-00-00 00:00:00', now(), 0); + +drop event if exists gh_ost_test; +delimiter ;; +create event gh_ost_test + on schedule every 1 second + starts current_timestamp + ends current_timestamp + interval 60 second + on completion not preserve + enable + do +begin + update gh_ost_test set counter = counter + 1 where id = 1; +end ;; diff --git a/localtests/datetime-1970/extra_args b/localtests/datetime-1970/extra_args new file mode 100644 index 0000000..453f761 --- /dev/null +++ b/localtests/datetime-1970/extra_args @@ -0,0 +1 @@ +--alter='add column name varchar(1)' diff --git a/localtests/datetime-1970/ghost_columns b/localtests/datetime-1970/ghost_columns new file mode 100644 index 0000000..581038f --- /dev/null +++ b/localtests/datetime-1970/ghost_columns @@ -0,0 +1 @@ +id, create_time, update_time, counter diff --git a/localtests/datetime-1970/orig_columns b/localtests/datetime-1970/orig_columns new file mode 100644 index 0000000..581038f --- /dev/null +++ b/localtests/datetime-1970/orig_columns @@ -0,0 +1 @@ +id, create_time, update_time, counter diff --git a/localtests/datetime-1970/sql_mode b/localtests/datetime-1970/sql_mode new file mode 100644 index 0000000..e69de29 diff --git a/localtests/test.sh b/localtests/test.sh index 80bacaa..41c9822 100755 --- a/localtests/test.sh +++ b/localtests/test.sh @@ -87,6 +87,7 @@ start_replication() { test_single() { local test_name test_name="$1" + original_sql_mode="$(gh-ost-test-mysql-master -e "select @@global.sql_mode" -s -s)" if [ -f $tests_path/$test_name/ignore_versions ] ; then ignore_versions=$(cat $tests_path/$test_name/ignore_versions) @@ -102,6 +103,12 @@ test_single() { echo_dot start_replication echo_dot + + if [ -f $tests_path/$test_name/sql_mode ] ; then + gh-ost-test-mysql-master --default-character-set=utf8mb4 test -e "set @@global.sql_mode='$(cat $tests_path/$test_name/sql_mode)'" + gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "set @@global.sql_mode='$(cat $tests_path/$test_name/sql_mode)'" + fi + gh-ost-test-mysql-master --default-character-set=utf8mb4 test < $tests_path/$test_name/create.sql extra_args="" @@ -154,6 +161,11 @@ test_single() { execution_result=$? + if [ -f $tests_path/$test_name/sql_mode ] ; then + gh-ost-test-mysql-master --default-character-set=utf8mb4 test -e "set @@global.sql_mode='${original_sql_mode}'" + gh-ost-test-mysql-replica --default-character-set=utf8mb4 test -e "set @@global.sql_mode='${original_sql_mode}'" + fi + if [ -f $tests_path/$test_name/destroy.sql ] ; then gh-ost-test-mysql-master --default-character-set=utf8mb4 test < $tests_path/$test_name/destroy.sql fi diff --git a/vendor/github.com/siddontang/go-mysql/replication/row_event.go b/vendor/github.com/siddontang/go-mysql/replication/row_event.go index c30d9ae..85a3e43 100644 --- a/vendor/github.com/siddontang/go-mysql/replication/row_event.go +++ b/vendor/github.com/siddontang/go-mysql/replication/row_event.go @@ -400,6 +400,10 @@ func (e *RowsEvent) decodeValue(data []byte, tp byte, meta uint16) (v interface{ case MYSQL_TYPE_DATETIME: n = 8 i64 := binary.LittleEndian.Uint64(data) + + if i64 == 0 { // commented by Shlomi Noach. Yes I know about `git blame` + return "0000-00-00 00:00:00", n, nil + } d := i64 / 1000000 t := i64 % 1000000 v = time.Date(int(d/10000),