diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/mysql_client_fw.c | 12 | ||||
-rw-r--r-- | tests/mysql_client_test.c | 136 |
3 files changed, 134 insertions, 18 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 917ec458203..cb6c756cfe3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -22,7 +22,7 @@ INCLUDE_DIRECTORIES(BEFORE ${CMAKE_BINARY_DIR}/libmariadb/include ${CMAKE_SOURCE_DIR}/libmariadb/include) -ADD_EXECUTABLE(mysql_client_test mysql_client_test.c) +MYSQL_ADD_EXECUTABLE(mysql_client_test mysql_client_test.c COMPONENT Test) SET(CLIENT_LIB mariadbclient mysys) TARGET_LINK_LIBRARIES(mysql_client_test ${CLIENT_LIB}) @@ -34,8 +34,6 @@ IF(WITH_UNIT_TESTS) ADD_DEPENDENCIES(bug25714 GenError ${CLIENT_LIB}) ENDIF() -INSTALL(TARGETS mysql_client_test DESTINATION ${INSTALL_BINDIR} COMPONENT Test) - CHECK_INCLUDE_FILE(event.h HAVE_EVENT_H) FIND_LIBRARY(EVENT_LIBRARY event) MARK_AS_ADVANCED(EVENT_LIBRARY) diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c index b1b0cf21edc..8a6d38d9e30 100644 --- a/tests/mysql_client_fw.c +++ b/tests/mysql_client_fw.c @@ -50,9 +50,6 @@ static char *opt_user= 0; static char *opt_password= 0; static char *opt_host= 0; static char *opt_unix_socket= 0; -#ifdef HAVE_SMEM -static char *shared_memory_base_name= 0; -#endif static unsigned int opt_port; static my_bool tty_password= 0, opt_silent= 0; @@ -253,10 +250,6 @@ static void print_st_error(MYSQL_STMT *stmt, const char *msg) static MYSQL *mysql_client_init(MYSQL* con) { MYSQL* res = mysql_init(con); -#ifdef HAVE_SMEM - if (res && shared_memory_base_name) - mysql_options(res, MYSQL_SHARED_MEMORY_BASE_NAME, shared_memory_base_name); -#endif if (res && non_blocking_api_enabled) mysql_options(res, MYSQL_OPT_NONBLOCK, 0); if (opt_plugin_dir && *opt_plugin_dir) @@ -1229,11 +1222,6 @@ static struct my_option client_test_long_options[] = 0, 0, 0, 0, 0, 0}, {"silent", 's', "Be more silent", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, -#ifdef HAVE_SMEM - {"shared-memory-base-name", 'm', "Base name of shared memory.", - &shared_memory_base_name, (uchar**)&shared_memory_base_name, 0, - GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, -#endif {"socket", 'S', "Socket file to use for connection", &opt_unix_socket, &opt_unix_socket, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index edad6453102..1f0ad42f6ea 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -7612,8 +7612,8 @@ static void test_explain_bug() verify_prepare_field(result, 7, "ref", "", MYSQL_TYPE_VAR_STRING, "", "", "", NAME_CHAR_LEN * HA_MAX_KEY_SEG, 0); - verify_prepare_field(result, 8, "rows", "", MYSQL_TYPE_LONGLONG, - "", "", "", 10, 0); + verify_prepare_field(result, 8, "rows", "", MYSQL_TYPE_VAR_STRING, + "", "", "", NAME_CHAR_LEN, 0); verify_prepare_field(result, 9, "Extra", "", MYSQL_TYPE_VAR_STRING, "", "", "", 255, 0); @@ -8423,6 +8423,50 @@ static void test_list_information_schema_fields() } +static void test_list_fields_blob() +{ + MYSQL_RES *result; + int rc; + myheader("test_list_fields_blob"); + + rc= mysql_query(mysql, "drop table if exists t1"); + myquery(rc); + + rc= mysql_query(mysql, "create table t1(c1 tinyblob, c2 blob, c3 mediumblob, c4 longblob)"); + myquery(rc); + + result= mysql_list_fields(mysql, "t1", NULL); + mytest(result); + + rc= my_process_result_set(result); + DIE_UNLESS(rc == 0); + + /* + All BLOB variant Fields are displayed as MYSQL_TYPE_BLOB in + the result set metadata. Note, some Items display the exact + BLOB type. This inconsistency should be fixed eventually. + */ + verify_prepare_field(result, 0, "c1", "c1", MYSQL_TYPE_BLOB, + "t1", "t1", + current_db, 255, NULL); + + verify_prepare_field(result, 1, "c2", "c2", MYSQL_TYPE_BLOB, + "t1", "t1", + current_db, 65535, NULL); + + verify_prepare_field(result, 2, "c3", "c3", MYSQL_TYPE_BLOB, + "t1", "t1", + current_db, 16777215, NULL); + + verify_prepare_field(result, 3, "c4", "c4", MYSQL_TYPE_BLOB, + "t1", "t1", + current_db, 4294967295ULL, NULL); + + mysql_free_result(result); + myquery(mysql_query(mysql, "drop table t1")); +} + + static void test_list_fields_default() { int rc, i; @@ -8493,6 +8537,43 @@ static void test_list_fields_default() } +/** + Note, this test covers MDEV-18408 and MDEV-18685 +*/ + +static void test_mdev18408() +{ + MYSQL_RES *result; + int rc; + myheader("test_mdev18408s"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + myquery(rc); + + rc= mysql_query(mysql, "DROP VIEW IF EXISTS v1"); + myquery(rc); + + rc= mysql_query(mysql, "CREATE TABLE t1 (c1 TIMESTAMP NULL DEFAULT NULL)"); + myquery(rc); + + rc= mysql_query(mysql, "CREATE VIEW v1 AS SELECT c1 FROM t1"); + myquery(rc); + + result= mysql_list_fields(mysql, "v1", NULL); + mytest(result); + + rc= my_process_result_set(result); + DIE_UNLESS(rc == 0); + + verify_prepare_field(result, 0, "c1", "c1", MYSQL_TYPE_TIMESTAMP, + "v1", "v1", current_db, 19, 0); + + mysql_free_result(result); + myquery(mysql_query(mysql, "DROP VIEW v1")); + myquery(mysql_query(mysql, "DROP TABLE t1")); +} + + static void test_bug19671() { MYSQL_RES *result; @@ -8519,7 +8600,7 @@ static void test_bug19671() DIE_UNLESS(rc == 0); verify_prepare_field(result, 0, "f1", "f1", MYSQL_TYPE_LONG, - "v1", "v1", current_db, 11, "0"); + "v1", "v1", current_db, 11, NULL); mysql_free_result(result); myquery(mysql_query(mysql, "drop view v1")); @@ -20860,6 +20941,52 @@ static void test_explain_meta() } +/* + MDEV-20261 NULL passed to String::eq, SEGV, server crash, regression in 10.4 +*/ +static void test_mdev20261() +{ + int rc; + MYSQL_STMT *stmt; + MYSQL_BIND param[1]; + const char *query= "SELECT * FROM t1 WHERE f = ? OR f = 'foo'"; + char val[]= ""; + my_bool is_null= TRUE; + + myheader("test_mdev20261"); + + rc= mysql_query(mysql, "CREATE OR REPLACE TABLE t1 (f varchar(64)) ENGINE=MyISAM"); + myquery(rc); + + stmt= mysql_stmt_init(mysql); + check_stmt(stmt); + rc= mysql_stmt_prepare(stmt, query, strlen(query)); + check_execute(stmt, rc); + + verify_param_count(stmt, 1); + + bzero((char*) param, sizeof(param)); + + param[0].buffer= &val; + param[0].buffer_type= MYSQL_TYPE_STRING; + param[0].is_null= &is_null; + + rc= mysql_stmt_bind_param(stmt, param); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + rc= mysql_stmt_store_result(stmt); + check_execute(stmt, rc); + + mysql_stmt_close(stmt); + + rc= mysql_query(mysql, "DROP TABLE t1"); + myquery(rc); +} + + static struct my_tests_st my_tests[]= { { "disable_query_logs", disable_query_logs }, { "test_view_sp_list_fields", test_view_sp_list_fields }, @@ -20959,6 +21086,7 @@ static struct my_tests_st my_tests[]= { { "test_mem_overun", test_mem_overun }, { "test_list_fields", test_list_fields }, { "test_list_information_schema_fields", test_list_information_schema_fields }, + { "test_list_fields_blob", test_list_fields_blob }, { "test_list_fields_default", test_list_fields_default }, { "test_free_result", test_free_result }, { "test_free_store_result", test_free_store_result }, @@ -21152,6 +21280,8 @@ static struct my_tests_st my_tests[]= { #endif { "test_ps_params_in_ctes", test_ps_params_in_ctes }, { "test_explain_meta", test_explain_meta }, + { "test_mdev18408", test_mdev18408 }, + { "test_mdev20261", test_mdev20261 }, { 0, 0 } }; |