Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
6668da22
Commit
6668da22
authored
Feb 16, 2018
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-15289 Binding an out-of-range DATETIME value in binary protocol breaks replication
parent
5ab46028
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
141 additions
and
1 deletion
+141
-1
mysql-test/suite/binlog/r/binlog_stm_datetime_ranges_mdev15289.result
...uite/binlog/r/binlog_stm_datetime_ranges_mdev15289.result
+19
-0
mysql-test/suite/binlog/t/binlog_stm_datetime_ranges_mdev15289.test
.../suite/binlog/t/binlog_stm_datetime_ranges_mdev15289.test
+7
-0
sql/item.cc
sql/item.cc
+1
-1
tests/mysql_client_test.c
tests/mysql_client_test.c
+114
-0
No files found.
mysql-test/suite/binlog/r/binlog_stm_datetime_ranges_mdev15289.result
0 → 100644
View file @
6668da22
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # CREATE DATABASE IF NOT EXISTS client_test_db
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `client_test_db`; create or replace table t1 (t time, d date, dt datetime,ts timestamp)
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `client_test_db`; INSERT INTO t1 VALUES (TIMESTAMP'0000-00-00 00:00:00', TIMESTAMP'0000-00-00 00:00:00', TIMESTAMP'0000-00-00 00:00:00', TIMESTAMP'0000-00-00 00:00:00')
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `client_test_db`; INSERT INTO t1 VALUES (DATE'0000-00-00', DATE'0000-00-00', DATE'0000-00-00', DATE'0000-00-00')
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # Query # # use `client_test_db`; INSERT INTO t1 VALUES (TIME'00:00:00', TIME'00:00:00', TIME'00:00:00', TIME'00:00:00')
master-bin.000001 # Query # # COMMIT
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # use `client_test_db`; DROP TABLE `t1` /* generated by server */
master-bin.000001 # Gtid # # GTID #-#-#
master-bin.000001 # Query # # DROP DATABASE IF EXISTS client_test_db
mysql-test/suite/binlog/t/binlog_stm_datetime_ranges_mdev15289.test
0 → 100644
View file @
6668da22
--
source
include
/
not_embedded
.
inc
--
source
include
/
have_binlog_format_statement
.
inc
--
exec
$MYSQL_CLIENT_TEST
test_datetime_ranges_mdev15289
>
$MYSQLTEST_VARDIR
/
log
/
binlog_stm_datetime_ranges_mysql_client_test
.
out
.
log
2
>&
1
--
let
$binlog_file
=
LAST
source
include
/
show_binlog_events
.
inc
;
sql/item.cc
View file @
6668da22
...
...
@@ -3562,7 +3562,7 @@ void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type,
ErrConvTime
str
(
&
value
.
time
);
make_truncated_value_warning
(
current_thd
,
Sql_condition
::
WARN_LEVEL_WARN
,
&
str
,
time_type
,
0
);
set_zero_time
(
&
value
.
time
,
MYSQL_TIMESTAMP_ERROR
);
set_zero_time
(
&
value
.
time
,
time_type
);
}
maybe_null
=
0
;
null_value
=
0
;
...
...
tests/mysql_client_test.c
View file @
6668da22
...
...
@@ -12333,6 +12333,119 @@ static void test_datetime_ranges()
}
/*
This test is used in:
mysql-test/suite/binlog/binlog_stm_datetime_ranges_mdev15289.test
*/
static
void
test_datetime_ranges_mdev15289
()
{
const
char
*
stmt_text
;
int
rc
,
i
;
MYSQL_STMT
*
stmt
;
MYSQL_BIND
my_bind
[
4
];
MYSQL_TIME
tm
[
4
];
myheader
(
"test_datetime_ranges_mdev15289"
);
stmt_text
=
"SET sql_mode=''"
;
rc
=
mysql_real_query
(
mysql
,
stmt_text
,
strlen
(
stmt_text
));
myquery
(
rc
);
stmt_text
=
"create or replace table t1 "
"(t time, d date, dt datetime,ts timestamp)"
;
rc
=
mysql_real_query
(
mysql
,
stmt_text
,
strlen
(
stmt_text
));
myquery
(
rc
);
stmt
=
mysql_simple_prepare
(
mysql
,
"INSERT INTO t1 VALUES (?, ?, ?, ?)"
);
check_stmt
(
stmt
);
verify_param_count
(
stmt
,
4
);
/*** Testing DATETIME ***/
bzero
((
char
*
)
my_bind
,
sizeof
(
my_bind
));
for
(
i
=
0
;
i
<
4
;
i
++
)
{
my_bind
[
i
].
buffer_type
=
MYSQL_TYPE_DATETIME
;
my_bind
[
i
].
buffer
=
&
tm
[
i
];
}
rc
=
mysql_stmt_bind_param
(
stmt
,
my_bind
);
check_execute
(
stmt
,
rc
);
/* Notice bad year */
tm
[
0
].
year
=
20010
;
tm
[
0
].
month
=
1
;
tm
[
0
].
day
=
2
;
tm
[
0
].
hour
=
03
;
tm
[
0
].
minute
=
04
;
tm
[
0
].
second
=
05
;
tm
[
0
].
second_part
=
0
;
tm
[
0
].
neg
=
0
;
tm
[
0
].
time_type
=
MYSQL_TIMESTAMP_DATETIME
;
tm
[
3
]
=
tm
[
2
]
=
tm
[
1
]
=
tm
[
0
];
rc
=
mysql_stmt_execute
(
stmt
);
check_execute
(
stmt
,
rc
);
my_process_warnings
(
mysql
,
4
);
verify_col_data
(
"t1"
,
"t"
,
"00:00:00"
);
verify_col_data
(
"t1"
,
"d"
,
"0000-00-00"
);
verify_col_data
(
"t1"
,
"dt"
,
"0000-00-00 00:00:00"
);
verify_col_data
(
"t1"
,
"ts"
,
"0000-00-00 00:00:00"
);
/*** Testing DATE ***/
bzero
((
char
*
)
my_bind
,
sizeof
(
my_bind
));
for
(
i
=
0
;
i
<
4
;
i
++
)
{
my_bind
[
i
].
buffer_type
=
MYSQL_TYPE_DATE
;
my_bind
[
i
].
buffer
=
&
tm
[
i
];
}
rc
=
mysql_stmt_bind_param
(
stmt
,
my_bind
);
check_execute
(
stmt
,
rc
);
/* Notice bad year */
tm
[
0
].
year
=
20010
;
tm
[
0
].
month
=
1
;
tm
[
0
].
day
=
2
;
tm
[
0
].
hour
=
00
;
tm
[
0
].
minute
=
00
;
tm
[
0
].
second
=
00
;
tm
[
0
].
second_part
=
0
;
tm
[
0
].
neg
=
0
;
tm
[
0
].
time_type
=
MYSQL_TIMESTAMP_DATE
;
tm
[
3
]
=
tm
[
2
]
=
tm
[
1
]
=
tm
[
0
];
rc
=
mysql_stmt_execute
(
stmt
);
check_execute
(
stmt
,
rc
);
my_process_warnings
(
mysql
,
4
);
verify_col_data
(
"t1"
,
"t"
,
"00:00:00"
);
verify_col_data
(
"t1"
,
"d"
,
"0000-00-00"
);
verify_col_data
(
"t1"
,
"dt"
,
"0000-00-00 00:00:00"
);
verify_col_data
(
"t1"
,
"ts"
,
"0000-00-00 00:00:00"
);
/*** Testing TIME ***/
bzero
((
char
*
)
my_bind
,
sizeof
(
my_bind
));
for
(
i
=
0
;
i
<
4
;
i
++
)
{
my_bind
[
i
].
buffer_type
=
MYSQL_TYPE_TIME
;
my_bind
[
i
].
buffer
=
&
tm
[
i
];
}
rc
=
mysql_stmt_bind_param
(
stmt
,
my_bind
);
check_execute
(
stmt
,
rc
);
/* Notice bad hour */
tm
[
0
].
year
=
0
;
tm
[
0
].
month
=
0
;
tm
[
0
].
day
=
0
;
tm
[
0
].
hour
=
100
;
tm
[
0
].
minute
=
64
;
tm
[
0
].
second
=
05
;
tm
[
0
].
second_part
=
0
;
tm
[
0
].
neg
=
0
;
tm
[
0
].
time_type
=
MYSQL_TIMESTAMP_TIME
;
tm
[
3
]
=
tm
[
2
]
=
tm
[
1
]
=
tm
[
0
];
rc
=
mysql_stmt_execute
(
stmt
);
check_execute
(
stmt
,
rc
);
my_process_warnings
(
mysql
,
4
);
verify_col_data
(
"t1"
,
"t"
,
"00:00:00"
);
verify_col_data
(
"t1"
,
"d"
,
"0000-00-00"
);
verify_col_data
(
"t1"
,
"dt"
,
"0000-00-00 00:00:00"
);
verify_col_data
(
"t1"
,
"ts"
,
"0000-00-00 00:00:00"
);
mysql_stmt_close
(
stmt
);
stmt_text
=
"drop table t1"
;
rc
=
mysql_real_query
(
mysql
,
stmt_text
,
strlen
(
stmt_text
));
myquery
(
rc
);
}
static
void
test_bug4172
()
{
MYSQL_STMT
*
stmt
;
...
...
@@ -19714,6 +19827,7 @@ static struct my_tests_st my_tests[]= {
{
"test_bug6081"
,
test_bug6081
},
{
"test_bug6096"
,
test_bug6096
},
{
"test_datetime_ranges"
,
test_datetime_ranges
},
{
"test_datetime_ranges_mdev15289"
,
test_datetime_ranges_mdev15289
},
{
"test_bug4172"
,
test_bug4172
},
{
"test_conversion"
,
test_conversion
},
{
"test_rewind"
,
test_rewind
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment