diff options
author | unknown <anozdrin/alik@quad.> | 2008-02-26 19:34:02 +0300 |
---|---|---|
committer | unknown <anozdrin/alik@quad.> | 2008-02-26 19:34:02 +0300 |
commit | 6f67007c9a1c14b14c03d3e8a73853736d2e5388 (patch) | |
tree | 4f6c2940e96b98c7499c2146e93e3ff920aed282 /tests | |
parent | a2ddb7cc781df02ab2a959f2749fefb67573c681 (diff) | |
parent | bb7585d335f85ad9eb9fbf661664e6e65ac67a82 (diff) | |
download | mariadb-git-6f67007c9a1c14b14c03d3e8a73853736d2e5388.tar.gz |
Merge quad.:/mnt/raid/alik/MySQL/devel/5.1
into quad.:/mnt/raid/alik/MySQL/devel/5.1-rt-merged
client/mysqltest.c:
Auto merged
mysql-test/r/view.result:
Auto merged
sql/ha_ndbcluster.cc:
Auto merged
sql/ha_ndbcluster_binlog.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/log_event.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/sql_class.cc:
Auto merged
sql/sql_connect.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
tests/mysql_client_test.c:
Auto merged
mysql-test/suite/rpl_ndb/t/disabled.def:
Manually merged.
mysql-test/t/disabled.def:
Manually merged.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mysql_client_test.c | 292 |
1 files changed, 237 insertions, 55 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 5b2af6550fd..188a051f874 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -289,6 +289,8 @@ static void client_connect(ulong flag) myerror("mysql_init() failed"); exit(1); } + /* enable local infile, in non-binary builds often disabled by default */ + mysql_options(mysql, MYSQL_OPT_LOCAL_INFILE, 0); if (!(mysql_real_connect(mysql, opt_host, opt_user, opt_password, opt_db ? opt_db:"test", opt_port, @@ -2421,7 +2423,7 @@ static uint query_cache_hits(MYSQL *conn) */ static void test_ps_query_cache() { - MYSQL *lmysql; + MYSQL *lmysql= mysql; MYSQL_STMT *stmt; int rc; MYSQL_BIND p_bind[2],r_bind[2]; /* p: param bind; r: result bind */ @@ -2456,7 +2458,6 @@ static void test_ps_query_cache() TEST_QCACHE_ON_OFF }; enum enum_test_ps_query_cache iteration; - LINT_INIT(lmysql); myheader("test_ps_query_cache"); @@ -2476,15 +2477,14 @@ static void test_ps_query_cache() for (iteration= TEST_QCACHE_ON; iteration <= TEST_QCACHE_ON_OFF; iteration++) { - switch (iteration) - { + switch (iteration) { case TEST_QCACHE_ON: case TEST_QCACHE_ON_OFF: - rc= mysql_query(mysql, "set global query_cache_size=1000000"); + rc= mysql_query(lmysql, "set global query_cache_size=1000000"); myquery(rc); break; case TEST_QCACHE_OFF_ON: - rc= mysql_query(mysql, "set global query_cache_size=0"); + rc= mysql_query(lmysql, "set global query_cache_size=0"); myquery(rc); break; case TEST_QCACHE_ON_WITH_OTHER_CONN: @@ -2492,37 +2492,35 @@ static void test_ps_query_cache() fprintf(stdout, "\n Establishing a test connection ..."); if (!(lmysql= mysql_init(NULL))) { - myerror("mysql_init() failed"); - exit(1); + printf("mysql_init() failed"); + DIE_UNLESS(0); } if (!(mysql_real_connect(lmysql, opt_host, opt_user, opt_password, current_db, opt_port, opt_unix_socket, 0))) { - myerror("connection failed"); + printf("connection failed"); mysql_close(lmysql); - exit(1); + DIE_UNLESS(0); } if (!opt_silent) fprintf(stdout, "OK"); - mysql= lmysql; } strmov(query, "select id1, value1 from t1 where id1= ? or " "CONVERT(value1 USING utf8)= ?"); - stmt= mysql_simple_prepare(mysql, query); + stmt= mysql_simple_prepare(lmysql, query); check_stmt(stmt); verify_param_count(stmt, 2); - switch(iteration) - { + switch (iteration) { case TEST_QCACHE_OFF_ON: - rc= mysql_query(mysql, "set global query_cache_size=1000000"); + rc= mysql_query(lmysql, "set global query_cache_size=1000000"); myquery(rc); break; case TEST_QCACHE_ON_OFF: - rc= mysql_query(mysql, "set global query_cache_size=0"); + rc= mysql_query(lmysql, "set global query_cache_size=0"); myquery(rc); default: break; @@ -2560,11 +2558,11 @@ static void test_ps_query_cache() test_ps_query_cache_result(1, "hh", 2, 2, "hh", 2, 1, "ii", 2); /* now retry with the same parameter values and see qcache hits */ - hits1= query_cache_hits(mysql); + hits1= query_cache_hits(lmysql); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); test_ps_query_cache_result(1, "hh", 2, 2, "hh", 2, 1, "ii", 2); - hits2= query_cache_hits(mysql); + hits2= query_cache_hits(lmysql); switch(iteration) { case TEST_QCACHE_ON_WITH_OTHER_CONN: case TEST_QCACHE_ON: /* should have hit */ @@ -2582,7 +2580,7 @@ static void test_ps_query_cache() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); test_ps_query_cache_result(1, "hh", 2, 1, "ii", 2, 2, "ii", 2); - hits1= query_cache_hits(mysql); + hits1= query_cache_hits(lmysql); switch(iteration) { case TEST_QCACHE_ON: @@ -2599,7 +2597,7 @@ static void test_ps_query_cache() check_execute(stmt, rc); test_ps_query_cache_result(1, "hh", 2, 1, "ii", 2, 2, "ii", 2); - hits2= query_cache_hits(mysql); + hits2= query_cache_hits(lmysql); mysql_stmt_close(stmt); @@ -2618,9 +2616,11 @@ static void test_ps_query_cache() } /* for(iteration=...) */ + if (lmysql != mysql) + mysql_close(lmysql); + rc= mysql_query(mysql, "set global query_cache_size=0"); myquery(rc); - } @@ -8971,8 +8971,8 @@ static void test_sqlmode() strmov(c1, "My"); strmov(c2, "SQL"); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - mysql_stmt_close(stmt); + verify_col_data("test_piping", "name", "MySQL"); rc= mysql_query(mysql, "DELETE FROM test_piping"); @@ -8983,6 +8983,7 @@ static void test_sqlmode() fprintf(stdout, "\n query: %s", query); stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); + mysql_stmt_close(stmt); /* ANSI */ strmov(query, "SET SQL_MODE= \"ANSI\""); @@ -13280,7 +13281,7 @@ from t2);"); static void test_bug8378() { #if defined(HAVE_CHARSET_gbk) && !defined(EMBEDDED_LIBRARY) - MYSQL *old_mysql=mysql; + MYSQL *lmysql; char out[9]; /* strlen(TEST_BUG8378)*2+1 */ char buf[256]; int len, rc; @@ -13289,17 +13290,17 @@ static void test_bug8378() if (!opt_silent) fprintf(stdout, "\n Establishing a test connection ..."); - if (!(mysql= mysql_init(NULL))) + if (!(lmysql= mysql_init(NULL))) { myerror("mysql_init() failed"); exit(1); } - if (mysql_options(mysql, MYSQL_SET_CHARSET_NAME, "gbk")) + if (mysql_options(lmysql, MYSQL_SET_CHARSET_NAME, "gbk")) { myerror("mysql_options() failed"); exit(1); } - if (!(mysql_real_connect(mysql, opt_host, opt_user, + if (!(mysql_real_connect(lmysql, opt_host, opt_user, opt_password, current_db, opt_port, opt_unix_socket, 0))) { @@ -13309,19 +13310,17 @@ static void test_bug8378() if (!opt_silent) fprintf(stdout, "OK"); - len= mysql_real_escape_string(mysql, out, TEST_BUG8378_IN, 4); + len= mysql_real_escape_string(lmysql, out, TEST_BUG8378_IN, 4); /* No escaping should have actually happened. */ DIE_UNLESS(memcmp(out, TEST_BUG8378_OUT, len) == 0); sprintf(buf, "SELECT '%s'", out); - rc=mysql_real_query(mysql, buf, strlen(buf)); + rc=mysql_real_query(lmysql, buf, strlen(buf)); myquery(rc); - mysql_close(mysql); - - mysql=old_mysql; + mysql_close(lmysql); #endif } @@ -15158,7 +15157,7 @@ static void test_opt_reconnect() if (mysql_options(lmysql, MYSQL_OPT_RECONNECT, &my_true)) { myerror("mysql_options failed: unknown option MYSQL_OPT_RECONNECT\n"); - exit(1); + DIE_UNLESS(0); } /* reconnect should be 1 */ @@ -15171,7 +15170,7 @@ static void test_opt_reconnect() opt_unix_socket, 0))) { myerror("connection failed"); - exit(1); + DIE_UNLESS(0); } /* reconnect should still be 1 */ @@ -15185,7 +15184,7 @@ static void test_opt_reconnect() if (!(lmysql= mysql_init(NULL))) { myerror("mysql_init() failed"); - exit(1); + DIE_UNLESS(0); } if (!opt_silent) @@ -15197,7 +15196,7 @@ static void test_opt_reconnect() opt_unix_socket, 0))) { myerror("connection failed"); - exit(1); + DIE_UNLESS(0); } /* reconnect should still be 0 */ @@ -15215,32 +15214,32 @@ static void test_opt_reconnect() static void test_bug12744() { MYSQL_STMT *prep_stmt = NULL; + MYSQL *lmysql; int rc; myheader("test_bug12744"); - prep_stmt= mysql_stmt_init(mysql); - rc= mysql_stmt_prepare(prep_stmt, "SELECT 1", 8); - DIE_UNLESS(rc==0); - - mysql_close(mysql); + lmysql= mysql_init(NULL); + DIE_UNLESS(lmysql); - if ((rc= mysql_stmt_execute(prep_stmt))) + if (!mysql_real_connect(lmysql, opt_host, opt_user, opt_password, + current_db, opt_port, opt_unix_socket, 0)) { - if ((rc= mysql_stmt_reset(prep_stmt))) - printf("OK!\n"); - else - { - printf("Error!"); - DIE_UNLESS(1==0); - } - } - else - { - fprintf(stderr, "expected error but no error occured\n"); - DIE_UNLESS(1==0); + fprintf(stderr, "Failed to connect to the database\n"); + DIE_UNLESS(0); } + + prep_stmt= mysql_stmt_init(lmysql); + rc= mysql_stmt_prepare(prep_stmt, "SELECT 1", 8); + DIE_UNLESS(rc == 0); + + mysql_close(lmysql); + + rc= mysql_stmt_execute(prep_stmt); + DIE_UNLESS(rc); + rc= mysql_stmt_reset(prep_stmt); + DIE_UNLESS(rc); rc= mysql_stmt_close(prep_stmt); - client_connect(0); + DIE_UNLESS(rc == 0); } #endif /* EMBEDDED_LIBRARY */ @@ -16104,11 +16103,104 @@ static void test_bug24179() mysql_stmt_error(stmt)); } DIE_UNLESS(mysql_stmt_errno(stmt) == 1323); + mysql_stmt_close(stmt); DBUG_VOID_RETURN; } +/** + Bug#32265 Server returns different metadata if prepared statement is used +*/ + +static void test_bug32265() +{ + int rc; + MYSQL_STMT *stmt; + MYSQL_FIELD *field; + MYSQL_RES *metadata; + + DBUG_ENTER("test_bug32265"); + myheader("test_bug32265"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + myquery(rc); + rc= mysql_query(mysql, "CREATE TABLE t1 (a INTEGER)"); + myquery(rc); + rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1)"); + myquery(rc); + rc= mysql_query(mysql, "CREATE VIEW v1 AS SELECT * FROM t1"); + myquery(rc); + + stmt= open_cursor("SELECT * FROM t1"); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + metadata= mysql_stmt_result_metadata(stmt); + field= mysql_fetch_field(metadata); + DIE_UNLESS(field); + DIE_UNLESS(strcmp(field->table, "t1") == 0); + DIE_UNLESS(strcmp(field->org_table, "t1") == 0); + DIE_UNLESS(strcmp(field->db, "client_test_db") == 0); + mysql_free_result(metadata); + mysql_stmt_close(stmt); + + stmt= open_cursor("SELECT a '' FROM t1 ``"); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + metadata= mysql_stmt_result_metadata(stmt); + field= mysql_fetch_field(metadata); + DIE_UNLESS(strcmp(field->table, "") == 0); + DIE_UNLESS(strcmp(field->org_table, "t1") == 0); + DIE_UNLESS(strcmp(field->db, "client_test_db") == 0); + mysql_free_result(metadata); + mysql_stmt_close(stmt); + + stmt= open_cursor("SELECT a '' FROM t1 ``"); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + metadata= mysql_stmt_result_metadata(stmt); + field= mysql_fetch_field(metadata); + DIE_UNLESS(strcmp(field->table, "") == 0); + DIE_UNLESS(strcmp(field->org_table, "t1") == 0); + DIE_UNLESS(strcmp(field->db, "client_test_db") == 0); + mysql_free_result(metadata); + mysql_stmt_close(stmt); + + stmt= open_cursor("SELECT * FROM v1"); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + metadata= mysql_stmt_result_metadata(stmt); + field= mysql_fetch_field(metadata); + DIE_UNLESS(strcmp(field->table, "v1") == 0); + DIE_UNLESS(strcmp(field->org_table, "t1") == 0); + DIE_UNLESS(strcmp(field->db, "client_test_db") == 0); + mysql_free_result(metadata); + mysql_stmt_close(stmt); + + stmt= open_cursor("SELECT * FROM v1 /* SIC */ GROUP BY 1"); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + metadata= mysql_stmt_result_metadata(stmt); + field= mysql_fetch_field(metadata); + DIE_UNLESS(strcmp(field->table, "v1") == 0); + DIE_UNLESS(strcmp(field->org_table, "t1") == 0); + DIE_UNLESS(strcmp(field->db, "client_test_db") == 0); + mysql_free_result(metadata); + mysql_stmt_close(stmt); + + rc= mysql_query(mysql, "DROP VIEW v1"); + myquery(rc); + rc= mysql_query(mysql, "DROP TABLE t1"); + myquery(rc); + + DBUG_VOID_RETURN; +} + /* Bug#28075 "COM_DEBUG crashes mysqld" */ @@ -16168,6 +16260,7 @@ static void test_bug27876() myquery(rc); result= mysql_store_result(mysql); mytest(result); + mysql_free_result(result); sprintf(query, "DROP FUNCTION IF EXISTS %s", (char*) utf8_func); rc= mysql_query(mysql, query); @@ -16184,6 +16277,7 @@ static void test_bug27876() myquery(rc); result= mysql_store_result(mysql); mytest(result); + mysql_free_result(result); sprintf(query, "DROP FUNCTION %s", (char*) utf8_func); rc= mysql_query(mysql, query); @@ -16821,7 +16915,7 @@ static void test_bug30472() /* Change connection-default character set in the client. */ - con.options.charset_name= my_strdup("utf8", MYF(MY_FAE)); + mysql_options(&con, MYSQL_SET_CHARSET_NAME, "utf8"); /* Call mysql_change_user() in order to check that new connection will @@ -17231,6 +17325,92 @@ static void test_bug31669() DBUG_VOID_RETURN; } + +/** + Bug#28386 the general log is incomplete +*/ + +static void test_bug28386() +{ + int rc; + MYSQL_STMT *stmt; + MYSQL_RES *result; + MYSQL_ROW row; + MYSQL_BIND bind; + const char hello[]= "hello world!"; + + DBUG_ENTER("test_bug28386"); + myheader("test_bug28386"); + + rc= mysql_query(mysql, "select @@global.log_output"); + myquery(rc); + + result= mysql_store_result(mysql); + DIE_UNLESS(result); + + row= mysql_fetch_row(result); + if (! strstr(row[0], "TABLE")) + { + mysql_free_result(result); + if (! opt_silent) + printf("Skipping the test since logging to tables is not enabled\n"); + /* Log output is not to tables */ + return; + } + mysql_free_result(result); + + rc= mysql_query(mysql, "set @save_global_general_log=@@global.general_log"); + myquery(rc); + + rc= mysql_query(mysql, "set @@global.general_log=on"); + myquery(rc); + + rc= mysql_query(mysql, "truncate mysql.general_log"); + myquery(rc); + + stmt= mysql_simple_prepare(mysql, "SELECT ?"); + check_stmt(stmt); + + memset(&bind, 0, sizeof(bind)); + + bind.buffer_type= MYSQL_TYPE_STRING; + bind.buffer= (void *) hello; + bind.buffer_length= sizeof(hello); + + mysql_stmt_bind_param(stmt, &bind); + mysql_stmt_send_long_data(stmt, 0, hello, sizeof(hello)); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + rc= my_process_stmt_result(stmt); + DIE_UNLESS(rc == 1); + + rc= mysql_stmt_reset(stmt); + check_execute(stmt, rc); + + rc= mysql_stmt_close(stmt); + DIE_UNLESS(!rc); + + rc= mysql_query(mysql, "select * from mysql.general_log where " + "command_type='Close stmt' or " + "command_type='Reset stmt' or " + "command_type='Long Data'"); + myquery(rc); + + result= mysql_store_result(mysql); + mytest(result); + + DIE_UNLESS(mysql_num_rows(result) == 3); + + mysql_free_result(result); + + rc= mysql_query(mysql, "set @@global.general_log=@save_global_general_log"); + myquery(rc); + + DBUG_VOID_RETURN; +} + /* Read and parse arguments and MySQL options from my.cnf */ @@ -17517,6 +17697,7 @@ static struct my_tests_st my_tests[]= { { "test_bug21726", test_bug21726 }, { "test_bug15518", test_bug15518 }, { "test_bug23383", test_bug23383 }, + { "test_bug32265", test_bug32265 }, { "test_bug21635", test_bug21635 }, { "test_status", test_status }, { "test_bug24179", test_bug24179 }, @@ -17535,6 +17716,7 @@ static struct my_tests_st my_tests[]= { { "test_bug20023", test_bug20023 }, { "test_bug31418", test_bug31418 }, { "test_bug31669", test_bug31669 }, + { "test_bug28386", test_bug28386 }, { 0, 0 } }; |