diff options
-rw-r--r-- | VC++Files/mysys/mysys.dsp | 4 | ||||
-rw-r--r-- | include/my_base.h | 2 | ||||
-rw-r--r-- | include/my_global.h | 3 | ||||
-rw-r--r-- | include/my_sys.h | 5 | ||||
-rw-r--r-- | include/mysql.h | 26 | ||||
-rw-r--r-- | innobase/fil/fil0fil.c | 8 | ||||
-rw-r--r-- | libmysql/libmysql.c | 18 | ||||
-rw-r--r-- | mysql-test/t/rpl_rotate_logs.test | 3 | ||||
-rw-r--r-- | mysys/mf_keycache.c | 2 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 68 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 19 | ||||
-rw-r--r-- | sql/set_var.h | 3 | ||||
-rw-r--r-- | sql/share/charsets/cp850.xml | 50 | ||||
-rw-r--r-- | strings/my_strtoll10.c | 1 | ||||
-rw-r--r-- | tests/client_test.c | 839 |
15 files changed, 569 insertions, 482 deletions
diff --git a/VC++Files/mysys/mysys.dsp b/VC++Files/mysys/mysys.dsp index 533d4212e2b..54345816884 100644 --- a/VC++Files/mysys/mysys.dsp +++ b/VC++Files/mysys/mysys.dsp @@ -190,6 +190,10 @@ SOURCE=.\mf_keycache.c # End Source File # Begin Source File +SOURCE=.\mf_keycaches.c +# End Source File +# Begin Source File + SOURCE=.\mf_loadpath.c # End Source File # Begin Source File diff --git a/include/my_base.h b/include/my_base.h index a1744f37bc6..1bd0f47afa4 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -133,7 +133,7 @@ enum ha_extra_function { HA_EXTRA_RETRIEVE_ALL_COLS, HA_EXTRA_PREPARE_FOR_DELETE, HA_EXTRA_PREPARE_FOR_UPDATE, /* Remove read cache if problems */ - HA_EXTRA_PRELOAD_BUFFER_SIZE, /* Set buffer size for preloading */ + HA_EXTRA_PRELOAD_BUFFER_SIZE /* Set buffer size for preloading */ }; /* The following is parameter to ha_panic() */ diff --git a/include/my_global.h b/include/my_global.h index 43cacf8fa65..b5b78774e91 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -688,7 +688,8 @@ typedef long long my_ptrdiff_t; #endif #endif #if defined(__IBMC__) || defined(__IBMCPP__) -#define STDCALL _System _Export +/* This was _System _Export but caused a lot of warnings on _AIX43 */ +#define STDCALL #elif !defined( STDCALL) #define STDCALL #endif diff --git a/include/my_sys.h b/include/my_sys.h index 25c450e5d2b..d1c7b658665 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -160,7 +160,7 @@ extern char *my_strdup_with_length(const byte *from, uint length, #endif #ifdef HAVE_ALLOCA -#if defined(_AIX) && !defined(__GNUC__) +#if defined(_AIX) && !defined(__GNUC__) && !defined(_AIX43) #pragma alloca #endif /* _AIX */ #if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) @@ -226,9 +226,8 @@ extern void add_compiled_collation(CHARSET_INFO *cs); extern ulong my_cache_w_requests, my_cache_write, my_cache_r_requests, my_cache_read; extern ulong my_blocks_used, my_blocks_changed; -extern uint key_cache_block_size; extern ulong my_file_opened,my_stream_opened, my_tmp_file_created; -extern my_bool key_cache_inited, my_init_done; +extern my_bool my_init_done; /* Point to current my_message() */ extern void (*my_sigtstp_cleanup)(void), diff --git a/include/mysql.h b/include/mysql.h index 2098ed0516a..7df42460c6d 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -552,27 +552,27 @@ typedef struct st_mysql_stmt typedef struct st_mysql_methods { - my_bool (STDCALL *read_query_result)(MYSQL *mysql); - my_bool (STDCALL *advanced_command)(MYSQL *mysql, + my_bool (* STDCALL read_query_result)(MYSQL *mysql); + my_bool (* STDCALL advanced_command)(MYSQL *mysql, enum enum_server_command command, const char *header, unsigned long header_length, const char *arg, unsigned long arg_length, my_bool skip_check); - MYSQL_DATA *(STDCALL *read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields, + MYSQL_DATA *(* STDCALL read_rows)(MYSQL *mysql,MYSQL_FIELD *mysql_fields, unsigned int fields); - MYSQL_RES * (STDCALL *use_result)(MYSQL *mysql); - void (STDCALL *fetch_lengths)(unsigned long *to, + MYSQL_RES * (* STDCALL use_result)(MYSQL *mysql); + void (* STDCALL fetch_lengths)(unsigned long *to, MYSQL_ROW column, unsigned int field_count); #if !defined(MYSQL_SERVER) || defined(EMBEDDED_LIBRARY) - MYSQL_FIELD * (STDCALL *list_fields)(MYSQL *mysql); - my_bool (STDCALL *read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt); - int (STDCALL *stmt_execute)(MYSQL_STMT *stmt); - MYSQL_DATA *(STDCALL *read_binary_rows)(MYSQL_STMT *stmt); - int (STDCALL *unbuffered_fetch)(MYSQL *mysql, char **row); - void (STDCALL *free_embedded_thd)(MYSQL *mysql); - const char *(STDCALL *read_statistic)(MYSQL *mysql); + MYSQL_FIELD * (* STDCALL list_fields)(MYSQL *mysql); + my_bool (* STDCALL read_prepare_result)(MYSQL *mysql, MYSQL_STMT *stmt); + int (* STDCALL stmt_execute)(MYSQL_STMT *stmt); + MYSQL_DATA *(* STDCALL read_binary_rows)(MYSQL_STMT *stmt); + int (* STDCALL unbuffered_fetch)(MYSQL *mysql, char **row); + void (* STDCALL free_embedded_thd)(MYSQL *mysql); + const char *(* STDCALL read_statistic)(MYSQL *mysql); #endif } MYSQL_METHODS; @@ -604,7 +604,7 @@ MYSQL_RES *STDCALL mysql_param_result(MYSQL_STMT *stmt); my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt); int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt); my_bool STDCALL mysql_more_results(MYSQL *mysql); -my_bool STDCALL mysql_next_result(MYSQL *mysql); +int STDCALL mysql_next_result(MYSQL *mysql); MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt, MYSQL_ROW_OFFSET offset); MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt); diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c index a9ae59fbd50..7cf3cc409b3 100644 --- a/innobase/fil/fil0fil.c +++ b/innobase/fil/fil0fil.c @@ -1567,7 +1567,7 @@ fil_op_write_log( mlog_close(mtr, log_ptr); - mlog_catenate_string(mtr, name, ut_strlen(name) + 1); + mlog_catenate_string(mtr, (byte*) name, ut_strlen(name) + 1); if (type == MLOG_FILE_RENAME) { log_ptr = mlog_open(mtr, 30); @@ -1576,7 +1576,7 @@ fil_op_write_log( mlog_close(mtr, log_ptr); - mlog_catenate_string(mtr, new_name, ut_strlen(new_name) + 1); + mlog_catenate_string(mtr, (byte*) new_name, ut_strlen(new_name) + 1); } } #endif @@ -1630,7 +1630,7 @@ fil_op_log_parse_or_replay( return(NULL); } - name = ptr; + name = (char*) ptr; ptr += name_len; @@ -1649,7 +1649,7 @@ fil_op_log_parse_or_replay( return(NULL); } - new_name = ptr; + new_name = (char*) ptr; ptr += new_name_len; } diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 9c388f71314..4f0a6aef11b 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2990,7 +2990,8 @@ int STDCALL cli_unbuffered_fetch(MYSQL *mysql, char **row) if (packet_error == net_safe_read(mysql)) return 1; - *row= (mysql->net.read_pos[0] == 254) ? NULL : (mysql->net.read_pos+1); + *row= ((mysql->net.read_pos[0] == 254) ? NULL : + (char*) (mysql->net.read_pos+1)); return 0; } @@ -3317,7 +3318,7 @@ my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt) my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt) { MYSQL *mysql; - DBUG_ENTER("mysql_stmt_close"); + DBUG_ENTER("mysql_stmt_free_result"); DBUG_ASSERT(stmt != 0); @@ -3498,10 +3499,18 @@ my_bool STDCALL mysql_more_results(MYSQL *mysql) Reads and returns the next query results */ -my_bool STDCALL mysql_next_result(MYSQL *mysql) +int STDCALL mysql_next_result(MYSQL *mysql) { DBUG_ENTER("mysql_next_result"); + if (mysql->status != MYSQL_STATUS_READY) + { + strmov(mysql->net.sqlstate, unknown_sqlstate); + strmov(mysql->net.last_error, + ER(mysql->net.last_errno=CR_COMMANDS_OUT_OF_SYNC)); + DBUG_RETURN(1); + } + mysql->net.last_error[0]= 0; mysql->net.last_errno= 0; strmov(mysql->net.sqlstate, not_error_sqlstate); @@ -3510,9 +3519,10 @@ my_bool STDCALL mysql_next_result(MYSQL *mysql) if (mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS) DBUG_RETURN((*mysql->methods->read_query_result)(mysql)); - DBUG_RETURN(0); + DBUG_RETURN(-1); /* No more results */ } + MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql) { return (*mysql->methods->use_result)(mysql); diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test index 78213c6a750..7560d56af1c 100644 --- a/mysql-test/t/rpl_rotate_logs.test +++ b/mysql-test/t/rpl_rotate_logs.test @@ -101,7 +101,8 @@ show master logs; # we just tests if synonyms are accepted purge binary logs to 'master-bin.000002'; show binary logs; ---sleep 1; +# sleeping 10 seconds or more would make the slave believe connection is down +--real_sleep 1; purge master logs before now(); show binary logs; insert into t2 values (65); diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 406b826382a..a45d967665a 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -571,7 +571,7 @@ void change_key_cache_param(KEY_CACHE_HANDLE keycache) void end_key_cache(KEY_CACHE_HANDLE keycache, my_bool cleanup) { - KEY_CACHE_VAR *env;; + KEY_CACHE_VAR *env; DBUG_ENTER("end_key_cache"); DBUG_PRINT("enter", ("key_cache: %lx", keycache)); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 8731e8fbe21..64d6b5fa7cf 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1375,6 +1375,7 @@ cmp_item* cmp_item::get_comparator(Item *item) return 0; // to satisfy compiler :) } + cmp_item* cmp_item_sort_string::make_same() { return new cmp_item_sort_string_in_static(cmp_charset); @@ -1395,27 +1396,46 @@ cmp_item* cmp_item_row::make_same() return new cmp_item_row(); } + +cmp_item_row::~cmp_item_row() +{ + DBUG_ENTER("~cmp_item_row"); + DBUG_PRINT("enter",("this: %lx", this)); + if (comparators) + { + for (uint i= 0; i < n; i++) + { + if (comparators[i]) + delete comparators[i]; + } + } + DBUG_VOID_RETURN; +} + + void cmp_item_row::store_value(Item *item) { + DBUG_ENTER("cmp_item_row::store_value"); THD *thd= current_thd; n= item->cols(); - if ((comparators= (cmp_item **) thd->calloc(sizeof(cmp_item *)*n))) + if (!comparators) + comparators= (cmp_item **) thd->calloc(sizeof(cmp_item *)*n); + if (comparators) { item->bring_value(); item->null_value= 0; for (uint i=0; i < n; i++) - if ((comparators[i]= cmp_item::get_comparator(item->el(i)))) - { - comparators[i]->store_value(item->el(i)); - item->null_value|= item->el(i)->null_value; - } - else - return; + { + if (!(comparators[i]= cmp_item::get_comparator(item->el(i)))) + break; // new failed + comparators[i]->store_value(item->el(i)); + item->null_value|= item->el(i)->null_value; + } } - else - return; + DBUG_VOID_RETURN; } + void cmp_item_row::store_value_by_template(cmp_item *t, Item *item) { cmp_item_row *tmpl= (cmp_item_row*) t; @@ -1430,19 +1450,17 @@ void cmp_item_row::store_value_by_template(cmp_item *t, Item *item) item->bring_value(); item->null_value= 0; for (uint i=0; i < n; i++) - if ((comparators[i]= tmpl->comparators[i]->make_same())) - { - comparators[i]->store_value_by_template(tmpl->comparators[i], - item->el(i)); - item->null_value|= item->el(i)->null_value; - } - else - return; + { + if (!(comparators[i]= tmpl->comparators[i]->make_same())) + break; // new failed + comparators[i]->store_value_by_template(tmpl->comparators[i], + item->el(i)); + item->null_value|= item->el(i)->null_value; + } } - else - return; } + int cmp_item_row::cmp(Item *arg) { arg->null_value= 0; @@ -1454,25 +1472,31 @@ int cmp_item_row::cmp(Item *arg) bool was_null= 0; arg->bring_value(); for (uint i=0; i < n; i++) + { if (comparators[i]->cmp(arg->el(i))) { if (!arg->el(i)->null_value) return 1; was_null= 1; } + } return (arg->null_value= was_null); } + int cmp_item_row::compare(cmp_item *c) { - int res; cmp_item_row *cmp= (cmp_item_row *) c; for (uint i=0; i < n; i++) + { + int res; if ((res= comparators[i]->compare(cmp->comparators[i]))) return res; + } return 0; } + bool Item_func_in::nulls_in_row() { Item **arg,**arg_end; @@ -1484,6 +1508,7 @@ bool Item_func_in::nulls_in_row() return 0; } + static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y) { return cs->coll->strnncollsp(cs, @@ -1491,6 +1516,7 @@ static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y) (unsigned char *) y->ptr(),y->length()); } + void Item_func_in::fix_length_and_dec() { Item **arg, **arg_end; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index dac7a2d43eb..51c53e6c136 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -638,17 +638,7 @@ class cmp_item_row :public cmp_item uint n; public: cmp_item_row(): comparators(0), n(0) {} - ~cmp_item_row() - { - if (comparators) - { - for (uint i= 0; i < n; i++) - { - if (comparators[i]) - delete comparators[i]; - } - } - } + ~cmp_item_row(); void store_value(Item *item); int cmp(Item *arg); int compare(cmp_item *arg); @@ -694,7 +684,7 @@ public: cmp_item_string *cmp= (cmp_item_string *)c; return sortcmp(value_res, cmp->value_res, cmp_charset); } - cmp_item * make_same() + cmp_item *make_same() { return new cmp_item_sort_string_in_static(cmp_charset); } @@ -715,7 +705,10 @@ class Item_func_in :public Item_int_func } longlong val_int(); void fix_length_and_dec(); - ~Item_func_in() {} + ~Item_func_in() + { + cleanup(); /* This is not called by Item::~Item() */ + } void cleanup() { delete array; diff --git a/sql/set_var.h b/sql/set_var.h index a4c3b546fe0..666575a75e4 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -791,3 +791,6 @@ gptr find_named(I_List<NAMED_LIST> *list, const char *name, uint length, KEY_CACHE_VAR *get_key_cache(LEX_STRING *cache_name); KEY_CACHE_VAR *get_or_create_key_cache(const char *name, uint length); void free_key_cache(const char *name, KEY_CACHE_VAR *key_cache); +bool process_key_caches(int (* func) (const char *name, KEY_CACHE_VAR *)); +void delete_elements(I_List<NAMED_LIST> *list, + void (*free_element)(const char*, gptr)); diff --git a/sql/share/charsets/cp850.xml b/sql/share/charsets/cp850.xml index ae2aebf13fa..d750bac37e2 100644 --- a/sql/share/charsets/cp850.xml +++ b/sql/share/charsets/cp850.xml @@ -15,13 +15,13 @@ 01 01 01 01 01 01 01 01 01 01 01 10 10 10 10 10 10 82 82 82 82 82 82 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 10 10 10 10 30 - 02 02 02 02 02 02 02 02 02 02 02 02 02 02 01 01 - 01 02 01 02 02 02 02 02 02 01 01 10 10 10 10 10 + 01 02 02 02 02 02 02 02 02 02 02 02 02 02 01 01 + 01 02 01 02 02 02 02 02 02 01 01 02 10 01 10 10 02 02 02 02 02 01 10 10 10 10 10 10 10 10 10 10 - 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 - 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 - 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 - 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 + 10 10 10 10 10 01 01 01 10 10 10 10 10 10 10 10 + 10 10 10 10 10 10 02 01 10 10 10 10 10 10 10 10 + 02 01 01 01 01 02 01 01 01 10 10 10 10 10 01 10 + 01 02 01 01 02 01 10 02 01 01 01 01 02 01 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 20 </map> </ctype> @@ -82,13 +82,13 @@ 0060 0061 0062 0063 0064 0065 0066 0067 0068 0069 006a 006b 006c 006d 006e 006f 0070 0071 0072 0073 0074 0075 0076 0077 0078 0079 007a 007b 007c 007d 007e 007f 00c7 00fc 00e9 00e2 00e4 00e0 00e5 00e7 00ea 00eb 00e8 00ef 00ee 00ec 00c4 00c5 -00c9 00e6 00c6 00f4 00f6 00f2 00fb 00f9 00ff 00d6 00dc 00a2 00a3 00a5 20a7 0192 -00e1 00ed 00f3 00fa 00f1 00d1 00aa 00ba 00bf 2310 00ac 00bd 00bc 00a1 00ab 00bb -2591 2592 2593 2502 2524 2561 2562 2556 2555 2563 2551 2557 255d 255c 255b 2510 -2514 2534 252c 251c 2500 253c 255e 255f 255a 2554 2569 2566 2560 2550 256c 2567 -2568 2564 2565 2559 2558 2552 2553 256b 256a 2518 250c 2588 2584 258c 2590 2580 -03b1 00df 0393 03c0 03a3 03c3 00b5 03c4 03a6 0398 03a9 03b4 221e 03c6 03b5 2229 -2261 00b1 2265 2264 2320 2321 00f7 2248 00b0 2219 00b7 221a 207f 00b2 25a0 00a0 +00c9 00e6 00c6 00f4 00f6 00f2 00fb 00f9 00ff 00d6 00dc 00f8 00a3 00d8 00d7 0192 +00e1 00ed 00f3 00fa 00f1 00d1 00aa 00ba 00bf 00ae 00ac 00bd 00bc 00a1 00ab 00bb +2591 2592 2593 2502 2524 00c1 00c2 00c0 00a9 2563 2551 2557 255d 00a2 00a5 2510 +2514 2534 252c 251c 2500 253c 00e3 00c3 255a 2554 2569 2566 2560 2550 256c 00a4 +00f0 00d0 00ca 00cb 00c8 0131 00cd 00ce 00cf 2518 250c 2588 2584 00a6 00cc 2580 +00d3 00df 00d4 00d2 00f5 00d5 00b5 00fe 00de 00da 00db 00d9 00fd 00dd 00af 00b4 +00ad 00b1 2017 00be 00b6 00a7 00f7 00b8 00b0 00a8 00b7 00b9 00b3 00b2 25a0 00a0 </map> </unicode> @@ -99,18 +99,18 @@ 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F - 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F - 60 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 55 56 57 58 59 5A 7B 7C 7D 7E 7F - 43 59 45 41 5C 41 5B 43 45 45 45 49 49 49 5C 5B - 45 5C 5C 4F 5D 4F 55 55 59 5D 59 24 24 24 24 24 - 41 49 4F 55 4E 4E A6 A7 3F A9 AA AB AC 21 22 22 - B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF - C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF - D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF - E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF - F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF + 40 41 51 53 55 59 63 65 67 69 74 76 78 7A 7C 80 + 8E 90 92 94 97 99 A3 A5 A7 A9 AE B1 B2 B3 B4 B5 + B6 41 51 53 55 59 63 65 67 69 74 76 78 7A 7C 80 + 8E 90 92 94 97 99 A3 A5 A7 A9 AE B7 B8 B9 BA BB + 54 A1 5D 47 4B 43 4D 54 5F 61 5B 71 6F 6B 4B 4D + 5D 4F 4F 86 8A 82 9F 9B AD 8A A1 8C E3 8C BD BE + 45 6D 84 9D 7E 7E EA FA FF EE EC FD FC CE EB FB + DC DD DE C3 C9 45 47 43 E9 D5 CF D1 D3 E2 E5 C5 + C6 CB CA C8 C2 CC 49 49 D2 D0 D7 D6 D4 CD D8 E4 + 57 57 5F 61 5B 73 6D 6F 71 C7 C4 DB DA E6 6B D9 + 84 96 86 82 88 88 F5 B0 B0 9D 9F 9B AB AB EF F4 + ED F1 C1 FE F6 E7 BF BC F0 E8 F7 F9 F3 F2 DF E0 </map> </collation> diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c index f795ef64728..117b9d16a65 100644 --- a/strings/my_strtoll10.c +++ b/strings/my_strtoll10.c @@ -18,6 +18,7 @@ #include <my_sys.h> #include <m_string.h> +#undef ULONGLONG_MAX #define ULONGLONG_MAX (~(ulonglong) 0) #define MAX_NEGATIVE_NUMBER ((ulonglong) LL(0x8000000000000000)) #define INIT_CNT 9 diff --git a/tests/client_test.c b/tests/client_test.c index 03c9c1ff3ae..517cac39d1b 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -72,60 +72,55 @@ static double total_time; static void print_error(const char *msg); static void print_st_error(MYSQL_STMT *stmt, const char *msg); -static void check_errcode(const unsigned int err); static void client_disconnect(); #define myerror(msg) print_error(msg) #define mysterror(stmt, msg) print_st_error(stmt, msg) -#define myerrno(n) check_errcode(n) - -#define myassert(exp) assert(exp) -#define myassert_r(exp) assert(!(exp)) #define myquery(r) \ { \ if (r) \ myerror(NULL); \ - myassert(r == 0); \ + assert(r == 0); \ } #define myquery_r(r) \ { \ if (r) \ myerror(NULL); \ -myassert_r(r == 0); \ +assert(r != 0); \ } #define mystmt(stmt,r) \ { \ if (r) \ mysterror(stmt,NULL); \ -myassert(r == 0);\ +assert(r == 0);\ } #define mystmt_r(stmt,r) \ { \ if (r) \ mysterror(stmt,NULL); \ -myassert_r(r == 0);\ +assert(r != 0);\ } #define mystmt_init(stmt) \ { \ if ( stmt == 0) \ myerror(NULL); \ -myassert(stmt != 0); \ +assert(stmt != 0); \ } #define mystmt_init_r(stmt) \ { \ if (stmt == 0) \ myerror(NULL);\ -myassert(stmt == 0);\ +assert(stmt == 0);\ } -#define mytest(x) if (!x) {myerror(NULL);myassert(TRUE);} -#define mytest_r(x) if (x) {myerror(NULL);myassert(TRUE);} +#define mytest(x) if (!x) {myerror(NULL);assert(TRUE);} +#define mytest_r(x) if (x) {myerror(NULL);assert(TRUE);} /******************************************************** * print the error message * @@ -143,16 +138,6 @@ static void print_error(const char *msg) else if (msg) fprintf(stderr, " [MySQL] %s\n", msg); } -static void check_errcode(const unsigned int err) -{ - if (mysql->server_version) - fprintf(stdout,"\n [MySQL-%s]",mysql->server_version); - else - fprintf(stdout,"\n [MySQL]"); - fprintf(stdout,"[%d] %s\n",mysql_errno(mysql),mysql_error(mysql)); - myassert(mysql_errno(mysql) == err); -} - static void print_st_error(MYSQL_STMT *stmt, const char *msg) { if (stmt && mysql_stmt_errno(stmt)) @@ -523,7 +508,7 @@ static void verify_col_data(const char *table, const char *col, } fprintf(stdout,"\n obtained: `%s` (expected: `%s`)", row[field], exp_data); - myassert(strcmp(row[field],exp_data) == 0); + assert(strcmp(row[field],exp_data) == 0); mysql_free_result(result); } @@ -556,15 +541,15 @@ static void verify_prepare_field(MYSQL_RES *result, fprintf(stdout,"\n charsetnr:`%d`", field->charsetnr); fprintf(stdout,"\n default :`%s`\t(expected: `%s`)", field->def ? field->def : "(null)", def ? def: "(null)"); fprintf(stdout,"\n"); - myassert(strcmp(field->name,name) == 0); - myassert(strcmp(field->org_name,org_name) == 0); - myassert(field->type == type); - myassert(strcmp(field->table,table) == 0); - myassert(strcmp(field->org_table,org_table) == 0); - myassert(strcmp(field->db,db) == 0); - myassert(field->length == length); + assert(strcmp(field->name,name) == 0); + assert(strcmp(field->org_name,org_name) == 0); + assert(field->type == type); + assert(strcmp(field->table,table) == 0); + assert(strcmp(field->org_table,org_table) == 0); + assert(strcmp(field->db,db) == 0); + assert(field->length == length); if (def) - myassert(strcmp(field->def,def) == 0); + assert(strcmp(field->def,def) == 0); } /* @@ -575,7 +560,7 @@ static void verify_param_count(MYSQL_STMT *stmt, long exp_count) long param_count= mysql_param_count(stmt); fprintf(stdout,"\n total parameters in stmt: `%ld` (expected: `%ld`)", param_count, exp_count); - myassert(param_count == exp_count); + assert(param_count == exp_count); } /* @@ -586,7 +571,7 @@ static void verify_st_affected_rows(MYSQL_STMT *stmt, ulonglong exp_count) ulonglong affected_rows= mysql_stmt_affected_rows(stmt); fprintf(stdout,"\n total affected rows: `%lld` (expected: `%lld`)", affected_rows, exp_count); - myassert(affected_rows == exp_count); + assert(affected_rows == exp_count); } /* @@ -597,7 +582,7 @@ static void verify_affected_rows(ulonglong exp_count) ulonglong affected_rows= mysql_affected_rows(mysql); fprintf(stdout,"\n total affected rows: `%lld` (expected: `%lld`)", affected_rows, exp_count); - myassert(affected_rows == exp_count); + assert(affected_rows == exp_count); } /* @@ -608,7 +593,7 @@ static void verify_field_count(MYSQL_RES *result, uint exp_count) uint field_count= mysql_num_fields(result); fprintf(stdout,"\n total fields in the result set: `%d` (expected: `%d`)", field_count, exp_count); - myassert(field_count == exp_count); + assert(field_count == exp_count); } /* @@ -630,7 +615,7 @@ static void execute_prepare_query(const char *query, ulonglong exp_count) fprintf(stdout,"\n total affected rows: `%lld` (expected: `%lld`)", affected_rows, exp_count); - myassert(affected_rows == exp_count); + assert(affected_rows == exp_count); mysql_stmt_close(stmt); } @@ -1174,7 +1159,7 @@ static void test_prepare() myquery(rc); /* test the results now, only one row should exists */ - myassert(tiny_data == (char) my_stmt_result("SELECT * FROM my_prepare",50)); + assert(tiny_data == (char) my_stmt_result("SELECT * FROM my_prepare",50)); stmt = mysql_prepare(mysql,"SELECT * FROM my_prepare",50); mystmt_init(stmt); @@ -1212,27 +1197,27 @@ static void test_prepare() fprintf(stdout, "\n\t str : %s (%lu)", str_data, length[1]); - myassert(tiny_data == o_tiny_data); - myassert(is_null[0] == 0); - myassert(length[0] == 1); + assert(tiny_data == o_tiny_data); + assert(is_null[0] == 0); + assert(length[0] == 1); - myassert(int_data == o_int_data); - myassert(length[2] == 4); + assert(int_data == o_int_data); + assert(length[2] == 4); - myassert(small_data == o_small_data); - myassert(length[3] == 2); + assert(small_data == o_small_data); + assert(length[3] == 2); - myassert(big_data == o_big_data); - myassert(length[4] == 8); + assert(big_data == o_big_data); + assert(length[4] == 8); - myassert(real_data == o_real_data); - myassert(length[5] == 4); + assert(real_data == o_real_data); + assert(length[5] == 4); - myassert(double_data == o_double_data); - myassert(length[6] == 8); + assert(double_data == o_double_data); + assert(length[6] == 8); - myassert(strcmp(data,str_data) == 0); - myassert(length[1] == len); + assert(strcmp(data,str_data) == 0); + assert(length[1] == len); o_int_data += 25; o_small_data += 10; @@ -1242,7 +1227,7 @@ static void test_prepare() } rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -1333,7 +1318,7 @@ static void test_double_compare() result = mysql_store_result(mysql); mytest(result); - myassert((int)tiny_data == my_process_result_set(result)); + assert((int)tiny_data == my_process_result_set(result)); mysql_free_result(result); } @@ -1408,7 +1393,7 @@ static void test_null() myquery(rc); nData*= 2; - myassert(nData == my_stmt_result("SELECT * FROM test_null", 30)); + assert(nData == my_stmt_result("SELECT * FROM test_null", 30)); /* Fetch results */ bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -1431,12 +1416,12 @@ static void test_null() is_null[0]= is_null[1]= 0; while (mysql_fetch(stmt) != MYSQL_NO_DATA) { - myassert(is_null[0]); - myassert(is_null[1]); + assert(is_null[0]); + assert(is_null[1]); rc++; is_null[0]= is_null[1]= 0; } - myassert(rc == (int)nData); + assert(rc == (int)nData); mysql_stmt_close(stmt); } @@ -1490,7 +1475,7 @@ static void test_fetch_null() strmov((char *)query , "SELECT * FROM test_fetch_null"); - myassert(3 == my_stmt_result(query,50)); + assert(3 == my_stmt_result(query,50)); stmt = mysql_prepare(mysql, query, 50); mystmt_init(stmt); @@ -1509,14 +1494,14 @@ static void test_fetch_null() { fprintf(stdout, "\n data[%d] : %s", i, is_null[i] ? "NULL" : "NOT NULL"); - myassert(is_null[i]); + assert(is_null[i]); } fprintf(stdout, "\n data[%d]: %d", i, nData); - myassert(nData == 1000 || nData == 88 || nData == 389789); - myassert(is_null[i] == 0); - myassert(length[i] == 4); + assert(nData == 1000 || nData == 88 || nData == 389789); + assert(is_null[i] == 0); + assert(length[i] == 4); } - myassert(rc == 3); + assert(rc == 3); mysql_stmt_close(stmt); } @@ -1651,7 +1636,7 @@ static void test_select_prepare() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); rc = mysql_query(mysql,"DROP TABLE test_select"); @@ -1681,7 +1666,7 @@ static void test_select_prepare() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } @@ -1757,7 +1742,7 @@ static void test_select() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 1); + assert(my_process_stmt_result(stmt) == 1); mysql_stmt_close(stmt); } @@ -1808,7 +1793,7 @@ session_id char(9) NOT NULL, \ rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 1); + assert(my_process_stmt_result(stmt) == 1); strmov(szData,(char *)"venu"); bind[0].buffer_type=FIELD_TYPE_STRING; @@ -1824,7 +1809,7 @@ session_id char(9) NOT NULL, \ rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 0); + assert(my_process_stmt_result(stmt) == 0); strmov(szData,(char *)"abc"); bind[0].buffer_type=FIELD_TYPE_STRING; @@ -1840,7 +1825,7 @@ session_id char(9) NOT NULL, \ rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 1); + assert(my_process_stmt_result(stmt) == 1); mysql_stmt_close(stmt); } @@ -1886,7 +1871,7 @@ static void test_bug1180() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 0); + assert(my_process_stmt_result(stmt) == 0); strmov(szData,(char *)"1111"); bind[0].buffer_type=FIELD_TYPE_STRING; @@ -1902,7 +1887,7 @@ static void test_bug1180() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 1); + assert(my_process_stmt_result(stmt) == 1); strmov(szData,(char *)"abc"); bind[0].buffer_type=FIELD_TYPE_STRING; @@ -1918,7 +1903,7 @@ static void test_bug1180() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(my_process_stmt_result(stmt) == 0); + assert(my_process_stmt_result(stmt) == 0); mysql_stmt_close(stmt); } @@ -1998,7 +1983,7 @@ static void test_bug1644() result= mysql_store_result(mysql); mytest(result); - myassert(3 == my_process_result_set(result)); + assert(3 == my_process_result_set(result)); mysql_data_seek(result, 0); @@ -2006,19 +1991,19 @@ static void test_bug1644() mytest(row); for (i = 0 ; i < 4 ; i++) { - myassert(strcmp(row[i], "22") == 0); + assert(strcmp(row[i], "22") == 0); } row= mysql_fetch_row(result); mytest(row); for (i = 0 ; i < 4 ; i++) { - myassert(row[i] == 0); + assert(row[i] == 0); } row= mysql_fetch_row(result); mytest(row); for (i = 0 ; i < 4 ; i++) { - myassert(strcmp(row[i], "88") == 0); + assert(strcmp(row[i], "88") == 0); } row= mysql_fetch_row(result); mytest_r(row); @@ -2084,7 +2069,7 @@ static void test_select_show() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } @@ -2170,7 +2155,7 @@ static void test_simple_update() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -2256,7 +2241,7 @@ static void test_long_data() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); verify_col_data("test_long_data","col1","999"); @@ -2346,7 +2331,7 @@ static void test_long_data_str() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); my_sprintf(data,(data,"%d", i*5)); @@ -2435,7 +2420,7 @@ static void test_long_data_str1() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); my_sprintf(data,(data,"%ld",(long)i*length)); @@ -2526,7 +2511,7 @@ static void test_long_data_bin() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -2614,7 +2599,7 @@ static void test_simple_delete() result = mysql_store_result(mysql); mytest(result); - myassert(0 == my_process_result_set(result)); + assert(0 == my_process_result_set(result)); mysql_free_result(result); } @@ -2720,7 +2705,7 @@ static void test_update() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -2770,7 +2755,7 @@ static void test_prepare_noparam() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -2840,17 +2825,17 @@ static void test_bind_result() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d,%s(%lu)",nData, szData, length1); - myassert(nData == 10); - myassert(strcmp(szData,"venu")==0); - myassert(length1 == 4); + assert(nData == 10); + assert(strcmp(szData,"venu")==0); + assert(length1 == 4); rc = mysql_fetch(stmt); mystmt(stmt,rc); fprintf(stdout,"\n row 2: %d,%s(%lu)",nData, szData, length1); - myassert(nData == 20); - myassert(strcmp(szData,"MySQL")==0); - myassert(length1 == 5); + assert(nData == 20); + assert(strcmp(szData,"MySQL")==0); + assert(length1 == 5); length=99; rc = mysql_fetch(stmt); @@ -2858,12 +2843,12 @@ static void test_bind_result() if (is_null[0]) fprintf(stdout,"\n row 3: NULL,%s(%lu)", szData, length1); - myassert(is_null[0]); - myassert(strcmp(szData,"monty")==0); - myassert(length1 == 5); + assert(is_null[0]); + assert(strcmp(szData,"monty")==0); + assert(length1 == 5); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -2972,19 +2957,19 @@ static void test_bind_result_ext() fprintf(stdout, "\n data (bin) : %s(%lu)", bData, bLength); - myassert(t_data == 19); - myassert(s_data == 2999); - myassert(i_data == 3999); - myassert(b_data == 4999999); - /*myassert(f_data == 2345.60);*/ - /*myassert(d_data == 5678.89563);*/ - myassert(strcmp(szData,"venu")==0); - myassert(strncmp(bData,"mysql",5)==0); - myassert(szLength == 4); - myassert(bLength == 5); + assert(t_data == 19); + assert(s_data == 2999); + assert(i_data == 3999); + assert(b_data == 4999999); + /*assert(f_data == 2345.60);*/ + /*assert(d_data == 5678.89563);*/ + assert(strcmp(szData,"venu")==0); + assert(strncmp(bData,"mysql",5)==0); + assert(szLength == 4); + assert(bLength == 5); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -3096,23 +3081,23 @@ static void test_bind_result_ext1() fprintf(stdout, "\n data (bin) : %ld(%lu)", bData, length[6]); fprintf(stdout, "\n data (str) : %g(%lu)", szData, length[7]); - myassert(strcmp(t_data,"120")==0); - myassert(i_data == 3999); - myassert(f_data == 2); - myassert(strcmp(d_data,"58.89")==0); - myassert(b_data == 54); - - myassert(length[0] == 3); - myassert(length[1] == 4); - myassert(length[2] == 2); - myassert(length[3] == 1); - myassert(length[4] == 4); - myassert(length[5] == 5); - myassert(length[6] == 4); - myassert(length[7] == 8); + assert(strcmp(t_data,"120")==0); + assert(i_data == 3999); + assert(f_data == 2); + assert(strcmp(d_data,"58.89")==0); + assert(b_data == 54); + + assert(length[0] == 3); + assert(length[1] == 4); + assert(length[2] == 2); + assert(length[3] == 1); + assert(length[4] == 4); + assert(length[5] == 5); + assert(length[6] == 4); + assert(length[7] == 8); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -3165,7 +3150,7 @@ static void bind_fetch(int row_count) mysql_stmt_close(stmt); - myassert(row_count == (int) + assert(row_count == (int) my_stmt_result("SELECT * FROM test_bind_fetch",50)); stmt = mysql_prepare(mysql,"SELECT * FROM test_bind_fetch",50); @@ -3220,33 +3205,33 @@ static void bind_fetch(int row_count) rc= 10+row_count; for (i=0; i < 4; i++) { - myassert(data[i] == rc+i); - myassert(length[i] == bit); + assert(data[i] == rc+i); + assert(length[i] == bit); bit<<= 1; rc+= 12; } /* FLOAT */ rc+= i; - myassert((int)f_data == rc); - myassert(length[4] == 4); + assert((int)f_data == rc); + assert(length[4] == 4); /* DOUBLE */ rc+= 13; - myassert((int)d_data == rc); - myassert(length[5] == 8); + assert((int)d_data == rc); + assert(length[5] == 8); /* CHAR */ rc+= 13; { char buff[20]; long len= my_sprintf(buff, (buff, "%d", rc)); - myassert(strcmp(s_data,buff)==0); - myassert(length[6] == (ulong) len); + assert(strcmp(s_data,buff)==0); + assert(length[6] == (ulong) len); } } rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -3336,7 +3321,7 @@ static void test_fetch_date() bind[6].buffer_length= sizeof(ts_6); bind[6].length= &ts6_length; - myassert(1 == my_stmt_result("SELECT * FROM test_bind_result",50)); + assert(1 == my_stmt_result("SELECT * FROM test_bind_result",50)); stmt = mysql_prepare(mysql, "SELECT * FROM test_bind_result", 50); mystmt_init(stmt); @@ -3359,29 +3344,29 @@ static void test_fetch_date() fprintf(stdout, "\n ts(4) : %s(%lu)", ts_4, ts4_length); fprintf(stdout, "\n ts(6) : %s(%lu)", ts_6, ts6_length); - myassert(strcmp(date,"2002-01-02")==0); - myassert(d_length == 10); + assert(strcmp(date,"2002-01-02")==0); + assert(d_length == 10); - myassert(strcmp(time,"12:49:00")==0); - myassert(t_length == 8); + assert(strcmp(time,"12:49:00")==0); + assert(t_length == 8); - myassert(strcmp(ts,"2002-01-02 17:46:59")==0); - myassert(ts_length == 19); + assert(strcmp(ts,"2002-01-02 17:46:59")==0); + assert(ts_length == 19); - myassert(year == 2010); - myassert(y_length == 4); + assert(year == 2010); + assert(y_length == 4); - myassert(strcmp(dt,"2010-07-10 00:00:00")==0); - myassert(dt_length == 19); + assert(strcmp(dt,"2010-07-10 00:00:00")==0); + assert(dt_length == 19); - myassert(ts_4[0] == '\0'); - myassert(ts4_length == 0); + assert(ts_4[0] == '\0'); + assert(ts4_length == 0); - myassert(strcmp(ts_6,"1999-12-29 00:00:00")==0); - myassert(ts6_length == 19); + assert(strcmp(ts_6,"1999-12-29 00:00:00")==0); + assert(ts6_length == 19); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -3726,7 +3711,7 @@ static void test_prepare_ext() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(nData == (int)my_process_stmt_result(stmt)); + assert(nData == (int)my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } @@ -3769,7 +3754,7 @@ static void test_field_names() result = mysql_use_result(mysql); mytest(result); - myassert(0 == my_process_result_set(result)); + assert(0 == my_process_result_set(result)); mysql_free_result(result); /* with table name included with TRUE column name */ @@ -3779,7 +3764,7 @@ static void test_field_names() result = mysql_use_result(mysql); mytest(result); - myassert(0 == my_process_result_set(result)); + assert(0 == my_process_result_set(result)); mysql_free_result(result); } @@ -3805,7 +3790,7 @@ static void test_warnings() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -3908,7 +3893,7 @@ static void test_insert() result = mysql_store_result(mysql); mytest(result); - myassert((int)tiny_data == my_process_result_set(result)); + assert((int)tiny_data == my_process_result_set(result)); mysql_free_result(result); } @@ -4074,18 +4059,18 @@ static void test_stmt_close() rc= mysql_stmt_close(stmt1); fprintf(stdout,"\n mysql_close_stmt(1) returned: %d", rc); - myassert(rc == 0); + assert(rc == 0); mysql_close(lmysql); /* it should free all open stmts(stmt3, 2 and 1) */ #if NOT_VALID rc= mysql_stmt_close(stmt3); fprintf(stdout,"\n mysql_close_stmt(3) returned: %d", rc); - myassert( rc == 1); + assert( rc == 1); rc= mysql_stmt_close(stmt2); fprintf(stdout,"\n mysql_close_stmt(2) returned: %d", rc); - myassert( rc == 1); + assert( rc == 1); #endif count= 100; @@ -4105,7 +4090,7 @@ static void test_stmt_close() rc= mysql_stmt_close(stmt_x); fprintf(stdout,"\n mysql_close_stmt(x) returned: %d", rc); - myassert( rc == 0); + assert( rc == 0); rc = mysql_query(mysql,"SELECT id FROM test_stmt_close"); myquery(rc); @@ -4113,7 +4098,7 @@ static void test_stmt_close() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_free_result(result); } @@ -4161,9 +4146,9 @@ static void test_set_variable() fprintf(stdout, "\n max_error_count(default): %d", get_count); def_count= get_count; - myassert(strcmp(var,"max_error_count") == 0); + assert(strcmp(var,"max_error_count") == 0); rc = mysql_fetch(stmt1); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); stmt = mysql_prepare(mysql, "set max_error_count=?", 50); mystmt_init(stmt); @@ -4189,10 +4174,10 @@ static void test_set_variable() mystmt(stmt1, rc); fprintf(stdout, "\n max_error_count : %d", get_count); - myassert(get_count == set_count); + assert(get_count == set_count); rc = mysql_fetch(stmt1); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); /* restore back to default */ set_count= def_count; @@ -4206,10 +4191,10 @@ static void test_set_variable() mystmt(stmt1, rc); fprintf(stdout, "\n max_error_count(default): %d", get_count); - myassert(get_count == set_count); + assert(get_count == set_count); rc = mysql_fetch(stmt1); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); mysql_stmt_close(stmt1); @@ -4265,12 +4250,12 @@ static void test_insert_meta() field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col1"); - myassert(strcmp(field->name,"col1")==0); + assert(strcmp(field->name,"col1")==0); field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col3"); - myassert(strcmp(field->name,"col3")==0); + assert(strcmp(field->name,"col3")==0); field= mysql_fetch_field(result); mytest_r(field); @@ -4329,15 +4314,15 @@ static void test_update_meta() mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); - myassert(strcmp(field->name,"col1")==0); - myassert(strcmp(field->table,"test_prep_update")==0); + assert(strcmp(field->name,"col1")==0); + assert(strcmp(field->table,"test_prep_update")==0); field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col3"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); - myassert(strcmp(field->name,"col3")==0); - myassert(strcmp(field->table,"test_prep_update")==0); + assert(strcmp(field->name,"col3")==0); + assert(strcmp(field->table,"test_prep_update")==0); field= mysql_fetch_field(result); mytest_r(field); @@ -4394,15 +4379,15 @@ static void test_select_meta() mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); - myassert(strcmp(field->name,"col1")==0); - myassert(strcmp(field->table,"test_prep_select")==0); + assert(strcmp(field->name,"col1")==0); + assert(strcmp(field->table,"test_prep_select")==0); field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col2"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); - myassert(strcmp(field->name,"col2")==0); - myassert(strcmp(field->table,"test_prep_select")==0); + assert(strcmp(field->name,"col2")==0); + assert(strcmp(field->table,"test_prep_select")==0); field= mysql_fetch_field(result); mytest_r(field); @@ -4448,7 +4433,7 @@ static void test_func_fields() mytest(field); fprintf(stdout,"\n table name: `%s` (expected: `%s`)", field->table, "test_dateformat"); - myassert(strcmp(field->table, "test_dateformat")==0); + assert(strcmp(field->table, "test_dateformat")==0); field = mysql_fetch_field(result); mytest_r(field); /* no more fields */ @@ -4465,7 +4450,7 @@ static void test_func_fields() field = mysql_fetch_field(result); mytest(field); fprintf(stdout,"\n table name: `%s` (expected: `%s`)", field->table, ""); - myassert(field->table[0] == '\0'); + assert(field->table[0] == '\0'); field = mysql_fetch_field(result); mytest_r(field); /* no more fields */ @@ -4483,8 +4468,8 @@ static void test_func_fields() mytest(field); fprintf(stdout,"\n field name: `%s` (expected: `%s`)", field->name, "YEAR"); fprintf(stdout,"\n field org name: `%s` (expected: `%s`)",field->org_name,""); - myassert(strcmp(field->name, "YEAR")==0); - myassert(field->org_name[0] == '\0'); + assert(strcmp(field->name, "YEAR")==0); + assert(field->org_name[0] == '\0'); field = mysql_fetch_field(result); mytest_r(field); /* no more fields */ @@ -4552,11 +4537,11 @@ static void test_multi_stmt() fprintf(stdout, "\n int_data: %d(%lu)", id, length[0]); fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); - myassert(id == 10); - myassert(strcmp(name,"mysql")==0); + assert(id == 10); + assert(strcmp(name,"mysql")==0); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); /* alter the table schema now */ stmt1 = mysql_prepare(mysql,"DELETE FROM test_multi_table WHERE id = ? AND name=?",100); @@ -4580,11 +4565,11 @@ static void test_multi_stmt() fprintf(stdout, "\n int_data: %d(%lu)", id, length[0]); fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); - myassert(id == 10); - myassert(strcmp(name,"updated")==0); + assert(id == 10); + assert(strcmp(name,"updated")==0); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); rc = mysql_execute(stmt1); mystmt(stmt1, rc); @@ -4597,9 +4582,9 @@ static void test_multi_stmt() mystmt(stmt, rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); - myassert(0 == my_stmt_result("SELECT * FROM test_multi_table",50)); + assert(0 == my_stmt_result("SELECT * FROM test_multi_table",50)); mysql_stmt_close(stmt); mysql_stmt_close(stmt2); @@ -4750,7 +4735,7 @@ static void test_manual_sample() fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); exit(0); } - myassert(2 == my_stmt_result("SELECT * FROM test_table",50)); + assert(2 == my_stmt_result("SELECT * FROM test_table",50)); /* DROP THE TABLE */ if (mysql_query(mysql,"DROP TABLE test_table")) @@ -4811,87 +4796,135 @@ static void test_prepare_alter() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert(4 == my_stmt_result("SELECT * FROM test_prep_alter",50)); + assert(4 == my_stmt_result("SELECT * FROM test_prep_alter",50)); mysql_stmt_close(stmt); } /******************************************************** -* to test the support of multi-query executions * +* to test the support of multi-statement executions * *********************************************************/ -static void test_multi_query() + +static void test_multi_statements() { - MYSQL *l_mysql, *org_mysql; + MYSQL *mysql_local; MYSQL_RES *result; int rc; - const char *query= "DROP TABLE IF EXISTS test_multi_tab;\ - CREATE TABLE test_multi_tab(id int,name char(20));\ - INSERT INTO test_multi_tab(xxxx) VALUES(10);\ - UPDATE test_multi_tab SET id=10 WHERE unkown_col=10;\ - CREATE TABLE test_multi_tab(id int,name char(20));\ - INSERT INTO test_multi_tab(id) VALUES(10),(20);\ - INSERT INTO test_multi_tab VALUES(20,'insert;comma');\ - SELECT * FROM test_multi_tab;\ - UPDATE test_multi_tab SET unknown_col=100 WHERE id=100;\ - UPDATE test_multi_tab SET name='new;name' WHERE id=20;\ - DELETE FROM test_multi_tab WHERE name='new;name';\ - SELECT * FROM test_multi_tab;\ - DELETE FROM test_multi_tab WHERE id=10;\ - SELECT * FROM test_multi_tab;\ - DROP TABLE test_multi_tab;\ - DROP TABLE test_multi_tab;\ - DROP TABLE IF EXISTS test_multi_tab"; - uint count, rows[16]={0,1054,1054,1050,2,1,3,1054,2,2,1,1,0,0,1051,0}, exp_value; - - myheader("test_multi_query"); + const char *query="\ +DROP TABLE IF EXISTS test_multi_tab;\ +CREATE TABLE test_multi_tab(id int,name char(20));\ +INSERT INTO test_multi_tab(id) VALUES(10),(20);\ +INSERT INTO test_multi_tab VALUES(20,'insert;comma');\ +SELECT * FROM test_multi_tab;\ +UPDATE test_multi_tab SET name='new;name' WHERE id=20;\ +DELETE FROM test_multi_tab WHERE name='new;name';\ +SELECT * FROM test_multi_tab;\ +DELETE FROM test_multi_tab WHERE id=10;\ +SELECT * FROM test_multi_tab;\ +DROP TABLE test_multi_tab;\ +select 1;\ +DROP TABLE IF EXISTS test_multi_tab"; + uint count, exp_value; + uint rows[]= {0, 0, 2, 1, 3, 2, 2, 1, 1, 0, 0, 1, 0}; + + myheader("test_multi_statements"); + /* + First test that we get an error for multi statements + (Becasue default connection is not opened with CLIENT_MULTI_STATEMENTS) + */ rc = mysql_query(mysql, query); /* syntax error */ myquery_r(rc); - myassert(0 == mysql_next_result(mysql)); - myassert(0 == mysql_more_results(mysql)); + assert(-1 == mysql_next_result(mysql)); + assert(0 == mysql_more_results(mysql)); - if (!(l_mysql = mysql_init(NULL))) + if (!(mysql_local = mysql_init(NULL))) { fprintf(stdout,"\n mysql_init() failed"); exit(1); } - if (!(mysql_real_connect(l_mysql,opt_host,opt_user, + + /* Create connection that supprot multi statements */ + if (!(mysql_real_connect(mysql_local,opt_host,opt_user, opt_password, current_db, opt_port, - opt_unix_socket, CLIENT_MULTI_STATEMENTS))) /* enable multi queries */ + opt_unix_socket, CLIENT_MULTI_STATEMENTS))) { - fprintf(stdout,"\n connection failed(%s)", mysql_error(l_mysql)); + fprintf(stdout,"\n connection failed(%s)", mysql_error(mysql_local)); exit(1); - } - org_mysql= mysql; - mysql= l_mysql; + } - rc = mysql_query(mysql, query); + rc = mysql_query(mysql_local, query); myquery(rc); - count= exp_value= 0; - while (mysql_more_results(mysql) && count < array_elements(rows)) + for (count=0 ; count < array_elements(rows) ; count++) { fprintf(stdout,"\n Query %d: ", count); - if ((rc= mysql_next_result(mysql))) + if ((result= mysql_store_result(mysql_local))) + my_process_result_set(result); + else + fprintf(stdout,"OK, %lld row(s) affected, %d warning(s)\n", + mysql_affected_rows(mysql_local), + mysql_warning_count(mysql_local)); + + exp_value= (uint) mysql_affected_rows(mysql_local); + if (rows[count] != exp_value) { - exp_value= mysql_errno(mysql); - fprintf(stdout, "ERROR %d: %s", exp_value, mysql_error(mysql)); + fprintf(stdout, "row %d had affected rows: %d, should be %d\n", + count, exp_value, rows[count]); + exit(1); + } + if (count != array_elements(rows) -1) + { + if (!(rc= mysql_more_results(mysql_local))) + { + fprintf(stdout, + "mysql_more_result returned wrong value: %d for row %d\n", + rc, count); + exit(1); + } + if ((rc= mysql_next_result(mysql_local))) + { + exp_value= mysql_errno(mysql_local); + + exit(1); + } } else { - if ((result= mysql_store_result(mysql))) - my_process_result_set(result); - else - fprintf(stdout,"OK, %lld row(s) affected, %d warning(s)", - mysql_affected_rows(mysql), - mysql_warning_count(mysql)); - exp_value= (uint) mysql_affected_rows(mysql); + assert(mysql_more_results(mysql_local) == 0); + assert(mysql_next_result(mysql_local) == -1); } - myassert(rows[count++] == exp_value); } - mysql= org_mysql; + + /* check that errors abort multi statements */ + + rc= mysql_query(mysql_local, "select 1+1+a;select 1+1"); + myquery_r(rc); + assert(mysql_more_results(mysql_local) == 0); + assert(mysql_next_result(mysql_local) == -1); + + rc= mysql_query(mysql_local, "select 1+1;select 1+1+a;select 1"); + myquery(rc); + result= mysql_store_result(mysql_local); + mytest(result); + mysql_free_result(result); + assert(mysql_more_results(mysql_local) == 1); + assert(mysql_next_result(mysql_local) > 0); + + /* + Ensure that we can now do a simple query (this checks that the server is + not trying to send us the results for the last 'select 1' + */ + rc= mysql_query(mysql_local, "select 1+1+1"); + myquery(rc); + result= mysql_store_result(mysql_local); + mytest(result); + my_process_result_set(result); + mysql_free_result(result); + + mysql_close(mysql_local); } @@ -4961,17 +4994,17 @@ static void test_store_result() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %ld,%s(%lu)", nData, szData, length1); - myassert(nData == 10); - myassert(strcmp(szData,"venu")==0); - myassert(length1 == 4); + assert(nData == 10); + assert(strcmp(szData,"venu")==0); + assert(length1 == 4); rc = mysql_fetch(stmt); mystmt(stmt,rc); fprintf(stdout,"\n row 2: %ld,%s(%lu)",nData, szData, length1); - myassert(nData == 20); - myassert(strcmp(szData,"mysql")==0); - myassert(length1 == 5); + assert(nData == 20); + assert(strcmp(szData,"mysql")==0); + assert(length1 == 5); length=99; rc = mysql_fetch(stmt); @@ -4979,12 +5012,12 @@ static void test_store_result() if (is_null[0]) fprintf(stdout,"\n row 3: NULL,%s(%lu)", szData, length1); - myassert(is_null[0]); - myassert(strcmp(szData,"monty")==0); - myassert(length1 == 5); + assert(is_null[0]); + assert(strcmp(szData,"monty")==0); + assert(length1 == 5); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); rc = mysql_execute(stmt); mystmt(stmt, rc); @@ -4996,17 +5029,17 @@ static void test_store_result() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %ld,%s(%lu)",nData, szData, length1); - myassert(nData == 10); - myassert(strcmp(szData,"venu")==0); - myassert(length1 == 4); + assert(nData == 10); + assert(strcmp(szData,"venu")==0); + assert(length1 == 4); rc = mysql_fetch(stmt); mystmt(stmt,rc); fprintf(stdout,"\n row 2: %ld,%s(%lu)",nData, szData, length1); - myassert(nData == 20); - myassert(strcmp(szData,"mysql")==0); - myassert(length1 == 5); + assert(nData == 20); + assert(strcmp(szData,"mysql")==0); + assert(length1 == 5); length=99; rc = mysql_fetch(stmt); @@ -5014,12 +5047,12 @@ static void test_store_result() if (is_null[0]) fprintf(stdout,"\n row 3: NULL,%s(%lu)", szData, length1); - myassert(is_null[0]); - myassert(strcmp(szData,"monty")==0); - myassert(length1 == 5); + assert(is_null[0]); + assert(strcmp(szData,"monty")==0); + assert(length1 == 5); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -5069,7 +5102,7 @@ static void test_store_result1() while (mysql_fetch(stmt) != MYSQL_NO_DATA) rc++; fprintf(stdout, "\n total rows: %d", rc); - myassert(rc == 3); + assert(rc == 3); rc = mysql_execute(stmt); mystmt(stmt, rc); @@ -5081,7 +5114,7 @@ static void test_store_result1() while (mysql_fetch(stmt) != MYSQL_NO_DATA) rc++; fprintf(stdout, "\n total rows: %d", rc); - myassert(rc == 3); + assert(rc == 3); mysql_stmt_close(stmt); } @@ -5148,10 +5181,10 @@ static void test_store_result2() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d",nData); - myassert(nData == 10); + assert(nData == 10); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); nData = 20; rc = mysql_execute(stmt); @@ -5165,10 +5198,10 @@ static void test_store_result2() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d",nData); - myassert(nData == 20); + assert(nData == 20); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -5242,11 +5275,11 @@ static void test_subselect() mysql_stmt_close(stmt); - myassert(3 == my_stmt_result("SELECT * FROM test_sub2",50)); + assert(3 == my_stmt_result("SELECT * FROM test_sub2",50)); strmov((char *)query , "SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=?)"); - myassert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=8)",100)); - myassert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=7)",100)); + assert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=8)",100)); + assert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=7)",100)); stmt = mysql_prepare(mysql, query, 150); mystmt_init(stmt); @@ -5265,10 +5298,10 @@ static void test_subselect() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d",id); - myassert(id == 1); + assert(id == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); id= 8; rc = mysql_execute(stmt); @@ -5278,10 +5311,10 @@ static void test_subselect() mystmt(stmt,rc); fprintf(stdout,"\n row 1: %d",id); - myassert(id == 0); + assert(id == 0); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); #endif @@ -5356,7 +5389,7 @@ static void test_bind_date_conv(uint row_count) mysql_stmt_close(stmt); - myassert(row_count == my_stmt_result("SELECT * FROM test_date",50)); + assert(row_count == my_stmt_result("SELECT * FROM test_date",50)); stmt = mysql_prepare(mysql,"SELECT * FROM test_date",50); myquery(rc); @@ -5384,23 +5417,23 @@ static void test_bind_date_conv(uint row_count) tm[i].hour, tm[i].minute, tm[i].second, tm[i].second_part); - myassert(tm[i].year == 0 || tm[i].year == year+count); - myassert(tm[i].month == 0 || tm[i].month == month+count); - myassert(tm[i].day == 0 || tm[i].day == day+count); + assert(tm[i].year == 0 || tm[i].year == year+count); + assert(tm[i].month == 0 || tm[i].month == month+count); + assert(tm[i].day == 0 || tm[i].day == day+count); - myassert(tm[i].hour == 0 || tm[i].hour == hour+count); + assert(tm[i].hour == 0 || tm[i].hour == hour+count); /* minute causes problems from date<->time, don't assert, instead validate separatly in another routine */ - /*myassert(tm[i].minute == 0 || tm[i].minute == minute+count); - myassert(tm[i].second == 0 || tm[i].second == sec+count);*/ + /*assert(tm[i].minute == 0 || tm[i].minute == minute+count); + assert(tm[i].second == 0 || tm[i].second == sec+count);*/ - myassert(tm[i].second_part == 0 || tm[i].second_part == second_part+count); + assert(tm[i].second_part == 0 || tm[i].second_part == second_part+count); } } rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -5673,9 +5706,9 @@ static void test_buffers() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - myassert(buffer[0] == 'M'); - myassert(buffer[1] == 'X'); - myassert(length == 5); + assert(buffer[0] == 'M'); + assert(buffer[1] == 'X'); + assert(length == 5); bind[0].buffer_length=8; rc = mysql_bind_result(stmt, bind);/* re-bind */ @@ -5684,8 +5717,8 @@ static void test_buffers() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - myassert(strncmp(buffer,"Database",8) == 0); - myassert(length == 8); + assert(strncmp(buffer,"Database",8) == 0); + assert(length == 8); bind[0].buffer_length=12; rc = mysql_bind_result(stmt, bind);/* re-bind */ @@ -5694,8 +5727,8 @@ static void test_buffers() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - myassert(strcmp(buffer,"Open-Source") == 0); - myassert(length == 11); + assert(strcmp(buffer,"Open-Source") == 0); + assert(length == 11); bind[0].buffer_length=6; rc = mysql_bind_result(stmt, bind);/* re-bind */ @@ -5704,8 +5737,8 @@ static void test_buffers() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - myassert(strncmp(buffer,"Popula",6) == 0); - myassert(length == 7); + assert(strncmp(buffer,"Popula",6) == 0); + assert(length == 7); mysql_stmt_close(stmt); } @@ -5736,7 +5769,7 @@ static void test_open_direct() result = mysql_store_result(mysql); mytest(result); - myassert(0 == my_process_result_set(result)); + assert(0 == my_process_result_set(result)); rc = mysql_execute(stmt); mystmt(stmt, rc); @@ -5749,7 +5782,7 @@ static void test_open_direct() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); rc = mysql_execute(stmt); mystmt(stmt, rc); @@ -5762,7 +5795,7 @@ static void test_open_direct() result = mysql_store_result(mysql); mytest(result); - myassert(2 == my_process_result_set(result)); + assert(2 == my_process_result_set(result)); mysql_stmt_close(stmt); /* run a direct query in the middle of a fetch */ @@ -5828,7 +5861,7 @@ static void test_fetch_nobuffs() rc++; fprintf(stdout, "\n total rows : %d", rc); - myassert(rc == 1); + assert(rc == 1); bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer= (char *)str[0]; @@ -5856,7 +5889,7 @@ static void test_fetch_nobuffs() fprintf(stdout, "\n CURRENT_TIME() : %s", str[3]); } fprintf(stdout, "\n total rows : %d", rc); - myassert(rc == 1); + assert(rc == 1); mysql_stmt_close(stmt); } @@ -5927,20 +5960,20 @@ static void test_ushort_bug() fprintf(stdout,"\n longlong : %lld (%ld)", longlong_value, ll_length); fprintf(stdout,"\n tinyint : %d (%ld)", tiny_value, t_length); - myassert(short_value == 35999); - myassert(s_length == 2); + assert(short_value == 35999); + assert(s_length == 2); - myassert(long_value == 35999); - myassert(l_length == 4); + assert(long_value == 35999); + assert(l_length == 4); - myassert(longlong_value == 35999); - myassert(ll_length == 8); + assert(longlong_value == 35999); + assert(ll_length == 8); - myassert(tiny_value == 200); - myassert(t_length == 1); + assert(tiny_value == 200); + assert(t_length == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -6011,20 +6044,20 @@ static void test_sshort_bug() fprintf(stdout,"\n longlong : %lld (%ld)", longlong_value, ll_length); fprintf(stdout,"\n tinyint : %d (%ld)", tiny_value, t_length); - myassert(short_value == -5999); - myassert(s_length == 2); + assert(short_value == -5999); + assert(s_length == 2); - myassert(long_value == -5999); - myassert(l_length == 4); + assert(long_value == -5999); + assert(l_length == 4); - myassert(longlong_value == 35999); - myassert(ll_length == 8); + assert(longlong_value == 35999); + assert(ll_length == 8); - myassert(tiny_value == 200); - myassert(t_length == 1); + assert(tiny_value == 200); + assert(t_length == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -6095,20 +6128,20 @@ static void test_stiny_bug() fprintf(stdout,"\n longlong : %lld (%ld)", longlong_value, ll_length); fprintf(stdout,"\n tinyint : %d (%ld)", tiny_value, t_length); - myassert(short_value == -128); - myassert(s_length == 2); + assert(short_value == -128); + assert(s_length == 2); - myassert(long_value == -127); - myassert(l_length == 4); + assert(long_value == -127); + assert(l_length == 4); - myassert(longlong_value == 255); - myassert(ll_length == 8); + assert(longlong_value == 255); + assert(ll_length == 8); - myassert(tiny_value == 0); - myassert(t_length == 1); + assert(tiny_value == 0); + assert(t_length == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -6133,7 +6166,7 @@ static void test_field_misc() result = mysql_store_result(mysql); mytest(result); - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); verify_prepare_field(result,0, "@@autocommit","", /* field and its org name */ @@ -6152,7 +6185,7 @@ static void test_field_misc() result = mysql_get_metadata(stmt); mytest(result); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@autocommit","", /* field and its org name */ @@ -6183,7 +6216,7 @@ static void test_field_misc() fprintf(stdout,"\n default table type: %s(%ld)", table_type, type_length); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -6196,7 +6229,7 @@ static void test_field_misc() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@table_type","", /* field and its org name */ @@ -6216,7 +6249,7 @@ static void test_field_misc() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@max_error_count","", /* field and its org name */ @@ -6236,7 +6269,7 @@ static void test_field_misc() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@max_allowed_packet","", /* field and its org name */ @@ -6256,7 +6289,7 @@ static void test_field_misc() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(1 == my_process_stmt_result(stmt)); + assert(1 == my_process_stmt_result(stmt)); verify_prepare_field(result,0, "@@sql_warnings","", /* field and its org name */ @@ -6303,7 +6336,7 @@ static void test_set_option() result = mysql_store_result(mysql); mytest(result); - myassert(2 == my_process_result_set(result)); + assert(2 == my_process_result_set(result)); mysql_free_result(result); @@ -6314,7 +6347,7 @@ static void test_set_option() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(2 == my_process_stmt_result(stmt)); + assert(2 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); @@ -6329,7 +6362,7 @@ static void test_set_option() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert(4 == my_process_stmt_result(stmt)); + assert(4 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } @@ -6400,7 +6433,7 @@ static void test_prepare_grant() execute_prepare_query("INSERT INTO test_grant(a) VALUES(NULL)",1); execute_prepare_query("INSERT INTO test_grant VALUES(NULL)",1); execute_prepare_query("UPDATE test_grant SET a=9 WHERE a=1",1); - myassert(4 == my_stmt_result("SELECT a FROM test_grant",50)); + assert(4 == my_stmt_result("SELECT a FROM test_grant",50)); rc = mysql_query(mysql,"DELETE FROM test_grant"); myquery_r(rc); @@ -6411,18 +6444,18 @@ static void test_prepare_grant() rc = mysql_execute(stmt); myquery_r(rc); - myassert(4 == my_stmt_result("SELECT * FROM test_grant",50)); + assert(4 == my_stmt_result("SELECT * FROM test_grant",50)); mysql_close(lmysql); mysql= org_mysql; rc = mysql_query(mysql,"delete from mysql.user where User='test_grant'"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); rc = mysql_query(mysql,"delete from mysql.tables_priv where User='test_grant'"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); } } @@ -6476,7 +6509,7 @@ static void test_frm_bug() fprintf(stdout,"\n data directory: %s", data_dir); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); strxmov(test_frm,data_dir,"/",current_db,"/","test_frm_bug.frm",NullS); @@ -6496,7 +6529,7 @@ static void test_frm_bug() result = mysql_store_result(mysql); mytest(result);/* It can't be NULL */ - myassert(1 == my_process_result_set(result)); + assert(1 == my_process_result_set(result)); mysql_data_seek(result,0); @@ -6504,7 +6537,7 @@ static void test_frm_bug() mytest(row); fprintf(stdout,"\n Comment: %s", row[16]); - myassert(row[16] != 0); + assert(row[16] != 0); mysql_free_result(result); mysql_stmt_close(stmt); @@ -6562,10 +6595,10 @@ static void test_decimal_bug() mystmt(stmt,rc); fprintf(stdout, "\n data: %g", data); - myassert(data == 8.0); + assert(data == 8.0); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); data= 5.61; rc = mysql_execute(stmt); @@ -6579,17 +6612,17 @@ static void test_decimal_bug() mystmt(stmt,rc); fprintf(stdout, "\n data: %g", data); - myassert(data == 5.61); + assert(data == 5.61); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); is_null= 1; rc = mysql_execute(stmt); mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); data= 10.22; is_null= 0; rc = mysql_execute(stmt); @@ -6603,10 +6636,10 @@ static void test_decimal_bug() mystmt(stmt,rc); fprintf(stdout, "\n data: %g", data); - myassert(data == 10.22); + assert(data == 10.22); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -6639,14 +6672,14 @@ static void test_explain_bug() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert( 2 == my_process_stmt_result(stmt)); + assert( 2 == my_process_stmt_result(stmt)); result = mysql_get_metadata(stmt); mytest(result); fprintf(stdout, "\n total fields in the result: %d", mysql_num_fields(result)); - myassert(6 == mysql_num_fields(result)); + assert(6 == mysql_num_fields(result)); verify_prepare_field(result,0,"Field","",MYSQL_TYPE_VAR_STRING, "","","",NAME_LEN,0); @@ -6675,14 +6708,14 @@ static void test_explain_bug() rc = mysql_execute(stmt); mystmt(stmt, rc); - myassert( 1 == my_process_stmt_result(stmt)); + assert( 1 == my_process_stmt_result(stmt)); result = mysql_get_metadata(stmt); mytest(result); fprintf(stdout, "\n total fields in the result: %d", mysql_num_fields(result)); - myassert(10 == mysql_num_fields(result)); + assert(10 == mysql_num_fields(result)); verify_prepare_field(result,0,"id","",MYSQL_TYPE_LONGLONG, "","","",3,0); @@ -6718,10 +6751,25 @@ static void test_explain_bug() mysql_stmt_close(stmt); } +#ifdef NOT_YET_WORKING + /* To test math functions bug #148 (reported by salle@mysql.com). */ + +#define myerrno(n) check_errcode(n) + +static void check_errcode(const unsigned int err) +{ + if (mysql->server_version) + fprintf(stdout,"\n [MySQL-%s]",mysql->server_version); + else + fprintf(stdout,"\n [MySQL]"); + fprintf(stdout,"[%d] %s\n",mysql_errno(mysql),mysql_error(mysql)); + assert(mysql_errno(mysql) == err); +} + static void test_drop_temp() { int rc; @@ -6814,18 +6862,19 @@ static void test_drop_temp() rc = mysql_query(mysql,"drop database test_drop_temp_db"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); rc = mysql_query(mysql,"delete from mysql.user where User='test_temp'"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); rc = mysql_query(mysql,"delete from mysql.tables_priv where User='test_temp'"); myquery(rc); - myassert(1 == mysql_affected_rows(mysql)); + assert(1 == mysql_affected_rows(mysql)); } } +#endif /* To test warnings for cuted rows @@ -6851,14 +6900,14 @@ static void test_cuted_rows() count= mysql_warning_count(mysql); fprintf(stdout, "\n total warnings: %d", count); - myassert(count == 0); + assert(count == 0); rc = mysql_query(mysql, "INSERT INTO t2 SELECT * FROM t1"); myquery(rc); count= mysql_warning_count(mysql); fprintf(stdout, "\n total warnings: %d", count); - myassert(count == 2); + assert(count == 2); rc = mysql_query(mysql, "SHOW WARNINGS"); myquery(rc); @@ -6866,7 +6915,7 @@ static void test_cuted_rows() result = mysql_store_result(mysql); mytest(result); - myassert(2 == my_process_result_set(result)); + assert(2 == my_process_result_set(result)); mysql_free_result(result); rc = mysql_query(mysql, "INSERT INTO t1 VALUES('junk'),(876789)"); @@ -6874,7 +6923,7 @@ static void test_cuted_rows() count= mysql_warning_count(mysql); fprintf(stdout, "\n total warnings: %d", count); - myassert(count == 2); + assert(count == 2); rc = mysql_query(mysql, "SHOW WARNINGS"); myquery(rc); @@ -6882,7 +6931,7 @@ static void test_cuted_rows() result = mysql_store_result(mysql); mytest(result); - myassert(2 == my_process_result_set(result)); + assert(2 == my_process_result_set(result)); mysql_free_result(result); } @@ -6985,44 +7034,44 @@ static void test_logs() fprintf(stdout, "\n id : %d", id); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(id == 9876); - myassert(length == 19); /* Due to VARCHAR(20) */ - myassert(strcmp(data,"MySQL - Open Source")==0); + assert(id == 9876); + assert(length == 19); /* Due to VARCHAR(20) */ + assert(strcmp(data,"MySQL - Open Source")==0); rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(length == 1); - myassert(strcmp(data,"'")==0); + assert(length == 1); + assert(strcmp(data,"'")==0); rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(length == 1); - myassert(strcmp(data,"\"")==0); + assert(length == 1); + assert(strcmp(data,"\"")==0); rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(length == 7); - myassert(strcmp(data,"my\'sql\'")==0); + assert(length == 7); + assert(strcmp(data,"my\'sql\'")==0); rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n name : %s(%ld)", data, length); - myassert(length == 7); - /*myassert(strcmp(data,"my\"sql\"")==0); */ + assert(length == 7); + /*assert(strcmp(data,"my\"sql\"")==0); */ rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -7089,10 +7138,10 @@ static void test_nstmts() rc = mysql_fetch(stmt); mystmt(stmt, rc); fprintf(stdout, "\n total rows: %d", i); - myassert( i == total_stmts); + assert( i == total_stmts); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -7189,7 +7238,7 @@ static void test_fetch_seek() mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -7249,17 +7298,17 @@ static void test_fetch_offset() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s (%ld)", data, length); - myassert(strncmp(data,"abcd",4) == 0 && length == 10); + assert(strncmp(data,"abcd",4) == 0 && length == 10); rc = mysql_fetch_column(stmt,bind,0,5); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s (%ld)", data, length); - myassert(strncmp(data,"fg",2) == 0 && length == 10); + assert(strncmp(data,"fg",2) == 0 && length == 10); rc = mysql_fetch_column(stmt,bind,0,9); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %s (%ld)", data, length); - myassert(strncmp(data,"j",1) == 0 && length == 10); + assert(strncmp(data,"j",1) == 0 && length == 10); rc = mysql_fetch(stmt); mystmt(stmt,rc); @@ -7269,10 +7318,10 @@ static void test_fetch_offset() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); - myassert(is_null == 1); + assert(is_null == 1); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); rc = mysql_fetch_column(stmt,bind,1,0); mystmt_r(stmt,rc); @@ -7342,13 +7391,13 @@ static void test_fetch_column() rc = mysql_fetch_column(stmt,bind,1,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - myassert(strncmp(c2,"venu",4)==0 && l2 == 4); + assert(strncmp(c2,"venu",4)==0 && l2 == 4); c2[0]= '\0'; l2= 0; rc = mysql_fetch_column(stmt,bind,1,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - myassert(strcmp(c2,"venu")==0 && l2 == 4); + assert(strcmp(c2,"venu")==0 && l2 == 4); c1= 0; bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -7360,7 +7409,7 @@ static void test_fetch_column() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); - myassert(c1 == 1 && l1 == 4); + assert(c1 == 1 && l1 == 4); rc = mysql_fetch_column(stmt,bind,10,0); mystmt_r(stmt,rc); @@ -7380,13 +7429,13 @@ static void test_fetch_column() rc = mysql_fetch_column(stmt,bind,1,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - myassert(strncmp(c2,"mysq",4)==0 && l2 == 5); + assert(strncmp(c2,"mysq",4)==0 && l2 == 5); c2[0]= '\0'; l2= 0; rc = mysql_fetch_column(stmt,bind,1,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %si(%ld)", c2, l2); - myassert(strcmp(c2,"mysql")==0 && l2 == 5); + assert(strcmp(c2,"mysql")==0 && l2 == 5); c1= 0; bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -7398,10 +7447,10 @@ static void test_fetch_column() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); - myassert(c1 == 2 && l1 == 4); + assert(c1 == 2 && l1 == 4); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); rc = mysql_fetch_column(stmt,bind,1,0); mystmt_r(stmt,rc); @@ -7427,7 +7476,7 @@ static void test_list_fields() result = mysql_list_fields(mysql, "test_list_fields",NULL); mytest(result); - myassert( 0 == my_process_result_set(result)); + assert( 0 == my_process_result_set(result)); verify_prepare_field(result,0,"c1","c1",MYSQL_TYPE_LONG, "test_list_fields","test_list_fields",current_db,11,"0"); @@ -7486,7 +7535,7 @@ static void test_mem_overun() rc = mysql_query(mysql,"select * from t_mem_overun"); myquery(rc); - myassert(1 == my_process_result(mysql)); + assert(1 == my_process_result(mysql)); stmt = mysql_prepare(mysql, "select * from t_mem_overun",30); mystmt_init(stmt); @@ -7498,7 +7547,7 @@ static void test_mem_overun() mytest(field_res); fprintf(stdout,"\n total fields : %d", mysql_num_fields(field_res)); - myassert( 1000 == mysql_num_fields(field_res)); + assert( 1000 == mysql_num_fields(field_res)); rc = mysql_stmt_store_result(stmt); mystmt(stmt,rc); @@ -7507,7 +7556,7 @@ static void test_mem_overun() mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } @@ -7562,7 +7611,7 @@ static void test_free_result() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %s(%ld)", c2, l2); - myassert(strncmp(c2,"1",1)==0 && l2 == 1); + assert(strncmp(c2,"1",1)==0 && l2 == 1); rc = mysql_fetch(stmt); mystmt(stmt,rc); @@ -7577,7 +7626,7 @@ static void test_free_result() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); - myassert(c1 == 2 && l2 == 4); + assert(c1 == 2 && l2 == 4); rc = mysql_query(mysql,"drop table test_free_result"); myquery_r(rc); /* error should be, COMMANDS OUT OF SYNC */ @@ -7644,7 +7693,7 @@ static void test_free_store_result() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - myassert(strncmp(c2,"1",1)==0 && l2 == 1); + assert(strncmp(c2,"1",1)==0 && l2 == 1); rc = mysql_fetch(stmt); mystmt(stmt,rc); @@ -7659,7 +7708,7 @@ static void test_free_store_result() rc = mysql_fetch_column(stmt,bind,0,0); mystmt(stmt,rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); - myassert(c1 == 2 && l2 == 4); + assert(c1 == 2 && l2 == 4); rc = mysql_stmt_free_result(stmt); mystmt(stmt,rc); @@ -7770,7 +7819,7 @@ static void test_sqlmode() mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); fprintf(stdout,"\n returned 1 row\n"); mysql_stmt_close(stmt); @@ -7793,7 +7842,7 @@ static void test_sqlmode() mystmt(stmt,rc); rc = mysql_fetch(stmt); - myassert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); fprintf(stdout,"\n returned 1 row"); mysql_stmt_close(stmt); @@ -7872,7 +7921,7 @@ static void test_ts() rc = mysql_execute(stmt); mystmt(stmt,rc); - myassert( 2== my_process_stmt_result(stmt)); + assert( 2== my_process_stmt_result(stmt)); field_count= mysql_num_fields(prep_res); mysql_free_result(prep_res); @@ -7899,7 +7948,7 @@ static void test_ts() row_count++; fprintf(stdout, "\n returned '%d' rows", row_count); - myassert(row_count == 2); + assert(row_count == 2); mysql_stmt_close(stmt); } } @@ -8108,7 +8157,7 @@ int main(int argc, char **argv) test_stmt_close(); /* mysql_stmt_close() test -- hangs */ test_prepare_field_result(); /* prepare meta info */ test_multi_stmt(); /* multi stmt test */ - test_multi_query(); /* test multi query execution */ + test_multi_statements(); /* test multi statement execution */ test_store_result(); /* test the store_result */ test_store_result1(); /* test store result without buffers */ test_store_result2(); /* test store result for misc case */ |