From 3f43953fcbf06a7ea04be35930e4922436568763 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Fri, 20 Apr 2018 07:19:40 +0200 Subject: [PATCH] Fixed test case for expired password Added test case for ODBC-138 --- unittest/libmariadb/connection.c | 8 +------ unittest/libmariadb/ps_bugs.c | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/unittest/libmariadb/connection.c b/unittest/libmariadb/connection.c index 8f1daa92..4fa22816 100644 --- a/unittest/libmariadb/connection.c +++ b/unittest/libmariadb/connection.c @@ -1340,21 +1340,15 @@ static int test_expired_pw(MYSQL *my) my_test_connect(mysql, hostname, "foo", "foo", schema, port, socketname, 0); - rc= mysql_query(mysql, "CREATE TEMPORARY TABLE t1 (a int)"); - diag("error: %d %s", mysql_errno(mysql), mysql_error(mysql)); FAIL_IF(mysql_errno(mysql) != ER_MUST_CHANGE_PASSWORD, "Error 1820 expected"); - rc= mysql_query(mysql, "SET PASSWORD=PASSWORD('foobar')"); - check_mysql_rc(rc, mysql); - rc= mysql_query(mysql, "CREATE TEMPORARY TABLE t1 (a int)"); - check_mysql_rc(rc, mysql); + mysql_close(mysql); sprintf(query, "DROP USER 'foo'@'%s'", this_host); rc= mysql_query(my, query); check_mysql_rc(rc, my); - mysql_close(mysql); return OK; } diff --git a/unittest/libmariadb/ps_bugs.c b/unittest/libmariadb/ps_bugs.c index c5cd53cd..5fa72b74 100644 --- a/unittest/libmariadb/ps_bugs.c +++ b/unittest/libmariadb/ps_bugs.c @@ -4651,8 +4651,48 @@ static int test_compress(MYSQL *mysql) return OK; } +static int test_codbc138(MYSQL *mysql) +{ + int rc; + MYSQL_STMT *stmt= mysql_stmt_init(mysql); + MYSQL_BIND bind[1]; + MYSQL_TIME tm; + + rc= mysql_stmt_prepare(stmt, SL("SELECT DATE_ADD('2018-02-01', INTERVAL -188 DAY)")); + check_stmt_rc(rc, stmt); + + rc= mysql_stmt_execute(stmt); + check_stmt_rc(rc, stmt); + + memset(bind, 0, sizeof(MYSQL_BIND)); + bind[0].buffer_type= MYSQL_TYPE_DATETIME; + bind[0].buffer= &tm; + bind[0].buffer_length= sizeof(MYSQL_TIME); + + rc= mysql_stmt_bind_result(stmt, bind); + check_stmt_rc(rc, stmt); + + rc= mysql_stmt_fetch(stmt); + check_stmt_rc(rc, stmt); + + if (tm.year != 2017 && tm.day != 28 && tm.month != 7) + { + diag("Error: Expected 2017-07-02"); + return FAIL; + } + if (tm.minute | tm.second || tm.second_part) + { + diag("Error: minute, second or second_part is not zero"); + return FAIL; + } + + mysql_stmt_close(stmt); + return OK; +} + struct my_tests_st my_tests[] = { {"test_compress", test_compress, TEST_CONNECTION_NEW, CLIENT_COMPRESS, NULL, NULL}, + {"test_codbc138", test_codbc138, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_conc208", test_conc208, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_mdev14165", test_mdev14165, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_conc208", test_conc208, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},