Commit 8010477a authored by unknown's avatar unknown

Merge joreland@bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/home/jonas/src/mysql-4.1

parents 92dce374 7b1f818d
...@@ -100,7 +100,10 @@ extern ulint srv_max_n_threads; ...@@ -100,7 +100,10 @@ extern ulint srv_max_n_threads;
extern lint srv_conc_n_threads; extern lint srv_conc_n_threads;
extern ibool srv_fast_shutdown; extern ibool srv_fast_shutdown;
extern ibool srv_very_fast_shutdown; /* if this TRUE, do not flush the
buffer pool to data files at the
shutdown; we effectively 'crash'
InnoDB */
extern ibool srv_innodb_status; extern ibool srv_innodb_status;
extern ibool srv_use_doublewrite_buf; extern ibool srv_use_doublewrite_buf;
......
...@@ -3048,13 +3048,25 @@ loop: ...@@ -3048,13 +3048,25 @@ loop:
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
log_archive_all(); log_archive_all();
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
log_make_checkpoint_at(ut_dulint_max, TRUE);
if (!srv_very_fast_shutdown) {
/* In a 'very fast' shutdown we do not flush the buffer pool:
it is essentially a 'crash' of the InnoDB server. */
log_make_checkpoint_at(ut_dulint_max, TRUE);
} else {
/* Make sure that the log is all flushed to disk, so that
we can recover all committed transactions in a crash
recovery */
log_buffer_flush_to_disk();
}
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
lsn = log_sys->lsn; lsn = log_sys->lsn;
if (ut_dulint_cmp(lsn, log_sys->last_checkpoint_lsn) != 0 if ((ut_dulint_cmp(lsn, log_sys->last_checkpoint_lsn) != 0
&& !srv_very_fast_shutdown)
#ifdef UNIV_LOG_ARCHIVE #ifdef UNIV_LOG_ARCHIVE
|| (srv_log_archive_on || (srv_log_archive_on
&& ut_dulint_cmp(lsn, && ut_dulint_cmp(lsn,
...@@ -3098,11 +3110,12 @@ loop: ...@@ -3098,11 +3110,12 @@ loop:
fil_flush_file_spaces(FIL_TABLESPACE); fil_flush_file_spaces(FIL_TABLESPACE);
fil_flush_file_spaces(FIL_LOG); fil_flush_file_spaces(FIL_LOG);
/* The next fil_write_... will pass the buffer pool: therefore /* The call fil_write_flushed_lsn_to_data_files() will pass the buffer
it is essential that the buffer pool has been completely flushed pool: therefore it is essential that the buffer pool has been
to disk! */ completely flushed to disk! (We do not call fil_write... if the
'very fast' shutdown is enabled.) */
if (!buf_all_freed()) { if (!srv_very_fast_shutdown && !buf_all_freed()) {
goto loop; goto loop;
} }
...@@ -3125,7 +3138,7 @@ loop: ...@@ -3125,7 +3138,7 @@ loop:
/* Make some checks that the server really is quiet */ /* Make some checks that the server really is quiet */
ut_a(srv_n_threads_active[SRV_MASTER] == 0); ut_a(srv_n_threads_active[SRV_MASTER] == 0);
ut_a(buf_all_freed()); ut_a(srv_very_fast_shutdown || buf_all_freed());
ut_a(0 == ut_dulint_cmp(lsn, log_sys->lsn)); ut_a(0 == ut_dulint_cmp(lsn, log_sys->lsn));
if (ut_dulint_cmp(lsn, srv_start_lsn) < 0) { if (ut_dulint_cmp(lsn, srv_start_lsn) < 0) {
...@@ -3140,7 +3153,15 @@ loop: ...@@ -3140,7 +3153,15 @@ loop:
srv_shutdown_lsn = lsn; srv_shutdown_lsn = lsn;
fil_write_flushed_lsn_to_data_files(lsn, arch_log_no); if (!srv_very_fast_shutdown) {
/* In a 'very fast' shutdown we do not flush the buffer pool:
it is essentially a 'crash' of the InnoDB server. Then we must
not write the lsn stamps to the data files, since at a
startup InnoDB deduces from the stamps if the previous
shutdown was clean. */
fil_write_flushed_lsn_to_data_files(lsn, arch_log_no);
}
fil_flush_file_spaces(FIL_TABLESPACE); fil_flush_file_spaces(FIL_TABLESPACE);
...@@ -3148,7 +3169,7 @@ loop: ...@@ -3148,7 +3169,7 @@ loop:
/* Make some checks that the server really is quiet */ /* Make some checks that the server really is quiet */
ut_a(srv_n_threads_active[SRV_MASTER] == 0); ut_a(srv_n_threads_active[SRV_MASTER] == 0);
ut_a(buf_all_freed()); ut_a(srv_very_fast_shutdown || buf_all_freed());
ut_a(0 == ut_dulint_cmp(lsn, log_sys->lsn)); ut_a(0 == ut_dulint_cmp(lsn, log_sys->lsn));
} }
......
...@@ -249,6 +249,10 @@ merge to completion before shutdown */ ...@@ -249,6 +249,10 @@ merge to completion before shutdown */
ibool srv_fast_shutdown = FALSE; ibool srv_fast_shutdown = FALSE;
ibool srv_very_fast_shutdown = FALSE; /* if this TRUE, do not flush the
buffer pool to data files at the
shutdown; we effectively 'crash'
InnoDB */
/* Generate a innodb_status.<pid> file */ /* Generate a innodb_status.<pid> file */
ibool srv_innodb_status = FALSE; ibool srv_innodb_status = FALSE;
...@@ -2178,7 +2182,8 @@ loop: ...@@ -2178,7 +2182,8 @@ loop:
/*****************************************************************/ /*****************************************************************/
background_loop: background_loop:
/* ---- In this loop we run background operations when the server /* ---- In this loop we run background operations when the server
is quiet from user activity */ is quiet from user activity. Also in the case of a shutdown, we
loop here, flushing the buffer pool to the data files. */
/* The server has been quiet for a while: start running background /* The server has been quiet for a while: start running background
operations */ operations */
...@@ -2251,7 +2256,16 @@ background_loop: ...@@ -2251,7 +2256,16 @@ background_loop:
flush_loop: flush_loop:
srv_main_thread_op_info = "flushing buffer pool pages"; srv_main_thread_op_info = "flushing buffer pool pages";
n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
if (!srv_very_fast_shutdown) {
n_pages_flushed =
buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
} else {
/* In a 'very fast' shutdown we do not flush the buffer pool
to data files: we set n_pages_flushed to 0 artificially. */
n_pages_flushed = 0;
}
srv_main_thread_op_info = "reserving kernel mutex"; srv_main_thread_op_info = "reserving kernel mutex";
...@@ -2304,7 +2318,10 @@ flush_loop: ...@@ -2304,7 +2318,10 @@ flush_loop:
/* If we are doing a fast shutdown (= the default) /* If we are doing a fast shutdown (= the default)
we do not do purge or insert buffer merge. But we we do not do purge or insert buffer merge. But we
flush the buffer pool completely to disk. */ flush the buffer pool completely to disk.
In a 'very fast' shutdown we do not flush the buffer
pool to data files: we have set n_pages_flushed to
0 artificially. */
goto background_loop; goto background_loop;
} }
......
...@@ -1057,12 +1057,15 @@ trx_purge(void) ...@@ -1057,12 +1057,15 @@ trx_purge(void)
&& !UT_LIST_GET_LAST(trx_sys->view_list)) { && !UT_LIST_GET_LAST(trx_sys->view_list)) {
float ratio = (float) trx_sys->rseg_history_len float ratio = (float) trx_sys->rseg_history_len
/ srv_max_purge_lag; / srv_max_purge_lag;
if (ratio > 1) { if (ratio > ULINT_MAX / 10000) {
/* Avoid overflow: maximum delay is 4295 seconds */
srv_dml_needed_delay = ULINT_MAX;
} else if (ratio > 1) {
/* If the history list length exceeds the /* If the history list length exceeds the
innodb_max_purge_lag, the innodb_max_purge_lag, the
data manipulation statements are delayed data manipulation statements are delayed
by at least 5000 microseconds. */ by at least 5000 microseconds. */
srv_dml_needed_delay = (ratio - .5) * 10000; srv_dml_needed_delay = (ulint) ((ratio - .5) * 10000);
} }
} }
......
...@@ -20,6 +20,9 @@ NOTE: You can only use noninlined InnoDB functions in this file, because we ...@@ -20,6 +20,9 @@ NOTE: You can only use noninlined InnoDB functions in this file, because we
have disables the InnoDB inlining in this file. */ have disables the InnoDB inlining in this file. */
/* TODO list for the InnoDB handler in 4.1: /* TODO list for the InnoDB handler in 4.1:
- Remove the flag innodb_active_trans from thd and replace it with a
function call innodb_active_trans(thd), which looks at the InnoDB
trx struct state field
- Find out what kind of problems the OS X case-insensitivity causes to - Find out what kind of problems the OS X case-insensitivity causes to
table and database names; should we 'normalize' the names like we do table and database names; should we 'normalize' the names like we do
in Windows? in Windows?
...@@ -114,6 +117,9 @@ uint innobase_flush_log_at_trx_commit = 1; ...@@ -114,6 +117,9 @@ uint innobase_flush_log_at_trx_commit = 1;
my_bool innobase_log_archive = FALSE;/* unused */ my_bool innobase_log_archive = FALSE;/* unused */
my_bool innobase_use_native_aio = FALSE; my_bool innobase_use_native_aio = FALSE;
my_bool innobase_fast_shutdown = TRUE; my_bool innobase_fast_shutdown = TRUE;
my_bool innobase_very_fast_shutdown = FALSE; /* this can be set to
1 just prior calling
innobase_end() */
my_bool innobase_file_per_table = FALSE; my_bool innobase_file_per_table = FALSE;
my_bool innobase_locks_unsafe_for_binlog = FALSE; my_bool innobase_locks_unsafe_for_binlog = FALSE;
my_bool innobase_create_status_file = FALSE; my_bool innobase_create_status_file = FALSE;
...@@ -799,6 +805,10 @@ ha_innobase::init_table_handle_for_HANDLER(void) ...@@ -799,6 +805,10 @@ ha_innobase::init_table_handle_for_HANDLER(void)
trx_assign_read_view(prebuilt->trx); trx_assign_read_view(prebuilt->trx);
/* Set the MySQL flag to mark that there is an active transaction */
current_thd->transaction.all.innodb_active_trans = 1;
/* We did the necessary inits in this function, no need to repeat them /* We did the necessary inits in this function, no need to repeat them
in row_search_for_mysql */ in row_search_for_mysql */
...@@ -1059,6 +1069,15 @@ innobase_end(void) ...@@ -1059,6 +1069,15 @@ innobase_end(void)
#endif #endif
if (innodb_inited) if (innodb_inited)
{ {
if (innobase_very_fast_shutdown) {
srv_very_fast_shutdown = TRUE;
fprintf(stderr,
"InnoDB: MySQL has requested a very fast shutdown without flushing\n"
"InnoDB: the InnoDB buffer pool to data files. At the next mysqld startup\n"
"InnoDB: InnoDB will do a crash recovery!\n");
}
innodb_inited= 0; innodb_inited= 0;
if (innobase_shutdown_for_mysql() != DB_SUCCESS) if (innobase_shutdown_for_mysql() != DB_SUCCESS)
err= 1; err= 1;
...@@ -1115,6 +1134,48 @@ innobase_commit_low( ...@@ -1115,6 +1134,48 @@ innobase_commit_low(
trx_commit_for_mysql(trx); trx_commit_for_mysql(trx);
} }
/*********************************************************************
Creates an InnoDB transaction struct for the thd if it does not yet have one.
Starts a new InnoDB transaction if a transaction is not yet started. And
assigns a new snapshot for a consistent read if the transaction does not yet
have one. */
int
innobase_start_trx_and_assign_read_view(
/*====================================*/
/* out: 0 */
THD* thd) /* in: MySQL thread handle of the user for whom
the transaction should be committed */
{
trx_t* trx;
DBUG_ENTER("innobase_start_trx_and_assign_read_view");
/* Create a new trx struct for thd, if it does not yet have one */
trx = check_trx_exists(thd);
/* This is just to play safe: release a possible FIFO ticket and
search latch. Since we will reserve the kernel mutex, we have to
release the search system latch first to obey the latching order. */
innobase_release_stat_resources(trx);
/* If the transaction is not started yet, start it */
trx_start_if_not_started_noninline(trx);
/* Assign a read view if the transaction does not have it yet */
trx_assign_read_view(trx);
/* Set the MySQL flag to mark that there is an active transaction */
current_thd->transaction.all.innodb_active_trans = 1;
DBUG_RETURN(0);
}
/********************************************************************* /*********************************************************************
Commits a transaction in an InnoDB database or marks an SQL statement Commits a transaction in an InnoDB database or marks an SQL statement
ended. */ ended. */
...@@ -1146,8 +1207,10 @@ innobase_commit( ...@@ -1146,8 +1207,10 @@ innobase_commit(
1. ::external_lock(), 1. ::external_lock(),
2. ::start_stmt(), 2. ::start_stmt(),
3. innobase_query_caching_of_table_permitted(), and 3. innobase_query_caching_of_table_permitted(),
4. innobase_savepoint(), 4. innobase_savepoint(),
5. ::init_table_handle_for_HANDLER(),
6. innobase_start_trx_and_assign_read_view()
and it is only set to 0 in a commit or a rollback. If it is 0 we know and it is only set to 0 in a commit or a rollback. If it is 0 we know
there cannot be resources to be freed and we could return immediately. there cannot be resources to be freed and we could return immediately.
......
...@@ -191,6 +191,11 @@ extern my_bool innobase_log_archive, ...@@ -191,6 +191,11 @@ extern my_bool innobase_log_archive,
innobase_use_native_aio, innobase_fast_shutdown, innobase_use_native_aio, innobase_fast_shutdown,
innobase_file_per_table, innobase_locks_unsafe_for_binlog, innobase_file_per_table, innobase_locks_unsafe_for_binlog,
innobase_create_status_file; innobase_create_status_file;
extern my_bool innobase_very_fast_shutdown; /* set this to 1 just before
calling innobase_end() if you want
InnoDB to shut down without
flushing the buffer pool: this
is equivalent to a 'crash' */
extern "C" { extern "C" {
extern ulong srv_max_buf_pool_modified_pct; extern ulong srv_max_buf_pool_modified_pct;
extern ulong srv_auto_extend_increment; extern ulong srv_auto_extend_increment;
...@@ -231,3 +236,4 @@ void innobase_release_temporary_latches(void* innobase_tid); ...@@ -231,3 +236,4 @@ void innobase_release_temporary_latches(void* innobase_tid);
void innobase_store_binlog_offset_and_flush_log(char *binlog_name,longlong offset); void innobase_store_binlog_offset_and_flush_log(char *binlog_name,longlong offset);
int innobase_start_trx_and_assign_read_view(THD* thd);
...@@ -261,8 +261,6 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables) ...@@ -261,8 +261,6 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables)
{ {
TABLE_LIST *hash_tables; TABLE_LIST *hash_tables;
TABLE **table_ptr; TABLE **table_ptr;
bool was_flushed= FALSE;
bool not_opened;
DBUG_ENTER("mysql_ha_close"); DBUG_ENTER("mysql_ha_close");
DBUG_PRINT("enter",("'%s'.'%s' as '%s'", DBUG_PRINT("enter",("'%s'.'%s' as '%s'",
tables->db, tables->real_name, tables->alias)); tables->db, tables->real_name, tables->alias));
...@@ -366,7 +364,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, ...@@ -366,7 +364,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables,
uint num_rows; uint num_rows;
byte *key; byte *key;
uint key_len; uint key_len;
bool was_flushed;
DBUG_ENTER("mysql_ha_read"); DBUG_ENTER("mysql_ha_read");
DBUG_PRINT("enter",("'%s'.'%s' as '%s'", DBUG_PRINT("enter",("'%s'.'%s' as '%s'",
tables->db, tables->real_name, tables->alias)); tables->db, tables->real_name, tables->alias));
...@@ -624,10 +621,8 @@ err0: ...@@ -624,10 +621,8 @@ err0:
int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags) int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags)
{ {
TABLE_LIST **tmp_tables_p;
TABLE_LIST *tmp_tables; TABLE_LIST *tmp_tables;
TABLE **table_ptr; TABLE **table_ptr;
bool was_flushed;
DBUG_ENTER("mysql_ha_flush"); DBUG_ENTER("mysql_ha_flush");
DBUG_PRINT("enter", ("tables: %p mode_flags: 0x%02x", tables, mode_flags)); DBUG_PRINT("enter", ("tables: %p mode_flags: 0x%02x", tables, mode_flags));
...@@ -703,14 +698,13 @@ static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, uint mode_flags) ...@@ -703,14 +698,13 @@ static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, uint mode_flags)
{ {
TABLE_LIST *hash_tables; TABLE_LIST *hash_tables;
TABLE *table= *table_ptr; TABLE *table= *table_ptr;
bool was_flushed;
DBUG_ENTER("mysql_ha_flush_table"); DBUG_ENTER("mysql_ha_flush_table");
DBUG_PRINT("enter",("'%s'.'%s' as '%s' flags: 0x%02x", DBUG_PRINT("enter",("'%s'.'%s' as '%s' flags: 0x%02x",
table->table_cache_key, table->real_name, table->table_cache_key, table->real_name,
table->table_name, mode_flags)); table->table_name, mode_flags));
if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash,
(*table_ptr)->table_name, (byte*) (*table_ptr)->table_name,
strlen((*table_ptr)->table_name) + 1))) strlen((*table_ptr)->table_name) + 1)))
{ {
if (! (mode_flags & MYSQL_HA_REOPEN_ON_USAGE)) if (! (mode_flags & MYSQL_HA_REOPEN_ON_USAGE))
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <mysql.h> #include <mysql.h>
#include <my_getopt.h> #include <my_getopt.h>
#include <m_string.h> #include <m_string.h>
#include <assert.h>
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
/* Include to get MAXPATHLEN */ /* Include to get MAXPATHLEN */
#include <sys/param.h> #include <sys/param.h>
...@@ -78,6 +77,28 @@ static void print_error(const char *msg); ...@@ -78,6 +77,28 @@ static void print_error(const char *msg);
static void print_st_error(MYSQL_STMT *stmt, const char *msg); static void print_st_error(MYSQL_STMT *stmt, const char *msg);
static void client_disconnect(); static void client_disconnect();
/*
Abort unless given experssion is non-zero.
SYNOPSIS
DIE_UNLESS(expr)
DESCRIPTION
We can't use any kind of system assert as we need to
preserve tested invariants in release builds as well.
*/
#define DIE_UNLESS(expr) \
((void) ((expr) ? 0 : (die(__FILE__, __LINE__, #expr), 0)))
void die(const char *file, int line, const char *expr)
{
fprintf(stderr, "%s:%d: check failed: '%s'\n", file, line, expr);
abort();
}
#define myerror(msg) print_error(msg) #define myerror(msg) print_error(msg)
#define mysterror(stmt, msg) print_st_error(stmt, msg) #define mysterror(stmt, msg) print_st_error(stmt, msg)
...@@ -85,46 +106,46 @@ static void client_disconnect(); ...@@ -85,46 +106,46 @@ static void client_disconnect();
{ \ { \
if (r) \ if (r) \
myerror(NULL); \ myerror(NULL); \
assert(r == 0); \ DIE_UNLESS(r == 0); \
} }
#define myquery_r(r) \ #define myquery_r(r) \
{ \ { \
if (r) \ if (r) \
myerror(NULL); \ myerror(NULL); \
assert(r != 0); \ DIE_UNLESS(r != 0); \
} }
#define check_execute(stmt, r) \ #define check_execute(stmt, r) \
{ \ { \
if (r) \ if (r) \
mysterror(stmt, NULL); \ mysterror(stmt, NULL); \
assert(r == 0);\ DIE_UNLESS(r == 0);\
} }
#define check_execute_r(stmt, r) \ #define check_execute_r(stmt, r) \
{ \ { \
if (r) \ if (r) \
mysterror(stmt, NULL); \ mysterror(stmt, NULL); \
assert(r != 0);\ DIE_UNLESS(r != 0);\
} }
#define check_stmt(stmt) \ #define check_stmt(stmt) \
{ \ { \
if ( stmt == 0) \ if ( stmt == 0) \
myerror(NULL); \ myerror(NULL); \
assert(stmt != 0); \ DIE_UNLESS(stmt != 0); \
} }
#define check_stmt_r(stmt) \ #define check_stmt_r(stmt) \
{ \ { \
if (stmt == 0) \ if (stmt == 0) \
myerror(NULL);\ myerror(NULL);\
assert(stmt == 0);\ DIE_UNLESS(stmt == 0);\
} }
#define mytest(x) if (!x) {myerror(NULL);assert(TRUE);} #define mytest(x) if (!x) {myerror(NULL);DIE_UNLESS(FALSE);}
#define mytest_r(x) if (x) {myerror(NULL);assert(TRUE);} #define mytest_r(x) if (x) {myerror(NULL);DIE_UNLESS(FALSE);}
/* Print the error message */ /* Print the error message */
...@@ -413,10 +434,10 @@ int my_process_result(MYSQL *mysql) ...@@ -413,10 +434,10 @@ int my_process_result(MYSQL *mysql)
#define MAX_RES_FIELDS 50 #define MAX_RES_FIELDS 50
#define MAX_FIELD_DATA_SIZE 255 #define MAX_FIELD_DATA_SIZE 255
uint my_process_stmt_result(MYSQL_STMT *stmt) int my_process_stmt_result(MYSQL_STMT *stmt)
{ {
int field_count; int field_count;
uint row_count= 0; int row_count= 0;
MYSQL_BIND buffer[MAX_RES_FIELDS]; MYSQL_BIND buffer[MAX_RES_FIELDS];
MYSQL_FIELD *field; MYSQL_FIELD *field;
MYSQL_RES *result; MYSQL_RES *result;
...@@ -492,10 +513,10 @@ uint my_process_stmt_result(MYSQL_STMT *stmt) ...@@ -492,10 +513,10 @@ uint my_process_stmt_result(MYSQL_STMT *stmt)
/* Prepare statement, execute, and process result set for given query */ /* Prepare statement, execute, and process result set for given query */
uint my_stmt_result(const char *buff) int my_stmt_result(const char *buff)
{ {
MYSQL_STMT *stmt; MYSQL_STMT *stmt;
uint row_count; int row_count;
int rc; int rc;
fprintf(stdout, "\n\n %s", buff); fprintf(stdout, "\n\n %s", buff);
...@@ -543,7 +564,7 @@ static void verify_col_data(const char *table, const char *col, ...@@ -543,7 +564,7 @@ static void verify_col_data(const char *table, const char *col,
{ {
fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", fprintf(stdout, "\n obtained: `%s` (expected: `%s`)",
row[field], exp_data); row[field], exp_data);
assert(0); DIE_UNLESS(FALSE);
} }
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -581,15 +602,15 @@ static void verify_prepare_field(MYSQL_RES *result, ...@@ -581,15 +602,15 @@ static void verify_prepare_field(MYSQL_RES *result,
fprintf(stdout, "\n default :`%s`\t(expected: `%s`)", fprintf(stdout, "\n default :`%s`\t(expected: `%s`)",
field->def ? field->def : "(null)", def ? def: "(null)"); field->def ? field->def : "(null)", def ? def: "(null)");
fprintf(stdout, "\n"); fprintf(stdout, "\n");
assert(strcmp(field->name, name) == 0); DIE_UNLESS(strcmp(field->name, name) == 0);
assert(strcmp(field->org_name, org_name) == 0); DIE_UNLESS(strcmp(field->org_name, org_name) == 0);
assert(field->type == type); DIE_UNLESS(field->type == type);
assert(strcmp(field->table, table) == 0); DIE_UNLESS(strcmp(field->table, table) == 0);
assert(strcmp(field->org_table, org_table) == 0); DIE_UNLESS(strcmp(field->org_table, org_table) == 0);
assert(strcmp(field->db, db) == 0); DIE_UNLESS(strcmp(field->db, db) == 0);
assert(field->length == length); DIE_UNLESS(field->length == length);
if (def) if (def)
assert(strcmp(field->def, def) == 0); DIE_UNLESS(strcmp(field->def, def) == 0);
} }
...@@ -600,7 +621,7 @@ static void verify_param_count(MYSQL_STMT *stmt, long exp_count) ...@@ -600,7 +621,7 @@ static void verify_param_count(MYSQL_STMT *stmt, long exp_count)
long param_count= mysql_stmt_param_count(stmt); long param_count= mysql_stmt_param_count(stmt);
fprintf(stdout, "\n total parameters in stmt: `%ld` (expected: `%ld`)", fprintf(stdout, "\n total parameters in stmt: `%ld` (expected: `%ld`)",
param_count, exp_count); param_count, exp_count);
assert(param_count == exp_count); DIE_UNLESS(param_count == exp_count);
} }
...@@ -611,7 +632,7 @@ static void verify_st_affected_rows(MYSQL_STMT *stmt, ulonglong exp_count) ...@@ -611,7 +632,7 @@ static void verify_st_affected_rows(MYSQL_STMT *stmt, ulonglong exp_count)
ulonglong affected_rows= mysql_stmt_affected_rows(stmt); ulonglong affected_rows= mysql_stmt_affected_rows(stmt);
fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)", fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)",
affected_rows, exp_count); affected_rows, exp_count);
assert(affected_rows == exp_count); DIE_UNLESS(affected_rows == exp_count);
} }
...@@ -622,7 +643,7 @@ static void verify_affected_rows(ulonglong exp_count) ...@@ -622,7 +643,7 @@ static void verify_affected_rows(ulonglong exp_count)
ulonglong affected_rows= mysql_affected_rows(mysql); ulonglong affected_rows= mysql_affected_rows(mysql);
fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)", fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)",
affected_rows, exp_count); affected_rows, exp_count);
assert(affected_rows == exp_count); DIE_UNLESS(affected_rows == exp_count);
} }
...@@ -633,7 +654,7 @@ static void verify_field_count(MYSQL_RES *result, uint exp_count) ...@@ -633,7 +654,7 @@ static void verify_field_count(MYSQL_RES *result, uint exp_count)
uint field_count= mysql_num_fields(result); uint field_count= mysql_num_fields(result);
fprintf(stdout, "\n total fields in the result set: `%d` (expected: `%d`)", fprintf(stdout, "\n total fields in the result set: `%d` (expected: `%d`)",
field_count, exp_count); field_count, exp_count);
assert(field_count == exp_count); DIE_UNLESS(field_count == exp_count);
} }
...@@ -655,7 +676,7 @@ static void execute_prepare_query(const char *query, ulonglong exp_count) ...@@ -655,7 +676,7 @@ static void execute_prepare_query(const char *query, ulonglong exp_count)
fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)", fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)",
affected_rows, exp_count); affected_rows, exp_count);
assert(affected_rows == exp_count); DIE_UNLESS(affected_rows == exp_count);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -676,7 +697,7 @@ static void client_store_result() ...@@ -676,7 +697,7 @@ static void client_store_result()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
my_process_result_set(result); (void) my_process_result_set(result);
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -696,7 +717,7 @@ static void client_use_result() ...@@ -696,7 +717,7 @@ static void client_use_result()
result= mysql_use_result(mysql); result= mysql_use_result(mysql);
mytest(result); mytest(result);
my_process_result_set(result); (void) my_process_result_set(result);
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -767,7 +788,7 @@ static void test_debug_example() ...@@ -767,7 +788,7 @@ static void test_debug_example()
result= mysql_use_result(mysql); result= mysql_use_result(mysql);
mytest(result); mytest(result);
my_process_result_set(result); (void) my_process_result_set(result);
mysql_free_result(result); mysql_free_result(result);
rc= mysql_query(mysql, "DROP TABLE test_debug_example"); rc= mysql_query(mysql, "DROP TABLE test_debug_example");
...@@ -827,7 +848,7 @@ static void test_tran_bdb() ...@@ -827,7 +848,7 @@ static void test_tran_bdb()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
my_process_result_set(result); (void) my_process_result_set(result);
mysql_free_result(result); mysql_free_result(result);
/* test the results now, only one row should exist */ /* test the results now, only one row should exist */
...@@ -900,7 +921,7 @@ static void test_tran_innodb() ...@@ -900,7 +921,7 @@ static void test_tran_innodb()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
my_process_result_set(result); (void) my_process_result_set(result);
mysql_free_result(result); mysql_free_result(result);
/* test the results now, only one row should exist */ /* test the results now, only one row should exist */
...@@ -1167,7 +1188,8 @@ static void test_prepare() ...@@ -1167,7 +1188,8 @@ static void test_prepare()
myquery(rc); myquery(rc);
/* test the results now, only one row should exist */ /* test the results now, only one row should exist */
assert(tiny_data == (char) my_stmt_result("SELECT * FROM my_prepare")); rc= my_stmt_result("SELECT * FROM my_prepare");
DIE_UNLESS(tiny_data == (char) rc);
stmt= mysql_simple_prepare(mysql, "SELECT * FROM my_prepare"); stmt= mysql_simple_prepare(mysql, "SELECT * FROM my_prepare");
check_stmt(stmt); check_stmt(stmt);
...@@ -1205,27 +1227,27 @@ static void test_prepare() ...@@ -1205,27 +1227,27 @@ static void test_prepare()
fprintf(stdout, "\n\t str : %s (%lu)", str_data, length[1]); fprintf(stdout, "\n\t str : %s (%lu)", str_data, length[1]);
assert(tiny_data == o_tiny_data); DIE_UNLESS(tiny_data == o_tiny_data);
assert(is_null[0] == 0); DIE_UNLESS(is_null[0] == 0);
assert(length[0] == 1); DIE_UNLESS(length[0] == 1);
assert(int_data == o_int_data); DIE_UNLESS(int_data == o_int_data);
assert(length[2] == 4); DIE_UNLESS(length[2] == 4);
assert(small_data == o_small_data); DIE_UNLESS(small_data == o_small_data);
assert(length[3] == 2); DIE_UNLESS(length[3] == 2);
assert(big_data == o_big_data); DIE_UNLESS(big_data == o_big_data);
assert(length[4] == 8); DIE_UNLESS(length[4] == 8);
assert(real_data == o_real_data); DIE_UNLESS(real_data == o_real_data);
assert(length[5] == 4); DIE_UNLESS(length[5] == 4);
assert(double_data == o_double_data); DIE_UNLESS(double_data == o_double_data);
assert(length[6] == 8); DIE_UNLESS(length[6] == 8);
assert(strcmp(data, str_data) == 0); DIE_UNLESS(strcmp(data, str_data) == 0);
assert(length[1] == len); DIE_UNLESS(length[1] == len);
o_int_data += 25; o_int_data += 25;
o_small_data += 10; o_small_data += 10;
...@@ -1235,7 +1257,7 @@ static void test_prepare() ...@@ -1235,7 +1257,7 @@ static void test_prepare()
} }
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -1320,7 +1342,8 @@ static void test_double_compare() ...@@ -1320,7 +1342,8 @@ static void test_double_compare()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert((int)tiny_data == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS((int)tiny_data == rc);
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -1393,7 +1416,8 @@ static void test_null() ...@@ -1393,7 +1416,8 @@ static void test_null()
myquery(rc); myquery(rc);
nData*= 2; nData*= 2;
assert(nData == my_stmt_result("SELECT * FROM test_null")); rc= my_stmt_result("SELECT * FROM test_null");;
DIE_UNLESS((int) nData == rc);
/* Fetch results */ /* Fetch results */
bind[0].buffer_type= MYSQL_TYPE_LONG; bind[0].buffer_type= MYSQL_TYPE_LONG;
...@@ -1416,12 +1440,12 @@ static void test_null() ...@@ -1416,12 +1440,12 @@ static void test_null()
is_null[0]= is_null[1]= 0; is_null[0]= is_null[1]= 0;
while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA)
{ {
assert(is_null[0]); DIE_UNLESS(is_null[0]);
assert(is_null[1]); DIE_UNLESS(is_null[1]);
rc++; rc++;
is_null[0]= is_null[1]= 0; is_null[0]= is_null[1]= 0;
} }
assert(rc == (int)nData); DIE_UNLESS(rc == (int) nData);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -1491,10 +1515,10 @@ static void test_ps_null_param() ...@@ -1491,10 +1515,10 @@ static void test_ps_null_param()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc != MYSQL_NO_DATA); DIE_UNLESS(rc != MYSQL_NO_DATA);
assert(out_is_null); DIE_UNLESS(out_is_null);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
} }
...@@ -1544,7 +1568,8 @@ static void test_fetch_null() ...@@ -1544,7 +1568,8 @@ static void test_fetch_null()
strmov((char *)query , "SELECT * FROM test_fetch_null"); strmov((char *)query , "SELECT * FROM test_fetch_null");
assert(3 == my_stmt_result(query)); rc= my_stmt_result(query);
DIE_UNLESS(rc == 3);
stmt= mysql_simple_prepare(mysql, query); stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt); check_stmt(stmt);
...@@ -1563,14 +1588,14 @@ static void test_fetch_null() ...@@ -1563,14 +1588,14 @@ static void test_fetch_null()
{ {
fprintf(stdout, "\n data[%d] : %s", i, fprintf(stdout, "\n data[%d] : %s", i,
is_null[i] ? "NULL" : "NOT NULL"); is_null[i] ? "NULL" : "NOT NULL");
assert(is_null[i]); DIE_UNLESS(is_null[i]);
} }
fprintf(stdout, "\n data[%d]: %d", i, nData); fprintf(stdout, "\n data[%d]: %d", i, nData);
assert(nData == 1000 || nData == 88 || nData == 389789); DIE_UNLESS(nData == 1000 || nData == 88 || nData == 389789);
assert(is_null[i] == 0); DIE_UNLESS(is_null[i] == 0);
assert(length[i] == 4); DIE_UNLESS(length[i] == 4);
} }
assert(rc == 3); DIE_UNLESS(rc == 3);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -1657,7 +1682,7 @@ static void test_select_direct() ...@@ -1657,7 +1682,7 @@ static void test_select_direct()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
my_process_result_set(result); (void) my_process_result_set(result);
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -1693,7 +1718,8 @@ static void test_select_prepare() ...@@ -1693,7 +1718,8 @@ static void test_select_prepare()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(1 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
rc= mysql_query(mysql, "DROP TABLE test_select"); rc= mysql_query(mysql, "DROP TABLE test_select");
...@@ -1717,7 +1743,8 @@ static void test_select_prepare() ...@@ -1717,7 +1743,8 @@ static void test_select_prepare()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(1 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -1782,7 +1809,8 @@ static void test_select() ...@@ -1782,7 +1809,8 @@ static void test_select()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(my_process_stmt_result(stmt) == 1); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -1841,7 +1869,8 @@ static void test_ps_conj_select() ...@@ -1841,7 +1869,8 @@ static void test_ps_conj_select()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(my_process_stmt_result(stmt) == 3); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 3);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -1914,7 +1943,8 @@ session_id char(9) NOT NULL, \ ...@@ -1914,7 +1943,8 @@ session_id char(9) NOT NULL, \
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(my_process_stmt_result(stmt) == 1); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
strmov(szData, (char *)"venu"); strmov(szData, (char *)"venu");
bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer_type= MYSQL_TYPE_STRING;
...@@ -1930,7 +1960,8 @@ session_id char(9) NOT NULL, \ ...@@ -1930,7 +1960,8 @@ session_id char(9) NOT NULL, \
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(my_process_stmt_result(stmt) == 0); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 0);
strmov(szData, (char *)"abc"); strmov(szData, (char *)"abc");
bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer_type= MYSQL_TYPE_STRING;
...@@ -1946,7 +1977,8 @@ session_id char(9) NOT NULL, \ ...@@ -1946,7 +1977,8 @@ session_id char(9) NOT NULL, \
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(my_process_stmt_result(stmt) == 1); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -1996,7 +2028,8 @@ static void test_bug1180() ...@@ -1996,7 +2028,8 @@ static void test_bug1180()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(my_process_stmt_result(stmt) == 0); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 0);
strmov(szData, (char *)"1111"); strmov(szData, (char *)"1111");
bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer_type= MYSQL_TYPE_STRING;
...@@ -2012,7 +2045,8 @@ static void test_bug1180() ...@@ -2012,7 +2045,8 @@ static void test_bug1180()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(my_process_stmt_result(stmt) == 1); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
strmov(szData, (char *)"abc"); strmov(szData, (char *)"abc");
bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer_type= MYSQL_TYPE_STRING;
...@@ -2028,7 +2062,8 @@ static void test_bug1180() ...@@ -2028,7 +2062,8 @@ static void test_bug1180()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(my_process_stmt_result(stmt) == 0); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 0);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -2111,7 +2146,8 @@ static void test_bug1644() ...@@ -2111,7 +2146,8 @@ static void test_bug1644()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(3 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 3);
mysql_data_seek(result, 0); mysql_data_seek(result, 0);
...@@ -2119,19 +2155,19 @@ static void test_bug1644() ...@@ -2119,19 +2155,19 @@ static void test_bug1644()
mytest(row); mytest(row);
for (i= 0 ; i < 4 ; i++) for (i= 0 ; i < 4 ; i++)
{ {
assert(strcmp(row[i], "22") == 0); DIE_UNLESS(strcmp(row[i], "22") == 0);
} }
row= mysql_fetch_row(result); row= mysql_fetch_row(result);
mytest(row); mytest(row);
for (i= 0 ; i < 4 ; i++) for (i= 0 ; i < 4 ; i++)
{ {
assert(row[i] == 0); DIE_UNLESS(row[i] == 0);
} }
row= mysql_fetch_row(result); row= mysql_fetch_row(result);
mytest(row); mytest(row);
for (i= 0 ; i < 4 ; i++) for (i= 0 ; i < 4 ; i++)
{ {
assert(strcmp(row[i], "88") == 0); DIE_UNLESS(strcmp(row[i], "88") == 0);
} }
row= mysql_fetch_row(result); row= mysql_fetch_row(result);
mytest_r(row); mytest_r(row);
...@@ -2197,7 +2233,8 @@ static void test_select_show() ...@@ -2197,7 +2233,8 @@ static void test_select_show()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(1 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -2275,7 +2312,8 @@ static void test_simple_update() ...@@ -2275,7 +2312,8 @@ static void test_simple_update()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(1 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 1);
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -2351,7 +2389,8 @@ static void test_long_data() ...@@ -2351,7 +2389,8 @@ static void test_long_data()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(1 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 1);
mysql_free_result(result); mysql_free_result(result);
verify_col_data("test_long_data", "col1", "999"); verify_col_data("test_long_data", "col1", "999");
...@@ -2435,7 +2474,8 @@ static void test_long_data_str() ...@@ -2435,7 +2474,8 @@ static void test_long_data_str()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(1 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 1);
mysql_free_result(result); mysql_free_result(result);
my_sprintf(data, (data, "%d", i*5)); my_sprintf(data, (data, "%d", i*5));
...@@ -2530,7 +2570,8 @@ static void test_long_data_str1() ...@@ -2530,7 +2570,8 @@ static void test_long_data_str1()
mytest(result); mytest(result);
assert(1 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 1);
mysql_free_result(result); mysql_free_result(result);
my_sprintf(data, (data, "%ld", (long)i*length)); my_sprintf(data, (data, "%ld", (long)i*length));
...@@ -2554,7 +2595,7 @@ static void test_long_data_str1() ...@@ -2554,7 +2595,7 @@ static void test_long_data_str1()
field= mysql_fetch_fields(result); field= mysql_fetch_fields(result);
/* First test what happens if STMT_ATTR_UPDATE_MAX_LENGTH is not used */ /* First test what happens if STMT_ATTR_UPDATE_MAX_LENGTH is not used */
DBUG_ASSERT(field->max_length == 0); DIE_UNLESS(field->max_length == 0);
mysql_free_result(result); mysql_free_result(result);
/* Enable updating of field->max_length */ /* Enable updating of field->max_length */
...@@ -2569,7 +2610,7 @@ static void test_long_data_str1() ...@@ -2569,7 +2610,7 @@ static void test_long_data_str1()
result= mysql_stmt_result_metadata(stmt); result= mysql_stmt_result_metadata(stmt);
field= mysql_fetch_fields(result); field= mysql_fetch_fields(result);
DBUG_ASSERT(field->max_length == max_blob_length); DIE_UNLESS(field->max_length == max_blob_length);
/* Fetch results into a data buffer that is smaller than data */ /* Fetch results into a data buffer that is smaller than data */
bzero((char*) bind, sizeof(*bind)); bzero((char*) bind, sizeof(*bind));
...@@ -2580,9 +2621,10 @@ static void test_long_data_str1() ...@@ -2580,9 +2621,10 @@ static void test_long_data_str1()
rc= mysql_stmt_bind_result(stmt, bind); rc= mysql_stmt_bind_result(stmt, bind);
data[16]= 0; data[16]= 0;
DBUG_ASSERT((mysql_stmt_fetch(stmt) == 0)); rc= mysql_stmt_fetch(stmt);
DBUG_ASSERT(strlen(data) == 16); DIE_UNLESS(rc == 0);
DBUG_ASSERT(blob_length == max_blob_length); DIE_UNLESS(strlen(data) == 16);
DIE_UNLESS(blob_length == max_blob_length);
/* Fetch all data */ /* Fetch all data */
bzero((char*) (bind+1), sizeof(*bind)); bzero((char*) (bind+1), sizeof(*bind));
...@@ -2592,7 +2634,7 @@ static void test_long_data_str1() ...@@ -2592,7 +2634,7 @@ static void test_long_data_str1()
bind[1].length= &blob_length; bind[1].length= &blob_length;
bzero(data, sizeof(data)); bzero(data, sizeof(data));
mysql_stmt_fetch_column(stmt, bind+1, 0, 0); mysql_stmt_fetch_column(stmt, bind+1, 0, 0);
DBUG_ASSERT(strlen(data) == max_blob_length); DIE_UNLESS(strlen(data) == max_blob_length);
mysql_free_result(result); mysql_free_result(result);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -2674,7 +2716,8 @@ static void test_long_data_bin() ...@@ -2674,7 +2716,8 @@ static void test_long_data_bin()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(1 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 1);
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -2754,7 +2797,8 @@ static void test_simple_delete() ...@@ -2754,7 +2797,8 @@ static void test_simple_delete()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(0 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 0);
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -2853,7 +2897,8 @@ static void test_update() ...@@ -2853,7 +2897,8 @@ static void test_update()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(1 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 1);
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -2899,7 +2944,8 @@ static void test_prepare_noparam() ...@@ -2899,7 +2944,8 @@ static void test_prepare_noparam()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(1 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 1);
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -2962,17 +3008,17 @@ static void test_bind_result() ...@@ -2962,17 +3008,17 @@ static void test_bind_result()
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n row 1: %d, %s(%lu)", nData, szData, length1); fprintf(stdout, "\n row 1: %d, %s(%lu)", nData, szData, length1);
assert(nData == 10); DIE_UNLESS(nData == 10);
assert(strcmp(szData, "venu") == 0); DIE_UNLESS(strcmp(szData, "venu") == 0);
assert(length1 == 4); DIE_UNLESS(length1 == 4);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n row 2: %d, %s(%lu)", nData, szData, length1); fprintf(stdout, "\n row 2: %d, %s(%lu)", nData, szData, length1);
assert(nData == 20); DIE_UNLESS(nData == 20);
assert(strcmp(szData, "MySQL") == 0); DIE_UNLESS(strcmp(szData, "MySQL") == 0);
assert(length1 == 5); DIE_UNLESS(length1 == 5);
length= 99; length= 99;
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
...@@ -2980,12 +3026,12 @@ static void test_bind_result() ...@@ -2980,12 +3026,12 @@ static void test_bind_result()
if (is_null[0]) if (is_null[0])
fprintf(stdout, "\n row 3: NULL, %s(%lu)", szData, length1); fprintf(stdout, "\n row 3: NULL, %s(%lu)", szData, length1);
assert(is_null[0]); DIE_UNLESS(is_null[0]);
assert(strcmp(szData, "monty") == 0); DIE_UNLESS(strcmp(szData, "monty") == 0);
assert(length1 == 5); DIE_UNLESS(length1 == 5);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -3090,19 +3136,19 @@ static void test_bind_result_ext() ...@@ -3090,19 +3136,19 @@ static void test_bind_result_ext()
fprintf(stdout, "\n data (bin) : %s(%lu)", bData, bLength); fprintf(stdout, "\n data (bin) : %s(%lu)", bData, bLength);
assert(t_data == 19); DIE_UNLESS(t_data == 19);
assert(s_data == 2999); DIE_UNLESS(s_data == 2999);
assert(i_data == 3999); DIE_UNLESS(i_data == 3999);
assert(b_data == 4999999); DIE_UNLESS(b_data == 4999999);
/*assert(f_data == 2345.60);*/ /*DIE_UNLESS(f_data == 2345.60);*/
/*assert(d_data == 5678.89563);*/ /*DIE_UNLESS(d_data == 5678.89563);*/
assert(strcmp(szData, "venu") == 0); DIE_UNLESS(strcmp(szData, "venu") == 0);
assert(strncmp(bData, "mysql", 5) == 0); DIE_UNLESS(strncmp(bData, "mysql", 5) == 0);
assert(szLength == 4); DIE_UNLESS(szLength == 4);
assert(bLength == 5); DIE_UNLESS(bLength == 5);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -3207,23 +3253,23 @@ static void test_bind_result_ext1() ...@@ -3207,23 +3253,23 @@ static void test_bind_result_ext1()
fprintf(stdout, "\n data (bin) : %ld(%lu)", bData, length[6]); fprintf(stdout, "\n data (bin) : %ld(%lu)", bData, length[6]);
fprintf(stdout, "\n data (str) : %g(%lu)", szData, length[7]); fprintf(stdout, "\n data (str) : %g(%lu)", szData, length[7]);
assert(strcmp(t_data, "120") == 0); DIE_UNLESS(strcmp(t_data, "120") == 0);
assert(i_data == 3999); DIE_UNLESS(i_data == 3999);
assert(f_data == 2); DIE_UNLESS(f_data == 2);
assert(strcmp(d_data, "58.89") == 0); DIE_UNLESS(strcmp(d_data, "58.89") == 0);
assert(b_data == 54); DIE_UNLESS(b_data == 54);
assert(length[0] == 3); DIE_UNLESS(length[0] == 3);
assert(length[1] == 4); DIE_UNLESS(length[1] == 4);
assert(length[2] == 2); DIE_UNLESS(length[2] == 2);
assert(length[3] == 1); DIE_UNLESS(length[3] == 1);
assert(length[4] == 4); DIE_UNLESS(length[4] == 4);
assert(length[5] == 5); DIE_UNLESS(length[5] == 5);
assert(length[6] == 4); DIE_UNLESS(length[6] == 4);
assert(length[7] == 8); DIE_UNLESS(length[7] == 8);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -3281,11 +3327,11 @@ static void bind_fetch(int row_count) ...@@ -3281,11 +3327,11 @@ static void bind_fetch(int row_count)
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
assert(row_count == (int) rc= my_stmt_result("SELECT * FROM test_bind_fetch");
my_stmt_result("SELECT * FROM test_bind_fetch")); DIE_UNLESS(row_count == rc);
stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_bind_fetch"); stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_bind_fetch");
myquery(rc); check_stmt(stmt);
for (i= 0; i < (int) array_elements(bind); i++) for (i= 0; i < (int) array_elements(bind); i++)
{ {
...@@ -3342,45 +3388,45 @@ static void bind_fetch(int row_count) ...@@ -3342,45 +3388,45 @@ static void bind_fetch(int row_count)
rc= 10+row_count; rc= 10+row_count;
/* TINY */ /* TINY */
assert((int) i8_data == rc); DIE_UNLESS((int) i8_data == rc);
assert(length[0] == 1); DIE_UNLESS(length[0] == 1);
rc+= 13; rc+= 13;
/* SHORT */ /* SHORT */
assert((int) i16_data == rc); DIE_UNLESS((int) i16_data == rc);
assert(length[1] == 2); DIE_UNLESS(length[1] == 2);
rc+= 13; rc+= 13;
/* LONG */ /* LONG */
assert((int) i32_data == rc); DIE_UNLESS((int) i32_data == rc);
assert(length[2] == 4); DIE_UNLESS(length[2] == 4);
rc+= 13; rc+= 13;
/* LONGLONG */ /* LONGLONG */
assert((int) i64_data == rc); DIE_UNLESS((int) i64_data == rc);
assert(length[3] == 8); DIE_UNLESS(length[3] == 8);
rc+= 13; rc+= 13;
/* FLOAT */ /* FLOAT */
assert((int)f_data == rc); DIE_UNLESS((int)f_data == rc);
assert(length[4] == 4); DIE_UNLESS(length[4] == 4);
rc+= 13; rc+= 13;
/* DOUBLE */ /* DOUBLE */
assert((int)d_data == rc); DIE_UNLESS((int)d_data == rc);
assert(length[5] == 8); DIE_UNLESS(length[5] == 8);
rc+= 13; rc+= 13;
/* CHAR */ /* CHAR */
{ {
char buff[20]; char buff[20];
long len= my_sprintf(buff, (buff, "%d", rc)); long len= my_sprintf(buff, (buff, "%d", rc));
assert(strcmp(s_data, buff) == 0); DIE_UNLESS(strcmp(s_data, buff) == 0);
assert(length[6] == (ulong) len); DIE_UNLESS(length[6] == (ulong) len);
} }
} }
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -3464,7 +3510,8 @@ static void test_fetch_date() ...@@ -3464,7 +3510,8 @@ static void test_fetch_date()
bind[6].buffer_length= sizeof(ts_6); bind[6].buffer_length= sizeof(ts_6);
bind[6].length= &ts6_length; bind[6].length= &ts6_length;
assert(1 == my_stmt_result("SELECT * FROM test_bind_result")); rc= my_stmt_result("SELECT * FROM test_bind_result");
DIE_UNLESS(rc == 1);
stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_bind_result"); stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_bind_result");
check_stmt(stmt); check_stmt(stmt);
...@@ -3487,29 +3534,29 @@ static void test_fetch_date() ...@@ -3487,29 +3534,29 @@ static void test_fetch_date()
fprintf(stdout, "\n ts(4) : %s(%lu)", ts_4, ts4_length); fprintf(stdout, "\n ts(4) : %s(%lu)", ts_4, ts4_length);
fprintf(stdout, "\n ts(6) : %s(%lu)", ts_6, ts6_length); fprintf(stdout, "\n ts(6) : %s(%lu)", ts_6, ts6_length);
assert(strcmp(date, "2002-01-02") == 0); DIE_UNLESS(strcmp(date, "2002-01-02") == 0);
assert(d_length == 10); DIE_UNLESS(d_length == 10);
assert(strcmp(time, "12:49:00") == 0); DIE_UNLESS(strcmp(time, "12:49:00") == 0);
assert(t_length == 8); DIE_UNLESS(t_length == 8);
assert(strcmp(ts, "2002-01-02 17:46:59") == 0); DIE_UNLESS(strcmp(ts, "2002-01-02 17:46:59") == 0);
assert(ts_length == 19); DIE_UNLESS(ts_length == 19);
assert(year == 2010); DIE_UNLESS(year == 2010);
assert(y_length == 4); DIE_UNLESS(y_length == 4);
assert(strcmp(dt, "2010-07-10 00:00:00") == 0); DIE_UNLESS(strcmp(dt, "2010-07-10 00:00:00") == 0);
assert(dt_length == 19); DIE_UNLESS(dt_length == 19);
assert(ts_4[0] == '\0'); DIE_UNLESS(ts_4[0] == '\0');
assert(ts4_length == 0); DIE_UNLESS(ts4_length == 0);
assert(strcmp(ts_6, "1999-12-29 00:00:00") == 0); DIE_UNLESS(strcmp(ts_6, "1999-12-29 00:00:00") == 0);
assert(ts6_length == 19); DIE_UNLESS(ts6_length == 19);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -3796,7 +3843,8 @@ static void test_prepare_ext() ...@@ -3796,7 +3843,8 @@ static void test_prepare_ext()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(nData == (int)my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(nData == rc);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -3831,7 +3879,8 @@ static void test_field_names() ...@@ -3831,7 +3879,8 @@ static void test_field_names()
result= mysql_use_result(mysql); result= mysql_use_result(mysql);
mytest(result); mytest(result);
assert(0 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 0);
mysql_free_result(result); mysql_free_result(result);
/* with table name included with TRUE column name */ /* with table name included with TRUE column name */
...@@ -3841,7 +3890,8 @@ static void test_field_names() ...@@ -3841,7 +3890,8 @@ static void test_field_names()
result= mysql_use_result(mysql); result= mysql_use_result(mysql);
mytest(result); mytest(result);
assert(0 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 0);
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -3867,7 +3917,8 @@ static void test_warnings() ...@@ -3867,7 +3917,8 @@ static void test_warnings()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(1 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 1);
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -3892,7 +3943,7 @@ static void test_errors() ...@@ -3892,7 +3943,7 @@ static void test_errors()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
my_process_result_set(result); (void) my_process_result_set(result);
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -3969,7 +4020,8 @@ static void test_insert() ...@@ -3969,7 +4020,8 @@ static void test_insert()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert((int)tiny_data == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS((int) tiny_data == rc);
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -4126,7 +4178,7 @@ static void test_stmt_close() ...@@ -4126,7 +4178,7 @@ static void test_stmt_close()
rc= mysql_stmt_close(stmt1); rc= mysql_stmt_close(stmt1);
fprintf(stdout, "\n mysql_close_stmt(1) returned: %d", rc); fprintf(stdout, "\n mysql_close_stmt(1) returned: %d", rc);
assert(rc == 0); DIE_UNLESS(rc == 0);
/* /*
Originally we were going to close all statements automatically in Originally we were going to close all statements automatically in
...@@ -4160,7 +4212,7 @@ static void test_stmt_close() ...@@ -4160,7 +4212,7 @@ static void test_stmt_close()
rc= mysql_stmt_close(stmt_x); rc= mysql_stmt_close(stmt_x);
fprintf(stdout, "\n mysql_close_stmt(x) returned: %d", rc); fprintf(stdout, "\n mysql_close_stmt(x) returned: %d", rc);
assert( rc == 0); DIE_UNLESS( rc == 0);
rc= mysql_query(mysql, "SELECT id FROM test_stmt_close"); rc= mysql_query(mysql, "SELECT id FROM test_stmt_close");
myquery(rc); myquery(rc);
...@@ -4168,7 +4220,8 @@ static void test_stmt_close() ...@@ -4168,7 +4220,8 @@ static void test_stmt_close()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(1 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 1);
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -4220,9 +4273,9 @@ static void test_set_variable() ...@@ -4220,9 +4273,9 @@ static void test_set_variable()
fprintf(stdout, "\n max_error_count(default): %d", get_count); fprintf(stdout, "\n max_error_count(default): %d", get_count);
def_count= get_count; def_count= get_count;
assert(strcmp(var, "max_error_count") == 0); DIE_UNLESS(strcmp(var, "max_error_count") == 0);
rc= mysql_stmt_fetch(stmt1); rc= mysql_stmt_fetch(stmt1);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
stmt= mysql_simple_prepare(mysql, "set max_error_count= ?"); stmt= mysql_simple_prepare(mysql, "set max_error_count= ?");
check_stmt(stmt); check_stmt(stmt);
...@@ -4248,10 +4301,10 @@ static void test_set_variable() ...@@ -4248,10 +4301,10 @@ static void test_set_variable()
check_execute(stmt1, rc); check_execute(stmt1, rc);
fprintf(stdout, "\n max_error_count : %d", get_count); fprintf(stdout, "\n max_error_count : %d", get_count);
assert(get_count == set_count); DIE_UNLESS(get_count == set_count);
rc= mysql_stmt_fetch(stmt1); rc= mysql_stmt_fetch(stmt1);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
/* restore back to default */ /* restore back to default */
set_count= def_count; set_count= def_count;
...@@ -4265,10 +4318,10 @@ static void test_set_variable() ...@@ -4265,10 +4318,10 @@ static void test_set_variable()
check_execute(stmt1, rc); check_execute(stmt1, rc);
fprintf(stdout, "\n max_error_count(default): %d", get_count); fprintf(stdout, "\n max_error_count(default): %d", get_count);
assert(get_count == set_count); DIE_UNLESS(get_count == set_count);
rc= mysql_stmt_fetch(stmt1); rc= mysql_stmt_fetch(stmt1);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
mysql_stmt_close(stmt1); mysql_stmt_close(stmt1);
...@@ -4323,12 +4376,12 @@ static void test_insert_meta() ...@@ -4323,12 +4376,12 @@ static void test_insert_meta()
field= mysql_fetch_field(result); field= mysql_fetch_field(result);
mytest(field); mytest(field);
fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col1"); fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col1");
assert(strcmp(field->name, "col1") == 0); DIE_UNLESS(strcmp(field->name, "col1") == 0);
field= mysql_fetch_field(result); field= mysql_fetch_field(result);
mytest(field); mytest(field);
fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col3"); fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col3");
assert(strcmp(field->name, "col3") == 0); DIE_UNLESS(strcmp(field->name, "col3") == 0);
field= mysql_fetch_field(result); field= mysql_fetch_field(result);
mytest_r(field); mytest_r(field);
...@@ -4386,15 +4439,15 @@ static void test_update_meta() ...@@ -4386,15 +4439,15 @@ static void test_update_meta()
mytest(field); mytest(field);
fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1");
fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update");
assert(strcmp(field->name, "col1") == 0); DIE_UNLESS(strcmp(field->name, "col1") == 0);
assert(strcmp(field->table, "test_prep_update") == 0); DIE_UNLESS(strcmp(field->table, "test_prep_update") == 0);
field= mysql_fetch_field(result); field= mysql_fetch_field(result);
mytest(field); mytest(field);
fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col3"); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col3");
fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update");
assert(strcmp(field->name, "col3") == 0); DIE_UNLESS(strcmp(field->name, "col3") == 0);
assert(strcmp(field->table, "test_prep_update") == 0); DIE_UNLESS(strcmp(field->table, "test_prep_update") == 0);
field= mysql_fetch_field(result); field= mysql_fetch_field(result);
mytest_r(field); mytest_r(field);
...@@ -4450,15 +4503,15 @@ static void test_select_meta() ...@@ -4450,15 +4503,15 @@ static void test_select_meta()
mytest(field); mytest(field);
fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1");
fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select");
assert(strcmp(field->name, "col1") == 0); DIE_UNLESS(strcmp(field->name, "col1") == 0);
assert(strcmp(field->table, "test_prep_select") == 0); DIE_UNLESS(strcmp(field->table, "test_prep_select") == 0);
field= mysql_fetch_field(result); field= mysql_fetch_field(result);
mytest(field); mytest(field);
fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col2"); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col2");
fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select");
assert(strcmp(field->name, "col2") == 0); DIE_UNLESS(strcmp(field->name, "col2") == 0);
assert(strcmp(field->table, "test_prep_select") == 0); DIE_UNLESS(strcmp(field->table, "test_prep_select") == 0);
field= mysql_fetch_field(result); field= mysql_fetch_field(result);
mytest_r(field); mytest_r(field);
...@@ -4502,7 +4555,7 @@ static void test_func_fields() ...@@ -4502,7 +4555,7 @@ static void test_func_fields()
mytest(field); mytest(field);
fprintf(stdout, "\n table name: `%s` (expected: `%s`)", field->table, fprintf(stdout, "\n table name: `%s` (expected: `%s`)", field->table,
"test_dateformat"); "test_dateformat");
assert(strcmp(field->table, "test_dateformat") == 0); DIE_UNLESS(strcmp(field->table, "test_dateformat") == 0);
field= mysql_fetch_field(result); field= mysql_fetch_field(result);
mytest_r(field); /* no more fields */ mytest_r(field); /* no more fields */
...@@ -4519,7 +4572,7 @@ static void test_func_fields() ...@@ -4519,7 +4572,7 @@ static void test_func_fields()
field= mysql_fetch_field(result); field= mysql_fetch_field(result);
mytest(field); mytest(field);
fprintf(stdout, "\n table name: `%s` (expected: `%s`)", field->table, ""); fprintf(stdout, "\n table name: `%s` (expected: `%s`)", field->table, "");
assert(field->table[0] == '\0'); DIE_UNLESS(field->table[0] == '\0');
field= mysql_fetch_field(result); field= mysql_fetch_field(result);
mytest_r(field); /* no more fields */ mytest_r(field); /* no more fields */
...@@ -4537,8 +4590,8 @@ static void test_func_fields() ...@@ -4537,8 +4590,8 @@ static void test_func_fields()
mytest(field); mytest(field);
fprintf(stdout, "\n field name: `%s` (expected: `%s`)", field->name, "YEAR"); fprintf(stdout, "\n field name: `%s` (expected: `%s`)", field->name, "YEAR");
fprintf(stdout, "\n field org name: `%s` (expected: `%s`)", field->org_name, ""); fprintf(stdout, "\n field org name: `%s` (expected: `%s`)", field->org_name, "");
assert(strcmp(field->name, "YEAR") == 0); DIE_UNLESS(strcmp(field->name, "YEAR") == 0);
assert(field->org_name[0] == '\0'); DIE_UNLESS(field->org_name[0] == '\0');
field= mysql_fetch_field(result); field= mysql_fetch_field(result);
mytest_r(field); /* no more fields */ mytest_r(field); /* no more fields */
...@@ -4615,11 +4668,11 @@ static void test_multi_stmt() ...@@ -4615,11 +4668,11 @@ static void test_multi_stmt()
fprintf(stdout, "\n int_data: %lu(%lu)", (ulong) id, length[0]); fprintf(stdout, "\n int_data: %lu(%lu)", (ulong) id, length[0]);
fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]);
assert(id == 10); DIE_UNLESS(id == 10);
assert(strcmp(name, "mysql") == 0); DIE_UNLESS(strcmp(name, "mysql") == 0);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
/* alter the table schema now */ /* alter the table schema now */
stmt1= mysql_simple_prepare(mysql, "DELETE FROM test_multi_table " stmt1= mysql_simple_prepare(mysql, "DELETE FROM test_multi_table "
...@@ -4644,11 +4697,11 @@ static void test_multi_stmt() ...@@ -4644,11 +4697,11 @@ static void test_multi_stmt()
fprintf(stdout, "\n int_data: %lu(%lu)", (ulong) id, length[0]); fprintf(stdout, "\n int_data: %lu(%lu)", (ulong) id, length[0]);
fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]);
assert(id == 10); DIE_UNLESS(id == 10);
assert(strcmp(name, "updated") == 0); DIE_UNLESS(strcmp(name, "updated") == 0);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
rc= mysql_stmt_execute(stmt1); rc= mysql_stmt_execute(stmt1);
check_execute(stmt1, rc); check_execute(stmt1, rc);
...@@ -4661,9 +4714,10 @@ static void test_multi_stmt() ...@@ -4661,9 +4714,10 @@ static void test_multi_stmt()
check_execute(stmt, rc); check_execute(stmt, rc);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
assert(0 == my_stmt_result("SELECT * FROM test_multi_table")); rc= my_stmt_result("SELECT * FROM test_multi_table");
DIE_UNLESS(rc == 0);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
mysql_stmt_close(stmt2); mysql_stmt_close(stmt2);
...@@ -4679,6 +4733,7 @@ static void test_manual_sample() ...@@ -4679,6 +4733,7 @@ static void test_manual_sample()
MYSQL_STMT *stmt; MYSQL_STMT *stmt;
short small_data; short small_data;
int int_data; int int_data;
int rc;
char str_data[50]; char str_data[50];
ulonglong affected_rows; ulonglong affected_rows;
MYSQL_BIND bind[3]; MYSQL_BIND bind[3];
...@@ -4814,7 +4869,8 @@ static void test_manual_sample() ...@@ -4814,7 +4869,8 @@ static void test_manual_sample()
fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); fprintf(stderr, "\n %s", mysql_stmt_error(stmt));
exit(1); exit(1);
} }
assert(2 == my_stmt_result("SELECT * FROM test_table")); rc= my_stmt_result("SELECT * FROM test_table");
DIE_UNLESS(rc == 2);
/* DROP THE TABLE */ /* DROP THE TABLE */
if (mysql_query(mysql, "DROP TABLE test_table")) if (mysql_query(mysql, "DROP TABLE test_table"))
...@@ -4879,7 +4935,8 @@ static void test_prepare_alter() ...@@ -4879,7 +4935,8 @@ static void test_prepare_alter()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(4 == my_stmt_result("SELECT * FROM test_prep_alter")); rc= my_stmt_result("SELECT * FROM test_prep_alter");
DIE_UNLESS(rc == 4);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -4919,8 +4976,10 @@ DROP TABLE IF EXISTS test_multi_tab"; ...@@ -4919,8 +4976,10 @@ DROP TABLE IF EXISTS test_multi_tab";
rc= mysql_query(mysql, query); /* syntax error */ rc= mysql_query(mysql, query); /* syntax error */
myquery_r(rc); myquery_r(rc);
assert(-1 == mysql_next_result(mysql)); rc= mysql_next_result(mysql);
assert(0 == mysql_more_results(mysql)); DIE_UNLESS(rc == -1);
rc= mysql_more_results(mysql);
DIE_UNLESS(rc == 0);
if (!(mysql_local= mysql_init(NULL))) if (!(mysql_local= mysql_init(NULL)))
{ {
...@@ -4945,7 +5004,7 @@ DROP TABLE IF EXISTS test_multi_tab"; ...@@ -4945,7 +5004,7 @@ DROP TABLE IF EXISTS test_multi_tab";
fprintf(stdout, "\n Query %d: ", count); fprintf(stdout, "\n Query %d: ", count);
if ((result= mysql_store_result(mysql_local))) if ((result= mysql_store_result(mysql_local)))
{ {
my_process_result_set(result); (void) my_process_result_set(result);
mysql_free_result(result); mysql_free_result(result);
} }
else else
...@@ -4978,8 +5037,10 @@ DROP TABLE IF EXISTS test_multi_tab"; ...@@ -4978,8 +5037,10 @@ DROP TABLE IF EXISTS test_multi_tab";
} }
else else
{ {
assert(mysql_more_results(mysql_local) == 0); rc= mysql_more_results(mysql_local);
assert(mysql_next_result(mysql_local) == -1); DIE_UNLESS(rc == 0);
rc= mysql_next_result(mysql_local);
DIE_UNLESS(rc == -1);
} }
} }
...@@ -4987,16 +5048,20 @@ DROP TABLE IF EXISTS test_multi_tab"; ...@@ -4987,16 +5048,20 @@ DROP TABLE IF EXISTS test_multi_tab";
rc= mysql_query(mysql_local, "select 1+1+a;select 1+1"); rc= mysql_query(mysql_local, "select 1+1+a;select 1+1");
myquery_r(rc); myquery_r(rc);
assert(mysql_more_results(mysql_local) == 0); rc= mysql_more_results(mysql_local);
assert(mysql_next_result(mysql_local) == -1); DIE_UNLESS(rc == 0);
rc= mysql_next_result(mysql_local);
DIE_UNLESS(rc == -1);
rc= mysql_query(mysql_local, "select 1+1;select 1+1+a;select 1"); rc= mysql_query(mysql_local, "select 1+1;select 1+1+a;select 1");
myquery(rc); myquery(rc);
result= mysql_store_result(mysql_local); result= mysql_store_result(mysql_local);
mytest(result); mytest(result);
mysql_free_result(result); mysql_free_result(result);
assert(mysql_more_results(mysql_local) == 1); rc= mysql_more_results(mysql_local);
assert(mysql_next_result(mysql_local) > 0); DIE_UNLESS(rc == 1);
rc= mysql_next_result(mysql_local);
DIE_UNLESS(rc > 0);
/* /*
Ensure that we can now do a simple query (this checks that the server is Ensure that we can now do a simple query (this checks that the server is
...@@ -5006,7 +5071,7 @@ DROP TABLE IF EXISTS test_multi_tab"; ...@@ -5006,7 +5071,7 @@ DROP TABLE IF EXISTS test_multi_tab";
myquery(rc); myquery(rc);
result= mysql_store_result(mysql_local); result= mysql_store_result(mysql_local);
mytest(result); mytest(result);
my_process_result_set(result); (void) my_process_result_set(result);
mysql_free_result(result); mysql_free_result(result);
mysql_close(mysql_local); mysql_close(mysql_local);
...@@ -5103,17 +5168,17 @@ static void test_store_result() ...@@ -5103,17 +5168,17 @@ static void test_store_result()
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n row 1: %ld, %s(%lu)", (long) nData, szData, length1); fprintf(stdout, "\n row 1: %ld, %s(%lu)", (long) nData, szData, length1);
assert(nData == 10); DIE_UNLESS(nData == 10);
assert(strcmp(szData, "venu") == 0); DIE_UNLESS(strcmp(szData, "venu") == 0);
assert(length1 == 4); DIE_UNLESS(length1 == 4);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n row 2: %ld, %s(%lu)", (long) nData, szData, length1); fprintf(stdout, "\n row 2: %ld, %s(%lu)", (long) nData, szData, length1);
assert(nData == 20); DIE_UNLESS(nData == 20);
assert(strcmp(szData, "mysql") == 0); DIE_UNLESS(strcmp(szData, "mysql") == 0);
assert(length1 == 5); DIE_UNLESS(length1 == 5);
length= 99; length= 99;
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
...@@ -5121,12 +5186,12 @@ static void test_store_result() ...@@ -5121,12 +5186,12 @@ static void test_store_result()
if (is_null[0]) if (is_null[0])
fprintf(stdout, "\n row 3: NULL, %s(%lu)", szData, length1); fprintf(stdout, "\n row 3: NULL, %s(%lu)", szData, length1);
assert(is_null[0]); DIE_UNLESS(is_null[0]);
assert(strcmp(szData, "monty") == 0); DIE_UNLESS(strcmp(szData, "monty") == 0);
assert(length1 == 5); DIE_UNLESS(length1 == 5);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
...@@ -5138,17 +5203,17 @@ static void test_store_result() ...@@ -5138,17 +5203,17 @@ static void test_store_result()
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n row 1: %ld, %s(%lu)", (long) nData, szData, length1); fprintf(stdout, "\n row 1: %ld, %s(%lu)", (long) nData, szData, length1);
assert(nData == 10); DIE_UNLESS(nData == 10);
assert(strcmp(szData, "venu") == 0); DIE_UNLESS(strcmp(szData, "venu") == 0);
assert(length1 == 4); DIE_UNLESS(length1 == 4);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n row 2: %ld, %s(%lu)", (long) nData, szData, length1); fprintf(stdout, "\n row 2: %ld, %s(%lu)", (long) nData, szData, length1);
assert(nData == 20); DIE_UNLESS(nData == 20);
assert(strcmp(szData, "mysql") == 0); DIE_UNLESS(strcmp(szData, "mysql") == 0);
assert(length1 == 5); DIE_UNLESS(length1 == 5);
length= 99; length= 99;
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
...@@ -5156,12 +5221,12 @@ static void test_store_result() ...@@ -5156,12 +5221,12 @@ static void test_store_result()
if (is_null[0]) if (is_null[0])
fprintf(stdout, "\n row 3: NULL, %s(%lu)", szData, length1); fprintf(stdout, "\n row 3: NULL, %s(%lu)", szData, length1);
assert(is_null[0]); DIE_UNLESS(is_null[0]);
assert(strcmp(szData, "monty") == 0); DIE_UNLESS(strcmp(szData, "monty") == 0);
assert(length1 == 5); DIE_UNLESS(length1 == 5);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -5204,7 +5269,7 @@ static void test_store_result1() ...@@ -5204,7 +5269,7 @@ static void test_store_result1()
while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA)
rc++; rc++;
fprintf(stdout, "\n total rows: %d", rc); fprintf(stdout, "\n total rows: %d", rc);
assert(rc == 3); DIE_UNLESS(rc == 3);
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
...@@ -5216,7 +5281,7 @@ static void test_store_result1() ...@@ -5216,7 +5281,7 @@ static void test_store_result1()
while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA)
rc++; rc++;
fprintf(stdout, "\n total rows: %d", rc); fprintf(stdout, "\n total rows: %d", rc);
assert(rc == 3); DIE_UNLESS(rc == 3);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -5282,10 +5347,10 @@ static void test_store_result2() ...@@ -5282,10 +5347,10 @@ static void test_store_result2()
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n row 1: %d", nData); fprintf(stdout, "\n row 1: %d", nData);
assert(nData == 10); DIE_UNLESS(nData == 10);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
nData= 20; nData= 20;
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
...@@ -5299,10 +5364,10 @@ static void test_store_result2() ...@@ -5299,10 +5364,10 @@ static void test_store_result2()
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n row 1: %d", nData); fprintf(stdout, "\n row 1: %d", nData);
assert(nData == 20); DIE_UNLESS(nData == 20);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -5374,13 +5439,18 @@ static void test_subselect() ...@@ -5374,13 +5439,18 @@ static void test_subselect()
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
assert(3 == my_stmt_result("SELECT * FROM test_sub2")); rc= my_stmt_result("SELECT * FROM test_sub2");
DIE_UNLESS(rc == 3);
strmov((char *)query , "SELECT ROW(1, 7) IN (select id, id1 from test_sub2 WHERE id1= ?)"); rc= my_stmt_result("SELECT ROW(1, 7) IN (select id, id1 "
assert(1 == my_stmt_result("SELECT ROW(1, 7) IN (select id, id1 from test_sub2 WHERE id1= 8)")); "from test_sub2 WHERE id1= 8)");
assert(1 == my_stmt_result("SELECT ROW(1, 7) IN (select id, id1 from test_sub2 WHERE id1= 7)")); DIE_UNLESS(rc == 1);
rc= my_stmt_result("SELECT ROW(1, 7) IN (select id, id1 "
"from test_sub2 WHERE id1= 7)");
DIE_UNLESS(rc == 1);
stmt= mysql_simple_prepare(mysql, query); stmt= mysql_simple_prepare(mysql, ("SELECT ROW(1, 7) IN (select id, id1 "
"from test_sub2 WHERE id1= ?)"));
check_stmt(stmt); check_stmt(stmt);
rc= mysql_stmt_bind_param(stmt, bind); rc= mysql_stmt_bind_param(stmt, bind);
...@@ -5397,10 +5467,10 @@ static void test_subselect() ...@@ -5397,10 +5467,10 @@ static void test_subselect()
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n row 1: %d", id); fprintf(stdout, "\n row 1: %d", id);
assert(id == 1); DIE_UNLESS(id == 1);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
id= 8; id= 8;
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
...@@ -5410,10 +5480,10 @@ static void test_subselect() ...@@ -5410,10 +5480,10 @@ static void test_subselect()
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n row 1: %d", id); fprintf(stdout, "\n row 1: %d", id);
assert(id == 0); DIE_UNLESS(id == 0);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -5505,10 +5575,11 @@ static void test_bind_date_conv(uint row_count) ...@@ -5505,10 +5575,11 @@ static void test_bind_date_conv(uint row_count)
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
assert(row_count == my_stmt_result("SELECT * FROM test_date")); rc= my_stmt_result("SELECT * FROM test_date");
DIE_UNLESS(row_count == rc);
stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_date"); stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_date");
myquery(rc); check_stmt(stmt);
rc= mysql_stmt_bind_result(stmt, bind); rc= mysql_stmt_bind_result(stmt, bind);
check_execute(stmt, rc); check_execute(stmt, rc);
...@@ -5533,23 +5604,25 @@ static void test_bind_date_conv(uint row_count) ...@@ -5533,23 +5604,25 @@ static void test_bind_date_conv(uint row_count)
tm[i].hour, tm[i].minute, tm[i].second, tm[i].hour, tm[i].minute, tm[i].second,
tm[i].second_part); tm[i].second_part);
assert(tm[i].year == 0 || tm[i].year == year+count); DIE_UNLESS(tm[i].year == 0 || tm[i].year == year+count);
assert(tm[i].month == 0 || tm[i].month == month+count); DIE_UNLESS(tm[i].month == 0 || tm[i].month == month+count);
assert(tm[i].day == 0 || tm[i].day == day+count); DIE_UNLESS(tm[i].day == 0 || tm[i].day == day+count);
assert(tm[i].hour == 0 || tm[i].hour == hour+count); DIE_UNLESS(tm[i].hour == 0 || tm[i].hour == hour+count);
#if 0
/* /*
minute causes problems from date<->time, don't assert, instead minute causes problems from date<->time, don't assert, instead
validate separatly in another routine validate separatly in another routine
*/ */
/*assert(tm[i].minute == 0 || tm[i].minute == minute+count); DIE_UNLESS(tm[i].minute == 0 || tm[i].minute == minute+count);
assert(tm[i].second == 0 || tm[i].second == sec+count);*/ DIE_UNLESS(tm[i].second == 0 || tm[i].second == sec+count);
#endif
assert(tm[i].second_part == 0 || tm[i].second_part == second_part+count); DIE_UNLESS(tm[i].second_part == 0 ||
tm[i].second_part == second_part+count);
} }
} }
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -5792,9 +5865,9 @@ static void test_buffers() ...@@ -5792,9 +5865,9 @@ static void test_buffers()
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n data: %s (%lu)", buffer, length); fprintf(stdout, "\n data: %s (%lu)", buffer, length);
assert(buffer[0] == 'M'); DIE_UNLESS(buffer[0] == 'M');
assert(buffer[1] == 'X'); DIE_UNLESS(buffer[1] == 'X');
assert(length == 5); DIE_UNLESS(length == 5);
bind[0].buffer_length= 8; bind[0].buffer_length= 8;
rc= mysql_stmt_bind_result(stmt, bind);/* re-bind */ rc= mysql_stmt_bind_result(stmt, bind);/* re-bind */
...@@ -5803,8 +5876,8 @@ static void test_buffers() ...@@ -5803,8 +5876,8 @@ static void test_buffers()
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n data: %s (%lu)", buffer, length); fprintf(stdout, "\n data: %s (%lu)", buffer, length);
assert(strncmp(buffer, "Database", 8) == 0); DIE_UNLESS(strncmp(buffer, "Database", 8) == 0);
assert(length == 8); DIE_UNLESS(length == 8);
bind[0].buffer_length= 12; bind[0].buffer_length= 12;
rc= mysql_stmt_bind_result(stmt, bind);/* re-bind */ rc= mysql_stmt_bind_result(stmt, bind);/* re-bind */
...@@ -5813,8 +5886,8 @@ static void test_buffers() ...@@ -5813,8 +5886,8 @@ static void test_buffers()
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n data: %s (%lu)", buffer, length); fprintf(stdout, "\n data: %s (%lu)", buffer, length);
assert(strcmp(buffer, "Open-Source") == 0); DIE_UNLESS(strcmp(buffer, "Open-Source") == 0);
assert(length == 11); DIE_UNLESS(length == 11);
bind[0].buffer_length= 6; bind[0].buffer_length= 6;
rc= mysql_stmt_bind_result(stmt, bind);/* re-bind */ rc= mysql_stmt_bind_result(stmt, bind);/* re-bind */
...@@ -5823,8 +5896,8 @@ static void test_buffers() ...@@ -5823,8 +5896,8 @@ static void test_buffers()
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n data: %s (%lu)", buffer, length); fprintf(stdout, "\n data: %s (%lu)", buffer, length);
assert(strncmp(buffer, "Popula", 6) == 0); DIE_UNLESS(strncmp(buffer, "Popula", 6) == 0);
assert(length == 7); DIE_UNLESS(length == 7);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -5855,7 +5928,8 @@ static void test_open_direct() ...@@ -5855,7 +5928,8 @@ static void test_open_direct()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(0 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 0);
mysql_free_result(result); mysql_free_result(result);
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
...@@ -5869,7 +5943,8 @@ static void test_open_direct() ...@@ -5869,7 +5943,8 @@ static void test_open_direct()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(1 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 1);
mysql_free_result(result); mysql_free_result(result);
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
...@@ -5883,7 +5958,8 @@ static void test_open_direct() ...@@ -5883,7 +5958,8 @@ static void test_open_direct()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(2 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 2);
mysql_free_result(result); mysql_free_result(result);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -5951,7 +6027,7 @@ static void test_fetch_nobuffs() ...@@ -5951,7 +6027,7 @@ static void test_fetch_nobuffs()
rc++; rc++;
fprintf(stdout, "\n total rows : %d", rc); fprintf(stdout, "\n total rows : %d", rc);
assert(rc == 1); DIE_UNLESS(rc == 1);
bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= (void *)str[0]; bind[0].buffer= (void *)str[0];
...@@ -5979,7 +6055,7 @@ static void test_fetch_nobuffs() ...@@ -5979,7 +6055,7 @@ static void test_fetch_nobuffs()
fprintf(stdout, "\n CURRENT_TIME() : %s", str[3]); fprintf(stdout, "\n CURRENT_TIME() : %s", str[3]);
} }
fprintf(stdout, "\n total rows : %d", rc); fprintf(stdout, "\n total rows : %d", rc);
assert(rc == 1); DIE_UNLESS(rc == 1);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -6050,20 +6126,20 @@ static void test_ushort_bug() ...@@ -6050,20 +6126,20 @@ static void test_ushort_bug()
fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length);
fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length);
assert(short_value == 35999); DIE_UNLESS(short_value == 35999);
assert(s_length == 2); DIE_UNLESS(s_length == 2);
assert(long_value == 35999); DIE_UNLESS(long_value == 35999);
assert(l_length == 4); DIE_UNLESS(l_length == 4);
assert(longlong_value == 35999); DIE_UNLESS(longlong_value == 35999);
assert(ll_length == 8); DIE_UNLESS(ll_length == 8);
assert(tiny_value == 200); DIE_UNLESS(tiny_value == 200);
assert(t_length == 1); DIE_UNLESS(t_length == 1);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -6134,20 +6210,20 @@ static void test_sshort_bug() ...@@ -6134,20 +6210,20 @@ static void test_sshort_bug()
fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length);
fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length);
assert(short_value == -5999); DIE_UNLESS(short_value == -5999);
assert(s_length == 2); DIE_UNLESS(s_length == 2);
assert(long_value == -5999); DIE_UNLESS(long_value == -5999);
assert(l_length == 4); DIE_UNLESS(l_length == 4);
assert(longlong_value == 35999); DIE_UNLESS(longlong_value == 35999);
assert(ll_length == 8); DIE_UNLESS(ll_length == 8);
assert(tiny_value == 200); DIE_UNLESS(tiny_value == 200);
assert(t_length == 1); DIE_UNLESS(t_length == 1);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -6218,20 +6294,20 @@ static void test_stiny_bug() ...@@ -6218,20 +6294,20 @@ static void test_stiny_bug()
fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length);
fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length);
assert(short_value == -128); DIE_UNLESS(short_value == -128);
assert(s_length == 2); DIE_UNLESS(s_length == 2);
assert(long_value == -127); DIE_UNLESS(long_value == -127);
assert(l_length == 4); DIE_UNLESS(l_length == 4);
assert(longlong_value == 255); DIE_UNLESS(longlong_value == 255);
assert(ll_length == 8); DIE_UNLESS(ll_length == 8);
assert(tiny_value == 0); DIE_UNLESS(tiny_value == 0);
assert(t_length == 1); DIE_UNLESS(t_length == 1);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -6256,13 +6332,14 @@ static void test_field_misc() ...@@ -6256,13 +6332,14 @@ static void test_field_misc()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(1 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 1);
verify_prepare_field(result, 0, verify_prepare_field(result, 0,
"@@autocommit", "", /* field and its org name */ "@@autocommit", "", /* field and its org name */
MYSQL_TYPE_LONGLONG, /* field type */ MYSQL_TYPE_LONGLONG, /* field type */
"", "", /* table and its org name */ "", "", /* table and its org name */
"", 1, 0); /* db name, length(its bool flag)*/ "", 1, 0); /* db name, length(its bool flag)*/
mysql_free_result(result); mysql_free_result(result);
...@@ -6275,13 +6352,14 @@ static void test_field_misc() ...@@ -6275,13 +6352,14 @@ static void test_field_misc()
result= mysql_stmt_result_metadata(stmt); result= mysql_stmt_result_metadata(stmt);
mytest(result); mytest(result);
assert(1 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
verify_prepare_field(result, 0, verify_prepare_field(result, 0,
"@@autocommit", "", /* field and its org name */ "@@autocommit", "", /* field and its org name */
MYSQL_TYPE_LONGLONG, /* field type */ MYSQL_TYPE_LONGLONG, /* field type */
"", "", /* table and its org name */ "", "", /* table and its org name */
"", 1, 0); /* db name, length(its bool flag)*/ "", 1, 0); /* db name, length(its bool flag)*/
mysql_free_result(result); mysql_free_result(result);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -6306,7 +6384,7 @@ static void test_field_misc() ...@@ -6306,7 +6384,7 @@ static void test_field_misc()
fprintf(stdout, "\n default table type: %s(%ld)", table_type, type_length); fprintf(stdout, "\n default table type: %s(%ld)", table_type, type_length);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -6315,12 +6393,12 @@ static void test_field_misc() ...@@ -6315,12 +6393,12 @@ static void test_field_misc()
result= mysql_stmt_result_metadata(stmt); result= mysql_stmt_result_metadata(stmt);
mytest(result); mytest(result);
assert(mysql_stmt_field_count(stmt) == mysql_num_fields(result)); DIE_UNLESS(mysql_stmt_field_count(stmt) == mysql_num_fields(result));
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(1 == my_process_stmt_result(stmt)); DIE_UNLESS(1 == my_process_stmt_result(stmt));
verify_prepare_field(result, 0, verify_prepare_field(result, 0,
"@@table_type", "", /* field and its org name */ "@@table_type", "", /* field and its org name */
...@@ -6340,7 +6418,8 @@ static void test_field_misc() ...@@ -6340,7 +6418,8 @@ static void test_field_misc()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(1 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
verify_prepare_field(result, 0, verify_prepare_field(result, 0,
"@@max_error_count", "", /* field and its org name */ "@@max_error_count", "", /* field and its org name */
...@@ -6360,7 +6439,7 @@ static void test_field_misc() ...@@ -6360,7 +6439,7 @@ static void test_field_misc()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(1 == my_process_stmt_result(stmt)); DIE_UNLESS(1 == my_process_stmt_result(stmt));
verify_prepare_field(result, 0, verify_prepare_field(result, 0,
"@@max_allowed_packet", "", /* field and its org name */ "@@max_allowed_packet", "", /* field and its org name */
...@@ -6380,13 +6459,14 @@ static void test_field_misc() ...@@ -6380,13 +6459,14 @@ static void test_field_misc()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(1 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
verify_prepare_field(result, 0, verify_prepare_field(result, 0,
"@@sql_warnings", "", /* field and its org name */ "@@sql_warnings", "", /* field and its org name */
MYSQL_TYPE_LONGLONG, /* field type */ MYSQL_TYPE_LONGLONG, /* field type */
"", "", /* table and its org name */ "", "", /* table and its org name */
"", 1, 0); /* db name, length */ "", 1, 0); /* db name, length */
mysql_free_result(result); mysql_free_result(result);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -6428,7 +6508,8 @@ static void test_set_option() ...@@ -6428,7 +6508,8 @@ static void test_set_option()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(2 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 2);
mysql_free_result(result); mysql_free_result(result);
...@@ -6439,7 +6520,8 @@ static void test_set_option() ...@@ -6439,7 +6520,8 @@ static void test_set_option()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(2 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 2);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -6454,7 +6536,8 @@ static void test_set_option() ...@@ -6454,7 +6536,8 @@ static void test_set_option()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(4 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 4);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -6527,7 +6610,8 @@ static void test_prepare_grant() ...@@ -6527,7 +6610,8 @@ static void test_prepare_grant()
execute_prepare_query("INSERT INTO test_grant(a) VALUES(NULL)", 1); execute_prepare_query("INSERT INTO test_grant(a) VALUES(NULL)", 1);
execute_prepare_query("INSERT INTO test_grant 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); execute_prepare_query("UPDATE test_grant SET a=9 WHERE a=1", 1);
assert(4 == my_stmt_result("SELECT a FROM test_grant")); rc= my_stmt_result("SELECT a FROM test_grant");
DIE_UNLESS(rc == 4);
/* Both DELETE expected to fail as user does not have DELETE privs */ /* Both DELETE expected to fail as user does not have DELETE privs */
...@@ -6537,18 +6621,19 @@ static void test_prepare_grant() ...@@ -6537,18 +6621,19 @@ static void test_prepare_grant()
stmt= mysql_simple_prepare(mysql, "DELETE FROM test_grant"); stmt= mysql_simple_prepare(mysql, "DELETE FROM test_grant");
check_stmt_r(stmt); check_stmt_r(stmt);
assert(4 == my_stmt_result("SELECT * FROM test_grant")); rc= my_stmt_result("SELECT * FROM test_grant");
DIE_UNLESS(rc == 4);
mysql_close(lmysql); mysql_close(lmysql);
mysql= org_mysql; mysql= org_mysql;
rc= mysql_query(mysql, "delete from mysql.user where User='test_grant'"); rc= mysql_query(mysql, "delete from mysql.user where User='test_grant'");
myquery(rc); myquery(rc);
assert(1 == mysql_affected_rows(mysql)); DIE_UNLESS(1 == mysql_affected_rows(mysql));
rc= mysql_query(mysql, "delete from mysql.tables_priv where User='test_grant'"); rc= mysql_query(mysql, "delete from mysql.tables_priv where User='test_grant'");
myquery(rc); myquery(rc);
assert(1 == mysql_affected_rows(mysql)); DIE_UNLESS(1 == mysql_affected_rows(mysql));
} }
} }
...@@ -6603,7 +6688,7 @@ static void test_frm_bug() ...@@ -6603,7 +6688,7 @@ static void test_frm_bug()
fprintf(stdout, "\n data directory: %s", data_dir); fprintf(stdout, "\n data directory: %s", data_dir);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
strxmov(test_frm, data_dir, "/", current_db, "/", "test_frm_bug.frm", NullS); strxmov(test_frm, data_dir, "/", current_db, "/", "test_frm_bug.frm", NullS);
...@@ -6623,7 +6708,8 @@ static void test_frm_bug() ...@@ -6623,7 +6708,8 @@ static void test_frm_bug()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result);/* It can't be NULL */ mytest(result);/* It can't be NULL */
assert(1 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 1);
mysql_data_seek(result, 0); mysql_data_seek(result, 0);
...@@ -6631,7 +6717,7 @@ static void test_frm_bug() ...@@ -6631,7 +6717,7 @@ static void test_frm_bug()
mytest(row); mytest(row);
fprintf(stdout, "\n Comment: %s", row[17]); fprintf(stdout, "\n Comment: %s", row[17]);
assert(row[17] != 0); DIE_UNLESS(row[17] != 0);
mysql_free_result(result); mysql_free_result(result);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -6694,10 +6780,10 @@ static void test_decimal_bug() ...@@ -6694,10 +6780,10 @@ static void test_decimal_bug()
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n data: %s", data); fprintf(stdout, "\n data: %s", data);
assert(strcmp(data, "8.00") == 0); DIE_UNLESS(strcmp(data, "8.00") == 0);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
strcpy(data, "5.61"); strcpy(data, "5.61");
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
...@@ -6711,17 +6797,17 @@ static void test_decimal_bug() ...@@ -6711,17 +6797,17 @@ static void test_decimal_bug()
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n data: %s", data); fprintf(stdout, "\n data: %s", data);
assert(strcmp(data, "5.61") == 0); DIE_UNLESS(strcmp(data, "5.61") == 0);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
is_null= 1; is_null= 1;
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
strcpy(data, "10.22"); is_null= 0; strcpy(data, "10.22"); is_null= 0;
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
...@@ -6735,10 +6821,10 @@ static void test_decimal_bug() ...@@ -6735,10 +6821,10 @@ static void test_decimal_bug()
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n data: %s", data); fprintf(stdout, "\n data: %s", data);
assert(strcmp(data, "10.22") == 0); DIE_UNLESS(strcmp(data, "10.22") == 0);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -6768,14 +6854,15 @@ static void test_explain_bug() ...@@ -6768,14 +6854,15 @@ static void test_explain_bug()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert( 2 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 2);
result= mysql_stmt_result_metadata(stmt); result= mysql_stmt_result_metadata(stmt);
mytest(result); mytest(result);
fprintf(stdout, "\n total fields in the result: %d", fprintf(stdout, "\n total fields in the result: %d",
mysql_num_fields(result)); mysql_num_fields(result));
assert(6 == mysql_num_fields(result)); DIE_UNLESS(6 == mysql_num_fields(result));
verify_prepare_field(result, 0, "Field", "", MYSQL_TYPE_VAR_STRING, verify_prepare_field(result, 0, "Field", "", MYSQL_TYPE_VAR_STRING,
"", "", "", NAME_LEN, 0); "", "", "", NAME_LEN, 0);
...@@ -6804,14 +6891,15 @@ static void test_explain_bug() ...@@ -6804,14 +6891,15 @@ static void test_explain_bug()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert( 1 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
result= mysql_stmt_result_metadata(stmt); result= mysql_stmt_result_metadata(stmt);
mytest(result); mytest(result);
fprintf(stdout, "\n total fields in the result: %d", fprintf(stdout, "\n total fields in the result: %d",
mysql_num_fields(result)); mysql_num_fields(result));
assert(10 == mysql_num_fields(result)); DIE_UNLESS(10 == mysql_num_fields(result));
verify_prepare_field(result, 0, "id", "", MYSQL_TYPE_LONGLONG, verify_prepare_field(result, 0, "id", "", MYSQL_TYPE_LONGLONG,
"", "", "", 3, 0); "", "", "", 3, 0);
...@@ -6863,7 +6951,7 @@ static void check_errcode(const unsigned int err) ...@@ -6863,7 +6951,7 @@ static void check_errcode(const unsigned int err)
else else
fprintf(stdout, "\n [MySQL]"); fprintf(stdout, "\n [MySQL]");
fprintf(stdout, "[%d] %s\n", mysql_errno(mysql), mysql_error(mysql)); fprintf(stdout, "[%d] %s\n", mysql_errno(mysql), mysql_error(mysql));
assert(mysql_errno(mysql) == err); DIE_UNLESS(mysql_errno(mysql) == err);
} }
...@@ -6959,16 +7047,16 @@ static void test_drop_temp() ...@@ -6959,16 +7047,16 @@ static void test_drop_temp()
rc= mysql_query(mysql, "drop database test_drop_temp_db"); rc= mysql_query(mysql, "drop database test_drop_temp_db");
myquery(rc); myquery(rc);
assert(1 == mysql_affected_rows(mysql)); DIE_UNLESS(1 == mysql_affected_rows(mysql));
rc= mysql_query(mysql, "delete from mysql.user where User='test_temp'"); rc= mysql_query(mysql, "delete from mysql.user where User='test_temp'");
myquery(rc); myquery(rc);
assert(1 == mysql_affected_rows(mysql)); DIE_UNLESS(1 == mysql_affected_rows(mysql));
rc= mysql_query(mysql, "delete from mysql.tables_priv where User='test_temp'"); rc= mysql_query(mysql, "delete from mysql.tables_priv where User='test_temp'");
myquery(rc); myquery(rc);
assert(1 == mysql_affected_rows(mysql)); DIE_UNLESS(1 == mysql_affected_rows(mysql));
} }
} }
#endif #endif
...@@ -6997,14 +7085,14 @@ static void test_cuted_rows() ...@@ -6997,14 +7085,14 @@ static void test_cuted_rows()
count= mysql_warning_count(mysql); count= mysql_warning_count(mysql);
fprintf(stdout, "\n total warnings: %d", count); fprintf(stdout, "\n total warnings: %d", count);
assert(count == 0); DIE_UNLESS(count == 0);
rc= mysql_query(mysql, "INSERT INTO t2 SELECT * FROM t1"); rc= mysql_query(mysql, "INSERT INTO t2 SELECT * FROM t1");
myquery(rc); myquery(rc);
count= mysql_warning_count(mysql); count= mysql_warning_count(mysql);
fprintf(stdout, "\n total warnings: %d", count); fprintf(stdout, "\n total warnings: %d", count);
assert(count == 2); DIE_UNLESS(count == 2);
rc= mysql_query(mysql, "SHOW WARNINGS"); rc= mysql_query(mysql, "SHOW WARNINGS");
myquery(rc); myquery(rc);
...@@ -7012,7 +7100,8 @@ static void test_cuted_rows() ...@@ -7012,7 +7100,8 @@ static void test_cuted_rows()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(2 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 2);
mysql_free_result(result); mysql_free_result(result);
rc= mysql_query(mysql, "INSERT INTO t1 VALUES('junk'), (876789)"); rc= mysql_query(mysql, "INSERT INTO t1 VALUES('junk'), (876789)");
...@@ -7020,7 +7109,7 @@ static void test_cuted_rows() ...@@ -7020,7 +7109,7 @@ static void test_cuted_rows()
count= mysql_warning_count(mysql); count= mysql_warning_count(mysql);
fprintf(stdout, "\n total warnings: %d", count); fprintf(stdout, "\n total warnings: %d", count);
assert(count == 2); DIE_UNLESS(count == 2);
rc= mysql_query(mysql, "SHOW WARNINGS"); rc= mysql_query(mysql, "SHOW WARNINGS");
myquery(rc); myquery(rc);
...@@ -7028,7 +7117,8 @@ static void test_cuted_rows() ...@@ -7028,7 +7117,8 @@ static void test_cuted_rows()
result= mysql_store_result(mysql); result= mysql_store_result(mysql);
mytest(result); mytest(result);
assert(2 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 2);
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -7134,44 +7224,44 @@ static void test_logs() ...@@ -7134,44 +7224,44 @@ static void test_logs()
fprintf(stdout, "\n id : %d", id); fprintf(stdout, "\n id : %d", id);
fprintf(stdout, "\n name : %s(%ld)", data, length); fprintf(stdout, "\n name : %s(%ld)", data, length);
assert(id == 9876); DIE_UNLESS(id == 9876);
assert(length == 19); /* Due to VARCHAR(20) */ DIE_UNLESS(length == 19); /* Due to VARCHAR(20) */
assert(strcmp(data, "MySQL - Open Source") == 0); DIE_UNLESS(strcmp(data, "MySQL - Open Source") == 0);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n name : %s(%ld)", data, length); fprintf(stdout, "\n name : %s(%ld)", data, length);
assert(length == 1); DIE_UNLESS(length == 1);
assert(strcmp(data, "'") == 0); DIE_UNLESS(strcmp(data, "'") == 0);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n name : %s(%ld)", data, length); fprintf(stdout, "\n name : %s(%ld)", data, length);
assert(length == 1); DIE_UNLESS(length == 1);
assert(strcmp(data, "\"") == 0); DIE_UNLESS(strcmp(data, "\"") == 0);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n name : %s(%ld)", data, length); fprintf(stdout, "\n name : %s(%ld)", data, length);
assert(length == 7); DIE_UNLESS(length == 7);
assert(strcmp(data, "my\'sql\'") == 0); DIE_UNLESS(strcmp(data, "my\'sql\'") == 0);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n name : %s(%ld)", data, length); fprintf(stdout, "\n name : %s(%ld)", data, length);
assert(length == 7); DIE_UNLESS(length == 7);
/*assert(strcmp(data, "my\"sql\"") == 0); */ /*DIE_UNLESS(strcmp(data, "my\"sql\"") == 0); */
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -7239,10 +7329,10 @@ static void test_nstmts() ...@@ -7239,10 +7329,10 @@ static void test_nstmts()
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n total rows: %d", i); fprintf(stdout, "\n total rows: %d", i);
assert( i == total_stmts); DIE_UNLESS( i == total_stmts);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -7339,7 +7429,7 @@ static void test_fetch_seek() ...@@ -7339,7 +7429,7 @@ static void test_fetch_seek()
check_execute(stmt, rc); check_execute(stmt, rc);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -7396,17 +7486,17 @@ static void test_fetch_offset() ...@@ -7396,17 +7486,17 @@ static void test_fetch_offset()
rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); rc= mysql_stmt_fetch_column(stmt, bind, 0, 0);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n col 1: %s (%ld)", data, length); fprintf(stdout, "\n col 1: %s (%ld)", data, length);
assert(strncmp(data, "abcd", 4) == 0 && length == 10); DIE_UNLESS(strncmp(data, "abcd", 4) == 0 && length == 10);
rc= mysql_stmt_fetch_column(stmt, bind, 0, 5); rc= mysql_stmt_fetch_column(stmt, bind, 0, 5);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n col 1: %s (%ld)", data, length); fprintf(stdout, "\n col 1: %s (%ld)", data, length);
assert(strncmp(data, "fg", 2) == 0 && length == 10); DIE_UNLESS(strncmp(data, "fg", 2) == 0 && length == 10);
rc= mysql_stmt_fetch_column(stmt, bind, 0, 9); rc= mysql_stmt_fetch_column(stmt, bind, 0, 9);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n col 0: %s (%ld)", data, length); fprintf(stdout, "\n col 0: %s (%ld)", data, length);
assert(strncmp(data, "j", 1) == 0 && length == 10); DIE_UNLESS(strncmp(data, "j", 1) == 0 && length == 10);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
...@@ -7416,10 +7506,10 @@ static void test_fetch_offset() ...@@ -7416,10 +7506,10 @@ static void test_fetch_offset()
rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); rc= mysql_stmt_fetch_column(stmt, bind, 0, 0);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(is_null == 1); DIE_UNLESS(is_null == 1);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); rc= mysql_stmt_fetch_column(stmt, bind, 1, 0);
check_execute_r(stmt, rc); check_execute_r(stmt, rc);
...@@ -7490,13 +7580,13 @@ static void test_fetch_column() ...@@ -7490,13 +7580,13 @@ static void test_fetch_column()
rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); rc= mysql_stmt_fetch_column(stmt, bind, 1, 0);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2);
assert(strncmp(c2, "venu", 4) == 0 && l2 == 4); DIE_UNLESS(strncmp(c2, "venu", 4) == 0 && l2 == 4);
c2[0]= '\0'; l2= 0; c2[0]= '\0'; l2= 0;
rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); rc= mysql_stmt_fetch_column(stmt, bind, 1, 0);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2);
assert(strcmp(c2, "venu") == 0 && l2 == 4); DIE_UNLESS(strcmp(c2, "venu") == 0 && l2 == 4);
c1= 0; c1= 0;
bind[0].buffer_type= MYSQL_TYPE_LONG; bind[0].buffer_type= MYSQL_TYPE_LONG;
...@@ -7508,7 +7598,7 @@ static void test_fetch_column() ...@@ -7508,7 +7598,7 @@ static void test_fetch_column()
rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); rc= mysql_stmt_fetch_column(stmt, bind, 0, 0);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); fprintf(stdout, "\n col 0: %d(%ld)", c1, l1);
assert(c1 == 1 && l1 == 4); DIE_UNLESS(c1 == 1 && l1 == 4);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
...@@ -7525,13 +7615,13 @@ static void test_fetch_column() ...@@ -7525,13 +7615,13 @@ static void test_fetch_column()
rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); rc= mysql_stmt_fetch_column(stmt, bind, 1, 0);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2);
assert(strncmp(c2, "mysq", 4) == 0 && l2 == 5); DIE_UNLESS(strncmp(c2, "mysq", 4) == 0 && l2 == 5);
c2[0]= '\0'; l2= 0; c2[0]= '\0'; l2= 0;
rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); rc= mysql_stmt_fetch_column(stmt, bind, 1, 0);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n col 1: %si(%ld)", c2, l2); fprintf(stdout, "\n col 1: %si(%ld)", c2, l2);
assert(strcmp(c2, "mysql") == 0 && l2 == 5); DIE_UNLESS(strcmp(c2, "mysql") == 0 && l2 == 5);
c1= 0; c1= 0;
bind[0].buffer_type= MYSQL_TYPE_LONG; bind[0].buffer_type= MYSQL_TYPE_LONG;
...@@ -7543,10 +7633,10 @@ static void test_fetch_column() ...@@ -7543,10 +7633,10 @@ static void test_fetch_column()
rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); rc= mysql_stmt_fetch_column(stmt, bind, 0, 0);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); fprintf(stdout, "\n col 0: %d(%ld)", c1, l1);
assert(c1 == 2 && l1 == 4); DIE_UNLESS(c1 == 2 && l1 == 4);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); rc= mysql_stmt_fetch_column(stmt, bind, 1, 0);
check_execute_r(stmt, rc); check_execute_r(stmt, rc);
...@@ -7572,13 +7662,16 @@ static void test_list_fields() ...@@ -7572,13 +7662,16 @@ static void test_list_fields()
result= mysql_list_fields(mysql, "test_list_fields", NULL); result= mysql_list_fields(mysql, "test_list_fields", NULL);
mytest(result); mytest(result);
assert( 0 == my_process_result_set(result)); rc= my_process_result_set(result);
DIE_UNLESS(rc == 0);
verify_prepare_field(result, 0, "c1", "c1", MYSQL_TYPE_LONG, verify_prepare_field(result, 0, "c1", "c1", MYSQL_TYPE_LONG,
"test_list_fields", "test_list_fields", current_db, 11, "0"); "test_list_fields", "test_list_fields",
current_db, 11, "0");
verify_prepare_field(result, 1, "c2", "c2", MYSQL_TYPE_STRING, verify_prepare_field(result, 1, "c2", "c2", MYSQL_TYPE_STRING,
"test_list_fields", "test_list_fields", current_db, 10, "mysql"); "test_list_fields", "test_list_fields",
current_db, 10, "mysql");
mysql_free_result(result); mysql_free_result(result);
} }
...@@ -7631,7 +7724,8 @@ static void test_mem_overun() ...@@ -7631,7 +7724,8 @@ static void test_mem_overun()
rc= mysql_query(mysql, "select * from t_mem_overun"); rc= mysql_query(mysql, "select * from t_mem_overun");
myquery(rc); myquery(rc);
assert(1 == my_process_result(mysql)); rc= my_process_result(mysql);
DIE_UNLESS(rc == 1);
stmt= mysql_simple_prepare(mysql, "select * from t_mem_overun"); stmt= mysql_simple_prepare(mysql, "select * from t_mem_overun");
check_stmt(stmt); check_stmt(stmt);
...@@ -7643,7 +7737,7 @@ static void test_mem_overun() ...@@ -7643,7 +7737,7 @@ static void test_mem_overun()
mytest(field_res); mytest(field_res);
fprintf(stdout, "\n total fields : %d", mysql_num_fields(field_res)); fprintf(stdout, "\n total fields : %d", mysql_num_fields(field_res));
assert( 1000 == mysql_num_fields(field_res)); DIE_UNLESS( 1000 == mysql_num_fields(field_res));
rc= mysql_stmt_store_result(stmt); rc= mysql_stmt_store_result(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
...@@ -7652,7 +7746,7 @@ static void test_mem_overun() ...@@ -7652,7 +7746,7 @@ static void test_mem_overun()
check_execute(stmt, rc); check_execute(stmt, rc);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_free_result(field_res); mysql_free_result(field_res);
...@@ -7710,7 +7804,7 @@ static void test_free_result() ...@@ -7710,7 +7804,7 @@ static void test_free_result()
rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); rc= mysql_stmt_fetch_column(stmt, bind, 0, 0);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n col 0: %s(%ld)", c2, l2); fprintf(stdout, "\n col 0: %s(%ld)", c2, l2);
assert(strncmp(c2, "1", 1) == 0 && l2 == 1); DIE_UNLESS(strncmp(c2, "1", 1) == 0 && l2 == 1);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
...@@ -7725,7 +7819,7 @@ static void test_free_result() ...@@ -7725,7 +7819,7 @@ static void test_free_result()
rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); rc= mysql_stmt_fetch_column(stmt, bind, 0, 0);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); fprintf(stdout, "\n col 0: %d(%ld)", c1, l2);
assert(c1 == 2 && l2 == 4); DIE_UNLESS(c1 == 2 && l2 == 4);
rc= mysql_query(mysql, "drop table test_free_result"); rc= mysql_query(mysql, "drop table test_free_result");
myquery_r(rc); /* error should be, COMMANDS OUT OF SYNC */ myquery_r(rc); /* error should be, COMMANDS OUT OF SYNC */
...@@ -7792,7 +7886,7 @@ static void test_free_store_result() ...@@ -7792,7 +7886,7 @@ static void test_free_store_result()
rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); rc= mysql_stmt_fetch_column(stmt, bind, 0, 0);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2);
assert(strncmp(c2, "1", 1) == 0 && l2 == 1); DIE_UNLESS(strncmp(c2, "1", 1) == 0 && l2 == 1);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
...@@ -7807,7 +7901,7 @@ static void test_free_store_result() ...@@ -7807,7 +7901,7 @@ static void test_free_store_result()
rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); rc= mysql_stmt_fetch_column(stmt, bind, 0, 0);
check_execute(stmt, rc); check_execute(stmt, rc);
fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); fprintf(stdout, "\n col 0: %d(%ld)", c1, l2);
assert(c1 == 2 && l2 == 4); DIE_UNLESS(c1 == 2 && l2 == 4);
rc= mysql_stmt_free_result(stmt); rc= mysql_stmt_free_result(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
...@@ -7916,7 +8010,7 @@ static void test_sqlmode() ...@@ -7916,7 +8010,7 @@ static void test_sqlmode()
check_execute(stmt, rc); check_execute(stmt, rc);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
fprintf(stdout, "\n returned 1 row\n"); fprintf(stdout, "\n returned 1 row\n");
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -7939,7 +8033,7 @@ static void test_sqlmode() ...@@ -7939,7 +8033,7 @@ static void test_sqlmode()
check_execute(stmt, rc); check_execute(stmt, rc);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
fprintf(stdout, "\n returned 1 row"); fprintf(stdout, "\n returned 1 row");
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -8019,7 +8113,8 @@ static void test_ts() ...@@ -8019,7 +8113,8 @@ static void test_ts()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(2 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 2);
field_count= mysql_num_fields(prep_res); field_count= mysql_num_fields(prep_res);
mysql_free_result(prep_res); mysql_free_result(prep_res);
...@@ -8045,7 +8140,7 @@ static void test_ts() ...@@ -8045,7 +8140,7 @@ static void test_ts()
row_count++; row_count++;
fprintf(stdout, "\n returned '%d' rows", row_count); fprintf(stdout, "\n returned '%d' rows", row_count);
assert(row_count == 2); DIE_UNLESS(row_count == 2);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
} }
...@@ -8097,7 +8192,8 @@ static void test_bug1500() ...@@ -8097,7 +8192,8 @@ static void test_bug1500()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(1 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -8133,7 +8229,8 @@ static void test_bug1500() ...@@ -8133,7 +8229,8 @@ static void test_bug1500()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(1 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
/* /*
FIXME If we comment out next string server will crash too :( FIXME If we comment out next string server will crash too :(
...@@ -8159,7 +8256,8 @@ static void test_bug1500() ...@@ -8159,7 +8256,8 @@ static void test_bug1500()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(1 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -8182,7 +8280,7 @@ static void test_bug1946() ...@@ -8182,7 +8280,7 @@ static void test_bug1946()
stmt= mysql_simple_prepare(mysql, query); stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt); check_stmt(stmt);
rc= mysql_real_query(mysql, query, strlen(query)); rc= mysql_real_query(mysql, query, strlen(query));
assert(rc != 0); DIE_UNLESS(rc != 0);
fprintf(stdout, "Got error (as expected):\n"); fprintf(stdout, "Got error (as expected):\n");
myerror(NULL); myerror(NULL);
...@@ -8200,18 +8298,19 @@ static void test_parse_error_and_bad_length() ...@@ -8200,18 +8298,19 @@ static void test_parse_error_and_bad_length()
myheader("test_parse_error_and_bad_length"); myheader("test_parse_error_and_bad_length");
rc= mysql_query(mysql, "SHOW DATABAAAA"); rc= mysql_query(mysql, "SHOW DATABAAAA");
assert(rc); DIE_UNLESS(rc);
fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql));
rc= mysql_real_query(mysql, "SHOW DATABASES", 100); rc= mysql_real_query(mysql, "SHOW DATABASES", 100);
assert(rc); DIE_UNLESS(rc);
fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql));
stmt= mysql_simple_prepare(mysql, "SHOW DATABAAAA"); stmt= mysql_simple_prepare(mysql, "SHOW DATABAAAA");
assert(!stmt); DIE_UNLESS(!stmt);
fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql));
stmt= mysql_stmt_init(mysql); stmt= mysql_stmt_init(mysql);
assert(stmt); DIE_UNLESS(stmt);
assert(mysql_stmt_prepare(stmt, "SHOW DATABASES", 100) != 0); rc= mysql_stmt_prepare(stmt, "SHOW DATABASES", 100);
DIE_UNLESS(rc != 0);
fprintf(stdout, "Got error (as expected): '%s'\n", mysql_stmt_error(stmt)); fprintf(stdout, "Got error (as expected): '%s'\n", mysql_stmt_error(stmt));
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -8250,7 +8349,7 @@ static void test_bug2247() ...@@ -8250,7 +8349,7 @@ static void test_bug2247()
check_execute(stmt, rc); check_execute(stmt, rc);
} }
exp_count= mysql_stmt_affected_rows(stmt); exp_count= mysql_stmt_affected_rows(stmt);
assert(exp_count == 1); DIE_UNLESS(exp_count == 1);
rc= mysql_query(mysql, select); rc= mysql_query(mysql, select);
myquery(rc); myquery(rc);
...@@ -8262,13 +8361,13 @@ static void test_bug2247() ...@@ -8262,13 +8361,13 @@ static void test_bug2247()
res= mysql_store_result(mysql); res= mysql_store_result(mysql);
mytest(res); mytest(res);
assert(mysql_affected_rows(mysql) == NUM_ROWS); DIE_UNLESS(mysql_affected_rows(mysql) == NUM_ROWS);
assert(exp_count == mysql_stmt_affected_rows(stmt)); DIE_UNLESS(exp_count == mysql_stmt_affected_rows(stmt));
rc= mysql_query(mysql, update); rc= mysql_query(mysql, update);
myquery(rc); myquery(rc);
assert(mysql_affected_rows(mysql) == NUM_ROWS); DIE_UNLESS(mysql_affected_rows(mysql) == NUM_ROWS);
assert(exp_count == mysql_stmt_affected_rows(stmt)); DIE_UNLESS(exp_count == mysql_stmt_affected_rows(stmt));
mysql_free_result(res); mysql_free_result(res);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -8282,12 +8381,12 @@ static void test_bug2247() ...@@ -8282,12 +8381,12 @@ static void test_bug2247()
rc= mysql_stmt_store_result(stmt); rc= mysql_stmt_store_result(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
exp_count= mysql_stmt_affected_rows(stmt); exp_count= mysql_stmt_affected_rows(stmt);
assert(exp_count == NUM_ROWS); DIE_UNLESS(exp_count == NUM_ROWS);
rc= mysql_query(mysql, insert); rc= mysql_query(mysql, insert);
myquery(rc); myquery(rc);
assert(mysql_affected_rows(mysql) == 1); DIE_UNLESS(mysql_affected_rows(mysql) == 1);
assert(mysql_stmt_affected_rows(stmt) == exp_count); DIE_UNLESS(mysql_stmt_affected_rows(stmt) == exp_count);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
fprintf(stdout, "OK"); fprintf(stdout, "OK");
...@@ -8321,7 +8420,8 @@ static void test_subqueries() ...@@ -8321,7 +8420,8 @@ static void test_subqueries()
{ {
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(5 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 5);
} }
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -8338,7 +8438,7 @@ static void test_bad_union() ...@@ -8338,7 +8438,7 @@ static void test_bad_union()
myheader("test_bad_union"); myheader("test_bad_union");
stmt= mysql_simple_prepare(mysql, query); stmt= mysql_simple_prepare(mysql, query);
assert(stmt == 0); DIE_UNLESS(stmt == 0);
myerror(NULL); myerror(NULL);
} }
...@@ -8369,7 +8469,8 @@ static void test_distinct() ...@@ -8369,7 +8469,8 @@ static void test_distinct()
check_stmt(stmt); check_stmt(stmt);
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(5 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 5);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -8418,7 +8519,7 @@ static void test_bug2248() ...@@ -8418,7 +8519,7 @@ static void test_bug2248()
/* This too should not hang but should return proper error */ /* This too should not hang but should return proper error */
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
/* This too should not hang but should not bark */ /* This too should not hang but should not bark */
rc= mysql_stmt_store_result(stmt); rc= mysql_stmt_store_result(stmt);
...@@ -8427,7 +8528,7 @@ static void test_bug2248() ...@@ -8427,7 +8528,7 @@ static void test_bug2248()
/* This should return proper error */ /* This should return proper error */
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute_r(stmt, rc); check_execute_r(stmt, rc);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -8460,7 +8561,8 @@ static void test_subqueries_ref() ...@@ -8460,7 +8561,8 @@ static void test_subqueries_ref()
{ {
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(1 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
} }
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -8513,7 +8615,8 @@ static void test_union() ...@@ -8513,7 +8615,8 @@ static void test_union()
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(20 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 20);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
rc= mysql_query(mysql, "DROP TABLE t1, t2"); rc= mysql_query(mysql, "DROP TABLE t1, t2");
...@@ -8563,7 +8666,7 @@ static void test_bug3117() ...@@ -8563,7 +8666,7 @@ static void test_bug3117()
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(is_null == 0 && lii == 1); DIE_UNLESS(is_null == 0 && lii == 1);
fprintf(stdout, "\n\tLAST_INSERT_ID()= 1 ok\n"); fprintf(stdout, "\n\tLAST_INSERT_ID()= 1 ok\n");
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (NULL)"); rc= mysql_query(mysql, "INSERT INTO t1 VALUES (NULL)");
...@@ -8575,7 +8678,7 @@ static void test_bug3117() ...@@ -8575,7 +8678,7 @@ static void test_bug3117()
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(is_null == 0 && lii == 2); DIE_UNLESS(is_null == 0 && lii == 2);
fprintf(stdout, "\tLAST_INSERT_ID()= 2 ok\n"); fprintf(stdout, "\tLAST_INSERT_ID()= 2 ok\n");
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -8626,7 +8729,8 @@ static void test_join() ...@@ -8626,7 +8729,8 @@ static void test_join()
{ {
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(5 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 5);
} }
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -8673,7 +8777,8 @@ static void test_selecttmp() ...@@ -8673,7 +8777,8 @@ static void test_selecttmp()
{ {
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(3 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 3);
} }
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -8728,7 +8833,8 @@ static void test_create_drop() ...@@ -8728,7 +8833,8 @@ static void test_create_drop()
rc= mysql_stmt_execute(stmt_select); rc= mysql_stmt_execute(stmt_select);
check_execute(stmt_select, rc); check_execute(stmt_select, rc);
assert(0 == my_process_stmt_result(stmt_select)); rc= my_process_stmt_result(stmt_select);
DIE_UNLESS(rc == 0);
rc= mysql_stmt_execute(stmt_drop); rc= mysql_stmt_execute(stmt_drop);
check_execute(stmt_drop, rc); check_execute(stmt_drop, rc);
...@@ -8740,7 +8846,8 @@ static void test_create_drop() ...@@ -8740,7 +8846,8 @@ static void test_create_drop()
rc= mysql_stmt_execute(stmt_select); rc= mysql_stmt_execute(stmt_select);
check_execute(stmt_select, rc); check_execute(stmt_select, rc);
assert(3 == my_process_stmt_result(stmt_select)); rc= my_process_stmt_result(stmt_select);
DIE_UNLESS(rc == 3);
rc= mysql_stmt_execute(stmt_drop); rc= mysql_stmt_execute(stmt_drop);
check_execute(stmt_drop, rc); check_execute(stmt_drop, rc);
...@@ -8904,11 +9011,13 @@ static void test_multi() ...@@ -8904,11 +9011,13 @@ static void test_multi()
rc= mysql_stmt_execute(stmt_select1); rc= mysql_stmt_execute(stmt_select1);
check_execute(stmt_select1, rc); check_execute(stmt_select1, rc);
assert((uint)(3-param) == my_process_stmt_result(stmt_select1)); rc= my_process_stmt_result(stmt_select1);
DIE_UNLESS(rc == 3-param);
rc= mysql_stmt_execute(stmt_select2); rc= mysql_stmt_execute(stmt_select2);
check_execute(stmt_select2, rc); check_execute(stmt_select2, rc);
assert((uint)(3-param) == my_process_stmt_result(stmt_select2)); rc= my_process_stmt_result(stmt_select2);
DIE_UNLESS(rc == 3-param);
param++; param++;
} }
...@@ -8958,7 +9067,8 @@ static void test_insert_select() ...@@ -8958,7 +9067,8 @@ static void test_insert_select()
rc= mysql_stmt_execute(stmt_select); rc= mysql_stmt_execute(stmt_select);
check_execute(stmt_select, rc); check_execute(stmt_select, rc);
assert((i+1) == my_process_stmt_result(stmt_select)); rc= my_process_stmt_result(stmt_select);
DIE_UNLESS(rc == (int)(i+1));
} }
mysql_stmt_close(stmt_insert); mysql_stmt_close(stmt_insert);
...@@ -9056,7 +9166,8 @@ TYPE=InnoDB DEFAULT CHARSET=utf8"); ...@@ -9056,7 +9166,8 @@ TYPE=InnoDB DEFAULT CHARSET=utf8");
{ {
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(1 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
} }
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -9108,7 +9219,8 @@ static void test_xjoin() ...@@ -9108,7 +9219,8 @@ static void test_xjoin()
{ {
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(1 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
} }
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -9265,37 +9377,37 @@ static void test_bug3035() ...@@ -9265,37 +9377,37 @@ static void test_bug3035()
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(int8_val == int8_min); DIE_UNLESS(int8_val == int8_min);
assert(uint8_val == uint8_min); DIE_UNLESS(uint8_val == uint8_min);
assert(int16_val == int16_min); DIE_UNLESS(int16_val == int16_min);
assert(uint16_val == uint16_min); DIE_UNLESS(uint16_val == uint16_min);
assert(int32_val == int32_min); DIE_UNLESS(int32_val == int32_min);
assert(uint32_val == uint32_min); DIE_UNLESS(uint32_val == uint32_min);
assert(int64_val == int64_min); DIE_UNLESS(int64_val == int64_min);
assert(uint64_val == uint64_min); DIE_UNLESS(uint64_val == uint64_min);
assert(double_val == (longlong) uint64_min); DIE_UNLESS(double_val == (longlong) uint64_min);
assert(udouble_val == ulonglong2double(uint64_val)); DIE_UNLESS(udouble_val == ulonglong2double(uint64_val));
assert(!strcmp(longlong_as_string, "0")); DIE_UNLESS(!strcmp(longlong_as_string, "0"));
assert(!strcmp(ulonglong_as_string, "0")); DIE_UNLESS(!strcmp(ulonglong_as_string, "0"));
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(int8_val == int8_max); DIE_UNLESS(int8_val == int8_max);
assert(uint8_val == uint8_max); DIE_UNLESS(uint8_val == uint8_max);
assert(int16_val == int16_max); DIE_UNLESS(int16_val == int16_max);
assert(uint16_val == uint16_max); DIE_UNLESS(uint16_val == uint16_max);
assert(int32_val == int32_max); DIE_UNLESS(int32_val == int32_max);
assert(uint32_val == uint32_max); DIE_UNLESS(uint32_val == uint32_max);
assert(int64_val == int64_max); DIE_UNLESS(int64_val == int64_max);
assert(uint64_val == uint64_max); DIE_UNLESS(uint64_val == uint64_max);
assert(double_val == (longlong) uint64_val); DIE_UNLESS(double_val == (longlong) uint64_val);
assert(udouble_val == ulonglong2double(uint64_val)); DIE_UNLESS(udouble_val == ulonglong2double(uint64_val));
assert(!strcmp(longlong_as_string, "-1")); DIE_UNLESS(!strcmp(longlong_as_string, "-1"));
assert(!strcmp(ulonglong_as_string, "18446744073709551615")); DIE_UNLESS(!strcmp(ulonglong_as_string, "18446744073709551615"));
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -9329,7 +9441,8 @@ static void test_union2() ...@@ -9329,7 +9441,8 @@ static void test_union2()
{ {
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(0 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 0);
} }
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -9562,7 +9675,8 @@ static void test_union_param() ...@@ -9562,7 +9675,8 @@ static void test_union_param()
{ {
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(1 == my_process_stmt_result(stmt)); rc= my_process_stmt_result(stmt);
DIE_UNLESS(rc == 1);
} }
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -9653,13 +9767,13 @@ static void test_ps_i18n() ...@@ -9653,13 +9767,13 @@ static void test_ps_i18n()
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
assert(buf1_len == strlen(cp1251)); DIE_UNLESS(buf1_len == strlen(cp1251));
assert(buf2_len == strlen(cp1251)); DIE_UNLESS(buf2_len == strlen(cp1251));
assert(!memcmp(buf1, cp1251, buf1_len)); DIE_UNLESS(!memcmp(buf1, cp1251, buf1_len));
assert(!memcmp(buf2, cp1251, buf1_len)); DIE_UNLESS(!memcmp(buf2, cp1251, buf1_len));
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
stmt_text= "DROP TABLE IF EXISTS t1"; stmt_text= "DROP TABLE IF EXISTS t1";
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
...@@ -9738,12 +9852,12 @@ static void test_ps_i18n() ...@@ -9738,12 +9852,12 @@ static void test_ps_i18n()
while ((rc= mysql_stmt_fetch(stmt)) == 0) while ((rc= mysql_stmt_fetch(stmt)) == 0)
{ {
assert(buf1_len == strlen(koi8)); DIE_UNLESS(buf1_len == strlen(koi8));
assert(buf2_len == strlen(koi8)); DIE_UNLESS(buf2_len == strlen(koi8));
assert(!memcmp(buf1, koi8, buf1_len)); DIE_UNLESS(!memcmp(buf1, koi8, buf1_len));
assert(!memcmp(buf2, koi8, buf1_len)); DIE_UNLESS(!memcmp(buf2, koi8, buf1_len));
} }
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
stmt_text= "DROP TABLE t1"; stmt_text= "DROP TABLE t1";
...@@ -9813,18 +9927,18 @@ static void test_bug3796() ...@@ -9813,18 +9927,18 @@ static void test_bug3796()
check_execute(stmt, rc); check_execute(stmt, rc);
strcpy(canonical_buff, concat_arg0); strcpy(canonical_buff, concat_arg0);
strcat(canonical_buff, "ONE"); strcat(canonical_buff, "ONE");
assert(strlen(canonical_buff) == out_length && DIE_UNLESS(strlen(canonical_buff) == out_length &&
strncmp(out_buff, canonical_buff, out_length) == 0); strncmp(out_buff, canonical_buff, out_length) == 0);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc); check_execute(stmt, rc);
strcpy(canonical_buff + strlen(concat_arg0), "TWO"); strcpy(canonical_buff + strlen(concat_arg0), "TWO");
assert(strlen(canonical_buff) == out_length && DIE_UNLESS(strlen(canonical_buff) == out_length &&
strncmp(out_buff, canonical_buff, out_length) == 0); strncmp(out_buff, canonical_buff, out_length) == 0);
printf("Concat result: '%s'\n", out_buff); printf("Concat result: '%s'\n", out_buff);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
...@@ -9871,7 +9985,7 @@ static void test_bug4026() ...@@ -9871,7 +9985,7 @@ static void test_bug4026()
time_in.second= 59; time_in.second= 59;
time_in.second_part= 123456; time_in.second_part= 123456;
/* /*
This is not necessary, just to make assert below work: this field This is not necessary, just to make DIE_UNLESS below work: this field
is filled in when time is received from server is filled in when time is received from server
*/ */
time_in.time_type= MYSQL_TIMESTAMP_TIME; time_in.time_type= MYSQL_TIMESTAMP_TIME;
...@@ -9894,15 +10008,15 @@ static void test_bug4026() ...@@ -9894,15 +10008,15 @@ static void test_bug4026()
mysql_stmt_bind_result(stmt, bind); mysql_stmt_bind_result(stmt, bind);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == 0); DIE_UNLESS(rc == 0);
printf("%d:%d:%d.%lu\n", time_out.hour, time_out.minute, time_out.second, printf("%d:%d:%d.%lu\n", time_out.hour, time_out.minute, time_out.second,
time_out.second_part); time_out.second_part);
printf("%d-%d-%d %d:%d:%d.%lu\n", datetime_out.year, datetime_out.month, printf("%d-%d-%d %d:%d:%d.%lu\n", datetime_out.year, datetime_out.month,
datetime_out.day, datetime_out.hour, datetime_out.day, datetime_out.hour,
datetime_out.minute, datetime_out.second, datetime_out.minute, datetime_out.second,
datetime_out.second_part); datetime_out.second_part);
assert(memcmp(&time_in, &time_out, sizeof(time_in)) == 0); DIE_UNLESS(memcmp(&time_in, &time_out, sizeof(time_in)) == 0);
assert(memcmp(&datetime_in, &datetime_out, sizeof(datetime_in)) == 0); DIE_UNLESS(memcmp(&datetime_in, &datetime_out, sizeof(datetime_in)) == 0);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -9942,7 +10056,7 @@ static void test_bug4079() ...@@ -9942,7 +10056,7 @@ static void test_bug4079()
mysql_stmt_bind_result(stmt, bind); mysql_stmt_bind_result(stmt, bind);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc != 0 && rc != MYSQL_NO_DATA); DIE_UNLESS(rc != 0 && rc != MYSQL_NO_DATA);
printf("Got error from mysql_stmt_fetch (as expected):\n%s\n", printf("Got error from mysql_stmt_fetch (as expected):\n%s\n",
mysql_stmt_error(stmt)); mysql_stmt_error(stmt));
/* buggy version of libmysql hanged up here */ /* buggy version of libmysql hanged up here */
...@@ -9970,7 +10084,7 @@ static void test_bug4236() ...@@ -9970,7 +10084,7 @@ static void test_bug4236()
backup.stmt_id= stmt->stmt_id; backup.stmt_id= stmt->stmt_id;
stmt->stmt_id= 0; stmt->stmt_id= 0;
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
assert(rc); DIE_UNLESS(rc);
/* Restore original statement id to be able to reprepare it */ /* Restore original statement id to be able to reprepare it */
stmt->stmt_id= backup.stmt_id; stmt->stmt_id= backup.stmt_id;
...@@ -10037,7 +10151,7 @@ static void test_bug4030() ...@@ -10037,7 +10151,7 @@ static void test_bug4030()
mysql_stmt_bind_result(stmt, bind); mysql_stmt_bind_result(stmt, bind);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == 0); DIE_UNLESS(rc == 0);
printf("%d:%d:%d.%lu\n", time_out.hour, time_out.minute, time_out.second, printf("%d:%d:%d.%lu\n", time_out.hour, time_out.minute, time_out.second,
time_out.second_part); time_out.second_part);
printf("%d-%d-%d\n", date_out.year, date_out.month, date_out.day); printf("%d-%d-%d\n", date_out.year, date_out.month, date_out.day);
...@@ -10045,9 +10159,9 @@ static void test_bug4030() ...@@ -10045,9 +10159,9 @@ static void test_bug4030()
datetime_out.day, datetime_out.hour, datetime_out.day, datetime_out.hour,
datetime_out.minute, datetime_out.second, datetime_out.minute, datetime_out.second,
datetime_out.second_part); datetime_out.second_part);
assert(memcmp(&time_canonical, &time_out, sizeof(time_out)) == 0); DIE_UNLESS(memcmp(&time_canonical, &time_out, sizeof(time_out)) == 0);
assert(memcmp(&date_canonical, &date_out, sizeof(date_out)) == 0); DIE_UNLESS(memcmp(&date_canonical, &date_out, sizeof(date_out)) == 0);
assert(memcmp(&datetime_canonical, &datetime_out, sizeof(datetime_out)) == 0); DIE_UNLESS(memcmp(&datetime_canonical, &datetime_out, sizeof(datetime_out)) == 0);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -10092,8 +10206,8 @@ static void test_bug5126() ...@@ -10092,8 +10206,8 @@ static void test_bug5126()
mysql_stmt_bind_result(stmt, bind); mysql_stmt_bind_result(stmt, bind);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
assert(rc == 0); DIE_UNLESS(rc == 0);
assert(c1 == 8386608 && c2 == 1); DIE_UNLESS(c1 == 8386608 && c2 == 1);
printf("%ld, %ld\n", (long) c1, (long) c2); printf("%ld, %ld\n", (long) c1, (long) c2);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
...@@ -10156,14 +10270,14 @@ static void test_bug4231() ...@@ -10156,14 +10270,14 @@ static void test_bug4231()
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
/* binds are unequal, no rows should be returned */ /* binds are unequal, no rows should be returned */
DBUG_ASSERT(rc == MYSQL_NO_DATA); DIE_UNLESS(rc == MYSQL_NO_DATA);
/* Set one of the dates to zero */ /* Set one of the dates to zero */
tm[0].year= tm[0].month= tm[0].day= 0; tm[0].year= tm[0].month= tm[0].day= 0;
tm[1]= tm[0]; tm[1]= tm[0];
mysql_stmt_execute(stmt); mysql_stmt_execute(stmt);
rc= mysql_stmt_fetch(stmt); rc= mysql_stmt_fetch(stmt);
DBUG_ASSERT(rc == 0); DIE_UNLESS(rc == 0);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
stmt_text= "DROP TABLE t1"; stmt_text= "DROP TABLE t1";
...@@ -10208,8 +10322,8 @@ static void test_bug5399() ...@@ -10208,8 +10322,8 @@ static void test_bug5399()
rc= mysql_stmt_store_result(stmt[i]); rc= mysql_stmt_store_result(stmt[i]);
check_execute(stmt[i], rc); check_execute(stmt[i], rc);
rc= mysql_stmt_fetch(stmt[i]); rc= mysql_stmt_fetch(stmt[i]);
assert(rc == 0); DIE_UNLESS(rc == 0);
assert((int32) i == no); DIE_UNLESS((int32) i == no);
} }
for (i= 0; i < NUM_OF_USED_STMT; ++i) for (i= 0; i < NUM_OF_USED_STMT; ++i)
...@@ -10410,19 +10524,19 @@ static void test_bug5315() ...@@ -10410,19 +10524,19 @@ static void test_bug5315()
stmt_text= "SELECT 1"; stmt_text= "SELECT 1";
stmt= mysql_stmt_init(mysql); stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
DBUG_ASSERT(rc == 0); DIE_UNLESS(rc == 0);
mysql_change_user(mysql, opt_user, opt_password, current_db); mysql_change_user(mysql, opt_user, opt_password, current_db);
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
DBUG_ASSERT(rc != 0); DIE_UNLESS(rc != 0);
if (rc) if (rc)
printf("Got error (as expected):\n%s", mysql_stmt_error(stmt)); printf("Got error (as expected):\n%s", mysql_stmt_error(stmt));
/* check that connection is OK */ /* check that connection is OK */
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
stmt= mysql_stmt_init(mysql); stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
DBUG_ASSERT(rc == 0); DIE_UNLESS(rc == 0);
rc= mysql_stmt_execute(stmt); rc= mysql_stmt_execute(stmt);
DBUG_ASSERT(rc == 0); DIE_UNLESS(rc == 0);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment