summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-02-19 11:37:29 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2018-02-19 11:37:29 +0200
commit2ba487cfe8bd95b90a537a5e9e54b5c1a5a35f37 (patch)
treed807814af6a0e1bb93b9f0060244220a0830dcc8 /tests
parentafc56a509cc7d3d651ca68ad826ca183da8dc7cc (diff)
parentef3147b1d64b298486fc6f77f9e84b28a9d1c5b3 (diff)
downloadmariadb-git-2ba487cfe8bd95b90a537a5e9e54b5c1a5a35f37.tar.gz
Merge bb-10.2-ext into 10.3
Diffstat (limited to 'tests')
-rw-r--r--tests/mysql_client_test.c114
1 files changed, 114 insertions, 0 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 46b0d86bf30..23dc458f97a 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -12409,6 +12409,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;
@@ -20269,6 +20382,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 },