diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/mysql_client_fw.c | 8 | ||||
-rw-r--r-- | tests/mysql_client_test.c | 139 |
3 files changed, 133 insertions, 16 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index dc775020954..f32e0270ce4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -35,4 +35,6 @@ MARK_AS_ADVANCED(EVENT_LIBRARY) IF(HAVE_EVENT_H AND EVENT_LIBRARY) ADD_EXECUTABLE(async_queries async_queries.c) TARGET_LINK_LIBRARIES(async_queries mysqlclient ${EVENT_LIBRARY}) + SET_TARGET_PROPERTIES(async_queries PROPERTIES LINKER_LANGUAGE CXX) + ENDIF() diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c index 90a1ea77a50..6dcfb697dbe 100644 --- a/tests/mysql_client_fw.c +++ b/tests/mysql_client_fw.c @@ -275,7 +275,9 @@ static my_bool check_have_innodb(MYSQL *conn) int rc; my_bool result; - rc= mysql_query(conn, "show variables like 'have_innodb'"); + rc= mysql_query(conn, + "SELECT (support = 'YES' or support = 'DEFAULT' or support = 'ENABLED') " + "AS `TRUE` FROM information_schema.engines WHERE engine = 'innodb'"); myquery(rc); res= mysql_use_result(conn); DIE_UNLESS(res); @@ -283,7 +285,7 @@ static my_bool check_have_innodb(MYSQL *conn) row= mysql_fetch_row(res); DIE_UNLESS(row); - result= strcmp(row[1], "YES") == 0; + result= strcmp(row[1], "1") == 0; mysql_free_result(res); return result; } @@ -583,7 +585,7 @@ static int my_process_stmt_result(MYSQL_STMT *stmt) return row_count; } - field_count= min(mysql_num_fields(result), MAX_RES_FIELDS); + field_count= MY_MIN(mysql_num_fields(result), MAX_RES_FIELDS); bzero((char*) buffer, sizeof(buffer)); bzero((char*) length, sizeof(length)); diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 446018e6906..7fd68fec308 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -1,5 +1,5 @@ /* Copyright (c) 2002, 2012, Oracle and/or its affiliates. - Copyright (c) 2008, 2012, Monty Program Ab + Copyright (c) 2008, 2013, Monty Program Ab This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -5976,6 +5976,10 @@ static void test_bind_date_conv(uint row_count) MYSQL_TIME tm[4]; ulong second_part; uint year, month, day, hour, minute, sec; + uint now_year= 1990, now_month= 3, now_day= 13; + + rc= mysql_query(mysql, "SET timestamp=UNIX_TIMESTAMP('1990-03-13')"); + myquery(rc); stmt= mysql_simple_prepare(mysql, "INSERT INTO test_date VALUES(?, ?, ?, ?)"); check_stmt(stmt); @@ -6076,9 +6080,15 @@ static void test_bind_date_conv(uint row_count) i, tm[i].year, tm[i].month, tm[i].day, tm[i].hour, tm[i].minute, tm[i].second, tm[i].second_part); - DIE_UNLESS(tm[i].year == 0 || tm[i].year == year+count); - DIE_UNLESS(tm[i].month == 0 || tm[i].month == month+count); - DIE_UNLESS(tm[i].day == 0 || tm[i].day == day+count); + DIE_UNLESS(tm[i].year == 0 || tm[i].year == year + count || + (tm[i].year == now_year && + my_bind[i].buffer_type == MYSQL_TYPE_TIME)); + DIE_UNLESS(tm[i].month == 0 || tm[i].month == month + count || + (tm[i].month == now_month && + my_bind[i].buffer_type == MYSQL_TYPE_TIME)); + DIE_UNLESS(tm[i].day == 0 || tm[i].day == day + count || + (tm[i].day == now_day && + my_bind[i].buffer_type == MYSQL_TYPE_TIME)); DIE_UNLESS(tm[i].hour == 0 || tm[i].hour == hour+count); DIE_UNLESS(tm[i].minute == 0 || tm[i].minute == minute+count); @@ -6930,7 +6940,7 @@ static void test_set_option() mysql_autocommit(mysql, TRUE); /* LIMIT the rows count to 2 */ - rc= mysql_query(mysql, "SET OPTION SQL_SELECT_LIMIT= 2"); + rc= mysql_query(mysql, "SET SQL_SELECT_LIMIT= 2"); myquery(rc); rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_limit"); @@ -6971,7 +6981,7 @@ static void test_set_option() /* RESET the LIMIT the rows count to 0 */ if (!opt_silent) fprintf(stdout, "\n with SQL_SELECT_LIMIT=DEFAULT (prepare)"); - rc= mysql_query(mysql, "SET OPTION SQL_SELECT_LIMIT=DEFAULT"); + rc= mysql_query(mysql, "SET SQL_SELECT_LIMIT=DEFAULT"); myquery(rc); stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_limit"); @@ -9864,11 +9874,11 @@ static void test_bug3035() const uint32 uint32_max= 4294967295U; /* it might not work okay everyplace */ - const longlong int64_max= LL(9223372036854775807); + const longlong int64_max= 9223372036854775807LL; const longlong int64_min= -int64_max - 1; const ulonglong uint64_min= 0U; - const ulonglong uint64_max= ULL(18446744073709551615); + const ulonglong uint64_max= 18446744073709551615ULL; const char *stmt_text; @@ -12535,7 +12545,7 @@ static void test_truncation() /* double -> longlong, negative fp number to signed integer: no loss */ DIE_UNLESS(my_bind++ < bind_array + bind_count); - DIE_UNLESS(! *my_bind->error && * (longlong*) my_bind->buffer == LL(-12345678910)); + DIE_UNLESS(! *my_bind->error && * (longlong*) my_bind->buffer == -12345678910LL); /* big numeric string -> number */ DIE_UNLESS(my_bind++ < bind_array + bind_count); @@ -14537,7 +14547,7 @@ static void test_bug12925() { myheader("test_bug12925"); if (opt_getopt_ll_test) - DIE_UNLESS(opt_getopt_ll_test == LL(25600*1024*1024)); + DIE_UNLESS(opt_getopt_ll_test == 25600LL*1024*1024); } @@ -17344,11 +17354,10 @@ static void test_wl4166_3() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); /* - Sic: only one warning, instead of two. The warning - about data truncation when assigning a parameter is lost. + The warning about data truncation when assigning a parameter is lost. This is a bug. */ - my_process_warnings(mysql, 1); + my_process_warnings(mysql, 0); verify_col_data("t1", "year", "0000-00-00 00:00:00"); @@ -18750,6 +18759,109 @@ static void test_bug12337762() DBUG_VOID_RETURN; } +/* + MDEV-4603: mysql_stmt_reset doesn't clear + all result sets (from stored procedures). + This test requires also fix for MDEV-4604 +*/ +static void test_mdev4603() +{ + MYSQL *my; + MYSQL_STMT *stmt; + int i, rc; + int a[] = {10,20,30}; + MYSQL_BIND bind[3]; + + myheader("test_mdev4603"); + my= mysql_client_init(NULL); + + if (!mysql_real_connect(my, opt_host, opt_user, + opt_password, current_db, opt_port, + opt_unix_socket, CLIENT_MULTI_RESULTS)) + DIE("mysql_real_connect failed"); + + /* 1st test: + use a procedure with out param + */ + rc= mysql_query(my, "DROP PROCEDURE IF EXISTS p1"); + myquery(rc); + + rc= mysql_query(mysql, "CREATE PROCEDURE p1(OUT p_out VARCHAR(19), IN p_in INT, INOUT p_inout INT)" + "BEGIN " + " SET p_in = 300, p_out := 'This is OUT param', p_inout = 200; " + " SELECT p_inout, p_in, substring(p_out, 9);" + "END"); + myquery(rc); + + stmt= mysql_stmt_init(mysql); + DIE_UNLESS(stmt != NULL); + + rc= mysql_stmt_prepare(stmt, "CALL P1(?,?,?)", 14); + DIE_UNLESS(rc == 0); + + DIE_UNLESS(mysql_stmt_param_count(stmt) == 3); + + memset(bind, 0, sizeof(MYSQL_BIND) * 3); + for (i=0; i < 3; i++) + { + bind[i].buffer= &a[i]; + bind[i].buffer_type= MYSQL_TYPE_LONG; + } + bind[0].buffer_type= MYSQL_TYPE_NULL; + rc= mysql_stmt_bind_param(stmt, bind); + DIE_UNLESS(rc == 0); + + rc= mysql_stmt_execute(stmt); + DIE_UNLESS(rc == 0); + + rc= mysql_stmt_fetch(stmt); + DIE_UNLESS(rc == 0); + + rc= mysql_stmt_reset(stmt); + DIE_UNLESS(rc == 0); + + /*connection shouldn't be blocked now */ + + rc= mysql_query(mysql, "DROP PROCEDURE p1"); + myquery(rc); + + /* 2nd test: + reset all result sets */ + rc= mysql_query(my, "CREATE PROCEDURE p1() " + "BEGIN" + " SELECT 1,2,3 FROM DUAL;" + " SELECT 'foo' FROM DUAL;" + "END"); + myquery(rc); + + rc= mysql_stmt_prepare(stmt, "CALL P1()", 9); + DIE_UNLESS(rc == 0); + + rc= mysql_stmt_execute(stmt); + DIE_UNLESS(rc == 0); + + rc= mysql_stmt_reset(stmt); + DIE_UNLESS(rc == 0); + + /* 3rd test: + mysql_stmt_close should also flush all pending + result sets + */ + + rc= mysql_stmt_prepare(stmt, "CALL P1()", 9); + DIE_UNLESS(rc == 0); + + rc= mysql_stmt_execute(stmt); + DIE_UNLESS(rc == 0); + + rc= mysql_stmt_close(stmt); + DIE_UNLESS(rc == 0); + + rc= mysql_query(my, "DROP PROCEDURE p1"); + myquery(rc); + + mysql_close(my); +} /* BUG 11754979 - 46675: ON DUPLICATE KEY UPDATE AND UPDATECOUNT() POSSIBLY WRONG @@ -19290,6 +19402,7 @@ static struct my_tests_st my_tests[]= { { "test_bug57058", test_bug57058 }, { "test_bug56976", test_bug56976 }, { "test_mdev3885", test_mdev3885 }, + { "test_mdev4603", test_mdev4603 }, { "test_bug11766854", test_bug11766854 }, { "test_bug12337762", test_bug12337762 }, { "test_progress_reporting", test_progress_reporting }, |