summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt22
-rw-r--r--tests/mysql_client_fw.c7
-rw-r--r--tests/mysql_client_test.c106
-rw-r--r--tests/nonblock-wrappers.h37
4 files changed, 93 insertions, 79 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index f32e0270ce4..8e9496ec0ae 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -15,16 +15,23 @@
ADD_DEFINITIONS("-DMYSQL_CLIENT")
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_SOURCE_DIR}/client)
+INCLUDE_DIRECTORIES(BEFORE
+ ${CMAKE_BINARY_DIR}/libmariadb/include
+ ${CMAKE_SOURCE_DIR}/libmariadb/include)
ADD_EXECUTABLE(mysql_client_test mysql_client_test.c)
-TARGET_LINK_LIBRARIES(mysql_client_test mysqlclient)
-SET_TARGET_PROPERTIES(mysql_client_test PROPERTIES LINKER_LANGUAGE CXX)
+SET(CLIENT_LIB mariadbclient mysys)
+
+TARGET_LINK_LIBRARIES(mysql_client_test ${CLIENT_LIB})
+ADD_DEPENDENCIES(mysql_client_test GenError ${CLIENT_LIB})
IF(WITH_UNIT_TESTS)
ADD_EXECUTABLE(bug25714 bug25714.c)
- TARGET_LINK_LIBRARIES(bug25714 mysqlclient)
- SET_TARGET_PROPERTIES(bug25714 PROPERTIES LINKER_LANGUAGE CXX)
+ TARGET_LINK_LIBRARIES(bug25714 ${CLIENT_LIB})
+ ADD_DEPENDENCIES(bug25714 GenError ${CLIENT_LIB})
ENDIF()
INSTALL(TARGETS mysql_client_test DESTINATION ${INSTALL_BINDIR} COMPONENT Test)
@@ -34,7 +41,6 @@ FIND_LIBRARY(EVENT_LIBRARY event)
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)
-
+ TARGET_LINK_LIBRARIES(async_queries ${CLIENT_LIB} ${EVENT_LIBRARY})
+ ADD_DEPENDENCIES(async_queries GenError ${CLIENT_LIB})
ENDIF()
diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c
index b7211989f1f..50ecf6c0860 100644
--- a/tests/mysql_client_fw.c
+++ b/tests/mysql_client_fw.c
@@ -21,6 +21,7 @@
#include <my_getopt.h>
#include <m_string.h>
#include <mysqld_error.h>
+#include <mysql_version.h>
#include <sql_common.h>
#include <mysql/client_plugin.h>
@@ -363,7 +364,7 @@ static MYSQL* client_connect(ulong flag, uint protocol, my_bool auto_reconnect)
fprintf(stdout, "\n Check the connection options using --help or -?\n");
exit(1);
}
- mysql->reconnect= auto_reconnect;
+ mysql_options(mysql, MYSQL_OPT_RECONNECT, &auto_reconnect);
if (!opt_silent)
fprintf(stdout, "OK");
@@ -1145,7 +1146,7 @@ static my_bool thread_query(const char *query)
{
MYSQL *l_mysql;
my_bool error;
-
+ my_bool reconnect= 1;
error= 0;
if (!opt_silent)
fprintf(stdout, "\n in thread_query(%s)", query);
@@ -1162,7 +1163,7 @@ static my_bool thread_query(const char *query)
error= 1;
goto end;
}
- l_mysql->reconnect= 1;
+ mysql_options(l_mysql, MYSQL_OPT_RECONNECT, &reconnect);
if (mysql_query(l_mysql, query))
{
fprintf(stderr, "Query failed (%s)\n", mysql_error(l_mysql));
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 0eb8aef95c4..469a6ec5103 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -34,8 +34,22 @@
#include "mysql_client_fw.c"
+static const my_bool my_true= 1;
+
+
/* Query processing */
+static my_bool get_reconnect(MYSQL *mysql)
+{
+#ifdef EMBEDDED_LIBRARY
+ return mysql->reconnect;
+#else
+ my_bool reconnect;
+ mysql_get_option(mysql, MYSQL_OPT_RECONNECT, &reconnect);
+ return reconnect;
+#endif
+}
+
static void client_query()
{
int rc;
@@ -447,7 +461,7 @@ static void test_prepare_simple()
strmov(query, "SHOW SLAVE STATUS");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
- DIE_UNLESS(mysql_stmt_field_count(stmt) == 47);
+ DIE_UNLESS(mysql_stmt_field_count(stmt) == 50);
mysql_stmt_close(stmt);
/* show master status */
@@ -3123,7 +3137,7 @@ static void test_long_data_str1()
int rc, i;
char data[255];
long length;
- ulong max_blob_length, blob_length, length1;
+ ulong max_blob_length, blob_length= 0, length1;
my_bool true_value;
MYSQL_RES *result;
MYSQL_BIND my_bind[2];
@@ -4812,7 +4826,7 @@ static void test_stmt_close()
myerror("connection failed");
exit(1);
}
- lmysql->reconnect= 1;
+ mysql_options(lmysql, MYSQL_OPT_RECONNECT, &my_true);
if (!opt_silent)
fprintf(stdout, "OK");
@@ -5496,7 +5510,7 @@ DROP TABLE IF EXISTS test_multi_tab";
fprintf(stdout, "\n connection failed(%s)", mysql_error(mysql_local));
exit(1);
}
- mysql_local->reconnect= 1;
+ mysql_options(mysql_local, MYSQL_OPT_RECONNECT, &my_true);
rc= mysql_query(mysql_local, query);
myquery(rc);
@@ -5620,7 +5634,7 @@ static void test_prepare_multi_statements()
fprintf(stderr, "\n connection failed(%s)", mysql_error(mysql_local));
exit(1);
}
- mysql_local->reconnect= 1;
+ mysql_options(mysql_local, MYSQL_OPT_RECONNECT, &my_true);
strmov(query, "select 1; select 'another value'");
stmt= mysql_simple_prepare(mysql_local, query);
check_stmt_r(stmt);
@@ -6338,10 +6352,10 @@ static void test_pure_coverage()
my_bind[0].buffer_type= MYSQL_TYPE_GEOMETRY;
rc= mysql_stmt_bind_result(stmt, my_bind);
- check_execute_r(stmt, rc); /* unsupported buffer type */
+ check_execute(stmt, rc); /* MariaDB C/C converts geometry to string */
rc= mysql_stmt_store_result(stmt);
- DIE_UNLESS(rc);
+ DIE_IF(rc);
rc= mysql_stmt_store_result(stmt);
DIE_UNLESS(rc); /* Old error must be reset first */
@@ -7225,7 +7239,7 @@ static void test_prepare_grant()
mysql_close(lmysql);
exit(1);
}
- lmysql->reconnect= 1;
+ mysql_options(lmysql, MYSQL_OPT_RECONNECT, &my_true);
if (!opt_silent)
fprintf(stdout, "OK");
@@ -7538,7 +7552,7 @@ static void test_explain_bug()
verify_prepare_field(result, 5, "Extra", "EXTRA",
mysql_get_server_version(mysql) <= 50000 ?
MYSQL_TYPE_STRING : MYSQL_TYPE_VAR_STRING,
- 0, 0, "information_schema", 27, 0);
+ 0, 0, "information_schema", 30, 0);
mysql_free_result(result);
mysql_stmt_close(stmt);
@@ -7687,7 +7701,7 @@ static void test_drop_temp()
mysql_close(lmysql);
exit(1);
}
- lmysql->reconnect= 1;
+ mysql_options(lmysql, MYSQL_OPT_RECONNECT, &my_true);
if (!opt_silent)
fprintf(stdout, "OK");
@@ -13402,10 +13416,7 @@ static void test_bug9478()
/* Fill in the fetch packet */
int4store(buff, stmt->stmt_id);
buff[4]= 1; /* prefetch rows */
- rc= ((*mysql->methods->advanced_command)(mysql, COM_STMT_FETCH,
- (uchar*) buff,
- sizeof(buff), 0,0,1,NULL) ||
- (*mysql->methods->read_query_result)(mysql));
+ rc= mysql_stmt_fetch(stmt);
DIE_UNLESS(rc);
if (!opt_silent && i == 0)
printf("Got error (as expected): %s\n", mysql_error(mysql));
@@ -14992,7 +15003,7 @@ static void test_bug15510()
static void test_opt_reconnect()
{
MYSQL *lmysql;
- my_bool my_true= TRUE;
+
myheader("test_opt_reconnect");
@@ -15003,8 +15014,8 @@ static void test_opt_reconnect()
}
if (!opt_silent)
- fprintf(stdout, "reconnect before mysql_options: %d\n", lmysql->reconnect);
- DIE_UNLESS(lmysql->reconnect == 0);
+ fprintf(stdout, "reconnect before mysql_options: %d\n", get_reconnect(lmysql));
+ DIE_UNLESS(get_reconnect(lmysql) == 0);
if (mysql_options(lmysql, MYSQL_OPT_RECONNECT, &my_true))
{
@@ -15014,8 +15025,8 @@ static void test_opt_reconnect()
/* reconnect should be 1 */
if (!opt_silent)
- fprintf(stdout, "reconnect after mysql_options: %d\n", lmysql->reconnect);
- DIE_UNLESS(lmysql->reconnect == 1);
+ fprintf(stdout, "reconnect after mysql_options: %d\n", get_reconnect(lmysql));
+ DIE_UNLESS(get_reconnect(lmysql) == 1);
if (!(mysql_real_connect(lmysql, opt_host, opt_user,
opt_password, current_db, opt_port,
@@ -15028,8 +15039,8 @@ static void test_opt_reconnect()
/* reconnect should still be 1 */
if (!opt_silent)
fprintf(stdout, "reconnect after mysql_real_connect: %d\n",
- lmysql->reconnect);
- DIE_UNLESS(lmysql->reconnect == 1);
+ get_reconnect(lmysql));
+ DIE_UNLESS(get_reconnect(lmysql) == 1);
mysql_close(lmysql);
@@ -15040,8 +15051,8 @@ static void test_opt_reconnect()
}
if (!opt_silent)
- fprintf(stdout, "reconnect before mysql_real_connect: %d\n", lmysql->reconnect);
- DIE_UNLESS(lmysql->reconnect == 0);
+ fprintf(stdout, "reconnect before mysql_real_connect: %d\n", get_reconnect(lmysql));
+ DIE_UNLESS(get_reconnect(lmysql) == 0);
if (!(mysql_real_connect(lmysql, opt_host, opt_user,
opt_password, current_db, opt_port,
@@ -15054,8 +15065,8 @@ static void test_opt_reconnect()
/* reconnect should still be 0 */
if (!opt_silent)
fprintf(stdout, "reconnect after mysql_real_connect: %d\n",
- lmysql->reconnect);
- DIE_UNLESS(lmysql->reconnect == 0);
+ get_reconnect(lmysql));
+ DIE_UNLESS(get_reconnect(lmysql) == 0);
mysql_close(lmysql);
}
@@ -15390,7 +15401,7 @@ static void test_mysql_insert_id()
myheader("test_mysql_insert_id");
- rc= mysql_query(mysql, "drop table if exists t1");
+ rc= mysql_query(mysql, "drop table if exists t1,t2");
myquery(rc);
/* table without auto_increment column */
rc= mysql_query(mysql, "create table t1 (f1 int, f2 varchar(255), key(f1))");
@@ -16232,7 +16243,6 @@ static void test_change_user()
const char *db= "mysqltest_user_test_database";
int rc;
MYSQL* conn;
-
DBUG_ENTER("test_change_user");
myheader("test_change_user");
@@ -16245,6 +16255,9 @@ static void test_change_user()
rc= mysql_query(mysql, buff);
myquery(rc);
+ rc= mysql_query(mysql, "SET SQL_MODE=''");
+ myquery(rc);
+
sprintf(buff,
"grant select on %s.* to %s@'%%' identified by '%s'",
db,
@@ -17486,7 +17499,6 @@ static void test_wl4166_2()
mysql_stmt_close(stmt);
rc= mysql_query(mysql, "drop table t1");
myquery(rc);
-
}
@@ -17987,7 +17999,8 @@ static void test_bug43560(void)
strncpy(buffer, values[2], BUFSIZE);
length= strlen(buffer);
rc= mysql_stmt_execute(stmt);
- DIE_UNLESS(rc && mysql_stmt_errno(stmt) == CR_SERVER_LOST);
+ DIE_UNLESS(rc && (mysql_stmt_errno(stmt) == CR_SERVER_LOST ||
+ mysql_stmt_errno(stmt) == CR_SERVER_GONE_ERROR));
opt_drop_db= 0;
client_disconnect(conn);
@@ -18753,8 +18766,11 @@ static void test_progress_reporting()
myheader("test_progress_reporting");
- conn= client_connect(CLIENT_PROGRESS, MYSQL_PROTOCOL_TCP, 0);
- DIE_UNLESS(conn->client_flag & CLIENT_PROGRESS);
+
+ conn= client_connect(CLIENT_PROGRESS_OBSOLETE, MYSQL_PROTOCOL_TCP, 0);
+ if (!(conn->server_capabilities & CLIENT_PROGRESS_OBSOLETE))
+ return;
+ DIE_UNLESS(conn->client_flag & CLIENT_PROGRESS_OBSOLETE);
mysql_options(conn, MYSQL_PROGRESS_CALLBACK, (void*) report_progress);
rc= mysql_query(conn, "set @save=@@global.progress_report_time");
@@ -19487,6 +19503,33 @@ static void test_big_packet()
}
+static void test_prepare_analyze()
+{
+ MYSQL_STMT *stmt;
+ const char *query= "ANALYZE SELECT 1";
+ int rc;
+ myheader("test_prepare_analyze");
+
+ stmt= mysql_stmt_init(mysql);
+ check_stmt(stmt);
+ rc= mysql_stmt_prepare(stmt, query, strlen(query));
+ check_execute(stmt, rc);
+
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+
+ rc= mysql_stmt_store_result(stmt);
+ check_execute(stmt, rc);
+
+ while (!(rc= mysql_stmt_fetch(stmt)))
+ ;
+
+ DIE_UNLESS(rc == MYSQL_NO_DATA);
+
+ rc= mysql_stmt_close(stmt);
+ check_execute(stmt, rc);
+}
+
static struct my_tests_st my_tests[]= {
{ "disable_query_logs", disable_query_logs },
{ "test_view_sp_list_fields", test_view_sp_list_fields },
@@ -19763,6 +19806,7 @@ static struct my_tests_st my_tests[]= {
#endif
{ "test_compressed_protocol", test_compressed_protocol },
{ "test_big_packet", test_big_packet },
+ { "test_prepare_analyze", test_prepare_analyze },
{ 0, 0 }
};
diff --git a/tests/nonblock-wrappers.h b/tests/nonblock-wrappers.h
index d6f42511f3a..78851854442 100644
--- a/tests/nonblock-wrappers.h
+++ b/tests/nonblock-wrappers.h
@@ -322,42 +322,6 @@ MK_WRAPPER(
mysql)
MK_WRAPPER(
- MYSQL_RES *,
- mysql_list_dbs,
- (MYSQL *mysql, const char *wild),
- (&res, mysql, wild),
- (mysql, wild),
- mysql,
- mysql)
-
-MK_WRAPPER(
- MYSQL_RES *,
- mysql_list_tables,
- (MYSQL *mysql, const char *wild),
- (&res, mysql, wild),
- (mysql, wild),
- mysql,
- mysql)
-
-MK_WRAPPER(
- MYSQL_RES *,
- mysql_list_processes,
- (MYSQL *mysql),
- (&res, mysql),
- (mysql),
- mysql,
- mysql)
-
-MK_WRAPPER(
- MYSQL_RES *,
- mysql_list_fields,
- (MYSQL *mysql, const char *table, const char *wild),
- (&res, mysql, table, wild),
- (mysql, table, wild),
- mysql,
- mysql)
-
-MK_WRAPPER(
my_bool,
mysql_read_query_result,
(MYSQL *mysql),
@@ -500,7 +464,6 @@ MK_WRAPPER(
#define mysql_list_dbs wrap_mysql_list_dbs
#define mysql_list_tables wrap_mysql_list_tables
#define mysql_list_processes wrap_mysql_list_processes
-#define mysql_list_fields wrap_mysql_list_fields
#define mysql_read_query_result wrap_mysql_read_query_result
#define mysql_stmt_prepare wrap_mysql_stmt_prepare
#define mysql_stmt_execute wrap_mysql_stmt_execute