#include <my_global.h>#include <my_sys.h>#include <mysql.h>#include <errmsg.h>#include <my_getopt.h>#include <m_string.h>Include dependency graph for mysql_client_test.c:

Go to the source code of this file.
Classes | |
| struct | my_tests_st |
| struct | st_stmt_fetch |
Defines | |
| #define | VER "2.1" |
| #define | MAX_TEST_QUERY_LENGTH 300 |
| #define | MAX_KEY MAX_INDEXES |
| #define | MAX_SERVER_ARGS 64 |
| #define | myheader(str) |
| #define | myheader_r(str) |
| #define | DIE_UNLESS(expr) ((void) ((expr) ? 0 : (die(__FILE__, __LINE__, #expr), 0))) |
| #define | DIE(expr) die(__FILE__, __LINE__, #expr) |
| #define | myerror(msg) print_error(msg) |
| #define | mysterror(stmt, msg) print_st_error(stmt, msg) |
| #define | myquery(RES) |
| #define | myquery_r(r) |
| #define | check_execute(stmt, r) |
| #define | check_execute_r(stmt, r) |
| #define | check_stmt(stmt) |
| #define | check_stmt_r(stmt) |
| #define | mytest(x) if (!x) {myerror(NULL);DIE_UNLESS(FALSE);} |
| #define | mytest_r(x) if (x) {myerror(NULL);DIE_UNLESS(FALSE);} |
| #define | MAX_RES_FIELDS 50 |
| #define | MAX_FIELD_DATA_SIZE 255 |
| #define | verify_prepare_field(result, no, name, org_name, type, table, org_table, db, length, def) |
| #define | NUM_OF_USED_STMT 97 |
| #define | TEST_BUG8378_IN "\xef\xbb\xbf\x27\xbf\x10" |
| #define | TEST_BUG8378_OUT "\xef\xbb\x5c\xbf\x5c\x27\x5c\xbf\x10" |
Typedefs | |
| typedef st_stmt_fetch | Stmt_fetch |
Enumerations | |
| enum | { MAX_COLUMN_LENGTH = 255 } |
| enum | fetch_type { USE_ROW_BY_ROW_FETCH = 0, USE_STORE_RESULT = 1 } |
Functions | |
| static void | print_error (const char *msg) |
| static void | print_st_error (MYSQL_STMT *stmt, const char *msg) |
| static void | client_disconnect () |
| void | die (const char *file, int line, const char *expr) |
| static int | cmp_double (double *a, double *b) |
| static my_bool | check_have_innodb (MYSQL *conn) |
| MYSQL_STMT *STDCALL | mysql_simple_prepare (MYSQL *mysql, const char *query) |
| static void | client_connect (ulong flag) |
| static void | client_query () |
| static void | my_print_dashes (MYSQL_RES *result) |
| static void | my_print_result_metadata (MYSQL_RES *result) |
| int | my_process_result_set (MYSQL_RES *result) |
| int | my_process_result (MYSQL *mysql) |
| int | my_process_stmt_result (MYSQL_STMT *stmt) |
| int | my_stmt_result (const char *buff) |
| static void | verify_col_data (const char *table, const char *col, const char *exp_data) |
| static void | do_verify_prepare_field (MYSQL_RES *result, unsigned int no, const char *name, const char *org_name, enum enum_field_types type, const char *table, const char *org_table, const char *db, unsigned long length, const char *def, const char *file, int line) |
| static void | verify_param_count (MYSQL_STMT *stmt, long exp_count) |
| static void | verify_st_affected_rows (MYSQL_STMT *stmt, ulonglong exp_count) |
| static void | verify_affected_rows (ulonglong exp_count) |
| static void | verify_field_count (MYSQL_RES *result, uint exp_count) |
| static void | execute_prepare_query (const char *query, ulonglong exp_count) |
| static void | client_store_result () |
| static void | client_use_result () |
| void | fill_tables (const char **query_list, unsigned query_count) |
| void | stmt_fetch_init (Stmt_fetch *fetch, unsigned stmt_no_arg, const char *query_arg) |
| int | stmt_fetch_fetch_row (Stmt_fetch *fetch) |
| void | stmt_fetch_close (Stmt_fetch *fetch) |
| my_bool | fetch_n (const char **query_list, unsigned query_count, enum fetch_type fetch_type) |
| static my_bool | thread_query (char *query) |
| static void | test_debug_example () |
| static void | test_tran_bdb () |
| static void | test_tran_innodb () |
| static void | test_prepare_insert_update () |
| static void | test_prepare_simple () |
| static void | test_prepare_field_result () |
| static void | test_prepare_syntax () |
| static void | test_prepare () |
| static void | test_double_compare () |
| static void | test_null () |
| static void | test_ps_null_param () |
| static void | test_fetch_null () |
| static void | test_select_version () |
| static void | test_select_show_table () |
| static void | test_select_direct () |
| static void | test_select_prepare () |
| static void | test_select () |
| static void | test_ps_conj_select () |
| static void | test_bug1115 () |
| static void | test_bug1180 () |
| static void | test_bug1644 () |
| static void | test_select_show () |
| static void | test_simple_update () |
| static void | test_long_data () |
| static void | test_long_data_str () |
| static void | test_long_data_str1 () |
| static void | test_long_data_bin () |
| static void | test_simple_delete () |
| static void | test_update () |
| static void | test_prepare_noparam () |
| static void | test_bind_result () |
| static void | test_bind_result_ext () |
| static void | test_bind_result_ext1 () |
| static void | bind_fetch (int row_count) |
| static void | test_fetch_date () |
| static void | test_fetch_str () |
| static void | test_fetch_long () |
| static void | test_fetch_short () |
| static void | test_fetch_tiny () |
| static void | test_fetch_bigint () |
| static void | test_fetch_float () |
| static void | test_fetch_double () |
| static void | test_prepare_ext () |
| static void | test_field_names () |
| static void | test_warnings () |
| static void | test_errors () |
| static void | test_insert () |
| static void | test_prepare_resultset () |
| static void | test_field_flags () |
| static void | test_stmt_close () |
| static void | test_set_variable () |
| static void | test_func_fields () |
| static void | test_multi_stmt () |
| static void | test_manual_sample () |
| static void | test_prepare_alter () |
| static void | test_multi_statements () |
| static void | test_prepare_multi_statements () |
| static void | test_store_result () |
| static void | test_store_result1 () |
| static void | test_store_result2 () |
| static void | test_subselect () |
| static void | test_bind_date_conv (uint row_count) |
| static void | test_date () |
| static void | test_date_date () |
| static void | test_date_time () |
| static void | test_date_ts () |
| static void | test_date_dt () |
| static void | test_pure_coverage () |
| static void | test_buffers () |
| static void | test_open_direct () |
| static void | test_fetch_nobuffs () |
| static void | test_ushort_bug () |
| static void | test_sshort_bug () |
| static void | test_stiny_bug () |
| static void | test_field_misc () |
| static void | test_set_option () |
| static void | test_prepare_grant () |
| static void | test_frm_bug () |
| static void | test_decimal_bug () |
| static void | test_explain_bug () |
| static void | test_cuted_rows () |
| static void | test_logs () |
| static void | test_nstmts () |
| static void | test_fetch_seek () |
| static void | test_fetch_offset () |
| static void | test_fetch_column () |
| static void | test_list_fields () |
| static void | test_bug19671 () |
| static void | test_mem_overun () |
| static void | test_free_result () |
| static void | test_free_store_result () |
| static void | test_sqlmode () |
| static void | test_ts () |
| static void | test_bug1500 () |
| static void | test_bug1946 () |
| static void | test_parse_error_and_bad_length () |
| static void | test_bug2247 () |
| static void | test_subqueries () |
| static void | test_bad_union () |
| static void | test_distinct () |
| static void | test_bug2248 () |
| static void | test_subqueries_ref () |
| static void | test_union () |
| static void | test_bug3117 () |
| static void | test_join () |
| static void | test_selecttmp () |
| static void | test_create_drop () |
| static void | test_rename () |
| static void | test_do_set () |
| static void | test_multi () |
| static void | test_insert_select () |
| static void | test_bind_nagative () |
| static void | test_derived () |
| static void | test_xjoin () |
| static void | test_bug3035 () |
| static void | test_union2 () |
| static void | test_bug1664 () |
| static void | test_order_param () |
| static void | test_union_param () |
| static void | test_ps_i18n () |
| static void | test_bug3796 () |
| static void | test_bug4026 () |
| static void | test_bug4079 () |
| static void | test_bug4236 () |
| static void | test_bug4030 () |
| static void | test_view () |
| static void | test_view_where () |
| static void | test_view_2where () |
| static void | test_view_star () |
| static void | test_view_insert () |
| static void | test_left_join_view () |
| static void | test_view_insert_fields () |
| static void | test_bug5126 () |
| static void | test_bug4231 () |
| static void | test_bug5399 () |
| static void | test_bug5194 () |
| static void | test_bug5315 () |
| static void | test_bug6049 () |
| static void | test_bug6058 () |
| static void | test_bug6059 () |
| static void | test_bug6046 () |
| static void | test_basic_cursors () |
| static void | test_cursors_with_union () |
| static void | test_bug6081 () |
| static void | test_bug6096 () |
| static void | test_datetime_ranges () |
| static void | test_bug4172 () |
| static void | test_conversion () |
| static void | test_rewind (void) |
| static void | test_truncation () |
| static void | test_truncation_option () |
| static void | test_bug6761 (void) |
| static void | test_bug8330 () |
| static void | test_bug7990 () |
| static void | test_view_sp_list_fields () |
| static void | test_bug8378 () |
| static void | test_bug8722 () |
| MYSQL_STMT * | open_cursor (const char *query) |
| static void | test_bug8880 () |
| static void | test_bug9159 () |
| static void | test_bug9520 () |
| static void | test_bug9478 () |
| static void | test_bug9643 () |
| static void | test_bug11111 () |
| static void | test_bug10729 () |
| static void | test_bug9992 () |
| static void | test_bug10736 () |
| static void | test_bug10794 () |
| static void | test_bug11172 () |
| static void | test_bug11656 () |
| static void | test_bug10214 () |
| static void | test_client_character_set () |
| static void | test_bug9735 () |
| static void | test_bug11183 () |
| static void | test_bug11037 () |
| static void | test_bug10760 () |
| static void | test_bug12001 () |
| static void | test_bug11909 () |
| static void | test_bug11901 () |
| static void | test_bug11904 () |
| static void | test_bug12243 () |
| static void | test_bug11718 () |
| static void | test_bug12925 () |
| static void | test_bug14210 () |
| static void | test_bug13488 () |
| static void | test_bug13524 () |
| static void | test_bug14845 () |
| static void | test_bug15510 () |
| static void | test_opt_reconnect () |
| static void | test_bug12744 () |
| static void | test_bug16143 () |
| static void | test_bug16144 () |
| static void | test_bug15613 () |
| static void | test_bug17667 () |
| static void | test_bug14169 () |
| static void | test_mysql_insert_id () |
| static void | test_bug20152 () |
| static void | test_bug15752 () |
| static void | test_bug21206 () |
| static void | usage (void) |
| static my_bool | get_one_option (int optid, const struct my_option *opt __attribute__((unused)), char *argument) |
| static void | get_options (int *argc, char ***argv) |
| static void | print_test_output () |
| int | main (int argc, char **argv) |
Variables | |
| static int | opt_testcase = 0 |
| static char * | opt_db = 0 |
| static char * | opt_user = 0 |
| static char * | opt_password = 0 |
| static char * | opt_host = 0 |
| static char * | opt_unix_socket = 0 |
| static unsigned int | opt_port |
| static my_bool | tty_password = 0 |
| static my_bool | opt_silent = 0 |
| static MYSQL * | mysql = 0 |
| static char | current_db [] = "client_test_db" |
| static unsigned int | test_count = 0 |
| static unsigned int | opt_count = 0 |
| static unsigned int | iter_count = 0 |
| static my_bool | have_innodb = FALSE |
| static const char * | opt_basedir = "./" |
| static const char * | opt_vardir = "mysql-test/var" |
| static longlong | opt_getopt_ll_test = 0 |
| static int | embedded_server_arg_count = 0 |
| static char * | embedded_server_args [MAX_SERVER_ARGS] |
| static const char * | embedded_server_groups [] |
| static time_t | start_time |
| static time_t | end_time |
| static double | total_time |
| const char * | default_dbug_option = "d:t:o,/tmp/mysql_client_test.trace" |
| static const char * | client_test_load_default_groups [] = { "client", 0 } |
| static char ** | defaults_argv |
| static struct my_option | client_test_long_options [] |
| static struct my_tests_st | my_tests [] |
| #define check_execute | ( | stmt, | |||
| r | ) |
Value:
{ \
if (r) \
mysterror(stmt, NULL); \
DIE_UNLESS(r == 0);\
}
Definition at line 148 of file mysql_client_test.c.
Referenced by bind_fetch(), fetch_n(), my_process_stmt_result(), my_stmt_result(), open_cursor(), stmt_fetch_init(), test_bind_date_conv(), test_bind_nagative(), test_bind_result(), test_bind_result_ext(), test_bind_result_ext1(), test_buffers(), test_bug10729(), test_bug10736(), test_bug10760(), test_bug10794(), test_bug11037(), test_bug11111(), test_bug1115(), test_bug11172(), test_bug11183(), test_bug11656(), test_bug1180(), test_bug11901(), test_bug11904(), test_bug11909(), test_bug12243(), test_bug13488(), test_bug13524(), test_bug14210(), test_bug14845(), test_bug1500(), test_bug15510(), test_bug1644(), test_bug1664(), test_bug20152(), test_bug2247(), test_bug2248(), test_bug3035(), test_bug3117(), test_bug3796(), test_bug4026(), test_bug4030(), test_bug4079(), test_bug4172(), test_bug4231(), test_bug4236(), test_bug5126(), test_bug5194(), test_bug5399(), test_bug6046(), test_bug6049(), test_bug6058(), test_bug6096(), test_bug8330(), test_bug8722(), test_bug8880(), test_bug9478(), test_bug9520(), test_bug9643(), test_conversion(), test_create_drop(), test_datetime_ranges(), test_decimal_bug(), test_derived(), test_distinct(), test_do_set(), test_double_compare(), test_explain_bug(), test_fetch_column(), test_fetch_date(), test_fetch_nobuffs(), test_fetch_null(), test_fetch_offset(), test_fetch_seek(), test_field_misc(), test_free_result(), test_free_store_result(), test_frm_bug(), test_insert(), test_insert_select(), test_join(), test_left_join_view(), test_logs(), test_long_data(), test_long_data_bin(), test_long_data_str(), test_long_data_str1(), test_mem_overun(), test_multi(), test_multi_stmt(), test_nstmts(), test_null(), test_open_direct(), test_prepare(), test_prepare_alter(), test_prepare_ext(), test_prepare_insert_update(), test_prepare_noparam(), test_prepare_simple(), test_ps_conj_select(), test_ps_i18n(), test_ps_null_param(), test_pure_coverage(), test_rename(), test_rewind(), test_select(), test_select_prepare(), test_select_show(), test_select_show_table(), test_select_version(), test_selecttmp(), test_set_option(), test_set_variable(), test_simple_delete(), test_simple_update(), test_sqlmode(), test_sshort_bug(), test_stiny_bug(), test_stmt_close(), test_store_result(), test_store_result1(), test_store_result2(), test_subqueries(), test_subqueries_ref(), test_subselect(), test_truncation(), test_truncation_option(), test_ts(), test_union(), test_union2(), test_union_param(), test_update(), test_ushort_bug(), test_view(), test_view_2where(), test_view_insert(), test_view_insert_fields(), test_view_star(), test_view_where(), and test_xjoin().
| #define check_execute_r | ( | stmt, | |||
| r | ) |
Value:
{ \
if (r) \
mysterror(stmt, NULL); \
DIE_UNLESS(r != 0);\
}
Definition at line 155 of file mysql_client_test.c.
Referenced by test_bug2248(), test_fetch_column(), test_fetch_offset(), test_pure_coverage(), and test_rename().
| #define check_stmt | ( | stmt | ) |
Value:
{ \
if ( stmt == 0) \
myerror(NULL); \
DIE_UNLESS(stmt != 0); \
}
Definition at line 162 of file mysql_client_test.c.
Referenced by bind_fetch(), execute_prepare_query(), my_stmt_result(), test_bind_date_conv(), test_bind_nagative(), test_bind_result(), test_bind_result_ext(), test_bind_result_ext1(), test_buffers(), test_bug1115(), test_bug1180(), test_bug1500(), test_bug1644(), test_bug1664(), test_bug1946(), test_bug2247(), test_bug2248(), test_bug3035(), test_bug3117(), test_create_drop(), test_datetime_ranges(), test_decimal_bug(), test_derived(), test_distinct(), test_do_set(), test_double_compare(), test_explain_bug(), test_fetch_column(), test_fetch_date(), test_fetch_nobuffs(), test_fetch_null(), test_fetch_offset(), test_fetch_seek(), test_field_misc(), test_free_result(), test_free_store_result(), test_frm_bug(), test_insert(), test_insert_select(), test_join(), test_logs(), test_long_data(), test_long_data_bin(), test_long_data_str(), test_long_data_str1(), test_mem_overun(), test_multi(), test_multi_stmt(), test_nstmts(), test_null(), test_open_direct(), test_order_param(), test_prepare(), test_prepare_alter(), test_prepare_ext(), test_prepare_field_result(), test_prepare_insert_update(), test_prepare_noparam(), test_prepare_resultset(), test_prepare_simple(), test_ps_conj_select(), test_ps_i18n(), test_ps_null_param(), test_pure_coverage(), test_rename(), test_select(), test_select_prepare(), test_select_show(), test_select_show_table(), test_select_version(), test_selecttmp(), test_set_option(), test_set_variable(), test_simple_delete(), test_simple_update(), test_sqlmode(), test_sshort_bug(), test_stiny_bug(), test_stmt_close(), test_store_result(), test_store_result1(), test_store_result2(), test_subqueries(), test_subqueries_ref(), test_subselect(), test_ts(), test_union(), test_union2(), test_union_param(), test_update(), test_ushort_bug(), and test_xjoin().
| #define check_stmt_r | ( | stmt | ) |
Value:
{ \
if (stmt == 0) \
myerror(NULL);\
DIE_UNLESS(stmt == 0);\
}
Definition at line 169 of file mysql_client_test.c.
Referenced by test_long_data(), test_null(), test_prepare_grant(), test_prepare_multi_statements(), test_prepare_syntax(), test_pure_coverage(), test_select_show(), and test_sqlmode().
| #define DIE | ( | expr | ) | die(__FILE__, __LINE__, #expr) |
Definition at line 119 of file mysql_client_test.c.
Referenced by get_one_option(), main(), and test_bug17667().
| #define DIE_UNLESS | ( | expr | ) | ((void) ((expr) ? 0 : (die(__FILE__, __LINE__, #expr), 0))) |
Definition at line 117 of file mysql_client_test.c.
Referenced by bind_fetch(), check_have_innodb(), do_verify_prepare_field(), execute_prepare_query(), my_process_stmt_result(), test_bad_union(), test_bind_date_conv(), test_bind_result(), test_bind_result_ext(), test_bind_result_ext1(), test_buffers(), test_bug10214(), test_bug10729(), test_bug10736(), test_bug10760(), test_bug11037(), test_bug11111(), test_bug1115(), test_bug11172(), test_bug11183(), test_bug11656(), test_bug11718(), test_bug1180(), test_bug11904(), test_bug11909(), test_bug12001(), test_bug12744(), test_bug12925(), test_bug13488(), test_bug13524(), test_bug14169(), test_bug14210(), test_bug14845(), test_bug1500(), test_bug15510(), test_bug15613(), test_bug15752(), test_bug16143(), test_bug16144(), test_bug1644(), test_bug1946(), test_bug19671(), test_bug20152(), test_bug2247(), test_bug2248(), test_bug3035(), test_bug3117(), test_bug3796(), test_bug4026(), test_bug4030(), test_bug4079(), test_bug4172(), test_bug4231(), test_bug4236(), test_bug5126(), test_bug5315(), test_bug5399(), test_bug6049(), test_bug6058(), test_bug6059(), test_bug6096(), test_bug6761(), test_bug7990(), test_bug8330(), test_bug8378(), test_bug9478(), test_bug9520(), test_bug9643(), test_bug9992(), test_client_character_set(), test_conversion(), test_create_drop(), test_cuted_rows(), test_datetime_ranges(), test_decimal_bug(), test_derived(), test_distinct(), test_double_compare(), test_explain_bug(), test_fetch_column(), test_fetch_date(), test_fetch_nobuffs(), test_fetch_null(), test_fetch_offset(), test_fetch_seek(), test_field_misc(), test_field_names(), test_free_result(), test_free_store_result(), test_frm_bug(), test_func_fields(), test_insert(), test_insert_select(), test_join(), test_list_fields(), test_logs(), test_long_data(), test_long_data_bin(), test_long_data_str(), test_long_data_str1(), test_manual_sample(), test_mem_overun(), test_multi(), test_multi_statements(), test_multi_stmt(), test_mysql_insert_id(), test_nstmts(), test_null(), test_open_direct(), test_opt_reconnect(), test_parse_error_and_bad_length(), test_prepare(), test_prepare_alter(), test_prepare_ext(), test_prepare_grant(), test_prepare_noparam(), test_ps_conj_select(), test_ps_i18n(), test_ps_null_param(), test_pure_coverage(), test_rewind(), test_select(), test_select_prepare(), test_select_show(), test_selecttmp(), test_set_option(), test_set_variable(), test_simple_delete(), test_simple_update(), test_sqlmode(), test_sshort_bug(), test_stiny_bug(), test_stmt_close(), test_store_result(), test_store_result1(), test_store_result2(), test_subqueries(), test_subqueries_ref(), test_subselect(), test_truncation(), test_truncation_option(), test_ts(), test_union(), test_union2(), test_union_param(), test_update(), test_ushort_bug(), test_view_sp_list_fields(), test_warnings(), test_xjoin(), verify_affected_rows(), verify_col_data(), verify_field_count(), verify_param_count(), and verify_st_affected_rows().
| #define MAX_FIELD_DATA_SIZE 255 |
| #define MAX_KEY MAX_INDEXES |
Definition at line 39 of file mysql_client_test.c.
| #define MAX_RES_FIELDS 50 |
| #define MAX_SERVER_ARGS 64 |
Definition at line 40 of file mysql_client_test.c.
| #define MAX_TEST_QUERY_LENGTH 300 |
Definition at line 38 of file mysql_client_test.c.
Referenced by client_connect(), client_disconnect(), test_bug1115(), test_bug1180(), test_bug1644(), test_bug17667(), test_double_compare(), test_fetch_null(), test_long_data(), test_long_data_bin(), test_long_data_str(), test_long_data_str1(), test_manual_sample(), test_null(), test_prepare(), test_prepare_ext(), test_prepare_field_result(), test_prepare_grant(), test_prepare_insert_update(), test_prepare_multi_statements(), test_prepare_noparam(), test_prepare_simple(), test_prepare_syntax(), test_ps_conj_select(), test_ps_null_param(), test_select(), test_select_show(), test_simple_delete(), test_simple_update(), test_sqlmode(), test_stmt_close(), test_store_result2(), test_ts(), test_update(), and verify_col_data().
| #define myerror | ( | msg | ) | print_error(msg) |
Definition at line 130 of file mysql_client_test.c.
Referenced by client_connect(), test_bad_union(), test_bug1946(), test_bug8378(), test_opt_reconnect(), test_prepare_grant(), test_stmt_close(), and thread_query().
| #define myheader | ( | str | ) |
Value:
if (opt_silent < 2) \ { \ fprintf(stdout, "\n\n#####################################\n"); \ fprintf(stdout, "%d of (%d/%d): %s", test_count++, iter_count, \ opt_count, str); \ fprintf(stdout, " \n#####################################\n"); \ }
Definition at line 85 of file mysql_client_test.c.
Referenced by client_query(), client_store_result(), client_use_result(), test_bad_union(), test_basic_cursors(), test_bind_nagative(), test_bind_result(), test_bind_result_ext(), test_bind_result_ext1(), test_buffers(), test_bug10214(), test_bug10729(), test_bug10736(), test_bug10760(), test_bug10794(), test_bug11037(), test_bug11111(), test_bug1115(), test_bug11172(), test_bug11183(), test_bug11656(), test_bug11718(), test_bug1180(), test_bug11901(), test_bug11904(), test_bug11909(), test_bug12001(), test_bug12243(), test_bug12744(), test_bug12925(), test_bug13488(), test_bug13524(), test_bug14169(), test_bug14210(), test_bug14845(), test_bug1500(), test_bug15510(), test_bug15613(), test_bug15752(), test_bug16143(), test_bug16144(), test_bug1644(), test_bug1664(), test_bug17667(), test_bug1946(), test_bug19671(), test_bug20152(), test_bug21206(), test_bug2247(), test_bug2248(), test_bug3035(), test_bug3117(), test_bug3796(), test_bug4026(), test_bug4030(), test_bug4079(), test_bug4172(), test_bug4231(), test_bug4236(), test_bug5126(), test_bug5194(), test_bug5315(), test_bug5399(), test_bug6046(), test_bug6049(), test_bug6058(), test_bug6059(), test_bug6081(), test_bug6096(), test_bug6761(), test_bug7990(), test_bug8330(), test_bug8378(), test_bug8722(), test_bug8880(), test_bug9159(), test_bug9478(), test_bug9520(), test_bug9643(), test_bug9735(), test_bug9992(), test_client_character_set(), test_conversion(), test_create_drop(), test_cursors_with_union(), test_cuted_rows(), test_date(), test_date_date(), test_date_dt(), test_date_time(), test_date_ts(), test_datetime_ranges(), test_debug_example(), test_decimal_bug(), test_derived(), test_distinct(), test_do_set(), test_double_compare(), test_errors(), test_explain_bug(), test_fetch_bigint(), test_fetch_column(), test_fetch_date(), test_fetch_double(), test_fetch_float(), test_fetch_long(), test_fetch_nobuffs(), test_fetch_null(), test_fetch_offset(), test_fetch_seek(), test_fetch_short(), test_fetch_str(), test_fetch_tiny(), test_field_flags(), test_field_misc(), test_field_names(), test_free_result(), test_free_store_result(), test_frm_bug(), test_func_fields(), test_insert(), test_insert_select(), test_join(), test_left_join_view(), test_list_fields(), test_logs(), test_long_data(), test_long_data_bin(), test_long_data_str(), test_long_data_str1(), test_manual_sample(), test_mem_overun(), test_multi(), test_multi_statements(), test_multi_stmt(), test_mysql_insert_id(), test_nstmts(), test_null(), test_open_direct(), test_opt_reconnect(), test_order_param(), test_parse_error_and_bad_length(), test_prepare(), test_prepare_alter(), test_prepare_ext(), test_prepare_field_result(), test_prepare_grant(), test_prepare_insert_update(), test_prepare_multi_statements(), test_prepare_noparam(), test_prepare_resultset(), test_prepare_simple(), test_prepare_syntax(), test_ps_conj_select(), test_ps_i18n(), test_ps_null_param(), test_pure_coverage(), test_rename(), test_rewind(), test_select(), test_select_direct(), test_select_prepare(), test_select_show(), test_select_show_table(), test_select_version(), test_selecttmp(), test_set_option(), test_set_variable(), test_simple_delete(), test_simple_update(), test_sqlmode(), test_sshort_bug(), test_stiny_bug(), test_stmt_close(), test_store_result(), test_store_result1(), test_store_result2(), test_subqueries(), test_subqueries_ref(), test_subselect(), test_tran_bdb(), test_tran_innodb(), test_truncation(), test_truncation_option(), test_ts(), test_union(), test_union2(), test_union_param(), test_update(), test_ushort_bug(), test_view(), test_view_2where(), test_view_insert(), test_view_insert_fields(), test_view_sp_list_fields(), test_view_star(), test_view_where(), test_warnings(), and test_xjoin().
| #define myheader_r | ( | str | ) |
Value:
if (!opt_silent) \ { \ fprintf(stdout, "\n\n#####################################\n"); \ fprintf(stdout, "%s", str); \ fprintf(stdout, " \n#####################################\n"); \ }
Definition at line 93 of file mysql_client_test.c.
Referenced by client_connect(), and client_disconnect().
| #define myquery | ( | RES | ) |
Value:
{ \
int r= (RES); \
if (r) \
myerror(NULL); \
DIE_UNLESS(r == 0); \
}
Definition at line 133 of file mysql_client_test.c.
Referenced by bind_fetch(), check_have_innodb(), client_connect(), client_query(), client_store_result(), client_use_result(), execute_prepare_query(), fill_tables(), test_bind_date_conv(), test_bind_nagative(), test_bind_result(), test_bind_result_ext(), test_bind_result_ext1(), test_buffers(), test_bug10729(), test_bug10736(), test_bug10760(), test_bug10794(), test_bug11037(), test_bug11111(), test_bug1115(), test_bug11172(), test_bug11183(), test_bug11656(), test_bug11718(), test_bug1180(), test_bug11901(), test_bug11904(), test_bug11909(), test_bug12001(), test_bug12243(), test_bug13488(), test_bug13524(), test_bug14169(), test_bug14210(), test_bug14845(), test_bug1500(), test_bug15510(), test_bug15613(), test_bug15752(), test_bug1644(), test_bug1664(), test_bug17667(), test_bug1946(), test_bug19671(), test_bug20152(), test_bug2247(), test_bug2248(), test_bug3035(), test_bug3117(), test_bug3796(), test_bug4172(), test_bug4231(), test_bug5126(), test_bug5194(), test_bug6046(), test_bug6049(), test_bug6058(), test_bug6081(), test_bug6096(), test_bug6761(), test_bug8330(), test_bug8378(), test_bug8722(), test_bug8880(), test_bug9159(), test_bug9478(), test_bug9520(), test_bug9643(), test_bug9735(), test_client_character_set(), test_conversion(), test_create_drop(), test_cuted_rows(), test_date(), test_date_date(), test_date_dt(), test_date_time(), test_date_ts(), test_datetime_ranges(), test_debug_example(), test_decimal_bug(), test_derived(), test_distinct(), test_do_set(), test_double_compare(), test_errors(), test_explain_bug(), test_fetch_bigint(), test_fetch_column(), test_fetch_date(), test_fetch_double(), test_fetch_float(), test_fetch_long(), test_fetch_null(), test_fetch_offset(), test_fetch_seek(), test_fetch_short(), test_fetch_str(), test_fetch_tiny(), test_field_flags(), test_field_misc(), test_field_names(), test_free_result(), test_free_store_result(), test_frm_bug(), test_func_fields(), test_insert(), test_insert_select(), test_join(), test_left_join_view(), test_list_fields(), test_logs(), test_long_data(), test_long_data_bin(), test_long_data_str(), test_long_data_str1(), test_mem_overun(), test_multi(), test_multi_statements(), test_multi_stmt(), test_mysql_insert_id(), test_nstmts(), test_null(), test_open_direct(), test_order_param(), test_prepare(), test_prepare_alter(), test_prepare_ext(), test_prepare_field_result(), test_prepare_grant(), test_prepare_insert_update(), test_prepare_noparam(), test_prepare_resultset(), test_prepare_simple(), test_prepare_syntax(), test_ps_conj_select(), test_ps_i18n(), test_ps_null_param(), test_pure_coverage(), test_rename(), test_rewind(), test_select(), test_select_direct(), test_select_prepare(), test_select_show(), test_selecttmp(), test_set_option(), test_simple_delete(), test_simple_update(), test_sqlmode(), test_sshort_bug(), test_stiny_bug(), test_stmt_close(), test_store_result(), test_store_result1(), test_store_result2(), test_subqueries(), test_subqueries_ref(), test_subselect(), test_tran_bdb(), test_tran_innodb(), test_truncation(), test_truncation_option(), test_ts(), test_union(), test_union2(), test_update(), test_ushort_bug(), test_view(), test_view_2where(), test_view_insert(), test_view_insert_fields(), test_view_sp_list_fields(), test_view_star(), test_view_where(), test_warnings(), test_xjoin(), and verify_col_data().
| #define myquery_r | ( | r | ) |
Value:
{ \
if (r) \
myerror(NULL); \
DIE_UNLESS(r != 0); \
}
Definition at line 141 of file mysql_client_test.c.
Referenced by client_query(), test_bug6081(), test_errors(), test_free_result(), test_multi_statements(), test_mysql_insert_id(), test_open_direct(), and test_prepare_grant().
| #define mysterror | ( | stmt, | |||
| msg | ) | print_st_error(stmt, msg) |
Definition at line 131 of file mysql_client_test.c.
Definition at line 176 of file mysql_client_test.c.
Referenced by client_store_result(), client_use_result(), test_bug1644(), test_bug19671(), test_bug2247(), test_cuted_rows(), test_debug_example(), test_double_compare(), test_errors(), test_explain_bug(), test_field_flags(), test_field_misc(), test_field_names(), test_frm_bug(), test_func_fields(), test_insert(), test_list_fields(), test_long_data(), test_long_data_bin(), test_long_data_str(), test_long_data_str1(), test_mem_overun(), test_multi_statements(), test_open_direct(), test_prepare_field_result(), test_prepare_noparam(), test_prepare_resultset(), test_select_direct(), test_set_option(), test_simple_delete(), test_simple_update(), test_stmt_close(), test_tran_bdb(), test_tran_innodb(), test_ts(), test_update(), test_warnings(), and verify_col_data().
Definition at line 177 of file mysql_client_test.c.
Referenced by test_bug1644(), test_func_fields(), test_tran_bdb(), and test_tran_innodb().
| #define NUM_OF_USED_STMT 97 |
Referenced by test_bug5399().
| #define TEST_BUG8378_IN "\xef\xbb\xbf\x27\xbf\x10" |
| #define TEST_BUG8378_OUT "\xef\xbb\x5c\xbf\x5c\x27\x5c\xbf\x10" |
| #define VER "2.1" |
| #define verify_prepare_field | ( | result, | |||
| no, | |||||
| name, | |||||
| org_name, | |||||
| type, | |||||
| table, | |||||
| org_table, | |||||
| db, | |||||
| length, | |||||
| def | ) |
Value:
do_verify_prepare_field((result),(no),(name),(org_name),(type), \ (table),(org_table),(db),(length),(def), \ __FILE__, __LINE__)
Definition at line 701 of file mysql_client_test.c.
Referenced by test_bug19671(), test_bug9735(), test_explain_bug(), test_field_misc(), test_list_fields(), and test_prepare_field_result().
| typedef struct st_stmt_fetch Stmt_fetch |
| anonymous enum |
| enum fetch_type |
Definition at line 1057 of file mysql_client_test.c.
01057 { USE_ROW_BY_ROW_FETCH= 0, USE_STORE_RESULT= 1 };
| static void bind_fetch | ( | int | row_count | ) | [static] |
Definition at line 3796 of file mysql_client_test.c.
References array_elements, buffer, bzero, check_execute, check_stmt, count, data, DIE_UNLESS, int(), my_sprintf, my_stmt_result(), myquery, mysql, mysql_commit(), MYSQL_NO_DATA, mysql_simple_prepare(), mysql_stmt_bind_param(), mysql_stmt_bind_result(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_store_result(), MYSQL_TYPE_DOUBLE, MYSQL_TYPE_FLOAT, MYSQL_TYPE_LONG, MYSQL_TYPE_LONGLONG, MYSQL_TYPE_SHORT, MYSQL_TYPE_STRING, MYSQL_TYPE_TINY, opt_silent, strcmp(), and verify_param_count().
Referenced by test_fetch_bigint(), test_fetch_double(), test_fetch_float(), test_fetch_long(), test_fetch_short(), test_fetch_str(), and test_fetch_tiny().
03797 { 03798 MYSQL_STMT *stmt; 03799 int rc, i, count= row_count; 03800 int32 data[10]; 03801 int8 i8_data; 03802 int16 i16_data; 03803 int32 i32_data; 03804 longlong i64_data; 03805 float f_data; 03806 double d_data; 03807 char s_data[10]; 03808 ulong length[10]; 03809 MYSQL_BIND bind[7]; 03810 my_bool is_null[7]; 03811 03812 stmt= mysql_simple_prepare(mysql, "INSERT INTO test_bind_fetch VALUES " 03813 "(?, ?, ?, ?, ?, ?, ?)"); 03814 check_stmt(stmt); 03815 03816 verify_param_count(stmt, 7); 03817 03818 /* Always bzero all members of bind parameter */ 03819 bzero((char*) bind, sizeof(bind)); 03820 03821 for (i= 0; i < (int) array_elements(bind); i++) 03822 { 03823 bind[i].buffer_type= MYSQL_TYPE_LONG; 03824 bind[i].buffer= (void *) &data[i]; 03825 } 03826 rc= mysql_stmt_bind_param(stmt, bind); 03827 check_execute(stmt, rc); 03828 03829 while (count--) 03830 { 03831 rc= 10+count; 03832 for (i= 0; i < (int) array_elements(bind); i++) 03833 { 03834 data[i]= rc+i; 03835 rc+= 12; 03836 } 03837 rc= mysql_stmt_execute(stmt); 03838 check_execute(stmt, rc); 03839 } 03840 03841 rc= mysql_commit(mysql); 03842 myquery(rc); 03843 03844 mysql_stmt_close(stmt); 03845 03846 rc= my_stmt_result("SELECT * FROM test_bind_fetch"); 03847 DIE_UNLESS(row_count == rc); 03848 03849 stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_bind_fetch"); 03850 check_stmt(stmt); 03851 03852 for (i= 0; i < (int) array_elements(bind); i++) 03853 { 03854 bind[i].buffer= (void *) &data[i]; 03855 bind[i].length= &length[i]; 03856 bind[i].is_null= &is_null[i]; 03857 } 03858 03859 bind[0].buffer_type= MYSQL_TYPE_TINY; 03860 bind[0].buffer= (void *)&i8_data; 03861 03862 bind[1].buffer_type= MYSQL_TYPE_SHORT; 03863 bind[1].buffer= (void *)&i16_data; 03864 03865 bind[2].buffer_type= MYSQL_TYPE_LONG; 03866 bind[2].buffer= (void *)&i32_data; 03867 03868 bind[3].buffer_type= MYSQL_TYPE_LONGLONG; 03869 bind[3].buffer= (void *)&i64_data; 03870 03871 bind[4].buffer_type= MYSQL_TYPE_FLOAT; 03872 bind[4].buffer= (void *)&f_data; 03873 03874 bind[5].buffer_type= MYSQL_TYPE_DOUBLE; 03875 bind[5].buffer= (void *)&d_data; 03876 03877 bind[6].buffer_type= MYSQL_TYPE_STRING; 03878 bind[6].buffer= (void *)&s_data; 03879 bind[6].buffer_length= sizeof(s_data); 03880 03881 rc= mysql_stmt_bind_result(stmt, bind); 03882 check_execute(stmt, rc); 03883 03884 rc= mysql_stmt_execute(stmt); 03885 check_execute(stmt, rc); 03886 03887 rc= mysql_stmt_store_result(stmt); 03888 check_execute(stmt, rc); 03889 03890 while (row_count--) 03891 { 03892 rc= mysql_stmt_fetch(stmt); 03893 check_execute(stmt, rc); 03894 03895 if (!opt_silent) 03896 { 03897 fprintf(stdout, "\n"); 03898 fprintf(stdout, "\n tiny : %ld(%lu)", (ulong) i8_data, length[0]); 03899 fprintf(stdout, "\n short : %ld(%lu)", (ulong) i16_data, length[1]); 03900 fprintf(stdout, "\n int : %ld(%lu)", (ulong) i32_data, length[2]); 03901 fprintf(stdout, "\n longlong : %ld(%lu)", (ulong) i64_data, length[3]); 03902 fprintf(stdout, "\n float : %f(%lu)", f_data, length[4]); 03903 fprintf(stdout, "\n double : %g(%lu)", d_data, length[5]); 03904 fprintf(stdout, "\n char : %s(%lu)", s_data, length[6]); 03905 } 03906 rc= 10+row_count; 03907 03908 /* TINY */ 03909 DIE_UNLESS((int) i8_data == rc); 03910 DIE_UNLESS(length[0] == 1); 03911 rc+= 13; 03912 03913 /* SHORT */ 03914 DIE_UNLESS((int) i16_data == rc); 03915 DIE_UNLESS(length[1] == 2); 03916 rc+= 13; 03917 03918 /* LONG */ 03919 DIE_UNLESS((int) i32_data == rc); 03920 DIE_UNLESS(length[2] == 4); 03921 rc+= 13; 03922 03923 /* LONGLONG */ 03924 DIE_UNLESS((int) i64_data == rc); 03925 DIE_UNLESS(length[3] == 8); 03926 rc+= 13; 03927 03928 /* FLOAT */ 03929 DIE_UNLESS((int)f_data == rc); 03930 DIE_UNLESS(length[4] == 4); 03931 rc+= 13; 03932 03933 /* DOUBLE */ 03934 DIE_UNLESS((int)d_data == rc); 03935 DIE_UNLESS(length[5] == 8); 03936 rc+= 13; 03937 03938 /* CHAR */ 03939 { 03940 char buff[20]; 03941 long len= my_sprintf(buff, (buff, "%d", rc)); 03942 DIE_UNLESS(strcmp(s_data, buff) == 0); 03943 DIE_UNLESS(length[6] == (ulong) len); 03944 } 03945 } 03946 rc= mysql_stmt_fetch(stmt); 03947 DIE_UNLESS(rc == MYSQL_NO_DATA); 03948 03949 mysql_stmt_close(stmt); 03950 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 229 of file mysql_client_test.c.
References DIE_UNLESS, myquery, mysql_fetch_row(), mysql_free_result(), mysql_query(), mysql_use_result(), and strcmp().
Referenced by client_connect().
00230 { 00231 MYSQL_RES *res; 00232 MYSQL_ROW row; 00233 int rc; 00234 my_bool result; 00235 00236 rc= mysql_query(conn, "show variables like 'have_innodb'"); 00237 myquery(rc); 00238 res= mysql_use_result(conn); 00239 DIE_UNLESS(res); 00240 00241 row= mysql_fetch_row(res); 00242 DIE_UNLESS(row); 00243 00244 result= strcmp(row[1], "YES") == 0; 00245 mysql_free_result(res); 00246 return result; 00247 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void client_connect | ( | ulong | flag | ) | [static] |
Definition at line 270 of file mysql_client_test.c.
References check_have_innodb(), current_db, exit, have_innodb, MAX_TEST_QUERY_LENGTH, myerror, myheader_r, myquery, mysql, mysql_autocommit(), mysql_close(), mysql_get_server_info(), mysql_get_server_version(), mysql_init(), mysql_query(), mysql_real_connect(), NULL, NullS, opt_db, opt_host, opt_password, opt_port, opt_silent, opt_unix_socket, opt_user, st_mysql::reconnect, strxmov(), and TRUE.
Referenced by main(), and test_bug12744().
00271 { 00272 int rc; 00273 static char query[MAX_TEST_QUERY_LENGTH]; 00274 myheader_r("client_connect"); 00275 00276 if (!opt_silent) 00277 fprintf(stdout, "\n Establishing a connection to '%s' ...", 00278 opt_host ? opt_host : ""); 00279 00280 if (!(mysql= mysql_init(NULL))) 00281 { 00282 opt_silent= 0; 00283 myerror("mysql_init() failed"); 00284 exit(1); 00285 } 00286 00287 if (!(mysql_real_connect(mysql, opt_host, opt_user, 00288 opt_password, opt_db ? opt_db:"test", opt_port, 00289 opt_unix_socket, flag))) 00290 { 00291 opt_silent= 0; 00292 myerror("connection failed"); 00293 mysql_close(mysql); 00294 fprintf(stdout, "\n Check the connection options using --help or -?\n"); 00295 exit(1); 00296 } 00297 mysql->reconnect= 1; 00298 00299 if (!opt_silent) 00300 fprintf(stdout, " OK"); 00301 00302 /* set AUTOCOMMIT to ON*/ 00303 mysql_autocommit(mysql, TRUE); 00304 00305 if (!opt_silent) 00306 { 00307 fprintf(stdout, "\nConnected to MySQL server version: %s (%lu)\n", 00308 mysql_get_server_info(mysql), 00309 (ulong) mysql_get_server_version(mysql)); 00310 fprintf(stdout, "\n Creating a test database '%s' ...", current_db); 00311 } 00312 strxmov(query, "CREATE DATABASE IF NOT EXISTS ", current_db, NullS); 00313 00314 rc= mysql_query(mysql, query); 00315 myquery(rc); 00316 00317 strxmov(query, "USE ", current_db, NullS); 00318 rc= mysql_query(mysql, query); 00319 myquery(rc); 00320 have_innodb= check_have_innodb(mysql); 00321 00322 if (!opt_silent) 00323 fprintf(stdout, " OK"); 00324 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void client_disconnect | ( | ) | [static] |
Definition at line 329 of file mysql_client_test.c.
References current_db, MAX_TEST_QUERY_LENGTH, myheader_r, mysql, mysql_close(), mysql_query(), NullS, opt_silent, and strxmov().
Referenced by main().
00330 { 00331 static char query[MAX_TEST_QUERY_LENGTH]; 00332 00333 myheader_r("client_disconnect"); 00334 00335 if (mysql) 00336 { 00337 if (!opt_silent) 00338 fprintf(stdout, "\n dropping the test database '%s' ...", current_db); 00339 strxmov(query, "DROP DATABASE IF EXISTS ", current_db, NullS); 00340 00341 mysql_query(mysql, query); 00342 if (!opt_silent) 00343 fprintf(stdout, " OK"); 00344 00345 if (!opt_silent) 00346 fprintf(stdout, "\n closing the connection ..."); 00347 mysql_close(mysql); 00348 fprintf(stdout, " OK\n"); 00349 } 00350 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void client_query | ( | ) | [static] |
Definition at line 355 of file mysql_client_test.c.
References myheader, myquery, myquery_r, mysql, and mysql_query().
00356 { 00357 int rc; 00358 00359 myheader("client_query"); 00360 00361 rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); 00362 myquery(rc); 00363 00364 rc= mysql_query(mysql, "CREATE TABLE t1(" 00365 "id int primary key auto_increment, " 00366 "name varchar(20))"); 00367 myquery(rc); 00368 00369 rc= mysql_query(mysql, "CREATE TABLE t1(id int, name varchar(20))"); 00370 myquery_r(rc); 00371 00372 rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('mysql')"); 00373 myquery(rc); 00374 00375 rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('monty')"); 00376 myquery(rc); 00377 00378 rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('venu')"); 00379 myquery(rc); 00380 00381 rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('deleted')"); 00382 myquery(rc); 00383 00384 rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('deleted')"); 00385 myquery(rc); 00386 00387 rc= mysql_query(mysql, "UPDATE t1 SET name= 'updated' " 00388 "WHERE name= 'deleted'"); 00389 myquery(rc); 00390 00391 rc= mysql_query(mysql, "UPDATE t1 SET id= 3 WHERE name= 'updated'"); 00392 myquery_r(rc); 00393 00394 myquery(mysql_query(mysql, "drop table t1")); 00395 }
Here is the call graph for this function:

| static void client_store_result | ( | ) | [static] |
Definition at line 862 of file mysql_client_test.c.
References my_process_result_set(), myheader, myquery, mysql, mysql_free_result(), mysql_query(), mysql_store_result(), and mytest.
00863 { 00864 MYSQL_RES *result; 00865 int rc; 00866 00867 myheader("client_store_result"); 00868 00869 rc= mysql_query(mysql, "SELECT * FROM t1"); 00870 myquery(rc); 00871 00872 /* get the result */ 00873 result= mysql_store_result(mysql); 00874 mytest(result); 00875 00876 (void) my_process_result_set(result); 00877 mysql_free_result(result); 00878 }
Here is the call graph for this function:

| static void client_use_result | ( | ) | [static] |
Definition at line 883 of file mysql_client_test.c.
References my_process_result_set(), myheader, myquery, mysql, mysql_free_result(), mysql_query(), mysql_use_result(), and mytest.
00884 { 00885 MYSQL_RES *result; 00886 int rc; 00887 myheader("client_use_result"); 00888 00889 rc= mysql_query(mysql, "SELECT * FROM t1"); 00890 myquery(rc); 00891 00892 /* get the result */ 00893 result= mysql_use_result(mysql); 00894 mytest(result); 00895 00896 (void) my_process_result_set(result); 00897 mysql_free_result(result); 00898 }
Here is the call graph for this function:

| static int cmp_double | ( | double * | a, | |
| double * | b | |||
| ) | [static] |
| void die | ( | const char * | file, | |
| int | line, | |||
| const char * | expr | |||
| ) |
| static void do_verify_prepare_field | ( | MYSQL_RES * | result, | |
| unsigned int | no, | |||
| const char * | name, | |||
| const char * | org_name, | |||
| enum enum_field_types | type, | |||
| const char * | table, | |||
| const char * | org_table, | |||
| const char * | db, | |||
| unsigned long | length, | |||
| const char * | def, | |||
| const char * | file, | |||
| int | line | |||
| ) | [static] |
Definition at line 706 of file mysql_client_test.c.
References st_mysql_field::charsetnr, st_mysql_field::db, st_mysql_field::def, DIE_UNLESS, exit, get_charset(), st_mysql_field::length, st_mysql_field::max_length, charset_info_st::mbmaxlen, mysql_fetch_field_direct(), st_mysql_field::name, opt_silent, st_mysql_field::org_name, st_mysql_field::org_table, strcmp(), st_mysql_field::table, and st_mysql_field::type.
00714 { 00715 MYSQL_FIELD *field; 00716 CHARSET_INFO *cs; 00717 00718 if (!(field= mysql_fetch_field_direct(result, no))) 00719 { 00720 fprintf(stdout, "\n *** ERROR: FAILED TO GET THE RESULT ***"); 00721 exit(1); 00722 } 00723 cs= get_charset(field->charsetnr, 0); 00724 DIE_UNLESS(cs); 00725 if (!opt_silent) 00726 { 00727 fprintf(stdout, "\n field[%d]:", no); 00728 fprintf(stdout, "\n name :`%s`\t(expected: `%s`)", field->name, name); 00729 fprintf(stdout, "\n org_name :`%s`\t(expected: `%s`)", 00730 field->org_name, org_name); 00731 fprintf(stdout, "\n type :`%d`\t(expected: `%d`)", field->type, type); 00732 if (table) 00733 fprintf(stdout, "\n table :`%s`\t(expected: `%s`)", 00734 field->table, table); 00735 if (org_table) 00736 fprintf(stdout, "\n org_table:`%s`\t(expected: `%s`)", 00737 field->org_table, org_table); 00738 fprintf(stdout, "\n database :`%s`\t(expected: `%s`)", field->db, db); 00739 fprintf(stdout, "\n length :`%lu`\t(expected: `%lu`)", 00740 field->length, length * cs->mbmaxlen); 00741 fprintf(stdout, "\n maxlength:`%ld`", field->max_length); 00742 fprintf(stdout, "\n charsetnr:`%d`", field->charsetnr); 00743 fprintf(stdout, "\n default :`%s`\t(expected: `%s`)", 00744 field->def ? field->def : "(null)", def ? def: "(null)"); 00745 fprintf(stdout, "\n"); 00746 } 00747 DIE_UNLESS(strcmp(field->name, name) == 0); 00748 DIE_UNLESS(strcmp(field->org_name, org_name) == 0); 00749 /* 00750 XXX: silent column specification change works based on number of 00751 bytes a column occupies. So CHAR -> VARCHAR upgrade is possible even 00752 for CHAR(2) column if its character set is multibyte. 00753 VARCHAR -> CHAR downgrade won't work for VARCHAR(3) as one would 00754 expect. 00755 */ 00756 if (cs->mbmaxlen == 1) 00757 { 00758 if (field->type != type) 00759 { 00760 fprintf(stderr, 00761 "Expected field type: %d, got type: %d in file %s, line %d\n", 00762 (int) type, (int) field->type, file, line); 00763 DIE_UNLESS(field->type == type); 00764 } 00765 } 00766 if (table) 00767 DIE_UNLESS(strcmp(field->table, table) == 0); 00768 if (org_table) 00769 DIE_UNLESS(strcmp(field->org_table, org_table) == 0); 00770 DIE_UNLESS(strcmp(field->db, db) == 0); 00771 /* 00772 Character set should be taken into account for multibyte encodings, such 00773 as utf8. Field length is calculated as number of characters * maximum 00774 number of bytes a character can occupy. 00775 */ 00776 if (length && field->length != length * cs->mbmaxlen) 00777 { 00778 fprintf(stderr, "Expected field length: %d, got length: %d\n", 00779 (int) (length * cs->mbmaxlen), (int) field->length); 00780 DIE_UNLESS(field->length == length * cs->mbmaxlen); 00781 } 00782 if (def) 00783 DIE_UNLESS(strcmp(field->def, def) == 0); 00784 }
Here is the call graph for this function:

| static void execute_prepare_query | ( | const char * | query, | |
| ulonglong | exp_count | |||
| ) | [static] |
Definition at line 838 of file mysql_client_test.c.
References check_stmt, DIE_UNLESS, myquery, mysql, mysql_simple_prepare(), mysql_stmt_affected_rows(), mysql_stmt_close(), mysql_stmt_execute(), and opt_silent.
Referenced by test_prepare_grant().
00839 { 00840 MYSQL_STMT *stmt; 00841 ulonglong affected_rows; 00842 int rc; 00843 00844 stmt= mysql_simple_prepare(mysql, query); 00845 check_stmt(stmt); 00846 00847 rc= mysql_stmt_execute(stmt); 00848 myquery(rc); 00849 00850 affected_rows= mysql_stmt_affected_rows(stmt); 00851 if (!opt_silent) 00852 fprintf(stdout, "\n total affected rows: `%ld` (expected: `%ld`)", 00853 (long) affected_rows, (long) exp_count); 00854 00855 DIE_UNLESS(affected_rows == exp_count); 00856 mysql_stmt_close(stmt); 00857 }
Here is the call graph for this function:

Here is the caller graph for this function:

| my_bool fetch_n | ( | const char ** | query_list, | |
| unsigned | query_count, | |||
| enum fetch_type | fetch_type | |||
| ) |
Definition at line 1059 of file mysql_client_test.c.
References check_execute, DBUG_ENTER, DBUG_RETURN, free, st_stmt_fetch::handle, st_stmt_fetch::is_open, MYSQL_NO_DATA, mysql_stmt_error(), mysql_stmt_store_result(), opt_silent, st_stmt_fetch::query, st_stmt_fetch::row_count, stmt_fetch_close(), stmt_fetch_fetch_row(), stmt_fetch_init(), and USE_STORE_RESULT.
Referenced by test_basic_cursors(), and test_cursors_with_union().
01061 { 01062 unsigned open_statements= query_count; 01063 int rc, error_count= 0; 01064 Stmt_fetch *fetch_array= (Stmt_fetch*) calloc(1, sizeof(Stmt_fetch) * 01065 query_count); 01066 Stmt_fetch *fetch; 01067 DBUG_ENTER("fetch_n"); 01068 01069 for (fetch= fetch_array; fetch < fetch_array + query_count; ++fetch) 01070 { 01071 /* Init will exit(1) in case of error */ 01072 stmt_fetch_init(fetch, fetch - fetch_array, 01073 query_list[fetch - fetch_array]); 01074 } 01075 01076 if (fetch_type == USE_STORE_RESULT) 01077 { 01078 for (fetch= fetch_array; fetch < fetch_array + query_count; ++fetch) 01079 { 01080 rc= mysql_stmt_store_result(fetch->handle); 01081 check_execute(fetch->handle, rc); 01082 } 01083 } 01084 01085 while (open_statements) 01086 { 01087 for (fetch= fetch_array; fetch < fetch_array + query_count; ++fetch) 01088 { 01089 if (fetch->is_open && (rc= stmt_fetch_fetch_row(fetch))) 01090 { 01091 open_statements--; 01092 /* 01093 We try to fetch from the rest of the statements in case of 01094 error 01095 */ 01096 if (rc != MYSQL_NO_DATA) 01097 { 01098 fprintf(stderr, 01099 "Got error reading rows from statement %d,\n" 01100 "query is: %s,\n" 01101 "error message: %s", (int) (fetch - fetch_array), 01102 fetch->query, 01103 mysql_stmt_error(fetch->handle)); 01104 error_count++; 01105 } 01106 } 01107 } 01108 } 01109 if (error_count) 01110 fprintf(stderr, "Fetch FAILED"); 01111 else 01112 { 01113 unsigned total_row_count= 0; 01114 for (fetch= fetch_array; fetch < fetch_array + query_count; ++fetch) 01115 total_row_count+= fetch->row_count; 01116 if (!opt_silent) 01117 printf("Success, total rows fetched: %d\n", total_row_count); 01118 } 01119 for (fetch= fetch_array; fetch < fetch_array + query_count; ++fetch) 01120 stmt_fetch_close(fetch); 01121 free(fetch_array); 01122 DBUG_RETURN(error_count != 0); 01123 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void fill_tables | ( | const char ** | query_list, | |
| unsigned | query_count | |||
| ) |
Definition at line 906 of file mysql_client_test.c.
References DBUG_ENTER, DBUG_VOID_RETURN, myquery, mysql, and mysql_query().
Referenced by test_basic_cursors(), and test_bug21206().
00907 { 00908 int rc; 00909 const char **query; 00910 DBUG_ENTER("fill_tables"); 00911 for (query= query_list; query < query_list + query_count; 00912 ++query) 00913 { 00914 rc= mysql_query(mysql, *query); 00915 myquery(rc); 00916 } 00917 DBUG_VOID_RETURN; 00918 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static my_bool get_one_option | ( | int | optid, | |
| const struct my_option *opt | __attribute__((unused)), | |||
| char * | argument | |||
| ) | [static] |
Definition at line 15677 of file mysql_client_test.c.
References DBUG_PUSH, default_dbug_option, DIE, disabled_my_option, embedded_server_arg_count, embedded_server_args, exit, MAX_SERVER_ARGS, MY_ALLOW_ZERO_PTR, MY_FAE, my_free, my_strdup(), my_tests, MYF, my_tests_st::name, opt_password, opt_silent, opt_testcase, start(), tty_password, and usage().
15679 { 15680 switch (optid) { 15681 case '#': 15682 DBUG_PUSH(argument ? argument : default_dbug_option); 15683 break; 15684 case 'c': 15685 opt_testcase = 1; 15686 break; 15687 case 'p': 15688 if (argument) 15689 { 15690 char *start=argument; 15691 my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR)); 15692 opt_password= my_strdup(argument, MYF(MY_FAE)); 15693 while (*argument) *argument++= 'x'; /* Destroy argument */ 15694 if (*start) 15695 start[1]=0; 15696 } 15697 else 15698 tty_password= 1; 15699 break; 15700 case 's': 15701 if (argument == disabled_my_option) 15702 opt_silent= 0; 15703 else 15704 opt_silent++; 15705 break; 15706 case 'A': 15707 /* 15708 When the embedded server is being tested, the test suite needs to be 15709 able to pass command-line arguments to the embedded server so it can 15710 locate the language files and data directory. The test suite 15711 (mysql-test-run) never uses config files, just command-line options. 15712 */ 15713 if (!embedded_server_arg_count) 15714 { 15715 embedded_server_arg_count= 1; 15716 embedded_server_args[0]= (char*) ""; 15717 } 15718 if (embedded_server_arg_count == MAX_SERVER_ARGS-1 || 15719 !(embedded_server_args[embedded_server_arg_count++]= 15720 my_strdup(argument, MYF(MY_FAE)))) 15721 { 15722 DIE("Can't use server argument"); 15723 } 15724 break; 15725 case 'T': 15726 { 15727 struct my_tests_st *fptr; 15728 15729 printf("All possible test names:\n\n"); 15730 for (fptr= my_tests; fptr->name; fptr++) 15731 printf("%s\n", fptr->name); 15732 exit(0); 15733 break; 15734 } 15735 case '?': 15736 case 'I': /* Info */ 15737 usage(); 15738 exit(0); 15739 break; 15740 } 15741 return 0; 15742 }
Here is the call graph for this function:

| static void get_options | ( | int * | argc, | |
| char *** | argv | |||
| ) | [static] |
Definition at line 15744 of file mysql_client_test.c.
References client_test_long_options, exit, get_one_option(), get_tty_password(), handle_options(), NullS, opt_password, and tty_password.
15745 { 15746 int ho_error; 15747 15748 if ((ho_error= handle_options(argc, argv, client_test_long_options, 15749 get_one_option))) 15750 exit(ho_error); 15751 15752 if (tty_password) 15753 opt_password= get_tty_password(NullS); 15754 return; 15755 }
Here is the call graph for this function:

| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 15781 of file mysql_client_test.c.
References client_connect(), client_disconnect(), DIE, embedded_server_arg_count, embedded_server_args, embedded_server_groups, exit, free_defaults(), my_tests_st::function, get_options(), iter_count, load_defaults(), MY_INIT, my_progname, my_tests, mysql_server_init, my_tests_st::name, opt_count, start_time, strcmp(), test_count, and total_time.
15782 { 15783 struct my_tests_st *fptr; 15784 15785 MY_INIT(argv[0]); 15786 15787 load_defaults("my", client_test_load_default_groups, &argc, &argv); 15788 defaults_argv= argv; 15789 get_options(&argc, &argv); 15790 15791 if (mysql_server_init(embedded_server_arg_count, 15792 embedded_server_args, 15793 (char**) embedded_server_groups)) 15794 DIE("Can't initialize MySQL server"); 15795 15796 client_connect(0); /* connect to server */ 15797 15798 total_time= 0; 15799 for (iter_count= 1; iter_count <= opt_count; iter_count++) 15800 { 15801 /* Start of tests */ 15802 test_count= 1; 15803 start_time= time((time_t *)0); 15804 if (!argc) 15805 { 15806 for (fptr= my_tests; fptr->name; fptr++) 15807 (*fptr->function)(); 15808 } 15809 else 15810 { 15811 for ( ; *argv ; argv++) 15812 { 15813 for (fptr= my_tests; fptr->name; fptr++) 15814 { 15815 if (!strcmp(fptr->name, *argv)) 15816 { 15817 (*fptr->function)(); 15818 break; 15819 } 15820 } 15821 if (!fptr->name) 15822 { 15823 fprintf(stderr, "\n\nGiven test not found: '%s'\n", *argv); 15824 fprintf(stderr, "See legal test names with %s -T\n\nAborting!\n", 15825 my_progname); 15826 client_disconnect(); 15827 free_defaults(defaults_argv); 15828 exit(1); 15829 } 15830 } 15831 } 15832 15833 end_time= time((time_t *)0); 15834 total_time+= difftime(end_time, start_time); 15835 15836 /* End of tests */ 15837 } 15838 15839 client_disconnect(); /* disconnect from server */ 15840 15841 free_defaults(defaults_argv); 15842 print_test_output(); 15843 15844 while (embedded_server_arg_count > 1) 15845 my_free(embedded_server_args[--embedded_server_arg_count],MYF(0)); 15846 15847 mysql_server_end(); 15848 15849 my_end(0); 15850 15851 exit(0); 15852 }
Here is the call graph for this function:

| static void my_print_dashes | ( | MYSQL_RES * | result | ) | [static] |
Definition at line 400 of file mysql_client_test.c.
References st_mysql_field::max_length, mysql_fetch_field(), mysql_field_seek(), and mysql_num_fields().
Referenced by my_print_result_metadata(), my_process_result_set(), and my_process_stmt_result().
00401 { 00402 MYSQL_FIELD *field; 00403 unsigned int i, j; 00404 00405 mysql_field_seek(result, 0); 00406 fputc('\t', stdout); 00407 fputc('+', stdout); 00408 00409 for(i= 0; i< mysql_num_fields(result); i++) 00410 { 00411 field= mysql_fetch_field(result); 00412 for(j= 0; j < field->max_length+2; j++) 00413 fputc('-', stdout); 00414 fputc('+', stdout); 00415 } 00416 fputc('\n', stdout); 00417 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void my_print_result_metadata | ( | MYSQL_RES * | result | ) | [static] |
Definition at line 422 of file mysql_client_test.c.
References st_mysql_field::flags, IS_NOT_NULL, st_mysql_field::max_length, my_print_dashes(), mysql_fetch_field(), mysql_field_seek(), mysql_num_fields(), st_mysql_field::name, opt_silent, and strlen().
Referenced by my_process_result_set(), my_process_stmt_result(), test_prepare_field_result(), and test_prepare_resultset().
00423 { 00424 MYSQL_FIELD *field; 00425 unsigned int i, j; 00426 unsigned int field_count; 00427 00428 mysql_field_seek(result, 0); 00429 if (!opt_silent) 00430 { 00431 fputc('\n', stdout); 00432 fputc('\n', stdout); 00433 } 00434 00435 field_count= mysql_num_fields(result); 00436 for(i= 0; i< field_count; i++) 00437 { 00438 field= mysql_fetch_field(result); 00439 j= strlen(field->name); 00440 if (j < field->max_length) 00441 j= field->max_length; 00442 if (j < 4 && !IS_NOT_NULL(field->flags)) 00443 j= 4; 00444 field->max_length= j; 00445 } 00446 if (!opt_silent) 00447 { 00448 my_print_dashes(result); 00449 fputc('\t', stdout); 00450 fputc('|', stdout); 00451 } 00452 00453 mysql_field_seek(result, 0); 00454 for(i= 0; i< field_count; i++) 00455 { 00456 field= mysql_fetch_field(result); 00457 if (!opt_silent) 00458 fprintf(stdout, " %-*s |", (int) field->max_length, field->name); 00459 } 00460 if (!opt_silent) 00461 { 00462 fputc('\n', stdout); 00463 my_print_dashes(result); 00464 } 00465 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int my_process_result | ( | MYSQL * | mysql | ) |
Definition at line 526 of file mysql_client_test.c.
References my_process_result_set(), mysql, mysql_free_result(), and mysql_store_result().
Referenced by test_mem_overun().
00527 { 00528 MYSQL_RES *result; 00529 int row_count; 00530 00531 if (!(result= mysql_store_result(mysql))) 00532 return 0; 00533 00534 row_count= my_process_result_set(result); 00535 00536 mysql_free_result(result); 00537 return row_count; 00538 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int my_process_result_set | ( | MYSQL_RES * | result | ) |
Definition at line 470 of file mysql_client_test.c.
References IS_NUM, st_mysql_field::max_length, my_print_dashes(), my_print_result_metadata(), mysql, mysql_errno(), mysql_fetch_field(), mysql_fetch_row(), mysql_field_seek(), mysql_num_fields(), NULL, opt_silent, and st_mysql_field::type.
Referenced by client_store_result(), client_use_result(), my_process_result(), test_bug1644(), test_bug19671(), test_cuted_rows(), test_debug_example(), test_double_compare(), test_errors(), test_field_misc(), test_field_names(), test_frm_bug(), test_insert(), test_list_fields(), test_long_data(), test_long_data_bin(), test_long_data_str(), test_long_data_str1(), test_multi_statements(), test_open_direct(), test_prepare_noparam(), test_select_direct(), test_set_option(), test_simple_delete(), test_simple_update(), test_stmt_close(), test_tran_bdb(), test_tran_innodb(), test_update(), and test_warnings().
00471 { 00472 MYSQL_ROW row; 00473 MYSQL_FIELD *field; 00474 unsigned int i; 00475 unsigned int row_count= 0; 00476 00477 if (!result) 00478 return 0; 00479 00480 my_print_result_metadata(result); 00481 00482 while ((row= mysql_fetch_row(result)) != NULL) 00483 { 00484 mysql_field_seek(result, 0); 00485 if (!opt_silent) 00486 { 00487 fputc('\t', stdout); 00488 fputc('|', stdout); 00489 } 00490 00491 for(i= 0; i< mysql_num_fields(result); i++) 00492 { 00493 field= mysql_fetch_field(result); 00494 if (!opt_silent) 00495 { 00496 if (row[i] == NULL) 00497 fprintf(stdout, " %-*s |", (int) field->max_length, "NULL"); 00498 else if (IS_NUM(field->type)) 00499 fprintf(stdout, " %*s |", (int) field->max_length, row[i]); 00500 else 00501 fprintf(stdout, " %-*s |", (int) field->max_length, row[i]); 00502 } 00503 } 00504 if (!opt_silent) 00505 { 00506 fputc('\t', stdout); 00507 fputc('\n', stdout); 00508 } 00509 row_count++; 00510 } 00511 if (!opt_silent) 00512 { 00513 if (row_count) 00514 my_print_dashes(result); 00515 00516 if (mysql_errno(mysql) != 0) 00517 fprintf(stderr, "\n\tmysql_fetch_row() failed\n"); 00518 else 00519 fprintf(stdout, "\n\t%d %s returned\n", row_count, 00520 row_count == 1 ? "row" : "rows"); 00521 } 00522 return row_count; 00523 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int my_process_stmt_result | ( | MYSQL_STMT * | stmt | ) |
Definition at line 546 of file mysql_client_test.c.
References buffer, bzero, check_execute, data, DIE_UNLESS, IS_NUM, MAX_FIELD_DATA_SIZE, st_mysql_field::max_length, MAX_RES_FIELDS, min, my_print_dashes(), my_print_result_metadata(), mysql_fetch_field(), mysql_field_seek(), mysql_free_result(), MYSQL_NO_DATA, mysql_num_fields(), mysql_stmt_attr_set(), mysql_stmt_bind_result(), mysql_stmt_fetch(), mysql_stmt_result_metadata(), mysql_stmt_store_result(), MYSQL_TYPE_STRING, opt_silent, STMT_ATTR_UPDATE_MAX_LENGTH, and st_mysql_field::type.
Referenced by my_stmt_result(), test_bug1115(), test_bug1180(), test_bug1500(), test_create_drop(), test_derived(), test_distinct(), test_explain_bug(), test_field_misc(), test_insert_select(), test_join(), test_left_join_view(), test_multi(), test_prepare_ext(), test_ps_conj_select(), test_select(), test_select_prepare(), test_select_show(), test_select_show_table(), test_select_version(), test_selecttmp(), test_set_option(), test_subqueries(), test_subqueries_ref(), test_ts(), test_union(), test_union2(), test_union_param(), test_view(), test_view_2where(), test_view_insert(), test_view_insert_fields(), test_view_star(), test_view_where(), and test_xjoin().
00547 { 00548 int field_count; 00549 int row_count= 0; 00550 MYSQL_BIND buffer[MAX_RES_FIELDS]; 00551 MYSQL_FIELD *field; 00552 MYSQL_RES *result; 00553 char data[MAX_RES_FIELDS][MAX_FIELD_DATA_SIZE]; 00554 ulong length[MAX_RES_FIELDS]; 00555 my_bool is_null[MAX_RES_FIELDS]; 00556 int rc, i; 00557 00558 if (!(result= mysql_stmt_result_metadata(stmt))) /* No meta info */ 00559 { 00560 while (!mysql_stmt_fetch(stmt)) 00561 row_count++; 00562 return row_count; 00563 } 00564 00565 field_count= min(mysql_num_fields(result), MAX_RES_FIELDS); 00566 00567 bzero((char*) buffer, sizeof(buffer)); 00568 bzero((char*) length, sizeof(length)); 00569 bzero((char*) is_null, sizeof(is_null)); 00570 00571 for(i= 0; i < field_count; i++) 00572 { 00573 buffer[i].buffer_type= MYSQL_TYPE_STRING; 00574 buffer[i].buffer_length= MAX_FIELD_DATA_SIZE; 00575 buffer[i].length= &length[i]; 00576 buffer[i].buffer= (void *) data[i]; 00577 buffer[i].is_null= &is_null[i]; 00578 } 00579 00580 rc= mysql_stmt_bind_result(stmt, buffer); 00581 check_execute(stmt, rc); 00582 00583 rc= 1; 00584 mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void*)&rc); 00585 rc= mysql_stmt_store_result(stmt); 00586 check_execute(stmt, rc); 00587 my_print_result_metadata(result); 00588 00589 mysql_field_seek(result, 0); 00590 while ((rc= mysql_stmt_fetch(stmt)) == 0) 00591 { 00592 if (!opt_silent) 00593 { 00594 fputc('\t', stdout); 00595 fputc('|', stdout); 00596 } 00597 mysql_field_seek(result, 0); 00598 for (i= 0; i < field_count; i++) 00599 { 00600 field= mysql_fetch_field(result); 00601 if (!opt_silent) 00602 { 00603 if (is_null[i]) 00604 fprintf(stdout, " %-*s |", (int) field->max_length, "NULL"); 00605 else if (length[i] == 0) 00606 { 00607 data[i][0]= '\0'; /* unmodified buffer */ 00608 fprintf(stdout, " %*s |", (int) field->max_length, data[i]); 00609 } 00610 else if (IS_NUM(field->type)) 00611 fprintf(stdout, " %*s |", (int) field->max_length, data[i]); 00612 else 00613 fprintf(stdout, " %-*s |", (int) field->max_length, data[i]); 00614 } 00615 } 00616 if (!opt_silent) 00617 { 00618 fputc('\t', stdout); 00619 fputc('\n', stdout); 00620 } 00621 row_count++; 00622 } 00623 DIE_UNLESS(rc == MYSQL_NO_DATA); 00624 if (!opt_silent) 00625 { 00626 if (row_count) 00627 my_print_dashes(result); 00628 fprintf(stdout, "\n\t%d %s returned\n", row_count, 00629 row_count == 1 ? "row" : "rows"); 00630 } 00631 mysql_free_result(result); 00632 return row_count; 00633 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int my_stmt_result | ( | const char * | buff | ) |
Definition at line 638 of file mysql_client_test.c.
References check_execute, check_stmt, my_process_stmt_result(), mysql, mysql_simple_prepare(), mysql_stmt_close(), mysql_stmt_execute(), and opt_silent.
Referenced by bind_fetch(), test_bind_date_conv(), test_fetch_date(), test_fetch_null(), test_manual_sample(), test_multi_stmt(), test_null(), test_prepare(), test_prepare_alter(), test_prepare_grant(), and test_subselect().
00639 { 00640 MYSQL_STMT *stmt; 00641 int row_count; 00642 int rc; 00643 00644 if (!opt_silent) 00645 fprintf(stdout, "\n\n %s", buff); 00646 stmt= mysql_simple_prepare(mysql, buff); 00647 check_stmt(stmt); 00648 00649 rc= mysql_stmt_execute(stmt); 00650 check_execute(stmt, rc); 00651 00652 row_count= my_process_stmt_result(stmt); 00653 mysql_stmt_close(stmt); 00654 00655 return row_count; 00656 }
Here is the call graph for this function:

Here is the caller graph for this function:

| MYSQL_STMT* STDCALL mysql_simple_prepare | ( | MYSQL * | mysql, | |
| const char * | query | |||
| ) |
Definition at line 256 of file mysql_client_test.c.
References mysql, mysql_stmt_close(), mysql_stmt_init(), mysql_stmt_prepare(), and strlen().
Referenced by bind_fetch(), execute_prepare_query(), my_stmt_result(), test_bad_union(), test_bind_date_conv(), test_bind_nagative(), test_bind_result(), test_bind_result_ext(), test_bind_result_ext1(), test_buffers(), test_bug1115(), test_bug1180(), test_bug1500(), test_bug1644(), test_bug1946(), test_bug2247(), test_bug2248(), test_bug3117(), test_create_drop(), test_datetime_ranges(), test_decimal_bug(), test_derived(), test_distinct(), test_do_set(), test_double_compare(), test_explain_bug(), test_fetch_column(), test_fetch_date(), test_fetch_nobuffs(), test_fetch_null(), test_fetch_offset(), test_fetch_seek(), test_field_misc(), test_free_result(), test_free_store_result(), test_frm_bug(), test_insert(), test_insert_select(), test_join(), test_logs(), test_long_data(), test_long_data_bin(), test_long_data_str(), test_long_data_str1(), test_manual_sample(), test_mem_overun(), test_multi(), test_multi_stmt(), test_nstmts(), test_null(), test_open_direct(), test_order_param(), test_parse_error_and_bad_length(), test_prepare(), test_prepare_alter(), test_prepare_ext(), test_prepare_field_result(), test_prepare_grant(), test_prepare_insert_update(), test_prepare_multi_statements(), test_prepare_noparam(), test_prepare_resultset(), test_prepare_simple(), test_prepare_syntax(), test_ps_conj_select(), test_ps_null_param(), test_pure_coverage(), test_rename(), test_select(), test_select_prepare(), test_select_show(), test_select_show_table(), test_select_version(), test_selecttmp(), test_set_option(), test_set_variable(), test_simple_delete(), test_simple_update(), test_sqlmode(), test_sshort_bug(), test_stiny_bug(), test_stmt_close(), test_store_result(), test_store_result1(), test_store_result2(), test_subqueries(), test_subqueries_ref(), test_subselect(), test_ts(), test_union(), test_union2(), test_union_param(), test_update(), test_ushort_bug(), and test_xjoin().
00257 { 00258 MYSQL_STMT *stmt= mysql_stmt_init(mysql); 00259 if (stmt && mysql_stmt_prepare(stmt, query, strlen(query))) 00260 { 00261 mysql_stmt_close(stmt); 00262 return 0; 00263 } 00264 return stmt; 00265 }
Here is the call graph for this function:

Here is the caller graph for this function:

| MYSQL_STMT* open_cursor | ( | const char * | query | ) |
Definition at line 12964 of file mysql_client_test.c.
References check_execute, CURSOR_TYPE_READ_ONLY, mysql, mysql_stmt_attr_set(), mysql_stmt_init(), mysql_stmt_prepare(), STMT_ATTR_CURSOR_TYPE, and strlen().
Referenced by test_bug11901(), test_bug11909(), test_bug8880(), test_bug9478(), and test_bug9520().
12965 { 12966 int rc; 12967 const ulong type= (ulong)CURSOR_TYPE_READ_ONLY; 12968 12969 MYSQL_STMT *stmt= mysql_stmt_init(mysql); 12970 rc= mysql_stmt_prepare(stmt, query, strlen(query)); 12971 check_execute(stmt, rc); 12972 12973 mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type); 12974 return stmt; 12975 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void print_error | ( | const char * | msg | ) | [static] |
Definition at line 190 of file mysql_client_test.c.
References mysql, mysql_errno(), mysql_error(), opt_silent, and st_mysql::server_version.
00191 { 00192 if (!opt_silent) 00193 { 00194 if (mysql && mysql_errno(mysql)) 00195 { 00196 if (mysql->server_version) 00197 fprintf(stdout, "\n [MySQL-%s]", mysql->server_version); 00198 else 00199 fprintf(stdout, "\n [MySQL]"); 00200 fprintf(stdout, "[%d] %s\n", mysql_errno(mysql), mysql_error(mysql)); 00201 } 00202 else if (msg) 00203 fprintf(stderr, " [MySQL] %s\n", msg); 00204 } 00205 }
Here is the call graph for this function:

| static void print_st_error | ( | MYSQL_STMT * | stmt, | |
| const char * | msg | |||
| ) | [static] |
Definition at line 208 of file mysql_client_test.c.
References st_mysql_stmt::mysql, mysql_stmt_errno(), mysql_stmt_error(), opt_silent, and st_mysql::server_version.
00209 { 00210 if (!opt_silent) 00211 { 00212 if (stmt && mysql_stmt_errno(stmt)) 00213 { 00214 if (stmt->mysql && stmt->mysql->server_version) 00215 fprintf(stdout, "\n [MySQL-%s]", stmt->mysql->server_version); 00216 else 00217 fprintf(stdout, "\n [MySQL]"); 00218 00219 fprintf(stdout, "[%d] %s\n", mysql_stmt_errno(stmt), 00220 mysql_stmt_error(stmt)); 00221 } 00222 else if (msg) 00223 fprintf(stderr, " [MySQL] %s\n", msg); 00224 } 00225 }
Here is the call graph for this function:

| static void print_test_output | ( | ) | [static] |
Definition at line 15761 of file mysql_client_test.c.
References opt_count, opt_silent, test_count, and total_time.
15762 { 15763 if (opt_silent < 3) 15764 { 15765 fprintf(stdout, "\n\n"); 15766 fprintf(stdout, "All '%d' tests were successful (in '%d' iterations)", 15767 test_count-1, opt_count); 15768 fprintf(stdout, "\n Total execution time: %g SECS", total_time); 15769 if (opt_count > 1) 15770 fprintf(stdout, " (Avg: %g SECS)", total_time/opt_count); 15771 15772 fprintf(stdout, "\n\n!!! SUCCESS !!!\n"); 15773 } 15774 }
| void stmt_fetch_close | ( | Stmt_fetch * | fetch | ) |
Definition at line 1036 of file mysql_client_test.c.
References st_stmt_fetch::bind_array, st_stmt_fetch::column_count, DBUG_ENTER, DBUG_VOID_RETURN, free, st_stmt_fetch::handle, mysql_stmt_close(), st_stmt_fetch::out_data, and st_stmt_fetch::out_data_length.
Referenced by fetch_n(), and test_bug21206().
01037 { 01038 unsigned i; 01039 DBUG_ENTER("stmt_fetch_close"); 01040 01041 for (i= 0; i < fetch->column_count; ++i) 01042 free(fetch->out_data[i]); 01043 free(fetch->out_data); 01044 free(fetch->out_data_length); 01045 free(fetch->bind_array); 01046 mysql_stmt_close(fetch->handle); 01047 DBUG_VOID_RETURN; 01048 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int stmt_fetch_fetch_row | ( | Stmt_fetch * | fetch | ) |
Definition at line 1012 of file mysql_client_test.c.
References st_stmt_fetch::column_count, DBUG_ENTER, DBUG_RETURN, FALSE, st_stmt_fetch::handle, st_stmt_fetch::is_open, mysql_stmt_fetch(), opt_silent, st_stmt_fetch::out_data, st_stmt_fetch::out_data_length, st_stmt_fetch::row_count, and st_stmt_fetch::stmt_no.
Referenced by fetch_n().
01013 { 01014 int rc; 01015 unsigned i; 01016 DBUG_ENTER("stmt_fetch_fetch_row"); 01017 01018 if ((rc= mysql_stmt_fetch(fetch->handle)) == 0) 01019 { 01020 ++fetch->row_count; 01021 if (!opt_silent) 01022 printf("Stmt %d fetched row %d:\n", fetch->stmt_no, fetch->row_count); 01023 for (i= 0; i < fetch->column_count; ++i) 01024 { 01025 fetch->out_data[i][fetch->out_data_length[i]]= '\0'; 01026 if (!opt_silent) 01027 printf("column %d: %s\n", i+1, fetch->out_data[i]); 01028 } 01029 } 01030 else 01031 fetch->is_open= FALSE; 01032 DBUG_RETURN(rc); 01033 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void stmt_fetch_init | ( | Stmt_fetch * | fetch, | |
| unsigned | stmt_no_arg, | |||
| const char * | query_arg | |||
| ) |
Definition at line 947 of file mysql_client_test.c.
References st_stmt_fetch::bind_array, st_mysql_bind::buffer, st_mysql_bind::buffer_length, st_mysql_bind::buffer_type, check_execute, st_stmt_fetch::column_count, CURSOR_TYPE_READ_ONLY, DBUG_ENTER, DBUG_VOID_RETURN, st_stmt_fetch::handle, st_stmt_fetch::is_open, st_mysql_bind::length, MAX_COLUMN_LENGTH, mysql, mysql_free_result(), mysql_num_fields(), mysql_stmt_attr_set(), mysql_stmt_bind_result(), mysql_stmt_execute(), mysql_stmt_init(), mysql_stmt_prepare(), mysql_stmt_result_metadata(), MYSQL_TYPE_STRING, st_stmt_fetch::out_data, st_stmt_fetch::out_data_length, st_stmt_fetch::query, st_stmt_fetch::row_count, STMT_ATTR_CURSOR_TYPE, st_stmt_fetch::stmt_no, strlen(), and TRUE.
Referenced by fetch_n(), and test_bug21206().
00949 { 00950 unsigned long type= CURSOR_TYPE_READ_ONLY; 00951 int rc; 00952 unsigned i; 00953 MYSQL_RES *metadata; 00954 DBUG_ENTER("stmt_fetch_init"); 00955 00956 /* Save query and statement number for error messages */ 00957 fetch->stmt_no= stmt_no_arg; 00958 fetch->query= query_arg; 00959 00960 fetch->handle= mysql_stmt_init(mysql); 00961 00962 rc= mysql_stmt_prepare(fetch->handle, fetch->query, strlen(fetch->query)); 00963 check_execute(fetch->handle, rc); 00964 00965 /* 00966 The attribute is sent to server on execute and asks to open read-only 00967 for result set 00968 */ 00969 mysql_stmt_attr_set(fetch->handle, STMT_ATTR_CURSOR_TYPE, 00970 (const void*) &type); 00971 00972 rc= mysql_stmt_execute(fetch->handle); 00973 check_execute(fetch->handle, rc); 00974 00975 /* Find out total number of columns in result set */ 00976 metadata= mysql_stmt_result_metadata(fetch->handle); 00977 fetch->column_count= mysql_num_fields(metadata); 00978 mysql_free_result(metadata); 00979 00980 /* 00981 Now allocate bind handles and buffers for output data: 00982 calloc memory to reduce number of MYSQL_BIND members we need to 00983 set up. 00984 */ 00985 00986 fetch->bind_array= (MYSQL_BIND *) calloc(1, sizeof(MYSQL_BIND) * 00987 fetch->column_count); 00988 fetch->out_data= (char**) calloc(1, sizeof(char*) * fetch->column_count); 00989 fetch->out_data_length= (ulong*) calloc(1, sizeof(ulong) * 00990 fetch->column_count); 00991 for (i= 0; i < fetch->column_count; ++i) 00992 { 00993 fetch->out_data[i]= (char*) calloc(1, MAX_COLUMN_LENGTH); 00994 fetch->bind_array[i].buffer_type= MYSQL_TYPE_STRING; 00995 fetch->bind_array[i].buffer= fetch->out_data[i]; 00996 fetch->bind_array[i].buffer_length= MAX_COLUMN_LENGTH; 00997 fetch->bind_array[i].length= fetch->out_data_length + i; 00998 } 00999 01000 mysql_stmt_bind_result(fetch->handle, fetch->bind_array); 01001 01002 fetch->row_count= 0; 01003 fetch->is_open= TRUE; 01004 01005 /* Ready for reading rows */ 01006 DBUG_VOID_RETURN; 01007 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void test_bad_union | ( | ) | [static] |
Definition at line 9159 of file mysql_client_test.c.
References DIE_UNLESS, myerror, myheader, mysql, mysql_simple_prepare(), and NULL.
09160 { 09161 MYSQL_STMT *stmt; 09162 const char *query= "SELECT 1, 2 union SELECT 1"; 09163 09164 myheader("test_bad_union"); 09165 09166 stmt= mysql_simple_prepare(mysql, query); 09167 DIE_UNLESS(stmt == 0); 09168 myerror(NULL); 09169 }
Here is the call graph for this function:

| static void test_basic_cursors | ( | ) | [static] |
Definition at line 11922 of file mysql_client_test.c.
References DBUG_ENTER, DBUG_VOID_RETURN, fetch_n(), fill_tables(), myheader, queries, USE_ROW_BY_ROW_FETCH, and USE_STORE_RESULT.
11923 { 11924 const char *basic_tables[]= 11925 { 11926 "DROP TABLE IF EXISTS t1, t2", 11927 11928 "CREATE TABLE t1 " 11929 "(id INTEGER NOT NULL PRIMARY KEY, " 11930 " name VARCHAR(20) NOT NULL)", 11931 11932 "INSERT INTO t1 (id, name) VALUES " 11933 " (2, 'Ja'), (3, 'Ede'), " 11934 " (4, 'Haag'), (5, 'Kabul'), " 11935 " (6, 'Almere'), (7, 'Utrecht'), " 11936 " (8, 'Qandahar'), (9, 'Amsterdam'), " 11937 " (10, 'Amersfoort'), (11, 'Constantine')", 11938 11939 "CREATE TABLE t2 " 11940 "(id INTEGER NOT NULL PRIMARY KEY, " 11941 " name VARCHAR(20) NOT NULL)", 11942 11943 "INSERT INTO t2 (id, name) VALUES " 11944 " (4, 'Guam'), (5, 'Aruba'), " 11945 " (6, 'Angola'), (7, 'Albania'), " 11946 " (8, 'Anguilla'), (9, 'Argentina'), " 11947 " (10, 'Azerbaijan'), (11, 'Afghanistan'), " 11948 " (12, 'Burkina Faso'), (13, 'Faroe Islands')" 11949 }; 11950 const char *queries[]= 11951 { 11952 "SELECT * FROM t1", 11953 "SELECT * FROM t2" 11954 }; 11955 11956 DBUG_ENTER("test_basic_cursors"); 11957 myheader("test_basic_cursors"); 11958 11959 fill_tables(basic_tables, sizeof(basic_tables)/sizeof(*basic_tables)); 11960 11961 fetch_n(queries, sizeof(queries)/sizeof(*queries), USE_ROW_BY_ROW_FETCH); 11962 fetch_n(queries, sizeof(queries)/sizeof(*queries), USE_STORE_RESULT); 11963 DBUG_VOID_RETURN; 11964 }
Here is the call graph for this function:

| static void test_bind_date_conv | ( | uint | row_count | ) | [static] |
Definition at line 6079 of file mysql_client_test.c.
References array_elements, buffer, bzero, check_execute, check_stmt, count, st_mysql_time::day, DIE_UNLESS, st_mysql_time::hour, int(), st_mysql_time::minute, st_mysql_time::month, my_stmt_result(), myquery, mysql, mysql_commit(), MYSQL_DATA_TRUNCATED, MYSQL_NO_DATA, mysql_simple_prepare(), mysql_stmt_bind_param(), mysql_stmt_bind_result(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_store_result(), MYSQL_TYPE_DATE, MYSQL_TYPE_DATETIME, MYSQL_TYPE_TIME, MYSQL_TYPE_TIMESTAMP, opt_silent, sec, st_mysql_time::second, st_mysql_time::second_part, verify_param_count(), and st_mysql_time::year.
Referenced by test_date(), test_date_date(), test_date_dt(), test_date_time(), and test_date_ts().
06080 { 06081 MYSQL_STMT *stmt= 0; 06082 uint rc, i, count= row_count; 06083 ulong length[4]; 06084 MYSQL_BIND bind[4]; 06085 my_bool is_null[4]= {0}; 06086 MYSQL_TIME tm[4]; 06087 ulong second_part; 06088 uint year, month, day, hour, minute, sec; 06089 06090 stmt= mysql_simple_prepare(mysql, "INSERT INTO test_date VALUES(?, ?, ?, ?)"); 06091 check_stmt(stmt); 06092 06093 verify_param_count(stmt, 4); 06094 06095 /* 06096 We need to bzero bind structure because mysql_stmt_bind_param checks all 06097 its members. 06098 */ 06099 bzero((char*) bind, sizeof(bind)); 06100 06101 bind[0].buffer_type= MYSQL_TYPE_TIMESTAMP; 06102 bind[1].buffer_type= MYSQL_TYPE_TIME; 06103 bind[2].buffer_type= MYSQL_TYPE_DATETIME; 06104 bind[3].buffer_type= MYSQL_TYPE_DATE; 06105 06106 for (i= 0; i < (int) array_elements(bind); i++) 06107 { 06108 bind[i].buffer= (void *) &tm[i]; 06109 bind[i].is_null= &is_null[i]; 06110 bind[i].length= &length[i]; 06111 bind[i].buffer_length= 30; 06112 length[i]= 20; 06113 } 06114 06115 second_part= 0; 06116 06117 year= 2000; 06118 month= 01; 06119 day= 10; 06120 06121 hour= 11; 06122 minute= 16; 06123 sec= 20; 06124 06125 rc= mysql_stmt_bind_param(stmt, bind); 06126 check_execute(stmt, rc); 06127 06128 for (count= 0; count < row_count; count++) 06129 { 06130 for (i= 0; i < (int) array_elements(bind); i++) 06131 { 06132 tm[i].neg= 0; 06133 tm[i].second_part= second_part+count; 06134 if (bind[i].buffer_type != MYSQL_TYPE_TIME) 06135 { 06136 tm[i].year= year+count; 06137 tm[i].month= month+count; 06138 tm[i].day= day+count; 06139 } 06140 else 06141 tm[i].year= tm[i].month= tm[i].day= 0; 06142 if (bind[i].buffer_type != MYSQL_TYPE_DATE) 06143 { 06144 tm[i].hour= hour+count; 06145 tm[i].minute= minute+count; 06146 tm[i].second= sec+count; 06147 } 06148 else 06149 tm[i].hour= tm[i].minute= tm[i].second= 0; 06150 } 06151 rc= mysql_stmt_execute(stmt); 06152 check_execute(stmt, rc); 06153 } 06154 06155 rc= mysql_commit(mysql); 06156 myquery(rc); 06157 06158 mysql_stmt_close(stmt); 06159 06160 rc= my_stmt_result("SELECT * FROM test_date"); 06161 DIE_UNLESS(row_count == rc); 06162 06163 stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_date"); 06164 check_stmt(stmt); 06165 06166 rc= mysql_stmt_bind_result(stmt, bind); 06167 check_execute(stmt, rc); 06168 06169 rc= mysql_stmt_execute(stmt); 06170 check_execute(stmt, rc); 06171 06172 rc= mysql_stmt_store_result(stmt); 06173 check_execute(stmt, rc); 06174 06175 for (count= 0; count < row_count; count++) 06176 { 06177 rc= mysql_stmt_fetch(stmt); 06178 DIE_UNLESS(rc == 0 || rc == MYSQL_DATA_TRUNCATED); 06179 06180 if (!opt_silent) 06181 fprintf(stdout, "\n"); 06182 for (i= 0; i < array_elements(bind); i++) 06183 { 06184 if (!opt_silent) 06185 fprintf(stdout, "\ntime[%d]: %02d-%02d-%02d %02d:%02d:%02d.%02lu", 06186 i, tm[i].year, tm[i].month, tm[i].day, 06187 tm[i].hour, tm[i].minute, tm[i].second, 06188 tm[i].second_part); 06189 DIE_UNLESS(tm[i].year == 0 || tm[i].year == year+count); 06190 DIE_UNLESS(tm[i].month == 0 || tm[i].month == month+count); 06191 DIE_UNLESS(tm[i].day == 0 || tm[i].day == day+count); 06192 06193 DIE_UNLESS(tm[i].hour == 0 || tm[i].hour == hour+count); 06194 DIE_UNLESS(tm[i].minute == 0 || tm[i].minute == minute+count); 06195 DIE_UNLESS(tm[i].second == 0 || tm[i].second == sec+count); 06196 DIE_UNLESS(tm[i].second_part == 0 || 06197 tm[i].second_part == second_part+count); 06198 } 06199 } 06200 rc= mysql_stmt_fetch(stmt); 06201 DIE_UNLESS(rc == MYSQL_NO_DATA); 06202 06203 mysql_stmt_close(stmt); 06204 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void test_bind_nagative | ( | ) | [static] |
Definition at line 9822 of file mysql_client_test.c.
References bzero, check_execute, check_stmt, FALSE, myheader, myquery, mysql, mysql_query(), mysql_simple_prepare(), mysql_stmt_bind_param(), mysql_stmt_close(), mysql_stmt_execute(), and MYSQL_TYPE_LONG.
09823 { 09824 MYSQL_STMT *stmt_insert; 09825 char *query; 09826 int rc; 09827 MYSQL_BIND bind[1]; 09828 int32 my_val= 0; 09829 ulong my_length= 0L; 09830 my_bool my_null= FALSE; 09831 myheader("test_insert_select"); 09832 09833 rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); 09834 myquery(rc); 09835 09836 rc= mysql_query(mysql, "create temporary table t1 (c1 int unsigned)"); 09837 myquery(rc); 09838 09839 rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1), (-1)"); 09840 myquery(rc); 09841 09842 query= (char*)"INSERT INTO t1 VALUES (?)"; 09843 stmt_insert= mysql_simple_prepare(mysql, query); 09844 check_stmt(stmt_insert); 09845 09846 /* bind parameters */ 09847 bzero((char*) bind, sizeof(bind)); 09848 09849 bind[0].buffer_type= MYSQL_TYPE_LONG; 09850 bind[0].buffer= (void *)&my_val; 09851 bind[0].length= &my_length; 09852 bind[0].is_null= (char*)&my_null; 09853 09854 rc= mysql_stmt_bind_param(stmt_insert, bind); 09855 check_execute(stmt_insert, rc); 09856 09857 my_val= -1; 09858 rc= mysql_stmt_execute(stmt_insert); 09859 check_execute(stmt_insert, rc); 09860 09861 mysql_stmt_close(stmt_insert); 09862 rc= mysql_query(mysql, "drop table t1"); 09863 myquery(rc); 09864 }
Here is the call graph for this function:

| static void test_bind_result | ( | ) | [static] |
Definition at line 3454 of file mysql_client_test.c.
References bzero, check_execute, check_stmt, DIE_UNLESS, myheader, myquery, mysql, mysql_commit(), MYSQL_NO_DATA, mysql_query(), mysql_simple_prepare(), mysql_stmt_bind_result(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), MYSQL_TYPE_LONG, MYSQL_TYPE_STRING, opt_silent, and strcmp().
03455 { 03456 MYSQL_STMT *stmt; 03457 int rc; 03458 int nData; 03459 ulong length1; 03460 char szData[100]; 03461 MYSQL_BIND bind[2]; 03462 my_bool is_null[2]; 03463 03464 myheader("test_bind_result"); 03465 03466 rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result"); 03467 myquery(rc); 03468 03469 rc= mysql_query(mysql, "CREATE TABLE test_bind_result(col1 int , col2 varchar(50))"); 03470 myquery(rc); 03471 03472 rc= mysql_query(mysql, "INSERT INTO test_bind_result VALUES(10, 'venu')"); 03473 myquery(rc); 03474 03475 rc= mysql_query(mysql, "INSERT INTO test_bind_result VALUES(20, 'MySQL')"); 03476 myquery(rc); 03477 03478 rc= mysql_query(mysql, "INSERT INTO test_bind_result(col2) VALUES('monty')"); 03479 myquery(rc); 03480 03481 rc= mysql_commit(mysql); 03482 myquery(rc); 03483 03484 /* fetch */ 03485 03486 bzero((char*) bind, sizeof(bind)); 03487 bind[0].buffer_type= MYSQL_TYPE_LONG; 03488 bind[0].buffer= (void *) &nData; /* integer data */ 03489 bind[0].is_null= &is_null[0]; 03490 03491 bind[1].buffer_type= MYSQL_TYPE_STRING; 03492 bind[1].buffer= szData; /* string data */ 03493 bind[1].buffer_length= sizeof(szData); 03494 bind[1].length= &length1; 03495 bind[1].is_null= &is_null[1]; 03496 03497 stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_bind_result"); 03498 check_stmt(stmt); 03499 03500 rc= mysql_stmt_bind_result(stmt, bind); 03501 check_execute(stmt, rc); 03502 03503 rc= mysql_stmt_execute(stmt); 03504 check_execute(stmt, rc); 03505 03506 rc= mysql_stmt_fetch(stmt); 03507 check_execute(stmt, rc); 03508 03509 if (!opt_silent) 03510 fprintf(stdout, "\n row 1: %d, %s(%lu)", nData, szData, length1); 03511 DIE_UNLESS(nData == 10); 03512 DIE_UNLESS(strcmp(szData, "venu") == 0); 03513 DIE_UNLESS(length1 == 4); 03514 03515 rc= mysql_stmt_fetch(stmt); 03516 check_execute(stmt, rc); 03517 03518 if (!opt_silent) 03519 fprintf(stdout, "\n row 2: %d, %s(%lu)", nData, szData, length1); 03520 DIE_UNLESS(nData == 20); 03521 DIE_UNLESS(strcmp(szData, "MySQL") == 0); 03522 DIE_UNLESS(length1 == 5); 03523 03524 rc= mysql_stmt_fetch(stmt); 03525 check_execute(stmt, rc); 03526 03527 if (!opt_silent && is_null[0]) 03528 fprintf(stdout, "\n row 3: NULL, %s(%lu)", szData, length1); 03529 DIE_UNLESS(is_null[0]); 03530 DIE_UNLESS(strcmp(szData, "monty") == 0); 03531 DIE_UNLESS(length1 == 5); 03532 03533 rc= mysql_stmt_fetch(stmt); 03534 DIE_UNLESS(rc == MYSQL_NO_DATA); 03535 03536 mysql_stmt_close(stmt); 03537 }
Here is the call graph for this function:

| static void test_bind_result_ext | ( | ) | [static] |
Definition at line 3542 of file mysql_client_test.c.
References array_elements, bzero, check_execute, check_stmt, DIE_UNLESS, int(), llstr(), myheader, myquery, mysql, mysql_commit(), MYSQL_NO_DATA, mysql_query(), mysql_simple_prepare(), mysql_stmt_bind_result(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), MYSQL_TYPE_DOUBLE, MYSQL_TYPE_FLOAT, MYSQL_TYPE_LONG, MYSQL_TYPE_LONGLONG, MYSQL_TYPE_SHORT, MYSQL_TYPE_STRING, MYSQL_TYPE_TINY, MYSQL_TYPE_TINY_BLOB, opt_silent, and strcmp().
03543 { 03544 MYSQL_STMT *stmt; 03545 int rc, i; 03546 uchar t_data; 03547 short s_data; 03548 int i_data; 03549 longlong b_data; 03550 float f_data; 03551 double d_data; 03552 char szData[20], bData[20]; 03553 ulong szLength, bLength; 03554 MYSQL_BIND bind[8]; 03555 ulong length[8]; 03556 my_bool is_null[8]; 03557 char llbuf[22]; 03558 myheader("test_bind_result_ext"); 03559 03560 rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result"); 03561 myquery(rc); 03562 03563 rc= mysql_query(mysql, "CREATE TABLE test_bind_result(c1 tinyint, " 03564 " c2 smallint, " 03565 " c3 int, c4 bigint, " 03566 " c5 float, c6 double, " 03567 " c7 varbinary(10), " 03568 " c8 varchar(50))"); 03569 myquery(rc); 03570 03571 rc= mysql_query(mysql, "INSERT INTO test_bind_result " 03572 "VALUES (19, 2999, 3999, 4999999, " 03573 " 2345.6, 5678.89563, 'venu', 'mysql')"); 03574 myquery(rc); 03575 03576 rc= mysql_commit(mysql); 03577 myquery(rc); 03578 03579 bzero((char*) bind, sizeof(bind)); 03580 for (i= 0; i < (int) array_elements(bind); i++) 03581 { 03582 bind[i].length= &length[i]; 03583 bind[i].is_null= &is_null[i]; 03584 } 03585 03586 bind[0].buffer_type= MYSQL_TYPE_TINY; 03587 bind[0].buffer= (void *)&t_data; 03588 03589 bind[1].buffer_type= MYSQL_TYPE_SHORT; 03590 bind[2].buffer_type= MYSQL_TYPE_LONG; 03591 03592 bind[3].buffer_type= MYSQL_TYPE_LONGLONG; 03593 bind[1].buffer= (void *)&s_data; 03594 03595 bind[2].buffer= (void *)&i_data; 03596 bind[3].buffer= (void *)&b_data; 03597 03598 bind[4].buffer_type= MYSQL_TYPE_FLOAT; 03599 bind[4].buffer= (void *)&f_data; 03600 03601 bind[5].buffer_type= MYSQL_TYPE_DOUBLE; 03602 bind[5].buffer= (void *)&d_data; 03603 03604 bind[6].buffer_type= MYSQL_TYPE_STRING; 03605 bind[6].buffer= (void *)szData; 03606 bind[6].buffer_length= sizeof(szData); 03607 bind[6].length= &szLength; 03608 03609 bind[7].buffer_type= MYSQL_TYPE_TINY_BLOB; 03610 bind[7].buffer= (void *)&bData; 03611 bind[7].length= &bLength; 03612 bind[7].buffer_length= sizeof(bData); 03613 03614 stmt= mysql_simple_prepare(mysql, "select * from test_bind_result"); 03615 check_stmt(stmt); 03616 03617 rc= mysql_stmt_bind_result(stmt, bind); 03618 check_execute(stmt, rc); 03619 03620 rc= mysql_stmt_execute(stmt); 03621 check_execute(stmt, rc); 03622 03623 rc= mysql_stmt_fetch(stmt); 03624 check_execute(stmt, rc); 03625 03626 if (!opt_silent) 03627 { 03628 fprintf(stdout, "\n data (tiny) : %d", t_data); 03629 fprintf(stdout, "\n data (short) : %d", s_data); 03630 fprintf(stdout, "\n data (int) : %d", i_data); 03631 fprintf(stdout, "\n data (big) : %s", llstr(b_data, llbuf)); 03632 03633 fprintf(stdout, "\n data (float) : %f", f_data); 03634 fprintf(stdout, "\n data (double) : %f", d_data); 03635 03636 fprintf(stdout, "\n data (str) : %s(%lu)", szData, szLength); 03637 03638 bData[bLength]= '\0'; /* bData is binary */ 03639 fprintf(stdout, "\n data (bin) : %s(%lu)", bData, bLength); 03640 } 03641 03642 DIE_UNLESS(t_data == 19); 03643 DIE_UNLESS(s_data == 2999); 03644 DIE_UNLESS(i_data == 3999); 03645 DIE_UNLESS(b_data == 4999999); 03646 /*DIE_UNLESS(f_data == 2345.60);*/ 03647 /*DIE_UNLESS(d_data == 5678.89563);*/ 03648 DIE_UNLESS(strcmp(szData, "venu") == 0); 03649 DIE_UNLESS(strncmp(bData, "mysql", 5) == 0); 03650 DIE_UNLESS(szLength == 4); 03651 DIE_UNLESS(bLength == 5); 03652 03653 rc= mysql_stmt_fetch(stmt); 03654 DIE_UNLESS(rc == MYSQL_NO_DATA); 03655 03656 mysql_stmt_close(stmt); 03657 }
Here is the call graph for this function:

| static void test_bind_result_ext1 | ( | ) | [static] |
Definition at line 3662 of file mysql_client_test.c.
References array_elements, bzero, check_execute, check_stmt, DIE_UNLESS, myheader, myquery, mysql, mysql_commit(), MYSQL_NO_DATA, mysql_query(), mysql_simple_prepare(), mysql_stmt_bind_result(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), MYSQL_TYPE_DOUBLE, MYSQL_TYPE_FLOAT, MYSQL_TYPE_LONG, MYSQL_TYPE_SHORT, MYSQL_TYPE_STRING, MYSQL_TYPE_TINY, opt_silent, and strcmp().
03663 { 03664 MYSQL_STMT *stmt; 03665 uint i; 03666 int rc; 03667 char t_data[20]; 03668 float s_data; 03669 short i_data; 03670 uchar b_data; 03671 int f_data; 03672 long bData; 03673 char d_data[20]; 03674 double szData; 03675 MYSQL_BIND bind[8]; 03676 ulong length[8]; 03677 my_bool is_null[8]; 03678 myheader("test_bind_result_ext1"); 03679 03680 rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result"); 03681 myquery(rc); 03682 03683 rc= mysql_query(mysql, "CREATE TABLE test_bind_result(c1 tinyint, c2 smallint, \ 03684 c3 int, c4 bigint, \ 03685 c5 float, c6 double, \ 03686 c7 varbinary(10), \ 03687 c8 varchar(10))"); 03688 myquery(rc); 03689 03690 rc= mysql_query(mysql, "INSERT INTO test_bind_result VALUES(120, 2999, 3999, 54, \ 03691 2.6, 58.89, \ 03692 '206', '6.7')"); 03693 myquery(rc); 03694 03695 rc= mysql_commit(mysql); 03696 myquery(rc); 03697 03698 bzero((char*) bind, sizeof(bind)); 03699 bind[0].buffer_type= MYSQL_TYPE_STRING; 03700 bind[0].buffer= (void *) t_data; 03701 bind[0].buffer_length= sizeof(t_data); 03702 bind[0].error= &bind[0].error_value; 03703 03704 bind[1].buffer_type= MYSQL_TYPE_FLOAT; 03705 bind[1].buffer= (void *)&s_data; 03706 bind[1].buffer_length= 0; 03707 bind[1].error= &bind[1].error_value; 03708 03709 bind[2].buffer_type= MYSQL_TYPE_SHORT; 03710 bind[2].buffer= (void *)&i_data; 03711 bind[2].buffer_length= 0; 03712 bind[2].error= &bind[2].error_value; 03713 03714 bind[3].buffer_type= MYSQL_TYPE_TINY; 03715 bind[3].buffer= (void *)&b_data; 03716 bind[3].buffer_length= 0; 03717 bind[3].error= &bind[3].error_value; 03718 03719 bind[4].buffer_type= MYSQL_TYPE_LONG; 03720 bind[4].buffer= (void *)&f_data; 03721 bind[4].buffer_length= 0; 03722 bind[4].error= &bind[4].error_value; 03723 03724 bind[5].buffer_type= MYSQL_TYPE_STRING; 03725 bind[5].buffer= (void *)d_data; 03726 bind[5].buffer_length= sizeof(d_data); 03727 bind[5].error= &bind[5].error_value; 03728 03729 bind[6].buffer_type= MYSQL_TYPE_LONG; 03730 bind[6].buffer= (void *)&bData; 03731 bind[6].buffer_length= 0; 03732 bind[6].error= &bind[6].error_value; 03733 03734 bind[7].buffer_type= MYSQL_TYPE_DOUBLE; 03735 bind[7].buffer= (void *)&szData; 03736 bind[7].buffer_length= 0; 03737 bind[7].error= &bind[7].error_value; 03738 03739 for (i= 0; i < array_elements(bind); i++) 03740 { 03741 bind[i].is_null= &is_null[i]; 03742 bind[i].length= &length[i]; 03743 } 03744 03745 stmt= mysql_simple_prepare(mysql, "select * from test_bind_result"); 03746 check_stmt(stmt); 03747 03748 rc= mysql_stmt_bind_result(stmt, bind); 03749 check_execute(stmt, rc); 03750 03751 rc= mysql_stmt_execute(stmt); 03752 check_execute(stmt, rc); 03753 03754 rc= mysql_stmt_fetch(stmt); 03755 printf("rc=%d\n", rc); 03756 DIE_UNLESS(rc == 0); 03757 03758 if (!opt_silent) 03759 { 03760 fprintf(stdout, "\n data (tiny) : %s(%lu)", t_data, length[0]); 03761 fprintf(stdout, "\n data (short) : %f(%lu)", s_data, length[1]); 03762 fprintf(stdout, "\n data (int) : %d(%lu)", i_data, length[2]); 03763 fprintf(stdout, "\n data (big) : %d(%lu)", b_data, length[3]); 03764 03765 fprintf(stdout, "\n data (float) : %d(%lu)", f_data, length[4]); 03766 fprintf(stdout, "\n data (double) : %s(%lu)", d_data, length[5]); 03767 03768 fprintf(stdout, "\n data (bin) : %ld(%lu)", bData, length[6]); 03769 fprintf(stdout, "\n data (str) : %g(%lu)", szData, length[7]); 03770 } 03771 03772 DIE_UNLESS(strcmp(t_data, "120") == 0); 03773 DIE_UNLESS(i_data == 3999); 03774 DIE_UNLESS(f_data == 2); 03775 DIE_UNLESS(strcmp(d_data, "58.89") == 0); 03776 DIE_UNLESS(b_data == 54); 03777 03778 DIE_UNLESS(length[0] == 3); 03779 DIE_UNLESS(length[1] == 4); 03780 DIE_UNLESS(length[2] == 2); 03781 DIE_UNLESS(length[3] == 1); 03782 DIE_UNLESS(length[4] == 4); 03783 DIE_UNLESS(length[5] == 5); 03784 DIE_UNLESS(length[6] == 4); 03785 DIE_UNLESS(length[7] == 8); 03786 03787 rc= mysql_stmt_fetch(stmt); 03788 DIE_UNLESS(rc == MYSQL_NO_DATA); 03789 03790 mysql_stmt_close(stmt); 03791 }
Here is the call graph for this function:

| static void test_buffers | ( | ) | [static] |
Definition at line 6399 of file mysql_client_test.c.
References buffer, bzero, check_execute, check_stmt, DIE_UNLESS, myheader, myquery, mysql, MYSQL_DATA_TRUNCATED, mysql_query(), mysql_simple_prepare(), mysql_stmt_bind_result(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_store_result(), MYSQL_TYPE_STRING, opt_silent, and strcmp().
06400 { 06401 MYSQL_STMT *stmt; 06402 MYSQL_BIND bind[1]; 06403 int rc; 06404 ulong length; 06405 my_bool is_null; 06406 char buffer[20]; 06407 06408 myheader("test_buffers"); 06409 06410 rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_buffer"); 06411 myquery(rc); 06412 06413 rc= mysql_query(mysql, "CREATE TABLE test_buffer(str varchar(20))"); 06414 myquery(rc); 06415 06416 rc= mysql_query(mysql, "insert into test_buffer values('MySQL')\ 06417 , ('Database'), ('Open-Source'), ('Popular')"); 06418 myquery(rc); 06419 06420 stmt= mysql_simple_prepare(mysql, "select str from test_buffer"); 06421 check_stmt(stmt); 06422 06423 rc= mysql_stmt_execute(stmt); 06424 check_execute(stmt, rc); 06425 06426 bzero(buffer, sizeof(buffer)); /* Avoid overruns in printf() */ 06427 06428 bzero((char*) bind, sizeof(bind)); 06429 bind[0].length= &length; 06430 bind[0].is_null= &is_null; 06431 bind[0].buffer_length= 1; 06432 bind[0].buffer_type= MYSQL_TYPE_STRING; 06433 bind[0].buffer= (void *)buffer; 06434 bind[0].error= &bind[0].error_value; 06435 06436 rc= mysql_stmt_bind_result(stmt, bind); 06437 check_execute(stmt, rc); 06438 06439 rc= mysql_stmt_store_result(stmt); 06440 check_execute(stmt, rc); 06441 06442 buffer[1]= 'X'; 06443 rc= mysql_stmt_fetch(stmt); 06444 DIE_UNLESS(rc == MYSQL_DATA_TRUNCATED); 06445 DIE_UNLESS(bind[0].error_value); 06446 if (!opt_silent) 06447 fprintf(stdout, "\n data: %s (%lu)", buffer, length); 06448 DIE_UNLESS(buffer[0] == 'M'); 06449 DIE_UNLESS(buffer[1] == 'X'); 06450 DIE_UNLESS(length == 5); 06451 06452 bind[0].buffer_length= 8; 06453 rc= mysql_stmt_bind_result(stmt, bind);/* re-bind */ 06454 check_execute(stmt, rc); 06455 06456 rc= mysql_stmt_fetch(stmt); 06457 check_execute(stmt, rc); 06458 if (!opt_silent) 06459 fprintf(stdout, "\n data: %s (%lu)", buffer, length); 06460 DIE_UNLESS(strncmp(buffer, "Database", 8) == 0); 06461 DIE_UNLESS(length == 8); 06462 06463 bind[0].buffer_length= 12; 06464 rc= mysql_stmt_bind_result(stmt, bind);/* re-bind */ 06465 check_execute(stmt, rc); 06466 06467 rc= mysql_stmt_fetch(stmt); 06468 check_execute(stmt, rc); 06469 if (!opt_silent) 06470 fprintf(stdout, "\n data: %s (%lu)", buffer, length); 06471 DIE_UNLESS(strcmp(buffer, "Open-Source") == 0); 06472 DIE_UNLESS(length == 11); 06473 06474 bind[0].buffer_length= 6; 06475 rc= mysql_stmt_bind_result(stmt, bind);/* re-bind */ 06476 check_execute(stmt, rc); 06477 06478 rc= mysql_stmt_fetch(stmt); 06479 DIE_UNLESS(rc == MYSQL_DATA_TRUNCATED); 06480 DIE_UNLESS(bind[0].error_value); 06481 if (!opt_silent) 06482 fprintf(stdout, "\n data: %s (%lu)", buffer, length); 06483 DIE_UNLESS(strncmp(buffer, "Popula", 6) == 0); 06484 DIE_UNLESS(length == 7); 06485 06486 mysql_stmt_close(stmt); 06487 }
Here is the call graph for this function:

| static void test_bug10214 | ( | ) | [static] |
Definition at line 13732 of file mysql_client_test.c.
References DIE_UNLESS, memcmp(), myheader, mysql, mysql_query(), mysql_real_escape_string(), st_mysql::server_status, and SERVER_STATUS_NO_BACKSLASH_ESCAPES.
13733 { 13734 int len; 13735 char out[8]; 13736 13737 myheader("test_bug10214"); 13738 13739 DIE_UNLESS(!(mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)); 13740 13741 len= mysql_real_escape_string(mysql, out, "a'b\\c", 5); 13742 DIE_UNLESS(memcmp(out, "a\\'b\\\\c", len) == 0); 13743 13744 mysql_query(mysql, "set sql_mode='NO_BACKSLASH_ESCAPES'"); 13745 DIE_UNLESS(mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES); 13746 13747 len= mysql_real_escape_string(mysql, out, "a'b\\c", 5); 13748 DIE_UNLESS(memcmp(out, "a''b\\c", len) == 0); 13749 13750 mysql_query(mysql, "set sql_mode=''"); 13751 }
Here is the call graph for this function:

| static void test_bug10729 | ( | ) | [static] |
Definition at line 13351 of file mysql_client_test.c.
References bzero, check_execute, CURSOR_TYPE_READ_ONLY, DIE_UNLESS, myheader, myquery, mysql, MYSQL_NO_DATA, mysql_query(), mysql_stmt_attr_set(), mysql_stmt_bind_result(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_init(), mysql_stmt_prepare(), MYSQL_TYPE_STRING, opt_silent, STMT_ATTR_CURSOR_TYPE, strcmp(), and strlen().
13352 { 13353 MYSQL_STMT *stmt; 13354 MYSQL_BIND bind[1]; 13355 char a[21]; 13356 int rc; 13357 const char *stmt_text; 13358 int i= 0; 13359 const char *name_array[3]= { "aaa", "bbb", "ccc" }; 13360 ulong type; 13361 13362 myheader("test_bug10729"); 13363 13364 mysql_query(mysql, "drop table if exists t1"); 13365 mysql_query(mysql, "create table t1 (id integer not null primary key," 13366 "name VARCHAR(20) NOT NULL)"); 13367 rc= mysql_query(mysql, "insert into t1 (id, name) values " 13368 "(1, 'aaa'), (2, 'bbb'), (3, 'ccc')"); 13369 myquery(rc); 13370 13371 stmt= mysql_stmt_init(mysql); 13372 13373 type= (ulong) CURSOR_TYPE_READ_ONLY; 13374 rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type); 13375 check_execute(stmt, rc); 13376 stmt_text= "select name from t1"; 13377 rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); 13378 check_execute(stmt, rc); 13379 13380 bzero((char*) bind, sizeof(bind)); 13381 bind[0].buffer_type= MYSQL_TYPE_STRING; 13382 bind[0].buffer= (void*) a; 13383 bind[0].buffer_length= sizeof(a); 13384 mysql_stmt_bind_result(stmt, bind); 13385 13386 for (i= 0; i < 3; i++) 13387 { 13388 int row_no= 0; 13389 rc= mysql_stmt_execute(stmt); 13390 check_execute(stmt, rc); 13391 while ((rc= mysql_stmt_fetch(stmt)) == 0) 13392 { 13393 DIE_UNLESS(strcmp(a, name_array[row_no]) == 0); 13394 if (!opt_silent) 13395 printf("%d: %s\n", row_no, a); 13396 ++row_no; 13397 } 13398 DIE_UNLESS(rc == MYSQL_NO_DATA); 13399 } 13400 rc= mysql_stmt_close(stmt); 13401 DIE_UNLESS(rc == 0); 13402 13403 rc= mysql_query(mysql, "drop table t1"); 13404 myquery(rc); 13405 }
Here is the call graph for this function:

| static void test_bug10736 | ( | ) | [static] |
Definition at line 13462 of file mysql_client_test.c.
References bzero, check_execute, CURSOR_TYPE_READ_ONLY, DIE_UNLESS, myheader, myquery, mysql, MYSQL_NO_DATA, mysql_query(), mysql_stmt_attr_set(), mysql_stmt_bind_result(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_init(), mysql_stmt_prepare(), MYSQL_TYPE_STRING, opt_silent, STMT_ATTR_CURSOR_TYPE, and strlen().
13463 { 13464 MYSQL_STMT *stmt; 13465 MYSQL_BIND bind[1]; 13466 char a[21]; 13467 int rc; 13468 const char *stmt_text; 13469 int i= 0; 13470 ulong type; 13471 13472 myheader("test_bug10736"); 13473 13474 mysql_query(mysql, "drop table if exists t1"); 13475 mysql_query(mysql, "create table t1 (id integer not null primary key," 13476 "name VARCHAR(20) NOT NULL)"); 13477 rc= mysql_query(mysql, "insert into t1 (id, name) values " 13478 "(1, 'aaa'), (2, 'bbb'), (3, 'ccc')"); 13479 myquery(rc); 13480 13481 stmt= mysql_stmt_init(mysql); 13482 13483 type= (ulong) CURSOR_TYPE_READ_ONLY; 13484 rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type); 13485 check_execute(stmt, rc); 13486 stmt_text= "select name from t1 where name=(select name from t1 where id=2)"; 13487 rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); 13488 check_execute(stmt, rc); 13489 13490 bzero((char*) bind, sizeof(bind)); 13491 bind[0].buffer_type= MYSQL_TYPE_STRING; 13492 bind[0].buffer= (void*) a; 13493 bind[0].buffer_length= sizeof(a); 13494 mysql_stmt_bind_result(stmt, bind); 13495 13496 for (i= 0; i < 3; i++) 13497 { 13498 int row_no= 0; 13499 rc= mysql_stmt_execute(stmt); 13500 check_execute(stmt, rc); 13501 while ((rc= mysql_stmt_fetch(stmt)) == 0) 13502 { 13503 if (!opt_silent) 13504 printf("%d: %s\n", row_no, a); 13505 ++row_no; 13506 } 13507 DIE_UNLESS(rc == MYSQL_NO_DATA); 13508 } 13509 rc= mysql_stmt_close(stmt); 13510 DIE_UNLESS(rc == 0); 13511 13512 rc= mysql_query(mysql, "drop table t1"); 13513 myquery(rc); 13514 }
Here is the call graph for this function:

| static void test_bug10760 | ( | ) | [static] |
Definition at line 13890 of file mysql_client_test.c.
References buf, bzero, check_execute, CURSOR_TYPE_READ_ONLY, DIE_UNLESS, FALSE, have_innodb, myheader, myquery, mysql, mysql_autocommit(), mysql_error(), mysql_query(), mysql_rollback(), mysql_stmt_attr_set(), mysql_stmt_bind_result(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_init(), mysql_stmt_prepare(), MYSQL_TYPE_STRING, opt_silent, STMT_ATTR_CURSOR_TYPE, strlen(), and TRUE.
13891 { 13892 MYSQL_STMT *stmt; 13893 MYSQL_BIND bind[1]; 13894 int rc; 13895 const char *stmt_text; 13896 char id_buf[20]; 13897 ulong id_len; 13898 int i= 0; 13899 ulong type; 13900 13901 myheader("test_bug10760"); 13902 13903 mysql_query(mysql, "drop table if exists t1, t2"); 13904 13905 /* create tables */ 13906 rc= mysql_query(mysql, "create table t1 (id integer not null primary key)" 13907 " engine=MyISAM"); 13908 myquery(rc); 13909 for (; i < 42; ++i) 13910 { 13911 char buf[100]; 13912 sprintf(buf, "insert into t1 (id) values (%d)", i+1); 13913 rc= mysql_query(mysql, buf); 13914 myquery(rc); 13915 } 13916 mysql_autocommit(mysql, FALSE); 13917 /* create statement */ 13918 stmt= mysql_stmt_init(mysql); 13919 type= (ulong) CURSOR_TYPE_READ_ONLY; 13920 mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type); 13921 13922 /* 13923 1: check that a deadlock within the same connection 13924 is resolved and an error is returned. The deadlock is modelled 13925 as follows: 13926 con1: open cursor for select * from t1; 13927 con1: insert into t1 (id) values (1) 13928 */ 13929 stmt_text= "select id from t1 order by 1"; 13930 rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); 13931 check_execute(stmt, rc); 13932 rc= mysql_stmt_execute(stmt); 13933 check_execute(stmt, rc); 13934 rc= mysql_query(mysql, "update t1 set id=id+100"); 13935 /* 13936 If cursors are not materialized, the update will return an error; 13937 we mainly test that it won't deadlock. 13938 */ 13939 if (rc && !opt_silent) 13940 printf("Got error (as expected): %s\n", mysql_error(mysql)); 13941 /* 13942 2: check that MyISAM tables used in cursors survive 13943 COMMIT/ROLLBACK. 13944 */ 13945 rc= mysql_rollback(mysql); /* should not close the cursor */ 13946 myquery(rc); 13947 rc= mysql_stmt_fetch(stmt); 13948 check_execute(stmt, rc); 13949 13950 /* 13951 3: check that cursors to InnoDB tables are closed (for now) by 13952 COMMIT/ROLLBACK. 13953 */ 13954 if (! have_innodb) 13955 { 13956 if (!opt_silent) 13957 printf("Testing that cursors are closed at COMMIT/ROLLBACK requires " 13958 "InnoDB.\n"); 13959 } 13960 else 13961 { 13962 stmt_text= "select id from t1 order by 1"; 13963 rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); 13964 check_execute(stmt, rc); 13965 13966 rc= mysql_query(mysql, "alter table t1 engine=InnoDB"); 13967 myquery(rc); 13968 13969 bzero(bind, sizeof(bind)); 13970 bind[0].buffer_type= MYSQL_TYPE_STRING; 13971 bind[0].buffer= (void*) id_buf; 13972 bind[0].buffer_length= sizeof(id_buf); 13973 bind[0].length= &id_len; 13974 check_execute(stmt, rc); 13975 mysql_stmt_bind_result(stmt, bind); 13976 13977 rc= mysql_stmt_execute(stmt); 13978 rc= mysql_stmt_fetch(stmt); 13979 DIE_UNLESS(rc == 0); 13980 if (!opt_silent) 13981 printf("Fetched row %s\n", id_buf); 13982 rc= mysql_rollback(mysql); /* should close the cursor */ 13983 myquery(rc); 13984 #if 0 13985 rc= mysql_stmt_fetch(stmt); 13986 DIE_UNLESS(rc); 13987 if (!opt_silent) 13988 printf("Got error (as expected): %s\n", mysql_error(mysql)); 13989 #endif 13990 } 13991 13992 mysql_stmt_close(stmt); 13993 rc= mysql_query(mysql, "drop table t1"); 13994 myquery(rc); 13995 mysql_autocommit(mysql, TRUE); /* restore default */ 13996 }
Here is the call graph for this function:

| static void test_bug10794 | ( | ) | [static] |
Definition at line 13518 of file mysql_client_test.c.
References bzero, check_execute, CURSOR_TYPE_READ_ONLY, myheader, myquery, mysql, MYSQL_NO_DATA, mysql_query(), mysql_stmt_attr_set(), mysql_stmt_bind_param(), mysql_stmt_bind_result(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_free_result(), mysql_stmt_init(), mysql_stmt_prepare(), mysql_stmt_reset(), MYSQL_TYPE_LONG, MYSQL_TYPE_STRING, opt_silent, STMT_ATTR_CURSOR_TYPE, and strlen().
13519 { 13520 MYSQL_STMT *stmt, *stmt1; 13521 MYSQL_BIND bind[2]; 13522 char a[21]; 13523 int id_val; 13524 ulong a_len; 13525 int rc; 13526 const char *stmt_text; 13527 int i= 0; 13528 ulong type; 13529 13530 myheader("test_bug10794"); 13531 13532 mysql_query(mysql, "drop table if exists t1"); 13533 mysql_query(mysql, "create table t1 (id integer not null primary key," 13534 "name varchar(20) not null)"); 13535 stmt= mysql_stmt_init(mysql); 13536 stmt_text= "insert into t1 (id, name) values (?, ?)"; 13537 rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); 13538 check_execute(stmt, rc); 13539 bzero((char*) bind, sizeof(bind)); 13540 bind[0].buffer_type= MYSQL_TYPE_LONG; 13541 bind[0].buffer= (void*) &id_val; 13542 bind[1].buffer_type= MYSQL_TYPE_STRING; 13543 bind[1].buffer= (void*) a; 13544 bind[1].length= &a_len; 13545 rc= mysql_stmt_bind_param(stmt, bind); 13546 check_execute(stmt, rc); 13547 for (i= 0; i < 42; i++) 13548 { 13549 id_val= (i+1)*10; 13550 sprintf(a, "a%d", i); 13551 a_len= strlen(a); /* safety against broken sprintf */ 13552 rc= mysql_stmt_execute(stmt); 13553 check_execute(stmt, rc); 13554 } 13555 stmt_text= "select name from t1"; 13556 rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); 13557 type= (ulong) CURSOR_TYPE_READ_ONLY; 13558 mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type); 13559 stmt1= mysql_stmt_init(mysql); 13560 mysql_stmt_attr_set(stmt1, STMT_ATTR_CURSOR_TYPE, (const void*) &type); 13561 bzero((char*) bind, sizeof(bind)); 13562 bind[0].buffer_type= MYSQL_TYPE_STRING; 13563 bind[0].buffer= (void*) a; 13564 bind[0].buffer_length= sizeof(a); 13565 bind[0].length= &a_len; 13566 rc= mysql_stmt_bind_result(stmt, bind); 13567 check_execute(stmt, rc); 13568 rc= mysql_stmt_execute(stmt); 13569 check_execute(stmt, rc); 13570 rc= mysql_stmt_fetch(stmt); 13571 check_execute(stmt, rc); 13572 if (!opt_silent) 13573 printf("Fetched row from stmt: %s\n", a); 13574 /* Don't optimize: an attribute of the original test case */ 13575 mysql_stmt_free_result(stmt); 13576 mysql_stmt_reset(stmt); 13577 stmt_text= "select name from t1 where id=10"; 13578 rc= mysql_stmt_prepare(stmt1, stmt_text, strlen(stmt_text)); 13579 check_execute(stmt1, rc); 13580 rc= mysql_stmt_bind_result(stmt1, bind); 13581 check_execute(stmt1, rc); 13582 rc= mysql_stmt_execute(stmt1); 13583 while (1) 13584 { 13585 rc= mysql_stmt_fetch(stmt1); 13586 if (rc == MYSQL_NO_DATA) 13587 { 13588 if (!opt_silent) 13589 printf("End of data in stmt1\n"); 13590 break; 13591 } 13592 check_execute(stmt1, rc); 13593 if (!opt_silent) 13594 printf("Fetched row from stmt1: %s\n", a); 13595 } 13596 mysql_stmt_close(stmt); 13597 mysql_stmt_close(stmt1); 13598 13599 rc= mysql_query(mysql, "drop table t1"); 13600 myquery(rc); 13601 }
Here is the call graph for this function:

| static void test_bug11037 | ( | ) | [static] |
Definition at line 13844 of file mysql_client_test.c.
References check_execute, DIE_UNLESS, myheader, myquery, mysql, MYSQL_NO_DATA, mysql_query(), mysql_stmt_close(), mysql_stmt_errno(), mysql_stmt_error(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_init(), mysql_stmt_prepare(), opt_silent, and strlen().
13845 { 13846 MYSQL_STMT *stmt; 13847 int rc; 13848 const char *stmt_text; 13849 13850 myheader("test_bug11037"); 13851 13852 mysql_query(mysql, "drop table if exists t1"); 13853 13854 rc= mysql_query(mysql, "create table t1 (id int not null)"); 13855 myquery(rc); 13856 13857 rc= mysql_query(mysql, "insert into t1 values (1)"); 13858 myquery(rc); 13859 13860 stmt_text= "select id FROM t1"; 13861 stmt= mysql_stmt_init(mysql); 13862 rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); 13863 13864 /* expected error */ 13865 rc = mysql_stmt_fetch(stmt); 13866 DIE_UNLESS(rc==1); 13867 if (!opt_silent) 13868 fprintf(stdout, "Got error, as expected:\n [%d] %s\n", 13869 mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); 13870 13871 rc= mysql_stmt_execute(stmt); 13872 check_execute(stmt, rc); 13873 13874 rc= mysql_stmt_fetch(stmt); 13875 DIE_UNLESS(rc==0); 13876 13877 rc= mysql_stmt_fetch(stmt); 13878 DIE_UNLESS(rc==MYSQL_NO_DATA); 13879 13880 rc= mysql_stmt_fetch(stmt); 13881 DIE_UNLESS(rc==MYSQL_NO_DATA); 13882 13883 mysql_stmt_close(stmt); 13884 rc= mysql_query(mysql, "drop table t1"); 13885 myquery(rc); 13886 }
Here is the call graph for this function:

| static void test_bug11111 | ( | ) | [static] |
Definition at line 13290 of file mysql_client_test.c.
References buf, bzero, check_execute, DIE_UNLESS, myheader, myquery, mysql, mysql_query(), mysql_stmt_bind_result(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_init(), mysql_stmt_prepare(), MYSQL_TYPE_STRING, opt_silent, strcmp(), and strlen().
13291 { 13292 MYSQL_STMT *stmt; 13293 MYSQL_BIND bind[2]; 13294 char buf[2][20]; 13295 ulong len[2]; 13296 int i; 13297 int rc; 13298 const char *query= "SELECT DISTINCT f1,ff2 FROM v1"; 13299 13300 myheader("test_bug11111"); 13301 13302 rc= mysql_query(mysql, "drop table if exists t1, t2, v1"); 13303 myquery(rc); 13304 rc= mysql_query(mysql, "drop view if exists t1, t2, v1"); 13305 myquery(rc); 13306 rc= mysql_query(mysql, "create table t1 (f1 int, f2 int)"); 13307 myquery(rc); 13308 rc= mysql_query(mysql, "create table t2 (ff1 int, ff2 int)"); 13309 myquery(rc); 13310 rc= mysql_query(mysql, "create view v1 as select * from t1, t2 where f1=ff1"); 13311 myquery(rc); 13312 rc= mysql_query(mysql, "insert into t1 values (1,1), (2,2), (3,3)"); 13313 myquery(rc); 13314 rc= mysql_query(mysql, "insert into t2 values (1,1), (2,2), (3,3)"); 13315 myquery(rc); 13316 13317 stmt= mysql_stmt_init(mysql); 13318 13319 mysql_stmt_prepare(stmt, query, strlen(query)); 13320 mysql_stmt_execute(stmt); 13321 13322 bzero((char*) bind, sizeof(bind)); 13323 for (i=0; i < 2; i++) 13324 { 13325 bind[i].buffer_type= MYSQL_TYPE_STRING; 13326 bind[i].buffer= (gptr *)&buf[i]; 13327 bind[i].buffer_length= 20; 13328 bind[i].length= &len[i]; 13329 } 13330 13331 rc= mysql_stmt_bind_result(stmt, bind); 13332 check_execute(stmt, rc); 13333 13334 rc= mysql_stmt_fetch(stmt); 13335 check_execute(stmt, rc); 13336 if (!opt_silent) 13337 printf("return: %s", buf[1]); 13338 DIE_UNLESS(!strcmp(buf[1],"1")); 13339 mysql_stmt_close(stmt); 13340 rc= mysql_query(mysql, "drop view v1"); 13341 myquery(rc); 13342 rc= mysql_query(mysql, "drop table t1, t2"); 13343 myquery(rc); 13344 }
Here is the call graph for this function:

| static void test_bug1115 | ( | ) | [static] |
Definition at line 2358 of file mysql_client_test.c.
References bzero, check_execute, check_stmt, DIE_UNLESS, MAX_TEST_QUERY_LENGTH, my_process_stmt_result(), myheader, myquery, mysql, mysql_query(), mysql_simple_prepare(), mysql_stmt_bind_param(), mysql_stmt_close(), mysql_stmt_execute(), MYSQL_TYPE_STRING, strmov(), and verify_param_count().
02359 { 02360 MYSQL_STMT *stmt; 02361 int rc; 02362 MYSQL_BIND bind[1]; 02363 ulong length[1]; 02364 char szData[11]; 02365 char query[MAX_TEST_QUERY_LENGTH]; 02366 02367 myheader("test_bug1115"); 02368 02369 rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_select"); 02370 myquery(rc); 02371 02372 rc= mysql_query(mysql, "CREATE TABLE test_select(\ 02373 session_id char(9) NOT NULL, \ 02374 a int(8) unsigned NOT NULL, \ 02375 b int(5) NOT NULL, \ 02376 c int(5) NOT NULL, \ 02377 d datetime NOT NULL)"); 02378 myquery(rc); 02379 rc= mysql_query(mysql, "INSERT INTO test_select VALUES " 02380 "(\"abc\", 1, 2, 3, 2003-08-30), " 02381 "(\"abd\", 1, 2, 3, 2003-08-30), " 02382 "(\"abf\", 1, 2, 3, 2003-08-30), " 02383 "(\"abg\", 1, 2, 3, 2003-08-30), " 02384 "(\"abh\", 1, 2, 3, 2003-08-30), " 02385 "(\"abj\", 1, 2, 3, 2003-08-30), " 02386 "(\"abk\", 1, 2, 3, 2003-08-30), " 02387 "(\"abl\", 1, 2, 3, 2003-08-30), " 02388 "(\"abq\", 1, 2, 3, 2003-08-30) "); 02389 myquery(rc); 02390 rc= mysql_query(mysql, "INSERT INTO test_select VALUES " 02391 "(\"abw\", 1, 2, 3, 2003-08-30), " 02392 "(\"abe\", 1, 2, 3, 2003-08-30), " 02393 "(\"abr\", 1, 2, 3, 2003-08-30), " 02394 "(\"abt\", 1, 2, 3, 2003-08-30), " 02395 "(\"aby\", 1, 2, 3, 2003-08-30), " 02396 "(\"abu\", 1, 2, 3, 2003-08-30), " 02397 "(\"abi\", 1, 2, 3, 2003-08-30), " 02398 "(\"abo\", 1, 2, 3, 2003-08-30), " 02399 "(\"abp\", 1, 2, 3, 2003-08-30), " 02400 "(\"abz\", 1, 2, 3, 2003-08-30), " 02401 "(\"abx\", 1, 2, 3, 2003-08-30)"); 02402 myquery(rc); 02403 02404 strmov(query, "SELECT * FROM test_select WHERE " 02405 "CONVERT(session_id USING utf8)= ?"); 02406 stmt= mysql_simple_prepare(mysql, query); 02407 check_stmt(stmt); 02408 02409 verify_param_count(stmt, 1); 02410 02411 /* Always bzero all members of bind parameter */ 02412 bzero((char*) bind, sizeof(bind)); 02413 02414 strmov(szData, (char *)"abc"); 02415 bind[0].buffer_type= MYSQL_TYPE_STRING; 02416 bind[0].buffer= (void *)szData; 02417 bind[0].buffer_length= 10; 02418 bind[0].length= &length[0]; 02419 length[0]= 3; 02420 02421 rc= mysql_stmt_bind_param(stmt, bind); 02422 check_execute(stmt, rc); 02423 02424 rc= mysql_stmt_execute(stmt); 02425 check_execute(stmt, rc); 02426 02427 rc= my_process_stmt_result(stmt); 02428 DIE_UNLESS(rc == 1); 02429 02430 strmov(szData, (char *)"venu"); 02431 bind[0].buffer_type= MYSQL_TYPE_STRING; 02432 bind[0].buffer= (void *)szData; 02433 bind[0].buffer_length= 10; 02434 bind[0].length= &length[0]; 02435 length[0]= 4; 02436 bind[0].is_null= 0; 02437 02438 rc= mysql_stmt_bind_param(stmt, bind); 02439 check_execute(stmt, rc); 02440 02441 rc= mysql_stmt_execute(stmt); 02442 check_execute(stmt, rc); 02443 02444 rc= my_process_stmt_result(stmt); 02445 DIE_UNLESS(rc == 0); 02446 02447 strmov(szData, (char *)"abc"); 02448 bind[0].buffer_type= MYSQL_TYPE_STRING; 02449 bind[0].buffer= (void *)szData; 02450 bind[0].buffer_length= 10; 02451 bind[0].length= &length[0]; 02452 length[0]= 3; 02453 bind[0].is_null= 0; 02454 02455 rc= mysql_stmt_bind_param(stmt, bind); 02456 check_execute(stmt, rc); 02457 02458 rc= mysql_stmt_execute(stmt); 02459 check_execute(stmt, rc); 02460 02461 rc= my_process_stmt_result(stmt); 02462 DIE_UNLESS(rc == 1); 02463 02464 mysql_stmt_close(stmt); 02465 }
Here is the call graph for this function:

| static void test_bug11172 | ( | ) | [static] |
Definition at line 13606 of file mysql_client_test.c.
References bzero, check_execute, CURSOR_TYPE_READ_ONLY, DIE_UNLESS, id, myheader, myquery, mysql, MYSQL_NO_DATA, mysql_query(), mysql_rollback(), mysql_stmt_attr_set(), mysql_stmt_bind_param(), mysql_stmt_bind_result(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_free_result(), mysql_stmt_init(), mysql_stmt_prepare(), mysql_stmt_reset(), MYSQL_TYPE_DATE, MYSQL_TYPE_LONG, opt_silent, STMT_ATTR_CURSOR_TYPE, and strlen().
13607 { 13608 MYSQL_STMT *stmt; 13609 MYSQL_BIND bind_in[1], bind_out[2]; 13610 MYSQL_TIME hired; 13611 int rc; 13612 const char *stmt_text; 13613 int i= 0, id; 13614 ulong type; 13615 13616 myheader("test_bug11172"); 13617 13618 mysql_query(mysql, "drop table if exists t1"); 13619 mysql_query(mysql, "create table t1 (id integer not null primary key," 13620 "hired date not null)"); 13621 rc= mysql_query(mysql, 13622 "insert into t1 (id, hired) values (1, '1933-08-24'), " 13623 "(2, '1965-01-01'), (3, '1949-08-17'), (4, '1945-07-07'), " 13624 "(5, '1941-05-15'), (6, '1978-09-15'), (7, '1936-03-28')"); 13625 myquery(rc); 13626 stmt= mysql_stmt_init(mysql); 13627 stmt_text= "SELECT id, hired FROM t1 WHERE hired=?"; 13628 rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); 13629 check_execute(stmt, rc); 13630 13631 type= (ulong) CURSOR_TYPE_READ_ONLY; 13632 mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type); 13633 13634 bzero((char*) bind_in, sizeof(bind_in)); 13635 bzero((char*) bind_out, sizeof(bind_out)); 13636 bzero((char*) &hired, sizeof(hired)); 13637 hired.year= 1965; 13638 hired.month= 1; 13639 hired.day= 1; 13640 bind_in[0].buffer_type= MYSQL_TYPE_DATE; 13641 bind_in[0].buffer= (void*) &hired; 13642 bind_in[0].buffer_length= sizeof(hired); 13643 bind_out[0].buffer_type= MYSQL_TYPE_LONG; 13644 bind_out[0].buffer= (void*) &id; 13645 bind_out[1]= bind_in[0]; 13646 13647 for (i= 0; i < 3; i++) 13648 { 13649 rc= mysql_stmt_bind_param(stmt, bind_in); 13650 check_execute(stmt, rc); 13651 rc= mysql_stmt_bind_result(stmt, bind_out); 13652 check_execute(stmt, rc); 13653 rc= mysql_stmt_execute(stmt); 13654 check_execute(stmt, rc); 13655 while ((rc= mysql_stmt_fetch(stmt)) == 0) 13656 { 13657 if (!opt_silent) 13658 printf("fetched data %d:%d-%d-%d\n", id, 13659 hired.year, hired.month, hired.day); 13660 } 13661 DIE_UNLESS(rc == MYSQL_NO_DATA); 13662 mysql_stmt_free_result(stmt) || mysql_stmt_reset(stmt); 13663 } 13664 mysql_stmt_close(stmt); 13665 mysql_rollback(mysql); 13666 mysql_rollback(mysql); 13667 13668 rc= mysql_query(mysql, "drop table t1"); 13669 myquery(rc); 13670 }
Here is the call graph for this function:

| static void test_bug11183 | ( | ) | [static] |
Definition at line 13802 of file mysql_client_test.c.
References check_execute, DIE_UNLESS, myheader, myquery, mysql, mysql_query(), mysql_stmt_close(), mysql_stmt_errno(), mysql_stmt_execute(), mysql_stmt_init(), mysql_stmt_prepare(), mysql_stmt_reset(), and strlen().
13803 { 13804 int rc; 13805 MYSQL_STMT *stmt; 13806 char bug_statement[]= "insert into t1 values (1)"; 13807 13808 myheader("test_bug11183"); 13809 13810 mysql_query(mysql, "drop table t1 if exists"); 13811 mysql_query(mysql, "create table t1 (a int)"); 13812 13813 stmt= mysql_stmt_init(mysql); 13814 DIE_UNLESS(stmt != 0); 13815 13816 rc= mysql_stmt_prepare(stmt, bug_statement, strlen(bug_statement)); 13817 check_execute(stmt, rc); 13818 13819 rc= mysql_query(mysql, "drop table t1"); 13820 myquery(rc); 13821 13822 /* Trying to execute statement that should fail on execute stage */ 13823 rc= mysql_stmt_execute(stmt); 13824 DIE_UNLESS(rc); 13825 13826 mysql_stmt_reset(stmt); 13827 DIE_UNLESS(mysql_stmt_errno(stmt) == 0); 13828 13829 mysql_query(mysql, "create table t1 (a int)"); 13830 13831 /* Trying to execute statement that should pass ok */ 13832 if (mysql_stmt_execute(stmt)) 13833 { 13834 mysql_stmt_reset(stmt); 13835 DIE_UNLESS(mysql_stmt_errno(stmt) == 0); 13836 } 13837 13838 mysql_stmt_close(stmt); 13839 13840 rc= mysql_query(mysql, "drop table t1"); 13841 myquery(rc); 13842 }
Here is the call graph for this function:

| static void test_bug11656 | ( | ) | [static] |
Definition at line 13675 of file mysql_client_test.c.
References buf, bzero, check_execute, CURSOR_TYPE_READ_ONLY, DIE_UNLESS, myheader, myquery, mysql, MYSQL_NO_DATA, mysql_query(), mysql_stmt_attr_set(), mysql_stmt_bind_param(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_init(), mysql_stmt_prepare(), MYSQL_TYPE_STRING, STMT_ATTR_CURSOR_TYPE, strlen(), and strmov().
13676 { 13677 MYSQL_STMT *stmt; 13678 MYSQL_BIND bind[2]; 13679 int rc; 13680 const char *stmt_text; 13681 char buf[2][20]; 13682 int i= 0; 13683 ulong type; 13684 13685 myheader("test_bug11656"); 13686 13687 mysql_query(mysql, "drop table if exists t1"); 13688 13689 rc= mysql_query(mysql, "create table t1 (" 13690 "server varchar(40) not null, " 13691 "test_kind varchar(1) not null, " 13692 "test_id varchar(30) not null , " 13693 "primary key (server,test_kind,test_id))"); 13694 myquery(rc); 13695 13696 stmt_text= "select distinct test_kind, test_id from t1 " 13697 "where server in (?, ?)"; 13698 stmt= mysql_stmt_init(mysql); 13699 rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); 13700 check_execute(stmt, rc); 13701 type= (ulong) CURSOR_TYPE_READ_ONLY; 13702 mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type); 13703 13704 bzero((char*) bind, sizeof(bind)); 13705 strmov(buf[0], "pcint502_MY2"); 13706 strmov(buf[1], "*"); 13707 for (i=0; i < 2; i++) 13708 { 13709 bind[i].buffer_type= MYSQL_TYPE_STRING; 13710 bind[i].buffer= (gptr *)&buf[i]; 13711 bind[i].buffer_length= strlen(buf[i]); 13712 } 13713 mysql_stmt_bind_param(stmt, bind); 13714 13715 rc= mysql_stmt_execute(stmt); 13716 check_execute(stmt, rc); 13717 13718 rc= mysql_stmt_fetch(stmt); 13719 DIE_UNLESS(rc == MYSQL_NO_DATA); 13720 13721 mysql_stmt_close(stmt); 13722 rc= mysql_query(mysql, "drop table t1"); 13723 myquery(rc); 13724 }
Here is the call graph for this function:

| static void test_bug11718 | ( | ) | [static] |
Definition at line 14429 of file mysql_client_test.c.
References DIE_UNLESS, st_mysql_res::fields, myheader, myquery, mysql, mysql_query(), mysql_store_result(), MYSQL_TYPE_DATE, opt_silent, and st_mysql_field::type.
14430 { 14431 MYSQL_RES *res; 14432 int rc; 14433 const char *query= "select str_to_date(concat(f3),'%Y%m%d') from t1,t2 " 14434 "where f1=f2 order by f1"; 14435 14436 myheader("test_bug11718"); 14437 14438 rc= mysql_query(mysql, "drop table if exists t1, t2"); 14439 myquery(rc); 14440 rc= mysql_query(mysql, "create table t1 (f1 int)"); 14441 myquery(rc); 14442 rc= mysql_query(mysql, "create table t2 (f2 int, f3 numeric(8))"); 14443 myquery(rc); 14444 rc= mysql_query(mysql, "insert into t1 values (1), (2)"); 14445 myquery(rc); 14446 rc= mysql_query(mysql, "insert into t2 values (1,20050101), (2,20050202)"); 14447 myquery(rc); 14448 rc= mysql_query(mysql, query); 14449 myquery(rc); 14450 res = mysql_store_result(mysql); 14451 14452 if (!opt_silent) 14453 printf("return type: %s", (res->fields[0].type == MYSQL_TYPE_DATE)?"DATE": 14454 "not DATE"); 14455 DIE_UNLESS(res->fields[0].type == MYSQL_TYPE_DATE); 14456 rc= mysql_query(mysql, "drop table t1, t2"); 14457 myquery(rc); 14458 }
Here is the call graph for this function:

| static void test_bug1180 | ( | ) | [static] |
Definition at line 2470 of file mysql_client_test.c.
References bzero, check_execute, check_stmt, DIE_UNLESS, MAX_TEST_QUERY_LENGTH, my_process_stmt_result(), myheader, myquery, mysql, mysql_query(), mysql_simple_prepare(), mysql_stmt_bind_param(), mysql_stmt_close(), mysql_stmt_execute(), MYSQL_TYPE_STRING, strmov(), and verify_param_count().
02471 { 02472 MYSQL_STMT *stmt; 02473 int rc; 02474 MYSQL_BIND bind[1]; 02475 ulong length[1]; 02476 char szData[11]; 02477 char query[MAX_TEST_QUERY_LENGTH]; 02478 02479 myheader("test_select_bug"); 02480 02481 rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_select"); 02482 myquery(rc); 02483 02484 rc= mysql_query(mysql, "CREATE TABLE test_select(session_id char(9) NOT NULL)"); 02485 myquery(rc); 02486 rc= mysql_query(mysql, "INSERT INTO test_select VALUES (\"abc\")"); 02487 myquery(rc); 02488 02489 strmov(query, "SELECT * FROM test_select WHERE ?= \"1111\" and " 02490 "session_id= \"abc\""); 02491 stmt= mysql_simple_prepare(mysql, query); 02492 check_stmt(stmt); 02493 02494 verify_param_count(stmt, 1); 02495 02496 /* Always bzero all members of bind parameter */ 02497 bzero((char*) bind, sizeof(bind)); 02498 02499 strmov(szData, (char *)"abc"); 02500 bind[0].buffer_type= MYSQL_TYPE_STRING; 02501 bind[0].buffer= (void *)szData; 02502 bind[0].buffer_length= 10; 02503 bind[0].length= &length[0]; 02504 length[0]= 3; 02505 bind[0].is_null= 0; 02506 02507 rc= mysql_stmt_bind_param(stmt, bind); 02508 check_execute(stmt, rc); 02509 02510 rc= mysql_stmt_execute(stmt); 02511 check_execute(stmt, rc); 02512 02513 rc= my_process_stmt_result(stmt); 02514 DIE_UNLESS(rc == 0); 02515 02516 strmov(szData, (char *)"1111"); 02517 bind[0].buffer_type= MYSQL_TYPE_STRING; 02518 bind[0].buffer= (void *)szData; 02519 bind[0].buffer_length= 10; 02520 bind[0].length= &length[0]; 02521 length[0]= 4; 02522 bind[0].is_null= 0; 02523 02524 rc= mysql_stmt_bind_param(stmt, bind); 02525 check_execute(stmt, rc); 02526 02527 rc= mysql_stmt_execute(stmt); 02528 check_execute(stmt, rc); 02529 02530 rc= my_process_stmt_result(stmt); 02531 DIE_UNLESS(rc == 1); 02532 02533 strmov(szData, (char *)"abc"); 02534 bind[0].buffer_type= MYSQL_TYPE_STRING; 02535 bind[0].buffer= (void *)szData; 02536 bind[0].buffer_length= 10; 02537 bind[0].length= &length[0]; 02538 length[0]= 3; 02539 bind[0].is_null= 0; 02540 02541 rc= mysql_stmt_bind_param(stmt, bind); 02542 check_execute(stmt, rc); 02543 02544 rc= mysql_stmt_execute(stmt); 02545 check_execute(stmt, rc); 02546 02547 rc= my_process_stmt_result(stmt); 02548 DIE_UNLESS(rc == 0); 02549 02550 mysql_stmt_close(stmt); 02551 }
Here is the call graph for this function:

| static void test_bug11901 | ( | ) | [static] |
Definition at line 14169 of file mysql_client_test.c.
References bzero, check_execute, myheader, myquery, mysql, mysql_query(), mysql_real_query(), mysql_stmt_bind_param(), mysql_stmt_bind_result(), mysql_stmt_close(), mysql_stmt_execute(), MYSQL_TYPE_LONG, MYSQL_TYPE_VAR_STRING, open_cursor(), and strlen().
14170 { 14171 MYSQL_STMT *stmt; 14172 MYSQL_BIND bind[2]; 14173 int rc; 14174 char workdept[20]; 14175 ulong workdept_len; 14176 uint32 empno; 14177 const char *stmt_text; 14178 14179 myheader("test_bug11901"); 14180 14181 stmt_text= "drop table if exists t1, t2"; 14182 rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); 14183 myquery(rc); 14184 14185 stmt_text= "create table t1 (" 14186 " empno int(11) not null, firstname varchar(20) not null," 14187 " midinit varchar(20) not null, lastname varchar(20) not null," 14188 " workdept varchar(6) not null, salary double not null," 14189 " bonus float not null, primary key (empno), " 14190 " unique key (workdept, empno) " 14191 ") default charset=latin1 collate=latin1_bin"; 14192 rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); 14193 myquery(rc); 14194 14195 stmt_text= "insert into t1 values " 14196 "(10, 'CHRISTINE', 'I', 'HAAS', 'A00', 52750, 1000)," 14197 "(20, 'MICHAEL', 'L', 'THOMPSON', 'B01', 41250, 800), " 14198 "(30, 'SALLY', 'A', 'KWAN', 'C01', 38250, 800), " 14199 "(50, 'JOHN', 'B', 'GEYER', 'E01', 40175, 800), " 14200 "(60, 'IRVING', 'F', 'STERN', 'D11', 32250, 500), " 14201 "(70, 'EVA', 'D', 'PULASKI', 'D21', 36170, 700), " 14202 "(90, 'EILEEN', 'W', 'HENDERSON', 'E11', 29750, 600), " 14203 "(100, 'THEODORE', 'Q', 'SPENSER', 'E21', 26150, 500), " 14204 "(110, 'VINCENZO', 'G', 'LUCCHESSI', 'A00', 46500, 900), " 14205 "(120, 'SEAN', '', 'O\\'CONNELL', 'A00', 29250, 600), " 14206 "(130, 'DOLORES', 'M', 'QUINTANA', 'C01', 23800, 500), " 14207 "(140, 'HEATHER', 'A', 'NICHOLLS', 'C01', 28420, 600), " 14208 "(150, 'BRUCE', '', 'ADAMSON', 'D11', 25280, 500), " 14209 "(160, 'ELIZABETH', 'R', 'PIANKA', 'D11', 22250, 400), " 14210 "(170, 'MASATOSHI', 'J', 'YOSHIMURA', 'D11', 24680, 500), " 14211 "(180, 'MARILYN', 'S', 'SCOUTTEN', 'D11', 21340, 500), " 14212 "(190, 'JAMES', 'H', 'WALKER', 'D11', 20450, 400), " 14213 "(200, 'DAVID', '', 'BROWN', 'D11', 27740, 600), " 14214 "(210, 'WILLIAM', 'T', 'JONES', 'D11', 18270, 400), " 14215 "(220, 'JENNIFER', 'K', 'LUTZ', 'D11', 29840, 600), " 14216 "(230, 'JAMES', 'J', 'JEFFERSON', 'D21', 22180, 400), " 14217 "(240, 'SALVATORE', 'M', 'MARINO', 'D21', 28760, 600), " 14218 "(250, 'DANIEL', 'S', 'SMITH', 'D21', 19180, 400), " 14219 "(260, 'SYBIL', 'P', 'JOHNSON', 'D21', 17250, 300), " 14220 "(270, 'MARIA', 'L', 'PEREZ', 'D21', 27380, 500), " 14221 "(280, 'ETHEL', 'R', 'SCHNEIDER', 'E11', 26250, 500), " 14222 "(290, 'JOHN', 'R', 'PARKER', 'E11', 15340, 300), " 14223 "(300, 'PHILIP', 'X', 'SMITH', 'E11', 17750, 400), " 14224 "(310, 'MAUDE', 'F', 'SETRIGHT', 'E11', 15900, 300), " 14225 "(320, 'RAMLAL', 'V', 'MEHTA', 'E21', 19950, 400), " 14226 "(330, 'WING', '', 'LEE', 'E21', 25370, 500), " 14227 "(340, 'JASON', 'R', 'GOUNOT', 'E21', 23840, 500)"; 14228 14229 rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); 14230 myquery(rc); 14231 14232 stmt_text= "create table t2 (" 14233 " deptno varchar(6) not null, deptname varchar(20) not null," 14234 " mgrno int(11) not null, location varchar(20) not null," 14235 " admrdept varchar(6) not null, refcntd int(11) not null," 14236 " refcntu int(11) not null, primary key (deptno)" 14237 ") default charset=latin1 collate=latin1_bin"; 14238 rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); 14239 myquery(rc); 14240 14241 stmt_text= "insert into t2 values " 14242 "('A00', 'SPIFFY COMPUTER SERV', 10, '', 'A00', 0, 0), " 14243 "('B01', 'PLANNING', 20, '', 'A00', 0, 0), " 14244 "('C01', 'INFORMATION CENTER', 30, '', 'A00', 0, 0), " 14245 "('D01', 'DEVELOPMENT CENTER', 0, '', 'A00', 0, 0)," 14246 "('D11', 'MANUFACTURING SYSTEM', 60, '', 'D01', 0, 0), " 14247 "('D21', 'ADMINISTRATION SYSTE', 70, '', 'D01', 0, 0), " 14248 "('E01', 'SUPPORT SERVICES', 50, '', 'A00', 0, 0), " 14249 "('E11', 'OPERATIONS', 90, '', 'E01', 0, 0), " 14250 "('E21', 'SOFTWARE SUPPORT', 100,'', 'E01', 0, 0)"; 14251 rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); 14252 myquery(rc); 14253 14254 /* ****** Begin of trace ****** */ 14255 14256 stmt= open_cursor("select t1.empno, t1.workdept " 14257 "from (t1 left join t2 on t2.deptno = t1.workdept) " 14258 "where t2.deptno in " 14259 " (select t2.deptno " 14260 " from (t1 left join t2 on t2.deptno = t1.workdept) " 14261 " where t1.empno = ?) " 14262 "order by 1"); 14263 bzero(bind, sizeof(bind)); 14264 14265 bind[0].buffer_type= MYSQL_TYPE_LONG; 14266 bind[0].buffer= &empno; 14267 rc= mysql_stmt_bind_param(stmt, bind); 14268 check_execute(stmt, rc); 14269 14270 bind[1].buffer_type= MYSQL_TYPE_VAR_STRING; 14271 bind[1].buffer= (void*) workdept; 14272 bind[1].buffer_length= sizeof(workdept); 14273 bind[1].length= &workdept_len; 14274 14275 rc= mysql_stmt_bind_result(stmt, bind); 14276 check_execute(stmt, rc); 14277 14278 empno= 10; 14279 /* ERROR: next statement causes a server crash */ 14280 rc= mysql_stmt_execute(stmt); 14281 check_execute(stmt, rc); 14282 14283 mysql_stmt_close(stmt); 14284 14285 rc= mysql_query(mysql, "drop table t1, t2"); 14286 myquery(rc); 14287 }
Here is the call graph for this function:

| static void test_bug11904 | ( | ) | [static] |
Definition at line 14291 of file mysql_client_test.c.
References check_execute, CURSOR_TYPE_READ_ONLY, DIE_UNLESS, memcmp(), memset, myheader, myquery, mysql, mysql_commit(), mysql_query(), mysql_stmt_attr_set(), mysql_stmt_bind_result(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_init(), mysql_stmt_prepare(), MYSQL_TYPE_LONG, MYSQL_TYPE_STRING, STMT_ATTR_CURSOR_TYPE, and strlen().
14292 { 14293 MYSQL_STMT *stmt1; 14294 int rc; 14295 const char *stmt_text; 14296 const ulong type= (ulong)CURSOR_TYPE_READ_ONLY; 14297 MYSQL_BIND bind[2]; 14298 int country_id=0; 14299 char row_data[11]= {0}; 14300 14301 myheader("test_bug11904"); 14302 14303 /* create tables */ 14304 rc= mysql_query(mysql, "DROP TABLE IF EXISTS bug11904b"); 14305 myquery(rc); 14306 rc= mysql_query(mysql, "CREATE TABLE bug11904b (id int, name char(10), primary key(id, name))"); 14307 myquery(rc); 14308 14309 rc= mysql_query(mysql, "INSERT INTO bug11904b VALUES (1, 'sofia'), (1,'plovdiv')," 14310 " (1,'varna'), (2,'LA'), (2,'new york'), (3,'heidelberg')," 14311 " (3,'berlin'), (3, 'frankfurt')"); 14312 14313 myquery(rc); 14314 mysql_commit(mysql); 14315 /* create statement */ 14316 stmt1= mysql_stmt_init(mysql); 14317 mysql_stmt_attr_set(stmt1, STMT_ATTR_CURSOR_TYPE, (const void*) &type); 14318 14319 stmt_text= "SELECT id, MIN(name) FROM bug11904b GROUP BY id"; 14320 14321 rc= mysql_stmt_prepare(stmt1, stmt_text, strlen(stmt_text)); 14322 check_execute(stmt1, rc); 14323 14324 memset(bind, 0, sizeof(bind)); 14325 bind[0].buffer_type= MYSQL_TYPE_LONG; 14326 bind[0].buffer=& country_id; 14327 bind[0].buffer_length= 0; 14328 bind[0].length= 0; 14329 14330 bind[1].buffer_type= MYSQL_TYPE_STRING; 14331 bind[1].buffer=& row_data; 14332 bind[1].buffer_length= sizeof(row_data) - 1; 14333 bind[1].length= 0; 14334 14335 rc= mysql_stmt_bind_result(stmt1, bind); 14336 check_execute(stmt1, rc); 14337 14338 rc= mysql_stmt_execute(stmt1); 14339 check_execute(stmt1, rc); 14340 14341 rc= mysql_stmt_fetch(stmt1); 14342 check_execute(stmt1, rc); 14343 DIE_UNLESS(country_id == 1); 14344 DIE_UNLESS(memcmp(row_data, "plovdiv", 7) == 0); 14345 14346 rc= mysql_stmt_fetch(stmt1); 14347 check_execute(stmt1, rc); 14348 DIE_UNLESS(country_id == 2); 14349 DIE_UNLESS(memcmp(row_data, "LA", 2) == 0); 14350 14351 rc= mysql_stmt_fetch(stmt1); 14352 check_execute(stmt1, rc); 14353 DIE_UNLESS(country_id == 3); 14354 DIE_UNLESS(memcmp(row_data, "berlin", 6) == 0); 14355 14356 rc= mysql_stmt_close(stmt1); 14357 check_execute(stmt1, rc); 14358 14359 rc= mysql_query(mysql, "drop table bug11904b"); 14360 myquery(rc); 14361 }
Here is the call graph for this function:

| static void test_bug11909 | ( | ) | [static] |
Definition at line 14051 of file mysql_client_test.c.
References bzero, check_execute, DIE_UNLESS, myheader, myquery, mysql, mysql_query(), mysql_real_query(), mysql_rollback(), mysql_stmt_bind_result(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_reset(), MYSQL_TYPE_DOUBLE, MYSQL_TYPE_FLOAT, MYSQL_TYPE_LONG, MYSQL_TYPE_VAR_STRING, open_cursor(), strcmp(), and strlen().
14052 { 14053 MYSQL_STMT *stmt1, *stmt2; 14054 MYSQL_BIND bind[7]; 14055 int rc; 14056 char firstname[20], midinit[20], lastname[20], workdept[20]; 14057 ulong firstname_len, midinit_len, lastname_len, workdept_len; 14058 uint32 empno; 14059 double salary; 14060 float bonus; 14061 const char *stmt_text; 14062 14063 myheader("test_bug11909"); 14064 14065 stmt_text= "drop table if exists t1"; 14066 rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); 14067 myquery(rc); 14068 14069 stmt_text= "create table t1 (" 14070 " empno int(11) not null, firstname varchar(20) not null," 14071 " midinit varchar(20) not null, lastname varchar(20) not null," 14072 " workdept varchar(6) not null, salary double not null," 14073 " bonus float not null, primary key (empno)" 14074 ") default charset=latin1 collate=latin1_bin"; 14075 rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); 14076 myquery(rc); 14077 14078 stmt_text= "insert into t1 values " 14079 "(10, 'CHRISTINE', 'I', 'HAAS', 'A00', 52750, 1000), " 14080 "(20, 'MICHAEL', 'L', 'THOMPSON', 'B01', 41250, 800)," 14081 "(30, 'SALLY', 'A', 'KWAN', 'C01', 38250, 800)," 14082 "(50, 'JOHN', 'B', 'GEYER', 'E01', 40175, 800), " 14083 "(60, 'IRVING', 'F', 'STERN', 'D11', 32250, 500)"; 14084 rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); 14085 myquery(rc); 14086 14087 /* ****** Begin of trace ****** */ 14088 14089 stmt1= open_cursor("SELECT empno, firstname, midinit, lastname," 14090 "workdept, salary, bonus FROM t1"); 14091 14092 bzero(bind, sizeof(bind)); 14093 bind[0].buffer_type= MYSQL_TYPE_LONG; 14094 bind[0].buffer= (void*) &empno; 14095 14096 bind[1].buffer_type= MYSQL_TYPE_VAR_STRING; 14097 bind[1].buffer= (void*) firstname; 14098 bind[1].buffer_length= sizeof(firstname); 14099 bind[1].length= &firstname_len; 14100 14101 bind[2].buffer_type= MYSQL_TYPE_VAR_STRING; 14102 bind[2].buffer= (void*) midinit; 14103 bind[2].buffer_length= sizeof(midinit); 14104 bind[2].length= &midinit_len; 14105 14106 bind[3].buffer_type= MYSQL_TYPE_VAR_STRING; 14107 bind[3].buffer= (void*) lastname; 14108 bind[3].buffer_length= sizeof(lastname); 14109 bind[3].length= &lastname_len; 14110 14111 bind[4].buffer_type= MYSQL_TYPE_VAR_STRING; 14112 bind[4].buffer= (void*) workdept; 14113 bind[4].buffer_length= sizeof(workdept); 14114 bind[4].length= &workdept_len; 14115 14116 bind[5].buffer_type= MYSQL_TYPE_DOUBLE; 14117 bind[5].buffer= (void*) &salary; 14118 14119 bind[6].buffer_type= MYSQL_TYPE_FLOAT; 14120 bind[6].buffer= (void*) &bonus; 14121 rc= mysql_stmt_bind_result(stmt1, bind); 14122 check_execute(stmt1, rc); 14123 14124 rc= mysql_stmt_execute(stmt1); 14125 check_execute(stmt1, rc); 14126 14127 rc= mysql_stmt_fetch(stmt1); 14128 DIE_UNLESS(rc == 0); 14129 DIE_UNLESS(empno == 10); 14130 DIE_UNLESS(strcmp(firstname, "CHRISTINE") == 0); 14131 DIE_UNLESS(strcmp(midinit, "I") == 0); 14132 DIE_UNLESS(strcmp(lastname, "HAAS") == 0); 14133 DIE_UNLESS(strcmp(workdept, "A00") == 0); 14134 DIE_UNLESS(salary == (double) 52750.0); 14135 DIE_UNLESS(bonus == (float) 1000.0); 14136 14137 stmt2= open_cursor("SELECT empno, firstname FROM t1"); 14138 rc= mysql_stmt_bind_result(stmt2, bind); 14139 check_execute(stmt2, rc); 14140 14141 rc= mysql_stmt_execute(stmt2); 14142 check_execute(stmt2, rc); 14143 14144 rc= mysql_stmt_fetch(stmt2); 14145 DIE_UNLESS(rc == 0); 14146 14147 DIE_UNLESS(empno == 10); 14148 DIE_UNLESS(strcmp(firstname, "CHRISTINE") == 0); 14149 14150 rc= mysql_stmt_reset(stmt2); 14151 check_execute(stmt2, rc); 14152 14153 /* ERROR: next statement should return 0 */ 14154 14155 rc= mysql_stmt_fetch(stmt1); 14156 DIE_UNLESS(rc == 0); 14157 14158 mysql_stmt_close(stmt1); 14159 mysql_stmt_close(stmt2); 14160 rc= mysql_rollback(mysql); 14161 myquery(rc); 14162 14163 rc= mysql_query(mysql, "drop table t1"); 14164 myquery(rc); 14165 }
Here is the call graph for this function:

| static void test_bug12001 | ( | ) | [static] |
Definition at line 13998 of file mysql_client_test.c.
References CLIENT_MULTI_RESULTS, CLIENT_MULTI_STATEMENTS, current_db, DIE_UNLESS, exit, myheader, myquery, mysql_close(), mysql_field_count(), mysql_free_result(), mysql_init(), mysql_next_result(), mysql_query(), mysql_real_connect(), mysql_use_result(), NULL, opt_password, opt_port, opt_unix_socket, and opt_user.
13999 { 14000 MYSQL *mysql_local; 14001 MYSQL_RES *result; 14002 const char *query= "DROP TABLE IF EXISTS test_table;" 14003 "CREATE TABLE test_table(id INT);" 14004 "INSERT INTO test_table VALUES(10);" 14005 "UPDATE test_table SET id=20 WHERE id=10;" 14006 "SELECT * FROM test_table;" 14007 "INSERT INTO non_existent_table VALUES(11);"; 14008 int rc, res; 14009 14010 myheader("test_bug12001"); 14011 14012 if (!(mysql_local= mysql_init(NULL))) 14013 { 14014 fprintf(stdout, "\n mysql_init() failed"); 14015 exit(1); 14016 } 14017 14018 /* Create connection that supports multi statements */ 14019 if (!mysql_real_connect(mysql_local, opt_host, opt_user, 14020 opt_password, current_db, opt_port, 14021 opt_unix_socket, CLIENT_MULTI_STATEMENTS | 14022 CLIENT_MULTI_RESULTS)) 14023 { 14024 fprintf(stdout, "\n mysql_real_connect() failed"); 14025 exit(1); 14026 } 14027 14028 rc= mysql_query(mysql_local, query); 14029 myquery(rc); 14030 14031 do 14032 { 14033 if (mysql_field_count(mysql_local) && 14034 (result= mysql_use_result(mysql_local))) 14035 { 14036 mysql_free_result(result); 14037 } 14038 } 14039 while (!(res= mysql_next_result(mysql_local))); 14040 14041 rc= mysql_query(mysql_local, "DROP TABLE IF EXISTS test_table"); 14042 myquery(rc); 14043 14044 mysql_close(mysql_local); 14045 DIE_UNLESS(res==1); 14046 }
Here is the call graph for this function:

| static void test_bug12243 | ( | ) | [static] |
Definition at line 14366 of file mysql_client_test.c.
References check_execute, CURSOR_TYPE_READ_ONLY, FALSE, have_innodb, myheader, myquery, mysql, mysql_autocommit(), mysql_commit(), mysql_query(), mysql_stmt_attr_set(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_init(), mysql_stmt_prepare(), opt_silent, STMT_ATTR_CURSOR_TYPE, strlen(), and TRUE.
14367 { 14368 MYSQL_STMT *stmt1, *stmt2; 14369 int rc; 14370 const char *stmt_text; 14371 ulong type; 14372 14373 myheader("test_bug12243"); 14374 14375 if (! have_innodb) 14376 { 14377 if (!opt_silent) 14378 printf("This test requires InnoDB.\n"); 14379 return; 14380 } 14381 14382 /* create tables */ 14383 mysql_query(mysql, "drop table if exists t1"); 14384 mysql_query(mysql, "create table t1 (a int) engine=InnoDB"); 14385 rc= mysql_query(mysql, "insert into t1 (a) values (1), (2)"); 14386 myquery(rc); 14387 mysql_autocommit(mysql, FALSE); 14388 /* create statement */ 14389 stmt1= mysql_stmt_init(mysql); 14390 stmt2= mysql_stmt_init(mysql); 14391 type= (ulong) CURSOR_TYPE_READ_ONLY; 14392 mysql_stmt_attr_set(stmt1, STMT_ATTR_CURSOR_TYPE, (const void*) &type); 14393 mysql_stmt_attr_set(stmt2, STMT_ATTR_CURSOR_TYPE, (const void*) &type); 14394 14395 stmt_text= "select a from t1"; 14396 14397 rc= mysql_stmt_prepare(stmt1, stmt_text, strlen(stmt_text)); 14398 check_execute(stmt1, rc); 14399 rc= mysql_stmt_execute(stmt1); 14400 check_execute(stmt1, rc); 14401 rc= mysql_stmt_fetch(stmt1); 14402 check_execute(stmt1, rc); 14403 14404 rc= mysql_stmt_prepare(stmt2, stmt_text, strlen(stmt_text)); 14405 check_execute(stmt2, rc); 14406 rc= mysql_stmt_execute(stmt2); 14407 check_execute(stmt2, rc); 14408 rc= mysql_stmt_fetch(stmt2); 14409 check_execute(stmt2, rc); 14410 14411 rc= mysql_stmt_close(stmt1); 14412 check_execute(stmt1, rc); 14413 rc= mysql_commit(mysql); 14414 myquery(rc); 14415 rc= mysql_stmt_fetch(stmt2); 14416 check_execute(stmt2, rc); 14417 14418 mysql_stmt_close(stmt2); 14419 rc= mysql_query(mysql, "drop table t1"); 14420 myquery(rc); 14421 mysql_autocommit(mysql, TRUE); /* restore default */ 14422 }
Here is the call graph for this function:

| static void test_bug12744 | ( | ) | [static] |
Definition at line 14803 of file mysql_client_test.c.
References client_connect(), DIE_UNLESS, myheader, mysql, mysql_close(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_init(), mysql_stmt_prepare(), mysql_stmt_reset(), and NULL.
14804 { 14805 MYSQL_STMT *prep_stmt = NULL; 14806 int rc; 14807 myheader("test_bug12744"); 14808 14809 prep_stmt= mysql_stmt_init(mysql); 14810 rc= mysql_stmt_prepare(prep_stmt, "SELECT 1", 8); 14811 DIE_UNLESS(rc==0); 14812 14813 mysql_close(mysql); 14814 14815 if ((rc= mysql_stmt_execute(prep_stmt))) 14816 { 14817 if ((rc= mysql_stmt_reset(prep_stmt))) 14818 printf("OK!\n"); 14819 else 14820 { 14821 printf("Error!"); 14822 DIE_UNLESS(1==0); 14823 } 14824 } 14825 else 14826 { 14827 fprintf(stderr, "expected error but no error occured\n"); 14828 DIE_UNLESS(1==0); 14829 } 14830 rc= mysql_stmt_close(prep_stmt); 14831 client_connect(0); 14832 }
Here is the call graph for this function:

| static void test_bug12925 | ( | ) | [static] |
Definition at line 14464 of file mysql_client_test.c.
References DIE_UNLESS, LL, myheader, and opt_getopt_ll_test.
14465 { 14466 myheader("test_bug12925"); 14467 if (opt_getopt_ll_test) 14468 DIE_UNLESS(opt_getopt_ll_test == LL(25600*1024*1024)); 14469 }
| static void test_bug13488 | ( | ) | [static] |
Definition at line 14526 of file mysql_client_test.c.
References check_execute, CURSOR_TYPE_READ_ONLY, DIE_UNLESS, f1, f2, f3, memset, myheader, myquery, mysql, mysql_query(), mysql_stmt_attr_set(), mysql_stmt_bind_result(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_free_result(), mysql_stmt_init(), mysql_stmt_prepare(), mysql_stmt_reset(), MYSQL_TYPE_LONG, opt_silent, STMT_ATTR_CURSOR_TYPE, and strlen().
14527 { 14528 MYSQL_BIND bind[3]; 14529 MYSQL_STMT *stmt1; 14530 int rc, f1, f2, f3, i; 14531 const ulong type= CURSOR_TYPE_READ_ONLY; 14532 const char *query= "select * from t1 left join t2 on f1=f2 where f1=1"; 14533 14534 myheader("test_bug13488"); 14535 14536 rc= mysql_query(mysql, "drop table if exists t1, t2"); 14537 myquery(rc); 14538 rc= mysql_query(mysql, "create table t1 (f1 int not null primary key)"); 14539 myquery(rc); 14540 rc= mysql_query(mysql, "create table t2 (f2 int not null primary key, " 14541 "f3 int not null)"); 14542 myquery(rc); 14543 rc= mysql_query(mysql, "insert into t1 values (1), (2)"); 14544 myquery(rc); 14545 rc= mysql_query(mysql, "insert into t2 values (1,2), (2,4)"); 14546 myquery(rc); 14547 14548 memset(bind, 0, sizeof(bind)); 14549 for (i= 0; i < 3; i++) 14550 { 14551 bind[i].buffer_type= MYSQL_TYPE_LONG; 14552 bind[i].buffer_length= 4; 14553 bind[i].length= 0; 14554 } 14555 bind[0].buffer=&f1; 14556 bind[1].buffer=&f2; 14557 bind[2].buffer=&f3; 14558 14559 stmt1= mysql_stmt_init(mysql); 14560 rc= mysql_stmt_attr_set(stmt1,STMT_ATTR_CURSOR_TYPE, (const void *)&type); 14561 check_execute(stmt1, rc); 14562 14563 rc= mysql_stmt_prepare(stmt1, query, strlen(query)); 14564 check_execute(stmt1, rc); 14565 14566 rc= mysql_stmt_execute(stmt1); 14567 check_execute(stmt1, rc); 14568 14569 rc= mysql_stmt_bind_result(stmt1, bind); 14570 check_execute(stmt1, rc); 14571 14572 rc= mysql_stmt_fetch(stmt1); 14573 check_execute(stmt1, rc); 14574 14575 rc= mysql_stmt_free_result(stmt1); 14576 check_execute(stmt1, rc); 14577 14578 rc= mysql_stmt_reset(stmt1); 14579 check_execute(stmt1, rc); 14580 14581 rc= mysql_stmt_close(stmt1); 14582 check_execute(stmt1, rc); 14583 14584 if (!opt_silent) 14585 printf("data is: %s", (f1 == 1 && f2 == 1 && f3 == 2)?"OK": 14586 "wrong"); 14587 DIE_UNLESS(f1 == 1 && f2 == 1 && f3 == 2); 14588 rc= mysql_query(mysql, "drop table t1, t2"); 14589 myquery(rc); 14590 }
Here is the call graph for this function:

| static void test_bug13524 | ( | ) | [static] |
Definition at line 14597 of file mysql_client_test.c.
References check_execute, CURSOR_TYPE_READ_ONLY, DIE_UNLESS, myheader, myquery, mysql, mysql_query(), mysql_stmt_attr_set(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_init(), mysql_stmt_prepare(), mysql_warning_count(), STMT_ATTR_CURSOR_TYPE, and strlen().
14598 { 14599 MYSQL_STMT *stmt; 14600 int rc; 14601 unsigned int warning_count; 14602 const ulong type= CURSOR_TYPE_READ_ONLY; 14603 const char *query= "select * from t1"; 14604 14605 myheader("test_bug13524"); 14606 14607 rc= mysql_query(mysql, "drop table if exists t1, t2"); 14608 myquery(rc); 14609 rc= mysql_query(mysql, "create table t1 (a int not null primary key)"); 14610 myquery(rc); 14611 rc= mysql_query(mysql, "insert into t1 values (1), (2), (3), (4)"); 14612 myquery(rc); 14613 14614 stmt= mysql_stmt_init(mysql); 14615 rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type); 14616 check_execute(stmt, rc); 14617 14618 rc= mysql_stmt_prepare(stmt, query, strlen(query)); 14619 check_execute(stmt, rc); 14620 14621 rc= mysql_stmt_execute(stmt); 14622 check_execute(stmt, rc); 14623 14624 rc= mysql_stmt_fetch(stmt); 14625 check_execute(stmt, rc); 14626 14627 warning_count= mysql_warning_count(mysql); 14628 DIE_UNLESS(warning_count == 0); 14629 14630 /* Check that DROP TABLE produced a warning (no such table) */ 14631 rc= mysql_query(mysql, "drop table if exists t2"); 14632 myquery(rc); 14633 warning_count= mysql_warning_count(mysql); 14634 DIE_UNLESS(warning_count == 1); 14635 14636 /* 14637 Check that fetch from a cursor cleared the warning from the previous 14638 command. 14639 */ 14640 rc= mysql_stmt_fetch(stmt); 14641 check_execute(stmt, rc); 14642 warning_count= mysql_warning_count(mysql); 14643 DIE_UNLESS(warning_count == 0); 14644 14645 /* Cleanup */ 14646 mysql_stmt_close(stmt); 14647 rc= mysql_query(mysql, "drop table t1"); 14648 myquery(rc); 14649 }
Here is the call graph for this function:

| static void test_bug14169 | ( | ) | [static] |
Definition at line 15025 of file mysql_client_test.c.
References DIE_UNLESS, myheader, myquery, mysql, mysql_fetch_fields(), mysql_query(), mysql_stmt_init(), mysql_stmt_prepare(), mysql_stmt_result_metadata(), MYSQL_TYPE_BLOB, opt_silent, and strlen().
15026 { 15027 MYSQL_STMT *stmt; 15028 const char *stmt_text; 15029 MYSQL_RES *res; 15030 MYSQL_FIELD *field; 15031 int rc; 15032 15033 myheader("test_bug14169"); 15034 15035 rc= mysql_query(mysql, "drop table if exists t1"); 15036 myquery(rc); 15037 rc= mysql_query(mysql, "set session group_concat_max_len=1024"); 15038 myquery(rc); 15039 rc= mysql_query(mysql, "create table t1 (f1 int unsigned, f2 varchar(255))"); 15040 myquery(rc); 15041 rc= mysql_query(mysql, "insert into t1 values (1,repeat('a',255))," 15042 "(2,repeat('b',255))"); 15043 myquery(rc); 15044 stmt= mysql_stmt_init(mysql); 15045 stmt_text= "select f2,group_concat(f1) from t1 group by f2"; 15046 rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); 15047 myquery(rc); 15048 res= mysql_stmt_result_metadata(stmt); 15049 field= mysql_fetch_fields(res); 15050 if (!opt_silent) 15051 printf("GROUP_CONCAT() result type %i", field[1].type); 15052 DIE_UNLESS(field[1].type == MYSQL_TYPE_BLOB); 15053 15054 rc= mysql_query(mysql, "drop table t1"); 15055 myquery(rc); 15056 }
Here is the call graph for this function:

| static void test_bug14210 | ( | ) | [static] |
Definition at line 14477 of file mysql_client_test.c.
References check_execute, CURSOR_TYPE_READ_ONLY, DIE_UNLESS, myheader, myquery, mysql, MYSQL_NO_DATA, mysql_query(), mysql_stmt_attr_set(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_init(), mysql_stmt_prepare(), STMT_ATTR_CURSOR_TYPE, and strlen().
14478 { 14479 MYSQL_STMT *stmt; 14480 int rc, i; 14481 const char *stmt_text; 14482 ulong type; 14483 14484 myheader("test_bug14210"); 14485 14486 mysql_query(mysql, "drop table if exists t1"); 14487 /* 14488 To trigger the problem the table must be InnoDB, although the problem 14489 itself is not InnoDB related. In case the table is MyISAM this test 14490 is harmless. 14491 */ 14492 mysql_query(mysql, "create table t1 (a varchar(255)) engine=InnoDB"); 14493 rc= mysql_query(mysql, "insert into t1 (a) values (repeat('a', 256))"); 14494 myquery(rc); 14495 rc= mysql_query(mysql, "set @@session.max_heap_table_size=16384"); 14496 /* Create a big enough table (more than max_heap_table_size) */ 14497 for (i= 0; i < 8; i++) 14498 { 14499 rc= mysql_query(mysql, "insert into t1 (a) select a from t1"); 14500 myquery(rc); 14501 } 14502 /* create statement */ 14503 stmt= mysql_stmt_init(mysql); 14504 type= (ulong) CURSOR_TYPE_READ_ONLY; 14505 mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type); 14506 14507 stmt_text= "select a from t1"; 14508 14509 rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); 14510 check_execute(stmt, rc); 14511 rc= mysql_stmt_execute(stmt); 14512 while ((rc= mysql_stmt_fetch(stmt)) == 0) 14513 ; 14514 DIE_UNLESS(rc == MYSQL_NO_DATA); 14515 14516 rc= mysql_stmt_close(stmt); 14517 14518 rc= mysql_query(mysql, "drop table t1"); 14519 myquery(rc); 14520 rc= mysql_query(mysql, "set @@session.max_heap_table_size=default"); 14521 myquery(rc); 14522 }
Here is the call graph for this function:

| static void test_bug14845 | ( | ) | [static] |
Definition at line 14655 of file mysql_client_test.c.
References check_execute, CURSOR_TYPE_READ_ONLY, DIE_UNLESS, myheader, myquery, mysql, MYSQL_NO_DATA, mysql_query(), mysql_stmt_attr_set(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_init(), mysql_stmt_prepare(), STMT_ATTR_CURSOR_TYPE, and strlen().
14656 { 14657 MYSQL_STMT *stmt; 14658 int rc; 14659 const ulong type= CURSOR_TYPE_READ_ONLY; 14660 const char *query= "select count(*) from t1 where 1 = 0"; 14661 14662 myheader("test_bug14845"); 14663 14664 rc= mysql_query(mysql, "drop table if exists t1"); 14665 myquery(rc); 14666 rc= mysql_query(mysql, "create table t1 (id int(11) default null, " 14667 "name varchar(20) default null)" 14668 "engine=MyISAM DEFAULT CHARSET=utf8"); 14669 myquery(rc); 14670 rc= mysql_query(mysql, "insert into t1 values (1,'abc'),(2,'def')"); 14671 myquery(rc); 14672 14673 stmt= mysql_stmt_init(mysql); 14674 rc= mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type); 14675 check_execute(stmt, rc); 14676 14677 rc= mysql_stmt_prepare(stmt, query, strlen(query)); 14678 check_execute(stmt, rc); 14679 14680 rc= mysql_stmt_execute(stmt); 14681 check_execute(stmt, rc); 14682 14683 rc= mysql_stmt_fetch(stmt); 14684 DIE_UNLESS(rc == 0); 14685 14686 rc= mysql_stmt_fetch(stmt); 14687 DIE_UNLESS(rc == MYSQL_NO_DATA); 14688 14689 /* Cleanup */ 14690 mysql_stmt_close(stmt); 14691 rc= mysql_query(mysql, "drop table t1"); 14692 myquery(rc); 14693 }
Here is the call graph for this function:

| static void test_bug1500 | ( | ) | [static] |
Definition at line 8874 of file mysql_client_test.c.
References bzero, check_execute, check_stmt, data, DIE_UNLESS, my_process_stmt_result(), myheader, myquery, mysql, mysql_commit(), mysql_query(), mysql_simple_prepare(), mysql_stmt_bind_param(), mysql_stmt_close(), mysql_stmt_execute(), MYSQL_TYPE_LONG, MYSQL_TYPE_STRING, strlen(), and verify_param_count().
08875 { 08876 MYSQL_STMT *stmt; 08877 MYSQL_BIND bind[3]; 08878 int rc; 08879 int32 int_data[3]= {2, 3, 4}; 08880 const char *data; 08881 08882 myheader("test_bug1500"); 08883 08884 rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bg1500"); 08885 myquery(rc); 08886 08887 rc= mysql_query(mysql, "CREATE TABLE test_bg1500 (i INT)"); 08888 myquery(rc); 08889 08890 rc= mysql_query(mysql, "INSERT INTO test_bg1500 VALUES (1), (2)"); 08891 myquery(rc); 08892 08893 rc= mysql_commit(mysql); 08894 myquery(rc); 08895 08896 stmt= mysql_simple_prepare(mysql, "SELECT i FROM test_bg1500 WHERE i IN (?, ?, ?)"); 08897 check_stmt(stmt); 08898 verify_param_count(stmt, 3); 08899 08900 /* 08901 We need to bzero bind structure because mysql_stmt_bind_param checks all 08902 its members. 08903 */ 08904 bzero((char*) bind, sizeof(bind)); 08905 08906 bind[0].buffer= (void *)int_data; 08907 bind[0].buffer_type= MYSQL_TYPE_LONG; 08908 bind[2]= bind[1]= bind[0]; 08909 bind[1].buffer= (void *)(int_data + 1); 08910 bind[2].buffer= (void *)(int_data + 2); 08911 08912 rc= mysql_stmt_bind_param(stmt, bind); 08913 check_execute(stmt, rc); 08914 08915 rc= mysql_stmt_execute(stmt); 08916 check_execute(stmt, rc); 08917 08918 rc= my_process_stmt_result(stmt); 08919 DIE_UNLESS(rc == 1); 08920 08921 mysql_stmt_close(stmt); 08922 08923 rc= mysql_query(mysql, "DROP TABLE test_bg1500"); 08924 myquery(rc); 08925 08926 rc= mysql_query(mysql, "CREATE TABLE test_bg1500 (s VARCHAR(25), FULLTEXT(s)) engine=MyISAM"); 08927 myquery(rc); 08928 08929 rc= mysql_query(mysql, 08930 "INSERT INTO test_bg1500 VALUES ('Gravedigger'), ('Greed'), ('Hollow Dogs')"); 08931 myquery(rc); 08932 08933 rc= mysql_commit(mysql); 08934 myquery(rc); 08935 08936 stmt= mysql_simple_prepare(mysql, 08937 "SELECT s FROM test_bg1500 WHERE MATCH (s) AGAINST (?)"); 08938 check_stmt(stmt); 08939 08940 verify_param_count(stmt, 1); 08941 08942 data= "Dogs"; 08943 bind[0].buffer_type= MYSQL_TYPE_STRING; 08944 bind[0].buffer= (void *) data; 08945 bind[0].buffer_length= strlen(data); 08946 bind[0].is_null= 0; 08947 bind[0].length= 0; 08948 08949 rc= mysql_stmt_bind_param(stmt, bind); 08950 check_execute(stmt, rc); 08951 08952 rc= mysql_stmt_execute(stmt); 08953 check_execute(stmt, rc); 08954 08955 rc= my_process_stmt_result(stmt); 08956 DIE_UNLESS(rc == 1); 08957 08958 mysql_stmt_close(stmt); 08959 08960 /* This should work too */ 08961 stmt= mysql_simple_prepare(mysql, 08962 "SELECT s FROM test_bg1500 WHERE MATCH (s) AGAINST (CONCAT(?, 'digger'))"); 08963 check_stmt(stmt); 08964 08965 verify_param_count(stmt, 1); 08966 08967 data= "Grave"; 08968 bind[0].buffer_type= MYSQL_TYPE_STRING; 08969 bind[0].buffer= (void *) data; 08970 bind[0].buffer_length= strlen(data); 08971 08972 rc= mysql_stmt_bind_param(stmt, bind); 08973 check_execute(stmt, rc); 08974 08975 rc= mysql_stmt_execute(stmt); 08976 check_execute(stmt, rc); 08977 08978 rc= my_process_stmt_result(stmt); 08979 DIE_UNLESS(rc == 1); 08980 08981 mysql_stmt_close(stmt); 08982 }
Here is the call graph for this function:

| static void test_bug15510 | ( | ) | [static] |
Definition at line 14700 of file mysql_client_test.c.
References check_execute, DIE_UNLESS, myheader, myquery, mysql, mysql_query(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), mysql_stmt_init(), mysql_stmt_prepare(), mysql_warning_count(), and strlen().
14701 { 14702 MYSQL_STMT *stmt; 14703 int rc; 14704 const char *query= "select 1 from dual where 1/0"; 14705 14706 myheader("test_bug15510"); 14707 14708 rc= mysql_query(mysql, "set @@sql_mode='ERROR_FOR_DIVISION_BY_ZERO'"); 14709 myquery(rc); 14710 14711 stmt= mysql_stmt_init(mysql); 14712 14713 rc= mysql_stmt_prepare(stmt, query, strlen(query)); 14714 check_execute(stmt, rc); 14715 14716 rc= mysql_stmt_execute(stmt); 14717 check_execute(stmt, rc); 14718 14719 rc= mysql_stmt_fetch(stmt); 14720 DIE_UNLESS(mysql_warning_count(mysql)); 14721 14722 /* Cleanup */ 14723 mysql_stmt_close(stmt); 14724 rc= mysql_query(mysql, "set @@sql_mode=''"); 14725 myquery(rc); 14726 }
Here is the call graph for this function:

| static void test_bug15613 | ( | ) | [static] |
Definition at line 14872 of file mysql_client_test.c.
References DIE_UNLESS, myheader, myquery, mysql, mysql_fetch_fields(), mysql_query(), mysql_stmt_close(), mysql_stmt_init(), mysql_stmt_prepare(), mysql_stmt_result_metadata(), opt_silent, and strlen().
14873 { 14874 MYSQL_STMT *stmt; 14875 const char *stmt_text; 14876 MYSQL_RES *metadata; 14877 MYSQL_FIELD *field; 14878 int rc; 14879 myheader("test_bug15613"); 14880 14881 /* I. Prepare the table */ 14882 rc= mysql_query(mysql, "set names latin1"); 14883 myquery(rc); 14884 mysql_query(mysql, "drop table if exists t1"); 14885 rc= mysql_query(mysql, 14886 "create table t1 (t text character set utf8, " 14887 "tt tinytext character set utf8, " 14888 "mt mediumtext character set utf8, " 14889 "lt longtext character set utf8, " 14890 "vl varchar(255) character set latin1," 14891 "vb varchar(255) character set binary," 14892 "vu varchar(255) character set utf8)"); 14893 myquery(rc); 14894 14895 stmt= mysql_stmt_init(mysql); 14896 14897 /* II. Check SELECT metadata */ 14898 stmt_text= ("select t, tt, mt, lt, vl, vb, vu from t1"); 14899 rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); 14900 metadata= mysql_stmt_result_metadata(stmt); 14901 field= mysql_fetch_fields(metadata); 14902 if (!opt_silent) 14903 { 14904 printf("Field lengths (client character set is latin1):\n" 14905 "text character set utf8:\t\t%lu\n" 14906 "tinytext character set utf8:\t\t%lu\n" 14907 "mediumtext character set utf8:\t\t%lu\n" 14908 "longtext character set utf8:\t\t%lu\n" 14909 "varchar(255) character set latin1:\t%lu\n" 14910 "varchar(255) character set binary:\t%lu\n" 14911 "varchar(255) character set utf8:\t%lu\n", 14912 field[0].length, field[1].length, field[2].length, field[3].length, 14913 field[4].length, field[5].length, field[6].length); 14914 } 14915 DIE_UNLESS(field[0].length == 65535); 14916 DIE_UNLESS(field[1].length == 255); 14917 DIE_UNLESS(field[2].length == 16777215); 14918 DIE_UNLESS(field[3].length == 4294967295UL); 14919 DIE_UNLESS(field[4].length == 255); 14920 DIE_UNLESS(field[5].length == 255); 14921 DIE_UNLESS(field[6].length == 255); 14922 14923 /* III. Cleanup */ 14924 rc= mysql_query(mysql, "drop table t1"); 14925 myquery(rc); 14926 rc= mysql_query(mysql, "set names default"); 14927 myquery(rc); 14928 mysql_stmt_close(stmt); 14929 }
Here is the call graph for this function:

| static void test_bug15752 | ( | ) | [static] |
Definition at line 15295 of file mysql_client_test.c.
References CLIENT_MULTI_RESULTS, CLIENT_MULTI_STATEMENTS, CR_COMMANDS_OUT_OF_SYNC, current_db, DIE_UNLESS, myheader, myquery, mysql, mysql_close(), mysql_errno(), mysql_error(), mysql_free_result(), mysql_init(), mysql_next_result(), mysql_query(), mysql_real_connect(), mysql_real_query(), mysql_store_result(), opt_password, opt_port, opt_silent, opt_unix_socket, opt_user, and strlen().
15296 { 15297 MYSQL mysql_local; 15298 int rc, i; 15299 const int ITERATION_COUNT= 100; 15300 char *query= "CALL p1()"; 15301 15302 myheader("test_bug15752"); 15303 15304 rc= mysql_query(mysql, "drop procedure if exists p1"); 15305 myquery(rc); 15306 rc= mysql_query(mysql, "create procedure p1() select 1"); 15307 myquery(rc); 15308 15309 mysql_init(&mysql_local); 15310 if (! mysql_real_connect(&mysql_local, opt_host, opt_user, 15311 opt_password, current_db, opt_port, 15312 opt_unix_socket, 15313 CLIENT_MULTI_STATEMENTS|CLIENT_MULTI_RESULTS)) 15314 { 15315 printf("Unable connect to MySQL server: %s\n", mysql_error(&mysql_local)); 15316 DIE_UNLESS(0); 15317 } 15318 rc= mysql_real_query(&mysql_local, query, strlen(query)); 15319 myquery(rc); 15320 mysql_free_result(mysql_store_result(&mysql_local)); 15321 15322 rc= mysql_real_query(&mysql_local, query, strlen(query)); 15323 DIE_UNLESS(rc && mysql_errno(&mysql_local) == CR_COMMANDS_OUT_OF_SYNC); 15324 15325 if (! opt_silent) 15326 printf("Got error (as expected): %s\n", mysql_error(&mysql_local)); 15327 15328 /* Check some other commands too */ 15329 15330 DIE_UNLESS(mysql_next_result(&mysql_local) == 0); 15331 mysql_free_result(mysql_store_result(&mysql_local)); 15332 DIE_UNLESS(mysql_next_result(&mysql_local) == -1); 15333 15334 /* The second problem is not reproducible: add the test case */ 15335 for (i = 0; i < ITERATION_COUNT; i++) 15336 { 15337 if (mysql_real_query(&mysql_local, query, strlen(query))) 15338 { 15339 printf("\ni=%d %s failed: %s\n", i, query, mysql_error(&mysql_local)); 15340 break; 15341 } 15342 mysql_free_result(mysql_store_result(&mysql_local)); 15343 DIE_UNLESS(mysql_next_result(&mysql_local) == 0); 15344 mysql_free_result(mysql_store_result(&mysql_local)); 15345 DIE_UNLESS(mysql_next_result(&mysql_local) == -1); 15346 15347 } 15348 mysql_close(&mysql_local); 15349 rc= mysql_query(mysql, "drop procedure p1"); 15350 myquery(rc); 15351 }
Here is the call graph for this function:

| static void test_bug16143 | ( | ) | [static] |
Definition at line 14836 of file mysql_client_test.c.
References DIE_UNLESS, myheader, mysql, mysql_stmt_close(), mysql_stmt_init(), mysql_stmt_sqlstate(), and strcmp().
14837 { 14838 MYSQL_STMT *stmt; 14839 myheader("test_bug16143"); 14840 14841 stmt= mysql_stmt_init(mysql); 14842 /* Check mysql_stmt_sqlstate return "no error" */ 14843 DIE_UNLESS(strcmp(mysql_stmt_sqlstate(stmt), "00000") == 0); 14844 14845 mysql_stmt_close(stmt); 14846 }
Here is the call graph for this function:

| static void test_bug16144 | ( | ) | [static] |
Definition at line 14851 of file mysql_client_test.c.
References DIE_UNLESS, flag, myheader, mysql, mysql_stmt_attr_get(), mysql_stmt_attr_set(), mysql_stmt_close(), mysql_stmt_init(), and STMT_ATTR_UPDATE_MAX_LENGTH.
14852 { 14853 const my_bool flag_orig= (my_bool) 0xde; 14854 my_bool flag= flag_orig; 14855 MYSQL_STMT *stmt; 14856 myheader("test_bug16144"); 14857 14858 /* Check that attr_get returns correct data on little and big endian CPUs */ 14859 stmt= mysql_stmt_init(mysql); 14860 mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (const void*) &flag); 14861 mysql_stmt_attr_get(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void*) &flag); 14862 DIE_UNLESS(flag == flag_orig); 14863 14864 mysql_stmt_close(stmt); 14865 }
Here is the call graph for this function:

| static void test_bug1644 | ( | ) | [static] |
Definition at line 2559 of file mysql_client_test.c.
References bzero, check_execute, check_stmt, DIE_UNLESS, MAX_TEST_QUERY_LENGTH, my_process_result_set(), myheader, myquery, mysql, mysql_data_seek(), mysql_fetch_row(), mysql_free_result(), mysql_query(), mysql_simple_prepare(), mysql_stmt_bind_param(), mysql_stmt_close(), mysql_stmt_execute(), mysql_store_result(), MYSQL_TYPE_LONG, mytest, mytest_r, strcmp(), strmov(), and verify_param_count().
02560 { 02561 MYSQL_STMT *stmt; 02562 MYSQL_RES *result; 02563 MYSQL_ROW row; 02564 MYSQL_BIND bind[4]; 02565 int num; 02566 my_bool isnull; 02567 int rc, i; 02568 char query[MAX_TEST_QUERY_LENGTH]; 02569 02570 myheader("test_bug1644"); 02571 02572 rc= mysql_query(mysql, "DROP TABLE IF EXISTS foo_dfr"); 02573 myquery(rc); 02574 02575 rc= mysql_query(mysql, 02576 "CREATE TABLE foo_dfr(col1 int, col2 int, col3 int, col4 int);"); 02577 myquery(rc); 02578 02579 strmov(query, "INSERT INTO foo_dfr VALUES (?, ?, ?, ? )"); 02580 stmt= mysql_simple_prepare(mysql, query); 02581 check_stmt(stmt); 02582 02583 verify_param_count(stmt, 4); 02584 02585 /* Always bzero all members of bind parameter */ 02586 bzero((char*) bind, sizeof(bind)); 02587 02588 num= 22; 02589 isnull= 0; 02590 for (i= 0 ; i < 4 ; i++) 02591 { 02592 bind[i].buffer_type= MYSQL_TYPE_LONG; 02593 bind[i].buffer= (void *)# 02594 bind[i].is_null= &isnull; 02595 } 02596 02597 rc= mysql_stmt_bind_param(stmt, bind); 02598 check_execute(stmt, rc); 02599 02600 rc= mysql_stmt_execute(stmt); 02601 check_execute(stmt, rc); 02602 02603 isnull= 1; 02604 for (i= 0 ; i < 4 ; i++) 02605 bind[i].is_null= &isnull; 02606 02607 rc= mysql_stmt_bind_param(stmt, bind); 02608 check_execute(stmt, rc); 02609 02610 rc= mysql_stmt_execute(stmt); 02611 check_execute(stmt, rc); 02612 02613 isnull= 0; 02614 num= 88; 02615 for (i= 0 ; i < 4 ; i++) 02616 bind[i].is_null= &isnull; 02617 02618 rc= mysql_stmt_bind_param(stmt, bind); 02619 check_execute(stmt, rc); 02620 02621 rc= mysql_stmt_execute(stmt); 02622 check_execute(stmt, rc); 02623 02624 mysql_stmt_close(stmt); 02625 02626 rc= mysql_query(mysql, "SELECT * FROM foo_dfr"); 02627 myquery(rc); 02628 02629 result= mysql_store_result(mysql); 02630 mytest(result); 02631 02632 rc= my_process_result_set(result); 02633 DIE_UNLESS(rc == 3); 02634 02635 mysql_data_seek(result, 0); 02636 02637 row= mysql_fetch_row(result); 02638 mytest(row); 02639 for (i= 0 ; i < 4 ; i++) 02640 { 02641 DIE_UNLESS(strcmp(row[i], "22") == 0); 02642 } 02643 row= mysql_fetch_row(result); 02644 mytest(row); 02645 for (i= 0 ; i < 4 ; i++) 02646 { 02647 DIE_UNLESS(row[i] == 0); 02648 } 02649 row= mysql_fetch_row(result); 02650 mytest(row); 02651 for (i= 0 ; i < 4 ; i++) 02652 { 02653 DIE_UNLESS(strcmp(row[i], "88") == 0); 02654 } 02655 row= mysql_fetch_row(result); 02656 mytest_r(row); 02657 02658 mysql_free_result(result); 02659 }
Here is the call graph for this function:

| static void test_bug1664 | ( | ) | [static] |
Definition at line 10213 of file mysql_client_test.c.
References bzero, check_execute, check_stmt, data, myheader, myquery, mysql, mysql_query(), mysql_stmt_bind_param(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_init(), mysql_stmt_prepare(), mysql_stmt_reset(), mysql_stmt_send_long_data(), MYSQL_TYPE_LONG, MYSQL_TYPE_STRING, strlen(), verify_col_data(), and verify_param_count().
10214 { 10215 MYSQL_STMT *stmt; 10216 int rc, int_data; 10217 const char *data; 10218 const char *str_data= "Simple string"; 10219 MYSQL_BIND bind[2]; 10220 const char *query= "INSERT INTO test_long_data(col2, col1) VALUES(?, ?)"; 10221 10222 myheader("test_bug1664"); 10223 10224 rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_long_data"); 10225 myquery(rc); 10226 10227 rc= mysql_query(mysql, "CREATE TABLE test_long_data(col1 int, col2 long varchar)"); 10228 myquery(rc); 10229 10230 stmt= mysql_stmt_init(mysql); 10231 check_stmt(stmt); 10232 rc= mysql_stmt_prepare(stmt, query, strlen(query)); 10233 check_execute(stmt, rc); 10234 10235 verify_param_count(stmt, 2); 10236 10237 bzero((char*) bind, sizeof(bind)); 10238 10239 bind[0].buffer_type= MYSQL_TYPE_STRING; 10240 bind[0].buffer= (void *)str_data; 10241 bind[0].buffer_length= strlen(str_data); 10242 10243 bind[1].buffer= (void *)&int_data; 10244 bind[1].buffer_type= MYSQL_TYPE_LONG; 10245 10246 rc= mysql_stmt_bind_param(stmt, bind); 10247 check_execute(stmt, rc); 10248 10249 int_data= 1; 10250 10251 /* 10252 Let us supply empty long_data. This should work and should 10253 not break following execution. 10254 */ 10255 data= ""; 10256 rc= mysql_stmt_send_long_data(stmt, 0, data, strlen(data)); 10257 check_execute(stmt, rc); 10258 10259 rc= mysql_stmt_execute(stmt); 10260 check_execute(stmt, rc); 10261 10262 verify_col_data("test_long_data", "col1", "1"); 10263 verify_col_data("test_long_data", "col2", ""); 10264 10265 rc= mysql_query(mysql, "DELETE FROM test_long_data"); 10266 myquery(rc); 10267 10268 /* This should pass OK */ 10269 data= (char *)"Data"; 10270 rc= mysql_stmt_send_long_data(stmt, 0, data, strlen(data)); 10271 check_execute(stmt, rc); 10272 10273 rc= mysql_stmt_execute(stmt); 10274 check_execute(stmt, rc); 10275 10276 verify_col_data("test_long_data", "col1", "1"); 10277 verify_col_data("test_long_data", "col2", "Data"); 10278 10279 /* clean up */ 10280 rc= mysql_query(mysql, "DELETE FROM test_long_data"); 10281 myquery(rc); 10282 10283 /* 10284 Now we are changing int parameter and don't do anything 10285 with first parameter. Second mysql_stmt_execute() should run 10286 OK treating this first parameter as string parameter. 10287 */ 10288 10289 int_data= 2; 10290 /* execute */ 10291 rc= mysql_stmt_execute(stmt); 10292 check_execute(stmt, rc); 10293 10294 verify_col_data("test_long_data", "col1", "2"); 10295 verify_col_data("test_long_data", "col2", str_data); 10296 10297 /* clean up */ 10298 rc= mysql_query(mysql, "DELETE FROM test_long_data"); 10299 myquery(rc); 10300 10301 /* 10302 Now we are sending other long data. It should not be 10303 concatened to previous. 10304 */ 10305 10306 data= (char *)"SomeOtherData"; 10307 rc= mysql_stmt_send_long_data(stmt, 0, data, strlen(data)); 10308 check_execute(stmt, rc); 10309 10310 rc= mysql_stmt_execute(stmt); 10311 check_execute(stmt, rc); 10312 10313 verify_col_data("test_long_data", "col1", "2"); 10314 verify_col_data("test_long_data", "col2", "SomeOtherData"); 10315 10316 mysql_stmt_close(stmt); 10317 10318 /* clean up */ 10319 rc= mysql_query(mysql, "DELETE FROM test_long_data"); 10320 myquery(rc); 10321 10322 /* Now let us test how mysql_stmt_reset works. */ 10323 stmt= mysql_stmt_init(mysql); 10324 check_stmt(stmt); 10325 rc= mysql_stmt_prepare(stmt, query, strlen(query)); 10326 check_execute(stmt, rc); 10327 rc= mysql_stmt_bind_param(stmt, bind); 10328 check_execute(stmt, rc); 10329 10330 data= (char *)"SomeData"; 10331 rc= mysql_stmt_send_long_data(stmt, 0, data, strlen(data)); 10332 check_execute(stmt, rc); 10333 10334 rc= mysql_stmt_reset(stmt); 10335 check_execute(stmt, rc); 10336 10337 rc= mysql_stmt_execute(stmt); 10338 check_execute(stmt, rc); 10339 10340 verify_col_data("test_long_data", "col1", "2"); 10341 verify_col_data("test_long_data", "col2", str_data); 10342 10343 mysql_stmt_close(stmt); 10344 10345 /* Final clean up */ 10346 rc= mysql_query(mysql, "DROP TABLE test_long_data"); 10347 myquery(rc); 10348 }
Here is the call graph for this function:

| static void test_bug17667 | ( | ) | [static] |
Definition at line 14934 of file mysql_client_test.c.
References buffer, DIE, free, line_buffer, malloc, MAX_TEST_QUERY_LENGTH, memset, my_memmem(), myheader, myquery, mysql, mysql_query(), mysql_real_query(), NULL, opt_vardir, strcat(), and strlen().
14935 { 14936 int rc; 14937 struct buffer_and_length { 14938 const char *buffer; 14939 const uint length; 14940 } statements[]= { 14941 { "drop table if exists bug17667", 29 }, 14942 { "create table bug17667 (c varchar(20))", 37 }, 14943 { "insert into bug17667 (c) values ('regular') /* NUL=\0 with comment */", 68 }, 14944 { "insert into bug17667 (c) values ('NUL=\0 in value')", 50 }, 14945 { "insert into bug17667 (c) values ('5 NULs=\0\0\0\0\0')", 48 }, 14946 { "/* NUL=\0 with comment */ insert into bug17667 (c) values ('encore')", 67 }, 14947 { "drop table bug17667", 19 }, 14948 { NULL, 0 } }; 14949 14950 struct buffer_and_length *statement_cursor; 14951 FILE *log_file; 14952 char *master_log_filename; 14953 14954 myheader("test_bug17667"); 14955 14956 for (statement_cursor= statements; statement_cursor->buffer != NULL; 14957 statement_cursor++) { 14958 rc= mysql_real_query(mysql, statement_cursor->buffer, 14959 statement_cursor->length); 14960 myquery(rc); 14961 } 14962 14963 /* Make sure the server has written the logs to disk before reading it */ 14964 rc= mysql_query(mysql, "flush logs"); 14965 myquery(rc); 14966 14967 master_log_filename = (char *) malloc(strlen(opt_vardir) + strlen("/log/master.log") + 1); 14968 strcpy(master_log_filename, opt_vardir); 14969 strcat(master_log_filename, "/log/master.log"); 14970 printf("Opening '%s'\n", master_log_filename); 14971 log_file= fopen(master_log_filename, "r"); 14972 free(master_log_filename); 14973 14974 if (log_file != NULL) { 14975 14976 for (statement_cursor= statements; statement_cursor->buffer != NULL; 14977 statement_cursor++) { 14978 char line_buffer[MAX_TEST_QUERY_LENGTH*2]; 14979 /* more than enough room for the query and some marginalia. */ 14980 14981 do { 14982 memset(line_buffer, '/', MAX_TEST_QUERY_LENGTH*2); 14983 14984 if(fgets(line_buffer, MAX_TEST_QUERY_LENGTH*2, log_file) == NULL) 14985 { 14986 /* If fgets returned NULL, it indicates either error or EOF */ 14987 if (feof(log_file)) 14988 DIE("Found EOF before all statements where found"); 14989 else 14990 { 14991 fprintf(stderr, "Got error %d while reading from file\n", 14992 ferror(log_file)); 14993 DIE("Read error"); 14994 } 14995 } 14996 14997 } while (my_memmem(line_buffer, MAX_TEST_QUERY_LENGTH*2, 14998 statement_cursor->buffer, statement_cursor->length) == NULL); 14999 15000 printf("Found statement starting with \"%s\"\n", 15001 statement_cursor->buffer); 15002 } 15003 15004 printf("success. All queries found intact in the log.\n"); 15005 15006 } 15007 else 15008 { 15009 fprintf(stderr, "Could not find the log file, VARDIR/log/master.log, so " 15010 "test_bug17667 is \ninconclusive. Run test from the " 15011 "mysql-test/mysql-test-run* program \nto set up the correct " 15012 "environment for this test.\n\n"); 15013 } 15014 15015 if (log_file != NULL) 15016 fclose(log_file); 15017 15018 }
Here is the call graph for this function:

| static void test_bug1946 | ( | ) | [static] |
Definition at line 8985 of file mysql_client_test.c.
References check_stmt, DIE_UNLESS, myerror, myheader, myquery, mysql, mysql_query(), mysql_real_query(), mysql_simple_prepare(), mysql_stmt_close(), NULL, opt_silent, and strlen().
08986 { 08987 MYSQL_STMT *stmt; 08988 int rc; 08989 const char *query= "INSERT INTO prepare_command VALUES (?)"; 08990 08991 myheader("test_bug1946"); 08992 08993 rc= mysql_query(mysql, "DROP TABLE IF EXISTS prepare_command"); 08994 myquery(rc); 08995 08996 rc= mysql_query(mysql, "CREATE TABLE prepare_command(ID INT)"); 08997 myquery(rc); 08998 08999 stmt= mysql_simple_prepare(mysql, query); 09000 check_stmt(stmt); 09001 rc= mysql_real_query(mysql, query, strlen(query)); 09002 DIE_UNLESS(rc != 0); 09003 if (!opt_silent) 09004 fprintf(stdout, "Got error (as expected):\n"); 09005 myerror(NULL); 09006 09007 mysql_stmt_close(stmt); 09008 rc= mysql_query(mysql, "DROP TABLE prepare_command"); 09009 }
Here is the call graph for this function:

| static void test_bug19671 | ( | ) | [static] |
Definition at line 8349 of file mysql_client_test.c.
References current_db, DIE_UNLESS, my_process_result_set(), myheader, myquery, mysql, mysql_free_result(), mysql_list_fields(), mysql_query(), MYSQL_TYPE_LONG, mytest, NULL, and verify_prepare_field.
08350 { 08351 MYSQL_RES *result; 08352 int rc; 08353 myheader("test_bug19671"); 08354 08355 mysql_query(mysql, "set sql_mode=''"); 08356 rc= mysql_query(mysql, "drop table if exists t1"); 08357 myquery(rc); 08358 08359 rc= mysql_query(mysql, "drop view if exists v1"); 08360 myquery(rc); 08361 08362 rc= mysql_query(mysql, "create table t1(f1 int)"); 08363 myquery(rc); 08364 08365 rc= mysql_query(mysql, "create view v1 as select va.* from t1 va"); 08366 myquery(rc); 08367 08368 result= mysql_list_fields(mysql, "v1", NULL); 08369 mytest(result); 08370 08371 rc= my_process_result_set(result); 08372 DIE_UNLESS(rc == 0); 08373 08374 verify_prepare_field(result, 0, "f1", "f1", MYSQL_TYPE_LONG, 08375 "v1", "v1", current_db, 11, "0"); 08376 08377 mysql_free_result(result); 08378 myquery(mysql_query(mysql, "drop view v1")); 08379 myquery(mysql_query(mysql, "drop table t1")); 08380 }
Here is the call graph for this function:

| static void test_bug20152 | ( | ) | [static] |
Definition at line 15246 of file mysql_client_test.c.
References check_execute, st_mysql_time::day, DIE_UNLESS, st_mysql_time::hour, memset, st_mysql_time::minute, st_mysql_time::month, myheader, myquery, mysql, mysql_query(), mysql_stmt_bind_param(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_init(), mysql_stmt_prepare(), MYSQL_TYPE_DATE, opt_silent, st_mysql_time::second, strlen(), and st_mysql_time::year.
15247 { 15248 MYSQL_BIND bind[1]; 15249 MYSQL_STMT *stmt; 15250 MYSQL_TIME tm; 15251 int rc; 15252 const char *query= "INSERT INTO t1 (f1) VALUES (?)"; 15253 15254 myheader("test_bug20152"); 15255 15256 memset(bind, 0, sizeof(bind)); 15257 bind[0].buffer_type= MYSQL_TYPE_DATE; 15258 bind[0].buffer= (void*)&tm; 15259 15260 tm.year = 2006; 15261 tm.month = 6; 15262 tm.day = 18; 15263 tm.hour = 14; 15264 tm.minute = 9; 15265 tm.second = 42; 15266 15267 rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); 15268 myquery(rc); 15269 rc= mysql_query(mysql, "CREATE TABLE t1 (f1 DATE)"); 15270 myquery(rc); 15271 15272 stmt= mysql_stmt_init(mysql); 15273 rc= mysql_stmt_prepare(stmt, query, strlen(query)); 15274 check_execute(stmt, rc); 15275 rc= mysql_stmt_bind_param(stmt, bind); 15276 check_execute(stmt, rc); 15277 rc= mysql_stmt_execute(stmt); 15278 check_execute(stmt, rc); 15279 rc= mysql_stmt_close(stmt); 15280 check_execute(stmt, rc); 15281 rc= mysql_query(mysql, "DROP TABLE t1"); 15282 myquery(rc); 15283 15284 if (tm.hour == 14 && tm.minute == 9 && tm.second == 42) { 15285 if (!opt_silent) 15286 printf("OK!"); 15287 } else { 15288 printf("[14:09:42] != [%02d:%02d:%02d]\n", tm.hour, tm.minute, tm.second); 15289 DIE_UNLESS(0==1); 15290 } 15291 }
Here is the call graph for this function:

| static void test_bug21206 | ( | ) | [static] |
Definition at line 15359 of file mysql_client_test.c.
References create_table(), DBUG_ENTER, DBUG_VOID_RETURN, fill_tables(), free, myheader, stmt_fetch_close(), and stmt_fetch_init().
15360 { 15361 const size_t cursor_count= 1025; 15362 15363 const char *create_table[]= 15364 { 15365 "DROP TABLE IF EXISTS t1", 15366 "CREATE TABLE t1 (i INT)", 15367 "INSERT INTO t1 VALUES (1), (2), (3)" 15368 }; 15369 const char *query= "SELECT * FROM t1"; 15370 15371 Stmt_fetch *fetch_array= 15372 (Stmt_fetch*) calloc(cursor_count, sizeof(Stmt_fetch)); 15373 15374 Stmt_fetch *fetch; 15375 15376 DBUG_ENTER("test_bug21206"); 15377 myheader("test_bug21206"); 15378 15379 fill_tables(create_table, sizeof(create_table) / sizeof(*create_table)); 15380 15381 for (fetch= fetch_array; fetch < fetch_array + cursor_count; ++fetch) 15382 { 15383 /* Init will exit(1) in case of error */ 15384 stmt_fetch_init(fetch, fetch - fetch_array, query); 15385 } 15386 15387 for (fetch= fetch_array; fetch < fetch_array + cursor_count; ++fetch) 15388 stmt_fetch_close(fetch); 15389 15390 free(fetch_array); 15391 15392 DBUG_VOID_RETURN; 15393 }
Here is the call graph for this function:

| static void test_bug2247 | ( | ) | [static] |
Definition at line 9043 of file mysql_client_test.c.
References check_execute, check_stmt, DIE_UNLESS, insert(), myheader, myquery, mysql, mysql_affected_rows(), mysql_free_result(), mysql_query(), mysql_simple_prepare(), mysql_stmt_affected_rows(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_store_result(), mysql_store_result(), mytest, opt_silent, and update.
09044 { 09045 MYSQL_STMT *stmt; 09046 MYSQL_RES *res; 09047 int rc; 09048 int i; 09049 const char *create= "CREATE TABLE bug2247(id INT UNIQUE AUTO_INCREMENT)"; 09050 const char *insert= "INSERT INTO bug2247 VALUES (NULL)"; 09051 const char *select= "SELECT id FROM bug2247"; 09052 const char *update= "UPDATE bug2247 SET id=id+10"; 09053 const char *drop= "DROP TABLE IF EXISTS bug2247"; 09054 ulonglong exp_count; 09055 enum { NUM_ROWS= 5 }; 09056 09057 myheader("test_bug2247"); 09058 09059 if (!opt_silent) 09060 fprintf(stdout, "\nChecking if stmt_affected_rows is not affected by\n" 09061 "mysql_query ... "); 09062 /* create table and insert few rows */ 09063 rc= mysql_query(mysql, drop); 09064 myquery(rc); 09065 09066 rc= mysql_query(mysql, create); 09067 myquery(rc); 09068 09069 stmt= mysql_simple_prepare(mysql, insert); 09070 check_stmt(stmt); 09071 for (i= 0; i < NUM_ROWS; ++i) 09072 { 09073 rc= mysql_stmt_execute(stmt); 09074 check_execute(stmt, rc); 09075 } 09076 exp_count= mysql_stmt_affected_rows(stmt); 09077 DIE_UNLESS(exp_count == 1); 09078 09079 rc= mysql_query(mysql, select); 09080 myquery(rc); 09081 /* 09082 mysql_store_result overwrites mysql->affected_rows. Check that 09083 mysql_stmt_affected_rows() returns the same value, whereas 09084 mysql_affected_rows() value is correct. 09085 */ 09086 res= mysql_store_result(mysql); 09087 mytest(res); 09088 09089 DIE_UNLESS(mysql_affected_rows(mysql) == NUM_ROWS); 09090 DIE_UNLESS(exp_count == mysql_stmt_affected_rows(stmt)); 09091 09092 rc= mysql_query(mysql, update); 09093 myquery(rc); 09094 DIE_UNLESS(mysql_affected_rows(mysql) == NUM_ROWS); 09095 DIE_UNLESS(exp_count == mysql_stmt_affected_rows(stmt)); 09096 09097 mysql_free_result(res); 09098 mysql_stmt_close(stmt); 09099 09100 /* check that mysql_stmt_store_result modifies mysql_stmt_affected_rows */ 09101 stmt= mysql_simple_prepare(mysql, select); 09102 check_stmt(stmt); 09103 09104 rc= mysql_stmt_execute(stmt); 09105 check_execute(stmt, rc); 09106 rc= mysql_stmt_store_result(stmt); 09107 check_execute(stmt, rc); 09108 exp_count= mysql_stmt_affected_rows(stmt); 09109 DIE_UNLESS(exp_count == NUM_ROWS); 09110 09111 rc= mysql_query(mysql, insert); 09112 myquery(rc); 09113 DIE_UNLESS(mysql_affected_rows(mysql) == 1); 09114 DIE_UNLESS(mysql_stmt_affected_rows(stmt) == exp_count); 09115 09116 mysql_stmt_close(stmt); 09117 if (!opt_silent) 09118 fprintf(stdout, "OK"); 09119 }
Here is the call graph for this function:

| static void test_bug2248 | ( | ) | [static] |
Definition at line 9212 of file mysql_client_test.c.
References check_execute, check_execute_r, check_stmt, DIE_UNLESS, myheader, myquery, mysql, mysql_query(), mysql_simple_prepare(), mysql_stmt_close(), mysql_stmt_execute(), mysql_stmt_fetch(), and mysql_stmt_store_result().
09213 { 09214 MYSQL_STMT *stmt; 09215 int rc; 09216 const char *query1= "SELECT DATABASE()"; 09217 const cha

