Merge pull request #539 from github/incorrect-datetime-1970
Incorrect datetime 1970
This commit is contained in:
commit
d37ad9c8d4
23
localtests/datetime-1970/create.sql
Normal file
23
localtests/datetime-1970/create.sql
Normal file
@ -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 ;;
|
1
localtests/datetime-1970/extra_args
Normal file
1
localtests/datetime-1970/extra_args
Normal file
@ -0,0 +1 @@
|
||||
--alter='add column name varchar(1)'
|
1
localtests/datetime-1970/ghost_columns
Normal file
1
localtests/datetime-1970/ghost_columns
Normal file
@ -0,0 +1 @@
|
||||
id, create_time, update_time, counter
|
1
localtests/datetime-1970/orig_columns
Normal file
1
localtests/datetime-1970/orig_columns
Normal file
@ -0,0 +1 @@
|
||||
id, create_time, update_time, counter
|
0
localtests/datetime-1970/sql_mode
Normal file
0
localtests/datetime-1970/sql_mode
Normal file
@ -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
|
||||
|
4
vendor/github.com/siddontang/go-mysql/replication/row_event.go
generated
vendored
4
vendor/github.com/siddontang/go-mysql/replication/row_event.go
generated
vendored
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user