diff options
author | unknown <tomas@mc05.(none)> | 2004-06-07 17:58:35 +0200 |
---|---|---|
committer | unknown <tomas@mc05.(none)> | 2004-06-07 17:58:35 +0200 |
commit | 86ab1dd2d6d6c0c72d27b85d9fbd15675bfddd28 (patch) | |
tree | 16b898bcf02bcc594ecc879f4e2d48e7ca5c7066 | |
parent | 7942677020d36bd5baafd8d765968921f348cdc2 (diff) | |
parent | a3426dd8abec62feeef3dbbbca4520480b0feb2b (diff) | |
download | mariadb-git-86ab1dd2d6d6c0c72d27b85d9fbd15675bfddd28.tar.gz |
Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1
into mc05.(none):/space2/tomas/mysql-4.1
acconfig.h:
Auto merged
configure.in:
Auto merged
77 files changed, 7869 insertions, 3699 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index d55a451a1ba..e419f9edfb9 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -26,6 +26,7 @@ bell@laptop.sanja.is.com.ua bell@sanja.is.com.ua bk@admin.bk bk@mysql.r18.ru +brian@avenger.(none) brian@brian-akers-computer.local carsten@tsort.bitbybit.dk davida@isil.mysql.com diff --git a/acconfig.h b/acconfig.h index db2a1a8755d..964e0018d86 100644 --- a/acconfig.h +++ b/acconfig.h @@ -115,6 +115,9 @@ /* Builds Example DB */ #undef HAVE_EXAMPLE_DB +/* Builds Archive Storage Engine */ +#undef HAVE_ARCHIVE_DB + /* fp_except from ieeefp.h */ #undef HAVE_FP_EXCEPT diff --git a/acinclude.m4 b/acinclude.m4 index 612a4d1a918..baad145c0e0 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1333,6 +1333,36 @@ dnl END OF MYSQL_CHECK_EXAMPLE SECTION dnl --------------------------------------------------------------------------- dnl --------------------------------------------------------------------------- +dnl Macro: MYSQL_CHECK_ARCHIVEDB +dnl Sets HAVE_ARCHIVE_DB if --with-archive-storage-engine is used +dnl --------------------------------------------------------------------------- +AC_DEFUN([MYSQL_CHECK_ARCHIVEDB], [ + AC_ARG_WITH([archive-storage-engine], + [ + --with-archive-storage-engine + Enable the Archive Storge Engine], + [archivedb="$withval"], + [archivedb=no]) + AC_MSG_CHECKING([for archive storage engine]) + + case "$archivedb" in + yes ) + AC_DEFINE(HAVE_ARCHIVE_DB) + AC_MSG_RESULT([yes]) + [archivedb=yes] + ;; + * ) + AC_MSG_RESULT([no]) + [archivedb=no] + ;; + esac + +]) +dnl --------------------------------------------------------------------------- +dnl END OF MYSQL_CHECK_ARCHIVE SECTION +dnl --------------------------------------------------------------------------- + +dnl --------------------------------------------------------------------------- dnl Macro: MYSQL_CHECK_NDBCLUSTER dnl Sets HAVE_NDBCLUSTER_DB if --with-ndbcluster is used dnl --------------------------------------------------------------------------- diff --git a/client/mysqldump.c b/client/mysqldump.c index 2b40264325f..9c64e2d1b3a 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -394,7 +394,11 @@ static void write_header(FILE *sql_file, char *db_name) mysql_get_server_info(&mysql_connection)); } if (opt_set_charset) - fprintf(sql_file,"\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT, CHARACTER_SET_CLIENT=%s */;\n",default_charset); + fprintf(sql_file, +"\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;" +"\n/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;" +"\n/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;" +"\n/*!40101 SET NAMES %s */;\n",default_charset); if (!path) { fprintf(md_result_file,"\ @@ -425,7 +429,9 @@ static void write_footer(FILE *sql_file) } if (opt_set_charset) fprintf(sql_file, - "/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n"); +"/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n" +"/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\n" +"/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\n"); fputs("\n", sql_file); } } /* write_footer */ diff --git a/configure.in b/configure.in index f53aadf0bf7..be40d8ff029 100644 --- a/configure.in +++ b/configure.in @@ -2677,6 +2677,7 @@ MYSQL_CHECK_ISAM MYSQL_CHECK_BDB MYSQL_CHECK_INNODB MYSQL_CHECK_EXAMPLEDB +MYSQL_CHECK_ARCHIVEDB MYSQL_CHECK_NDBCLUSTER # If we have threads generate some library functions and test programs diff --git a/extra/perror.c b/extra/perror.c index a31889cc26d..26ebdd5b096 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -197,7 +197,7 @@ int main(int argc,char *argv[]) for (code=1 ; code < sys_nerr ; code++) { if (sys_errlist[code][0]) - { /* Skipp if no error-text */ + { /* Skip if no error-text */ printf("%3d = %s\n",code,sys_errlist[code]); } } diff --git a/heap/hp_hash.c b/heap/hp_hash.c index 38ed581fe58..1f36f9b3059 100644 --- a/heap/hp_hash.c +++ b/heap/hp_hash.c @@ -236,7 +236,7 @@ ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) key+=seg->length; if (seg->null_bit) { - key++; /* Skipp null byte */ + key++; /* Skip null byte */ if (*pos) /* Found null */ { nr^= (nr << 1) | 1; diff --git a/include/mysql.h b/include/mysql.h index e2d0acd7839..71bff833d59 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -77,7 +77,6 @@ extern char *mysql_unix_port; #define IS_NUM_FIELD(f) ((f)->flags & NUM_FLAG) #define INTERNAL_NUM_FIELD(f) (((f)->type <= FIELD_TYPE_INT24 && ((f)->type != FIELD_TYPE_TIMESTAMP || (f)->length == 14 || (f)->length == 8)) || (f)->type == FIELD_TYPE_YEAR) -#define HAVE_DEPRECATED_411_API 1 typedef struct st_mysql_field { char *name; /* Name of column */ @@ -711,6 +710,7 @@ void STDCALL mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong offset); my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt); my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt); my_ulonglong STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt); +unsigned int STDCALL mysql_stmt_field_count(MYSQL_STMT *stmt); my_bool STDCALL mysql_commit(MYSQL * mysql); my_bool STDCALL mysql_rollback(MYSQL * mysql); diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 57e9690d990..469e7c025b6 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -733,7 +733,7 @@ os_file_create_directory( if (!(rcode != 0 || (GetLastError() == ERROR_FILE_EXISTS && !fail_if_exists))) { /* failure */ - os_file_handle_error(Npathname, "CreateDirectory"); + os_file_handle_error(pathname, "CreateDirectory"); return(FALSE); } diff --git a/isam/_dynrec.c b/isam/_dynrec.c index d17d34e6778..25fe01e23f2 100644 --- a/isam/_dynrec.c +++ b/isam/_dynrec.c @@ -430,7 +430,7 @@ uint _nisam_rec_pack(N_INFO *info, register byte *to, register const byte *from) to+=length+blob->length; } blob++; - from+=sizeof(char*); /* Skipp blob-pointer */ + from+=sizeof(char*); /* Skip blob-pointer */ } else if (type == FIELD_SKIP_ZERO) { @@ -633,7 +633,7 @@ uint _nisam_rec_unpack(register N_INFO *info, register byte *to, byte *from, if ((type = (enum en_fieldtype) rec->base.type) != FIELD_NORMAL) { if (type == FIELD_ZERO) - continue; /* Skipp this */ + continue; /* Skip this */ if (flag & bit) { if (type == FIELD_BLOB) @@ -747,7 +747,7 @@ uint _calc_blob_length(uint length, const byte *pos) return (uint) (unsigned short) j; } #ifdef MSDOS - break; /* skipp microsoft warning */ + break; /* skip microsoft warning */ #endif case 3: return uint3korr(pos); diff --git a/isam/isamchk.c b/isam/isamchk.c index cccd7cf4127..5dd20c14063 100644 --- a/isam/isamchk.c +++ b/isam/isamchk.c @@ -858,7 +858,7 @@ static int chk_size(register N_INFO *info) #endif if (skr != size) { - info->s->state.data_file_length=(ulong) size; /* Skipp other errors */ + info->s->state.data_file_length=(ulong) size; /* Skip other errors */ if (skr > size && skr != size + MEMMAP_EXTRA_MARGIN) { error=1; @@ -2672,7 +2672,7 @@ static int sort_get_next_record() goto try_next; block_info.second_read=0; searching=1; - for (i=1 ; i < 11 ; i++) /* Skipp from read string */ + for (i=1 ; i < 11 ; i++) /* Skip from read string */ if (block_info.header[i] >= 1 && block_info.header[i] <= 16) break; pos+=(ulong) i; diff --git a/isam/isamlog.c b/isam/isamlog.c index 75a35ef9704..5cc204b26aa 100644 --- a/isam/isamlog.c +++ b/isam/isamlog.c @@ -144,7 +144,7 @@ static void get_options(register int *argc, register char ***argv) switch((option=*pos)) { case '#': DBUG_PUSH (++pos); - pos=" "; /* Skipp rest of arg */ + pos=" "; /* Skip rest of arg */ break; case 'c': if (! *++pos) diff --git a/isam/pack_isam.c b/isam/pack_isam.c index 9108070f918..aa83b2b2a96 100644 --- a/isam/pack_isam.c +++ b/isam/pack_isam.c @@ -28,7 +28,7 @@ #include <io.h> #endif #ifndef __GNU_LIBRARY__ -#define __GNU_LIBRARY__ /* Skipp warnings in getopt.h */ +#define __GNU_LIBRARY__ /* Skip warnings in getopt.h */ #endif #include <my_getopt.h> diff --git a/isam/test1.c b/isam/test1.c index 9ebc7af041d..b9f4d8242c3 100644 --- a/isam/test1.c +++ b/isam/test1.c @@ -136,7 +136,7 @@ int main(int argc, char *argv[]) err: printf("got error: %3d when using nisam-database\n",my_errno); exit(1); - return 0; /* skipp warning */ + return 0; /* skip warning */ } /* main */ diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index b12965a85e7..a68837df114 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1640,70 +1640,46 @@ myodbc_remove_escape(MYSQL *mysql,char *name) } /******************************************************************** + Implementation of new client API for 4.1 version. - Implementation of new client-server prototypes for 4.1 version - starts from here .. - - mysql_* are real prototypes used by applications + mysql_stmt_* are real prototypes used by applications. + To make API work in embedded library all functions performing + real I/O are prefixed with 'cli_' (abbreviated from 'Call Level + Interface'). This functions are invoked via pointers set in + MYSQL::methods structure. Embedded counterparts, prefixed with + 'emb_' reside in libmysqld/lib_sql.cc. *********************************************************************/ -/******************************************************************** - Misc Utility functions -********************************************************************/ - -/* - Set the internal stmt error messages -*/ - -static void set_stmt_error(MYSQL_STMT * stmt, int errcode, - const char *sqlstate) -{ - DBUG_ENTER("set_stmt_error"); - DBUG_PRINT("enter", ("error: %d '%s'", errcode, ER(errcode))); - DBUG_ASSERT(stmt != 0); - - stmt->last_errno= errcode; - strmov(stmt->last_error, ER(errcode)); - strmov(stmt->sqlstate, sqlstate); - - DBUG_VOID_RETURN; -} +/******************* Declarations ***********************************/ /* - Copy error message to statement handler + These functions are called by function pointer MYSQL_STMT::read_row_func. + Each function corresponds to one of the read methods: + - mysql_stmt_fetch without prior mysql_stmt_store_result, + - mysql_stmt_fetch when result is stored, + - mysql_stmt_fetch when there are no rows (always returns MYSQL_NO_DATA) */ -void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode, - const char *sqlstate) -{ - DBUG_ENTER("set_stmt_error_msg"); - DBUG_PRINT("enter", ("error: %d/%s '%s'", errcode, sqlstate, err)); - DBUG_ASSERT(stmt != 0); - - stmt->last_errno= errcode; - if (err && err[0]) - strmov(stmt->last_error, err); - strmov(stmt->sqlstate, sqlstate); - - DBUG_VOID_RETURN; -} +static int stmt_read_row_unbuffered(MYSQL_STMT *stmt, unsigned char **row); +static int stmt_read_row_buffered(MYSQL_STMT *stmt, unsigned char **row); +static int stmt_read_row_no_data(MYSQL_STMT *stmt, unsigned char **row); +/**************** Misc utility functions ****************************/ /* Reallocate the NET package to be at least of 'length' bytes SYNPOSIS my_realloc_str() - net The NET structure to modify - int length Ensure that net->buff is at least this big + net The NET structure to modify + length Ensure that net->buff is at least this big RETURN VALUES 0 ok 1 Error - */ static my_bool my_realloc_str(NET *net, ulong length) @@ -1719,20 +1695,54 @@ static my_bool my_realloc_str(NET *net, ulong length) DBUG_RETURN(res); } -/******************************************************************** - Prepare related implementations -********************************************************************/ -static int stmt_read_row_unbuffered(MYSQL_STMT *stmt, unsigned char **row); -static int stmt_read_row_buffered(MYSQL_STMT *stmt, unsigned char **row); -static int stmt_read_row_no_data(MYSQL_STMT *stmt, unsigned char **row); +/* + Set statement error code, sqlstate, and error message + from given errcode and sqlstate. +*/ + +static void set_stmt_error(MYSQL_STMT * stmt, int errcode, + const char *sqlstate) +{ + DBUG_ENTER("set_stmt_error"); + DBUG_PRINT("enter", ("error: %d '%s'", errcode, ER(errcode))); + DBUG_ASSERT(stmt != 0); + + stmt->last_errno= errcode; + strmov(stmt->last_error, ER(errcode)); + strmov(stmt->sqlstate, sqlstate); + + DBUG_VOID_RETURN; +} + + +/* + Set statement error code, sqlstate, and error message. +*/ + +void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode, + const char *sqlstate) +{ + DBUG_ENTER("set_stmt_errmsg"); + DBUG_PRINT("enter", ("error: %d/%s '%s'", errcode, sqlstate, err)); + DBUG_ASSERT(stmt != 0); + + stmt->last_errno= errcode; + if (err && err[0]) + strmov(stmt->last_error, err); + strmov(stmt->sqlstate, sqlstate); + + DBUG_VOID_RETURN; +} /* - Read the prepared statement results .. + Read and unpack server reply to COM_PREPARE command (sent from + mysql_stmt_prepare). - NOTE - This is only called for connection to servers that supports - prepared statements (and thus the 4.1 protocol) + SYNOPSIS + cli_read_prepare_result() + mysql connection handle + stmt statement handle RETURN VALUES 0 ok @@ -1752,7 +1762,9 @@ my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) pos= (uchar*) mysql->net.read_pos; stmt->stmt_id= uint4korr(pos+1); pos+= 5; + /* Number of columns in result set */ field_count= uint2korr(pos); pos+= 2; + /* Number of placeholders in the statement */ param_count= uint2korr(pos); pos+= 2; if (param_count != 0) @@ -1802,10 +1814,30 @@ MYSQL_STMT * STDCALL mysql_prepare(MYSQL *mysql, const char *query, #endif /* - Allocate memory and init prepared statement structure + Allocate memory and init prepared statement structure. + SYNOPSIS mysql_stmt_init() - mysql connection handle + mysql connection handle + + DESCRIPTION + This is an entry point of the new API. Returned handle stands for + a server-side prepared statement. Memory for this structure (~700 + bytes) is allocated using 'malloc'. Once created, the handle can be + reused many times. Created statement handle is bound to connection + handle provided to this call: it's lifetime is limited by lifetime + of connection. + 'mysql_stmt_init()' is a pure local call, server side structure is + created only in mysql_stmt_prepare. + Next steps you may want to make: + - set a statement attribute (mysql_stmt_attr_set()), + - prepare statement handle with a query (mysql_stmt_prepare()), + - close statement handle and free it's memory (mysql_stmt_close()), + - reset statement with mysql_stmt_reset() (a no-op which will + just return). + Behaviour of the rest of API calls on this statement is not defined yet + (though we're working on making each wrong call sequence return + error). RETURN VALUE statement structure upon success and NULL if out of @@ -1838,27 +1870,41 @@ mysql_stmt_init(MYSQL *mysql) DBUG_RETURN(stmt); } + /* - Prepare server side statement with query: + Prepare server side statement with query. + SYNOPSIS mysql_stmt_prepare() - query statement to prepare - length statement length + stmt statement handle + query statement to prepare + length statement length DESCRIPTION - - if this is a re-prepare of the statement, first close previous data + Associate statement with statement handle. This is done both on + client and server sides. At this point the server parses given query + and creates an internal structure to represent it. + Next steps you may want to make: + - find out if this statement returns a result set by + calling mysql_stmt_field_count(), and get result set metadata + with mysql_stmt_result_metadata(), + - if query contains placeholders, bind input parameters to placeholders + using mysql_stmt_bind_param(), + - otherwise proceed directly to mysql_stmt_execute(). + + IMPLEMENTATION NOTES + - if this is a re-prepare of the statement, first close previous data structure on the server and free old statement data - - send the query to server and get back number of placeholders, + - then send the query to server and get back number of placeholders, number of columns in result set (if any), and result set metadata. - At the same time allocate memory for input and output parameters + At the same time allocate memory for input and output parameters to have less checks in mysql_stmt_bind_{param, result}. RETURN VALUES 0 success - !0 error + !0 error */ - int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length) { @@ -1938,8 +1984,10 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length) } /* - Get the execute query meta information for non-select - statements. + Get result set metadata from reply to mysql_stmt_execute. + This is used mainly for SHOW commands, as metadata for these + commands is sent only with result set. + To be removed when all commands will fully support prepared mode. */ static unsigned int alloc_stmt_fields(MYSQL_STMT *stmt) @@ -1983,8 +2031,31 @@ static unsigned int alloc_stmt_fields(MYSQL_STMT *stmt) } /* - Returns prepared meta information in the form of resultset - to client. + Returns prepared statement metadata in the form of a result set. + + SYNOPSIS + mysql_stmt_result_metadata() + stmt statement handle + + RETURN + NULL statement contains no result set or out of memory. + In the latter case you can retreive error message + with mysql_stmt_error. + MYSQL_RES a result set with no rows + + DESCRIPTION + This function should be used after mysql_stmt_execute(). + You can safely check that prepared statement has a result set by calling + mysql_stmt_num_fields(): if number of fields is not zero, you can call + this function to get fields metadata. + Next steps you may want to make: + - find out number of columns in result set by calling + mysql_num_fields(res) (the same value is returned by + mysql_stmt_num_fields) + - fetch metadata for any column with mysql_fetch_field, + mysql_fetch_field_direct, mysql_fetch_fields, mysql_field_seek. + - free returned MYSQL_RES structure with mysql_free_result. + - proceed to binding of output parameters. */ MYSQL_RES * STDCALL @@ -2016,8 +2087,9 @@ mysql_stmt_result_metadata(MYSQL_STMT *stmt) } /* - Returns parameter columns meta information in the form of - resultset. + Returns parameter columns meta information in the form of + result set. + XXX: not implemented yet. */ MYSQL_RES * STDCALL @@ -2036,12 +2108,8 @@ mysql_stmt_param_metadata(MYSQL_STMT *stmt) } -/******************************************************************** - Prepare-execute, and param handling -*********************************************************************/ - -/**************************************************************************** - Functions to store parameter data from a prepared statement. +/* + Functions to store parameter data in network packet. All functions have the following characteristics: @@ -2053,7 +2121,7 @@ mysql_stmt_param_metadata(MYSQL_STMT *stmt) RETURN VALUES 0 ok 1 Error (Can't alloc net->buffer) -****************************************************************************/ +*/ static void store_param_tinyint(NET *net, MYSQL_BIND *param) { @@ -2162,7 +2230,8 @@ static void store_param_datetime(NET *net, MYSQL_BIND *param) static void store_param_str(NET *net, MYSQL_BIND *param) { - ulong length= param->length ? *param->length : param->buffer_length; + /* param->length is always set in mysql_stmt_bind_param */ + ulong length= *param->length; char *to= (char *) net_store_length((char *) net->write_pos, length); memcpy(to, param->buffer, length); net->write_pos= (uchar*) to+length; @@ -2530,6 +2599,16 @@ my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt) /* + Returns the number of result columns for the most recent query + run on this statement. +*/ + +unsigned int STDCALL mysql_stmt_field_count(MYSQL_STMT *stmt) +{ + return stmt->field_count; +} + +/* Return last inserted id for auto_increment columns */ @@ -2538,6 +2617,7 @@ my_ulonglong STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt) return stmt->insert_id; } + static my_bool int_is_null_true= 1; /* Used for MYSQL_TYPE_NULL */ static my_bool int_is_null_false= 0; @@ -2630,6 +2710,11 @@ my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind) case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_STRING: param->store_param_func= store_param_str; + /* + For variable length types we expect user to set + length or buffer_length. Otherwise mysql_stmt_execute + will just fail. + */ break; default: strmov(stmt->sqlstate, unknown_sqlstate); @@ -2671,7 +2756,6 @@ my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind) 1 error */ - my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number, const char *data, ulong length) @@ -2769,6 +2853,7 @@ static uint read_binary_time(MYSQL_TIME *tm, uchar **pos) uchar *to; uint length; + /* net_field_length will set pos to the first byte of data */ if (!(length= net_field_length(pos))) { set_zero_time(tm); diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def index 927d46be91c..bbd5af6558d 100644 --- a/libmysql/libmysql.def +++ b/libmysql/libmysql.def @@ -131,3 +131,4 @@ EXPORTS mysql_stmt_insert_id mysql_stmt_attr_get mysql_stmt_attr_set + mysql_stmt_field_count diff --git a/merge/mrg_open.c b/merge/mrg_open.c index 83b776ea201..6bf75392131 100644 --- a/merge/mrg_open.c +++ b/merge/mrg_open.c @@ -62,7 +62,7 @@ int handle_locking) { if ((end=buff+length)[-1] == '\n') end[-1]='\0'; - if (buff[0] && buff[0] != '#') /* Skipp empty lines and comments */ + if (buff[0] && buff[0] != '#') /* Skip empty lines and comments */ { last_isam=isam; if (!test_if_hard_path(buff)) diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 5f20046d1cf..6da0fd9552b 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -307,7 +307,7 @@ int chk_size(MI_CHECK *param, register MI_INFO *info) #endif if (skr != size) { - info->state->data_file_length=size; /* Skipp other errors */ + info->state->data_file_length=size; /* Skip other errors */ if (skr > size && skr != size + MEMMAP_EXTRA_MARGIN) { error=1; @@ -3672,7 +3672,7 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename) if (param->language) keyseg->language=param->language; /* change language */ } - keyseg++; /* Skipp end pointer */ + keyseg++; /* Skip end pointer */ } /* Copy the unique definitions and change them to point at the new key diff --git a/myisam/mi_delete.c b/myisam/mi_delete.c index 19cfc050ea1..3eb8e9a7226 100644 --- a/myisam/mi_delete.c +++ b/myisam/mi_delete.c @@ -816,7 +816,7 @@ static uint remove_key(MI_KEYDEF *keyinfo, uint nod_flag, if (!(*start & 128)) prev_length=0; /* prev key not packed */ if (keyinfo->seg[0].flag & HA_NULL_PART) - lastkey++; /* Skipp null marker */ + lastkey++; /* Skip null marker */ get_key_length(lastkey_length,lastkey); if (!next_length) /* Same key after */ { diff --git a/myisam/mi_key.c b/myisam/mi_key.c index d81584d648b..4aebba041f8 100644 --- a/myisam/mi_key.c +++ b/myisam/mi_key.c @@ -221,7 +221,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, k_length-= 2+length; set_if_smaller(length,tmp_length); /* Safety */ store_key_length_inc(key,length); - old+=2; /* Skipp length */ + old+=2; /* Skip length */ memcpy((byte*) key, pos+2,(size_t) length); key+= length; continue; diff --git a/myisam/mi_search.c b/myisam/mi_search.c index 1c4342ff39a..51ced6fa15a 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -761,7 +761,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, } if (keyseg->flag & HA_NULL_PART) { - key++; /* Skipp null marker*/ + key++; /* Skip null marker*/ start++; } @@ -1395,7 +1395,7 @@ _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key, if (prev_key && !*prev_key++) org_key=prev_key=0; /* Can't pack against prev */ else if (org_key) - org_key++; /* Skipp NULL */ + org_key++; /* Skip NULL */ } else s_temp->store_not_null=0; diff --git a/myisam/myisamlog.c b/myisam/myisamlog.c index 82f6277ce25..6679510227e 100644 --- a/myisam/myisamlog.c +++ b/myisam/myisamlog.c @@ -145,7 +145,7 @@ static void get_options(register int *argc, register char ***argv) switch((option=*pos)) { case '#': DBUG_PUSH (++pos); - pos=" "; /* Skipp rest of arg */ + pos=" "; /* Skip rest of arg */ break; case 'c': if (! *++pos) diff --git a/mysql-test/include/have_archive.inc b/mysql-test/include/have_archive.inc new file mode 100644 index 00000000000..f7fb942e83e --- /dev/null +++ b/mysql-test/include/have_archive.inc @@ -0,0 +1,4 @@ +-- require r/have_archive.require +disable_query_log; +show variables like "have_archive"; +enable_query_log; diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result new file mode 100644 index 00000000000..b380ea910de --- /dev/null +++ b/mysql-test/r/archive.result @@ -0,0 +1,1396 @@ +drop table if exists t1,t2; +CREATE TABLE t1 ( +Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, +Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +) ENGINE=archive; +INSERT INTO t1 VALUES (9410,9412); +select period from t1; +period +9410 +select * from t1; +Period Varor_period +9410 9412 +select t1.* from t1; +Period Varor_period +9410 9412 +CREATE TABLE t2 ( +auto int, +fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, +companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, +fld3 char(30) DEFAULT '' NOT NULL, +fld4 char(35) DEFAULT '' NOT NULL, +fld5 char(35) DEFAULT '' NOT NULL, +fld6 char(4) DEFAULT '' NOT NULL +) ENGINE=archive; +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +fld3 +imaginable +select fld3 from t2 where fld3 like "%cultivation" ; +fld3 +cultivation +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3,companynr from t2 where companynr = 58 order by fld3; +fld3 companynr +concoct 58 +druggists 58 +engrossing 58 +Eurydice 58 +exclaimers 58 +ferociousness 58 +hopelessness 58 +Huey 58 +imaginable 58 +judges 58 +merging 58 +ostrich 58 +peering 58 +Phelps 58 +presumes 58 +Ruth 58 +sentences 58 +Shylock 58 +straggled 58 +synergy 58 +thanking 58 +tying 58 +unlocks 58 +select fld3 from t2 order by fld3 desc limit 10; +fld3 +youthfulness +yelped +Wotan +workers +Witt +witchcraft +Winsett +Willy +willed +wildcats +select fld3 from t2 order by fld3 desc limit 5; +fld3 +youthfulness +yelped +Wotan +workers +Witt +select fld3 from t2 order by fld3 desc limit 5,5; +fld3 +witchcraft +Winsett +Willy +willed +wildcats +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'h%le'; +fld3 +honeysuckle +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +fld3 +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; +fld3 +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +fld3 +honeysuckle +honoring +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; +fld1 fld3 +148504 Colombo +068305 Colombo +000000 nondecreasing +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +fld1 fld3 +012001 flanking +013602 foldout +013606 fingerings +018007 fanatic +018017 featherweight +018054 fetters +018103 flint +018104 flopping +036002 funereal +038017 fetched +038205 firearm +058004 Fenton +088303 feminine +186002 freakish +188007 flurried +188505 fitting +198006 furthermore +202301 Fitzpatrick +208101 fiftieth +208113 freest +218008 finishers +218022 feed +218401 faithful +226205 foothill +226209 furnishings +228306 forthcoming +228311 fated +231315 freezes +232102 forgivably +238007 filial +238008 fixedly +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +fld3 +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +fld3 +Chantilly +select fld1,fld3 from t2 where fld1 like "25050%"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +select fld1,fld3 from t2 where fld1 like "25050_"; +fld1 fld3 +250501 poisoning +250502 Iraqis +250503 heaving +250504 population +250505 bomb +INSERT INTO t2 VALUES (1,000001,00,'Omaha','teethe','neat',''); +INSERT INTO t2 VALUES (2,011401,37,'breaking','dreaded','Steinberg','W'); +INSERT INTO t2 VALUES (3,011402,37,'Romans','scholastics','jarring',''); +INSERT INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); +SELECT * FROM t2; +auto fld1 companynr fld3 fld4 fld5 fld6 +1 000001 00 Omaha teethe neat +2 011401 37 breaking dreaded Steinberg W +3 011402 37 Romans scholastics jarring +4 011403 37 intercepted audiology tinily +5 011501 37 bewilderingly wallet balled +6 011701 37 astound parters persist W +7 011702 37 admonishing eschew attainments +8 011703 37 sumac quitter fanatic +9 012001 37 flanking neat measures FAS +10 012003 37 combed Steinberg rightfulness +11 012004 37 subjective jarring capably +12 012005 37 scatterbrain tinily impulsive +13 012301 37 Eulerian balled starlet +14 012302 36 dubbed persist terminators +15 012303 37 Kane attainments untying +16 012304 37 overlay fanatic announces FAS +17 012305 37 perturb measures featherweight FAS +18 012306 37 goblins rightfulness pessimist FAS +19 012501 37 annihilates capably daughter +20 012602 37 Wotan impulsive decliner FAS +21 012603 37 snatching starlet lawgiver +22 012604 37 concludes terminators stated +23 012605 37 laterally untying readable +24 012606 37 yelped announces attrition +25 012701 37 grazing featherweight cascade FAS +26 012702 37 Baird pessimist motors FAS +27 012703 37 celery daughter interrogate +28 012704 37 misunderstander decliner pests W +29 013601 37 handgun lawgiver stairway +30 013602 37 foldout stated dopers FAS +31 013603 37 mystic readable testicle W +32 013604 37 succumbed attrition Parsifal W +33 013605 37 Nabisco cascade leavings +34 013606 37 fingerings motors postulation W +35 013607 37 aging interrogate squeaking +36 013608 37 afield pests contrasted +37 013609 37 ammonium stairway leftover +38 013610 37 boat dopers whiteners +39 013801 37 intelligibility testicle erases W +40 013802 37 Augustine Parsifal Punjab W +41 013803 37 teethe leavings Merritt +42 013804 37 dreaded postulation Quixotism +43 013901 37 scholastics squeaking sweetish FAS +44 016001 37 audiology contrasted dogging FAS +45 016201 37 wallet leftover scornfully FAS +46 016202 37 parters whiteners bellow +47 016301 37 eschew erases bills +48 016302 37 quitter Punjab cupboard FAS +49 016303 37 neat Merritt sureties FAS +50 016304 37 Steinberg Quixotism puddings +51 018001 37 jarring sweetish tapestry +52 018002 37 tinily dogging fetters +53 018003 37 balled scornfully bivalves +54 018004 37 persist bellow incurring +55 018005 37 attainments bills Adolph +56 018007 37 fanatic cupboard pithed +57 018008 37 measures sureties emergency +58 018009 37 rightfulness puddings Miles +59 018010 37 capably tapestry trimmings +60 018012 37 impulsive fetters tragedies W +61 018013 37 starlet bivalves skulking W +62 018014 37 terminators incurring flint +63 018015 37 untying Adolph flopping W +64 018016 37 announces pithed relaxing FAS +65 018017 37 featherweight emergency offload FAS +66 018018 37 pessimist Miles suites W +67 018019 37 daughter trimmings lists FAS +68 018020 37 decliner tragedies animized FAS +69 018021 37 lawgiver skulking multilayer W +70 018022 37 stated flint standardizes FAS +71 018023 37 readable flopping Judas +72 018024 37 attrition relaxing vacuuming W +73 018025 37 cascade offload dentally W +74 018026 37 motors suites humanness W +75 018027 37 interrogate lists inch W +76 018028 37 pests animized Weissmuller W +77 018029 37 stairway multilayer irresponsibly W +78 018030 37 dopers standardizes luckily FAS +79 018032 37 testicle Judas culled W +80 018033 37 Parsifal vacuuming medical FAS +81 018034 37 leavings dentally bloodbath FAS +82 018035 37 postulation humanness subschema W +83 018036 37 squeaking inch animals W +84 018037 37 contrasted Weissmuller Micronesia +85 018038 37 leftover irresponsibly repetitions +86 018039 37 whiteners luckily Antares +87 018040 37 erases culled ventilate W +88 018041 37 Punjab medical pityingly +89 018042 37 Merritt bloodbath interdependent +90 018043 37 Quixotism subschema Graves FAS +91 018044 37 sweetish animals neonatal +92 018045 37 dogging Micronesia scribbled FAS +93 018046 37 scornfully repetitions chafe W +94 018048 37 bellow Antares honoring +95 018049 37 bills ventilate realtor +96 018050 37 cupboard pityingly elite +97 018051 37 sureties interdependent funereal +98 018052 37 puddings Graves abrogating +99 018053 50 tapestry neonatal sorters +100 018054 37 fetters scribbled Conley +101 018055 37 bivalves chafe lectured +102 018056 37 incurring honoring Abraham +103 018057 37 Adolph realtor Hawaii W +104 018058 37 pithed elite cage +105 018059 36 emergency funereal hushes +106 018060 37 Miles abrogating Simla +107 018061 37 trimmings sorters reporters +108 018101 37 tragedies Conley Dutchman FAS +109 018102 37 skulking lectured descendants FAS +110 018103 37 flint Abraham groupings FAS +111 018104 37 flopping Hawaii dissociate +112 018201 37 relaxing cage coexist W +113 018202 37 offload hushes Beebe +114 018402 37 suites Simla Taoism +115 018403 37 lists reporters Connally +116 018404 37 animized Dutchman fetched FAS +117 018405 37 multilayer descendants checkpoints FAS +118 018406 37 standardizes groupings rusting +119 018409 37 Judas dissociate galling +120 018601 37 vacuuming coexist obliterates +121 018602 37 dentally Beebe traitor +122 018603 37 humanness Taoism resumes FAS +123 018801 37 inch Connally analyzable FAS +124 018802 37 Weissmuller fetched terminator FAS +125 018803 37 irresponsibly checkpoints gritty FAS +126 018804 37 luckily rusting firearm W +127 018805 37 culled galling minima +128 018806 37 medical obliterates Selfridge +129 018807 37 bloodbath traitor disable +130 018808 37 subschema resumes witchcraft W +131 018809 37 animals analyzable betroth W +132 018810 37 Micronesia terminator Manhattanize +133 018811 37 repetitions gritty imprint +134 018812 37 Antares firearm peeked +135 019101 37 ventilate minima swelling +136 019102 37 pityingly Selfridge interrelationships W +137 019103 37 interdependent disable riser +138 019201 37 Graves witchcraft Gandhian W +139 030501 37 neonatal betroth peacock A +140 030502 50 scribbled Manhattanize bee A +141 030503 37 chafe imprint kanji +142 030504 37 honoring peeked dental +143 031901 37 realtor swelling scarf FAS +144 036001 37 elite interrelationships chasm A +145 036002 37 funereal riser insolence A +146 036004 37 abrogating Gandhian syndicate +147 036005 37 sorters peacock alike +148 038001 37 Conley bee imperial A +149 038002 37 lectured kanji convulsion A +150 038003 37 Abraham dental railway A +151 038004 37 Hawaii scarf validate A +152 038005 37 cage chasm normalizes A +153 038006 37 hushes insolence comprehensive +154 038007 37 Simla syndicate chewing +155 038008 37 reporters alike denizen +156 038009 37 Dutchman imperial schemer +157 038010 37 descendants convulsion chronicle +158 038011 37 groupings railway Kline +159 038012 37 dissociate validate Anatole +160 038013 37 coexist normalizes partridges +161 038014 37 Beebe comprehensive brunch +162 038015 37 Taoism chewing recruited +163 038016 37 Connally denizen dimensions W +164 038017 37 fetched schemer Chicana W +165 038018 37 checkpoints chronicle announced +166 038101 37 rusting Kline praised FAS +167 038102 37 galling Anatole employing +168 038103 37 obliterates partridges linear +169 038104 37 traitor brunch quagmire +170 038201 37 resumes recruited western A +171 038202 37 analyzable dimensions relishing +172 038203 37 terminator Chicana serving A +173 038204 37 gritty announced scheduling +174 038205 37 firearm praised lore +175 038206 37 minima employing eventful +176 038208 37 Selfridge linear arteriole A +177 042801 37 disable quagmire disentangle +178 042802 37 witchcraft western cured A +179 046101 37 betroth relishing Fenton W +180 048001 37 Manhattanize serving avoidable A +181 048002 37 imprint scheduling drains A +182 048003 37 peeked lore detectably FAS +183 048004 37 swelling eventful husky +184 048005 37 interrelationships arteriole impelling +185 048006 37 riser disentangle undoes +186 048007 37 Gandhian cured evened +187 048008 37 peacock Fenton squeezes +188 048101 37 bee avoidable destroyer FAS +189 048102 37 kanji drains rudeness +190 048201 37 dental detectably beaner FAS +191 048202 37 scarf husky boorish +192 048203 37 chasm impelling Everhart +193 048204 37 insolence undoes encompass A +194 048205 37 syndicate evened mushrooms +195 048301 37 alike squeezes Alison A +196 048302 37 imperial destroyer externally FAS +197 048303 37 convulsion rudeness pellagra +198 048304 37 railway beaner cult +199 048305 37 validate boorish creek A +200 048401 37 normalizes Everhart Huffman +201 048402 37 comprehensive encompass Majorca FAS +202 048403 37 chewing mushrooms governing A +203 048404 37 denizen Alison gadfly FAS +204 048405 37 schemer externally reassigned FAS +205 048406 37 chronicle pellagra intentness W +206 048407 37 Kline cult craziness +207 048408 37 Anatole creek psychic +208 048409 37 partridges Huffman squabbled +209 048410 37 brunch Majorca burlesque +210 048411 37 recruited governing capped +211 048412 37 dimensions gadfly extracted A +212 048413 37 Chicana reassigned DiMaggio +213 048601 37 announced intentness exclamation FAS +214 048602 37 praised craziness subdirectory +215 048603 37 employing psychic fangs +216 048604 37 linear squabbled buyer A +217 048801 37 quagmire burlesque pithing A +218 050901 37 western capped transistorizing A +219 051201 37 relishing extracted nonbiodegradable +220 056002 37 serving DiMaggio dislocate +221 056003 37 scheduling exclamation monochromatic FAS +222 056004 37 lore subdirectory batting +223 056102 37 eventful fangs postcondition A +224 056203 37 arteriole buyer catalog FAS +225 056204 37 disentangle pithing Remus +226 058003 37 cured transistorizing devices A +227 058004 37 Fenton nonbiodegradable bike A +228 058005 37 avoidable dislocate qualify +229 058006 37 drains monochromatic detained +230 058007 37 detectably batting commended +231 058101 37 husky postcondition civilize +232 058102 37 impelling catalog Elmhurst +233 058103 37 undoes Remus anesthetizing +234 058105 37 evened devices deaf +235 058111 37 squeezes bike Brigham +236 058112 37 destroyer qualify title +237 058113 37 rudeness detained coarse +238 058114 37 beaner commended combinations +239 058115 37 boorish civilize grayness +240 058116 37 Everhart Elmhurst innumerable FAS +241 058117 37 encompass anesthetizing Caroline A +242 058118 37 mushrooms deaf fatty FAS +243 058119 37 Alison Brigham eastbound +244 058120 37 externally title inexperienced +245 058121 37 pellagra coarse hoarder A +246 058122 37 cult combinations scotch W +247 058123 37 creek grayness passport A +248 058124 37 Huffman innumerable strategic FAS +249 058125 37 Majorca Caroline gated +250 058126 37 governing fatty flog +251 058127 37 gadfly eastbound Pipestone +252 058128 37 reassigned inexperienced Dar +253 058201 37 intentness hoarder Corcoran +254 058202 37 craziness scotch flyers A +255 058303 37 psychic passport competitions W +256 058304 37 squabbled strategic suppliers FAS +257 058602 37 burlesque gated skips +258 058603 37 capped flog institutes +259 058604 37 extracted Pipestone troop A +260 058605 37 DiMaggio Dar connective W +261 058606 37 exclamation Corcoran denies +262 058607 37 subdirectory flyers polka +263 060401 36 fangs competitions observations FAS +264 061701 36 buyer suppliers askers +265 066201 36 pithing skips homeless FAS +266 066501 36 transistorizing institutes Anna +267 068001 36 nonbiodegradable troop subdirectories W +268 068002 36 dislocate connective decaying FAS +269 068005 36 monochromatic denies outwitting W +270 068006 36 batting polka Harpy W +271 068007 36 postcondition observations crazed +272 068008 36 catalog askers suffocate +273 068009 36 Remus homeless provers FAS +274 068010 36 devices Anna technically +275 068011 36 bike subdirectories Franklinizations +276 068202 36 qualify decaying considered +277 068302 36 detained outwitting tinnily +278 068303 36 commended Harpy uninterruptedly +279 068401 36 civilize crazed whistled A +280 068501 36 Elmhurst suffocate automate +281 068502 36 anesthetizing provers gutting W +282 068503 36 deaf technically surreptitious +283 068602 36 Brigham Franklinizations Choctaw +284 068603 36 title considered cooks +285 068701 36 coarse tinnily millivolt FAS +286 068702 36 combinations uninterruptedly counterpoise +287 068703 36 grayness whistled Gothicism +288 076001 36 innumerable automate feminine +289 076002 36 Caroline gutting metaphysically W +290 076101 36 fatty surreptitious sanding A +291 076102 36 eastbound Choctaw contributorily +292 076103 36 inexperienced cooks receivers FAS +293 076302 36 hoarder millivolt adjourn +294 076303 36 scotch counterpoise straggled A +295 076304 36 passport Gothicism druggists +296 076305 36 strategic feminine thanking FAS +297 076306 36 gated metaphysically ostrich +298 076307 36 flog sanding hopelessness FAS +299 076402 36 Pipestone contributorily Eurydice +300 076501 36 Dar receivers excitation W +301 076502 36 Corcoran adjourn presumes FAS +302 076701 36 flyers straggled imaginable FAS +303 078001 36 competitions druggists concoct W +304 078002 36 suppliers thanking peering W +305 078003 36 skips ostrich Phelps FAS +306 078004 36 institutes hopelessness ferociousness FAS +307 078005 36 troop Eurydice sentences +308 078006 36 connective excitation unlocks +309 078007 36 denies presumes engrossing W +310 078008 36 polka imaginable Ruth +311 078101 36 observations concoct tying +312 078103 36 askers peering exclaimers +313 078104 36 homeless Phelps synergy +314 078105 36 Anna ferociousness Huey W +315 082101 36 subdirectories sentences merging +316 083401 36 decaying unlocks judges A +317 084001 36 outwitting engrossing Shylock W +318 084002 36 Harpy Ruth Miltonism +319 086001 36 crazed tying hen W +320 086102 36 suffocate exclaimers honeybee FAS +321 086201 36 provers synergy towers +322 088001 36 technically Huey dilutes W +323 088002 36 Franklinizations merging numerals FAS +324 088003 36 considered judges democracy FAS +325 088004 36 tinnily Shylock Ibero- +326 088101 36 uninterruptedly Miltonism invalids +327 088102 36 whistled hen behavior +328 088103 36 automate honeybee accruing +329 088104 36 gutting towers relics A +330 088105 36 surreptitious dilutes rackets +331 088106 36 Choctaw numerals Fischbein W +332 088201 36 cooks democracy phony W +333 088203 36 millivolt Ibero- cross FAS +334 088204 36 counterpoise invalids cleanup +335 088302 37 Gothicism behavior conspirator +336 088303 37 feminine accruing label FAS +337 088305 37 metaphysically relics university +338 088402 37 sanding rackets cleansed FAS +339 088501 36 contributorily Fischbein ballgown +340 088502 36 receivers phony starlet +341 088503 36 adjourn cross aqueous +342 098001 58 straggled cleanup portrayal A +343 098002 58 druggists conspirator despising W +344 098003 58 thanking label distort W +345 098004 58 ostrich university palmed +346 098005 58 hopelessness cleansed faced +347 098006 58 Eurydice ballgown silverware +348 141903 29 excitation starlet assessor +349 098008 58 presumes aqueous spiders +350 098009 58 imaginable portrayal artificially +351 098010 58 concoct despising reminiscence +352 098011 58 peering distort Mexican +353 098012 58 Phelps palmed obnoxious +354 098013 58 ferociousness faced fragile +355 098014 58 sentences silverware apprehensible +356 098015 58 unlocks assessor births +357 098016 58 engrossing spiders garages +358 098017 58 Ruth artificially panty +359 098018 58 tying reminiscence anteater +360 098019 58 exclaimers Mexican displacement A +361 098020 58 synergy obnoxious drovers A +362 098021 58 Huey fragile patenting A +363 098022 58 merging apprehensible far A +364 098023 58 judges births shrieks +365 098024 58 Shylock garages aligning W +366 098025 37 Miltonism panty pragmatism +367 106001 36 hen anteater fevers W +368 108001 36 honeybee displacement reexamines A +369 108002 36 towers drovers occupancies +370 108003 36 dilutes patenting sweats FAS +371 108004 36 numerals far modulators +372 108005 36 democracy shrieks demand W +373 108007 36 Ibero- aligning Madeira +374 108008 36 invalids pragmatism Viennese W +375 108009 36 behavior fevers chillier W +376 108010 36 accruing reexamines wildcats FAS +377 108011 36 relics occupancies gentle +378 108012 36 rackets sweats Angles W +379 108101 36 Fischbein modulators accuracies +380 108102 36 phony demand toggle +381 108103 36 cross Madeira Mendelssohn W +382 108111 50 cleanup Viennese behaviorally +383 108105 36 conspirator chillier Rochford +384 108106 36 label wildcats mirror W +385 108107 36 university gentle Modula +386 108108 50 cleansed Angles clobbering +387 108109 36 ballgown accuracies chronography +388 108110 36 starlet toggle Eskimoizeds +389 108201 36 aqueous Mendelssohn British W +390 108202 36 portrayal behaviorally pitfalls +391 108203 36 despising Rochford verify W +392 108204 36 distort mirror scatter FAS +393 108205 36 palmed Modula Aztecan +394 108301 36 faced clobbering acuity W +395 108302 36 silverware chronography sinking W +396 112101 36 assessor Eskimoizeds beasts FAS +397 112102 36 spiders British Witt W +398 113701 36 artificially pitfalls physicists FAS +399 116001 36 reminiscence verify folksong A +400 116201 36 Mexican scatter strokes FAS +401 116301 36 obnoxious Aztecan crowder +402 116302 36 fragile acuity merry +403 116601 36 apprehensible sinking cadenced +404 116602 36 births beasts alimony A +405 116603 36 garages Witt principled A +406 116701 36 panty physicists golfing +407 116702 36 anteater folksong undiscovered +408 118001 36 displacement strokes irritates +409 118002 36 drovers crowder patriots A +410 118003 36 patenting merry rooms FAS +411 118004 36 far cadenced towering W +412 118005 36 shrieks alimony displease +413 118006 36 aligning principled photosensitive +414 118007 36 pragmatism golfing inking +415 118008 36 fevers undiscovered gainers +416 118101 36 reexamines irritates leaning A +417 118102 36 occupancies patriots hydrant A +418 118103 36 sweats rooms preserve +419 118202 36 modulators towering blinded A +420 118203 36 demand displease interactions A +421 118204 36 Madeira photosensitive Barry +422 118302 36 Viennese inking whiteness A +423 118304 36 chillier gainers pastimes W +424 118305 36 wildcats leaning Edenization +425 118306 36 gentle hydrant Muscat +426 118307 36 Angles preserve assassinated +427 123101 36 accuracies blinded labeled +428 123102 36 toggle interactions glacial A +429 123301 36 Mendelssohn Barry implied W +430 126001 36 behaviorally whiteness bibliographies W +431 126002 36 Rochford pastimes Buchanan +432 126003 36 mirror Edenization forgivably FAS +433 126101 36 Modula Muscat innuendo A +434 126301 36 clobbering assassinated den FAS +435 126302 36 chronography labeled submarines W +436 126402 36 Eskimoizeds glacial mouthful A +437 126601 36 British implied expiring +438 126602 36 pitfalls bibliographies unfulfilled FAS +439 126702 36 verify Buchanan precession +440 128001 36 scatter forgivably nullified +441 128002 36 Aztecan innuendo affects +442 128003 36 acuity den Cynthia +443 128004 36 sinking submarines Chablis A +444 128005 36 beasts mouthful betterments FAS +445 128007 36 Witt expiring advertising +446 128008 36 physicists unfulfilled rubies A +447 128009 36 folksong precession southwest FAS +448 128010 36 strokes nullified superstitious A +449 128011 36 crowder affects tabernacle W +450 128012 36 merry Cynthia silk A +451 128013 36 cadenced Chablis handsomest A +452 128014 36 alimony betterments Persian A +453 128015 36 principled advertising analog W +454 128016 36 golfing rubies complex W +455 128017 36 undiscovered southwest Taoist +456 128018 36 irritates superstitious suspend +457 128019 36 patriots tabernacle relegated +458 128020 36 rooms silk awesome W +459 128021 36 towering handsomest Bruxelles +460 128022 36 displease Persian imprecisely A +461 128023 36 photosensitive analog televise +462 128101 36 inking complex braking +463 128102 36 gainers Taoist true FAS +464 128103 36 leaning suspend disappointing FAS +465 128104 36 hydrant relegated navally W +466 128106 36 preserve awesome circus +467 128107 36 blinded Bruxelles beetles +468 128108 36 interactions imprecisely trumps +469 128202 36 Barry televise fourscore W +470 128203 36 whiteness braking Blackfoots +471 128301 36 pastimes true Grady +472 128302 36 Edenization disappointing quiets FAS +473 128303 36 Muscat navally floundered FAS +474 128304 36 assassinated circus profundity W +475 128305 36 labeled beetles Garrisonian W +476 128307 36 glacial trumps Strauss +477 128401 36 implied fourscore cemented FAS +478 128502 36 bibliographies Blackfoots contrition A +479 128503 36 Buchanan Grady mutations +480 128504 36 forgivably quiets exhibits W +481 128505 36 innuendo floundered tits +482 128601 36 den profundity mate A +483 128603 36 submarines Garrisonian arches +484 128604 36 mouthful Strauss Moll +485 128702 36 expiring cemented ropers +486 128703 36 unfulfilled contrition bombast +487 128704 36 precession mutations difficultly A +488 138001 36 nullified exhibits adsorption +489 138002 36 affects tits definiteness FAS +490 138003 36 Cynthia mate cultivation A +491 138004 36 Chablis arches heals A +492 138005 36 betterments Moll Heusen W +493 138006 36 advertising ropers target FAS +494 138007 36 rubies bombast cited A +495 138008 36 southwest difficultly congresswoman W +496 138009 36 superstitious adsorption Katherine +497 138102 36 tabernacle definiteness titter A +498 138103 36 silk cultivation aspire A +499 138104 36 handsomest heals Mardis +500 138105 36 Persian Heusen Nadia W +501 138201 36 analog target estimating FAS +502 138302 36 complex cited stuck A +503 138303 36 Taoist congresswoman fifteenth A +504 138304 36 suspend Katherine Colombo +505 138401 29 relegated titter survey A +506 140102 29 awesome aspire staffing +507 140103 29 Bruxelles Mardis obtain +508 140104 29 imprecisely Nadia loaded +509 140105 29 televise estimating slaughtered +510 140201 29 braking stuck lights A +511 140701 29 true fifteenth circumference +512 141501 29 disappointing Colombo dull A +513 141502 29 navally survey weekly A +514 141901 29 circus staffing wetness +515 141902 29 beetles obtain visualized +516 142101 29 trumps loaded Tannenbaum +517 142102 29 fourscore slaughtered moribund +518 142103 29 Blackfoots lights demultiplex +519 142701 29 Grady circumference lockings +520 143001 29 quiets dull thugs FAS +521 143501 29 floundered weekly unnerves +522 143502 29 profundity wetness abut +523 148001 29 Garrisonian visualized Chippewa A +524 148002 29 Strauss Tannenbaum stratifications A +525 148003 29 cemented moribund signaled +526 148004 29 contrition demultiplex Italianizes A +527 148005 29 mutations lockings algorithmic A +528 148006 29 exhibits thugs paranoid FAS +529 148007 29 tits unnerves camping A +530 148009 29 mate abut signifying A +531 148010 29 arches Chippewa Patrice W +532 148011 29 Moll stratifications search A +533 148012 29 ropers signaled Angeles A +534 148013 29 bombast Italianizes semblance +535 148023 36 difficultly algorithmic taxed +536 148015 29 adsorption paranoid Beatrice +537 148016 29 definiteness camping retrace +538 148017 29 cultivation signifying lockout +539 148018 29 heals Patrice grammatic +540 148019 29 Heusen search helmsman +541 148020 29 target Angeles uniform W +542 148021 29 cited semblance hamming +543 148022 29 congresswoman taxed disobedience +544 148101 29 Katherine Beatrice captivated A +545 148102 29 titter retrace transferals A +546 148201 29 aspire lockout cartographer A +547 148401 29 Mardis grammatic aims FAS +548 148402 29 Nadia helmsman Pakistani +549 148501 29 estimating uniform burglarized FAS +550 148502 29 stuck hamming saucepans A +551 148503 29 fifteenth disobedience lacerating A +552 148504 29 Colombo captivated corny +553 148601 29 survey transferals megabytes FAS +554 148602 29 staffing cartographer chancellor +555 150701 29 obtain aims bulk A +556 152101 29 loaded Pakistani commits A +557 152102 29 slaughtered burglarized meson W +558 155202 36 lights saucepans deputies +559 155203 29 circumference lacerating northeaster A +560 155204 29 dull corny dipole +561 155205 29 weekly megabytes machining 0 +562 156001 29 wetness chancellor therefore +563 156002 29 visualized bulk Telefunken +564 156102 29 Tannenbaum commits salvaging +565 156301 29 moribund meson Corinthianizes A +566 156302 29 demultiplex deputies restlessly A +567 156303 29 lockings northeaster bromides +568 156304 29 thugs dipole generalized A +569 156305 29 unnerves machining mishaps +570 156306 29 abut therefore quelling +571 156501 29 Chippewa Telefunken spiritual A +572 158001 29 stratifications salvaging beguiles FAS +573 158002 29 signaled Corinthianizes Trobriand FAS +574 158101 29 Italianizes restlessly fleeing A +575 158102 29 algorithmic bromides Armour A +576 158103 29 paranoid generalized chin A +577 158201 29 camping mishaps provers A +578 158202 29 signifying quelling aeronautic A +579 158203 29 Patrice spiritual voltage W +580 158204 29 search beguiles sash +581 158301 29 Angeles Trobriand anaerobic A +582 158302 29 semblance fleeing simultaneous A +583 158303 29 taxed Armour accumulating A +584 158304 29 Beatrice chin Medusan A +585 158305 29 retrace provers shouted A +586 158306 29 lockout aeronautic freakish +587 158501 29 grammatic voltage index FAS +588 160301 29 helmsman sash commercially +589 166101 50 uniform anaerobic mistiness A +590 166102 50 hamming simultaneous endpoint +591 168001 29 disobedience accumulating straight A +592 168002 29 captivated Medusan flurried +593 168003 29 transferals shouted denotative A +594 168101 29 cartographer freakish coming FAS +595 168102 29 aims index commencements FAS +596 168103 29 Pakistani commercially gentleman +597 168104 29 burglarized mistiness gifted +598 168202 29 saucepans endpoint Shanghais +599 168301 29 lacerating straight sportswriting A +600 168502 29 corny flurried sloping A +601 168503 29 megabytes denotative navies +602 168601 29 chancellor coming leaflet A +603 173001 40 bulk commencements shooter +604 173701 40 commits gentleman Joplin FAS +605 173702 40 meson gifted babies +606 176001 40 deputies Shanghais subdivision FAS +607 176101 40 northeaster sportswriting burstiness W +608 176201 40 dipole sloping belted FAS +609 176401 40 machining navies assails FAS +610 176501 40 therefore leaflet admiring W +611 176601 40 Telefunken shooter swaying 0 +612 176602 40 salvaging Joplin Goldstine FAS +613 176603 40 Corinthianizes babies fitting +614 178001 40 restlessly subdivision Norwalk W +615 178002 40 bromides burstiness weakening W +616 178003 40 generalized belted analogy FAS +617 178004 40 mishaps assails deludes +618 178005 40 quelling admiring cokes +619 178006 40 spiritual swaying Clayton +620 178007 40 beguiles Goldstine exhausts +621 178008 40 Trobriand fitting causality +622 178101 40 fleeing Norwalk sating FAS +623 178102 40 Armour weakening icon +624 178103 40 chin analogy throttles +625 178201 40 provers deludes communicants FAS +626 178202 40 aeronautic cokes dehydrate FAS +627 178301 40 voltage Clayton priceless FAS +628 178302 40 sash exhausts publicly +629 178401 40 anaerobic causality incidentals FAS +630 178402 40 simultaneous sating commonplace +631 178403 40 accumulating icon mumbles +632 178404 40 Medusan throttles furthermore W +633 178501 40 shouted communicants cautioned W +634 186002 37 freakish dehydrate parametrized A +635 186102 37 index priceless registration A +636 186201 40 commercially publicly sadly FAS +637 186202 40 mistiness incidentals positioning +638 186203 40 endpoint commonplace babysitting +639 186302 37 straight mumbles eternal A +640 188007 37 flurried furthermore hoarder +641 188008 37 denotative cautioned congregates +642 188009 37 coming parametrized rains +643 188010 37 commencements registration workers W +644 188011 37 gentleman sadly sags A +645 188012 37 gifted positioning unplug W +646 188013 37 Shanghais babysitting garage A +647 188014 37 sportswriting eternal boulder A +648 188015 37 sloping hoarder hollowly A +649 188016 37 navies congregates specifics +650 188017 37 leaflet rains Teresa +651 188102 37 shooter workers Winsett +652 188103 37 Joplin sags convenient A +653 188202 37 babies unplug buckboards FAS +654 188301 40 subdivision garage amenities +655 188302 40 burstiness boulder resplendent FAS +656 188303 40 belted hollowly priding FAS +657 188401 37 assails specifics configurations +658 188402 37 admiring Teresa untidiness A +659 188503 37 swaying Winsett Brice W +660 188504 37 Goldstine convenient sews FAS +661 188505 37 fitting buckboards participated +662 190701 37 Norwalk amenities Simon FAS +663 190703 50 weakening resplendent certificates +664 191701 37 analogy priding Fitzpatrick +665 191702 37 deludes configurations Evanston A +666 191703 37 cokes untidiness misted +667 196001 37 Clayton Brice textures A +668 196002 37 exhausts sews save +669 196003 37 causality participated count +670 196101 37 sating Simon rightful A +671 196103 37 icon certificates chaperone +672 196104 37 throttles Fitzpatrick Lizzy A +673 196201 37 communicants Evanston clenched A +674 196202 37 dehydrate misted effortlessly +675 196203 37 priceless textures accessed +676 198001 37 publicly save beaters A +677 198003 37 incidentals count Hornblower FAS +678 198004 37 commonplace rightful vests A +679 198005 37 mumbles chaperone indulgences FAS +680 198006 37 furthermore Lizzy infallibly A +681 198007 37 cautioned clenched unwilling FAS +682 198008 37 parametrized effortlessly excrete FAS +683 198009 37 registration accessed spools A +684 198010 37 sadly beaters crunches FAS +685 198011 37 positioning Hornblower overestimating FAS +686 198012 37 babysitting vests ineffective +687 198013 37 eternal indulgences humiliation A +688 198014 37 hoarder infallibly sophomore +689 198015 37 congregates unwilling star +690 198017 37 rains excrete rifles +691 198018 37 workers spools dialysis +692 198019 37 sags crunches arriving +693 198020 37 unplug overestimating indulge +694 198021 37 garage ineffective clockers +695 198022 37 boulder humiliation languages +696 198023 50 hollowly sophomore Antarctica A +697 198024 37 specifics star percentage +698 198101 37 Teresa rifles ceiling A +699 198103 37 Winsett dialysis specification +700 198105 37 convenient arriving regimented A +701 198106 37 buckboards indulge ciphers +702 198201 37 amenities clockers pictures A +703 198204 37 resplendent languages serpents A +704 198301 53 priding Antarctica allot A +705 198302 53 configurations percentage realized A +706 198303 53 untidiness ceiling mayoral A +707 198304 53 Brice specification opaquely A +708 198401 37 sews regimented hostess FAS +709 198402 37 participated ciphers fiftieth +710 198403 37 Simon pictures incorrectly +711 202101 37 certificates serpents decomposition FAS +712 202301 37 Fitzpatrick allot stranglings +713 202302 37 Evanston realized mixture FAS +714 202303 37 misted mayoral electroencephalography FAS +715 202304 37 textures opaquely similarities FAS +716 202305 37 save hostess charges W +717 202601 37 count fiftieth freest FAS +718 202602 37 rightful incorrectly Greenberg FAS +719 202605 37 chaperone decomposition tinting +720 202606 37 Lizzy stranglings expelled W +721 202607 37 clenched mixture warm +722 202901 37 effortlessly electroencephalography smoothed +723 202902 37 accessed similarities deductions FAS +724 202903 37 beaters charges Romano W +725 202904 37 Hornblower freest bitterroot +726 202907 37 vests Greenberg corset +727 202908 37 indulgences tinting securing +728 203101 37 infallibly expelled environing FAS +729 203103 37 unwilling warm cute +730 203104 37 excrete smoothed Crays +731 203105 37 spools deductions heiress FAS +732 203401 37 crunches Romano inform FAS +733 203402 37 overestimating bitterroot avenge +734 203404 37 ineffective corset universals +735 203901 37 humiliation securing Kinsey W +736 203902 37 sophomore environing ravines FAS +737 203903 37 star cute bestseller +738 203906 37 rifles Crays equilibrium +739 203907 37 dialysis heiress extents 0 +740 203908 37 arriving inform relatively +741 203909 37 indulge avenge pressure FAS +742 206101 37 clockers universals critiques FAS +743 206201 37 languages Kinsey befouled +744 206202 37 Antarctica ravines rightfully FAS +745 206203 37 percentage bestseller mechanizing FAS +746 206206 37 ceiling equilibrium Latinizes +747 206207 37 specification extents timesharing +748 206208 37 regimented relatively Aden +749 208001 37 ciphers pressure embassies +750 208002 37 pictures critiques males FAS +751 208003 37 serpents befouled shapelessly FAS +752 208004 37 allot rightfully genres FAS +753 208008 37 realized mechanizing mastering +754 208009 37 mayoral Latinizes Newtonian +755 208010 37 opaquely timesharing finishers FAS +756 208011 37 hostess Aden abates +757 208101 37 fiftieth embassies teem +758 208102 37 incorrectly males kiting FAS +759 208103 37 decomposition shapelessly stodgy FAS +760 208104 37 stranglings genres scalps FAS +761 208105 37 mixture mastering feed FAS +762 208110 37 electroencephalography Newtonian guitars +763 208111 37 similarities finishers airships +764 208112 37 charges abates store +765 208113 37 freest teem denounces +766 208201 37 Greenberg kiting Pyle FAS +767 208203 37 tinting stodgy Saxony +768 208301 37 expelled scalps serializations FAS +769 208302 37 warm feed Peruvian FAS +770 208305 37 smoothed guitars taxonomically FAS +771 208401 37 deductions airships kingdom A +772 208402 37 Romano store stint A +773 208403 37 bitterroot denounces Sault A +774 208404 37 corset Pyle faithful +775 208501 37 securing Saxony Ganymede FAS +776 208502 37 environing serializations tidiness FAS +777 208503 37 cute Peruvian gainful FAS +778 208504 37 Crays taxonomically contrary FAS +779 208505 37 heiress kingdom Tipperary FAS +780 210101 37 inform stint tropics W +781 210102 37 avenge Sault theorizers +782 210103 37 universals faithful renew 0 +783 210104 37 Kinsey Ganymede already +784 210105 37 ravines tidiness terminal +785 210106 37 bestseller gainful Hegelian +786 210107 37 equilibrium contrary hypothesizer +787 210401 37 extents Tipperary warningly FAS +788 213201 37 relatively tropics journalizing FAS +789 213203 37 pressure theorizers nested +790 213204 37 critiques renew Lars +791 213205 37 befouled already saplings +792 213206 37 rightfully terminal foothill +793 213207 37 mechanizing Hegelian labeled +794 216101 37 Latinizes hypothesizer imperiously FAS +795 216103 37 timesharing warningly reporters FAS +796 218001 37 Aden journalizing furnishings FAS +797 218002 37 embassies nested precipitable FAS +798 218003 37 males Lars discounts FAS +799 218004 37 shapelessly saplings excises FAS +800 143503 50 genres foothill Stalin +801 218006 37 mastering labeled despot FAS +802 218007 37 Newtonian imperiously ripeness FAS +803 218008 37 finishers reporters Arabia +804 218009 37 abates furnishings unruly +805 218010 37 teem precipitable mournfulness +806 218011 37 kiting discounts boom FAS +807 218020 37 stodgy excises slaughter A +808 218021 50 scalps Stalin Sabine +809 218022 37 feed despot handy FAS +810 218023 37 guitars ripeness rural +811 218024 37 airships Arabia organizer +812 218101 37 store unruly shipyard FAS +813 218102 37 denounces mournfulness civics FAS +814 218103 37 Pyle boom inaccuracy FAS +815 218201 37 Saxony slaughter rules FAS +816 218202 37 serializations Sabine juveniles FAS +817 218203 37 Peruvian handy comprised W +818 218204 37 taxonomically rural investigations +819 218205 37 kingdom organizer stabilizes A +820 218301 37 stint shipyard seminaries FAS +821 218302 37 Sault civics Hunter A +822 218401 37 faithful inaccuracy sporty FAS +823 218402 37 Ganymede rules test FAS +824 218403 37 tidiness juveniles weasels +825 218404 37 gainful comprised CERN +826 218407 37 contrary investigations tempering +827 218408 37 Tipperary stabilizes afore FAS +828 218409 37 tropics seminaries Galatean +829 218410 37 theorizers Hunter techniques W +830 226001 37 renew sporty error +831 226002 37 already test veranda +832 226003 37 terminal weasels severely +833 226004 37 Hegelian CERN Cassites FAS +834 226005 37 hypothesizer tempering forthcoming +835 226006 37 warningly afore guides +836 226007 37 journalizing Galatean vanish FAS +837 226008 37 nested techniques lied A +838 226203 37 Lars error sawtooth FAS +839 226204 37 saplings veranda fated FAS +840 226205 37 foothill severely gradually +841 226206 37 labeled Cassites widens +842 226207 37 imperiously forthcoming preclude +843 226208 37 reporters guides Jobrel +844 226209 37 furnishings vanish hooker +845 226210 37 precipitable lied rainstorm +846 226211 37 discounts sawtooth disconnects +847 228001 37 excises fated cruelty +848 228004 37 Stalin gradually exponentials A +849 228005 37 despot widens affective A +850 228006 37 ripeness preclude arteries +851 228007 37 Arabia Jobrel Crosby FAS +852 228008 37 unruly hooker acquaint +853 228009 37 mournfulness rainstorm evenhandedly +854 228101 37 boom disconnects percentage +855 228108 37 slaughter cruelty disobedience +856 228109 37 Sabine exponentials humility +857 228110 37 handy affective gleaning A +858 228111 37 rural arteries petted A +859 228112 37 organizer Crosby bloater A +860 228113 37 shipyard acquaint minion A +861 228114 37 civics evenhandedly marginal A +862 228115 37 inaccuracy percentage apiary A +863 228116 37 rules disobedience measures +864 228117 37 juveniles humility precaution +865 228118 37 comprised gleaning repelled +866 228119 37 investigations petted primary FAS +867 228120 37 stabilizes bloater coverings +868 228121 37 seminaries minion Artemia A +869 228122 37 Hunter marginal navigate +870 228201 37 sporty apiary spatial +871 228206 37 test measures Gurkha +872 228207 37 weasels precaution meanwhile A +873 228208 37 CERN repelled Melinda A +874 228209 37 tempering primary Butterfield +875 228210 37 afore coverings Aldrich A +876 228211 37 Galatean Artemia previewing A +877 228212 37 techniques navigate glut A +878 228213 37 error spatial unaffected +879 228214 37 veranda Gurkha inmate +880 228301 37 severely meanwhile mineral +881 228305 37 Cassites Melinda impending A +882 228306 37 forthcoming Butterfield meditation A +883 228307 37 guides Aldrich ideas +884 228308 37 vanish previewing miniaturizes W +885 228309 37 lied glut lewdly +886 228310 37 sawtooth unaffected title +887 228311 37 fated inmate youthfulness +888 228312 37 gradually mineral creak FAS +889 228313 37 widens impending Chippewa +890 228314 37 preclude meditation clamored +891 228401 65 Jobrel ideas freezes +892 228402 65 hooker miniaturizes forgivably FAS +893 228403 65 rainstorm lewdly reduce FAS +894 228404 65 disconnects title McGovern W +895 228405 65 cruelty youthfulness Nazis W +896 228406 65 exponentials creak epistle W +897 228407 65 affective Chippewa socializes W +898 228408 65 arteries clamored conceptions +899 228409 65 Crosby freezes Kevin +900 228410 65 acquaint forgivably uncovering +901 230301 37 evenhandedly reduce chews FAS +902 230302 37 percentage McGovern appendixes FAS +903 230303 37 disobedience Nazis raining +904 018062 37 humility epistle infest +905 230501 37 gleaning socializes compartment +906 230502 37 petted conceptions minting +907 230503 37 bloater Kevin ducks +908 230504 37 minion uncovering roped A +909 230505 37 marginal chews waltz +910 230506 37 apiary appendixes Lillian +911 230507 37 measures raining repressions A +912 230508 37 precaution infest chillingly +913 230509 37 repelled compartment noncritical +914 230901 37 primary minting lithograph +915 230902 37 coverings ducks spongers +916 230903 37 Artemia roped parenthood +917 230904 37 navigate waltz posed +918 230905 37 spatial Lillian instruments +919 230906 37 Gurkha repressions filial +920 230907 37 meanwhile chillingly fixedly +921 230908 37 Melinda noncritical relives +922 230909 37 Butterfield lithograph Pandora +923 230910 37 Aldrich spongers watering A +924 230911 37 previewing parenthood ungrateful +925 230912 37 glut posed secures +926 230913 37 unaffected instruments chastisers +927 230914 37 inmate filial icon +928 231304 37 mineral fixedly reuniting A +929 231305 37 impending relives imagining A +930 231306 37 meditation Pandora abiding A +931 231307 37 ideas watering omnisciently +932 231308 37 miniaturizes ungrateful Britannic +933 231309 37 lewdly secures scholastics A +934 231310 37 title chastisers mechanics A +935 231311 37 youthfulness icon humidly A +936 231312 37 creak reuniting masterpiece +937 231313 37 Chippewa imagining however +938 231314 37 clamored abiding Mendelian +939 231315 37 freezes omnisciently jarred +940 232102 37 forgivably Britannic scolds +941 232103 37 reduce scholastics infatuate +942 232104 37 McGovern mechanics willed A +943 232105 37 Nazis humidly joyfully +944 232106 37 epistle masterpiece Microsoft +945 232107 37 socializes however fibrosities +946 232108 37 conceptions Mendelian Baltimorean +947 232601 37 Kevin jarred equestrian +948 232602 37 uncovering scolds Goodrich +949 232603 37 chews infatuate apish A +950 232605 37 appendixes willed Adlerian +5950 1232605 37 appendixes willed Adlerian +5951 1232606 37 appendixes willed Adlerian +5952 1232607 37 appendixes willed Adlerian +5953 1232608 37 appendixes willed Adlerian +5954 1232609 37 appendixes willed Adlerian +951 232606 37 raining joyfully Tropez +952 232607 37 infest Microsoft nouns +953 232608 37 compartment fibrosities distracting +954 232609 37 minting Baltimorean mutton +955 236104 37 ducks equestrian bridgeable A +956 236105 37 roped Goodrich stickers A +957 236106 37 waltz apish transcontinental A +958 236107 37 Lillian Adlerian amateurish +959 236108 37 repressions Tropez Gandhian +960 236109 37 chillingly nouns stratified +961 236110 37 noncritical distracting chamberlains +962 236111 37 lithograph mutton creditably +963 236112 37 spongers bridgeable philosophic +964 236113 37 parenthood stickers ores +965 238005 37 posed transcontinental Carleton +966 238006 37 instruments amateurish tape A +967 238007 37 filial Gandhian afloat A +968 238008 37 fixedly stratified goodness A +969 238009 37 relives chamberlains welcoming +970 238010 37 Pandora creditably Pinsky FAS +971 238011 37 watering philosophic halting +972 238012 37 ungrateful ores bibliography +973 238013 37 secures Carleton decoding +974 240401 41 chastisers tape variance A +975 240402 41 icon afloat allowed A +976 240901 41 reuniting goodness dire A +977 240902 41 imagining welcoming dub A +978 241801 41 abiding Pinsky poisoning +979 242101 41 omnisciently halting Iraqis A +980 242102 41 Britannic bibliography heaving +981 242201 41 scholastics decoding population A +982 242202 41 mechanics variance bomb A +983 242501 41 humidly allowed Majorca A +984 242502 41 masterpiece dire Gershwins +985 246201 41 however dub explorers +986 246202 41 Mendelian poisoning libretto A +987 246203 41 jarred Iraqis occurred +988 246204 41 scolds heaving Lagos +989 246205 41 infatuate population rats +990 246301 41 willed bomb bankruptcies A +991 246302 41 joyfully Majorca crying +992 248001 41 Microsoft Gershwins unexpected +993 248002 41 fibrosities explorers accessed A +994 248003 41 Baltimorean libretto colorful A +995 248004 41 equestrian occurred versatility A +996 248005 41 Goodrich Lagos cosy +997 248006 41 apish rats Darius A +998 248007 41 Adlerian bankruptcies mastering A +999 248008 41 Tropez crying Asiaticizations A +1000 248009 41 nouns unexpected offerers A +1001 248010 41 distracting accessed uncles A +1002 248011 41 mutton colorful sleepwalk +1003 248012 41 bridgeable versatility Ernestine +1004 248013 41 stickers cosy checksumming +1005 248014 41 transcontinental Darius stopped +1006 248015 41 amateurish mastering sicker +1007 248016 41 Gandhian Asiaticizations Italianization +1008 248017 41 stratified offerers alphabetic +1009 248018 41 chamberlains uncles pharmaceutic +1010 248019 41 creditably sleepwalk creator +1011 248020 41 philosophic Ernestine chess +1012 248021 41 ores checksumming charcoal +1013 248101 41 Carleton stopped Epiphany A +1014 248102 41 tape sicker bulldozes A +1015 248201 41 afloat Italianization Pygmalion A +1016 248202 41 goodness alphabetic caressing A +1017 248203 41 welcoming pharmaceutic Palestine A +1018 248204 41 Pinsky creator regimented A +1019 248205 41 halting chess scars A +1020 248206 41 bibliography charcoal realest A +1021 248207 41 decoding Epiphany diffusing A +1022 248208 41 variance bulldozes clubroom A +1023 248209 41 allowed Pygmalion Blythe A +1024 248210 41 dire caressing ahead +1025 248211 50 dub Palestine reviver +1026 250501 34 poisoning regimented retransmitting A +1027 250502 34 Iraqis scars landslide +1028 250503 34 heaving realest Eiffel +1029 250504 34 population diffusing absentee +1030 250505 34 bomb clubroom aye +1031 250601 34 Majorca Blythe forked A +1032 250602 34 Gershwins ahead Peruvianizes +1033 250603 34 explorers reviver clerked +1034 250604 34 libretto retransmitting tutor +1035 250605 34 occurred landslide boulevard +1036 251001 34 Lagos Eiffel shuttered +1037 251002 34 rats absentee quotes A +1038 251003 34 bankruptcies aye Caltech +1039 251004 34 crying forked Mossberg +1040 251005 34 unexpected Peruvianizes kept +1041 251301 34 accessed clerked roundly +1042 251302 34 colorful tutor features A +1043 251303 34 versatility boulevard imaginable A +1044 251304 34 cosy shuttered controller +1045 251305 34 Darius quotes racial +1046 251401 34 mastering Caltech uprisings A +1047 251402 34 Asiaticizations Mossberg narrowed A +1048 251403 34 offerers kept cannot A +1049 251404 34 uncles roundly vest +1050 251405 34 sleepwalk features famine +1051 251406 34 Ernestine imaginable sugars +1052 251801 34 checksumming controller exterminated A +1053 251802 34 stopped racial belays +1054 252101 34 sicker uprisings Hodges A +1055 252102 34 Italianization narrowed translatable +1056 252301 34 alphabetic cannot duality A +1057 252302 34 pharmaceutic vest recording A +1058 252303 34 creator famine rouses A +1059 252304 34 chess sugars poison +1060 252305 34 charcoal exterminated attitude +1061 252306 34 Epiphany belays dusted +1062 252307 34 bulldozes Hodges encompasses +1063 252308 34 Pygmalion translatable presentation +1064 252309 34 caressing duality Kantian +1065 256001 34 Palestine recording imprecision A +1066 256002 34 regimented rouses saving +1067 256003 34 scars poison maternal +1068 256004 34 realest attitude hewed +1069 256005 34 diffusing dusted kerosene +1070 258001 34 clubroom encompasses Cubans +1071 258002 34 Blythe presentation photographers +1072 258003 34 ahead Kantian nymph A +1073 258004 34 reviver imprecision bedlam A +1074 258005 34 retransmitting saving north A +1075 258006 34 landslide maternal Schoenberg A +1076 258007 34 Eiffel hewed botany A +1077 258008 34 absentee kerosene curs +1078 258009 34 aye Cubans solidification +1079 258010 34 forked photographers inheritresses +1080 258011 34 Peruvianizes nymph stiller +1081 258101 68 clerked bedlam t1 A +1082 258102 68 tutor north suite A +1083 258103 34 boulevard Schoenberg ransomer +1084 258104 68 shuttered botany Willy +1085 258105 68 quotes curs Rena A +1086 258106 68 Caltech solidification Seattle A +1087 258107 68 Mossberg inheritresses relaxes A +1088 258108 68 kept stiller exclaim +1089 258109 68 roundly t1 implicated A +1090 258110 68 features suite distinguish +1091 258111 68 imaginable ransomer assayed +1092 258112 68 controller Willy homeowner +1093 258113 68 racial Rena and +1094 258201 34 uprisings Seattle stealth +1095 258202 34 narrowed relaxes coinciding A +1096 258203 34 cannot exclaim founder A +1097 258204 34 vest implicated environing +1098 258205 34 famine distinguish jewelry +1099 258301 34 sugars assayed lemons A +1100 258401 34 exterminated homeowner brokenness A +1101 258402 34 belays and bedpost A +1102 258403 34 Hodges stealth assurers A +1103 258404 34 translatable coinciding annoyers +1104 258405 34 duality founder affixed +1105 258406 34 recording environing warbling +1106 258407 34 rouses jewelry seriously +1107 228123 37 poison lemons boasted +1108 250606 34 attitude brokenness Chantilly +1109 208405 37 dusted bedpost Iranizes +1110 212101 37 encompasses assurers violinist +1111 218206 37 presentation annoyers extramarital +1112 150401 37 Kantian affixed spates +1113 248212 41 imprecision warbling cloakroom +1114 128026 00 saving seriously gazer +1115 128024 00 maternal boasted hand +1116 128027 00 hewed Chantilly tucked +1117 128025 00 kerosene Iranizes gems +1118 128109 00 Cubans violinist clinker +1119 128705 00 photographers extramarital refiner +1120 126303 00 nymph spates callus +1121 128308 00 bedlam cloakroom leopards +1122 128204 00 north gazer comfortingly +1123 128205 00 Schoenberg hand generically +1124 128206 00 botany tucked getters +1125 128207 00 curs gems sexually +1126 118205 00 solidification clinker spear +1127 116801 00 inheritresses refiner serums +1128 116803 00 stiller callus Italianization +1129 116804 00 t1 leopards attendants +1130 116802 00 suite comfortingly spies +1131 128605 00 ransomer generically Anthony +1132 118308 00 Willy getters planar +1133 113702 00 Rena sexually cupped +1134 113703 00 Seattle spear cleanser +1135 112103 00 relaxes serums commuters +1136 118009 00 exclaim Italianization honeysuckle +5136 1118009 00 exclaim Italianization honeysuckle +1137 138011 00 implicated attendants orphanage +1138 138010 00 distinguish spies skies +1139 138012 00 assayed Anthony crushers +1140 068304 00 homeowner planar Puritan +1141 078009 00 and cupped squeezer +1142 108013 00 stealth cleanser bruises +1143 084004 00 coinciding commuters bonfire +1144 083402 00 founder honeysuckle Colombo +1145 084003 00 environing orphanage nondecreasing +1146 088504 00 jewelry skies innocents +1147 088005 00 lemons crushers masked +1148 088007 00 brokenness Puritan file +1149 088006 00 bedpost squeezer brush +1150 148025 00 assurers bruises mutilate +1151 148024 00 annoyers bonfire mommy +1152 138305 00 affixed Colombo bulkheads +1153 138306 00 warbling nondecreasing undeclared +1154 152701 00 seriously innocents displacements +1155 148505 00 boasted masked nieces +1156 158003 00 Chantilly file coeducation +1157 156201 00 Iranizes brush brassy +1158 156202 00 violinist mutilate authenticator +1159 158307 00 extramarital mommy Washoe +1160 158402 00 spates bulkheads penny +1161 158401 00 cloakroom undeclared Flagler +1162 068013 00 gazer displacements stoned +1163 068012 00 hand nieces cranes +1164 068203 00 tucked coeducation masterful +1165 088205 00 gems brassy biracial +1166 068704 00 clinker authenticator steamships +1167 068604 00 refiner Washoe windmills +1168 158502 00 callus penny exploit +1169 123103 00 leopards Flagler riverfront +1170 148026 00 comfortingly stoned sisterly +1171 123302 00 generically cranes sharpshoot +1172 076503 00 getters masterful mittens +1173 126304 00 sexually biracial interdependency +1174 068306 00 spear steamships policy +1175 143504 00 serums windmills unleashing +1176 160201 00 Italianization exploit pretenders +1177 148028 00 attendants riverfront overstatements +1178 148027 00 spies sisterly birthed +1179 143505 00 Anthony sharpshoot opportunism +1180 108014 00 planar mittens showroom +1181 076104 00 cupped interdependency compromisingly +1182 078106 00 cleanser policy Medicare +1183 126102 00 commuters unleashing corresponds +1184 128029 00 honeysuckle pretenders hardware +1185 128028 00 orphanage overstatements implant +1186 018410 00 skies birthed Alicia +1187 128110 00 crushers opportunism requesting +1188 148506 00 Puritan showroom produced +1189 123303 00 squeezer compromisingly criticizes +1190 123304 00 bruises Medicare backer +1191 068504 00 bonfire corresponds positively +1192 068305 00 Colombo hardware colicky +1193 000000 00 nondecreasing implant thrillingly +1 000001 00 Omaha teethe neat +2 011401 37 breaking dreaded Steinberg W +3 011402 37 Romans scholastics jarring +4 011403 37 intercepted audiology tinily +drop table t1, t2; diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 30795aaf106..f16524c020b 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -47,6 +47,15 @@ t1 CREATE TABLE `t1` ( `r` char(10) character set ucs2 NOT NULL default '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; +create table t2(f1 Char(30)); +insert into t2 values ("103000"), ("22720000"), ("3401200"), ("78000"); +select lpad(f1, 12, "-o-/") from t2; +lpad(f1, 12, "-o-/") +-o-/-o103000 +-o-/22720000 +-o-/-3401200 +-o-/-o-78000 +drop table t2; SET NAMES koi8r; SET character_set_connection=ucs2; create table t1 (a varchar(10) character set ucs2, key(a)); diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 28af71b7681..6c11dd210aa 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -218,3 +218,25 @@ b select * from t1 where a = 'b' and a != 'b'; a drop table t1; +set names utf8; +select 'ваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]'; +'ваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]' +1 +select 'ваÑÑ ' rlike '[[:<:]]ваÑÑ[[:>:]]'; +'ваÑÑ ' rlike '[[:<:]]ваÑÑ[[:>:]]' +1 +select ' ваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]'; +' ваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]' +1 +select ' ваÑÑ ' rlike '[[:<:]]ваÑÑ[[:>:]]'; +' ваÑÑ ' rlike '[[:<:]]ваÑÑ[[:>:]]' +1 +select 'ваÑÑz' rlike '[[:<:]]ваÑÑ[[:>:]]'; +'ваÑÑz' rlike '[[:<:]]ваÑÑ[[:>:]]' +0 +select 'zваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]'; +'zваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]' +0 +select 'zваÑÑz' rlike '[[:<:]]ваÑÑ[[:>:]]'; +'zваÑÑz' rlike '[[:<:]]ваÑÑ[[:>:]]' +0 diff --git a/mysql-test/r/have_archive.require b/mysql-test/r/have_archive.require new file mode 100644 index 00000000000..c4b4ba24fcd --- /dev/null +++ b/mysql-test/r/have_archive.require @@ -0,0 +1,2 @@ +Variable_name Value +have_archive YES diff --git a/mysql-test/r/rpl_charset.result b/mysql-test/r/rpl_charset.result new file mode 100644 index 00000000000..6ba82d0dd2f --- /dev/null +++ b/mysql-test/r/rpl_charset.result @@ -0,0 +1,199 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +drop database if exists test2; +drop database if exists test3; +create database test2 character set latin2; +set @@character_set_server=latin5; +create database test3; + +--- --master-- +show create database test2; +Database Create Database +test2 CREATE DATABASE `test2` /*!40100 DEFAULT CHARACTER SET latin2 */ +show create database test3; +Database Create Database +test3 CREATE DATABASE `test3` /*!40100 DEFAULT CHARACTER SET latin5 */ + +--- --slave-- +show create database test2; +Database Create Database +test2 CREATE DATABASE `test2` /*!40100 DEFAULT CHARACTER SET latin2 */ +show create database test3; +Database Create Database +test3 CREATE DATABASE `test3` /*!40100 DEFAULT CHARACTER SET latin5 */ +set @@collation_server=armscii_bin; +drop database test3; +create database test3; + +--- --master-- +show create database test3; +Database Create Database +test3 CREATE DATABASE `test3` /*!40100 DEFAULT CHARACTER SET armscii8 COLLATE armscii_bin */ + +--- --slave-- +show create database test3; +Database Create Database +test3 CREATE DATABASE `test3` /*!40100 DEFAULT CHARACTER SET armscii8 COLLATE armscii_bin */ +use test2; +create table t1 (a int auto_increment primary key, b varchar(100)); +set character_set_client=cp850, collation_connection=latin2_croatian_ci; +insert into t1 (b) values(@@character_set_server); +insert into t1 (b) values(@@collation_server); +insert into t1 (b) values(@@character_set_client); +insert into t1 (b) values(@@character_set_connection); +insert into t1 (b) values(@@collation_connection); + +--- --master-- +select * from t1 order by a; +a b +1 armscii8 +2 armscii_bin +3 cp850 +4 latin2 +5 latin2_croatian_ci + +--- --slave-- +select * from test2.t1 order by a; +a b +1 armscii8 +2 armscii_bin +3 cp850 +4 latin2 +5 latin2_croatian_ci +set character_set_client=latin1, collation_connection=latin1_german1_ci; +truncate table t1; +insert into t1 (b) values(@@collation_connection); +insert into t1 (b) values(LEAST("Müller","Muffler")); +set collation_connection=latin1_german2_ci; +insert into t1 (b) values(@@collation_connection); +insert into t1 (b) values(LEAST("Müller","Muffler")); + +--- --master-- +select * from t1 order by a; +a b +1 latin1_german1_ci +2 Muffler +3 latin1_german2_ci +4 Müller + +--- --slave-- +select * from test2.t1 order by a; +a b +1 latin1_german1_ci +2 Muffler +3 latin1_german2_ci +4 Müller +load data infile '../../std_data/words.dat' into table t1 (b); +set @a= _cp850 'Müller' collate cp850_general_ci; +truncate table t1; +insert into t1 (b) values(collation(@a)); + +--- --master-- +select * from t1 order by a; +a b +1 cp850_general_ci + +--- --slave-- +select * from test2.t1 order by a; +a b +1 cp850_general_ci +drop database test2; +drop database test3; +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.000001 79 Query 1 79 use `test`; create database test2 character set latin2 +master-bin.000001 156 Query 1 156 use `test`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=8,COLLATION_DATABASE=8,COLLATION_SERVER=30 +master-bin.000001 290 Query 1 290 use `test`; create database test3 +master-bin.000001 346 Query 1 346 use `test`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=8,COLLATION_DATABASE=8,COLLATION_SERVER=64 +master-bin.000001 480 Query 1 480 use `test`; drop database test3 +master-bin.000001 534 Query 1 534 use `test`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=8,COLLATION_DATABASE=8,COLLATION_SERVER=64 +master-bin.000001 668 Query 1 668 use `test`; create database test3 +master-bin.000001 724 Query 1 724 use `test2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=8,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 859 Query 1 859 use `test2`; create table t1 (a int auto_increment primary key, b varchar(100)) +master-bin.000001 961 Query 1 961 use `test2`; SET ONE_SHOT CHARACTER_SET_CLIENT=4,COLLATION_CONNECTION=27,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 1097 Intvar 1 1097 INSERT_ID=1 +master-bin.000001 1125 Query 1 1125 use `test2`; insert into t1 (b) values(@@character_set_server) +master-bin.000001 1210 Query 1 1210 use `test2`; SET ONE_SHOT CHARACTER_SET_CLIENT=4,COLLATION_CONNECTION=27,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 1346 Intvar 1 1346 INSERT_ID=2 +master-bin.000001 1374 Query 1 1374 use `test2`; insert into t1 (b) values(@@collation_server) +master-bin.000001 1455 Query 1 1455 use `test2`; SET ONE_SHOT CHARACTER_SET_CLIENT=4,COLLATION_CONNECTION=27,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 1591 Intvar 1 1591 INSERT_ID=3 +master-bin.000001 1619 Query 1 1619 use `test2`; insert into t1 (b) values(@@character_set_client) +master-bin.000001 1704 Query 1 1704 use `test2`; SET ONE_SHOT CHARACTER_SET_CLIENT=4,COLLATION_CONNECTION=27,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 1840 Intvar 1 1840 INSERT_ID=4 +master-bin.000001 1868 Query 1 1868 use `test2`; insert into t1 (b) values(@@character_set_connection) +master-bin.000001 1957 Query 1 1957 use `test2`; SET ONE_SHOT CHARACTER_SET_CLIENT=4,COLLATION_CONNECTION=27,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 2093 Intvar 1 2093 INSERT_ID=5 +master-bin.000001 2121 Query 1 2121 use `test2`; insert into t1 (b) values(@@collation_connection) +master-bin.000001 2206 Query 1 2206 use `test2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=5,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 2341 Query 1 2341 use `test2`; truncate table t1 +master-bin.000001 2394 Query 1 2394 use `test2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=5,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 2529 Intvar 1 2529 INSERT_ID=1 +master-bin.000001 2557 Query 1 2557 use `test2`; insert into t1 (b) values(@@collation_connection) +master-bin.000001 2642 Query 1 2642 use `test2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=5,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 2777 Intvar 1 2777 INSERT_ID=2 +master-bin.000001 2805 Query 1 2805 use `test2`; insert into t1 (b) values(LEAST("Müller","Muffler")) +master-bin.000001 2893 Query 1 2893 use `test2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 3029 Intvar 1 3029 INSERT_ID=3 +master-bin.000001 3057 Query 1 3057 use `test2`; insert into t1 (b) values(@@collation_connection) +master-bin.000001 3142 Query 1 3142 use `test2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 3278 Intvar 1 3278 INSERT_ID=4 +master-bin.000001 3306 Query 1 3306 use `test2`; insert into t1 (b) values(LEAST("Müller","Muffler")) +master-bin.000001 3394 Query 1 3394 use `test2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 3530 Intvar 1 3530 INSERT_ID=74 +master-bin.000001 3558 Create_file 1 3558 db=test2;table=t1;file_id=1;block_len=581 +master-bin.000001 4226 Query 1 4226 use `test2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 4362 Intvar 1 4362 INSERT_ID=5 +master-bin.000001 4390 Exec_load 1 4390 ;file_id=1 +master-bin.000001 4413 Query 1 4413 use `test2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 4549 Query 1 4549 use `test2`; truncate table t1 +master-bin.000001 4602 Query 1 4602 use `test2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 4738 Intvar 1 4738 INSERT_ID=1 +master-bin.000001 4766 User var 1 4766 @`a`=_cp850'Müller' COLLATE cp850_general_ci +master-bin.000001 4806 Query 1 4806 use `test2`; insert into t1 (b) values(collation(@a)) +master-bin.000001 4882 Query 1 4882 use `test2`; SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 5018 Query 1 5018 use `test2`; drop database test2 +master-bin.000001 5073 Query 1 5073 SET ONE_SHOT CHARACTER_SET_CLIENT=8,COLLATION_CONNECTION=31,COLLATION_DATABASE=9,COLLATION_SERVER=64 +master-bin.000001 5204 Query 1 5204 drop database test3 +set global character_set_server=latin2; +ERROR HY000: Binary logging and replication forbid changing the global server character set or collation +set global character_set_server=latin2; +ERROR HY000: Binary logging and replication forbid changing the global server character set or collation +set one_shot @@character_set_server=latin5; +set @@max_join_size=1000; +select @@character_set_server; +@@character_set_server +latin5 +select @@character_set_server; +@@character_set_server +latin1 +set @@character_set_server=latin5; +select @@character_set_server; +@@character_set_server +latin5 +select @@character_set_server; +@@character_set_server +latin5 +set one_shot max_join_size=10; +ERROR HY000: The SET ONE_SHOT syntax is reserved for purposes internal to the MySQL server +set character_set_client=9999999; +ERROR 42000: Unknown character set: '9999999' +set collation_server=9999998; +ERROR HY000: Unknown collation: '9999998' +use test; +CREATE TABLE t1 (c1 VARBINARY(255), c2 VARBINARY(255)); +SET CHARACTER_SET_CLIENT=koi8r, +CHARACTER_SET_CONNECTION=cp1251, +CHARACTER_SET_RESULTS=koi8r; +INSERT INTO t1 (c1, c2) VALUES ('îÕ, ÚÁ ÒÙÂÁÌËÕ','îÕ, ÚÁ ÒÙÂÁÌËÕ'); +select hex(c1), hex(c2) from t1; +hex(c1) hex(c2) +CDF32C20E7E020F0FBE1E0EBEAF3 CDF32C20E7E020F0FBE1E0EBEAF3 +select hex(c1), hex(c2) from t1; +hex(c1) hex(c2) +CDF32C20E7E020F0FBE1E0EBEAF3 CDF32C20E7E020F0FBE1E0EBEAF3 +drop table t1; diff --git a/mysql-test/r/rpl_server_id1.result b/mysql-test/r/rpl_server_id1.result index 8c383802de4..32e14b053d7 100644 --- a/mysql-test/r/rpl_server_id1.result +++ b/mysql-test/r/rpl_server_id1.result @@ -15,8 +15,5 @@ start slave; insert into t1 values (1); show status like "slave_running"; Variable_name Value -Slave_running ON -select * from t1; -n -1 +Slave_running OFF drop table t1; diff --git a/mysql-test/r/rpl_user_variables.result b/mysql-test/r/rpl_user_variables.result index 71147772ac4..7bb5dc163ea 100644 --- a/mysql-test/r/rpl_user_variables.result +++ b/mysql-test/r/rpl_user_variables.result @@ -86,11 +86,11 @@ slave-bin.000001 313 Query 1 313 use `test`; insert into t1 values (@i1), (@i2), slave-bin.000001 396 User var 2 396 @r1=12.5 slave-bin.000001 439 User var 2 439 @r2=-12.5 slave-bin.000001 482 Query 1 482 use `test`; insert into t1 values (@r1), (@r2) -slave-bin.000001 551 User var 2 551 @s1='This is a test' -slave-bin.000001 600 User var 2 600 @s2='' -slave-bin.000001 635 User var 2 635 @s3='abc'def' -slave-bin.000001 677 User var 2 677 @s4='abc\def' -slave-bin.000001 719 User var 2 719 @s5='abc'def' +slave-bin.000001 551 User var 2 551 @s1=_latin1'This is a test' COLLATE latin1_swedish_ci +slave-bin.000001 600 User var 2 600 @s2=_latin1'' COLLATE latin1_swedish_ci +slave-bin.000001 635 User var 2 635 @s3=_latin1'abc'def' COLLATE latin1_swedish_ci +slave-bin.000001 677 User var 2 677 @s4=_latin1'abc\def' COLLATE latin1_swedish_ci +slave-bin.000001 719 User var 2 719 @s5=_latin1'abc'def' COLLATE latin1_swedish_ci slave-bin.000001 761 Query 1 761 use `test`; insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5) slave-bin.000001 851 User var 2 851 @n1=NULL slave-bin.000001 877 Query 1 877 use `test`; insert into t1 values (@n1) @@ -99,7 +99,7 @@ slave-bin.000001 965 Query 1 965 use `test`; insert into t1 values (@n2) slave-bin.000001 1027 Query 1 1027 use `test`; insert into t1 values (@a:=0), (@a:=@a+1), (@a:=@a+1) slave-bin.000001 1115 User var 2 1115 @a=2 slave-bin.000001 1157 Query 1 1157 use `test`; insert into t1 values (@a+(@b:=@a+1)) -slave-bin.000001 1229 User var 2 1229 @q='abc' +slave-bin.000001 1229 User var 2 1229 @q=_latin1'abc' COLLATE latin1_swedish_ci slave-bin.000001 1266 Query 1 1266 use `test`; insert t1 values (@q), (@q:=concat(@q, 'n1')), (@q:=concat(@q, 'n2')) slave-bin.000001 1370 User var 2 1370 @a=5 slave-bin.000001 1412 Query 1 1412 use `test`; insert into t1 values (@a),(@a) diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index a9351d2f1fb..605780a7280 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -162,3 +162,36 @@ charset(@a) collation(@a) coercibility(@a) latin2 latin2_bin 0 select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci; ERROR HY000: Illegal mix of collations (latin2_bin,EXPLICIT) and (latin2_general_ci,EXPLICIT) for operation '=' +create table t1 (a varchar(50)); +reset master; +SET TIMESTAMP=10000; +SET @`a b`='hello'; +INSERT INTO t1 VALUES(@`a b`); +set @var1= "';aaa"; +insert into t1 values (@var1); +create table t2 (c char(30)) charset=ucs2; +set @v=convert('abc' using ucs2); +insert into t2 values (@v); +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.000001 79 User var 1 79 @`a b`=_latin1'hello' COLLATE latin1_swedish_ci +master-bin.000001 120 Query 1 120 use `test`; INSERT INTO t1 VALUES(@`a b`) +master-bin.000001 184 User var 1 184 @`var1`=_latin1'\';aaa' COLLATE latin1_swedish_ci +master-bin.000001 226 Query 1 226 use `test`; insert into t1 values (@var1) +master-bin.000001 290 Query 1 290 use `test`; create table t2 (c char(30)) charset=ucs2 +master-bin.000001 366 User var 1 366 @`v`=_ucs2'\0a\0b\0c' COLLATE ucs2_general_ci +master-bin.000001 406 Query 1 406 use `test`; insert into t2 values (@v) +/*!40019 SET @@session.max_insert_delayed_threads=0*/; +SET @`a b`:=_latin1'hello' COLLATE latin1_swedish_ci; +use test; +SET TIMESTAMP=10000; +INSERT INTO t1 VALUES(@`a b`); +SET @`var1`:=_latin1'\';aaa' COLLATE latin1_swedish_ci; +SET TIMESTAMP=10000; +insert into t1 values (@var1); +SET TIMESTAMP=10000; +create table t2 (c char(30)) charset=ucs2; +SET @`v`:=_ucs2'\0a\0b\0c' COLLATE ucs2_general_ci; +SET TIMESTAMP=10000; +insert into t2 values (@v); +drop table t1, t2; diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test new file mode 100644 index 00000000000..5c2e73e5af7 --- /dev/null +++ b/mysql-test/t/archive.test @@ -0,0 +1,1300 @@ +# +# Simple test for archive example +# Taken fromm the select test +# +-- source include/have_archive.inc + +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +CREATE TABLE t1 ( + Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, + Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL +) ENGINE=archive; + +INSERT INTO t1 VALUES (9410,9412); + +select period from t1; +select * from t1; +select t1.* from t1; + +# +# Create test table +# + +CREATE TABLE t2 ( + auto int, + fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL, + companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL, + fld3 char(30) DEFAULT '' NOT NULL, + fld4 char(35) DEFAULT '' NOT NULL, + fld5 char(35) DEFAULT '' NOT NULL, + fld6 char(4) DEFAULT '' NOT NULL +) ENGINE=archive; + +# +# Populate table +# + +--disable_query_log +INSERT INTO t2 VALUES (1,000001,00,'Omaha','teethe','neat',''); +INSERT INTO t2 VALUES (2,011401,37,'breaking','dreaded','Steinberg','W'); +INSERT INTO t2 VALUES (3,011402,37,'Romans','scholastics','jarring',''); +INSERT INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); +INSERT INTO t2 VALUES (5,011501,37,'bewilderingly','wallet','balled',''); +INSERT INTO t2 VALUES (6,011701,37,'astound','parters','persist','W'); +INSERT INTO t2 VALUES (7,011702,37,'admonishing','eschew','attainments',''); +INSERT INTO t2 VALUES (8,011703,37,'sumac','quitter','fanatic',''); +INSERT INTO t2 VALUES (9,012001,37,'flanking','neat','measures','FAS'); +INSERT INTO t2 VALUES (10,012003,37,'combed','Steinberg','rightfulness',''); +INSERT INTO t2 VALUES (11,012004,37,'subjective','jarring','capably',''); +INSERT INTO t2 VALUES (12,012005,37,'scatterbrain','tinily','impulsive',''); +INSERT INTO t2 VALUES (13,012301,37,'Eulerian','balled','starlet',''); +INSERT INTO t2 VALUES (14,012302,36,'dubbed','persist','terminators',''); +INSERT INTO t2 VALUES (15,012303,37,'Kane','attainments','untying',''); +INSERT INTO t2 VALUES (16,012304,37,'overlay','fanatic','announces','FAS'); +INSERT INTO t2 VALUES (17,012305,37,'perturb','measures','featherweight','FAS'); +INSERT INTO t2 VALUES (18,012306,37,'goblins','rightfulness','pessimist','FAS'); +INSERT INTO t2 VALUES (19,012501,37,'annihilates','capably','daughter',''); +INSERT INTO t2 VALUES (20,012602,37,'Wotan','impulsive','decliner','FAS'); +INSERT INTO t2 VALUES (21,012603,37,'snatching','starlet','lawgiver',''); +INSERT INTO t2 VALUES (22,012604,37,'concludes','terminators','stated',''); +INSERT INTO t2 VALUES (23,012605,37,'laterally','untying','readable',''); +INSERT INTO t2 VALUES (24,012606,37,'yelped','announces','attrition',''); +INSERT INTO t2 VALUES (25,012701,37,'grazing','featherweight','cascade','FAS'); +INSERT INTO t2 VALUES (26,012702,37,'Baird','pessimist','motors','FAS'); +INSERT INTO t2 VALUES (27,012703,37,'celery','daughter','interrogate',''); +INSERT INTO t2 VALUES (28,012704,37,'misunderstander','decliner','pests','W'); +INSERT INTO t2 VALUES (29,013601,37,'handgun','lawgiver','stairway',''); +INSERT INTO t2 VALUES (30,013602,37,'foldout','stated','dopers','FAS'); +INSERT INTO t2 VALUES (31,013603,37,'mystic','readable','testicle','W'); +INSERT INTO t2 VALUES (32,013604,37,'succumbed','attrition','Parsifal','W'); +INSERT INTO t2 VALUES (33,013605,37,'Nabisco','cascade','leavings',''); +INSERT INTO t2 VALUES (34,013606,37,'fingerings','motors','postulation','W'); +INSERT INTO t2 VALUES (35,013607,37,'aging','interrogate','squeaking',''); +INSERT INTO t2 VALUES (36,013608,37,'afield','pests','contrasted',''); +INSERT INTO t2 VALUES (37,013609,37,'ammonium','stairway','leftover',''); +INSERT INTO t2 VALUES (38,013610,37,'boat','dopers','whiteners',''); +INSERT INTO t2 VALUES (39,013801,37,'intelligibility','testicle','erases','W'); +INSERT INTO t2 VALUES (40,013802,37,'Augustine','Parsifal','Punjab','W'); +INSERT INTO t2 VALUES (41,013803,37,'teethe','leavings','Merritt',''); +INSERT INTO t2 VALUES (42,013804,37,'dreaded','postulation','Quixotism',''); +INSERT INTO t2 VALUES (43,013901,37,'scholastics','squeaking','sweetish','FAS'); +INSERT INTO t2 VALUES (44,016001,37,'audiology','contrasted','dogging','FAS'); +INSERT INTO t2 VALUES (45,016201,37,'wallet','leftover','scornfully','FAS'); +INSERT INTO t2 VALUES (46,016202,37,'parters','whiteners','bellow',''); +INSERT INTO t2 VALUES (47,016301,37,'eschew','erases','bills',''); +INSERT INTO t2 VALUES (48,016302,37,'quitter','Punjab','cupboard','FAS'); +INSERT INTO t2 VALUES (49,016303,37,'neat','Merritt','sureties','FAS'); +INSERT INTO t2 VALUES (50,016304,37,'Steinberg','Quixotism','puddings',''); +INSERT INTO t2 VALUES (51,018001,37,'jarring','sweetish','tapestry',''); +INSERT INTO t2 VALUES (52,018002,37,'tinily','dogging','fetters',''); +INSERT INTO t2 VALUES (53,018003,37,'balled','scornfully','bivalves',''); +INSERT INTO t2 VALUES (54,018004,37,'persist','bellow','incurring',''); +INSERT INTO t2 VALUES (55,018005,37,'attainments','bills','Adolph',''); +INSERT INTO t2 VALUES (56,018007,37,'fanatic','cupboard','pithed',''); +INSERT INTO t2 VALUES (57,018008,37,'measures','sureties','emergency',''); +INSERT INTO t2 VALUES (58,018009,37,'rightfulness','puddings','Miles',''); +INSERT INTO t2 VALUES (59,018010,37,'capably','tapestry','trimmings',''); +INSERT INTO t2 VALUES (60,018012,37,'impulsive','fetters','tragedies','W'); +INSERT INTO t2 VALUES (61,018013,37,'starlet','bivalves','skulking','W'); +INSERT INTO t2 VALUES (62,018014,37,'terminators','incurring','flint',''); +INSERT INTO t2 VALUES (63,018015,37,'untying','Adolph','flopping','W'); +INSERT INTO t2 VALUES (64,018016,37,'announces','pithed','relaxing','FAS'); +INSERT INTO t2 VALUES (65,018017,37,'featherweight','emergency','offload','FAS'); +INSERT INTO t2 VALUES (66,018018,37,'pessimist','Miles','suites','W'); +INSERT INTO t2 VALUES (67,018019,37,'daughter','trimmings','lists','FAS'); +INSERT INTO t2 VALUES (68,018020,37,'decliner','tragedies','animized','FAS'); +INSERT INTO t2 VALUES (69,018021,37,'lawgiver','skulking','multilayer','W'); +INSERT INTO t2 VALUES (70,018022,37,'stated','flint','standardizes','FAS'); +INSERT INTO t2 VALUES (71,018023,37,'readable','flopping','Judas',''); +INSERT INTO t2 VALUES (72,018024,37,'attrition','relaxing','vacuuming','W'); +INSERT INTO t2 VALUES (73,018025,37,'cascade','offload','dentally','W'); +INSERT INTO t2 VALUES (74,018026,37,'motors','suites','humanness','W'); +INSERT INTO t2 VALUES (75,018027,37,'interrogate','lists','inch','W'); +INSERT INTO t2 VALUES (76,018028,37,'pests','animized','Weissmuller','W'); +INSERT INTO t2 VALUES (77,018029,37,'stairway','multilayer','irresponsibly','W'); +INSERT INTO t2 VALUES (78,018030,37,'dopers','standardizes','luckily','FAS'); +INSERT INTO t2 VALUES (79,018032,37,'testicle','Judas','culled','W'); +INSERT INTO t2 VALUES (80,018033,37,'Parsifal','vacuuming','medical','FAS'); +INSERT INTO t2 VALUES (81,018034,37,'leavings','dentally','bloodbath','FAS'); +INSERT INTO t2 VALUES (82,018035,37,'postulation','humanness','subschema','W'); +INSERT INTO t2 VALUES (83,018036,37,'squeaking','inch','animals','W'); +INSERT INTO t2 VALUES (84,018037,37,'contrasted','Weissmuller','Micronesia',''); +INSERT INTO t2 VALUES (85,018038,37,'leftover','irresponsibly','repetitions',''); +INSERT INTO t2 VALUES (86,018039,37,'whiteners','luckily','Antares',''); +INSERT INTO t2 VALUES (87,018040,37,'erases','culled','ventilate','W'); +INSERT INTO t2 VALUES (88,018041,37,'Punjab','medical','pityingly',''); +INSERT INTO t2 VALUES (89,018042,37,'Merritt','bloodbath','interdependent',''); +INSERT INTO t2 VALUES (90,018043,37,'Quixotism','subschema','Graves','FAS'); +INSERT INTO t2 VALUES (91,018044,37,'sweetish','animals','neonatal',''); +INSERT INTO t2 VALUES (92,018045,37,'dogging','Micronesia','scribbled','FAS'); +INSERT INTO t2 VALUES (93,018046,37,'scornfully','repetitions','chafe','W'); +INSERT INTO t2 VALUES (94,018048,37,'bellow','Antares','honoring',''); +INSERT INTO t2 VALUES (95,018049,37,'bills','ventilate','realtor',''); +INSERT INTO t2 VALUES (96,018050,37,'cupboard','pityingly','elite',''); +INSERT INTO t2 VALUES (97,018051,37,'sureties','interdependent','funereal',''); +INSERT INTO t2 VALUES (98,018052,37,'puddings','Graves','abrogating',''); +INSERT INTO t2 VALUES (99,018053,50,'tapestry','neonatal','sorters',''); +INSERT INTO t2 VALUES (100,018054,37,'fetters','scribbled','Conley',''); +INSERT INTO t2 VALUES (101,018055,37,'bivalves','chafe','lectured',''); +INSERT INTO t2 VALUES (102,018056,37,'incurring','honoring','Abraham',''); +INSERT INTO t2 VALUES (103,018057,37,'Adolph','realtor','Hawaii','W'); +INSERT INTO t2 VALUES (104,018058,37,'pithed','elite','cage',''); +INSERT INTO t2 VALUES (105,018059,36,'emergency','funereal','hushes',''); +INSERT INTO t2 VALUES (106,018060,37,'Miles','abrogating','Simla',''); +INSERT INTO t2 VALUES (107,018061,37,'trimmings','sorters','reporters',''); +INSERT INTO t2 VALUES (108,018101,37,'tragedies','Conley','Dutchman','FAS'); +INSERT INTO t2 VALUES (109,018102,37,'skulking','lectured','descendants','FAS'); +INSERT INTO t2 VALUES (110,018103,37,'flint','Abraham','groupings','FAS'); +INSERT INTO t2 VALUES (111,018104,37,'flopping','Hawaii','dissociate',''); +INSERT INTO t2 VALUES (112,018201,37,'relaxing','cage','coexist','W'); +INSERT INTO t2 VALUES (113,018202,37,'offload','hushes','Beebe',''); +INSERT INTO t2 VALUES (114,018402,37,'suites','Simla','Taoism',''); +INSERT INTO t2 VALUES (115,018403,37,'lists','reporters','Connally',''); +INSERT INTO t2 VALUES (116,018404,37,'animized','Dutchman','fetched','FAS'); +INSERT INTO t2 VALUES (117,018405,37,'multilayer','descendants','checkpoints','FAS'); +INSERT INTO t2 VALUES (118,018406,37,'standardizes','groupings','rusting',''); +INSERT INTO t2 VALUES (119,018409,37,'Judas','dissociate','galling',''); +INSERT INTO t2 VALUES (120,018601,37,'vacuuming','coexist','obliterates',''); +INSERT INTO t2 VALUES (121,018602,37,'dentally','Beebe','traitor',''); +INSERT INTO t2 VALUES (122,018603,37,'humanness','Taoism','resumes','FAS'); +INSERT INTO t2 VALUES (123,018801,37,'inch','Connally','analyzable','FAS'); +INSERT INTO t2 VALUES (124,018802,37,'Weissmuller','fetched','terminator','FAS'); +INSERT INTO t2 VALUES (125,018803,37,'irresponsibly','checkpoints','gritty','FAS'); +INSERT INTO t2 VALUES (126,018804,37,'luckily','rusting','firearm','W'); +INSERT INTO t2 VALUES (127,018805,37,'culled','galling','minima',''); +INSERT INTO t2 VALUES (128,018806,37,'medical','obliterates','Selfridge',''); +INSERT INTO t2 VALUES (129,018807,37,'bloodbath','traitor','disable',''); +INSERT INTO t2 VALUES (130,018808,37,'subschema','resumes','witchcraft','W'); +INSERT INTO t2 VALUES (131,018809,37,'animals','analyzable','betroth','W'); +INSERT INTO t2 VALUES (132,018810,37,'Micronesia','terminator','Manhattanize',''); +INSERT INTO t2 VALUES (133,018811,37,'repetitions','gritty','imprint',''); +INSERT INTO t2 VALUES (134,018812,37,'Antares','firearm','peeked',''); +INSERT INTO t2 VALUES (135,019101,37,'ventilate','minima','swelling',''); +INSERT INTO t2 VALUES (136,019102,37,'pityingly','Selfridge','interrelationships','W'); +INSERT INTO t2 VALUES (137,019103,37,'interdependent','disable','riser',''); +INSERT INTO t2 VALUES (138,019201,37,'Graves','witchcraft','Gandhian','W'); +INSERT INTO t2 VALUES (139,030501,37,'neonatal','betroth','peacock','A'); +INSERT INTO t2 VALUES (140,030502,50,'scribbled','Manhattanize','bee','A'); +INSERT INTO t2 VALUES (141,030503,37,'chafe','imprint','kanji',''); +INSERT INTO t2 VALUES (142,030504,37,'honoring','peeked','dental',''); +INSERT INTO t2 VALUES (143,031901,37,'realtor','swelling','scarf','FAS'); +INSERT INTO t2 VALUES (144,036001,37,'elite','interrelationships','chasm','A'); +INSERT INTO t2 VALUES (145,036002,37,'funereal','riser','insolence','A'); +INSERT INTO t2 VALUES (146,036004,37,'abrogating','Gandhian','syndicate',''); +INSERT INTO t2 VALUES (147,036005,37,'sorters','peacock','alike',''); +INSERT INTO t2 VALUES (148,038001,37,'Conley','bee','imperial','A'); +INSERT INTO t2 VALUES (149,038002,37,'lectured','kanji','convulsion','A'); +INSERT INTO t2 VALUES (150,038003,37,'Abraham','dental','railway','A'); +INSERT INTO t2 VALUES (151,038004,37,'Hawaii','scarf','validate','A'); +INSERT INTO t2 VALUES (152,038005,37,'cage','chasm','normalizes','A'); +INSERT INTO t2 VALUES (153,038006,37,'hushes','insolence','comprehensive',''); +INSERT INTO t2 VALUES (154,038007,37,'Simla','syndicate','chewing',''); +INSERT INTO t2 VALUES (155,038008,37,'reporters','alike','denizen',''); +INSERT INTO t2 VALUES (156,038009,37,'Dutchman','imperial','schemer',''); +INSERT INTO t2 VALUES (157,038010,37,'descendants','convulsion','chronicle',''); +INSERT INTO t2 VALUES (158,038011,37,'groupings','railway','Kline',''); +INSERT INTO t2 VALUES (159,038012,37,'dissociate','validate','Anatole',''); +INSERT INTO t2 VALUES (160,038013,37,'coexist','normalizes','partridges',''); +INSERT INTO t2 VALUES (161,038014,37,'Beebe','comprehensive','brunch',''); +INSERT INTO t2 VALUES (162,038015,37,'Taoism','chewing','recruited',''); +INSERT INTO t2 VALUES (163,038016,37,'Connally','denizen','dimensions','W'); +INSERT INTO t2 VALUES (164,038017,37,'fetched','schemer','Chicana','W'); +INSERT INTO t2 VALUES (165,038018,37,'checkpoints','chronicle','announced',''); +INSERT INTO t2 VALUES (166,038101,37,'rusting','Kline','praised','FAS'); +INSERT INTO t2 VALUES (167,038102,37,'galling','Anatole','employing',''); +INSERT INTO t2 VALUES (168,038103,37,'obliterates','partridges','linear',''); +INSERT INTO t2 VALUES (169,038104,37,'traitor','brunch','quagmire',''); +INSERT INTO t2 VALUES (170,038201,37,'resumes','recruited','western','A'); +INSERT INTO t2 VALUES (171,038202,37,'analyzable','dimensions','relishing',''); +INSERT INTO t2 VALUES (172,038203,37,'terminator','Chicana','serving','A'); +INSERT INTO t2 VALUES (173,038204,37,'gritty','announced','scheduling',''); +INSERT INTO t2 VALUES (174,038205,37,'firearm','praised','lore',''); +INSERT INTO t2 VALUES (175,038206,37,'minima','employing','eventful',''); +INSERT INTO t2 VALUES (176,038208,37,'Selfridge','linear','arteriole','A'); +INSERT INTO t2 VALUES (177,042801,37,'disable','quagmire','disentangle',''); +INSERT INTO t2 VALUES (178,042802,37,'witchcraft','western','cured','A'); +INSERT INTO t2 VALUES (179,046101,37,'betroth','relishing','Fenton','W'); +INSERT INTO t2 VALUES (180,048001,37,'Manhattanize','serving','avoidable','A'); +INSERT INTO t2 VALUES (181,048002,37,'imprint','scheduling','drains','A'); +INSERT INTO t2 VALUES (182,048003,37,'peeked','lore','detectably','FAS'); +INSERT INTO t2 VALUES (183,048004,37,'swelling','eventful','husky',''); +INSERT INTO t2 VALUES (184,048005,37,'interrelationships','arteriole','impelling',''); +INSERT INTO t2 VALUES (185,048006,37,'riser','disentangle','undoes',''); +INSERT INTO t2 VALUES (186,048007,37,'Gandhian','cured','evened',''); +INSERT INTO t2 VALUES (187,048008,37,'peacock','Fenton','squeezes',''); +INSERT INTO t2 VALUES (188,048101,37,'bee','avoidable','destroyer','FAS'); +INSERT INTO t2 VALUES (189,048102,37,'kanji','drains','rudeness',''); +INSERT INTO t2 VALUES (190,048201,37,'dental','detectably','beaner','FAS'); +INSERT INTO t2 VALUES (191,048202,37,'scarf','husky','boorish',''); +INSERT INTO t2 VALUES (192,048203,37,'chasm','impelling','Everhart',''); +INSERT INTO t2 VALUES (193,048204,37,'insolence','undoes','encompass','A'); +INSERT INTO t2 VALUES (194,048205,37,'syndicate','evened','mushrooms',''); +INSERT INTO t2 VALUES (195,048301,37,'alike','squeezes','Alison','A'); +INSERT INTO t2 VALUES (196,048302,37,'imperial','destroyer','externally','FAS'); +INSERT INTO t2 VALUES (197,048303,37,'convulsion','rudeness','pellagra',''); +INSERT INTO t2 VALUES (198,048304,37,'railway','beaner','cult',''); +INSERT INTO t2 VALUES (199,048305,37,'validate','boorish','creek','A'); +INSERT INTO t2 VALUES (200,048401,37,'normalizes','Everhart','Huffman',''); +INSERT INTO t2 VALUES (201,048402,37,'comprehensive','encompass','Majorca','FAS'); +INSERT INTO t2 VALUES (202,048403,37,'chewing','mushrooms','governing','A'); +INSERT INTO t2 VALUES (203,048404,37,'denizen','Alison','gadfly','FAS'); +INSERT INTO t2 VALUES (204,048405,37,'schemer','externally','reassigned','FAS'); +INSERT INTO t2 VALUES (205,048406,37,'chronicle','pellagra','intentness','W'); +INSERT INTO t2 VALUES (206,048407,37,'Kline','cult','craziness',''); +INSERT INTO t2 VALUES (207,048408,37,'Anatole','creek','psychic',''); +INSERT INTO t2 VALUES (208,048409,37,'partridges','Huffman','squabbled',''); +INSERT INTO t2 VALUES (209,048410,37,'brunch','Majorca','burlesque',''); +INSERT INTO t2 VALUES (210,048411,37,'recruited','governing','capped',''); +INSERT INTO t2 VALUES (211,048412,37,'dimensions','gadfly','extracted','A'); +INSERT INTO t2 VALUES (212,048413,37,'Chicana','reassigned','DiMaggio',''); +INSERT INTO t2 VALUES (213,048601,37,'announced','intentness','exclamation','FAS'); +INSERT INTO t2 VALUES (214,048602,37,'praised','craziness','subdirectory',''); +INSERT INTO t2 VALUES (215,048603,37,'employing','psychic','fangs',''); +INSERT INTO t2 VALUES (216,048604,37,'linear','squabbled','buyer','A'); +INSERT INTO t2 VALUES (217,048801,37,'quagmire','burlesque','pithing','A'); +INSERT INTO t2 VALUES (218,050901,37,'western','capped','transistorizing','A'); +INSERT INTO t2 VALUES (219,051201,37,'relishing','extracted','nonbiodegradable',''); +INSERT INTO t2 VALUES (220,056002,37,'serving','DiMaggio','dislocate',''); +INSERT INTO t2 VALUES (221,056003,37,'scheduling','exclamation','monochromatic','FAS'); +INSERT INTO t2 VALUES (222,056004,37,'lore','subdirectory','batting',''); +INSERT INTO t2 VALUES (223,056102,37,'eventful','fangs','postcondition','A'); +INSERT INTO t2 VALUES (224,056203,37,'arteriole','buyer','catalog','FAS'); +INSERT INTO t2 VALUES (225,056204,37,'disentangle','pithing','Remus',''); +INSERT INTO t2 VALUES (226,058003,37,'cured','transistorizing','devices','A'); +INSERT INTO t2 VALUES (227,058004,37,'Fenton','nonbiodegradable','bike','A'); +INSERT INTO t2 VALUES (228,058005,37,'avoidable','dislocate','qualify',''); +INSERT INTO t2 VALUES (229,058006,37,'drains','monochromatic','detained',''); +INSERT INTO t2 VALUES (230,058007,37,'detectably','batting','commended',''); +INSERT INTO t2 VALUES (231,058101,37,'husky','postcondition','civilize',''); +INSERT INTO t2 VALUES (232,058102,37,'impelling','catalog','Elmhurst',''); +INSERT INTO t2 VALUES (233,058103,37,'undoes','Remus','anesthetizing',''); +INSERT INTO t2 VALUES (234,058105,37,'evened','devices','deaf',''); +INSERT INTO t2 VALUES (235,058111,37,'squeezes','bike','Brigham',''); +INSERT INTO t2 VALUES (236,058112,37,'destroyer','qualify','title',''); +INSERT INTO t2 VALUES (237,058113,37,'rudeness','detained','coarse',''); +INSERT INTO t2 VALUES (238,058114,37,'beaner','commended','combinations',''); +INSERT INTO t2 VALUES (239,058115,37,'boorish','civilize','grayness',''); +INSERT INTO t2 VALUES (240,058116,37,'Everhart','Elmhurst','innumerable','FAS'); +INSERT INTO t2 VALUES (241,058117,37,'encompass','anesthetizing','Caroline','A'); +INSERT INTO t2 VALUES (242,058118,37,'mushrooms','deaf','fatty','FAS'); +INSERT INTO t2 VALUES (243,058119,37,'Alison','Brigham','eastbound',''); +INSERT INTO t2 VALUES (244,058120,37,'externally','title','inexperienced',''); +INSERT INTO t2 VALUES (245,058121,37,'pellagra','coarse','hoarder','A'); +INSERT INTO t2 VALUES (246,058122,37,'cult','combinations','scotch','W'); +INSERT INTO t2 VALUES (247,058123,37,'creek','grayness','passport','A'); +INSERT INTO t2 VALUES (248,058124,37,'Huffman','innumerable','strategic','FAS'); +INSERT INTO t2 VALUES (249,058125,37,'Majorca','Caroline','gated',''); +INSERT INTO t2 VALUES (250,058126,37,'governing','fatty','flog',''); +INSERT INTO t2 VALUES (251,058127,37,'gadfly','eastbound','Pipestone',''); +INSERT INTO t2 VALUES (252,058128,37,'reassigned','inexperienced','Dar',''); +INSERT INTO t2 VALUES (253,058201,37,'intentness','hoarder','Corcoran',''); +INSERT INTO t2 VALUES (254,058202,37,'craziness','scotch','flyers','A'); +INSERT INTO t2 VALUES (255,058303,37,'psychic','passport','competitions','W'); +INSERT INTO t2 VALUES (256,058304,37,'squabbled','strategic','suppliers','FAS'); +INSERT INTO t2 VALUES (257,058602,37,'burlesque','gated','skips',''); +INSERT INTO t2 VALUES (258,058603,37,'capped','flog','institutes',''); +INSERT INTO t2 VALUES (259,058604,37,'extracted','Pipestone','troop','A'); +INSERT INTO t2 VALUES (260,058605,37,'DiMaggio','Dar','connective','W'); +INSERT INTO t2 VALUES (261,058606,37,'exclamation','Corcoran','denies',''); +INSERT INTO t2 VALUES (262,058607,37,'subdirectory','flyers','polka',''); +INSERT INTO t2 VALUES (263,060401,36,'fangs','competitions','observations','FAS'); +INSERT INTO t2 VALUES (264,061701,36,'buyer','suppliers','askers',''); +INSERT INTO t2 VALUES (265,066201,36,'pithing','skips','homeless','FAS'); +INSERT INTO t2 VALUES (266,066501,36,'transistorizing','institutes','Anna',''); +INSERT INTO t2 VALUES (267,068001,36,'nonbiodegradable','troop','subdirectories','W'); +INSERT INTO t2 VALUES (268,068002,36,'dislocate','connective','decaying','FAS'); +INSERT INTO t2 VALUES (269,068005,36,'monochromatic','denies','outwitting','W'); +INSERT INTO t2 VALUES (270,068006,36,'batting','polka','Harpy','W'); +INSERT INTO t2 VALUES (271,068007,36,'postcondition','observations','crazed',''); +INSERT INTO t2 VALUES (272,068008,36,'catalog','askers','suffocate',''); +INSERT INTO t2 VALUES (273,068009,36,'Remus','homeless','provers','FAS'); +INSERT INTO t2 VALUES (274,068010,36,'devices','Anna','technically',''); +INSERT INTO t2 VALUES (275,068011,36,'bike','subdirectories','Franklinizations',''); +INSERT INTO t2 VALUES (276,068202,36,'qualify','decaying','considered',''); +INSERT INTO t2 VALUES (277,068302,36,'detained','outwitting','tinnily',''); +INSERT INTO t2 VALUES (278,068303,36,'commended','Harpy','uninterruptedly',''); +INSERT INTO t2 VALUES (279,068401,36,'civilize','crazed','whistled','A'); +INSERT INTO t2 VALUES (280,068501,36,'Elmhurst','suffocate','automate',''); +INSERT INTO t2 VALUES (281,068502,36,'anesthetizing','provers','gutting','W'); +INSERT INTO t2 VALUES (282,068503,36,'deaf','technically','surreptitious',''); +INSERT INTO t2 VALUES (283,068602,36,'Brigham','Franklinizations','Choctaw',''); +INSERT INTO t2 VALUES (284,068603,36,'title','considered','cooks',''); +INSERT INTO t2 VALUES (285,068701,36,'coarse','tinnily','millivolt','FAS'); +INSERT INTO t2 VALUES (286,068702,36,'combinations','uninterruptedly','counterpoise',''); +INSERT INTO t2 VALUES (287,068703,36,'grayness','whistled','Gothicism',''); +INSERT INTO t2 VALUES (288,076001,36,'innumerable','automate','feminine',''); +INSERT INTO t2 VALUES (289,076002,36,'Caroline','gutting','metaphysically','W'); +INSERT INTO t2 VALUES (290,076101,36,'fatty','surreptitious','sanding','A'); +INSERT INTO t2 VALUES (291,076102,36,'eastbound','Choctaw','contributorily',''); +INSERT INTO t2 VALUES (292,076103,36,'inexperienced','cooks','receivers','FAS'); +INSERT INTO t2 VALUES (293,076302,36,'hoarder','millivolt','adjourn',''); +INSERT INTO t2 VALUES (294,076303,36,'scotch','counterpoise','straggled','A'); +INSERT INTO t2 VALUES (295,076304,36,'passport','Gothicism','druggists',''); +INSERT INTO t2 VALUES (296,076305,36,'strategic','feminine','thanking','FAS'); +INSERT INTO t2 VALUES (297,076306,36,'gated','metaphysically','ostrich',''); +INSERT INTO t2 VALUES (298,076307,36,'flog','sanding','hopelessness','FAS'); +INSERT INTO t2 VALUES (299,076402,36,'Pipestone','contributorily','Eurydice',''); +INSERT INTO t2 VALUES (300,076501,36,'Dar','receivers','excitation','W'); +INSERT INTO t2 VALUES (301,076502,36,'Corcoran','adjourn','presumes','FAS'); +INSERT INTO t2 VALUES (302,076701,36,'flyers','straggled','imaginable','FAS'); +INSERT INTO t2 VALUES (303,078001,36,'competitions','druggists','concoct','W'); +INSERT INTO t2 VALUES (304,078002,36,'suppliers','thanking','peering','W'); +INSERT INTO t2 VALUES (305,078003,36,'skips','ostrich','Phelps','FAS'); +INSERT INTO t2 VALUES (306,078004,36,'institutes','hopelessness','ferociousness','FAS'); +INSERT INTO t2 VALUES (307,078005,36,'troop','Eurydice','sentences',''); +INSERT INTO t2 VALUES (308,078006,36,'connective','excitation','unlocks',''); +INSERT INTO t2 VALUES (309,078007,36,'denies','presumes','engrossing','W'); +INSERT INTO t2 VALUES (310,078008,36,'polka','imaginable','Ruth',''); +INSERT INTO t2 VALUES (311,078101,36,'observations','concoct','tying',''); +INSERT INTO t2 VALUES (312,078103,36,'askers','peering','exclaimers',''); +INSERT INTO t2 VALUES (313,078104,36,'homeless','Phelps','synergy',''); +INSERT INTO t2 VALUES (314,078105,36,'Anna','ferociousness','Huey','W'); +INSERT INTO t2 VALUES (315,082101,36,'subdirectories','sentences','merging',''); +INSERT INTO t2 VALUES (316,083401,36,'decaying','unlocks','judges','A'); +INSERT INTO t2 VALUES (317,084001,36,'outwitting','engrossing','Shylock','W'); +INSERT INTO t2 VALUES (318,084002,36,'Harpy','Ruth','Miltonism',''); +INSERT INTO t2 VALUES (319,086001,36,'crazed','tying','hen','W'); +INSERT INTO t2 VALUES (320,086102,36,'suffocate','exclaimers','honeybee','FAS'); +INSERT INTO t2 VALUES (321,086201,36,'provers','synergy','towers',''); +INSERT INTO t2 VALUES (322,088001,36,'technically','Huey','dilutes','W'); +INSERT INTO t2 VALUES (323,088002,36,'Franklinizations','merging','numerals','FAS'); +INSERT INTO t2 VALUES (324,088003,36,'considered','judges','democracy','FAS'); +INSERT INTO t2 VALUES (325,088004,36,'tinnily','Shylock','Ibero-',''); +INSERT INTO t2 VALUES (326,088101,36,'uninterruptedly','Miltonism','invalids',''); +INSERT INTO t2 VALUES (327,088102,36,'whistled','hen','behavior',''); +INSERT INTO t2 VALUES (328,088103,36,'automate','honeybee','accruing',''); +INSERT INTO t2 VALUES (329,088104,36,'gutting','towers','relics','A'); +INSERT INTO t2 VALUES (330,088105,36,'surreptitious','dilutes','rackets',''); +INSERT INTO t2 VALUES (331,088106,36,'Choctaw','numerals','Fischbein','W'); +INSERT INTO t2 VALUES (332,088201,36,'cooks','democracy','phony','W'); +INSERT INTO t2 VALUES (333,088203,36,'millivolt','Ibero-','cross','FAS'); +INSERT INTO t2 VALUES (334,088204,36,'counterpoise','invalids','cleanup',''); +INSERT INTO t2 VALUES (335,088302,37,'Gothicism','behavior','conspirator',''); +INSERT INTO t2 VALUES (336,088303,37,'feminine','accruing','label','FAS'); +INSERT INTO t2 VALUES (337,088305,37,'metaphysically','relics','university',''); +INSERT INTO t2 VALUES (338,088402,37,'sanding','rackets','cleansed','FAS'); +INSERT INTO t2 VALUES (339,088501,36,'contributorily','Fischbein','ballgown',''); +INSERT INTO t2 VALUES (340,088502,36,'receivers','phony','starlet',''); +INSERT INTO t2 VALUES (341,088503,36,'adjourn','cross','aqueous',''); +INSERT INTO t2 VALUES (342,098001,58,'straggled','cleanup','portrayal','A'); +INSERT INTO t2 VALUES (343,098002,58,'druggists','conspirator','despising','W'); +INSERT INTO t2 VALUES (344,098003,58,'thanking','label','distort','W'); +INSERT INTO t2 VALUES (345,098004,58,'ostrich','university','palmed',''); +INSERT INTO t2 VALUES (346,098005,58,'hopelessness','cleansed','faced',''); +INSERT INTO t2 VALUES (347,098006,58,'Eurydice','ballgown','silverware',''); +INSERT INTO t2 VALUES (348,141903,29,'excitation','starlet','assessor',''); +INSERT INTO t2 VALUES (349,098008,58,'presumes','aqueous','spiders',''); +INSERT INTO t2 VALUES (350,098009,58,'imaginable','portrayal','artificially',''); +INSERT INTO t2 VALUES (351,098010,58,'concoct','despising','reminiscence',''); +INSERT INTO t2 VALUES (352,098011,58,'peering','distort','Mexican',''); +INSERT INTO t2 VALUES (353,098012,58,'Phelps','palmed','obnoxious',''); +INSERT INTO t2 VALUES (354,098013,58,'ferociousness','faced','fragile',''); +INSERT INTO t2 VALUES (355,098014,58,'sentences','silverware','apprehensible',''); +INSERT INTO t2 VALUES (356,098015,58,'unlocks','assessor','births',''); +INSERT INTO t2 VALUES (357,098016,58,'engrossing','spiders','garages',''); +INSERT INTO t2 VALUES (358,098017,58,'Ruth','artificially','panty',''); +INSERT INTO t2 VALUES (359,098018,58,'tying','reminiscence','anteater',''); +INSERT INTO t2 VALUES (360,098019,58,'exclaimers','Mexican','displacement','A'); +INSERT INTO t2 VALUES (361,098020,58,'synergy','obnoxious','drovers','A'); +INSERT INTO t2 VALUES (362,098021,58,'Huey','fragile','patenting','A'); +INSERT INTO t2 VALUES (363,098022,58,'merging','apprehensible','far','A'); +INSERT INTO t2 VALUES (364,098023,58,'judges','births','shrieks',''); +INSERT INTO t2 VALUES (365,098024,58,'Shylock','garages','aligning','W'); +INSERT INTO t2 VALUES (366,098025,37,'Miltonism','panty','pragmatism',''); +INSERT INTO t2 VALUES (367,106001,36,'hen','anteater','fevers','W'); +INSERT INTO t2 VALUES (368,108001,36,'honeybee','displacement','reexamines','A'); +INSERT INTO t2 VALUES (369,108002,36,'towers','drovers','occupancies',''); +INSERT INTO t2 VALUES (370,108003,36,'dilutes','patenting','sweats','FAS'); +INSERT INTO t2 VALUES (371,108004,36,'numerals','far','modulators',''); +INSERT INTO t2 VALUES (372,108005,36,'democracy','shrieks','demand','W'); +INSERT INTO t2 VALUES (373,108007,36,'Ibero-','aligning','Madeira',''); +INSERT INTO t2 VALUES (374,108008,36,'invalids','pragmatism','Viennese','W'); +INSERT INTO t2 VALUES (375,108009,36,'behavior','fevers','chillier','W'); +INSERT INTO t2 VALUES (376,108010,36,'accruing','reexamines','wildcats','FAS'); +INSERT INTO t2 VALUES (377,108011,36,'relics','occupancies','gentle',''); +INSERT INTO t2 VALUES (378,108012,36,'rackets','sweats','Angles','W'); +INSERT INTO t2 VALUES (379,108101,36,'Fischbein','modulators','accuracies',''); +INSERT INTO t2 VALUES (380,108102,36,'phony','demand','toggle',''); +INSERT INTO t2 VALUES (381,108103,36,'cross','Madeira','Mendelssohn','W'); +INSERT INTO t2 VALUES (382,108111,50,'cleanup','Viennese','behaviorally',''); +INSERT INTO t2 VALUES (383,108105,36,'conspirator','chillier','Rochford',''); +INSERT INTO t2 VALUES (384,108106,36,'label','wildcats','mirror','W'); +INSERT INTO t2 VALUES (385,108107,36,'university','gentle','Modula',''); +INSERT INTO t2 VALUES (386,108108,50,'cleansed','Angles','clobbering',''); +INSERT INTO t2 VALUES (387,108109,36,'ballgown','accuracies','chronography',''); +INSERT INTO t2 VALUES (388,108110,36,'starlet','toggle','Eskimoizeds',''); +INSERT INTO t2 VALUES (389,108201,36,'aqueous','Mendelssohn','British','W'); +INSERT INTO t2 VALUES (390,108202,36,'portrayal','behaviorally','pitfalls',''); +INSERT INTO t2 VALUES (391,108203,36,'despising','Rochford','verify','W'); +INSERT INTO t2 VALUES (392,108204,36,'distort','mirror','scatter','FAS'); +INSERT INTO t2 VALUES (393,108205,36,'palmed','Modula','Aztecan',''); +INSERT INTO t2 VALUES (394,108301,36,'faced','clobbering','acuity','W'); +INSERT INTO t2 VALUES (395,108302,36,'silverware','chronography','sinking','W'); +INSERT INTO t2 VALUES (396,112101,36,'assessor','Eskimoizeds','beasts','FAS'); +INSERT INTO t2 VALUES (397,112102,36,'spiders','British','Witt','W'); +INSERT INTO t2 VALUES (398,113701,36,'artificially','pitfalls','physicists','FAS'); +INSERT INTO t2 VALUES (399,116001,36,'reminiscence','verify','folksong','A'); +INSERT INTO t2 VALUES (400,116201,36,'Mexican','scatter','strokes','FAS'); +INSERT INTO t2 VALUES (401,116301,36,'obnoxious','Aztecan','crowder',''); +INSERT INTO t2 VALUES (402,116302,36,'fragile','acuity','merry',''); +INSERT INTO t2 VALUES (403,116601,36,'apprehensible','sinking','cadenced',''); +INSERT INTO t2 VALUES (404,116602,36,'births','beasts','alimony','A'); +INSERT INTO t2 VALUES (405,116603,36,'garages','Witt','principled','A'); +INSERT INTO t2 VALUES (406,116701,36,'panty','physicists','golfing',''); +INSERT INTO t2 VALUES (407,116702,36,'anteater','folksong','undiscovered',''); +INSERT INTO t2 VALUES (408,118001,36,'displacement','strokes','irritates',''); +INSERT INTO t2 VALUES (409,118002,36,'drovers','crowder','patriots','A'); +INSERT INTO t2 VALUES (410,118003,36,'patenting','merry','rooms','FAS'); +INSERT INTO t2 VALUES (411,118004,36,'far','cadenced','towering','W'); +INSERT INTO t2 VALUES (412,118005,36,'shrieks','alimony','displease',''); +INSERT INTO t2 VALUES (413,118006,36,'aligning','principled','photosensitive',''); +INSERT INTO t2 VALUES (414,118007,36,'pragmatism','golfing','inking',''); +INSERT INTO t2 VALUES (415,118008,36,'fevers','undiscovered','gainers',''); +INSERT INTO t2 VALUES (416,118101,36,'reexamines','irritates','leaning','A'); +INSERT INTO t2 VALUES (417,118102,36,'occupancies','patriots','hydrant','A'); +INSERT INTO t2 VALUES (418,118103,36,'sweats','rooms','preserve',''); +INSERT INTO t2 VALUES (419,118202,36,'modulators','towering','blinded','A'); +INSERT INTO t2 VALUES (420,118203,36,'demand','displease','interactions','A'); +INSERT INTO t2 VALUES (421,118204,36,'Madeira','photosensitive','Barry',''); +INSERT INTO t2 VALUES (422,118302,36,'Viennese','inking','whiteness','A'); +INSERT INTO t2 VALUES (423,118304,36,'chillier','gainers','pastimes','W'); +INSERT INTO t2 VALUES (424,118305,36,'wildcats','leaning','Edenization',''); +INSERT INTO t2 VALUES (425,118306,36,'gentle','hydrant','Muscat',''); +INSERT INTO t2 VALUES (426,118307,36,'Angles','preserve','assassinated',''); +INSERT INTO t2 VALUES (427,123101,36,'accuracies','blinded','labeled',''); +INSERT INTO t2 VALUES (428,123102,36,'toggle','interactions','glacial','A'); +INSERT INTO t2 VALUES (429,123301,36,'Mendelssohn','Barry','implied','W'); +INSERT INTO t2 VALUES (430,126001,36,'behaviorally','whiteness','bibliographies','W'); +INSERT INTO t2 VALUES (431,126002,36,'Rochford','pastimes','Buchanan',''); +INSERT INTO t2 VALUES (432,126003,36,'mirror','Edenization','forgivably','FAS'); +INSERT INTO t2 VALUES (433,126101,36,'Modula','Muscat','innuendo','A'); +INSERT INTO t2 VALUES (434,126301,36,'clobbering','assassinated','den','FAS'); +INSERT INTO t2 VALUES (435,126302,36,'chronography','labeled','submarines','W'); +INSERT INTO t2 VALUES (436,126402,36,'Eskimoizeds','glacial','mouthful','A'); +INSERT INTO t2 VALUES (437,126601,36,'British','implied','expiring',''); +INSERT INTO t2 VALUES (438,126602,36,'pitfalls','bibliographies','unfulfilled','FAS'); +INSERT INTO t2 VALUES (439,126702,36,'verify','Buchanan','precession',''); +INSERT INTO t2 VALUES (440,128001,36,'scatter','forgivably','nullified',''); +INSERT INTO t2 VALUES (441,128002,36,'Aztecan','innuendo','affects',''); +INSERT INTO t2 VALUES (442,128003,36,'acuity','den','Cynthia',''); +INSERT INTO t2 VALUES (443,128004,36,'sinking','submarines','Chablis','A'); +INSERT INTO t2 VALUES (444,128005,36,'beasts','mouthful','betterments','FAS'); +INSERT INTO t2 VALUES (445,128007,36,'Witt','expiring','advertising',''); +INSERT INTO t2 VALUES (446,128008,36,'physicists','unfulfilled','rubies','A'); +INSERT INTO t2 VALUES (447,128009,36,'folksong','precession','southwest','FAS'); +INSERT INTO t2 VALUES (448,128010,36,'strokes','nullified','superstitious','A'); +INSERT INTO t2 VALUES (449,128011,36,'crowder','affects','tabernacle','W'); +INSERT INTO t2 VALUES (450,128012,36,'merry','Cynthia','silk','A'); +INSERT INTO t2 VALUES (451,128013,36,'cadenced','Chablis','handsomest','A'); +INSERT INTO t2 VALUES (452,128014,36,'alimony','betterments','Persian','A'); +INSERT INTO t2 VALUES (453,128015,36,'principled','advertising','analog','W'); +INSERT INTO t2 VALUES (454,128016,36,'golfing','rubies','complex','W'); +INSERT INTO t2 VALUES (455,128017,36,'undiscovered','southwest','Taoist',''); +INSERT INTO t2 VALUES (456,128018,36,'irritates','superstitious','suspend',''); +INSERT INTO t2 VALUES (457,128019,36,'patriots','tabernacle','relegated',''); +INSERT INTO t2 VALUES (458,128020,36,'rooms','silk','awesome','W'); +INSERT INTO t2 VALUES (459,128021,36,'towering','handsomest','Bruxelles',''); +INSERT INTO t2 VALUES (460,128022,36,'displease','Persian','imprecisely','A'); +INSERT INTO t2 VALUES (461,128023,36,'photosensitive','analog','televise',''); +INSERT INTO t2 VALUES (462,128101,36,'inking','complex','braking',''); +INSERT INTO t2 VALUES (463,128102,36,'gainers','Taoist','true','FAS'); +INSERT INTO t2 VALUES (464,128103,36,'leaning','suspend','disappointing','FAS'); +INSERT INTO t2 VALUES (465,128104,36,'hydrant','relegated','navally','W'); +INSERT INTO t2 VALUES (466,128106,36,'preserve','awesome','circus',''); +INSERT INTO t2 VALUES (467,128107,36,'blinded','Bruxelles','beetles',''); +INSERT INTO t2 VALUES (468,128108,36,'interactions','imprecisely','trumps',''); +INSERT INTO t2 VALUES (469,128202,36,'Barry','televise','fourscore','W'); +INSERT INTO t2 VALUES (470,128203,36,'whiteness','braking','Blackfoots',''); +INSERT INTO t2 VALUES (471,128301,36,'pastimes','true','Grady',''); +INSERT INTO t2 VALUES (472,128302,36,'Edenization','disappointing','quiets','FAS'); +INSERT INTO t2 VALUES (473,128303,36,'Muscat','navally','floundered','FAS'); +INSERT INTO t2 VALUES (474,128304,36,'assassinated','circus','profundity','W'); +INSERT INTO t2 VALUES (475,128305,36,'labeled','beetles','Garrisonian','W'); +INSERT INTO t2 VALUES (476,128307,36,'glacial','trumps','Strauss',''); +INSERT INTO t2 VALUES (477,128401,36,'implied','fourscore','cemented','FAS'); +INSERT INTO t2 VALUES (478,128502,36,'bibliographies','Blackfoots','contrition','A'); +INSERT INTO t2 VALUES (479,128503,36,'Buchanan','Grady','mutations',''); +INSERT INTO t2 VALUES (480,128504,36,'forgivably','quiets','exhibits','W'); +INSERT INTO t2 VALUES (481,128505,36,'innuendo','floundered','tits',''); +INSERT INTO t2 VALUES (482,128601,36,'den','profundity','mate','A'); +INSERT INTO t2 VALUES (483,128603,36,'submarines','Garrisonian','arches',''); +INSERT INTO t2 VALUES (484,128604,36,'mouthful','Strauss','Moll',''); +INSERT INTO t2 VALUES (485,128702,36,'expiring','cemented','ropers',''); +INSERT INTO t2 VALUES (486,128703,36,'unfulfilled','contrition','bombast',''); +INSERT INTO t2 VALUES (487,128704,36,'precession','mutations','difficultly','A'); +INSERT INTO t2 VALUES (488,138001,36,'nullified','exhibits','adsorption',''); +INSERT INTO t2 VALUES (489,138002,36,'affects','tits','definiteness','FAS'); +INSERT INTO t2 VALUES (490,138003,36,'Cynthia','mate','cultivation','A'); +INSERT INTO t2 VALUES (491,138004,36,'Chablis','arches','heals','A'); +INSERT INTO t2 VALUES (492,138005,36,'betterments','Moll','Heusen','W'); +INSERT INTO t2 VALUES (493,138006,36,'advertising','ropers','target','FAS'); +INSERT INTO t2 VALUES (494,138007,36,'rubies','bombast','cited','A'); +INSERT INTO t2 VALUES (495,138008,36,'southwest','difficultly','congresswoman','W'); +INSERT INTO t2 VALUES (496,138009,36,'superstitious','adsorption','Katherine',''); +INSERT INTO t2 VALUES (497,138102,36,'tabernacle','definiteness','titter','A'); +INSERT INTO t2 VALUES (498,138103,36,'silk','cultivation','aspire','A'); +INSERT INTO t2 VALUES (499,138104,36,'handsomest','heals','Mardis',''); +INSERT INTO t2 VALUES (500,138105,36,'Persian','Heusen','Nadia','W'); +INSERT INTO t2 VALUES (501,138201,36,'analog','target','estimating','FAS'); +INSERT INTO t2 VALUES (502,138302,36,'complex','cited','stuck','A'); +INSERT INTO t2 VALUES (503,138303,36,'Taoist','congresswoman','fifteenth','A'); +INSERT INTO t2 VALUES (504,138304,36,'suspend','Katherine','Colombo',''); +INSERT INTO t2 VALUES (505,138401,29,'relegated','titter','survey','A'); +INSERT INTO t2 VALUES (506,140102,29,'awesome','aspire','staffing',''); +INSERT INTO t2 VALUES (507,140103,29,'Bruxelles','Mardis','obtain',''); +INSERT INTO t2 VALUES (508,140104,29,'imprecisely','Nadia','loaded',''); +INSERT INTO t2 VALUES (509,140105,29,'televise','estimating','slaughtered',''); +INSERT INTO t2 VALUES (510,140201,29,'braking','stuck','lights','A'); +INSERT INTO t2 VALUES (511,140701,29,'true','fifteenth','circumference',''); +INSERT INTO t2 VALUES (512,141501,29,'disappointing','Colombo','dull','A'); +INSERT INTO t2 VALUES (513,141502,29,'navally','survey','weekly','A'); +INSERT INTO t2 VALUES (514,141901,29,'circus','staffing','wetness',''); +INSERT INTO t2 VALUES (515,141902,29,'beetles','obtain','visualized',''); +INSERT INTO t2 VALUES (516,142101,29,'trumps','loaded','Tannenbaum',''); +INSERT INTO t2 VALUES (517,142102,29,'fourscore','slaughtered','moribund',''); +INSERT INTO t2 VALUES (518,142103,29,'Blackfoots','lights','demultiplex',''); +INSERT INTO t2 VALUES (519,142701,29,'Grady','circumference','lockings',''); +INSERT INTO t2 VALUES (520,143001,29,'quiets','dull','thugs','FAS'); +INSERT INTO t2 VALUES (521,143501,29,'floundered','weekly','unnerves',''); +INSERT INTO t2 VALUES (522,143502,29,'profundity','wetness','abut',''); +INSERT INTO t2 VALUES (523,148001,29,'Garrisonian','visualized','Chippewa','A'); +INSERT INTO t2 VALUES (524,148002,29,'Strauss','Tannenbaum','stratifications','A'); +INSERT INTO t2 VALUES (525,148003,29,'cemented','moribund','signaled',''); +INSERT INTO t2 VALUES (526,148004,29,'contrition','demultiplex','Italianizes','A'); +INSERT INTO t2 VALUES (527,148005,29,'mutations','lockings','algorithmic','A'); +INSERT INTO t2 VALUES (528,148006,29,'exhibits','thugs','paranoid','FAS'); +INSERT INTO t2 VALUES (529,148007,29,'tits','unnerves','camping','A'); +INSERT INTO t2 VALUES (530,148009,29,'mate','abut','signifying','A'); +INSERT INTO t2 VALUES (531,148010,29,'arches','Chippewa','Patrice','W'); +INSERT INTO t2 VALUES (532,148011,29,'Moll','stratifications','search','A'); +INSERT INTO t2 VALUES (533,148012,29,'ropers','signaled','Angeles','A'); +INSERT INTO t2 VALUES (534,148013,29,'bombast','Italianizes','semblance',''); +INSERT INTO t2 VALUES (535,148023,36,'difficultly','algorithmic','taxed',''); +INSERT INTO t2 VALUES (536,148015,29,'adsorption','paranoid','Beatrice',''); +INSERT INTO t2 VALUES (537,148016,29,'definiteness','camping','retrace',''); +INSERT INTO t2 VALUES (538,148017,29,'cultivation','signifying','lockout',''); +INSERT INTO t2 VALUES (539,148018,29,'heals','Patrice','grammatic',''); +INSERT INTO t2 VALUES (540,148019,29,'Heusen','search','helmsman',''); +INSERT INTO t2 VALUES (541,148020,29,'target','Angeles','uniform','W'); +INSERT INTO t2 VALUES (542,148021,29,'cited','semblance','hamming',''); +INSERT INTO t2 VALUES (543,148022,29,'congresswoman','taxed','disobedience',''); +INSERT INTO t2 VALUES (544,148101,29,'Katherine','Beatrice','captivated','A'); +INSERT INTO t2 VALUES (545,148102,29,'titter','retrace','transferals','A'); +INSERT INTO t2 VALUES (546,148201,29,'aspire','lockout','cartographer','A'); +INSERT INTO t2 VALUES (547,148401,29,'Mardis','grammatic','aims','FAS'); +INSERT INTO t2 VALUES (548,148402,29,'Nadia','helmsman','Pakistani',''); +INSERT INTO t2 VALUES (549,148501,29,'estimating','uniform','burglarized','FAS'); +INSERT INTO t2 VALUES (550,148502,29,'stuck','hamming','saucepans','A'); +INSERT INTO t2 VALUES (551,148503,29,'fifteenth','disobedience','lacerating','A'); +INSERT INTO t2 VALUES (552,148504,29,'Colombo','captivated','corny',''); +INSERT INTO t2 VALUES (553,148601,29,'survey','transferals','megabytes','FAS'); +INSERT INTO t2 VALUES (554,148602,29,'staffing','cartographer','chancellor',''); +INSERT INTO t2 VALUES (555,150701,29,'obtain','aims','bulk','A'); +INSERT INTO t2 VALUES (556,152101,29,'loaded','Pakistani','commits','A'); +INSERT INTO t2 VALUES (557,152102,29,'slaughtered','burglarized','meson','W'); +INSERT INTO t2 VALUES (558,155202,36,'lights','saucepans','deputies',''); +INSERT INTO t2 VALUES (559,155203,29,'circumference','lacerating','northeaster','A'); +INSERT INTO t2 VALUES (560,155204,29,'dull','corny','dipole',''); +INSERT INTO t2 VALUES (561,155205,29,'weekly','megabytes','machining','0'); +INSERT INTO t2 VALUES (562,156001,29,'wetness','chancellor','therefore',''); +INSERT INTO t2 VALUES (563,156002,29,'visualized','bulk','Telefunken',''); +INSERT INTO t2 VALUES (564,156102,29,'Tannenbaum','commits','salvaging',''); +INSERT INTO t2 VALUES (565,156301,29,'moribund','meson','Corinthianizes','A'); +INSERT INTO t2 VALUES (566,156302,29,'demultiplex','deputies','restlessly','A'); +INSERT INTO t2 VALUES (567,156303,29,'lockings','northeaster','bromides',''); +INSERT INTO t2 VALUES (568,156304,29,'thugs','dipole','generalized','A'); +INSERT INTO t2 VALUES (569,156305,29,'unnerves','machining','mishaps',''); +INSERT INTO t2 VALUES (570,156306,29,'abut','therefore','quelling',''); +INSERT INTO t2 VALUES (571,156501,29,'Chippewa','Telefunken','spiritual','A'); +INSERT INTO t2 VALUES (572,158001,29,'stratifications','salvaging','beguiles','FAS'); +INSERT INTO t2 VALUES (573,158002,29,'signaled','Corinthianizes','Trobriand','FAS'); +INSERT INTO t2 VALUES (574,158101,29,'Italianizes','restlessly','fleeing','A'); +INSERT INTO t2 VALUES (575,158102,29,'algorithmic','bromides','Armour','A'); +INSERT INTO t2 VALUES (576,158103,29,'paranoid','generalized','chin','A'); +INSERT INTO t2 VALUES (577,158201,29,'camping','mishaps','provers','A'); +INSERT INTO t2 VALUES (578,158202,29,'signifying','quelling','aeronautic','A'); +INSERT INTO t2 VALUES (579,158203,29,'Patrice','spiritual','voltage','W'); +INSERT INTO t2 VALUES (580,158204,29,'search','beguiles','sash',''); +INSERT INTO t2 VALUES (581,158301,29,'Angeles','Trobriand','anaerobic','A'); +INSERT INTO t2 VALUES (582,158302,29,'semblance','fleeing','simultaneous','A'); +INSERT INTO t2 VALUES (583,158303,29,'taxed','Armour','accumulating','A'); +INSERT INTO t2 VALUES (584,158304,29,'Beatrice','chin','Medusan','A'); +INSERT INTO t2 VALUES (585,158305,29,'retrace','provers','shouted','A'); +INSERT INTO t2 VALUES (586,158306,29,'lockout','aeronautic','freakish',''); +INSERT INTO t2 VALUES (587,158501,29,'grammatic','voltage','index','FAS'); +INSERT INTO t2 VALUES (588,160301,29,'helmsman','sash','commercially',''); +INSERT INTO t2 VALUES (589,166101,50,'uniform','anaerobic','mistiness','A'); +INSERT INTO t2 VALUES (590,166102,50,'hamming','simultaneous','endpoint',''); +INSERT INTO t2 VALUES (591,168001,29,'disobedience','accumulating','straight','A'); +INSERT INTO t2 VALUES (592,168002,29,'captivated','Medusan','flurried',''); +INSERT INTO t2 VALUES (593,168003,29,'transferals','shouted','denotative','A'); +INSERT INTO t2 VALUES (594,168101,29,'cartographer','freakish','coming','FAS'); +INSERT INTO t2 VALUES (595,168102,29,'aims','index','commencements','FAS'); +INSERT INTO t2 VALUES (596,168103,29,'Pakistani','commercially','gentleman',''); +INSERT INTO t2 VALUES (597,168104,29,'burglarized','mistiness','gifted',''); +INSERT INTO t2 VALUES (598,168202,29,'saucepans','endpoint','Shanghais',''); +INSERT INTO t2 VALUES (599,168301,29,'lacerating','straight','sportswriting','A'); +INSERT INTO t2 VALUES (600,168502,29,'corny','flurried','sloping','A'); +INSERT INTO t2 VALUES (601,168503,29,'megabytes','denotative','navies',''); +INSERT INTO t2 VALUES (602,168601,29,'chancellor','coming','leaflet','A'); +INSERT INTO t2 VALUES (603,173001,40,'bulk','commencements','shooter',''); +INSERT INTO t2 VALUES (604,173701,40,'commits','gentleman','Joplin','FAS'); +INSERT INTO t2 VALUES (605,173702,40,'meson','gifted','babies',''); +INSERT INTO t2 VALUES (606,176001,40,'deputies','Shanghais','subdivision','FAS'); +INSERT INTO t2 VALUES (607,176101,40,'northeaster','sportswriting','burstiness','W'); +INSERT INTO t2 VALUES (608,176201,40,'dipole','sloping','belted','FAS'); +INSERT INTO t2 VALUES (609,176401,40,'machining','navies','assails','FAS'); +INSERT INTO t2 VALUES (610,176501,40,'therefore','leaflet','admiring','W'); +INSERT INTO t2 VALUES (611,176601,40,'Telefunken','shooter','swaying','0'); +INSERT INTO t2 VALUES (612,176602,40,'salvaging','Joplin','Goldstine','FAS'); +INSERT INTO t2 VALUES (613,176603,40,'Corinthianizes','babies','fitting',''); +INSERT INTO t2 VALUES (614,178001,40,'restlessly','subdivision','Norwalk','W'); +INSERT INTO t2 VALUES (615,178002,40,'bromides','burstiness','weakening','W'); +INSERT INTO t2 VALUES (616,178003,40,'generalized','belted','analogy','FAS'); +INSERT INTO t2 VALUES (617,178004,40,'mishaps','assails','deludes',''); +INSERT INTO t2 VALUES (618,178005,40,'quelling','admiring','cokes',''); +INSERT INTO t2 VALUES (619,178006,40,'spiritual','swaying','Clayton',''); +INSERT INTO t2 VALUES (620,178007,40,'beguiles','Goldstine','exhausts',''); +INSERT INTO t2 VALUES (621,178008,40,'Trobriand','fitting','causality',''); +INSERT INTO t2 VALUES (622,178101,40,'fleeing','Norwalk','sating','FAS'); +INSERT INTO t2 VALUES (623,178102,40,'Armour','weakening','icon',''); +INSERT INTO t2 VALUES (624,178103,40,'chin','analogy','throttles',''); +INSERT INTO t2 VALUES (625,178201,40,'provers','deludes','communicants','FAS'); +INSERT INTO t2 VALUES (626,178202,40,'aeronautic','cokes','dehydrate','FAS'); +INSERT INTO t2 VALUES (627,178301,40,'voltage','Clayton','priceless','FAS'); +INSERT INTO t2 VALUES (628,178302,40,'sash','exhausts','publicly',''); +INSERT INTO t2 VALUES (629,178401,40,'anaerobic','causality','incidentals','FAS'); +INSERT INTO t2 VALUES (630,178402,40,'simultaneous','sating','commonplace',''); +INSERT INTO t2 VALUES (631,178403,40,'accumulating','icon','mumbles',''); +INSERT INTO t2 VALUES (632,178404,40,'Medusan','throttles','furthermore','W'); +INSERT INTO t2 VALUES (633,178501,40,'shouted','communicants','cautioned','W'); +INSERT INTO t2 VALUES (634,186002,37,'freakish','dehydrate','parametrized','A'); +INSERT INTO t2 VALUES (635,186102,37,'index','priceless','registration','A'); +INSERT INTO t2 VALUES (636,186201,40,'commercially','publicly','sadly','FAS'); +INSERT INTO t2 VALUES (637,186202,40,'mistiness','incidentals','positioning',''); +INSERT INTO t2 VALUES (638,186203,40,'endpoint','commonplace','babysitting',''); +INSERT INTO t2 VALUES (639,186302,37,'straight','mumbles','eternal','A'); +INSERT INTO t2 VALUES (640,188007,37,'flurried','furthermore','hoarder',''); +INSERT INTO t2 VALUES (641,188008,37,'denotative','cautioned','congregates',''); +INSERT INTO t2 VALUES (642,188009,37,'coming','parametrized','rains',''); +INSERT INTO t2 VALUES (643,188010,37,'commencements','registration','workers','W'); +INSERT INTO t2 VALUES (644,188011,37,'gentleman','sadly','sags','A'); +INSERT INTO t2 VALUES (645,188012,37,'gifted','positioning','unplug','W'); +INSERT INTO t2 VALUES (646,188013,37,'Shanghais','babysitting','garage','A'); +INSERT INTO t2 VALUES (647,188014,37,'sportswriting','eternal','boulder','A'); +INSERT INTO t2 VALUES (648,188015,37,'sloping','hoarder','hollowly','A'); +INSERT INTO t2 VALUES (649,188016,37,'navies','congregates','specifics',''); +INSERT INTO t2 VALUES (650,188017,37,'leaflet','rains','Teresa',''); +INSERT INTO t2 VALUES (651,188102,37,'shooter','workers','Winsett',''); +INSERT INTO t2 VALUES (652,188103,37,'Joplin','sags','convenient','A'); +INSERT INTO t2 VALUES (653,188202,37,'babies','unplug','buckboards','FAS'); +INSERT INTO t2 VALUES (654,188301,40,'subdivision','garage','amenities',''); +INSERT INTO t2 VALUES (655,188302,40,'burstiness','boulder','resplendent','FAS'); +INSERT INTO t2 VALUES (656,188303,40,'belted','hollowly','priding','FAS'); +INSERT INTO t2 VALUES (657,188401,37,'assails','specifics','configurations',''); +INSERT INTO t2 VALUES (658,188402,37,'admiring','Teresa','untidiness','A'); +INSERT INTO t2 VALUES (659,188503,37,'swaying','Winsett','Brice','W'); +INSERT INTO t2 VALUES (660,188504,37,'Goldstine','convenient','sews','FAS'); +INSERT INTO t2 VALUES (661,188505,37,'fitting','buckboards','participated',''); +INSERT INTO t2 VALUES (662,190701,37,'Norwalk','amenities','Simon','FAS'); +INSERT INTO t2 VALUES (663,190703,50,'weakening','resplendent','certificates',''); +INSERT INTO t2 VALUES (664,191701,37,'analogy','priding','Fitzpatrick',''); +INSERT INTO t2 VALUES (665,191702,37,'deludes','configurations','Evanston','A'); +INSERT INTO t2 VALUES (666,191703,37,'cokes','untidiness','misted',''); +INSERT INTO t2 VALUES (667,196001,37,'Clayton','Brice','textures','A'); +INSERT INTO t2 VALUES (668,196002,37,'exhausts','sews','save',''); +INSERT INTO t2 VALUES (669,196003,37,'causality','participated','count',''); +INSERT INTO t2 VALUES (670,196101,37,'sating','Simon','rightful','A'); +INSERT INTO t2 VALUES (671,196103,37,'icon','certificates','chaperone',''); +INSERT INTO t2 VALUES (672,196104,37,'throttles','Fitzpatrick','Lizzy','A'); +INSERT INTO t2 VALUES (673,196201,37,'communicants','Evanston','clenched','A'); +INSERT INTO t2 VALUES (674,196202,37,'dehydrate','misted','effortlessly',''); +INSERT INTO t2 VALUES (675,196203,37,'priceless','textures','accessed',''); +INSERT INTO t2 VALUES (676,198001,37,'publicly','save','beaters','A'); +INSERT INTO t2 VALUES (677,198003,37,'incidentals','count','Hornblower','FAS'); +INSERT INTO t2 VALUES (678,198004,37,'commonplace','rightful','vests','A'); +INSERT INTO t2 VALUES (679,198005,37,'mumbles','chaperone','indulgences','FAS'); +INSERT INTO t2 VALUES (680,198006,37,'furthermore','Lizzy','infallibly','A'); +INSERT INTO t2 VALUES (681,198007,37,'cautioned','clenched','unwilling','FAS'); +INSERT INTO t2 VALUES (682,198008,37,'parametrized','effortlessly','excrete','FAS'); +INSERT INTO t2 VALUES (683,198009,37,'registration','accessed','spools','A'); +INSERT INTO t2 VALUES (684,198010,37,'sadly','beaters','crunches','FAS'); +INSERT INTO t2 VALUES (685,198011,37,'positioning','Hornblower','overestimating','FAS'); +INSERT INTO t2 VALUES (686,198012,37,'babysitting','vests','ineffective',''); +INSERT INTO t2 VALUES (687,198013,37,'eternal','indulgences','humiliation','A'); +INSERT INTO t2 VALUES (688,198014,37,'hoarder','infallibly','sophomore',''); +INSERT INTO t2 VALUES (689,198015,37,'congregates','unwilling','star',''); +INSERT INTO t2 VALUES (690,198017,37,'rains','excrete','rifles',''); +INSERT INTO t2 VALUES (691,198018,37,'workers','spools','dialysis',''); +INSERT INTO t2 VALUES (692,198019,37,'sags','crunches','arriving',''); +INSERT INTO t2 VALUES (693,198020,37,'unplug','overestimating','indulge',''); +INSERT INTO t2 VALUES (694,198021,37,'garage','ineffective','clockers',''); +INSERT INTO t2 VALUES (695,198022,37,'boulder','humiliation','languages',''); +INSERT INTO t2 VALUES (696,198023,50,'hollowly','sophomore','Antarctica','A'); +INSERT INTO t2 VALUES (697,198024,37,'specifics','star','percentage',''); +INSERT INTO t2 VALUES (698,198101,37,'Teresa','rifles','ceiling','A'); +INSERT INTO t2 VALUES (699,198103,37,'Winsett','dialysis','specification',''); +INSERT INTO t2 VALUES (700,198105,37,'convenient','arriving','regimented','A'); +INSERT INTO t2 VALUES (701,198106,37,'buckboards','indulge','ciphers',''); +INSERT INTO t2 VALUES (702,198201,37,'amenities','clockers','pictures','A'); +INSERT INTO t2 VALUES (703,198204,37,'resplendent','languages','serpents','A'); +INSERT INTO t2 VALUES (704,198301,53,'priding','Antarctica','allot','A'); +INSERT INTO t2 VALUES (705,198302,53,'configurations','percentage','realized','A'); +INSERT INTO t2 VALUES (706,198303,53,'untidiness','ceiling','mayoral','A'); +INSERT INTO t2 VALUES (707,198304,53,'Brice','specification','opaquely','A'); +INSERT INTO t2 VALUES (708,198401,37,'sews','regimented','hostess','FAS'); +INSERT INTO t2 VALUES (709,198402,37,'participated','ciphers','fiftieth',''); +INSERT INTO t2 VALUES (710,198403,37,'Simon','pictures','incorrectly',''); +INSERT INTO t2 VALUES (711,202101,37,'certificates','serpents','decomposition','FAS'); +INSERT INTO t2 VALUES (712,202301,37,'Fitzpatrick','allot','stranglings',''); +INSERT INTO t2 VALUES (713,202302,37,'Evanston','realized','mixture','FAS'); +INSERT INTO t2 VALUES (714,202303,37,'misted','mayoral','electroencephalography','FAS'); +INSERT INTO t2 VALUES (715,202304,37,'textures','opaquely','similarities','FAS'); +INSERT INTO t2 VALUES (716,202305,37,'save','hostess','charges','W'); +INSERT INTO t2 VALUES (717,202601,37,'count','fiftieth','freest','FAS'); +INSERT INTO t2 VALUES (718,202602,37,'rightful','incorrectly','Greenberg','FAS'); +INSERT INTO t2 VALUES (719,202605,37,'chaperone','decomposition','tinting',''); +INSERT INTO t2 VALUES (720,202606,37,'Lizzy','stranglings','expelled','W'); +INSERT INTO t2 VALUES (721,202607,37,'clenched','mixture','warm',''); +INSERT INTO t2 VALUES (722,202901,37,'effortlessly','electroencephalography','smoothed',''); +INSERT INTO t2 VALUES (723,202902,37,'accessed','similarities','deductions','FAS'); +INSERT INTO t2 VALUES (724,202903,37,'beaters','charges','Romano','W'); +INSERT INTO t2 VALUES (725,202904,37,'Hornblower','freest','bitterroot',''); +INSERT INTO t2 VALUES (726,202907,37,'vests','Greenberg','corset',''); +INSERT INTO t2 VALUES (727,202908,37,'indulgences','tinting','securing',''); +INSERT INTO t2 VALUES (728,203101,37,'infallibly','expelled','environing','FAS'); +INSERT INTO t2 VALUES (729,203103,37,'unwilling','warm','cute',''); +INSERT INTO t2 VALUES (730,203104,37,'excrete','smoothed','Crays',''); +INSERT INTO t2 VALUES (731,203105,37,'spools','deductions','heiress','FAS'); +INSERT INTO t2 VALUES (732,203401,37,'crunches','Romano','inform','FAS'); +INSERT INTO t2 VALUES (733,203402,37,'overestimating','bitterroot','avenge',''); +INSERT INTO t2 VALUES (734,203404,37,'ineffective','corset','universals',''); +INSERT INTO t2 VALUES (735,203901,37,'humiliation','securing','Kinsey','W'); +INSERT INTO t2 VALUES (736,203902,37,'sophomore','environing','ravines','FAS'); +INSERT INTO t2 VALUES (737,203903,37,'star','cute','bestseller',''); +INSERT INTO t2 VALUES (738,203906,37,'rifles','Crays','equilibrium',''); +INSERT INTO t2 VALUES (739,203907,37,'dialysis','heiress','extents','0'); +INSERT INTO t2 VALUES (740,203908,37,'arriving','inform','relatively',''); +INSERT INTO t2 VALUES (741,203909,37,'indulge','avenge','pressure','FAS'); +INSERT INTO t2 VALUES (742,206101,37,'clockers','universals','critiques','FAS'); +INSERT INTO t2 VALUES (743,206201,37,'languages','Kinsey','befouled',''); +INSERT INTO t2 VALUES (744,206202,37,'Antarctica','ravines','rightfully','FAS'); +INSERT INTO t2 VALUES (745,206203,37,'percentage','bestseller','mechanizing','FAS'); +INSERT INTO t2 VALUES (746,206206,37,'ceiling','equilibrium','Latinizes',''); +INSERT INTO t2 VALUES (747,206207,37,'specification','extents','timesharing',''); +INSERT INTO t2 VALUES (748,206208,37,'regimented','relatively','Aden',''); +INSERT INTO t2 VALUES (749,208001,37,'ciphers','pressure','embassies',''); +INSERT INTO t2 VALUES (750,208002,37,'pictures','critiques','males','FAS'); +INSERT INTO t2 VALUES (751,208003,37,'serpents','befouled','shapelessly','FAS'); +INSERT INTO t2 VALUES (752,208004,37,'allot','rightfully','genres','FAS'); +INSERT INTO t2 VALUES (753,208008,37,'realized','mechanizing','mastering',''); +INSERT INTO t2 VALUES (754,208009,37,'mayoral','Latinizes','Newtonian',''); +INSERT INTO t2 VALUES (755,208010,37,'opaquely','timesharing','finishers','FAS'); +INSERT INTO t2 VALUES (756,208011,37,'hostess','Aden','abates',''); +INSERT INTO t2 VALUES (757,208101,37,'fiftieth','embassies','teem',''); +INSERT INTO t2 VALUES (758,208102,37,'incorrectly','males','kiting','FAS'); +INSERT INTO t2 VALUES (759,208103,37,'decomposition','shapelessly','stodgy','FAS'); +INSERT INTO t2 VALUES (760,208104,37,'stranglings','genres','scalps','FAS'); +INSERT INTO t2 VALUES (761,208105,37,'mixture','mastering','feed','FAS'); +INSERT INTO t2 VALUES (762,208110,37,'electroencephalography','Newtonian','guitars',''); +INSERT INTO t2 VALUES (763,208111,37,'similarities','finishers','airships',''); +INSERT INTO t2 VALUES (764,208112,37,'charges','abates','store',''); +INSERT INTO t2 VALUES (765,208113,37,'freest','teem','denounces',''); +INSERT INTO t2 VALUES (766,208201,37,'Greenberg','kiting','Pyle','FAS'); +INSERT INTO t2 VALUES (767,208203,37,'tinting','stodgy','Saxony',''); +INSERT INTO t2 VALUES (768,208301,37,'expelled','scalps','serializations','FAS'); +INSERT INTO t2 VALUES (769,208302,37,'warm','feed','Peruvian','FAS'); +INSERT INTO t2 VALUES (770,208305,37,'smoothed','guitars','taxonomically','FAS'); +INSERT INTO t2 VALUES (771,208401,37,'deductions','airships','kingdom','A'); +INSERT INTO t2 VALUES (772,208402,37,'Romano','store','stint','A'); +INSERT INTO t2 VALUES (773,208403,37,'bitterroot','denounces','Sault','A'); +INSERT INTO t2 VALUES (774,208404,37,'corset','Pyle','faithful',''); +INSERT INTO t2 VALUES (775,208501,37,'securing','Saxony','Ganymede','FAS'); +INSERT INTO t2 VALUES (776,208502,37,'environing','serializations','tidiness','FAS'); +INSERT INTO t2 VALUES (777,208503,37,'cute','Peruvian','gainful','FAS'); +INSERT INTO t2 VALUES (778,208504,37,'Crays','taxonomically','contrary','FAS'); +INSERT INTO t2 VALUES (779,208505,37,'heiress','kingdom','Tipperary','FAS'); +INSERT INTO t2 VALUES (780,210101,37,'inform','stint','tropics','W'); +INSERT INTO t2 VALUES (781,210102,37,'avenge','Sault','theorizers',''); +INSERT INTO t2 VALUES (782,210103,37,'universals','faithful','renew','0'); +INSERT INTO t2 VALUES (783,210104,37,'Kinsey','Ganymede','already',''); +INSERT INTO t2 VALUES (784,210105,37,'ravines','tidiness','terminal',''); +INSERT INTO t2 VALUES (785,210106,37,'bestseller','gainful','Hegelian',''); +INSERT INTO t2 VALUES (786,210107,37,'equilibrium','contrary','hypothesizer',''); +INSERT INTO t2 VALUES (787,210401,37,'extents','Tipperary','warningly','FAS'); +INSERT INTO t2 VALUES (788,213201,37,'relatively','tropics','journalizing','FAS'); +INSERT INTO t2 VALUES (789,213203,37,'pressure','theorizers','nested',''); +INSERT INTO t2 VALUES (790,213204,37,'critiques','renew','Lars',''); +INSERT INTO t2 VALUES (791,213205,37,'befouled','already','saplings',''); +INSERT INTO t2 VALUES (792,213206,37,'rightfully','terminal','foothill',''); +INSERT INTO t2 VALUES (793,213207,37,'mechanizing','Hegelian','labeled',''); +INSERT INTO t2 VALUES (794,216101,37,'Latinizes','hypothesizer','imperiously','FAS'); +INSERT INTO t2 VALUES (795,216103,37,'timesharing','warningly','reporters','FAS'); +INSERT INTO t2 VALUES (796,218001,37,'Aden','journalizing','furnishings','FAS'); +INSERT INTO t2 VALUES (797,218002,37,'embassies','nested','precipitable','FAS'); +INSERT INTO t2 VALUES (798,218003,37,'males','Lars','discounts','FAS'); +INSERT INTO t2 VALUES (799,218004,37,'shapelessly','saplings','excises','FAS'); +INSERT INTO t2 VALUES (800,143503,50,'genres','foothill','Stalin',''); +INSERT INTO t2 VALUES (801,218006,37,'mastering','labeled','despot','FAS'); +INSERT INTO t2 VALUES (802,218007,37,'Newtonian','imperiously','ripeness','FAS'); +INSERT INTO t2 VALUES (803,218008,37,'finishers','reporters','Arabia',''); +INSERT INTO t2 VALUES (804,218009,37,'abates','furnishings','unruly',''); +INSERT INTO t2 VALUES (805,218010,37,'teem','precipitable','mournfulness',''); +INSERT INTO t2 VALUES (806,218011,37,'kiting','discounts','boom','FAS'); +INSERT INTO t2 VALUES (807,218020,37,'stodgy','excises','slaughter','A'); +INSERT INTO t2 VALUES (808,218021,50,'scalps','Stalin','Sabine',''); +INSERT INTO t2 VALUES (809,218022,37,'feed','despot','handy','FAS'); +INSERT INTO t2 VALUES (810,218023,37,'guitars','ripeness','rural',''); +INSERT INTO t2 VALUES (811,218024,37,'airships','Arabia','organizer',''); +INSERT INTO t2 VALUES (812,218101,37,'store','unruly','shipyard','FAS'); +INSERT INTO t2 VALUES (813,218102,37,'denounces','mournfulness','civics','FAS'); +INSERT INTO t2 VALUES (814,218103,37,'Pyle','boom','inaccuracy','FAS'); +INSERT INTO t2 VALUES (815,218201,37,'Saxony','slaughter','rules','FAS'); +INSERT INTO t2 VALUES (816,218202,37,'serializations','Sabine','juveniles','FAS'); +INSERT INTO t2 VALUES (817,218203,37,'Peruvian','handy','comprised','W'); +INSERT INTO t2 VALUES (818,218204,37,'taxonomically','rural','investigations',''); +INSERT INTO t2 VALUES (819,218205,37,'kingdom','organizer','stabilizes','A'); +INSERT INTO t2 VALUES (820,218301,37,'stint','shipyard','seminaries','FAS'); +INSERT INTO t2 VALUES (821,218302,37,'Sault','civics','Hunter','A'); +INSERT INTO t2 VALUES (822,218401,37,'faithful','inaccuracy','sporty','FAS'); +INSERT INTO t2 VALUES (823,218402,37,'Ganymede','rules','test','FAS'); +INSERT INTO t2 VALUES (824,218403,37,'tidiness','juveniles','weasels',''); +INSERT INTO t2 VALUES (825,218404,37,'gainful','comprised','CERN',''); +INSERT INTO t2 VALUES (826,218407,37,'contrary','investigations','tempering',''); +INSERT INTO t2 VALUES (827,218408,37,'Tipperary','stabilizes','afore','FAS'); +INSERT INTO t2 VALUES (828,218409,37,'tropics','seminaries','Galatean',''); +INSERT INTO t2 VALUES (829,218410,37,'theorizers','Hunter','techniques','W'); +INSERT INTO t2 VALUES (830,226001,37,'renew','sporty','error',''); +INSERT INTO t2 VALUES (831,226002,37,'already','test','veranda',''); +INSERT INTO t2 VALUES (832,226003,37,'terminal','weasels','severely',''); +INSERT INTO t2 VALUES (833,226004,37,'Hegelian','CERN','Cassites','FAS'); +INSERT INTO t2 VALUES (834,226005,37,'hypothesizer','tempering','forthcoming',''); +INSERT INTO t2 VALUES (835,226006,37,'warningly','afore','guides',''); +INSERT INTO t2 VALUES (836,226007,37,'journalizing','Galatean','vanish','FAS'); +INSERT INTO t2 VALUES (837,226008,37,'nested','techniques','lied','A'); +INSERT INTO t2 VALUES (838,226203,37,'Lars','error','sawtooth','FAS'); +INSERT INTO t2 VALUES (839,226204,37,'saplings','veranda','fated','FAS'); +INSERT INTO t2 VALUES (840,226205,37,'foothill','severely','gradually',''); +INSERT INTO t2 VALUES (841,226206,37,'labeled','Cassites','widens',''); +INSERT INTO t2 VALUES (842,226207,37,'imperiously','forthcoming','preclude',''); +INSERT INTO t2 VALUES (843,226208,37,'reporters','guides','Jobrel',''); +INSERT INTO t2 VALUES (844,226209,37,'furnishings','vanish','hooker',''); +INSERT INTO t2 VALUES (845,226210,37,'precipitable','lied','rainstorm',''); +INSERT INTO t2 VALUES (846,226211,37,'discounts','sawtooth','disconnects',''); +INSERT INTO t2 VALUES (847,228001,37,'excises','fated','cruelty',''); +INSERT INTO t2 VALUES (848,228004,37,'Stalin','gradually','exponentials','A'); +INSERT INTO t2 VALUES (849,228005,37,'despot','widens','affective','A'); +INSERT INTO t2 VALUES (850,228006,37,'ripeness','preclude','arteries',''); +INSERT INTO t2 VALUES (851,228007,37,'Arabia','Jobrel','Crosby','FAS'); +INSERT INTO t2 VALUES (852,228008,37,'unruly','hooker','acquaint',''); +INSERT INTO t2 VALUES (853,228009,37,'mournfulness','rainstorm','evenhandedly',''); +INSERT INTO t2 VALUES (854,228101,37,'boom','disconnects','percentage',''); +INSERT INTO t2 VALUES (855,228108,37,'slaughter','cruelty','disobedience',''); +INSERT INTO t2 VALUES (856,228109,37,'Sabine','exponentials','humility',''); +INSERT INTO t2 VALUES (857,228110,37,'handy','affective','gleaning','A'); +INSERT INTO t2 VALUES (858,228111,37,'rural','arteries','petted','A'); +INSERT INTO t2 VALUES (859,228112,37,'organizer','Crosby','bloater','A'); +INSERT INTO t2 VALUES (860,228113,37,'shipyard','acquaint','minion','A'); +INSERT INTO t2 VALUES (861,228114,37,'civics','evenhandedly','marginal','A'); +INSERT INTO t2 VALUES (862,228115,37,'inaccuracy','percentage','apiary','A'); +INSERT INTO t2 VALUES (863,228116,37,'rules','disobedience','measures',''); +INSERT INTO t2 VALUES (864,228117,37,'juveniles','humility','precaution',''); +INSERT INTO t2 VALUES (865,228118,37,'comprised','gleaning','repelled',''); +INSERT INTO t2 VALUES (866,228119,37,'investigations','petted','primary','FAS'); +INSERT INTO t2 VALUES (867,228120,37,'stabilizes','bloater','coverings',''); +INSERT INTO t2 VALUES (868,228121,37,'seminaries','minion','Artemia','A'); +INSERT INTO t2 VALUES (869,228122,37,'Hunter','marginal','navigate',''); +INSERT INTO t2 VALUES (870,228201,37,'sporty','apiary','spatial',''); +INSERT INTO t2 VALUES (871,228206,37,'test','measures','Gurkha',''); +INSERT INTO t2 VALUES (872,228207,37,'weasels','precaution','meanwhile','A'); +INSERT INTO t2 VALUES (873,228208,37,'CERN','repelled','Melinda','A'); +INSERT INTO t2 VALUES (874,228209,37,'tempering','primary','Butterfield',''); +INSERT INTO t2 VALUES (875,228210,37,'afore','coverings','Aldrich','A'); +INSERT INTO t2 VALUES (876,228211,37,'Galatean','Artemia','previewing','A'); +INSERT INTO t2 VALUES (877,228212,37,'techniques','navigate','glut','A'); +INSERT INTO t2 VALUES (878,228213,37,'error','spatial','unaffected',''); +INSERT INTO t2 VALUES (879,228214,37,'veranda','Gurkha','inmate',''); +INSERT INTO t2 VALUES (880,228301,37,'severely','meanwhile','mineral',''); +INSERT INTO t2 VALUES (881,228305,37,'Cassites','Melinda','impending','A'); +INSERT INTO t2 VALUES (882,228306,37,'forthcoming','Butterfield','meditation','A'); +INSERT INTO t2 VALUES (883,228307,37,'guides','Aldrich','ideas',''); +INSERT INTO t2 VALUES (884,228308,37,'vanish','previewing','miniaturizes','W'); +INSERT INTO t2 VALUES (885,228309,37,'lied','glut','lewdly',''); +INSERT INTO t2 VALUES (886,228310,37,'sawtooth','unaffected','title',''); +INSERT INTO t2 VALUES (887,228311,37,'fated','inmate','youthfulness',''); +INSERT INTO t2 VALUES (888,228312,37,'gradually','mineral','creak','FAS'); +INSERT INTO t2 VALUES (889,228313,37,'widens','impending','Chippewa',''); +INSERT INTO t2 VALUES (890,228314,37,'preclude','meditation','clamored',''); +INSERT INTO t2 VALUES (891,228401,65,'Jobrel','ideas','freezes',''); +INSERT INTO t2 VALUES (892,228402,65,'hooker','miniaturizes','forgivably','FAS'); +INSERT INTO t2 VALUES (893,228403,65,'rainstorm','lewdly','reduce','FAS'); +INSERT INTO t2 VALUES (894,228404,65,'disconnects','title','McGovern','W'); +INSERT INTO t2 VALUES (895,228405,65,'cruelty','youthfulness','Nazis','W'); +INSERT INTO t2 VALUES (896,228406,65,'exponentials','creak','epistle','W'); +INSERT INTO t2 VALUES (897,228407,65,'affective','Chippewa','socializes','W'); +INSERT INTO t2 VALUES (898,228408,65,'arteries','clamored','conceptions',''); +INSERT INTO t2 VALUES (899,228409,65,'Crosby','freezes','Kevin',''); +INSERT INTO t2 VALUES (900,228410,65,'acquaint','forgivably','uncovering',''); +INSERT INTO t2 VALUES (901,230301,37,'evenhandedly','reduce','chews','FAS'); +INSERT INTO t2 VALUES (902,230302,37,'percentage','McGovern','appendixes','FAS'); +INSERT INTO t2 VALUES (903,230303,37,'disobedience','Nazis','raining',''); +INSERT INTO t2 VALUES (904,018062,37,'humility','epistle','infest',''); +INSERT INTO t2 VALUES (905,230501,37,'gleaning','socializes','compartment',''); +INSERT INTO t2 VALUES (906,230502,37,'petted','conceptions','minting',''); +INSERT INTO t2 VALUES (907,230503,37,'bloater','Kevin','ducks',''); +INSERT INTO t2 VALUES (908,230504,37,'minion','uncovering','roped','A'); +INSERT INTO t2 VALUES (909,230505,37,'marginal','chews','waltz',''); +INSERT INTO t2 VALUES (910,230506,37,'apiary','appendixes','Lillian',''); +INSERT INTO t2 VALUES (911,230507,37,'measures','raining','repressions','A'); +INSERT INTO t2 VALUES (912,230508,37,'precaution','infest','chillingly',''); +INSERT INTO t2 VALUES (913,230509,37,'repelled','compartment','noncritical',''); +INSERT INTO t2 VALUES (914,230901,37,'primary','minting','lithograph',''); +INSERT INTO t2 VALUES (915,230902,37,'coverings','ducks','spongers',''); +INSERT INTO t2 VALUES (916,230903,37,'Artemia','roped','parenthood',''); +INSERT INTO t2 VALUES (917,230904,37,'navigate','waltz','posed',''); +INSERT INTO t2 VALUES (918,230905,37,'spatial','Lillian','instruments',''); +INSERT INTO t2 VALUES (919,230906,37,'Gurkha','repressions','filial',''); +INSERT INTO t2 VALUES (920,230907,37,'meanwhile','chillingly','fixedly',''); +INSERT INTO t2 VALUES (921,230908,37,'Melinda','noncritical','relives',''); +INSERT INTO t2 VALUES (922,230909,37,'Butterfield','lithograph','Pandora',''); +INSERT INTO t2 VALUES (923,230910,37,'Aldrich','spongers','watering','A'); +INSERT INTO t2 VALUES (924,230911,37,'previewing','parenthood','ungrateful',''); +INSERT INTO t2 VALUES (925,230912,37,'glut','posed','secures',''); +INSERT INTO t2 VALUES (926,230913,37,'unaffected','instruments','chastisers',''); +INSERT INTO t2 VALUES (927,230914,37,'inmate','filial','icon',''); +INSERT INTO t2 VALUES (928,231304,37,'mineral','fixedly','reuniting','A'); +INSERT INTO t2 VALUES (929,231305,37,'impending','relives','imagining','A'); +INSERT INTO t2 VALUES (930,231306,37,'meditation','Pandora','abiding','A'); +INSERT INTO t2 VALUES (931,231307,37,'ideas','watering','omnisciently',''); +INSERT INTO t2 VALUES (932,231308,37,'miniaturizes','ungrateful','Britannic',''); +INSERT INTO t2 VALUES (933,231309,37,'lewdly','secures','scholastics','A'); +INSERT INTO t2 VALUES (934,231310,37,'title','chastisers','mechanics','A'); +INSERT INTO t2 VALUES (935,231311,37,'youthfulness','icon','humidly','A'); +INSERT INTO t2 VALUES (936,231312,37,'creak','reuniting','masterpiece',''); +INSERT INTO t2 VALUES (937,231313,37,'Chippewa','imagining','however',''); +INSERT INTO t2 VALUES (938,231314,37,'clamored','abiding','Mendelian',''); +INSERT INTO t2 VALUES (939,231315,37,'freezes','omnisciently','jarred',''); +INSERT INTO t2 VALUES (940,232102,37,'forgivably','Britannic','scolds',''); +INSERT INTO t2 VALUES (941,232103,37,'reduce','scholastics','infatuate',''); +INSERT INTO t2 VALUES (942,232104,37,'McGovern','mechanics','willed','A'); +INSERT INTO t2 VALUES (943,232105,37,'Nazis','humidly','joyfully',''); +INSERT INTO t2 VALUES (944,232106,37,'epistle','masterpiece','Microsoft',''); +INSERT INTO t2 VALUES (945,232107,37,'socializes','however','fibrosities',''); +INSERT INTO t2 VALUES (946,232108,37,'conceptions','Mendelian','Baltimorean',''); +INSERT INTO t2 VALUES (947,232601,37,'Kevin','jarred','equestrian',''); +INSERT INTO t2 VALUES (948,232602,37,'uncovering','scolds','Goodrich',''); +INSERT INTO t2 VALUES (949,232603,37,'chews','infatuate','apish','A'); +INSERT INTO t2 VALUES (950,232605,37,'appendixes','willed','Adlerian',''); +INSERT INTO t2 VALUES (5950,1232605,37,'appendixes','willed','Adlerian',''); +INSERT INTO t2 VALUES (5951,1232606,37,'appendixes','willed','Adlerian',''); +INSERT INTO t2 VALUES (5952,1232607,37,'appendixes','willed','Adlerian',''); +INSERT INTO t2 VALUES (5953,1232608,37,'appendixes','willed','Adlerian',''); +INSERT INTO t2 VALUES (5954,1232609,37,'appendixes','willed','Adlerian',''); +INSERT INTO t2 VALUES (951,232606,37,'raining','joyfully','Tropez',''); +INSERT INTO t2 VALUES (952,232607,37,'infest','Microsoft','nouns',''); +INSERT INTO t2 VALUES (953,232608,37,'compartment','fibrosities','distracting',''); +INSERT INTO t2 VALUES (954,232609,37,'minting','Baltimorean','mutton',''); +INSERT INTO t2 VALUES (955,236104,37,'ducks','equestrian','bridgeable','A'); +INSERT INTO t2 VALUES (956,236105,37,'roped','Goodrich','stickers','A'); +INSERT INTO t2 VALUES (957,236106,37,'waltz','apish','transcontinental','A'); +INSERT INTO t2 VALUES (958,236107,37,'Lillian','Adlerian','amateurish',''); +INSERT INTO t2 VALUES (959,236108,37,'repressions','Tropez','Gandhian',''); +INSERT INTO t2 VALUES (960,236109,37,'chillingly','nouns','stratified',''); +INSERT INTO t2 VALUES (961,236110,37,'noncritical','distracting','chamberlains',''); +INSERT INTO t2 VALUES (962,236111,37,'lithograph','mutton','creditably',''); +INSERT INTO t2 VALUES (963,236112,37,'spongers','bridgeable','philosophic',''); +INSERT INTO t2 VALUES (964,236113,37,'parenthood','stickers','ores',''); +INSERT INTO t2 VALUES (965,238005,37,'posed','transcontinental','Carleton',''); +INSERT INTO t2 VALUES (966,238006,37,'instruments','amateurish','tape','A'); +INSERT INTO t2 VALUES (967,238007,37,'filial','Gandhian','afloat','A'); +INSERT INTO t2 VALUES (968,238008,37,'fixedly','stratified','goodness','A'); +INSERT INTO t2 VALUES (969,238009,37,'relives','chamberlains','welcoming',''); +INSERT INTO t2 VALUES (970,238010,37,'Pandora','creditably','Pinsky','FAS'); +INSERT INTO t2 VALUES (971,238011,37,'watering','philosophic','halting',''); +INSERT INTO t2 VALUES (972,238012,37,'ungrateful','ores','bibliography',''); +INSERT INTO t2 VALUES (973,238013,37,'secures','Carleton','decoding',''); +INSERT INTO t2 VALUES (974,240401,41,'chastisers','tape','variance','A'); +INSERT INTO t2 VALUES (975,240402,41,'icon','afloat','allowed','A'); +INSERT INTO t2 VALUES (976,240901,41,'reuniting','goodness','dire','A'); +INSERT INTO t2 VALUES (977,240902,41,'imagining','welcoming','dub','A'); +INSERT INTO t2 VALUES (978,241801,41,'abiding','Pinsky','poisoning',''); +INSERT INTO t2 VALUES (979,242101,41,'omnisciently','halting','Iraqis','A'); +INSERT INTO t2 VALUES (980,242102,41,'Britannic','bibliography','heaving',''); +INSERT INTO t2 VALUES (981,242201,41,'scholastics','decoding','population','A'); +INSERT INTO t2 VALUES (982,242202,41,'mechanics','variance','bomb','A'); +INSERT INTO t2 VALUES (983,242501,41,'humidly','allowed','Majorca','A'); +INSERT INTO t2 VALUES (984,242502,41,'masterpiece','dire','Gershwins',''); +INSERT INTO t2 VALUES (985,246201,41,'however','dub','explorers',''); +INSERT INTO t2 VALUES (986,246202,41,'Mendelian','poisoning','libretto','A'); +INSERT INTO t2 VALUES (987,246203,41,'jarred','Iraqis','occurred',''); +INSERT INTO t2 VALUES (988,246204,41,'scolds','heaving','Lagos',''); +INSERT INTO t2 VALUES (989,246205,41,'infatuate','population','rats',''); +INSERT INTO t2 VALUES (990,246301,41,'willed','bomb','bankruptcies','A'); +INSERT INTO t2 VALUES (991,246302,41,'joyfully','Majorca','crying',''); +INSERT INTO t2 VALUES (992,248001,41,'Microsoft','Gershwins','unexpected',''); +INSERT INTO t2 VALUES (993,248002,41,'fibrosities','explorers','accessed','A'); +INSERT INTO t2 VALUES (994,248003,41,'Baltimorean','libretto','colorful','A'); +INSERT INTO t2 VALUES (995,248004,41,'equestrian','occurred','versatility','A'); +INSERT INTO t2 VALUES (996,248005,41,'Goodrich','Lagos','cosy',''); +INSERT INTO t2 VALUES (997,248006,41,'apish','rats','Darius','A'); +INSERT INTO t2 VALUES (998,248007,41,'Adlerian','bankruptcies','mastering','A'); +INSERT INTO t2 VALUES (999,248008,41,'Tropez','crying','Asiaticizations','A'); +INSERT INTO t2 VALUES (1000,248009,41,'nouns','unexpected','offerers','A'); +INSERT INTO t2 VALUES (1001,248010,41,'distracting','accessed','uncles','A'); +INSERT INTO t2 VALUES (1002,248011,41,'mutton','colorful','sleepwalk',''); +INSERT INTO t2 VALUES (1003,248012,41,'bridgeable','versatility','Ernestine',''); +INSERT INTO t2 VALUES (1004,248013,41,'stickers','cosy','checksumming',''); +INSERT INTO t2 VALUES (1005,248014,41,'transcontinental','Darius','stopped',''); +INSERT INTO t2 VALUES (1006,248015,41,'amateurish','mastering','sicker',''); +INSERT INTO t2 VALUES (1007,248016,41,'Gandhian','Asiaticizations','Italianization',''); +INSERT INTO t2 VALUES (1008,248017,41,'stratified','offerers','alphabetic',''); +INSERT INTO t2 VALUES (1009,248018,41,'chamberlains','uncles','pharmaceutic',''); +INSERT INTO t2 VALUES (1010,248019,41,'creditably','sleepwalk','creator',''); +INSERT INTO t2 VALUES (1011,248020,41,'philosophic','Ernestine','chess',''); +INSERT INTO t2 VALUES (1012,248021,41,'ores','checksumming','charcoal',''); +INSERT INTO t2 VALUES (1013,248101,41,'Carleton','stopped','Epiphany','A'); +INSERT INTO t2 VALUES (1014,248102,41,'tape','sicker','bulldozes','A'); +INSERT INTO t2 VALUES (1015,248201,41,'afloat','Italianization','Pygmalion','A'); +INSERT INTO t2 VALUES (1016,248202,41,'goodness','alphabetic','caressing','A'); +INSERT INTO t2 VALUES (1017,248203,41,'welcoming','pharmaceutic','Palestine','A'); +INSERT INTO t2 VALUES (1018,248204,41,'Pinsky','creator','regimented','A'); +INSERT INTO t2 VALUES (1019,248205,41,'halting','chess','scars','A'); +INSERT INTO t2 VALUES (1020,248206,41,'bibliography','charcoal','realest','A'); +INSERT INTO t2 VALUES (1021,248207,41,'decoding','Epiphany','diffusing','A'); +INSERT INTO t2 VALUES (1022,248208,41,'variance','bulldozes','clubroom','A'); +INSERT INTO t2 VALUES (1023,248209,41,'allowed','Pygmalion','Blythe','A'); +INSERT INTO t2 VALUES (1024,248210,41,'dire','caressing','ahead',''); +INSERT INTO t2 VALUES (1025,248211,50,'dub','Palestine','reviver',''); +INSERT INTO t2 VALUES (1026,250501,34,'poisoning','regimented','retransmitting','A'); +INSERT INTO t2 VALUES (1027,250502,34,'Iraqis','scars','landslide',''); +INSERT INTO t2 VALUES (1028,250503,34,'heaving','realest','Eiffel',''); +INSERT INTO t2 VALUES (1029,250504,34,'population','diffusing','absentee',''); +INSERT INTO t2 VALUES (1030,250505,34,'bomb','clubroom','aye',''); +INSERT INTO t2 VALUES (1031,250601,34,'Majorca','Blythe','forked','A'); +INSERT INTO t2 VALUES (1032,250602,34,'Gershwins','ahead','Peruvianizes',''); +INSERT INTO t2 VALUES (1033,250603,34,'explorers','reviver','clerked',''); +INSERT INTO t2 VALUES (1034,250604,34,'libretto','retransmitting','tutor',''); +INSERT INTO t2 VALUES (1035,250605,34,'occurred','landslide','boulevard',''); +INSERT INTO t2 VALUES (1036,251001,34,'Lagos','Eiffel','shuttered',''); +INSERT INTO t2 VALUES (1037,251002,34,'rats','absentee','quotes','A'); +INSERT INTO t2 VALUES (1038,251003,34,'bankruptcies','aye','Caltech',''); +INSERT INTO t2 VALUES (1039,251004,34,'crying','forked','Mossberg',''); +INSERT INTO t2 VALUES (1040,251005,34,'unexpected','Peruvianizes','kept',''); +INSERT INTO t2 VALUES (1041,251301,34,'accessed','clerked','roundly',''); +INSERT INTO t2 VALUES (1042,251302,34,'colorful','tutor','features','A'); +INSERT INTO t2 VALUES (1043,251303,34,'versatility','boulevard','imaginable','A'); +INSERT INTO t2 VALUES (1044,251304,34,'cosy','shuttered','controller',''); +INSERT INTO t2 VALUES (1045,251305,34,'Darius','quotes','racial',''); +INSERT INTO t2 VALUES (1046,251401,34,'mastering','Caltech','uprisings','A'); +INSERT INTO t2 VALUES (1047,251402,34,'Asiaticizations','Mossberg','narrowed','A'); +INSERT INTO t2 VALUES (1048,251403,34,'offerers','kept','cannot','A'); +INSERT INTO t2 VALUES (1049,251404,34,'uncles','roundly','vest',''); +INSERT INTO t2 VALUES (1050,251405,34,'sleepwalk','features','famine',''); +INSERT INTO t2 VALUES (1051,251406,34,'Ernestine','imaginable','sugars',''); +INSERT INTO t2 VALUES (1052,251801,34,'checksumming','controller','exterminated','A'); +INSERT INTO t2 VALUES (1053,251802,34,'stopped','racial','belays',''); +INSERT INTO t2 VALUES (1054,252101,34,'sicker','uprisings','Hodges','A'); +INSERT INTO t2 VALUES (1055,252102,34,'Italianization','narrowed','translatable',''); +INSERT INTO t2 VALUES (1056,252301,34,'alphabetic','cannot','duality','A'); +INSERT INTO t2 VALUES (1057,252302,34,'pharmaceutic','vest','recording','A'); +INSERT INTO t2 VALUES (1058,252303,34,'creator','famine','rouses','A'); +INSERT INTO t2 VALUES (1059,252304,34,'chess','sugars','poison',''); +INSERT INTO t2 VALUES (1060,252305,34,'charcoal','exterminated','attitude',''); +INSERT INTO t2 VALUES (1061,252306,34,'Epiphany','belays','dusted',''); +INSERT INTO t2 VALUES (1062,252307,34,'bulldozes','Hodges','encompasses',''); +INSERT INTO t2 VALUES (1063,252308,34,'Pygmalion','translatable','presentation',''); +INSERT INTO t2 VALUES (1064,252309,34,'caressing','duality','Kantian',''); +INSERT INTO t2 VALUES (1065,256001,34,'Palestine','recording','imprecision','A'); +INSERT INTO t2 VALUES (1066,256002,34,'regimented','rouses','saving',''); +INSERT INTO t2 VALUES (1067,256003,34,'scars','poison','maternal',''); +INSERT INTO t2 VALUES (1068,256004,34,'realest','attitude','hewed',''); +INSERT INTO t2 VALUES (1069,256005,34,'diffusing','dusted','kerosene',''); +INSERT INTO t2 VALUES (1070,258001,34,'clubroom','encompasses','Cubans',''); +INSERT INTO t2 VALUES (1071,258002,34,'Blythe','presentation','photographers',''); +INSERT INTO t2 VALUES (1072,258003,34,'ahead','Kantian','nymph','A'); +INSERT INTO t2 VALUES (1073,258004,34,'reviver','imprecision','bedlam','A'); +INSERT INTO t2 VALUES (1074,258005,34,'retransmitting','saving','north','A'); +INSERT INTO t2 VALUES (1075,258006,34,'landslide','maternal','Schoenberg','A'); +INSERT INTO t2 VALUES (1076,258007,34,'Eiffel','hewed','botany','A'); +INSERT INTO t2 VALUES (1077,258008,34,'absentee','kerosene','curs',''); +INSERT INTO t2 VALUES (1078,258009,34,'aye','Cubans','solidification',''); +INSERT INTO t2 VALUES (1079,258010,34,'forked','photographers','inheritresses',''); +INSERT INTO t2 VALUES (1080,258011,34,'Peruvianizes','nymph','stiller',''); +INSERT INTO t2 VALUES (1081,258101,68,'clerked','bedlam','t1','A'); +INSERT INTO t2 VALUES (1082,258102,68,'tutor','north','suite','A'); +INSERT INTO t2 VALUES (1083,258103,34,'boulevard','Schoenberg','ransomer',''); +INSERT INTO t2 VALUES (1084,258104,68,'shuttered','botany','Willy',''); +INSERT INTO t2 VALUES (1085,258105,68,'quotes','curs','Rena','A'); +INSERT INTO t2 VALUES (1086,258106,68,'Caltech','solidification','Seattle','A'); +INSERT INTO t2 VALUES (1087,258107,68,'Mossberg','inheritresses','relaxes','A'); +INSERT INTO t2 VALUES (1088,258108,68,'kept','stiller','exclaim',''); +INSERT INTO t2 VALUES (1089,258109,68,'roundly','t1','implicated','A'); +INSERT INTO t2 VALUES (1090,258110,68,'features','suite','distinguish',''); +INSERT INTO t2 VALUES (1091,258111,68,'imaginable','ransomer','assayed',''); +INSERT INTO t2 VALUES (1092,258112,68,'controller','Willy','homeowner',''); +INSERT INTO t2 VALUES (1093,258113,68,'racial','Rena','and',''); +INSERT INTO t2 VALUES (1094,258201,34,'uprisings','Seattle','stealth',''); +INSERT INTO t2 VALUES (1095,258202,34,'narrowed','relaxes','coinciding','A'); +INSERT INTO t2 VALUES (1096,258203,34,'cannot','exclaim','founder','A'); +INSERT INTO t2 VALUES (1097,258204,34,'vest','implicated','environing',''); +INSERT INTO t2 VALUES (1098,258205,34,'famine','distinguish','jewelry',''); +INSERT INTO t2 VALUES (1099,258301,34,'sugars','assayed','lemons','A'); +INSERT INTO t2 VALUES (1100,258401,34,'exterminated','homeowner','brokenness','A'); +INSERT INTO t2 VALUES (1101,258402,34,'belays','and','bedpost','A'); +INSERT INTO t2 VALUES (1102,258403,34,'Hodges','stealth','assurers','A'); +INSERT INTO t2 VALUES (1103,258404,34,'translatable','coinciding','annoyers',''); +INSERT INTO t2 VALUES (1104,258405,34,'duality','founder','affixed',''); +INSERT INTO t2 VALUES (1105,258406,34,'recording','environing','warbling',''); +INSERT INTO t2 VALUES (1106,258407,34,'rouses','jewelry','seriously',''); +INSERT INTO t2 VALUES (1107,228123,37,'poison','lemons','boasted',''); +INSERT INTO t2 VALUES (1108,250606,34,'attitude','brokenness','Chantilly',''); +INSERT INTO t2 VALUES (1109,208405,37,'dusted','bedpost','Iranizes',''); +INSERT INTO t2 VALUES (1110,212101,37,'encompasses','assurers','violinist',''); +INSERT INTO t2 VALUES (1111,218206,37,'presentation','annoyers','extramarital',''); +INSERT INTO t2 VALUES (1112,150401,37,'Kantian','affixed','spates',''); +INSERT INTO t2 VALUES (1113,248212,41,'imprecision','warbling','cloakroom',''); +INSERT INTO t2 VALUES (1114,128026,00,'saving','seriously','gazer',''); +INSERT INTO t2 VALUES (1115,128024,00,'maternal','boasted','hand',''); +INSERT INTO t2 VALUES (1116,128027,00,'hewed','Chantilly','tucked',''); +INSERT INTO t2 VALUES (1117,128025,00,'kerosene','Iranizes','gems',''); +INSERT INTO t2 VALUES (1118,128109,00,'Cubans','violinist','clinker',''); +INSERT INTO t2 VALUES (1119,128705,00,'photographers','extramarital','refiner',''); +INSERT INTO t2 VALUES (1120,126303,00,'nymph','spates','callus',''); +INSERT INTO t2 VALUES (1121,128308,00,'bedlam','cloakroom','leopards',''); +INSERT INTO t2 VALUES (1122,128204,00,'north','gazer','comfortingly',''); +INSERT INTO t2 VALUES (1123,128205,00,'Schoenberg','hand','generically',''); +INSERT INTO t2 VALUES (1124,128206,00,'botany','tucked','getters',''); +INSERT INTO t2 VALUES (1125,128207,00,'curs','gems','sexually',''); +INSERT INTO t2 VALUES (1126,118205,00,'solidification','clinker','spear',''); +INSERT INTO t2 VALUES (1127,116801,00,'inheritresses','refiner','serums',''); +INSERT INTO t2 VALUES (1128,116803,00,'stiller','callus','Italianization',''); +INSERT INTO t2 VALUES (1129,116804,00,'t1','leopards','attendants',''); +INSERT INTO t2 VALUES (1130,116802,00,'suite','comfortingly','spies',''); +INSERT INTO t2 VALUES (1131,128605,00,'ransomer','generically','Anthony',''); +INSERT INTO t2 VALUES (1132,118308,00,'Willy','getters','planar',''); +INSERT INTO t2 VALUES (1133,113702,00,'Rena','sexually','cupped',''); +INSERT INTO t2 VALUES (1134,113703,00,'Seattle','spear','cleanser',''); +INSERT INTO t2 VALUES (1135,112103,00,'relaxes','serums','commuters',''); +INSERT INTO t2 VALUES (1136,118009,00,'exclaim','Italianization','honeysuckle',''); +INSERT INTO t2 VALUES (5136,1118009,00,'exclaim','Italianization','honeysuckle',''); +INSERT INTO t2 VALUES (1137,138011,00,'implicated','attendants','orphanage',''); +INSERT INTO t2 VALUES (1138,138010,00,'distinguish','spies','skies',''); +INSERT INTO t2 VALUES (1139,138012,00,'assayed','Anthony','crushers',''); +INSERT INTO t2 VALUES (1140,068304,00,'homeowner','planar','Puritan',''); +INSERT INTO t2 VALUES (1141,078009,00,'and','cupped','squeezer',''); +INSERT INTO t2 VALUES (1142,108013,00,'stealth','cleanser','bruises',''); +INSERT INTO t2 VALUES (1143,084004,00,'coinciding','commuters','bonfire',''); +INSERT INTO t2 VALUES (1144,083402,00,'founder','honeysuckle','Colombo',''); +INSERT INTO t2 VALUES (1145,084003,00,'environing','orphanage','nondecreasing',''); +INSERT INTO t2 VALUES (1146,088504,00,'jewelry','skies','innocents',''); +INSERT INTO t2 VALUES (1147,088005,00,'lemons','crushers','masked',''); +INSERT INTO t2 VALUES (1148,088007,00,'brokenness','Puritan','file',''); +INSERT INTO t2 VALUES (1149,088006,00,'bedpost','squeezer','brush',''); +INSERT INTO t2 VALUES (1150,148025,00,'assurers','bruises','mutilate',''); +INSERT INTO t2 VALUES (1151,148024,00,'annoyers','bonfire','mommy',''); +INSERT INTO t2 VALUES (1152,138305,00,'affixed','Colombo','bulkheads',''); +INSERT INTO t2 VALUES (1153,138306,00,'warbling','nondecreasing','undeclared',''); +INSERT INTO t2 VALUES (1154,152701,00,'seriously','innocents','displacements',''); +INSERT INTO t2 VALUES (1155,148505,00,'boasted','masked','nieces',''); +INSERT INTO t2 VALUES (1156,158003,00,'Chantilly','file','coeducation',''); +INSERT INTO t2 VALUES (1157,156201,00,'Iranizes','brush','brassy',''); +INSERT INTO t2 VALUES (1158,156202,00,'violinist','mutilate','authenticator',''); +INSERT INTO t2 VALUES (1159,158307,00,'extramarital','mommy','Washoe',''); +INSERT INTO t2 VALUES (1160,158402,00,'spates','bulkheads','penny',''); +INSERT INTO t2 VALUES (1161,158401,00,'cloakroom','undeclared','Flagler',''); +INSERT INTO t2 VALUES (1162,068013,00,'gazer','displacements','stoned',''); +INSERT INTO t2 VALUES (1163,068012,00,'hand','nieces','cranes',''); +INSERT INTO t2 VALUES (1164,068203,00,'tucked','coeducation','masterful',''); +INSERT INTO t2 VALUES (1165,088205,00,'gems','brassy','biracial',''); +INSERT INTO t2 VALUES (1166,068704,00,'clinker','authenticator','steamships',''); +INSERT INTO t2 VALUES (1167,068604,00,'refiner','Washoe','windmills',''); +INSERT INTO t2 VALUES (1168,158502,00,'callus','penny','exploit',''); +INSERT INTO t2 VALUES (1169,123103,00,'leopards','Flagler','riverfront',''); +INSERT INTO t2 VALUES (1170,148026,00,'comfortingly','stoned','sisterly',''); +INSERT INTO t2 VALUES (1171,123302,00,'generically','cranes','sharpshoot',''); +INSERT INTO t2 VALUES (1172,076503,00,'getters','masterful','mittens',''); +INSERT INTO t2 VALUES (1173,126304,00,'sexually','biracial','interdependency',''); +INSERT INTO t2 VALUES (1174,068306,00,'spear','steamships','policy',''); +INSERT INTO t2 VALUES (1175,143504,00,'serums','windmills','unleashing',''); +INSERT INTO t2 VALUES (1176,160201,00,'Italianization','exploit','pretenders',''); +INSERT INTO t2 VALUES (1177,148028,00,'attendants','riverfront','overstatements',''); +INSERT INTO t2 VALUES (1178,148027,00,'spies','sisterly','birthed',''); +INSERT INTO t2 VALUES (1179,143505,00,'Anthony','sharpshoot','opportunism',''); +INSERT INTO t2 VALUES (1180,108014,00,'planar','mittens','showroom',''); +INSERT INTO t2 VALUES (1181,076104,00,'cupped','interdependency','compromisingly',''); +INSERT INTO t2 VALUES (1182,078106,00,'cleanser','policy','Medicare',''); +INSERT INTO t2 VALUES (1183,126102,00,'commuters','unleashing','corresponds',''); +INSERT INTO t2 VALUES (1184,128029,00,'honeysuckle','pretenders','hardware',''); +INSERT INTO t2 VALUES (1185,128028,00,'orphanage','overstatements','implant',''); +INSERT INTO t2 VALUES (1186,018410,00,'skies','birthed','Alicia',''); +INSERT INTO t2 VALUES (1187,128110,00,'crushers','opportunism','requesting',''); +INSERT INTO t2 VALUES (1188,148506,00,'Puritan','showroom','produced',''); +INSERT INTO t2 VALUES (1189,123303,00,'squeezer','compromisingly','criticizes',''); +INSERT INTO t2 VALUES (1190,123304,00,'bruises','Medicare','backer',''); +INSERT INTO t2 VALUES (1191,068504,00,'bonfire','corresponds','positively',''); +INSERT INTO t2 VALUES (1192,068305,00,'Colombo','hardware','colicky',''); +INSERT INTO t2 VALUES (1193,000000,00,'nondecreasing','implant','thrillingly',''); +--enable_query_log + +# +# Search with a key +# + +select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; +select fld3 from t2 where fld3 like "%cultivation" ; + +# +# Search with a key using sorting and limit the same time +# + +select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; +select fld3,companynr from t2 where companynr = 58 order by fld3; + +select fld3 from t2 order by fld3 desc limit 10; +select fld3 from t2 order by fld3 desc limit 5; +select fld3 from t2 order by fld3 desc limit 5,5; + +# +# Search with a key having a constant with each unique key. +# The table is read directly with read-next on fld3 +# + +select t2.fld3 from t2 where fld3 = 'honeysuckle'; +select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; +select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; +select t2.fld3 from t2 where fld3 LIKE 'h%le'; + +select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; +select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; + +# +# Test sorting with a used key (there is no need for sorting) +# + +select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; +select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; + +# +# Search with a key with LIKE constant +# If the like starts with a certain letter key will be used. +# + +select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; +select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; +select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); +select fld1,fld3 from t2 where fld1 like "25050%"; +select fld1,fld3 from t2 where fld1 like "25050_"; + +# +# Test for insert after select +# +INSERT INTO t2 VALUES (1,000001,00,'Omaha','teethe','neat',''); +INSERT INTO t2 VALUES (2,011401,37,'breaking','dreaded','Steinberg','W'); +INSERT INTO t2 VALUES (3,011402,37,'Romans','scholastics','jarring',''); +INSERT INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); +SELECT * FROM t2; +drop table t1, t2; diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 5b1a5923ad4..b8574fb7623 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -47,6 +47,16 @@ LPAD(_ucs2 X'0420',10,_ucs2 X'0421') l, RPAD(_ucs2 X'0420',10,_ucs2 X'0421') r; SHOW CREATE TABLE t1; DROP TABLE t1; + + +# +# BUG3946 +# + +create table t2(f1 Char(30)); +insert into t2 values ("103000"), ("22720000"), ("3401200"), ("78000"); +select lpad(f1, 12, "-o-/") from t2; +drop table t2; ###################################################### # # Test of like diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 4e68efeffc3..6a504a8533a 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -141,3 +141,19 @@ select * from t1 where a = 'b'; select * from t1 where a = 'b' and a = 'b'; select * from t1 where a = 'b' and a != 'b'; drop table t1; + +# +# Bug #3928 regexp [[:>:]] and UTF-8 +# +set names utf8; + +# This should return TRUE +select 'ваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]'; +select 'ваÑÑ ' rlike '[[:<:]]ваÑÑ[[:>:]]'; +select ' ваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]'; +select ' ваÑÑ ' rlike '[[:<:]]ваÑÑ[[:>:]]'; + +# This should return FALSE +select 'ваÑÑz' rlike '[[:<:]]ваÑÑ[[:>:]]'; +select 'zваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]'; +select 'zваÑÑz' rlike '[[:<:]]ваÑÑ[[:>:]]'; diff --git a/mysql-test/t/rpl_charset.test b/mysql-test/t/rpl_charset.test new file mode 100644 index 00000000000..c13b57a3108 --- /dev/null +++ b/mysql-test/t/rpl_charset.test @@ -0,0 +1,153 @@ +# Replication of character sets. +# This test will fail if the server/client does not support enough charsets. + +# Remember that there currently exists +# Bug #2326: Charset of table is determined by charset of db only if "USE db;" + +source include/master-slave.inc; +--disable_warnings +drop database if exists test2; +drop database if exists test3; +--enable_warnings + +create database test2 character set latin2; +set @@character_set_server=latin5; +create database test3; +--disable_query_log +select "--- --master--" as ""; +--enable_query_log +show create database test2; +show create database test3; +sync_slave_with_master; +--disable_query_log +select "--- --slave--" as ""; +--enable_query_log +show create database test2; +show create database test3; + +connection master; +set @@collation_server=armscii_bin; +drop database test3; +create database test3; +--disable_query_log +select "--- --master--" as ""; +--enable_query_log +show create database test3; +sync_slave_with_master; +--disable_query_log +select "--- --slave--" as ""; +--enable_query_log +show create database test3; + +connection master; +use test2; +create table t1 (a int auto_increment primary key, b varchar(100)); +set character_set_client=cp850, collation_connection=latin2_croatian_ci; +insert into t1 (b) values(@@character_set_server); +insert into t1 (b) values(@@collation_server); +# character_set_database and collation_database are not tested as they +# are not replicated (Bar said that this variable may be removed shortly). +insert into t1 (b) values(@@character_set_client); +# collation_client does not exist +insert into t1 (b) values(@@character_set_connection); +insert into t1 (b) values(@@collation_connection); +--disable_query_log +select "--- --master--" as ""; +--enable_query_log +select * from t1 order by a; +sync_slave_with_master; +--disable_query_log +select "--- --slave--" as ""; +--enable_query_log +select * from test2.t1 order by a; + +connection master; +set character_set_client=latin1, collation_connection=latin1_german1_ci; +truncate table t1; +insert into t1 (b) values(@@collation_connection); +insert into t1 (b) values(LEAST("Müller","Muffler")); +set collation_connection=latin1_german2_ci; +insert into t1 (b) values(@@collation_connection); +insert into t1 (b) values(LEAST("Müller","Muffler")); +--disable_query_log +select "--- --master--" as ""; +--enable_query_log +select * from t1 order by a; +sync_slave_with_master; +--disable_query_log +select "--- --slave--" as ""; +--enable_query_log +select * from test2.t1 order by a; + +# See if SET ONE_SHOT gets into binlog when LOAD DATA +connection master; +load data infile '../../std_data/words.dat' into table t1 (b); + +# See if user var is prefixed with collation in binlog and replicated well. +# Note: replication of user variables is broken as far as derivation is +# concerned. That's because when we store a user variable in the binlog, +# we lose its derivation. So later on the slave, it's impossible to +# know if the collation was explicit or not, so we use DERIVATION_NONE, +# which provokes error messages (like 'Illegal mix of collation') when +# we replay the master's INSERT/etc statements. +set @a= _cp850 'Müller' collate cp850_general_ci; +truncate table t1; +insert into t1 (b) values(collation(@a)); +--disable_query_log +select "--- --master--" as ""; +--enable_query_log +select * from t1 order by a; +sync_slave_with_master; +--disable_query_log +select "--- --slave--" as ""; +--enable_query_log +select * from test2.t1 order by a; + +connection master; +drop database test2; +drop database test3; +show binlog events from 79; +sync_slave_with_master; + +# Check that we can't change global.collation_server + +error 1105; +set global character_set_server=latin2; +connection master; +error 1105; +set global character_set_server=latin2; + +# Check that SET ONE_SHOT is really one shot + +set one_shot @@character_set_server=latin5; +set @@max_join_size=1000; +select @@character_set_server; +select @@character_set_server; +set @@character_set_server=latin5; +select @@character_set_server; +select @@character_set_server; + +# ONE_SHOT on not charset/collation stuff is not allowed +error 1105; +set one_shot max_join_size=10; + +# Test of wrong character set numbers; +error 1115; +set character_set_client=9999999; +error 1273; +set collation_server=9999998; + +# This one was contributed by Sergey Petrunia (BUG#3943) + +use test; +CREATE TABLE t1 (c1 VARBINARY(255), c2 VARBINARY(255)); +SET CHARACTER_SET_CLIENT=koi8r, + CHARACTER_SET_CONNECTION=cp1251, + CHARACTER_SET_RESULTS=koi8r; +INSERT INTO t1 (c1, c2) VALUES ('îÕ, ÚÁ ÒÙÂÁÌËÕ','îÕ, ÚÁ ÒÙÂÁÌËÕ'); +select hex(c1), hex(c2) from t1; +sync_slave_with_master; +select hex(c1), hex(c2) from t1; +connection master; +drop table t1; +sync_slave_with_master; diff --git a/mysql-test/t/rpl_server_id1.test b/mysql-test/t/rpl_server_id1.test index aefcb81c930..4d504325294 100644 --- a/mysql-test/t/rpl_server_id1.test +++ b/mysql-test/t/rpl_server_id1.test @@ -1,5 +1,8 @@ -# This test checks that a slave does not execute queries originating -# from itself, by default. +# This test checks that the slave I/O thread refuses to start if slave +# and master have the same server id (because this is a useless setup, +# and otherwise SHOW SLAVE STATUS shows progress but all queries are +# ignored, which has caught our customers), unless +# --replicate-same-server-id. source include/master-slave.inc; connection slave; @@ -18,5 +21,4 @@ insert into t1 values (1); # (when slave is its own master without --replicate-same-server-id) sleep 2; # enough time for the event to be replicated (it should not) show status like "slave_running"; -select * from t1; drop table t1; diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index a28b327cf58..601724e68c8 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -99,3 +99,24 @@ select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST'; select charset(@a),collation(@a),coercibility(@a); --error 1267 select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci; + +# Check that user variables are binlogged correctly (BUG#3875) +create table t1 (a varchar(50)); +reset master; +SET TIMESTAMP=10000; +SET @`a b`='hello'; +INSERT INTO t1 VALUES(@`a b`); +set @var1= "';aaa"; +insert into t1 values (@var1); +create table t2 (c char(30)) charset=ucs2; +set @v=convert('abc' using ucs2); +insert into t2 values (@v); +show binlog events from 79; +# more important than SHOW BINLOG EVENTS, mysqlbinlog (where we +# absolutely need variables names to be quoted and strings to be +# escaped). +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 +drop table t1, t2; + + diff --git a/mysys/ChangeLog b/mysys/ChangeLog index e24fc00b493..7a426106667 100644 --- a/mysys/ChangeLog +++ b/mysys/ChangeLog @@ -91,7 +91,7 @@ Tue Mar 26 15:09:45 1991 Mikael WIDENIUS (monty at panther) Sat Mar 23 10:49:49 1991 Michael Widenius (monty at LYNX) - * Added init of alarm variables to skipp some warnings from gcc. + * Added init of alarm variables to skip some warnings from gcc. Tue Mar 5 16:50:34 1991 Michael Widenius (monty at LYNX) @@ -124,7 +124,7 @@ Mon Aug 27 22:20:38 1990 Michael Widenius (monty at lynx) Sun Apr 1 23:29:47 1990 Monty (monty at monty) * Changed mf_keydisk.c to have separate functions for read and write. - Read can now return pointer to intern key-buffer to skipp + Read can now return pointer to intern key-buffer to skip unessessary memcpy-s. Fri Mar 23 23:03:39 1990 Monty (monty at monty) diff --git a/mysys/charset.c b/mysys/charset.c index 62068beccae..7eccf2dab68 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -158,7 +158,7 @@ static int ch2x(int ch) if (ch >= 'a' && ch <= 'f') return 10 + ch - 'a'; - if (ch >= 'A' && ch <= 'Z') + if (ch >= 'A' && ch <= 'F') return 10 + ch - 'A'; return -1; diff --git a/mysys/default.c b/mysys/default.c index 056f686e16f..792233ed10d 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -222,7 +222,7 @@ int load_defaults(const char *conf_file, const char **groups, /* copy name + found arguments + command line arguments to new array */ res[0]= argv[0][0]; /* Name MUST be set, even by embedded library */ memcpy((gptr) (res+1), args.buffer, args.elements*sizeof(char*)); - /* Skipp --defaults-file and --defaults-extra-file */ + /* Skip --defaults-file and --defaults-extra-file */ (*argc)-= args_used; (*argv)+= args_used; diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index 530721a79ad..7b5371c4289 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -800,7 +800,7 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count) { /* Fix if skipped bytes */ if (info->aio_read_pos + read_length < info->pos_in_file) { - read_length=0; /* Skipp block */ + read_length=0; /* Skip block */ next_pos_in_file=info->pos_in_file; } else @@ -894,7 +894,7 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count) if (aioread(info->file,read_buffer,(int) max_length, (my_off_t) next_pos_in_file,MY_SEEK_SET, &info->aio_result.result)) - { /* Skipp async io */ + { /* Skip async io */ my_errno=errno; DBUG_PRINT("error",("got error: %d, aio_result: %d from aioread, async skipped", errno, info->aio_result.result.aio_errno)); diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index bce08b9795b..70b2f288538 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -266,7 +266,7 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) fmt++; /* Found one '%' */ } - /* Skipp if max size is used (to be compatible with printf) */ + /* Skip if max size is used (to be compatible with printf) */ while (my_isdigit(&my_charset_latin1, *fmt) || *fmt == '.' || *fmt == '-') fmt++; if (*fmt == 's') /* String parameter */ diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c index 2d0a5ea282b..9193238708d 100644 --- a/mysys/mf_pack.c +++ b/mysys/mf_pack.c @@ -43,7 +43,7 @@ void pack_dirname(my_string to, const char *from) (void) intern_filename(to,from); /* Change to intern name */ #ifdef FN_DEVCHAR - if ((start=strrchr(to,FN_DEVCHAR)) != 0) /* Skipp device part */ + if ((start=strrchr(to,FN_DEVCHAR)) != 0) /* Skip device part */ start++; else #endif @@ -131,7 +131,7 @@ uint cleanup_dirname(register my_string to, const char *from) from_ptr=(my_string) from; #ifdef FN_DEVCHAR if ((pos=strrchr(from_ptr,FN_DEVCHAR)) != 0) - { /* Skipp device part */ + { /* Skip device part */ length=(uint) (pos-from_ptr)+1; start=strnmov(buff,from_ptr,length); from_ptr+=length; } @@ -195,7 +195,7 @@ uint cleanup_dirname(register my_string to, const char *from) pos--; /* Remove dupplicate '/' */ } else if (pos-start > 1 && pos[-1] == FN_CURLIB && pos[-2] == FN_LIBCHAR) - pos-=2; /* Skipp /./ */ + pos-=2; /* Skip /./ */ else if (pos > buff+1 && pos[-1] == FN_HOMELIB && pos[-2] == FN_LIBCHAR) { /* Found ..../~/ */ buff[0]=FN_HOMELIB; @@ -409,7 +409,7 @@ uint system_filename(my_string to, const char *from) libchar_found=0; (void) strmov(buff,from); /* If to == from */ from_pos= buff; - if ((pos=strrchr(from_pos,FN_DEVCHAR))) /* Skipp device part */ + if ((pos=strrchr(from_pos,FN_DEVCHAR))) /* Skip device part */ { pos++; to_pos=strnmov(to,from_pos,(size_s) (pos-from_pos)); @@ -419,7 +419,7 @@ uint system_filename(my_string to, const char *from) to_pos=to; if (from_pos[0] == FN_CURLIB && from_pos[1] == FN_LIBCHAR) - from_pos+=2; /* Skipp './' */ + from_pos+=2; /* Skip './' */ if (strchr(from_pos,FN_LIBCHAR)) { *(to_pos++) = FN_C_BEFORE_DIR; @@ -487,7 +487,7 @@ my_string intern_filename(my_string to, const char *from) convert_dirname(buff,from,NullS); /* change '<>' to '[]' */ from_pos=buff; - if ((pos=strrchr(from_pos,FN_DEVCHAR))) /* Skipp device part */ + if ((pos=strrchr(from_pos,FN_DEVCHAR))) /* Skip device part */ { pos++; to_pos=strnmov(to,from_pos,(size_s) (pos-from_pos)); diff --git a/mysys/mf_soundex.c b/mysys/mf_soundex.c index 27ab4892c57..c0c6105a6eb 100644 --- a/mysys/mf_soundex.c +++ b/mysys/mf_soundex.c @@ -52,7 +52,7 @@ void soundex(CHARSET_INFO * cs,register my_string out_pntr, my_string in_pntr, if (remove_garbage) { - while (*in_pntr && !my_isalpha(cs,*in_pntr)) /* Skipp pre-space */ + while (*in_pntr && !my_isalpha(cs,*in_pntr)) /* Skip pre-space */ in_pntr++; } *out_pntr++ = map[(uchar)*in_pntr]; /* Copy first letter */ @@ -82,7 +82,7 @@ void soundex(CHARSET_INFO * cs,register my_string out_pntr, my_string in_pntr, /* If alpha, map input letter to soundex code. - If not alpha and remove_garbage is set then skipp to next char + If not alpha and remove_garbage is set then skip to next char else return 0 */ diff --git a/mysys/mf_wfile.c b/mysys/mf_wfile.c index b964d7ee494..7d537eaa06a 100644 --- a/mysys/mf_wfile.c +++ b/mysys/mf_wfile.c @@ -39,7 +39,7 @@ WF_PACK *wf_comp(my_string str) WF_PACK *ret; DBUG_ENTER("wf_comp"); - not_pos= -1; /* Skipp space and '!' in front */ + not_pos= -1; /* Skip space and '!' in front */ while (*str == ' ') str++; if (*str == '!') diff --git a/mysys/my_error.c b/mysys/my_error.c index 33d79bbc5e6..9789de9d58a 100644 --- a/mysys/my_error.c +++ b/mysys/my_error.c @@ -68,10 +68,10 @@ int my_error(int nr,myf MyFlags, ...) } else { - /* Skipp if max size is used (to be compatible with printf) */ + /* Skip if max size is used (to be compatible with printf) */ while (my_isdigit(&my_charset_latin1, *tpos) || *tpos == '.' || *tpos == '-') tpos++; - if (*tpos == 'l') /* Skipp 'l' argument */ + if (*tpos == 'l') /* Skip 'l' argument */ tpos++; if (*tpos == 's') /* String parameter */ { diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c index a08d28d8545..fd47c532cff 100644 --- a/mysys/my_getwd.c +++ b/mysys/my_getwd.c @@ -108,7 +108,7 @@ int my_setwd(const char *dir, myf MyFlags) { uint drive,drives; - pos++; /* Skipp FN_DEVCHAR */ + pos++; /* Skip FN_DEVCHAR */ drive=(uint) (my_toupper(&my_charset_latin1,dir[0])-'A'+1); drives= (uint) -1; if ((pos-(byte*) dir) == 2 && drive > 0 && drive < 32) diff --git a/scripts/mysql_find_rows.sh b/scripts/mysql_find_rows.sh index 3d7bad3323e..91ffc326e16 100644 --- a/scripts/mysql_find_rows.sh +++ b/scripts/mysql_find_rows.sh @@ -16,7 +16,7 @@ usage() if ($opt_help || $opt_Information); $query=$search=$database=$set=""; $eoq=0; while (<>) { - next if (length($query) == 0 && /^\#/); # Skipp comments + next if (length($query) == 0 && /^\#/); # Skip comments $query.=search($_); if ($eoq) { diff --git a/sql-common/client.c b/sql-common/client.c index 87e62b5cd11..962faf5cbe1 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1835,40 +1835,39 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, } /* Set character set */ - if (mysql->options.charset_name) + if (!mysql->options.charset_name && + !(mysql->options.charset_name= + my_strdup(MYSQL_DEFAULT_CHARSET_NAME,MYF(MY_WME)))) + goto error; + { const char *save= charsets_dir; if (mysql->options.charset_dir) charsets_dir=mysql->options.charset_dir; mysql->charset=get_charset_by_csname(mysql->options.charset_name, - MY_CS_PRIMARY, - MYF(MY_WME)); + MY_CS_PRIMARY, MYF(MY_WME)); charsets_dir= save; - - if (!mysql->charset) - { - net->last_errno=CR_CANT_READ_CHARSET; - strmov(net->sqlstate, unknown_sqlstate); - if (mysql->options.charset_dir) - my_snprintf(net->last_error, sizeof(net->last_error)-1, - ER(net->last_errno), - mysql->options.charset_name, - mysql->options.charset_dir); - else - { - char cs_dir_name[FN_REFLEN]; - get_charsets_dir(cs_dir_name); - my_snprintf(net->last_error, sizeof(net->last_error)-1, - ER(net->last_errno), - mysql->options.charset_name, - cs_dir_name); - } - goto error; - } } - else + + if (!mysql->charset) { - mysql->charset= default_charset_info; + net->last_errno=CR_CANT_READ_CHARSET; + strmov(net->sqlstate, unknown_sqlstate); + if (mysql->options.charset_dir) + my_snprintf(net->last_error, sizeof(net->last_error)-1, + ER(net->last_errno), + mysql->options.charset_name, + mysql->options.charset_dir); + else + { + char cs_dir_name[FN_REFLEN]; + get_charsets_dir(cs_dir_name); + my_snprintf(net->last_error, sizeof(net->last_error)-1, + ER(net->last_errno), + mysql->options.charset_name, + cs_dir_name); + } + goto error; } diff --git a/sql/Makefile.am b/sql/Makefile.am index 469b82f95fa..cdbf78bed0e 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -58,7 +58,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ log_event.h sql_repl.h slave.h \ stacktrace.h sql_sort.h sql_cache.h set_var.h \ spatial.h gstream.h client_settings.h \ - examples/ha_example.h + examples/ha_example.h examples/ha_archive.h mysqld_SOURCES = sql_lex.cc sql_handler.cc \ item.cc item_sum.cc item_buff.cc item_func.cc \ item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \ @@ -88,7 +88,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \ client.c sql_client.cc mini_client_errors.c pack.c\ stacktrace.c repl_failsafe.h repl_failsafe.cc \ gstream.cc spatial.cc sql_help.cc protocol_cursor.cc \ - examples/ha_example.cc + examples/ha_example.cc examples/ha_archive.cc gen_lex_hash_SOURCES = gen_lex_hash.cc gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS) diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc new file mode 100644 index 00000000000..001ab735497 --- /dev/null +++ b/sql/examples/ha_archive.cc @@ -0,0 +1,586 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifdef __GNUC__ +#pragma implementation // gcc: Class implementation +#endif + +#include <mysql_priv.h> + +#ifdef HAVE_ARCHIVE_DB +#include "ha_archive.h" + +/* + First, if you want to understand storage engines you should look at + ha_example.cc and ha_example.h. + This example was written as a test case for a customer who needed + a storage engine without indexes that could compress data very well. + So, welcome to a completely compressed storage engine. This storage + engine only does inserts. No replace, deletes, or updates. All reads are + complete table scans. Compression is done through gzip (bzip compresses + better, but only marginally, if someone asks I could add support for + it too, but beaware that it costs a lot more in CPU time then gzip). + + We keep a file pointer open for each instance of ha_archive for each read + but for writes we keep one open file handle just for that. We flush it + only if we have a read occur. gzip handles compressing lots of records + at once much better then doing lots of little records between writes. + It is possible to not lock on writes but this would then mean we couldn't + handle bulk inserts as well (that is if someone was trying to read at + the same time since we would want to flush). + + No attempts at durability are made. You can corrupt your data. + + For performance as far as table scans go it is quite fast. I don't have + good numbers but locally it has out performed both Innodb and MyISAM. For + Innodb the question will be if the table can be fit into the buffer + pool. For MyISAM its a question of how much the file system caches the + MyISAM file. With enough free memory MyISAM is faster. Its only when the OS + doesn't have enough memory to cache entire table that archive turns out + to be any faster. For writes it is always a bit slower then MyISAM. It has no + internal limits though for row length. + + Examples between MyISAM (packed) and Archive. + + Table with 76695844 identical rows: + 29680807 a_archive.ARZ + 920350317 a.MYD + + + Table with 8991478 rows (all of Slashdot's comments): + 1922964506 comment_archive.ARZ + 2944970297 comment_text.MYD + + + TODO: + Add bzip optional support. + Allow users to set compression level. + Add truncate table command. + Implement versioning, should be easy. + Implement optimize so we can fix broken tables. + Allow for errors, find a way to mark bad rows. + See if during an optimize you can make the table smaller. + Talk to the gzip guys, come up with a writable format so that updates are doable + without switching to a block method. + Add optional feature so that rows can be flushed at interval (which will cause less + compression but may speed up ordered searches). + + -Brian +*/ + +/* Variables for archive share methods */ +pthread_mutex_t archive_mutex; +static HASH archive_open_tables; +static int archive_init= 0; + +/* The file extension */ +#define ARZ ".ARZ" + +/* + Used for hash table that tracks open tables. +*/ +static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length, + my_bool not_used __attribute__((unused))) +{ + *length=share->table_name_length; + return (byte*) share->table_name; +} + + +/* + Example of simple lock controls. + See ha_example.cc for a description. +*/ +static ARCHIVE_SHARE *get_share(const char *table_name, TABLE *table) +{ + ARCHIVE_SHARE *share; + uint length; + char *tmp_name; + + if (!archive_init) + { + /* Hijack a mutex for init'ing the storage engine */ + pthread_mutex_lock(&LOCK_mysql_create_db); + if (!archive_init) + { + archive_init++; + VOID(pthread_mutex_init(&archive_mutex,MY_MUTEX_INIT_FAST)); + (void) hash_init(&archive_open_tables,system_charset_info,32,0,0, + (hash_get_key) archive_get_key,0,0); + } + pthread_mutex_unlock(&LOCK_mysql_create_db); + } + pthread_mutex_lock(&archive_mutex); + length=(uint) strlen(table_name); + + if (!(share=(ARCHIVE_SHARE*) hash_search(&archive_open_tables, + (byte*) table_name, + length))) + { + if (!(share=(ARCHIVE_SHARE *) + my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), + &share, sizeof(*share), + &tmp_name, length+1, + NullS))) + { + pthread_mutex_unlock(&archive_mutex); + return NULL; + } + + share->use_count=0; + share->table_name_length=length; + share->table_name=tmp_name; + fn_format(share->data_file_name,table_name,"",ARZ,MY_REPLACE_EXT|MY_UNPACK_FILENAME); + strmov(share->table_name,table_name); + /* + It is expensive to open and close the data files and since you can't have + a gzip file that can be both read and written we keep a writer open + that is shared amoung all open tables. + */ + if ((share->archive_write= gzopen(share->data_file_name, "ab")) == NULL) + goto error; + if (my_hash_insert(&archive_open_tables, (byte*) share)) + goto error; + thr_lock_init(&share->lock); + if (pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST)) + goto error2; + } + share->use_count++; + pthread_mutex_unlock(&archive_mutex); + + return share; + +error2: + thr_lock_delete(&share->lock); + /* We close, but ignore errors since we already have errors */ + (void)gzclose(share->archive_write); +error: + pthread_mutex_unlock(&archive_mutex); + my_free((gptr) share, MYF(0)); + + return NULL; +} + + +/* + Free lock controls. + See ha_example.cc for a description. +*/ +static int free_share(ARCHIVE_SHARE *share) +{ + int rc= 0; + pthread_mutex_lock(&archive_mutex); + if (!--share->use_count) + { + hash_delete(&archive_open_tables, (byte*) share); + thr_lock_delete(&share->lock); + pthread_mutex_destroy(&share->mutex); + my_free((gptr) share, MYF(0)); + if (gzclose(share->archive_write) == Z_ERRNO) + rc= -1; + } + pthread_mutex_unlock(&archive_mutex); + + return rc; +} + + +/* + We just implement one additional file extension. +*/ +const char **ha_archive::bas_ext() const +{ static const char *ext[]= { ARZ, NullS }; return ext; } + + +/* + When opening a file we: + Create/get our shared structure. + Init out lock. + We open the file we will read from. + Set the size of ref_length. +*/ +int ha_archive::open(const char *name, int mode, uint test_if_locked) +{ + DBUG_ENTER("ha_archive::open"); + + if (!(share= get_share(name, table))) + DBUG_RETURN(1); + thr_lock_data_init(&share->lock,&lock,NULL); + + if ((archive= gzopen(share->data_file_name, "rb")) == NULL) + { + (void)free_share(share); //We void since we already have an error + DBUG_RETURN(-1); + } + + DBUG_RETURN(0); +} + + +/* + Closes the file. We first close this storage engines file handle to the + archive and then remove our reference count to the table (and possibly + free it as well). + */ +int ha_archive::close(void) +{ + DBUG_ENTER("ha_archive::close"); + int rc= 0; + if (gzclose(archive) == Z_ERRNO) + rc =-1; + rc |= free_share(share); + DBUG_RETURN(rc); +} + + +/* + We create our data file here. The format is pretty simple. The first bytes in + any file are the version number. Currently we do nothing with this, but in + the future this gives us the ability to figure out version if we change the + format at all. After the version we starting writing our rows. Unlike other + storage engines we do not "pack" our data. Since we are about to do a general + compression, packing would just be a waste of CPU time. If the table has blobs + they are written after the row in the order of creation. + So to read a row we: + Read the version + Read the record and copy it into buf + Loop through any blobs and read them + */ +int ha_archive::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info) +{ + File create_file; + char name_buff[FN_REFLEN]; + size_t written; + DBUG_ENTER("ha_archive::create"); + + if ((create_file= my_create(fn_format(name_buff,name,"",ARZ,MY_REPLACE_EXT|MY_UNPACK_FILENAME),0, + O_RDWR | O_TRUNC,MYF(MY_WME))) < 0) + DBUG_RETURN(-1); + if ((archive= gzdopen(create_file, "ab")) == NULL) + { + delete_table(name); + DBUG_RETURN(-1); + } + version= ARCHIVE_VERSION; + written= gzwrite(archive, &version, sizeof(version)); + if (written == 0 || written != sizeof(version)) + { + delete_table(name); + DBUG_RETURN(-1); + } + if (gzclose(archive)) + { + delete_table(name); + DBUG_RETURN(-1); + } + + DBUG_RETURN(0); +} + +/* + Look at ha_archive::open() for an explanation of the row format. + Here we just write out the row. +*/ +int ha_archive::write_row(byte * buf) +{ + char *pos; + z_off_t written; + DBUG_ENTER("ha_archive::write_row"); + + statistic_increment(ha_write_count,&LOCK_status); + if (table->timestamp_default_now) + update_timestamp(buf+table->timestamp_default_now-1); + written= gzwrite(share->archive_write, buf, table->reclength); + share->dirty= true; + if (written == 0 || written != table->reclength) + DBUG_RETURN(-1); + + for (Field_blob **field=table->blob_field ; *field ; field++) + { + char *ptr; + uint32 size= (*field)->get_length(); + + (*field)->get_ptr(&ptr); + written= gzwrite(share->archive_write, ptr, (unsigned)size); + if (written == 0 || written != size) + DBUG_RETURN(-1); + } + + DBUG_RETURN(0); +} + + +/* + All calls that need to scan the table start with this method. If we are told + that it is a table scan we rewind the file to the beginning, otherwise + we assume the position will be set. +*/ +int ha_archive::rnd_init(bool scan) +{ + DBUG_ENTER("ha_archive::rnd_init"); + int read; // gzread() returns int, and we use this to check the header + + /* We rewind the file so that we can read from the beginning if scan */ + if(scan) + { + records= 0; + if (gzrewind(archive)) + DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); + } + + /* + If dirty, we lock, and then reset/flush the data. + I found that just calling gzflush() doesn't always work. + */ + if (share->dirty == true) + { + pthread_mutex_lock(&share->mutex); + if (share->dirty == true) + { +/* I was having problems with OSX, but it worked for 10.3 so I am wrapping this with and ifdef */ +#ifdef BROKEN_GZFLUSH + gzclose(share->archive_write); + if ((share->archive_write= gzopen(share->data_file_name, "ab")) == NULL) + { + pthread_mutex_unlock(&share->mutex); + DBUG_RETURN(-1); + } +#else + gzflush(share->archive_write, Z_SYNC_FLUSH); +#endif + share->dirty= false; + } + pthread_mutex_unlock(&share->mutex); + } + + /* + At the moment we just check the size of version to make sure the header is + intact. + */ + if (scan) + { + read= gzread(archive, &version, sizeof(version)); + if (read == 0 || read != sizeof(version)) + DBUG_RETURN(-1); + } + + DBUG_RETURN(0); +} + + +/* + This is the method that is used to read a row. It assumes that the row is + positioned where you want it. +*/ +int ha_archive::get_row(byte *buf) +{ + int read; // Bytes read, gzread() returns int + char *last; + size_t total_blob_length= 0; + DBUG_ENTER("ha_archive::get_row"); + + read= gzread(archive, buf, table->reclength); + + /* If we read nothing we are at the end of the file */ + if (read == 0) + DBUG_RETURN(HA_ERR_END_OF_FILE); + + /* If the record is the wrong size, the file is probably damaged */ + if (read != table->reclength) + DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); + + /* Calculate blob length, we use this for our buffer */ + for (Field_blob **field=table->blob_field; *field ; field++) + total_blob_length += (*field)->get_length(); + + /* Adjust our row buffer if we need be */ + buffer.alloc(total_blob_length); + last= (char *)buffer.ptr(); + + /* Loop through our blobs and read them */ + for (Field_blob **field=table->blob_field; *field ; field++) + { + size_t size= (*field)->get_length(); + read= gzread(archive, last, size); + if (read == 0 || read != size) + DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); + (*field)->set_ptr(size, last); + last += size; + } + DBUG_RETURN(0); +} + +/* + Called during ORDER BY. Its position is either from being called sequentially + or by having had ha_archive::rnd_pos() called before it is called. +*/ +int ha_archive::rnd_next(byte *buf) +{ + DBUG_ENTER("ha_archive::rnd_next"); + int rc; + + statistic_increment(ha_read_rnd_next_count,&LOCK_status); + current_position= gztell(archive); + rc= get_row(buf); + if (!(HA_ERR_END_OF_FILE == rc)) + records++; + + DBUG_RETURN(rc); +} + + +/* + Thanks to the table flag HA_REC_NOT_IN_SEQ this will be called after + each call to ha_archive::rnd_next() if an ordering of the rows is + needed. +*/ +void ha_archive::position(const byte *record) +{ + DBUG_ENTER("ha_archive::position"); + ha_store_ptr(ref, ref_length, current_position); + DBUG_VOID_RETURN; +} + + +/* + This is called after a table scan for each row if the results of the scan need + to be ordered. It will take *pos and use it to move the cursor in the file so + that the next row that is called is the correctly ordered row. +*/ +int ha_archive::rnd_pos(byte * buf, byte *pos) +{ + DBUG_ENTER("ha_archive::rnd_pos"); + statistic_increment(ha_read_rnd_count,&LOCK_status); + current_position= ha_get_ptr(pos, ref_length); + z_off_t seek= gzseek(archive, current_position, SEEK_SET); + + DBUG_RETURN(get_row(buf)); +} + +/****************************************************************************** + + Everything below here is default, please look at ha_example.cc for + descriptions. + + ******************************************************************************/ + +int ha_archive::update_row(const byte * old_data, byte * new_data) +{ + + DBUG_ENTER("ha_archive::update_row"); + DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); +} + +int ha_archive::delete_row(const byte * buf) +{ + DBUG_ENTER("ha_archive::delete_row"); + DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); +} + +int ha_archive::index_read(byte * buf, const byte * key, + uint key_len __attribute__((unused)), + enum ha_rkey_function find_flag + __attribute__((unused))) +{ + DBUG_ENTER("ha_archive::index_read"); + DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); +} + +int ha_archive::index_read_idx(byte * buf, uint index, const byte * key, + uint key_len __attribute__((unused)), + enum ha_rkey_function find_flag + __attribute__((unused))) +{ + DBUG_ENTER("ha_archive::index_read_idx"); + DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); +} + + +int ha_archive::index_next(byte * buf) +{ + DBUG_ENTER("ha_archive::index_next"); + DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); +} + +int ha_archive::index_prev(byte * buf) +{ + DBUG_ENTER("ha_archive::index_prev"); + DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); +} + +int ha_archive::index_first(byte * buf) +{ + DBUG_ENTER("ha_archive::index_first"); + DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); +} + +int ha_archive::index_last(byte * buf) +{ + DBUG_ENTER("ha_archive::index_last"); + DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); +} + + +void ha_archive::info(uint flag) +{ + DBUG_ENTER("ha_archive::info"); + + /* This is a lie, but you don't want the optimizer to see zero or 1 */ + if (records < 2) + records= 2; + + DBUG_VOID_RETURN; +} + +int ha_archive::extra(enum ha_extra_function operation) +{ + DBUG_ENTER("ha_archive::extra"); + DBUG_RETURN(0); +} + +int ha_archive::reset(void) +{ + DBUG_ENTER("ha_archive::reset"); + DBUG_RETURN(0); +} + + +int ha_archive::external_lock(THD *thd, int lock_type) +{ + DBUG_ENTER("ha_archive::external_lock"); + DBUG_RETURN(0); +} + +THR_LOCK_DATA **ha_archive::store_lock(THD *thd, + THR_LOCK_DATA **to, + enum thr_lock_type lock_type) +{ + if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) + lock.type=lock_type; + *to++= &lock; + return to; +} + +ha_rows ha_archive::records_in_range(int inx, + const byte *start_key,uint start_key_len, + enum ha_rkey_function start_search_flag, + const byte *end_key,uint end_key_len, + enum ha_rkey_function end_search_flag) +{ + DBUG_ENTER("ha_archive::records_in_range "); + DBUG_RETURN(records); // HA_ERR_NOT_IMPLEMENTED +} +#endif /* HAVE_ARCHIVE_DB */ diff --git a/sql/examples/ha_archive.h b/sql/examples/ha_archive.h new file mode 100644 index 00000000000..90f64b4c01c --- /dev/null +++ b/sql/examples/ha_archive.h @@ -0,0 +1,123 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifdef __GNUC__ +#pragma interface /* gcc class implementation */ +#endif + +#include <zlib.h> + +/* + Please read ha_archive.cc first. If you are looking for more general + answers on how storage engines work, look at ha_example.cc and + ha_example.h. +*/ + +typedef struct st_archive_share { + char *table_name; + char data_file_name[FN_REFLEN]; + uint table_name_length,use_count; + pthread_mutex_t mutex; + THR_LOCK lock; + gzFile archive_write; /* Archive file we are working with */ + bool dirty; /* Flag for if a flush should occur */ +} ARCHIVE_SHARE; + +/* + Version for file format. + 1 - Initial Version +*/ +#define ARCHIVE_VERSION 1 + +class ha_archive: public handler +{ + THR_LOCK_DATA lock; /* MySQL lock */ + ARCHIVE_SHARE *share; /* Shared lock info */ + gzFile archive; /* Archive file we are working with */ + z_off_t current_position; /* The position of the row we just read */ + byte byte_buffer[IO_SIZE]; /* Initial buffer for our string */ + String buffer; /* Buffer used for blob storage */ + unsigned int version; /* Used for recording version */ + +public: + ha_archive(TABLE *table): handler(table) + { + /* Set our original buffer from pre-allocated memory */ + buffer.set(byte_buffer, IO_SIZE, system_charset_info); + + /* The size of the offset value we will use for position() */ + ref_length = sizeof(z_off_t); + } + ~ha_archive() + { + } + const char *table_type() const { return "ARCHIVE"; } + const char *index_type(uint inx) { return "NONE"; } + const char **bas_ext() const; + ulong table_flags() const + { + return (HA_REC_NOT_IN_SEQ | HA_NOT_EXACT_COUNT | HA_NO_WRITE_DELAYED | + HA_NO_AUTO_INCREMENT); + } + ulong index_flags(uint inx) const + { + return 0; + } + /* + This is just a default, there is no real limit as far as + archive is concerned. + */ + uint max_record_length() const { return HA_MAX_REC_LENGTH; } + uint max_keys() const { return 0; } + uint max_key_parts() const { return 0; } + uint max_key_length() const { return 0; } + /* + Called in test_quick_select to determine if indexes should be used. + */ + virtual double scan_time() { return (double) (records) / 20.0+10; } + /* The next method will never be called */ + virtual double read_time(ha_rows rows) { return (double) rows / 20.0+1; } + int open(const char *name, int mode, uint test_if_locked); + int close(void); + int write_row(byte * buf); + int update_row(const byte * old_data, byte * new_data); + int delete_row(const byte * buf); + int index_read(byte * buf, const byte * key, + uint key_len, enum ha_rkey_function find_flag); + int index_read_idx(byte * buf, uint idx, const byte * key, + uint key_len, enum ha_rkey_function find_flag); + int index_next(byte * buf); + int index_prev(byte * buf); + int index_first(byte * buf); + int index_last(byte * buf); + int rnd_init(bool scan=1); + int rnd_next(byte *buf); + int rnd_pos(byte * buf, byte *pos); + int get_row(byte *buf); + void position(const byte *record); + void info(uint); + int extra(enum ha_extra_function operation); + int reset(void); + int external_lock(THD *thd, int lock_type); + ha_rows records_in_range(int inx, const byte *start_key,uint start_key_len, + enum ha_rkey_function start_search_flag, + const byte *end_key,uint end_key_len, + enum ha_rkey_function end_search_flag); + int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); + + THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, + enum thr_lock_type lock_type); +}; diff --git a/sql/examples/ha_example.cc b/sql/examples/ha_example.cc index 2d17caf1a83..4c192a94b4b 100644 --- a/sql/examples/ha_example.cc +++ b/sql/examples/ha_example.cc @@ -596,6 +596,10 @@ THR_LOCK_DATA **ha_example::store_lock(THD *thd, shared references released. The variable name will just be the name of the table. You will need to remove any files you have created at this point. + If you do not implement this, the default delete_table() is called from + handler.cc and it will delete all files with the file extentions returned + by bas_ext(). + Called from handler.cc by delete_table and ha_create_table(). Only used during create if the table_flag HA_DROP_BEFORE_CREATE was specified for the storage engine. @@ -610,6 +614,10 @@ int ha_example::delete_table(const char *name) /* Renames a table from one name to another from alter table call. + If you do not implement this, the default rename_table() is called from + handler.cc and it will delete all files with the file extentions returned + by bas_ext(). + Called from sql_table.cc by mysql_rename_table(). */ int ha_example::rename_table(const char * from, const char * to) diff --git a/sql/examples/ha_example.h b/sql/examples/ha_example.h index 2228f04284a..cd8baac2017 100644 --- a/sql/examples/ha_example.h +++ b/sql/examples/ha_example.h @@ -21,6 +21,10 @@ that you can implement. */ +#ifdef __GNUC__ +#pragma interface /* gcc class implementation */ +#endif + /* EXAMPLE_SHARE is a structure that will be shared amoung all open handlers The example implements the minimum of what you will probably need. @@ -87,7 +91,6 @@ public: The next method will never be called if you do not implement indexes. */ virtual double read_time(ha_rows rows) { return (double) rows / 20.0+1; } - virtual bool fast_key_read() { return 1;} /* Everything below are methods that we implment in ha_example.cc. diff --git a/sql/handler.cc b/sql/handler.cc index 4a2948e63f8..717b2ee0ce8 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -35,6 +35,9 @@ #ifdef HAVE_EXAMPLE_DB #include "examples/ha_example.h" #endif +#ifdef HAVE_ARCHIVE_DB +#include "examples/ha_archive.h" +#endif #ifdef HAVE_INNOBASE_DB #include "ha_innodb.h" #else @@ -88,6 +91,8 @@ struct show_table_type_st sys_table_types[]= "Alias for NDBCLUSTER", DB_TYPE_NDBCLUSTER}, {"EXAMPLE",&have_example_db, "Example storage engine", DB_TYPE_EXAMPLE_DB}, + {"ARCHIVE",&have_archive_db, + "Archive storage engine", DB_TYPE_ARCHIVE_DB}, {NullS, NULL, NullS, DB_TYPE_UNKNOWN} }; @@ -189,6 +194,10 @@ handler *get_new_handler(TABLE *table, enum db_type db_type) case DB_TYPE_EXAMPLE_DB: return new ha_example(table); #endif +#ifdef HAVE_ARCHIVE_DB + case DB_TYPE_ARCHIVE_DB: + return new ha_archive(table); +#endif #ifdef HAVE_NDBCLUSTER_DB case DB_TYPE_NDBCLUSTER: return new ha_ndbcluster(table); diff --git a/sql/handler.h b/sql/handler.h index 04a437725ab..e7dcb97f0e8 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -158,7 +158,7 @@ enum db_type DB_TYPE_MRG_ISAM, DB_TYPE_MYISAM, DB_TYPE_MRG_MYISAM, DB_TYPE_BERKELEY_DB, DB_TYPE_INNODB, DB_TYPE_GEMINI, DB_TYPE_NDBCLUSTER, - DB_TYPE_EXAMPLE_DB, + DB_TYPE_EXAMPLE_DB, DB_TYPE_ARCHIVE_DB, DB_TYPE_DEFAULT // Must be last }; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index c6401218fe2..6be9bee438e 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2097,10 +2097,8 @@ String *Item_func_lpad::val_str(String *str) count-= pad_char_length; } if (count > 0) - { - pad->length(pad->charpos(count)); - str->append(*pad); - } + str->append(pad->ptr(), pad->charpos(count), collation.collation); + str->append(*res); null_value= 0; return str; diff --git a/sql/lex.h b/sql/lex.h index e5bc537c213..f8ead8a8d2d 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -310,6 +310,7 @@ static SYMBOL symbols[] = { { "OFFSET", SYM(OFFSET_SYM)}, { "OLD_PASSWORD", SYM(OLD_PASSWORD)}, { "ON", SYM(ON)}, + { "ONE_SHOT", SYM(ONE_SHOT_SYM)}, { "OPEN", SYM(OPEN_SYM)}, { "OPTIMIZE", SYM(OPTIMIZE)}, { "OPTION", SYM(OPTION)}, diff --git a/sql/log.cc b/sql/log.cc index 8df5ea5096b..e7a142230b1 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1231,6 +1231,40 @@ bool MYSQL_LOG::write(Log_event* event_info) if (thd) { +#if MYSQL_VERSION_ID < 50000 + /* + To make replication of charsets working in 4.1 we are writing values + of charset related variables before every statement in the binlog, + if values of those variables differ from global server-wide defaults. + We are using SET ONE_SHOT command so that the charset vars get reset + to default after the first non-SET statement. + In the next 5.0 this won't be needed as we will use the new binlog + format to store charset info. + */ + if ((thd->variables.character_set_client->number != + global_system_variables.collation_server->number) || + (thd->variables.character_set_client->number != + thd->variables.collation_connection->number) || + (thd->variables.collation_server->number != + thd->variables.collation_connection->number)) + { + char buf[200]; + int written= my_snprintf(buf, sizeof(buf)-1, + "SET ONE_SHOT CHARACTER_SET_CLIENT=%lu,\ +COLLATION_CONNECTION=%lu,COLLATION_DATABASE=%lu,COLLATION_SERVER=%lu", + thd->variables.character_set_client->number, + thd->variables.collation_connection->number, + thd->variables.collation_database->number, + thd->variables.collation_server->number); + Query_log_event e(thd, buf, written, 0); + e.set_log_pos(this); + if (e.write(file)) + goto err; + } +#endif + + /* Add logging of timezones here */ + if (thd->last_insert_id_used) { Intvar_log_event e(thd,(uchar) LAST_INSERT_ID_EVENT, diff --git a/sql/log_event.cc b/sql/log_event.cc index fd65ec64a76..a76725a95e0 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2176,7 +2176,7 @@ int Rand_log_event::exec_event(struct st_relay_log_info* rli) void User_var_log_event::pack_info(Protocol* protocol) { char *buf= 0; - uint val_offset= 2 + name_len; + uint val_offset= 4 + name_len; uint event_len= val_offset; if (is_null) @@ -2200,16 +2200,21 @@ void User_var_log_event::pack_info(Protocol* protocol) event_len= longlong10_to_str(uint8korr(val), buf + val_offset,-10)-buf; break; case STRING_RESULT: - /* - This is correct as pack_info is used for SHOW BINLOG command - only. But be carefull this is may be incorrect in other cases as - string may contain \ and '. - */ - event_len= val_offset + 2 + val_len; - buf= my_malloc(event_len, MYF(MY_WME)); - buf[val_offset]= '\''; - memcpy(buf + val_offset + 1, val, val_len); - buf[val_offset + val_len + 1]= '\''; + /* 15 is for 'COLLATE' and other chars */ + buf= my_malloc(event_len+val_len*2+1+2*MY_CS_NAME_SIZE+15, MYF(MY_WME)); + CHARSET_INFO *cs; + if (!(cs= get_charset(charset_number, MYF(0)))) + { + strmov(buf+val_offset, "???"); + event_len+= 3; + } + else + { + char *p= strxmov(buf + val_offset, "_", cs->csname, "'", NullS); + p+= escape_string_for_mysql(&my_charset_bin, p, val, val_len); + p= strxmov(p, "' COLLATE ", cs->name, NullS); + event_len= p-buf; + } break; case ROW_RESULT: default: @@ -2218,8 +2223,10 @@ void User_var_log_event::pack_info(Protocol* protocol) } } buf[0]= '@'; - buf[1+name_len]= '='; - memcpy(buf+1, name, name_len); + buf[1]= '`'; + buf[2+name_len]= '`'; + buf[3+name_len]= '='; + memcpy(buf+2, name, name_len); protocol->store(buf, event_len, &my_charset_bin); my_free(buf, MYF(MY_ALLOW_ZERO_PTR)); } @@ -2311,8 +2318,9 @@ void User_var_log_event::print(FILE* file, bool short_form, char* last_db) fprintf(file, "\tUser_var\n"); } - fprintf(file, "SET @"); + fprintf(file, "SET @`"); my_fwrite(file, (byte*) name, (uint) (name_len), MYF(MY_NABP | MY_WME)); + fprintf(file, "`"); if (is_null) { @@ -2332,7 +2340,36 @@ void User_var_log_event::print(FILE* file, bool short_form, char* last_db) fprintf(file, ":=%s;\n", int_buf); break; case STRING_RESULT: - fprintf(file, ":='%s';\n", val); + { + char *p; + if (!(p= (char *)my_alloca(2*val_len+1))) + break; // no error, as we are 'void' + escape_string_for_mysql(&my_charset_bin, p, val, val_len); +#if MYSQL_VERSION_ID < 50000 + /* + For proper behaviour when mysqlbinlog|mysql, we need to explicitely + specify the variable's collation. It will however cause problems when + people want to mysqlbinlog|mysql into another server not supporting the + character set. But there's not much to do about this and it's unlikely. + */ + CHARSET_INFO *cs; + if (!(cs= get_charset(charset_number, MYF(0)))) + /* + Generate an unusable command (=> syntax error) is probably the best + thing we can do here. + */ + fprintf(file, ":=???;\n"); + else + fprintf(file, ":=_%s'%s' COLLATE %s;\n", cs->csname, p, cs->name); +#else + /* + In 5.0 we will have some SET CHARACTER_SET_ect automatically printed + for all events where it's needed. + */ + fprintf(file, ":='%s';\n", p); +#endif + my_afree(p); + } break; case ROW_RESULT: default: @@ -2353,7 +2390,9 @@ void User_var_log_event::print(FILE* file, bool short_form, char* last_db) int User_var_log_event::exec_event(struct st_relay_log_info* rli) { Item *it= 0; - CHARSET_INFO *charset= get_charset(charset_number, MYF(0)); + CHARSET_INFO *charset; + if (!(charset= get_charset(charset_number, MYF(MY_WME)))) + return 1; LEX_STRING user_var_name; user_var_name.str= name; user_var_name.length= name_len; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 368774877d0..7479474deee 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -915,7 +915,8 @@ extern struct my_option my_long_options[]; /* optional things, have_* variables */ -extern SHOW_COMP_OPTION have_isam, have_innodb, have_berkeley_db, have_example_db; +extern SHOW_COMP_OPTION have_isam, have_innodb, have_berkeley_db; +extern SHOW_COMP_OPTION have_example_db, have_archive_db; extern SHOW_COMP_OPTION have_raid, have_openssl, have_symlink; extern SHOW_COMP_OPTION have_query_cache, have_berkeley_db, have_innodb; extern SHOW_COMP_OPTION have_geometry, have_rtree_keys; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 4f70c72f8ec..5c16fe2e575 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -375,8 +375,8 @@ KEY_CACHE *sql_key_cache; CHARSET_INFO *system_charset_info, *files_charset_info ; CHARSET_INFO *national_charset_info, *table_alias_charset; -SHOW_COMP_OPTION have_berkeley_db, have_innodb, have_isam, - have_ndbcluster, have_example_db; +SHOW_COMP_OPTION have_berkeley_db, have_innodb, have_isam, have_ndbcluster, + have_example_db, have_archive_db; SHOW_COMP_OPTION have_raid, have_openssl, have_symlink, have_query_cache; SHOW_COMP_OPTION have_geometry, have_rtree_keys; SHOW_COMP_OPTION have_crypt, have_compress; @@ -3959,6 +3959,12 @@ Disable with --skip-bdb (will save memory).", REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"bootstrap", OPT_BOOTSTRAP, "Used by mysql installation scripts.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"character_set_server", 'C', "Set the default character set.", + (gptr*) &default_character_set_name, (gptr*) &default_character_set_name, + 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + {"collation_server", OPT_DEFAULT_COLLATION, "Set the default collation.", + (gptr*) &default_collation_name, (gptr*) &default_collation_name, + 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, {"console", OPT_CONSOLE, "Write error output on screen; Don't remove the console window on windows.", (gptr*) &opt_console, (gptr*) &opt_console, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -3992,10 +3998,10 @@ Disable with --skip-bdb (will save memory).", (gptr*) &des_key_file, (gptr*) &des_key_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif /* HAVE_OPENSSL */ - {"default-character-set", 'C', "Set the default character set.", + {"default-character-set", 'C', "Set the default character set (Deprecated option, use character_set_server instead).", (gptr*) &default_character_set_name, (gptr*) &default_character_set_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, - {"default-collation", OPT_DEFAULT_COLLATION, "Set the default collation.", + {"default-collation", OPT_DEFAULT_COLLATION, "Set the default collation (Deprecated option, use character_set_server instead).", (gptr*) &default_collation_name, (gptr*) &default_collation_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, {"default-storage-engine", OPT_STORAGE_ENGINE, @@ -5338,6 +5344,11 @@ static void mysql_init_variables(void) #else have_example_db= SHOW_OPTION_NO; #endif +#ifdef HAVE_ARCHIVE_DB + have_archive_db= SHOW_OPTION_YES; +#else + have_archive_db= SHOW_OPTION_NO; +#endif #ifdef HAVE_NDBCLUSTER_DB have_ndbcluster=SHOW_OPTION_DISABLED; #else diff --git a/sql/set_var.cc b/sql/set_var.cc index 517a3c65ab8..35bcbc9ce34 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -638,6 +638,7 @@ struct show_var_st init_vars[]= { {"ft_query_expansion_limit",(char*) &ft_query_expansion_limit, SHOW_LONG}, {"ft_stopword_file", (char*) &ft_stopword_file, SHOW_CHAR_PTR}, {sys_group_concat_max_len.name, (char*) &sys_group_concat_max_len, SHOW_SYS}, + {"have_archive", (char*) &have_archive_db, SHOW_HAVE}, {"have_bdb", (char*) &have_berkeley_db, SHOW_HAVE}, {"have_compress", (char*) &have_compress, SHOW_HAVE}, {"have_crypt", (char*) &have_crypt, SHOW_HAVE}, @@ -1710,19 +1711,31 @@ CHARSET_INFO *get_old_charset_by_name(const char *name) bool sys_var_collation::check(THD *thd, set_var *var) { CHARSET_INFO *tmp; - char buff[80]; - String str(buff,sizeof(buff), system_charset_info), *res; - if (!(res=var->value->val_str(&str))) + if (var->value->result_type() == STRING_RESULT) { - my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL"); - return 1; + char buff[80]; + String str(buff,sizeof(buff), system_charset_info), *res; + if (!(res=var->value->val_str(&str))) + { + my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL"); + return 1; + } + if (!(tmp=get_charset_by_name(res->c_ptr(),MYF(0)))) + { + my_error(ER_UNKNOWN_COLLATION, MYF(0), res->c_ptr()); + return 1; + } } - - if (!(tmp=get_charset_by_name(res->c_ptr(),MYF(0)))) + else // INT_RESULT { - my_error(ER_UNKNOWN_COLLATION, MYF(0), res->c_ptr()); - return 1; + if (!(tmp=get_charset(var->value->val_int(),MYF(0)))) + { + char buf[20]; + int10_to_str(var->value->val_int(), buf, -10); + my_error(ER_UNKNOWN_COLLATION, MYF(0), buf); + return 1; + } } var->save_result.charset= tmp; // Save for update return 0; @@ -1732,23 +1745,36 @@ bool sys_var_collation::check(THD *thd, set_var *var) bool sys_var_character_set::check(THD *thd, set_var *var) { CHARSET_INFO *tmp; - char buff[80]; - String str(buff,sizeof(buff), system_charset_info), *res; - if (!(res=var->value->val_str(&str))) - { - if (!nullable) + if (var->value->result_type() == STRING_RESULT) + { + char buff[80]; + String str(buff,sizeof(buff), system_charset_info), *res; + if (!(res=var->value->val_str(&str))) { - my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL"); + if (!nullable) + { + my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL"); + return 1; + } + tmp= NULL; + } + else if (!(tmp=get_charset_by_csname(res->c_ptr(),MY_CS_PRIMARY,MYF(0))) && + !(tmp=get_old_charset_by_name(res->c_ptr()))) + { + my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr()); return 1; } - tmp= NULL; } - else if (!(tmp=get_charset_by_csname(res->c_ptr(),MY_CS_PRIMARY,MYF(0))) && - !(tmp=get_old_charset_by_name(res->c_ptr()))) + else // INT_RESULT { - my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr()); - return 1; + if (!(tmp=get_charset(var->value->val_int(),MYF(0)))) + { + char buf[20]; + int10_to_str(var->value->val_int(), buf, -10); + my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), buf); + return 1; + } } var->save_result.charset= tmp; // Save for update return 0; @@ -1861,6 +1887,20 @@ void sys_var_character_set_server::set_default(THD *thd, enum_var_type type) } } +#if defined(HAVE_REPLICATION) && (MYSQL_VERSION_ID < 50000) +bool sys_var_character_set_server::check(THD *thd, set_var *var) +{ + if ((var->type == OPT_GLOBAL) && + (mysql_bin_log.is_open() || + active_mi->slave_running || active_mi->rli.slave_running)) + { + my_printf_error(0, "Binary logging and replication forbid changing \ +the global server character set or collation", MYF(0)); + return 1; + } + return sys_var_character_set::check(thd,var); +} +#endif CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd, enum_var_type type) @@ -1954,6 +1994,20 @@ void sys_var_collation_database::set_default(THD *thd, enum_var_type type) } } +#if defined(HAVE_REPLICATION) && (MYSQL_VERSION_ID < 50000) +bool sys_var_collation_server::check(THD *thd, set_var *var) +{ + if ((var->type == OPT_GLOBAL) && + (mysql_bin_log.is_open() || + active_mi->slave_running || active_mi->rli.slave_running)) + { + my_printf_error(0, "Binary logging and replication forbid changing \ +the global server character set or collation", MYF(0)); + return 1; + } + return sys_var_collation::check(thd,var); +} +#endif bool sys_var_collation_server::update(THD *thd, set_var *var) { @@ -2526,6 +2580,36 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list) } +/* + Say if all variables set by a SET support the ONE_SHOT keyword (currently, + only character set and collation do; later timezones will). + + SYNOPSIS + + not_all_support_one_shot + set_var List of variables to update + + NOTES + It has a "not_" because it makes faster tests (no need to "!") + + RETURN VALUE + 0 all variables of the list support ONE_SHOT + 1 at least one does not support ONE_SHOT +*/ + +bool not_all_support_one_shot(List<set_var_base> *var_list) +{ + List_iterator_fast<set_var_base> it(*var_list); + set_var_base *var; + while ((var= it++)) + { + if (var->no_support_one_shot()) + return 1; + } + return 0; +} + + /***************************************************************************** Functions to handle SET mysql_internal_variable=const_expr *****************************************************************************/ diff --git a/sql/set_var.h b/sql/set_var.h index 699f320bbd9..64bdfdb718b 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -49,10 +49,20 @@ public: const char *name; sys_after_update_func after_update; - sys_var(const char *name_arg) :name(name_arg),after_update(0) - {} +#if MYSQL_VERSION_ID < 50000 + bool no_support_one_shot; +#endif + sys_var(const char *name_arg) + :name(name_arg), after_update(0) +#if MYSQL_VERSION_ID < 50000 + , no_support_one_shot(1) +#endif + {} sys_var(const char *name_arg,sys_after_update_func func) - :name(name_arg),after_update(func) + :name(name_arg), after_update(func) +#if MYSQL_VERSION_ID < 50000 + , no_support_one_shot(1) +#endif {} virtual ~sys_var() {} virtual bool check(THD *thd, set_var *var); @@ -487,12 +497,17 @@ public: class sys_var_collation :public sys_var_thd { public: - sys_var_collation(const char *name_arg) :sys_var_thd(name_arg) {} + sys_var_collation(const char *name_arg) :sys_var_thd(name_arg) + { +#if MYSQL_VERSION_ID < 50000 + no_support_one_shot= 0; +#endif + } bool check(THD *thd, set_var *var); SHOW_TYPE type() { return SHOW_CHAR; } bool check_update_type(Item_result type) { - return type != STRING_RESULT; /* Only accept strings */ + return ((type != STRING_RESULT) && (type != INT_RESULT)); } bool check_default(enum_var_type type) { return 0; } virtual void set_default(THD *thd, enum_var_type type)= 0; @@ -502,13 +517,23 @@ class sys_var_character_set :public sys_var_thd { public: bool nullable; - sys_var_character_set(const char *name_arg) :sys_var_thd(name_arg) - { nullable= 0; } + sys_var_character_set(const char *name_arg) : + sys_var_thd(name_arg) + { + nullable= 0; +#if MYSQL_VERSION_ID < 50000 + /* + In fact only almost all variables derived from sys_var_character_set + support ONE_SHOT; character_set_results doesn't. But that's good enough. + */ + no_support_one_shot= 0; +#endif + } bool check(THD *thd, set_var *var); SHOW_TYPE type() { return SHOW_CHAR; } bool check_update_type(Item_result type) { - return type != STRING_RESULT; /* Only accept strings */ + return ((type != STRING_RESULT) && (type != INT_RESULT)); } bool check_default(enum_var_type type) { return 0; } bool update(THD *thd, set_var *var); @@ -541,6 +566,9 @@ class sys_var_character_set_server :public sys_var_character_set public: sys_var_character_set_server(const char *name_arg) : sys_var_character_set(name_arg) {} +#if defined(HAVE_REPLICATION) && (MYSQL_VERSION_ID < 50000) + bool check(THD *thd, set_var *var); +#endif void set_default(THD *thd, enum_var_type type); CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type); }; @@ -576,6 +604,9 @@ class sys_var_collation_server :public sys_var_collation { public: sys_var_collation_server(const char *name_arg) :sys_var_collation(name_arg) {} +#if defined(HAVE_REPLICATION) && (MYSQL_VERSION_ID < 50000) + bool check(THD *thd, set_var *var); +#endif bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); @@ -689,7 +720,10 @@ public: virtual int check(THD *thd)=0; /* To check privileges etc. */ virtual int update(THD *thd)=0; /* To set the value */ /* light check for PS */ - virtual int light_check(THD *thd) { return check(thd); } + virtual int light_check(THD *thd) { return check(thd); } +#if MYSQL_VERSION_ID < 50000 + virtual bool no_support_one_shot() { return 1; } +#endif }; @@ -731,6 +765,9 @@ public: int check(THD *thd); int update(THD *thd); int light_check(THD *thd); +#if MYSQL_VERSION_ID < 50000 + bool no_support_one_shot() { return var->no_support_one_shot; } +#endif }; @@ -833,6 +870,7 @@ void set_var_init(); void set_var_free(); sys_var *find_sys_var(const char *str, uint length=0); int sql_set_variables(THD *thd, List<set_var_base> *var_list); +bool not_all_support_one_shot(List<set_var_base> *var_list); void fix_delay_key_write(THD *thd, enum_var_type type); ulong fix_sql_mode(ulong sql_mode); extern sys_var_str sys_charset_system; diff --git a/sql/slave.cc b/sql/slave.cc index 59af7c663e9..a9b598d73db 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -72,7 +72,7 @@ static int safe_sleep(THD* thd, int sec, CHECK_KILLED_FUNC thread_killed, static int request_table_dump(MYSQL* mysql, const char* db, const char* table); static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, const char* table_name, bool overwrite); -static int check_master_version_and_clock(MYSQL* mysql, MASTER_INFO* mi); +static int get_master_version_and_clock(MYSQL* mysql, MASTER_INFO* mi); /* @@ -1187,38 +1187,75 @@ slaves can't replicate a 5.0 or newer master."; break; } - MYSQL_RES *master_clock_res; - MYSQL_ROW master_clock_row; - time_t slave_clock; - - if (mysql_real_query(mysql, "SELECT UNIX_TIMESTAMP()", 23)) - errmsg= "\"SELECT UNIX_TIMESTAMP()\" failed on master"; - else if (!(master_clock_res= mysql_store_result(mysql))) + /* + Compare the master and slave's clock. Do not die if master's clock is + unavailable (very old master not supporting UNIX_TIMESTAMP()?). + */ + MYSQL_RES *master_res= 0; + MYSQL_ROW master_row; + + if (!mysql_real_query(mysql, "SELECT UNIX_TIMESTAMP()", 23) && + (master_res= mysql_store_result(mysql)) && + (master_row= mysql_fetch_row(master_res))) { - errmsg= "Could not read the result of \"SELECT UNIX_TIMESTAMP()\" on \ -master"; + mi->clock_diff_with_master= + (long) (time((time_t*) 0) - strtoul(master_row[0], 0, 10)); } - else + else { - if (!(master_clock_row= mysql_fetch_row(master_clock_res))) - errmsg= "Could not read a row from the result of \"SELECT \ -UNIX_TIMESTAMP()\" on master"; - else - { - slave_clock= time((time_t*) 0); - mi->clock_diff_with_master= (long) (slave_clock - - strtoul(master_clock_row[0], 0, 10)); - DBUG_PRINT("info",("slave_clock=%lu, master_clock=%s", - slave_clock, master_clock_row[0])); - } - mysql_free_result(master_clock_res); + mi->clock_diff_with_master= 0; /* The "most sensible" value */ + sql_print_error("Warning: \"SELECT UNIX_TIMESTAMP()\" failed on master, \ +do not trust column Seconds_Behind_Master of SHOW SLAVE STATUS"); + } + if (master_res) + mysql_free_result(master_res); + + /* + Check that the master's server id and ours are different. Because if they + are equal (which can result from a simple copy of master's datadir to slave, + thus copying some my.cnf), replication will work but all events will be + skipped. + Do not die if SHOW VARIABLES LIKE 'SERVER_ID' fails on master (very old + master?). + Note: we could have put a @@SERVER_ID in the previous SELECT + UNIX_TIMESTAMP() instead, but this would not have worked on 3.23 masters. + */ + if (!mysql_real_query(mysql, "SHOW VARIABLES LIKE 'SERVER_ID'", 31) && + (master_res= mysql_store_result(mysql))) + { + if ((master_row= mysql_fetch_row(master_res)) && + (::server_id == strtoul(master_row[1], 0, 10)) && + !replicate_same_server_id) + errmsg= "The slave I/O thread stops because master and slave have equal \ +MySQL server ids; these ids must be different for replication to work (or \ +the --replicate-same-server-id option must be used on slave but this does \ +not always make sense; please check the manual before using it)."; + mysql_free_result(master_res); + } + + /* + Check that the master's global character_set_server and ours are the same. + Not fatal if query fails (old master?). + */ + if (!mysql_real_query(mysql, "SELECT @@GLOBAL.COLLATION_SERVER", 32) && + (master_res= mysql_store_result(mysql))) + { + if ((master_row= mysql_fetch_row(master_res)) && + strcmp(master_row[0], global_system_variables.collation_server->name)) + errmsg= "The slave I/O thread stops because master and slave have \ +different values for the COLLATION_SERVER global variable. The values must \ +be equal for replication to work"; + mysql_free_result(master_res); } + /* Add a timezones check here */ + if (errmsg) { sql_print_error(errmsg); return 1; } + return 0; } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index d16d1de7607..3ee9bd609a2 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -181,6 +181,7 @@ THD::THD():user_time(0), current_statement(0), is_fatal_error(0), current_linfo = 0; slave_thread = 0; variables.pseudo_thread_id= 0; + one_shot_set= 0; file_id = 0; warn_id= 0; db_charset= global_system_variables.collation_database; diff --git a/sql/sql_class.h b/sql/sql_class.h index a3e398dc1d6..867d3f49840 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -801,7 +801,7 @@ public: /* scramble - random string sent to client on handshake */ char scramble[SCRAMBLE_LENGTH+1]; - bool slave_thread; + bool slave_thread, one_shot_set; bool locked, some_tables_deleted; bool last_cuted_field; bool no_errors, password, is_fatal_error; @@ -932,7 +932,7 @@ public: net.last_errno= 0; net.report_error= 0; } - inline bool vio_ok() const { return net.vio; } + inline bool vio_ok() const { return net.vio != 0; } #else void clear_error(); inline bool vio_ok() const { return true; } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 92ed53cf814..3884c8f2674 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -611,7 +611,7 @@ typedef struct st_lex uint fk_delete_opt, fk_update_opt, fk_match_option; uint slave_thd_opt; uint8 describe; - bool drop_if_exists, drop_temporary, local_file; + bool drop_if_exists, drop_temporary, local_file, one_shot_set; bool in_comment, ignore_space, verbose, no_write_to_binlog; bool derived_tables; bool safe_to_cache_query; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a7ecda72905..e83260b5de0 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2918,14 +2918,31 @@ unsent_create_error: } case SQLCOM_SET_OPTION: + { + List<set_var_base> *lex_var_list= &lex->var_list; if (tables && ((res= check_table_access(thd, SELECT_ACL, tables,0)) || (res= open_and_lock_tables(thd,tables)))) break; - if (!(res= sql_set_variables(thd, &lex->var_list))) + if (lex->one_shot_set && not_all_support_one_shot(lex_var_list)) + { + my_printf_error(0, "The SET ONE_SHOT syntax is reserved for \ +purposes internal to the MySQL server", MYF(0)); + res= -1; + break; + } + if (!(res= sql_set_variables(thd, lex_var_list))) + { + /* + If the previous command was a SET ONE_SHOT, we don't want to forget + about the ONE_SHOT property of that SET. So we use a |= instead of = . + */ + thd->one_shot_set|= lex->one_shot_set; send_ok(thd); + } if (thd->net.report_error) res= -1; break; + } case SQLCOM_UNLOCK_TABLES: unlock_locked_tables(thd); @@ -3377,6 +3394,29 @@ unsent_create_error: break; } thd->proc_info="query end"; // QQ + if (thd->one_shot_set) + { + /* + If this is a SET, do nothing. This is to allow mysqlbinlog to print + many SET commands (in this case we want the charset temp setting to + live until the real query). This is also needed so that SET + CHARACTER_SET_CLIENT... does not cancel itself immediately. + */ + if (lex->sql_command != SQLCOM_SET_OPTION) + { + thd->variables.character_set_client= + global_system_variables.character_set_client; + thd->variables.collation_connection= + global_system_variables.collation_connection; + thd->variables.collation_database= + global_system_variables.collation_database; + thd->variables.collation_server= + global_system_variables.collation_server; + thd->update_charset(); + /* Add timezone stuff here */ + thd->one_shot_set= 0; + } + } if (res < 0) send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 23b87a41c1a..1713c81a096 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -210,7 +210,13 @@ static ulong get_param_length(uchar **packet, ulong len) if (len < 5) return 0; (*packet)+=9; // Must be 254 when here - /* TODO: why uint4korr here? (should be uint8korr) */ + /* + In our client-server protocol all numbers bigger than 2^24 + stored as 8 bytes with uint8korr. Here we always know that + parameter length is less than 2^4 so don't look at the second + 4 bytes. But still we need to obey the protocol hence 9 in the + assignment above. + */ return (ulong) uint4korr(pos+1); } #else diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 6a40dc3c23a..dc6968bb15a 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -316,6 +316,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %token NUM %token OFFSET_SYM %token ON +%token ONE_SHOT_SYM %token OPEN_SYM %token OPTION %token OPTIONALLY @@ -4768,7 +4769,7 @@ simple_ident: field_ident: ident { $$=$1;} - | ident '.' ident { $$=$3;} /* Skipp schema name in create*/ + | ident '.' ident { $$=$3;} /* Skip schema name in create*/ | '.' ident { $$=$2;} /* For Delphi */; table_ident: @@ -5002,6 +5003,7 @@ keyword: | NVARCHAR_SYM {} | OFFSET_SYM {} | OLD_PASSWORD {} + | ONE_SHOT_SYM {} | OPEN_SYM {} | PACK_KEYS_SYM {} | PARTIAL {} @@ -5088,6 +5090,7 @@ set: lex->sql_command= SQLCOM_SET_OPTION; lex->option_type=OPT_SESSION; lex->var_list.empty(); + lex->one_shot_set= 0; } option_value_list {} @@ -5106,6 +5109,7 @@ option_type: | GLOBAL_SYM { Lex->option_type= OPT_GLOBAL; } | LOCAL_SYM { Lex->option_type= OPT_SESSION; } | SESSION_SYM { Lex->option_type= OPT_SESSION; } + | ONE_SHOT_SYM { Lex->option_type= OPT_SESSION; Lex->one_shot_set= 1; } ; opt_var_type: diff --git a/sql/time.cc b/sql/time.cc index 6d15fa184a1..992f1afc4af 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -745,7 +745,7 @@ bool str_to_time(const char *str,uint length,TIME *l_time) for (value=0; str != end && my_isdigit(&my_charset_latin1,*str) ; str++) value=value*10L + (long) (*str - '0'); - /* Skipp all space after 'days' */ + /* Skip all space after 'days' */ end_of_days= str; for (; str != end && my_isspace(&my_charset_latin1, str[0]) ; str++) ; diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 2071759ddae..f024fa0cc14 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -402,7 +402,7 @@ static my_bool my_like_range_big5(CHARSET_INFO *cs __attribute__((unused)), } if (*ptr == escape && ptr+1 != end) { - ptr++; /* Skipp escape */ + ptr++; /* Skip escape */ *min_str++= *max_str++ = *ptr; continue; } diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index cc0f226d01c..0dc00a73fa3 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -2715,7 +2715,7 @@ static my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)), } if (*ptr == escape && ptr+1 != end) { - ptr++; /* Skipp escape */ + ptr++; /* Skip escape */ *min_str++= *max_str++ = *ptr; continue; } diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 1b6b1edc8b9..e2a138300c3 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -671,7 +671,7 @@ my_bool my_like_range_tis620(CHARSET_INFO *cs __attribute__((unused)), { if (*ptr == escape && ptr+1 != end) { - ptr++; /* Skipp escape */ + ptr++; /* Skip escape */ *min_str++ = *max_str++ = *ptr; continue; } diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 29d2c5d1358..09b918b0777 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1524,8 +1524,12 @@ MY_UNICASE_INFO *uni_plane[256]={ #ifdef HAVE_CHARSET_utf8 -/* These arrays are taken from usa7 implementation */ - +/* + We consider bytes with code more than 127 as a letter. + This garantees that word boundaries work fine with regular + expressions. Note, there is no need to mark byte 255 as a + letter, it is illegal byte in UTF8. +*/ static uchar ctype_utf8[] = { 0, 32, 32, 32, 32, 32, 32, 32, 32, 32, 40, 40, 40, 40, 40, 32, 32, @@ -1536,16 +1540,18 @@ static uchar ctype_utf8[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, 16, 16, 16, 16, 16,130,130,130,130,130,130, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16, 16, 16, 16, 32, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0 }; +/* The below are taken from usa7 implementation */ + static uchar to_lower_utf8[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, diff --git a/tests/client_test.c b/tests/client_test.c index 1f80ecc9481..04549f3355c 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -19,12 +19,6 @@ protocol Main author: venu ( venu@mysql.com ) - - NOTES: - - To be able to test which fields are used, we are not clearing - the MYSQL_BIND with bzero() but instead just clearing the fields that - are used by the API. - ***************************************************************************/ #include <my_global.h> @@ -38,16 +32,16 @@ #define MAX_TEST_QUERY_LENGTH 300 /* MAX QUERY BUFFER LENGTH */ /* set default options */ -static char *opt_db=0; -static char *opt_user=0; -static char *opt_password=0; -static char *opt_host=0; -static char *opt_unix_socket=0; +static char *opt_db= 0; +static char *opt_user= 0; +static char *opt_password= 0; +static char *opt_host= 0; +static char *opt_unix_socket= 0; static unsigned int opt_port; -static my_bool tty_password=0; +static my_bool tty_password= 0; -static MYSQL *mysql=0; -static char query[MAX_TEST_QUERY_LENGTH]; +static MYSQL *mysql= 0; +static char query[MAX_TEST_QUERY_LENGTH]; static char current_db[]= "client_test_db"; static unsigned int test_count= 0; static unsigned int opt_count= 0; @@ -56,20 +50,20 @@ static unsigned int iter_count= 0; static time_t start_time, end_time; static double total_time; -const char *default_dbug_option="d:t:o,/tmp/client_test.trace"; +const char *default_dbug_option= "d:t:o,/tmp/client_test.trace"; #define myheader(str) \ { \ - fprintf(stdout,"\n\n#####################################\n"); \ - fprintf(stdout,"%d of (%d/%d): %s",test_count++, iter_count,\ + fprintf(stdout, "\n\n#####################################\n"); \ + fprintf(stdout, "%d of (%d/%d): %s", test_count++, iter_count, \ opt_count, str); \ - fprintf(stdout," \n#####################################\n"); \ + fprintf(stdout, " \n#####################################\n"); \ } #define myheader_r(str) \ { \ - fprintf(stdout,"\n\n#####################################\n"); \ - fprintf(stdout,"%s", str); \ - fprintf(stdout," \n#####################################\n"); \ + fprintf(stdout, "\n\n#####################################\n"); \ + fprintf(stdout, "%s", str); \ + fprintf(stdout, " \n#####################################\n"); \ } static void print_error(const char *msg); @@ -93,17 +87,17 @@ if (r) \ assert(r != 0); \ } -#define check_execute(stmt,r) \ +#define check_execute(stmt, r) \ { \ if (r) \ - mysterror(stmt,NULL); \ + mysterror(stmt, NULL); \ assert(r == 0);\ } -#define check_execute_r(stmt,r) \ +#define check_execute_r(stmt, r) \ { \ if (r) \ - mysterror(stmt,NULL); \ + mysterror(stmt, NULL); \ assert(r != 0);\ } @@ -119,46 +113,50 @@ assert(stmt != 0); \ if (stmt == 0) \ myerror(NULL);\ assert(stmt == 0);\ -} +} #define mytest(x) if (!x) {myerror(NULL);assert(TRUE);} #define mytest_r(x) if (x) {myerror(NULL);assert(TRUE);} -/******************************************************** -* print the error message * -*********************************************************/ + +/* Print the error message */ + static void print_error(const char *msg) -{ +{ if (mysql && mysql_errno(mysql)) { if (mysql->server_version) - fprintf(stdout,"\n [MySQL-%s]",mysql->server_version); + fprintf(stdout, "\n [MySQL-%s]", mysql->server_version); else - fprintf(stdout,"\n [MySQL]"); - fprintf(stdout,"[%d] %s\n",mysql_errno(mysql),mysql_error(mysql)); + fprintf(stdout, "\n [MySQL]"); + fprintf(stdout, "[%d] %s\n", mysql_errno(mysql), mysql_error(mysql)); } else if (msg) fprintf(stderr, " [MySQL] %s\n", msg); } + static void print_st_error(MYSQL_STMT *stmt, const char *msg) -{ +{ if (stmt && mysql_stmt_errno(stmt)) { if (stmt->mysql && stmt->mysql->server_version) - fprintf(stdout,"\n [MySQL-%s]",stmt->mysql->server_version); + fprintf(stdout, "\n [MySQL-%s]", stmt->mysql->server_version); else - fprintf(stdout,"\n [MySQL]"); + fprintf(stdout, "\n [MySQL]"); - fprintf(stdout,"[%d] %s\n",mysql_stmt_errno(stmt), + fprintf(stdout, "[%d] %s\n", mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); } - else if (msg) fprintf(stderr, " [MySQL] %s\n", msg); + else if (msg) + fprintf(stderr, " [MySQL] %s\n", msg); } + /* This is to be what mysql_query() is for mysql_real_query(), for - mysql_prepare(): a variant without the 'length' parameter. + mysql_simple_prepare(): a variant without the 'length' parameter. */ + MYSQL_STMT *STDCALL mysql_simple_prepare(MYSQL *mysql, const char *query) { @@ -172,196 +170,197 @@ mysql_simple_prepare(MYSQL *mysql, const char *query) } -/******************************************************** -* connect to the server * -*********************************************************/ +/* Connect to the server */ + static void client_connect() { int rc; - myheader_r("client_connect"); + myheader_r("client_connect"); fprintf(stdout, "\n Establishing a connection to '%s' ...", opt_host); - - if (!(mysql = mysql_init(NULL))) - { + + if (!(mysql= mysql_init(NULL))) + { myerror("mysql_init() failed"); exit(0); } - - if (!(mysql_real_connect(mysql,opt_host,opt_user, + + if (!(mysql_real_connect(mysql, opt_host, opt_user, opt_password, opt_db ? opt_db:"test", opt_port, opt_unix_socket, 0))) { - myerror("connection failed"); + myerror("connection failed"); mysql_close(mysql); - fprintf(stdout,"\n Check the connection options using --help or -?\n"); + fprintf(stdout, "\n Check the connection options using --help or -?\n"); exit(0); - } - - fprintf(stdout," OK"); + } + + fprintf(stdout, " OK"); /* set AUTOCOMMIT to ON*/ mysql_autocommit(mysql, TRUE); - + fprintf(stdout, "\n Creating a test database '%s' ...", current_db); - strxmov(query,"CREATE DATABASE IF NOT EXISTS ", current_db, NullS); - - rc = mysql_query(mysql, query); + strxmov(query, "CREATE DATABASE IF NOT EXISTS ", current_db, NullS); + + rc= mysql_query(mysql, query); myquery(rc); - - strxmov(query,"USE ", current_db, NullS); - rc = mysql_query(mysql, query); + + strxmov(query, "USE ", current_db, NullS); + rc= mysql_query(mysql, query); myquery(rc); - - fprintf(stdout," OK"); + + fprintf(stdout, " OK"); } -/******************************************************** -* close the connection * -*********************************************************/ + +/* Close the connection */ + static void client_disconnect() -{ - myheader_r("client_disconnect"); +{ + myheader_r("client_disconnect"); if (mysql) { fprintf(stdout, "\n droping the test database '%s' ...", current_db); - strxmov(query,"DROP DATABASE IF EXISTS ", current_db, NullS); - + strxmov(query, "DROP DATABASE IF EXISTS ", current_db, NullS); + mysql_query(mysql, query); fprintf(stdout, " OK"); - + fprintf(stdout, "\n closing the connection ..."); mysql_close(mysql); fprintf(stdout, " OK\n"); } } -/******************************************************** -* query processing * -*********************************************************/ + +/* Query processing */ + static void client_query() { int rc; myheader("client_query"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS myclient_test"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS myclient_test"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE myclient_test(id int primary key auto_increment,\ - name varchar(20))"); + rc= mysql_query(mysql, "CREATE TABLE myclient_test(" + "id int primary key auto_increment, " + "name varchar(20))"); myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE myclient_test(id int, name varchar(20))"); + + rc= mysql_query(mysql, "CREATE TABLE myclient_test(id int, name varchar(20))"); myquery_r(rc); - - rc = mysql_query(mysql,"INSERT INTO myclient_test(name) VALUES('mysql')"); + + rc= mysql_query(mysql, "INSERT INTO myclient_test(name) VALUES('mysql')"); myquery(rc); - - rc = mysql_query(mysql,"INSERT INTO myclient_test(name) VALUES('monty')"); + + rc= mysql_query(mysql, "INSERT INTO myclient_test(name) VALUES('monty')"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO myclient_test(name) VALUES('venu')"); + rc= mysql_query(mysql, "INSERT INTO myclient_test(name) VALUES('venu')"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO myclient_test(name) VALUES('deleted')"); + rc= mysql_query(mysql, "INSERT INTO myclient_test(name) VALUES('deleted')"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO myclient_test(name) VALUES('deleted')"); + rc= mysql_query(mysql, "INSERT INTO myclient_test(name) VALUES('deleted')"); myquery(rc); - rc = mysql_query(mysql,"UPDATE myclient_test SET name='updated' WHERE name='deleted'"); + rc= mysql_query(mysql, "UPDATE myclient_test SET name= 'updated' " + "WHERE name= 'deleted'"); myquery(rc); - rc = mysql_query(mysql,"UPDATE myclient_test SET id=3 WHERE name='updated'"); + rc= mysql_query(mysql, "UPDATE myclient_test SET id= 3 WHERE name= 'updated'"); myquery_r(rc); } -/******************************************************** -* print dashes * -*********************************************************/ + +/* Print dashes */ + static void my_print_dashes(MYSQL_RES *result) { MYSQL_FIELD *field; - unsigned int i,j; + unsigned int i, j; - mysql_field_seek(result,0); - fputc('\t',stdout); + mysql_field_seek(result, 0); + fputc('\t', stdout); fputc('+', stdout); - for(i=0; i< mysql_num_fields(result); i++) + for(i= 0; i< mysql_num_fields(result); i++) { - field = mysql_fetch_field(result); - for(j=0; j < field->max_length+2; j++) - fputc('-',stdout); - fputc('+',stdout); + field= mysql_fetch_field(result); + for(j= 0; j < field->max_length+2; j++) + fputc('-', stdout); + fputc('+', stdout); } - fputc('\n',stdout); + fputc('\n', stdout); } -/******************************************************** -* print resultset metadata information * -*********************************************************/ + +/* Print resultset metadata information */ + static void my_print_result_metadata(MYSQL_RES *result) { MYSQL_FIELD *field; - unsigned int i,j; + unsigned int i, j; unsigned int field_count; - mysql_field_seek(result,0); + mysql_field_seek(result, 0); fputc('\n', stdout); fputc('\n', stdout); - field_count = mysql_num_fields(result); - for(i=0; i< field_count; i++) + field_count= mysql_num_fields(result); + for(i= 0; i< field_count; i++) { - field = mysql_fetch_field(result); - j = strlen(field->name); + field= mysql_fetch_field(result); + j= strlen(field->name); if (j < field->max_length) - j = field->max_length; + j= field->max_length; if (j < 4 && !IS_NOT_NULL(field->flags)) - j = 4; - field->max_length = j; + j= 4; + field->max_length= j; } my_print_dashes(result); - fputc('\t',stdout); + fputc('\t', stdout); fputc('|', stdout); - mysql_field_seek(result,0); - for(i=0; i< field_count; i++) + mysql_field_seek(result, 0); + for(i= 0; i< field_count; i++) { - field = mysql_fetch_field(result); - fprintf(stdout, " %-*s |",(int) field->max_length, field->name); + field= mysql_fetch_field(result); + fprintf(stdout, " %-*s |", (int) field->max_length, field->name); } fputc('\n', stdout); my_print_dashes(result); } -/******************************************************** -* process the result set * -*********************************************************/ + +/* Process the result set */ + int my_process_result_set(MYSQL_RES *result) { MYSQL_ROW row; MYSQL_FIELD *field; unsigned int i; - unsigned int row_count=0; - + unsigned int row_count= 0; + if (!result) return 0; my_print_result_metadata(result); - while ((row = mysql_fetch_row(result)) != NULL) + while ((row= mysql_fetch_row(result)) != NULL) { - mysql_field_seek(result,0); - fputc('\t',stdout); - fputc('|',stdout); + mysql_field_seek(result, 0); + fputc('\t', stdout); + fputc('|', stdout); - for(i=0; i< mysql_num_fields(result); i++) + for(i= 0; i< mysql_num_fields(result); i++) { - field = mysql_fetch_field(result); + field= mysql_fetch_field(result); if (row[i] == NULL) fprintf(stdout, " %-*s |", (int) field->max_length, "NULL"); else if (IS_NUM(field->type)) @@ -369,38 +368,39 @@ int my_process_result_set(MYSQL_RES *result) else fprintf(stdout, " %-*s |", (int) field->max_length, row[i]); } - fputc('\t',stdout); - fputc('\n',stdout); + fputc('\t', stdout); + fputc('\n', stdout); row_count++; } - if (row_count) + if (row_count) my_print_dashes(result); if (mysql_errno(mysql) != 0) fprintf(stderr, "\n\tmysql_fetch_row() failed\n"); else - fprintf(stdout,"\n\t%d %s returned\n", row_count, + fprintf(stdout, "\n\t%d %s returned\n", row_count, row_count == 1 ? "row" : "rows"); return row_count; } + int my_process_result(MYSQL *mysql) { MYSQL_RES *result; int row_count; - if (!(result = mysql_store_result(mysql))) + if (!(result= mysql_store_result(mysql))) return 0; - + row_count= my_process_result_set(result); - + mysql_free_result(result); return row_count; } -/******************************************************** -* process the stmt result set * -*********************************************************/ + +/* Process the statement result set */ + #define MAX_RES_FIELDS 50 #define MAX_FIELD_DATA_SIZE 255 @@ -416,15 +416,20 @@ uint my_process_stmt_result(MYSQL_STMT *stmt) my_bool is_null[MAX_RES_FIELDS]; int rc, i; - if (!(result= mysql_get_metadata(stmt))) /* No meta info */ + if (!(result= mysql_stmt_result_metadata(stmt))) /* No meta info */ { - while (!mysql_fetch(stmt)) + while (!mysql_stmt_fetch(stmt)) row_count++; return row_count; } - + field_count= min(mysql_num_fields(result), MAX_RES_FIELDS); - for(i=0; i < field_count; i++) + + bzero((char*) buffer, sizeof(buffer)); + bzero((char*) length, sizeof(length)); + bzero((char*) is_null, sizeof(is_null)); + + for(i= 0; i < field_count; i++) { buffer[i].buffer_type= MYSQL_TYPE_STRING; buffer[i].buffer_length= MAX_FIELD_DATA_SIZE; @@ -434,27 +439,27 @@ uint my_process_stmt_result(MYSQL_STMT *stmt) } my_print_result_metadata(result); - rc= mysql_bind_result(stmt,buffer); - check_execute(stmt,rc); + rc= mysql_stmt_bind_result(stmt, buffer); + check_execute(stmt, rc); rc= mysql_stmt_store_result(stmt); - check_execute(stmt,rc); - - mysql_field_seek(result, 0); - while (mysql_fetch(stmt) == 0) - { - fputc('\t',stdout); - fputc('|',stdout); - - mysql_field_seek(result,0); - for (i=0; i < field_count; i++) + check_execute(stmt, rc); + + mysql_field_seek(result, 0); + while (mysql_stmt_fetch(stmt) == 0) + { + fputc('\t', stdout); + fputc('|', stdout); + + mysql_field_seek(result, 0); + for (i= 0; i < field_count; i++) { - field = mysql_fetch_field(result); + field= mysql_fetch_field(result); if (is_null[i]) fprintf(stdout, " %-*s |", (int) field->max_length, "NULL"); else if (length[i] == 0) { - data[i][0]='\0'; /* unmodified buffer */ + data[i][0]= '\0'; /* unmodified buffer */ fprintf(stdout, " %*s |", (int) field->max_length, data[i]); } else if (IS_NUM(field->type)) @@ -462,179 +467,183 @@ uint my_process_stmt_result(MYSQL_STMT *stmt) else fprintf(stdout, " %-*s |", (int) field->max_length, data[i]); } - fputc('\t',stdout); - fputc('\n',stdout); + fputc('\t', stdout); + fputc('\n', stdout); row_count++; } if (row_count) my_print_dashes(result); - fprintf(stdout,"\n\t%d %s returned\n", row_count, + fprintf(stdout, "\n\t%d %s returned\n", row_count, row_count == 1 ? "row" : "rows"); mysql_free_result(result); return row_count; } -/******************************************************** -* process the stmt result set * -*********************************************************/ + +/* Prepare statement, execute, and process result set for given query */ + uint my_stmt_result(const char *buff) { MYSQL_STMT *stmt; uint row_count; int rc; - fprintf(stdout,"\n\n %s", buff); - stmt= mysql_simple_prepare(mysql,buff); + fprintf(stdout, "\n\n %s", buff); + stmt= mysql_simple_prepare(mysql, buff); check_stmt(stmt); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); row_count= my_process_stmt_result(stmt); mysql_stmt_close(stmt); - + return row_count; } -/* - Utility function to verify a particular column data -*/ -static void verify_col_data(const char *table, const char *col, + +/* Utility function to verify a particular column data */ + +static void verify_col_data(const char *table, const char *col, const char *exp_data) { MYSQL_RES *result; MYSQL_ROW row; int rc, field= 1; - + if (table && col) { - strxmov(query,"SELECT ",col," FROM ",table," LIMIT 1", NullS); - fprintf(stdout,"\n %s", query); - rc = mysql_query(mysql, query); + strxmov(query, "SELECT ", col, " FROM ", table, " LIMIT 1", NullS); + fprintf(stdout, "\n %s", query); + rc= mysql_query(mysql, query); myquery(rc); field= 0; } - result = mysql_use_result(mysql); + result= mysql_use_result(mysql); mytest(result); if (!(row= mysql_fetch_row(result)) || !row[field]) { - fprintf(stdout,"\n *** ERROR: FAILED TO GET THE RESULT ***"); + fprintf(stdout, "\n *** ERROR: FAILED TO GET THE RESULT ***"); exit(1); } - if (strcmp(row[field],exp_data)) + if (strcmp(row[field], exp_data)) { - fprintf(stdout,"\n obtained: `%s` (expected: `%s`)", - row[field], exp_data); + fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", + row[field], exp_data); assert(0); } mysql_free_result(result); } -/* - Utility function to verify the field members -*/ -static void verify_prepare_field(MYSQL_RES *result, - unsigned int no,const char *name, const char *org_name, - enum enum_field_types type, const char *table, - const char *org_table, const char *db, +/* Utility function to verify the field members */ + +static void verify_prepare_field(MYSQL_RES *result, + unsigned int no, const char *name, const char *org_name, + enum enum_field_types type, const char *table, + const char *org_table, const char *db, unsigned long length, const char *def) { MYSQL_FIELD *field; - if (!(field= mysql_fetch_field_direct(result,no))) + if (!(field= mysql_fetch_field_direct(result, no))) { - fprintf(stdout,"\n *** ERROR: FAILED TO GET THE RESULT ***"); + fprintf(stdout, "\n *** ERROR: FAILED TO GET THE RESULT ***"); exit(1); } - fprintf(stdout,"\n field[%d]:", no); - fprintf(stdout,"\n name :`%s`\t(expected: `%s`)", field->name, name); - fprintf(stdout,"\n org_name :`%s`\t(expected: `%s`)", field->org_name, org_name); - fprintf(stdout,"\n type :`%d`\t(expected: `%d`)", field->type, type); - fprintf(stdout,"\n table :`%s`\t(expected: `%s`)", field->table, table); - fprintf(stdout,"\n org_table:`%s`\t(expected: `%s`)", field->org_table, org_table); - fprintf(stdout,"\n database :`%s`\t(expected: `%s`)", field->db, db); - fprintf(stdout,"\n length :`%ld`\t(expected: `%ld`)", field->length, length); - fprintf(stdout,"\n maxlength:`%ld`", field->max_length); - fprintf(stdout,"\n charsetnr:`%d`", field->charsetnr); - fprintf(stdout,"\n default :`%s`\t(expected: `%s`)", field->def ? field->def : "(null)", def ? def: "(null)"); - fprintf(stdout,"\n"); - assert(strcmp(field->name,name) == 0); - assert(strcmp(field->org_name,org_name) == 0); + fprintf(stdout, "\n field[%d]:", no); + fprintf(stdout, "\n name :`%s`\t(expected: `%s`)", field->name, name); + fprintf(stdout, "\n org_name :`%s`\t(expected: `%s`)", + field->org_name, org_name); + fprintf(stdout, "\n type :`%d`\t(expected: `%d`)", field->type, type); + fprintf(stdout, "\n table :`%s`\t(expected: `%s`)", + field->table, table); + fprintf(stdout, "\n org_table:`%s`\t(expected: `%s`)", + field->org_table, org_table); + fprintf(stdout, "\n database :`%s`\t(expected: `%s`)", field->db, db); + fprintf(stdout, "\n length :`%ld`\t(expected: `%ld`)", + field->length, length); + fprintf(stdout, "\n maxlength:`%ld`", field->max_length); + fprintf(stdout, "\n charsetnr:`%d`", field->charsetnr); + fprintf(stdout, "\n default :`%s`\t(expected: `%s`)", + field->def ? field->def : "(null)", def ? def: "(null)"); + fprintf(stdout, "\n"); + assert(strcmp(field->name, name) == 0); + assert(strcmp(field->org_name, org_name) == 0); assert(field->type == type); - assert(strcmp(field->table,table) == 0); - assert(strcmp(field->org_table,org_table) == 0); - assert(strcmp(field->db,db) == 0); + assert(strcmp(field->table, table) == 0); + assert(strcmp(field->org_table, org_table) == 0); + assert(strcmp(field->db, db) == 0); assert(field->length == length); if (def) - assert(strcmp(field->def,def) == 0); + assert(strcmp(field->def, def) == 0); } -/* - Utility function to verify the parameter count -*/ + +/* Utility function to verify the parameter count */ + static void verify_param_count(MYSQL_STMT *stmt, long exp_count) { - long param_count= mysql_param_count(stmt); - fprintf(stdout,"\n total parameters in stmt: `%ld` (expected: `%ld`)", + long param_count= mysql_stmt_param_count(stmt); + fprintf(stdout, "\n total parameters in stmt: `%ld` (expected: `%ld`)", param_count, exp_count); assert(param_count == exp_count); } -/* - Utility function to verify the total affected rows -*/ + +/* Utility function to verify the total affected rows */ + static void verify_st_affected_rows(MYSQL_STMT *stmt, ulonglong exp_count) { ulonglong affected_rows= mysql_stmt_affected_rows(stmt); - fprintf(stdout,"\n total affected rows: `%lld` (expected: `%lld`)", + fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)", affected_rows, exp_count); assert(affected_rows == exp_count); } -/* - Utility function to verify the total affected rows -*/ + +/* Utility function to verify the total affected rows */ + static void verify_affected_rows(ulonglong exp_count) { 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); assert(affected_rows == exp_count); } -/* - Utility function to verify the total fields count -*/ + +/* Utility function to verify the total fields count */ + static void verify_field_count(MYSQL_RES *result, uint exp_count) { uint field_count= mysql_num_fields(result); - fprintf(stdout,"\n total fields in the result set: `%d` (expected: `%d`)", + fprintf(stdout, "\n total fields in the result set: `%d` (expected: `%d`)", field_count, exp_count); assert(field_count == exp_count); } -/* - Utility function to execute a query using prepare-execute -*/ + +/* Utility function to execute a query using prepare-execute */ + static void execute_prepare_query(const char *query, ulonglong exp_count) { MYSQL_STMT *stmt; ulonglong affected_rows; int rc; - stmt= mysql_simple_prepare(mysql,query); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - rc = mysql_execute(stmt); - myquery(rc); + rc= mysql_stmt_execute(stmt); + myquery(rc); 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); assert(affected_rows == exp_count); @@ -642,9 +651,8 @@ static void execute_prepare_query(const char *query, ulonglong exp_count) } -/******************************************************** -* store result processing * -*********************************************************/ +/* Store result processing */ + static void client_store_result() { MYSQL_RES *result; @@ -652,63 +660,63 @@ static void client_store_result() myheader("client_store_result"); - rc = mysql_query(mysql, "SELECT * FROM myclient_test"); + rc= mysql_query(mysql, "SELECT * FROM myclient_test"); myquery(rc); /* get the result */ - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); my_process_result_set(result); mysql_free_result(result); } -/******************************************************** -* fetch the results -*********************************************************/ + +/* Fetch the results */ + static void client_use_result() { MYSQL_RES *result; int rc; myheader("client_use_result"); - rc = mysql_query(mysql, "SELECT * FROM myclient_test"); + rc= mysql_query(mysql, "SELECT * FROM myclient_test"); myquery(rc); /* get the result */ - result = mysql_use_result(mysql); + result= mysql_use_result(mysql); mytest(result); my_process_result_set(result); mysql_free_result(result); } -/* - Separate thread query to test some cases -*/ + +/* Separate thread query to test some cases */ + static my_bool thread_query(char *query) { MYSQL *l_mysql; my_bool error; error= 0; - fprintf(stdout,"\n in thread_query(%s)", query); - if (!(l_mysql = mysql_init(NULL))) - { + fprintf(stdout, "\n in thread_query(%s)", query); + if (!(l_mysql= mysql_init(NULL))) + { myerror("mysql_init() failed"); return 1; } - if (!(mysql_real_connect(l_mysql,opt_host,opt_user, - opt_password, current_db, opt_port, - opt_unix_socket, 0))) + if (!(mysql_real_connect(l_mysql, opt_host, opt_user, + opt_password, current_db, opt_port, + opt_unix_socket, 0))) { - myerror("connection failed"); + myerror("connection failed"); error= 1; goto end; - } - if (mysql_query(l_mysql,(char *)query)) + } + if (mysql_query(l_mysql, (char *)query)) { - fprintf(stderr,"Query failed (%s)\n",mysql_error(l_mysql)); + fprintf(stderr, "Query failed (%s)\n", mysql_error(l_mysql)); error= 1; goto end; } @@ -719,9 +727,8 @@ end: } -/******************************************************** -* query processing * -*********************************************************/ +/* Query processing */ + static void test_debug_example() { int rc; @@ -729,35 +736,38 @@ static void test_debug_example() myheader("test_debug_example"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_debug_example"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_debug_example"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_debug_example(id int primary key auto_increment,\ - name varchar(20),xxx int)"); + rc= mysql_query(mysql, "CREATE TABLE test_debug_example(" + "id INT PRIMARY KEY AUTO_INCREMENT, " + "name VARCHAR(20), xxx INT)"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_debug_example(name) VALUES('mysql')"); + rc= mysql_query(mysql, "INSERT INTO test_debug_example (name) " + "VALUES ('mysql')"); myquery(rc); - rc = mysql_query(mysql,"UPDATE test_debug_example SET name='updated' WHERE name='deleted'"); + rc= mysql_query(mysql, "UPDATE test_debug_example SET name='updated' " + "WHERE name='deleted'"); myquery(rc); - rc = mysql_query(mysql,"SELECT * FROM test_debug_example where name='mysql'"); + rc= mysql_query(mysql, "SELECT * FROM test_debug_example where name='mysql'"); myquery(rc); - result = mysql_use_result(mysql); + result= mysql_use_result(mysql); mytest(result); my_process_result_set(result); mysql_free_result(result); - rc = mysql_query(mysql,"DROP TABLE test_debug_example"); + rc= mysql_query(mysql, "DROP TABLE test_debug_example"); myquery(rc); } -/******************************************************** -* to test autocommit feature * -*********************************************************/ + +/* Test autocommit feature for BDB tables */ + static void test_tran_bdb() { MYSQL_RES *result; @@ -767,76 +777,71 @@ static void test_tran_bdb() myheader("test_tran_bdb"); /* set AUTOCOMMIT to OFF */ - rc = mysql_autocommit(mysql, FALSE); + rc= mysql_autocommit(mysql, FALSE); myquery(rc); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS my_demo_transaction"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS my_demo_transaction"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - /* create the table 'mytran_demo' of type BDB' or 'InnoDB' */ - rc = mysql_query(mysql,"CREATE TABLE my_demo_transaction(col1 int ,col2 varchar(30)) TYPE = BDB"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE my_demo_transaction( " + "col1 int , col2 varchar(30)) TYPE= BDB"); myquery(rc); /* insert a row and commit the transaction */ - rc = mysql_query(mysql,"INSERT INTO my_demo_transaction VALUES(10,'venu')"); + rc= mysql_query(mysql, "INSERT INTO my_demo_transaction VALUES(10, 'venu')"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* now insert the second row, and rollback the transaction */ - rc = mysql_query(mysql,"INSERT INTO my_demo_transaction VALUES(20,'mysql')"); + rc= mysql_query(mysql, "INSERT INTO my_demo_transaction VALUES(20, 'mysql')"); myquery(rc); - rc = mysql_rollback(mysql); + rc= mysql_rollback(mysql); myquery(rc); /* delete first row, and rollback it */ - rc = mysql_query(mysql,"DELETE FROM my_demo_transaction WHERE col1 = 10"); + rc= mysql_query(mysql, "DELETE FROM my_demo_transaction WHERE col1= 10"); myquery(rc); - rc = mysql_rollback(mysql); + rc= mysql_rollback(mysql); myquery(rc); /* test the results now, only one row should exists */ - rc = mysql_query(mysql,"SELECT * FROM my_demo_transaction"); + rc= mysql_query(mysql, "SELECT * FROM my_demo_transaction"); myquery(rc); /* get the result */ - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); my_process_result_set(result); mysql_free_result(result); /* test the results now, only one row should exists */ - rc = mysql_query(mysql,"SELECT * FROM my_demo_transaction"); + rc= mysql_query(mysql, "SELECT * FROM my_demo_transaction"); myquery(rc); /* get the result */ - result = mysql_use_result(mysql); + result= mysql_use_result(mysql); mytest(result); - row = mysql_fetch_row(result); + row= mysql_fetch_row(result); mytest(row); - row = mysql_fetch_row(result); + row= mysql_fetch_row(result); mytest_r(row); mysql_free_result(result); - mysql_autocommit(mysql,TRUE); + mysql_autocommit(mysql, TRUE); } -/******************************************************** -* to test autocommit feature * -*********************************************************/ + +/* Test autocommit feature for InnoDB tables */ + static void test_tran_innodb() { MYSQL_RES *result; @@ -846,76 +851,69 @@ static void test_tran_innodb() myheader("test_tran_innodb"); /* set AUTOCOMMIT to OFF */ - rc = mysql_autocommit(mysql, FALSE); + rc= mysql_autocommit(mysql, FALSE); myquery(rc); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS my_demo_transaction"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS my_demo_transaction"); myquery(rc); /* create the table 'mytran_demo' of type BDB' or 'InnoDB' */ - rc = mysql_query(mysql,"CREATE TABLE my_demo_transaction(col1 int ,col2 varchar(30)) TYPE = InnoDB"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE my_demo_transaction(col1 int, " + "col2 varchar(30)) TYPE= InnoDB"); myquery(rc); /* insert a row and commit the transaction */ - rc = mysql_query(mysql,"INSERT INTO my_demo_transaction VALUES(10,'venu')"); + rc= mysql_query(mysql, "INSERT INTO my_demo_transaction VALUES(10, 'venu')"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* now insert the second row, and rollback the transaction */ - rc = mysql_query(mysql,"INSERT INTO my_demo_transaction VALUES(20,'mysql')"); + rc= mysql_query(mysql, "INSERT INTO my_demo_transaction VALUES(20, 'mysql')"); myquery(rc); - rc = mysql_rollback(mysql); + rc= mysql_rollback(mysql); myquery(rc); /* delete first row, and rollback it */ - rc = mysql_query(mysql,"DELETE FROM my_demo_transaction WHERE col1 = 10"); + rc= mysql_query(mysql, "DELETE FROM my_demo_transaction WHERE col1= 10"); myquery(rc); - rc = mysql_rollback(mysql); + rc= mysql_rollback(mysql); myquery(rc); /* test the results now, only one row should exists */ - rc = mysql_query(mysql,"SELECT * FROM my_demo_transaction"); + rc= mysql_query(mysql, "SELECT * FROM my_demo_transaction"); myquery(rc); /* get the result */ - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); my_process_result_set(result); mysql_free_result(result); /* test the results now, only one row should exists */ - rc = mysql_query(mysql,"SELECT * FROM my_demo_transaction"); + rc= mysql_query(mysql, "SELECT * FROM my_demo_transaction"); myquery(rc); /* get the result */ - result = mysql_use_result(mysql); + result= mysql_use_result(mysql); mytest(result); - row = mysql_fetch_row(result); + row= mysql_fetch_row(result); mytest(row); - row = mysql_fetch_row(result); + row= mysql_fetch_row(result); mytest_r(row); mysql_free_result(result); - mysql_autocommit(mysql,TRUE); + mysql_autocommit(mysql, TRUE); } -/******************************************************** - To test simple prepares of all DML statements -*********************************************************/ +/* Test simple prepares of all DML statements */ static void test_prepare_simple() { @@ -924,69 +922,66 @@ static void test_prepare_simple() myheader("test_prepare_simple"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prepare_simple"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prepare_simple"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_prepare_simple(id int, name varchar(50))"); + rc= mysql_query(mysql, "CREATE TABLE test_prepare_simple(" + "id int, name varchar(50))"); myquery(rc); /* insert */ - strmov(query,"INSERT INTO test_prepare_simple VALUES(?,?)"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "INSERT INTO test_prepare_simple VALUES(?, ?)"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,2); + verify_param_count(stmt, 2); mysql_stmt_close(stmt); /* update */ - strmov(query,"UPDATE test_prepare_simple SET id=? WHERE id=? AND name= ?"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "UPDATE test_prepare_simple SET id=? WHERE id=? AND name= ?"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,3); + verify_param_count(stmt, 3); mysql_stmt_close(stmt); /* delete */ - strmov(query,"DELETE FROM test_prepare_simple WHERE id=10"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "DELETE FROM test_prepare_simple WHERE id=10"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,0); + verify_param_count(stmt, 0); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); mysql_stmt_close(stmt); /* delete */ - strmov(query,"DELETE FROM test_prepare_simple WHERE id=?"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "DELETE FROM test_prepare_simple WHERE id=?"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,1); + verify_param_count(stmt, 1); mysql_stmt_close(stmt); /* select */ - strmov(query,"SELECT * FROM test_prepare_simple WHERE id=? AND name= ?"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "SELECT * FROM test_prepare_simple WHERE id=? AND name= ?"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,2); + verify_param_count(stmt, 2); mysql_stmt_close(stmt); /* now fetch the results ..*/ - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); } -/******************************************************** -* to test simple prepare field results * -*********************************************************/ +/* Test simple prepare field results */ + static void test_prepare_field_result() { MYSQL_STMT *stmt; @@ -995,41 +990,38 @@ static void test_prepare_field_result() myheader("test_prepare_field_result"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prepare_field_result"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prepare_field_result"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_prepare_field_result(int_c int, " + "var_c varchar(50), ts_c timestamp(14), " + "char_c char(3), date_c date, extra tinyint)"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_prepare_field_result(int_c int, \ - var_c varchar(50), ts_c timestamp(14),\ - char_c char(3), date_c date,extra tinyint)"); - myquery(rc); - /* insert */ - strmov(query,"SELECT int_c,var_c,date_c as date,ts_c,char_c FROM \ - test_prepare_field_result as t1 WHERE int_c=?"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "SELECT int_c, var_c, date_c as date, ts_c, char_c FROM " + " test_prepare_field_result as t1 WHERE int_c=?"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,1); + verify_param_count(stmt, 1); - result = mysql_get_metadata(stmt); + result= mysql_stmt_result_metadata(stmt); mytest(result); - + my_print_result_metadata(result); - fprintf(stdout,"\n\n field attributes:\n"); - verify_prepare_field(result,0,"int_c","int_c",MYSQL_TYPE_LONG, - "t1","test_prepare_field_result",current_db,11,0); - verify_prepare_field(result,1,"var_c","var_c",MYSQL_TYPE_VAR_STRING, - "t1","test_prepare_field_result",current_db,50,0); - verify_prepare_field(result,2,"date","date_c",MYSQL_TYPE_DATE, - "t1","test_prepare_field_result",current_db,10,0); - verify_prepare_field(result,3,"ts_c","ts_c",MYSQL_TYPE_TIMESTAMP, - "t1","test_prepare_field_result",current_db,19,0); - verify_prepare_field(result,4,"char_c","char_c",MYSQL_TYPE_STRING, - "t1","test_prepare_field_result",current_db,3,0); + fprintf(stdout, "\n\n field attributes:\n"); + verify_prepare_field(result, 0, "int_c", "int_c", MYSQL_TYPE_LONG, + "t1", "test_prepare_field_result", current_db, 11, 0); + verify_prepare_field(result, 1, "var_c", "var_c", MYSQL_TYPE_VAR_STRING, + "t1", "test_prepare_field_result", current_db, 50, 0); + verify_prepare_field(result, 2, "date", "date_c", MYSQL_TYPE_DATE, + "t1", "test_prepare_field_result", current_db, 10, 0); + verify_prepare_field(result, 3, "ts_c", "ts_c", MYSQL_TYPE_TIMESTAMP, + "t1", "test_prepare_field_result", current_db, 19, 0); + verify_prepare_field(result, 4, "char_c", "char_c", MYSQL_TYPE_STRING, + "t1", "test_prepare_field_result", current_db, 3, 0); verify_field_count(result, 5); mysql_free_result(result); @@ -1037,9 +1029,8 @@ static void test_prepare_field_result() } -/******************************************************** -* to test simple prepare field results * -*********************************************************/ +/* Test simple prepare field results */ + static void test_prepare_syntax() { MYSQL_STMT *stmt; @@ -1047,32 +1038,29 @@ static void test_prepare_syntax() myheader("test_prepare_syntax"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prepare_syntax"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prepare_syntax"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_prepare_syntax(" + "id int, name varchar(50), extra int)"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_prepare_syntax(id int, name varchar(50), extra int)"); - myquery(rc); - - strmov(query,"INSERT INTO test_prepare_syntax VALUES(?"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "INSERT INTO test_prepare_syntax VALUES(?"); + stmt= mysql_simple_prepare(mysql, query); check_stmt_r(stmt); - strmov(query,"SELECT id,name FROM test_prepare_syntax WHERE id=? AND WHERE"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "SELECT id, name FROM test_prepare_syntax WHERE id=? AND WHERE"); + stmt= mysql_simple_prepare(mysql, query); check_stmt_r(stmt); /* now fetch the results ..*/ - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); } -/******************************************************** -* to test simple prepare * -*********************************************************/ +/* Test a simple prepare */ + static void test_prepare() { MYSQL_STMT *stmt; @@ -1090,49 +1078,48 @@ static void test_prepare() myheader("test_prepare"); - rc = mysql_autocommit(mysql, TRUE); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS my_prepare"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS my_prepare"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE my_prepare(col1 tinyint,\ - col2 varchar(15), col3 int,\ - col4 smallint, col5 bigint, \ - col6 float, col7 double )"); + rc= mysql_query(mysql, "CREATE TABLE my_prepare(col1 tinyint, " + "col2 varchar(15), col3 int, " + "col4 smallint, col5 bigint, " + "col6 float, col7 double )"); myquery(rc); /* insert by prepare */ - strxmov(query,"INSERT INTO my_prepare VALUES(?,?,?,?,?,?,?)",NullS); - stmt = mysql_simple_prepare(mysql, query); + strxmov(query, "INSERT INTO my_prepare VALUES(?, ?, ?, ?, ?, ?, ?)", NullS); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,7); + verify_param_count(stmt, 7); + + bzero((char*) bind, sizeof(bind)); /* tinyint */ - bind[0].buffer_type=FIELD_TYPE_TINY; + bind[0].buffer_type= MYSQL_TYPE_TINY; bind[0].buffer= (char *)&tiny_data; /* string */ - bind[1].buffer_type=FIELD_TYPE_STRING; + bind[1].buffer_type= MYSQL_TYPE_STRING; bind[1].buffer= (char *)str_data; - bind[1].buffer_length= 1000; /* Max string length */ + bind[1].buffer_length= 1000; /* Max string length */ /* integer */ - bind[2].buffer_type=FIELD_TYPE_LONG; + bind[2].buffer_type= MYSQL_TYPE_LONG; bind[2].buffer= (char *)&int_data; /* short */ - bind[3].buffer_type=FIELD_TYPE_SHORT; + bind[3].buffer_type= MYSQL_TYPE_SHORT; bind[3].buffer= (char *)&small_data; /* bigint */ - bind[4].buffer_type=FIELD_TYPE_LONGLONG; + bind[4].buffer_type= MYSQL_TYPE_LONGLONG; bind[4].buffer= (char *)&big_data; /* float */ - bind[5].buffer_type=FIELD_TYPE_FLOAT; + bind[5].buffer_type= MYSQL_TYPE_FLOAT; bind[5].buffer= (char *)&real_data; /* double */ - bind[6].buffer_type=FIELD_TYPE_DOUBLE; + bind[6].buffer_type= MYSQL_TYPE_DOUBLE; bind[6].buffer= (char *)&double_data; for (i= 0; i < (int) array_elements(bind); i++) @@ -1142,20 +1129,20 @@ static void test_prepare() is_null[i]= 0; } - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - int_data = 320; - small_data = 1867; - big_data = 1000; - real_data = 2; - double_data = 6578.001; + int_data= 320; + small_data= 1867; + big_data= 1000; + real_data= 2; + double_data= 6578.001; /* now, execute the prepared statement to insert 10 records.. */ - for (tiny_data=0; tiny_data < 100; tiny_data++) + for (tiny_data= 0; tiny_data < 100; tiny_data++) { - length[1]= my_sprintf(str_data,(str_data, "MySQL%d",int_data)); - rc = mysql_execute(stmt); + length[1]= my_sprintf(str_data, (str_data, "MySQL%d", int_data)); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); int_data += 25; small_data += 10; @@ -1167,45 +1154,45 @@ static void test_prepare() mysql_stmt_close(stmt); /* now fetch the results ..*/ - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* test the results now, only one row should exists */ assert(tiny_data == (char) my_stmt_result("SELECT * FROM my_prepare")); - - stmt = mysql_simple_prepare(mysql,"SELECT * FROM my_prepare"); + + stmt= mysql_simple_prepare(mysql, "SELECT * FROM my_prepare"); check_stmt(stmt); - rc = mysql_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); /* get the result */ - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - - o_int_data = 320; - o_small_data = 1867; - o_big_data = 1000; - o_real_data = 2; - o_double_data = 6578.001; + + o_int_data= 320; + o_small_data= 1867; + o_big_data= 1000; + o_real_data= 2; + o_double_data= 6578.001; /* now, execute the prepared statement to insert 10 records.. */ - for (o_tiny_data=0; o_tiny_data < 100; o_tiny_data++) + for (o_tiny_data= 0; o_tiny_data < 100; o_tiny_data++) { - len = my_sprintf(data, (data, "MySQL%d",o_int_data)); - - rc = mysql_fetch(stmt); + len= my_sprintf(data, (data, "MySQL%d", o_int_data)); + + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); fprintf(stdout, "\n"); - - fprintf(stdout, "\n\t tiny : %d (%lu)", tiny_data,length[0]); - fprintf(stdout, "\n\t short : %d (%lu)", small_data,length[3]); - fprintf(stdout, "\n\t int : %d (%lu)", int_data,length[2]); - fprintf(stdout, "\n\t big : %lld (%lu)", big_data,length[4]); - fprintf(stdout, "\n\t float : %f (%lu)", real_data,length[5]); - fprintf(stdout, "\n\t double : %f (%lu)", double_data,length[6]); + fprintf(stdout, "\n\t tiny : %d (%lu)", tiny_data, length[0]); + fprintf(stdout, "\n\t short : %d (%lu)", small_data, length[3]); + fprintf(stdout, "\n\t int : %d (%lu)", int_data, length[2]); + fprintf(stdout, "\n\t big : %lld (%lu)", big_data, length[4]); + + fprintf(stdout, "\n\t float : %f (%lu)", real_data, length[5]); + fprintf(stdout, "\n\t double : %f (%lu)", double_data, length[6]); fprintf(stdout, "\n\t str : %s (%lu)", str_data, length[1]); @@ -1215,22 +1202,22 @@ static void test_prepare() assert(int_data == o_int_data); assert(length[2] == 4); - + assert(small_data == o_small_data); assert(length[3] == 2); - + assert(big_data == o_big_data); assert(length[4] == 8); - + assert(real_data == o_real_data); assert(length[5] == 4); - + assert(double_data == o_double_data); assert(length[6] == 8); - - assert(strcmp(data,str_data) == 0); + + assert(strcmp(data, str_data) == 0); assert(length[1] == len); - + o_int_data += 25; o_small_data += 10; o_big_data += 100; @@ -1238,7 +1225,7 @@ static void test_prepare() o_double_data += 10.09; } - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -1246,9 +1233,8 @@ static void test_prepare() } -/******************************************************** -* to test double comparision * -*********************************************************/ +/* Test double comparision */ + static void test_double_compare() { MYSQL_STMT *stmt; @@ -1257,61 +1243,56 @@ static void test_double_compare() double double_data; MYSQL_RES *result; MYSQL_BIND bind[3]; - ulong length[3]; + ulong length[3]; myheader("test_double_compare"); - rc = mysql_autocommit(mysql, TRUE); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_double_compare"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_double_compare"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_double_compare(col1 tinyint, " + " col2 float, col3 double )"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_double_compare(col1 tinyint,\ - col2 float, col3 double )"); + rc= mysql_query(mysql, "INSERT INTO test_double_compare " + "VALUES (1, 10.2, 34.5)"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_double_compare VALUES(1,10.2,34.5)"); - myquery(rc); - - strmov(query, "UPDATE test_double_compare SET col1=100 WHERE col1 = ? AND col2 = ? AND COL3 = ?"); - stmt = mysql_simple_prepare(mysql,query); + strmov(query, "UPDATE test_double_compare SET col1=100 " + "WHERE col1 = ? AND col2 = ? AND COL3 = ?"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,3); + verify_param_count(stmt, 3); + + /* Always bzero bind array because there can be internal members */ + bzero((char*) bind, sizeof(bind)); /* tinyint */ - bind[0].buffer_type=FIELD_TYPE_TINY; - bind[0].buffer=(char *)&tiny_data; - bind[0].buffer_length= 0; - bind[0].length= 0; - bind[0].is_null= 0; /* Can never be null */ + bind[0].buffer_type= MYSQL_TYPE_TINY; + bind[0].buffer= (char *)&tiny_data; /* string->float */ - bind[1].buffer_type=FIELD_TYPE_STRING; + bind[1].buffer_type= MYSQL_TYPE_STRING; bind[1].buffer= (char *)&real_data; - bind[1].buffer_length=sizeof(real_data); - bind[1].is_null= 0; + bind[1].buffer_length= sizeof(real_data); bind[1].length= &length[1]; - length[1]= 10; + length[1]= 10; /* double */ - bind[2].buffer_type=FIELD_TYPE_DOUBLE; + bind[2].buffer_type= MYSQL_TYPE_DOUBLE; bind[2].buffer= (char *)&double_data; - bind[2].buffer_length= 0; - bind[2].length= 0; - bind[2].is_null= 0; - tiny_data = 1; - strmov(real_data,"10.2"); - double_data = 34.5; - rc = mysql_bind_param(stmt,bind); + tiny_data= 1; + strmov(real_data, "10.2"); + double_data= 34.5; + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); verify_affected_rows(0); @@ -1319,15 +1300,15 @@ static void test_double_compare() mysql_stmt_close(stmt); /* now fetch the results ..*/ - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* test the results now, only one row should exists */ - rc = mysql_query(mysql,"SELECT * FROM test_double_compare"); + rc= mysql_query(mysql, "SELECT * FROM test_double_compare"); myquery(rc); /* get the result */ - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert((int)tiny_data == my_process_result_set(result)); @@ -1335,9 +1316,8 @@ static void test_double_compare() } -/******************************************************** -* to test simple null * -*********************************************************/ +/* Test simple null */ + static void test_null() { MYSQL_STMT *stmt; @@ -1348,39 +1328,38 @@ static void test_null() myheader("test_null"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_null"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_null"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE test_null(col1 int,col2 varchar(50))"); + rc= mysql_query(mysql, "CREATE TABLE test_null(col1 int, col2 varchar(50))"); myquery(rc); /* insert by prepare, wrong column name */ - strmov(query,"INSERT INTO test_null(col3,col2) VALUES(?,?)"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "INSERT INTO test_null(col3, col2) VALUES(?, ?)"); + stmt= mysql_simple_prepare(mysql, query); check_stmt_r(stmt); - strmov(query,"INSERT INTO test_null(col1,col2) VALUES(?,?)"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "INSERT INTO test_null(col1, col2) VALUES(?, ?)"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,2); + verify_param_count(stmt, 2); - bind[0].buffer_type=MYSQL_TYPE_LONG; + /* Always bzero all members of bind parameter */ + bzero((char*) bind, sizeof(bind)); + + bind[0].buffer_type= MYSQL_TYPE_LONG; bind[0].is_null= &is_null[0]; - bind[0].length= 0; is_null[0]= 1; - bind[1]=bind[0]; + bind[1]= bind[0]; - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); /* now, execute the prepared statement to insert 10 records.. */ - for (nData=0; nData<10; nData++) + for (nData= 0; nData<10; nData++) { - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); } @@ -1389,19 +1368,19 @@ static void test_null() is_null[0]= 0; /* reset */ bind[1]= bind[0]; - rc = mysql_bind_param(stmt,bind); - check_execute(stmt,rc); - - for (nData=0; nData<10; nData++) + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); + + for (nData= 0; nData<10; nData++) { - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); } - + mysql_stmt_close(stmt); /* now fetch the results ..*/ - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); nData*= 2; @@ -1415,18 +1394,18 @@ static void test_null() bind[0].is_null= &is_null[0]; bind[1].is_null= &is_null[1]; - stmt = mysql_simple_prepare(mysql,"SELECT * FROM test_null"); + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_null"); check_stmt(stmt); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); - rc = mysql_bind_result(stmt,bind); - check_execute(stmt,rc); + rc= mysql_stmt_bind_result(stmt, bind); + check_execute(stmt, rc); rc= 0; is_null[0]= is_null[1]= 0; - while (mysql_fetch(stmt) != MYSQL_NO_DATA) + while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) { assert(is_null[0]); assert(is_null[1]); @@ -1437,24 +1416,24 @@ static void test_null() mysql_stmt_close(stmt); } -/********************************************************* -* Test for NULL as PS parameter (BUG#3367, BUG#3371) * -**********************************************************/ + +/* Test for NULL as PS parameter (BUG#3367, BUG#3371) */ + static void test_ps_null_param() { MYSQL_STMT *stmt; int rc; - + MYSQL_BIND in_bind; my_bool in_is_null; long int in_long; - + MYSQL_BIND out_bind; - ulong out_length; + ulong out_length; my_bool out_is_null; char out_str_data[20]; - const char *queries[]= {"select ?", "select ?+1", + const char *queries[]= {"select ?", "select ?+1", "select col1 from test_ps_nulls where col1 <=> ?", NULL }; @@ -1462,15 +1441,19 @@ static void test_ps_null_param() myheader("test_null_ps_param_in_result"); - rc= mysql_query(mysql,"DROP TABLE IF EXISTS test_ps_nulls"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_ps_nulls"); myquery(rc); - rc= mysql_query(mysql,"CREATE TABLE test_ps_nulls(col1 int)"); + rc= mysql_query(mysql, "CREATE TABLE test_ps_nulls(col1 int)"); myquery(rc); - rc= mysql_query(mysql,"INSERT INTO test_ps_nulls values (1),(null)"); + rc= mysql_query(mysql, "INSERT INTO test_ps_nulls values (1), (null)"); myquery(rc); + /* Always bzero all members of bind parameter */ + bzero((char*) &in_bind, sizeof(in_bind)); + bzero((char*) &out_bind, sizeof(out_bind)); + in_bind.buffer_type= MYSQL_TYPE_LONG; in_bind.is_null= &in_is_null; in_bind.length= 0; @@ -1478,102 +1461,98 @@ static void test_ps_null_param() in_is_null= 1; in_long= 1; - out_bind.buffer_type=FIELD_TYPE_STRING; + out_bind.buffer_type= MYSQL_TYPE_STRING; out_bind.is_null= &out_is_null; out_bind.length= &out_length; out_bind.buffer= out_str_data; - out_bind.buffer_length= array_elements(out_str_data); - + out_bind.buffer_length= array_elements(out_str_data); + /* Execute several queries, all returning NULL in result. */ for(cur_query= queries; *cur_query; cur_query++) { strmov(query, *cur_query); - stmt = mysql_simple_prepare(mysql, query); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,1); + verify_param_count(stmt, 1); - rc = mysql_bind_param(stmt,&in_bind); + rc= mysql_stmt_bind_param(stmt, &in_bind); check_execute(stmt, rc); - rc= mysql_bind_result(stmt,&out_bind); + rc= mysql_stmt_bind_result(stmt, &out_bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc= mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc != MYSQL_NO_DATA); assert(out_is_null); - rc= mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } } -/******************************************************** -* to test fetch null * -*********************************************************/ + +/* Test fetch null */ + static void test_fetch_null() { MYSQL_STMT *stmt; int rc; int i, nData; MYSQL_BIND bind[11]; - ulong length[11]; + ulong length[11]; my_bool is_null[11]; myheader("test_fetch_null"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_fetch_null"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_fetch_null"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_fetch_null(" + " col1 tinyint, col2 smallint, " + " col3 int, col4 bigint, " + " col5 float, col6 double, " + " col7 date, col8 time, " + " col9 varbinary(10), " + " col10 varchar(50), " + " col11 char(20))"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_fetch_null(col1 tinyint, col2 smallint, \ - col3 int, col4 bigint, \ - col5 float, col6 double, \ - col7 date, col8 time, \ - col9 varbinary(10), \ - col10 varchar(50),\ - col11 char(20))"); + rc= mysql_query(mysql, "INSERT INTO test_fetch_null (col11) " + "VALUES (1000), (88), (389789)"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"INSERT INTO test_fetch_null(col11) VALUES(1000),(88),(389789)"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* fetch */ for (i= 0; i < (int) array_elements(bind); i++) { - bind[i].buffer_type=FIELD_TYPE_LONG; + bind[i].buffer_type= MYSQL_TYPE_LONG; bind[i].is_null= &is_null[i]; bind[i].length= &length[i]; } - bind[i-1].buffer=(char *)&nData; /* Last column is not null */ + bind[i-1].buffer= (char *)&nData; /* Last column is not null */ strmov((char *)query , "SELECT * FROM test_fetch_null"); assert(3 == my_stmt_result(query)); - stmt = mysql_simple_prepare(mysql, query); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - rc = mysql_bind_result(stmt,bind); + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); rc= 0; - while (mysql_fetch(stmt) != MYSQL_NO_DATA) + while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) { rc++; - for (i=0; i < 10; i++) + for (i= 0; i < 10; i++) { - fprintf(stdout, "\n data[%d] : %s", i, + fprintf(stdout, "\n data[%d] : %s", i, is_null[i] ? "NULL" : "NOT NULL"); assert(is_null[i]); } @@ -1587,9 +1566,8 @@ static void test_fetch_null() } -/******************************************************** -* to test simple select * -*********************************************************/ +/* Test simple select */ + static void test_select_version() { MYSQL_STMT *stmt; @@ -1597,21 +1575,21 @@ static void test_select_version() myheader("test_select_version"); - stmt = mysql_simple_prepare(mysql, "SELECT @@version"); + stmt= mysql_simple_prepare(mysql, "SELECT @@version"); check_stmt(stmt); - verify_param_count(stmt,0); + verify_param_count(stmt, 0); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); my_process_stmt_result(stmt); mysql_stmt_close(stmt); } -/******************************************************** -* to test simple show * -*********************************************************/ + +/* Test simple show */ + static void test_select_show_table() { MYSQL_STMT *stmt; @@ -1619,14 +1597,14 @@ static void test_select_show_table() myheader("test_select_show_table"); - stmt = mysql_simple_prepare(mysql, "SHOW TABLES FROM mysql"); + stmt= mysql_simple_prepare(mysql, "SHOW TABLES FROM mysql"); check_stmt(stmt); - verify_param_count(stmt,0); + verify_param_count(stmt, 0); for (i= 1; i < 3; i++) { - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); } @@ -1635,46 +1613,39 @@ static void test_select_show_table() } -/******************************************************** -* to test simple select to debug * -*********************************************************/ +/* Test simple select to debug */ + static void test_select_direct() { int rc; MYSQL_RES *result; myheader("test_select_direct"); - - rc = mysql_autocommit(mysql,TRUE); - myquery(rc); - - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_select"); - myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_select(id int, id1 tinyint, \ - id2 float, \ - id3 double, \ - name varchar(50))"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_select"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_select(id int, id1 tinyint, " + " id2 float, " + " id3 double, " + " name varchar(50))"); myquery(rc); /* insert a row and commit the transaction */ - rc = mysql_query(mysql,"INSERT INTO test_select VALUES(10,5,2.3,4.5,'venu')"); + rc= mysql_query(mysql, "INSERT INTO test_select VALUES(10, 5, 2.3, 4.5, 'venu')"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); - rc = mysql_query(mysql,"SELECT * FROM test_select"); + rc= mysql_query(mysql, "SELECT * FROM test_select"); myquery(rc); /* get the result */ - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); my_process_result_set(result); @@ -1682,148 +1653,124 @@ static void test_select_direct() } -/******************************************************** -* to test simple select with prepare * -*********************************************************/ +/* Test simple select with prepare */ + static void test_select_prepare() { int rc; MYSQL_STMT *stmt; myheader("test_select_prepare"); - - rc = mysql_autocommit(mysql,TRUE); - myquery(rc); - - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_select"); - myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_select(id int, name varchar(50))"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_select"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_select(id int, name varchar(50))"); myquery(rc); /* insert a row and commit the transaction */ - rc = mysql_query(mysql,"INSERT INTO test_select VALUES(10,'venu')"); + rc= mysql_query(mysql, "INSERT INTO test_select VALUES(10, 'venu')"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); - stmt = mysql_simple_prepare(mysql,"SELECT * FROM test_select"); + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_select"); check_stmt(stmt); - - rc = mysql_execute(stmt); - check_execute(stmt,rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); assert(1 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); - rc = mysql_query(mysql,"DROP TABLE test_select"); + rc= mysql_query(mysql, "DROP TABLE test_select"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE test_select(id tinyint, id1 int, \ - id2 float, id3 float, \ - name varchar(50))"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_select(id tinyint, id1 int, " + " id2 float, id3 float, " + " name varchar(50))"); myquery(rc); /* insert a row and commit the transaction */ - rc = mysql_query(mysql,"INSERT INTO test_select(id,id1,id2,name) VALUES(10,5,2.3,'venu')"); + rc= mysql_query(mysql, "INSERT INTO test_select(id, id1, id2, name) VALUES(10, 5, 2.3, 'venu')"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); - stmt = mysql_simple_prepare(mysql,"SELECT * FROM test_select"); + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_select"); check_stmt(stmt); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); assert(1 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } -/******************************************************** -* to test simple select * -*********************************************************/ +/* Test simple select */ + static void test_select() { MYSQL_STMT *stmt; int rc; char szData[25]; - int nData=1; + int nData= 1; MYSQL_BIND bind[2]; ulong length[2]; myheader("test_select"); - rc = mysql_autocommit(mysql,TRUE); - myquery(rc); - - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_select"); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_select"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_select(id int,name varchar(50))"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_select(id int, name varchar(50))"); myquery(rc); /* insert a row and commit the transaction */ - rc = mysql_query(mysql,"INSERT INTO test_select VALUES(10,'venu')"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "INSERT INTO test_select VALUES(10, 'venu')"); myquery(rc); /* now insert the second row, and rollback the transaction */ - rc = mysql_query(mysql,"INSERT INTO test_select VALUES(20,'mysql')"); + rc= mysql_query(mysql, "INSERT INTO test_select VALUES(20, 'mysql')"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); - strmov(query,"SELECT * FROM test_select WHERE id=? AND name=?"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "SELECT * FROM test_select WHERE id= ? AND name=?"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,2); + verify_param_count(stmt, 2); + + /* Always bzero all members of bind parameter */ + bzero((char*) bind, sizeof(bind)); /* string data */ - nData=10; - strmov(szData,(char *)"venu"); - bind[1].buffer_type=FIELD_TYPE_STRING; - bind[1].buffer=(char *)szData; + nData= 10; + strmov(szData, (char *)"venu"); + bind[1].buffer_type= MYSQL_TYPE_STRING; + bind[1].buffer= (char *)szData; bind[1].buffer_length= 4; bind[1].length= &length[1]; length[1]= 4; - bind[1].is_null=0; - bind[0].buffer=(char *)&nData; - bind[0].buffer_type=FIELD_TYPE_LONG; - bind[0].buffer_length= 0; - bind[0].length= 0; - bind[0].is_null= 0; + bind[0].buffer= (char *)&nData; + bind[0].buffer_type= MYSQL_TYPE_LONG; - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(my_process_stmt_result(stmt) == 1); @@ -1831,56 +1778,58 @@ static void test_select() mysql_stmt_close(stmt); } + /* - Test for BUG#3420 ("select id1,value1 from t where id=? or value=?" + Test for BUG#3420 ("select id1, value1 from t where id= ? or value= ?" returns all rows in the table) */ + static void test_ps_conj_select() { MYSQL_STMT *stmt; int rc; MYSQL_BIND bind[2]; long int int_data; - char str_data[32]; + char str_data[32]; unsigned long str_length; myheader("test_ps_conj_select"); - + rc= mysql_query(mysql, "drop table if exists t1"); myquery(rc); - - rc= mysql_query(mysql, "create table t1 (id1 int(11) NOT NULL default '0'," + + rc= mysql_query(mysql, "create table t1 (id1 int(11) NOT NULL default '0', " "value2 varchar(100), value1 varchar(100))"); myquery(rc); - rc= mysql_query(mysql, "insert into t1 values (1,'hh','hh'),(2,'hh','hh')," - "(1,'ii','ii'),(2,'ii','ii')"); + rc= mysql_query(mysql, "insert into t1 values (1, 'hh', 'hh'), " + "(2, 'hh', 'hh'), (1, 'ii', 'ii'), (2, 'ii', 'ii')"); myquery(rc); - - strmov(query, "select id1,value1 from t1 where id1=? or value1=?"); + + strmov(query, "select id1, value1 from t1 where id1= ? or value1= ?"); stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,2); + verify_param_count(stmt, 2); + + /* Always bzero all members of bind parameter */ + bzero((char*) bind, sizeof(bind)); bind[0].buffer_type= MYSQL_TYPE_LONG; bind[0].buffer= (char *)&int_data; - bind[0].is_null= 0; - bind[0].length= 0; bind[1].buffer_type= MYSQL_TYPE_VAR_STRING; bind[1].buffer= (char *)str_data; - bind[1].buffer_length= array_elements(str_data); - bind[1].is_null= 0; + bind[1].buffer_length= array_elements(str_data); bind[1].length= &str_length; - - rc = mysql_bind_param(stmt,bind); + + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); int_data= 1; - strcpy(str_data, "hh"); + strcpy(str_data, "hh"); str_length= strlen(str_data); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(my_process_stmt_result(stmt) == 3); @@ -1888,9 +1837,9 @@ static void test_ps_conj_select() mysql_stmt_close(stmt); } -/* - test BUG#1115 (incorrect string parameter value allocation) -*/ + +/* Test BUG#1115 (incorrect string parameter value allocation) */ + static void test_bug1115() { MYSQL_STMT *stmt; @@ -1901,69 +1850,91 @@ static void test_bug1115() myheader("test_bug1115"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_select"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_select"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_select(\ + rc= mysql_query(mysql, "CREATE TABLE test_select(\ session_id char(9) NOT NULL, \ a int(8) unsigned NOT NULL, \ b int(5) NOT NULL, \ c int(5) NOT NULL, \ d datetime NOT NULL)"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_select VALUES (\"abc\",1,2,3,2003-08-30), (\"abd\",1,2,3,2003-08-30), (\"abf\",1,2,3,2003-08-30), (\"abg\",1,2,3,2003-08-30), (\"abh\",1,2,3,2003-08-30), (\"abj\",1,2,3,2003-08-30), (\"abk\",1,2,3,2003-08-30), (\"abl\",1,2,3,2003-08-30), (\"abq\",1,2,3,2003-08-30), (\"abw\",1,2,3,2003-08-30), (\"abe\",1,2,3,2003-08-30), (\"abr\",1,2,3,2003-08-30), (\"abt\",1,2,3,2003-08-30), (\"aby\",1,2,3,2003-08-30), (\"abu\",1,2,3,2003-08-30), (\"abi\",1,2,3,2003-08-30), (\"abo\",1,2,3,2003-08-30), (\"abp\",1,2,3,2003-08-30), (\"abz\",1,2,3,2003-08-30), (\"abx\",1,2,3,2003-08-30)"); - myquery(rc); - - strmov(query,"SELECT * FROM test_select WHERE session_id = ?"); - stmt = mysql_simple_prepare(mysql, query); + rc= mysql_query(mysql, "INSERT INTO test_select VALUES " + "(\"abc\", 1, 2, 3, 2003-08-30), " + "(\"abd\", 1, 2, 3, 2003-08-30), " + "(\"abf\", 1, 2, 3, 2003-08-30), " + "(\"abg\", 1, 2, 3, 2003-08-30), " + "(\"abh\", 1, 2, 3, 2003-08-30), " + "(\"abj\", 1, 2, 3, 2003-08-30), " + "(\"abk\", 1, 2, 3, 2003-08-30), " + "(\"abl\", 1, 2, 3, 2003-08-30), " + "(\"abq\", 1, 2, 3, 2003-08-30), " + "(\"abw\", 1, 2, 3, 2003-08-30), " + "(\"abe\", 1, 2, 3, 2003-08-30), " + "(\"abr\", 1, 2, 3, 2003-08-30), " + "(\"abt\", 1, 2, 3, 2003-08-30), " + "(\"aby\", 1, 2, 3, 2003-08-30), " + "(\"abu\", 1, 2, 3, 2003-08-30), " + "(\"abi\", 1, 2, 3, 2003-08-30), " + "(\"abo\", 1, 2, 3, 2003-08-30), " + "(\"abp\", 1, 2, 3, 2003-08-30), " + "(\"abz\", 1, 2, 3, 2003-08-30), " + "(\"abx\", 1, 2, 3, 2003-08-30)"); + myquery(rc); + + strmov(query, "SELECT * FROM test_select WHERE session_id= ?"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,1); + verify_param_count(stmt, 1); + + /* Always bzero all members of bind parameter */ + bzero((char*) bind, sizeof(bind)); - strmov(szData,(char *)"abc"); - bind[0].buffer_type=FIELD_TYPE_STRING; - bind[0].buffer=(char *)szData; + strmov(szData, (char *)"abc"); + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[0].buffer= (char *)szData; bind[0].buffer_length= 10; bind[0].length= &length[0]; length[0]= 3; - bind[0].is_null=0; - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(my_process_stmt_result(stmt) == 1); - strmov(szData,(char *)"venu"); - bind[0].buffer_type=FIELD_TYPE_STRING; - bind[0].buffer=(char *)szData; + strmov(szData, (char *)"venu"); + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[0].buffer= (char *)szData; bind[0].buffer_length= 10; bind[0].length= &length[0]; length[0]= 4; - bind[0].is_null=0; + bind[0].is_null= 0; - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(my_process_stmt_result(stmt) == 0); - strmov(szData,(char *)"abc"); - bind[0].buffer_type=FIELD_TYPE_STRING; - bind[0].buffer=(char *)szData; + strmov(szData, (char *)"abc"); + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[0].buffer= (char *)szData; bind[0].buffer_length= 10; bind[0].length= &length[0]; length[0]= 3; - bind[0].is_null=0; + bind[0].is_null= 0; - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(my_process_stmt_result(stmt) == 1); @@ -1971,9 +1942,9 @@ session_id char(9) NOT NULL, \ mysql_stmt_close(stmt); } -/* - test BUG#1180 (optimized away part of WHERE clause) -*/ + +/* Test BUG#1180 (optimized away part of WHERE clause) */ + static void test_bug1180() { MYSQL_STMT *stmt; @@ -1984,64 +1955,68 @@ static void test_bug1180() myheader("test_select_bug"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_select"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_select"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_select(session_id char(9) NOT NULL)"); + rc= mysql_query(mysql, "CREATE TABLE test_select(session_id char(9) NOT NULL)"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_select VALUES (\"abc\")"); + rc= mysql_query(mysql, "INSERT INTO test_select VALUES (\"abc\")"); myquery(rc); - strmov(query,"SELECT * FROM test_select WHERE ?=\"1111\" and session_id = \"abc\""); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "SELECT * FROM test_select WHERE ?= \"1111\" and " + "session_id= \"abc\""); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,1); + verify_param_count(stmt, 1); - strmov(szData,(char *)"abc"); - bind[0].buffer_type=FIELD_TYPE_STRING; - bind[0].buffer=(char *)szData; + /* Always bzero all members of bind parameter */ + bzero((char*) bind, sizeof(bind)); + + strmov(szData, (char *)"abc"); + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[0].buffer= (char *)szData; bind[0].buffer_length= 10; bind[0].length= &length[0]; length[0]= 3; - bind[0].is_null=0; + bind[0].is_null= 0; - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(my_process_stmt_result(stmt) == 0); - strmov(szData,(char *)"1111"); - bind[0].buffer_type=FIELD_TYPE_STRING; - bind[0].buffer=(char *)szData; + strmov(szData, (char *)"1111"); + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[0].buffer= (char *)szData; bind[0].buffer_length= 10; bind[0].length= &length[0]; length[0]= 4; - bind[0].is_null=0; + bind[0].is_null= 0; - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(my_process_stmt_result(stmt) == 1); - strmov(szData,(char *)"abc"); - bind[0].buffer_type=FIELD_TYPE_STRING; - bind[0].buffer=(char *)szData; + strmov(szData, (char *)"abc"); + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[0].buffer= (char *)szData; bind[0].buffer_length= 10; bind[0].length= &length[0]; length[0]= 3; - bind[0].is_null=0; + bind[0].is_null= 0; - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(my_process_stmt_result(stmt) == 0); @@ -2049,10 +2024,12 @@ static void test_bug1180() mysql_stmt_close(stmt); } + /* - test BUG#1644 (Insertion of more than 3 NULL columns with - parameter binding fails) + Test BUG#1644 (Insertion of more than 3 NULL columns with parameter + binding fails) */ + static void test_bug1644() { MYSQL_STMT *stmt; @@ -2069,51 +2046,52 @@ static void test_bug1644() myquery(rc); rc= mysql_query(mysql, - "CREATE TABLE foo_dfr(col1 int, col2 int, col3 int, col4 int);"); + "CREATE TABLE foo_dfr(col1 int, col2 int, col3 int, col4 int);"); myquery(rc); - strmov(query, "INSERT INTO foo_dfr VALUES (?,?,?,? )"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "INSERT INTO foo_dfr VALUES (?, ?, ?, ? )"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); verify_param_count(stmt, 4); + /* Always bzero all members of bind parameter */ + bzero((char*) bind, sizeof(bind)); + num= 22; isnull= 0; - for (i = 0 ; i < 4 ; i++) + for (i= 0 ; i < 4 ; i++) { - bind[i].buffer_type= FIELD_TYPE_LONG; + bind[i].buffer_type= MYSQL_TYPE_LONG; bind[i].buffer= (char *)# - bind[i].buffer_length= 0; - bind[i].length= 0; bind[i].is_null= &isnull; } - rc= mysql_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); isnull= 1; - for (i = 0 ; i < 4 ; i++) + for (i= 0 ; i < 4 ; i++) bind[i].is_null= &isnull; - rc= mysql_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); isnull= 0; num= 88; - for (i = 0 ; i < 4 ; i++) + for (i= 0 ; i < 4 ; i++) bind[i].is_null= &isnull; - rc= mysql_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); mysql_stmt_close(stmt); @@ -2130,19 +2108,19 @@ static void test_bug1644() row= mysql_fetch_row(result); mytest(row); - for (i = 0 ; i < 4 ; i++) + for (i= 0 ; i < 4 ; i++) { assert(strcmp(row[i], "22") == 0); } row= mysql_fetch_row(result); mytest(row); - for (i = 0 ; i < 4 ; i++) + for (i= 0 ; i < 4 ; i++) { assert(row[i] == 0); } row= mysql_fetch_row(result); mytest(row); - for (i = 0 ; i < 4 ; i++) + for (i= 0 ; i < 4 ; i++) { assert(strcmp(row[i], "88") == 0); } @@ -2153,9 +2131,8 @@ static void test_bug1644() } -/******************************************************** -* to test simple select show * -*********************************************************/ +/* Test simple select show */ + static void test_select_show() { MYSQL_STMT *stmt; @@ -2163,51 +2140,52 @@ static void test_select_show() myheader("test_select_show"); - mysql_autocommit(mysql,TRUE); + mysql_autocommit(mysql, TRUE); - rc = mysql_query(mysql, "DROP TABLE IF EXISTS test_show"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_show"); myquery(rc); - - rc = mysql_query(mysql, "CREATE TABLE test_show(id int(4) NOT NULL primary key, name char(2))"); + + rc= mysql_query(mysql, "CREATE TABLE test_show(id int(4) NOT NULL primary " + " key, name char(2))"); myquery(rc); - stmt = mysql_simple_prepare(mysql, "show columns from test_show"); + stmt= mysql_simple_prepare(mysql, "show columns from test_show"); check_stmt(stmt); - verify_param_count(stmt,0); + verify_param_count(stmt, 0); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); my_process_stmt_result(stmt); mysql_stmt_close(stmt); - - stmt = mysql_simple_prepare(mysql, "show tables from mysql like ?"); + + stmt= mysql_simple_prepare(mysql, "show tables from mysql like ?"); check_stmt_r(stmt); - - strxmov(query,"show tables from ", current_db, " like \'test_show\'", NullS); - stmt = mysql_simple_prepare(mysql, query); + + strxmov(query, "show tables from ", current_db, " like \'test_show\'", NullS); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); my_process_stmt_result(stmt); mysql_stmt_close(stmt); - - stmt = mysql_simple_prepare(mysql, "describe test_show"); + + stmt= mysql_simple_prepare(mysql, "describe test_show"); check_stmt(stmt); - - rc = mysql_execute(stmt); + + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); my_process_stmt_result(stmt); mysql_stmt_close(stmt); - - stmt = mysql_simple_prepare(mysql, "show keys from test_show"); + + stmt= mysql_simple_prepare(mysql, "show keys from test_show"); check_stmt(stmt); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(1 == my_process_stmt_result(stmt)); @@ -2215,85 +2193,77 @@ static void test_select_show() } -/******************************************************** -* to test simple update * -*********************************************************/ +/* Test simple update */ + static void test_simple_update() { MYSQL_STMT *stmt; int rc; char szData[25]; - int nData=1; + int nData= 1; MYSQL_RES *result; - MYSQL_BIND bind[2]; - ulong length[2]; + MYSQL_BIND bind[2]; + ulong length[2]; myheader("test_simple_update"); - rc = mysql_autocommit(mysql,TRUE); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_update"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_update"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE test_update(col1 int,\ - col2 varchar(50), col3 int )"); + rc= mysql_query(mysql, "CREATE TABLE test_update(col1 int, " + " col2 varchar(50), col3 int )"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"INSERT INTO test_update VALUES(1,'MySQL',100)"); + rc= mysql_query(mysql, "INSERT INTO test_update VALUES(1, 'MySQL', 100)"); myquery(rc); verify_affected_rows(1); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* insert by prepare */ - strmov(query,"UPDATE test_update SET col2=? WHERE col1=?"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "UPDATE test_update SET col2= ? WHERE col1= ?"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,2); + verify_param_count(stmt, 2); + + /* Always bzero all members of bind parameter */ + bzero((char*) bind, sizeof(bind)); - nData=1; - bind[0].buffer_type=FIELD_TYPE_STRING; - bind[0].buffer=szData; /* string data */ - bind[0].buffer_length=sizeof(szData); + nData= 1; + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[0].buffer= szData; /* string data */ + bind[0].buffer_length= sizeof(szData); bind[0].length= &length[0]; - bind[0].is_null= 0; - length[0]= my_sprintf(szData, (szData,"updated-data")); + length[0]= my_sprintf(szData, (szData, "updated-data")); - bind[1].buffer=(char *) &nData; - bind[1].buffer_type=FIELD_TYPE_LONG; - bind[1].buffer_length= 0; - bind[1].length= 0; - bind[1].is_null= 0; + bind[1].buffer= (char *) &nData; + bind[1].buffer_type= MYSQL_TYPE_LONG; - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); verify_affected_rows(1); mysql_stmt_close(stmt); /* now fetch the results ..*/ - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* test the results now, only one row should exists */ - rc = mysql_query(mysql,"SELECT * FROM test_update"); + rc= mysql_query(mysql, "SELECT * FROM test_update"); myquery(rc); /* get the result */ - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert(1 == my_process_result_set(result)); @@ -2301,203 +2271,185 @@ static void test_simple_update() } -/******************************************************** -* to test simple long data handling * -*********************************************************/ +/* Test simple long data handling */ + static void test_long_data() { MYSQL_STMT *stmt; int rc, int_data; - char *data=NullS; + char *data= NullS; MYSQL_RES *result; MYSQL_BIND bind[3]; myheader("test_long_data"); - rc = mysql_autocommit(mysql,TRUE); - myquery(rc); - - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_long_data"); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_long_data"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_long_data(col1 int,\ - col2 long varchar, col3 long varbinary)"); + rc= mysql_query(mysql, "CREATE TABLE test_long_data(col1 int, " + " col2 long varchar, col3 long varbinary)"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - strmov(query,"INSERT INTO test_long_data(col1,col2) VALUES(?)"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "INSERT INTO test_long_data(col1, col2) VALUES(?)"); + stmt= mysql_simple_prepare(mysql, query); check_stmt_r(stmt); - strmov(query,"INSERT INTO test_long_data(col1,col2,col3) VALUES(?,?,?)"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "INSERT INTO test_long_data(col1, col2, col3) VALUES(?, ?, ?)"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,3); + verify_param_count(stmt, 3); - bind[0].buffer=(char *)&int_data; - bind[0].buffer_type=FIELD_TYPE_LONG; - bind[0].is_null=0; - bind[0].buffer_length= 0; - bind[0].length= 0; + /* Always bzero all members of bind parameter */ + bzero((char*) bind, sizeof(bind)); - bind[1].buffer_type=FIELD_TYPE_STRING; - bind[1].is_null=0; - bind[1].buffer_length=0; /* Will not be used */ - bind[1].length=0; /* Will not be used */ + bind[0].buffer= (char *)&int_data; + bind[0].buffer_type= MYSQL_TYPE_LONG; + + bind[1].buffer_type= MYSQL_TYPE_STRING; - bind[2]=bind[1]; - rc = mysql_bind_param(stmt,bind); + bind[2]= bind[1]; + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); int_data= 999; - data = (char *)"Michael"; + data= (char *)"Michael"; /* supply data in pieces */ - rc = mysql_send_long_data(stmt,1,data,strlen(data)); - data = (char *)" 'Monty' Widenius"; - rc = mysql_send_long_data(stmt,1,data,strlen(data)); + rc= mysql_stmt_send_long_data(stmt, 1, data, strlen(data)); + data= (char *)" 'Monty' Widenius"; + rc= mysql_stmt_send_long_data(stmt, 1, data, strlen(data)); check_execute(stmt, rc); - rc = mysql_send_long_data(stmt,2,"Venu (venu@mysql.com)",4); + rc= mysql_stmt_send_long_data(stmt, 2, "Venu (venu@mysql.com)", 4); check_execute(stmt, rc); /* execute */ - rc = mysql_execute(stmt); - fprintf(stdout," mysql_execute() returned %d\n",rc); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); + check_execute(stmt, rc); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* now fetch the results ..*/ - rc = mysql_query(mysql,"SELECT * FROM test_long_data"); + rc= mysql_query(mysql, "SELECT * FROM test_long_data"); myquery(rc); /* get the result */ - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert(1 == my_process_result_set(result)); mysql_free_result(result); - verify_col_data("test_long_data","col1","999"); - verify_col_data("test_long_data","col2","Michael 'Monty' Widenius"); - verify_col_data("test_long_data","col3","Venu"); + verify_col_data("test_long_data", "col1", "999"); + verify_col_data("test_long_data", "col2", "Michael 'Monty' Widenius"); + verify_col_data("test_long_data", "col3", "Venu"); mysql_stmt_close(stmt); } -/******************************************************** -* to test long data (string) handling * -*********************************************************/ +/* Test long data (string) handling */ + static void test_long_data_str() { MYSQL_STMT *stmt; int rc, i; char data[255]; long length; - ulong length1; + ulong length1; MYSQL_RES *result; MYSQL_BIND bind[2]; my_bool is_null[2]; myheader("test_long_data_str"); - rc = mysql_autocommit(mysql,TRUE); - myquery(rc); - - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_long_data_str"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_long_data_str(id int, longstr long varchar)"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_long_data_str"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_long_data_str(id int, longstr long varchar)"); myquery(rc); - strmov(query,"INSERT INTO test_long_data_str VALUES(?,?)"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "INSERT INTO test_long_data_str VALUES(?, ?)"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,2); + verify_param_count(stmt, 2); + + /* Always bzero all members of bind parameter */ + bzero((char*) bind, sizeof(bind)); - bind[0].buffer = (char *)&length; - bind[0].buffer_type = FIELD_TYPE_LONG; + bind[0].buffer= (char *)&length; + bind[0].buffer_type= MYSQL_TYPE_LONG; bind[0].is_null= &is_null[0]; - bind[0].buffer_length= 0; - bind[0].length= 0; - is_null[0]=0; + is_null[0]= 0; length= 0; - bind[1].buffer=data; /* string data */ - bind[1].buffer_type=FIELD_TYPE_STRING; + bind[1].buffer= data; /* string data */ + bind[1].buffer_type= MYSQL_TYPE_STRING; bind[1].length= &length1; - bind[1].buffer_length=0; /* Will not be used */ bind[1].is_null= &is_null[1]; - is_null[1]=0; - rc = mysql_bind_param(stmt,bind); + is_null[1]= 0; + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - length = 40; - strmov(data,"MySQL AB"); + length= 40; + strmov(data, "MySQL AB"); /* supply data in pieces */ - for(i=0; i < 4; i++) + for(i= 0; i < 4; i++) { - rc = mysql_send_long_data(stmt,1,(char *)data,5); + rc= mysql_stmt_send_long_data(stmt, 1, (char *)data, 5); check_execute(stmt, rc); } /* execute */ - rc = mysql_execute(stmt); - fprintf(stdout," mysql_execute() returned %d\n",rc); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); + check_execute(stmt, rc); mysql_stmt_close(stmt); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* now fetch the results ..*/ - rc = mysql_query(mysql,"SELECT LENGTH(longstr), longstr FROM test_long_data_str"); + rc= mysql_query(mysql, "SELECT LENGTH(longstr), longstr FROM test_long_data_str"); myquery(rc); /* get the result */ - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert(1 == my_process_result_set(result)); mysql_free_result(result); - my_sprintf(data,(data,"%d", i*5)); - verify_col_data("test_long_data_str","LENGTH(longstr)", data); - data[0]='\0'; + my_sprintf(data, (data, "%d", i*5)); + verify_col_data("test_long_data_str", "LENGTH(longstr)", data); + data[0]= '\0'; while (i--) - strxmov(data,data,"MySQL",NullS); - verify_col_data("test_long_data_str","longstr", data); + strxmov(data, data, "MySQL", NullS); + verify_col_data("test_long_data_str", "longstr", data); - rc = mysql_query(mysql,"DROP TABLE test_long_data_str"); + rc= mysql_query(mysql, "DROP TABLE test_long_data_str"); myquery(rc); } -/******************************************************** -* to test long data (string) handling * -*********************************************************/ +/* Test long data (string) handling */ + static void test_long_data_str1() { MYSQL_STMT *stmt; int rc, i; char data[255]; long length; - ulong max_blob_length, blob_length, length1; + ulong max_blob_length, blob_length, length1; my_bool true_value; MYSQL_RES *result; MYSQL_BIND bind[2]; @@ -2505,67 +2457,63 @@ static void test_long_data_str1() myheader("test_long_data_str1"); - rc = mysql_autocommit(mysql,TRUE); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_long_data_str"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_long_data_str"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_long_data_str(longstr long varchar, blb long varbinary)"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_long_data_str(longstr long varchar,blb long varbinary)"); - myquery(rc); - - rc = mysql_commit(mysql); - myquery(rc); - - strmov(query,"INSERT INTO test_long_data_str VALUES(?,?)"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "INSERT INTO test_long_data_str VALUES(?, ?)"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,2); + verify_param_count(stmt, 2); + + /* Always bzero all members of bind parameter */ + bzero((char*) bind, sizeof(bind)); - bind[0].buffer=data; /* string data */ + bind[0].buffer= data; /* string data */ bind[0].buffer_length= sizeof(data); bind[0].length= &length1; - bind[0].buffer_type=FIELD_TYPE_STRING; - bind[0].is_null= 0; + bind[0].buffer_type= MYSQL_TYPE_STRING; length1= 0; - bind[1] = bind[0]; - bind[1].buffer_type=FIELD_TYPE_BLOB; + bind[1]= bind[0]; + bind[1].buffer_type= MYSQL_TYPE_BLOB; - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - length = my_sprintf(data, (data, "MySQL AB")); + length= my_sprintf(data, (data, "MySQL AB")); /* supply data in pieces */ - for (i=0; i < 3; i++) + for (i= 0; i < 3; i++) { - rc = mysql_send_long_data(stmt,0,data,length); + rc= mysql_stmt_send_long_data(stmt, 0, data, length); check_execute(stmt, rc); - rc = mysql_send_long_data(stmt,1,data,2); + rc= mysql_stmt_send_long_data(stmt, 1, data, 2); check_execute(stmt, rc); } /* execute */ - rc = mysql_execute(stmt); - fprintf(stdout," mysql_execute() returned %d\n",rc); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); + check_execute(stmt, rc); mysql_stmt_close(stmt); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* now fetch the results ..*/ - rc = mysql_query(mysql,"SELECT LENGTH(longstr),longstr,LENGTH(blb),blb FROM test_long_data_str"); + rc= mysql_query(mysql, "SELECT LENGTH(longstr), longstr, LENGTH(blb), blb FROM test_long_data_str"); myquery(rc); /* get the result */ - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mysql_field_seek(result, 1); field= mysql_fetch_field(result); @@ -2576,24 +2524,24 @@ static void test_long_data_str1() assert(1 == my_process_result_set(result)); mysql_free_result(result); - my_sprintf(data,(data,"%ld",(long)i*length)); - verify_col_data("test_long_data_str","length(longstr)",data); + my_sprintf(data, (data, "%ld", (long)i*length)); + verify_col_data("test_long_data_str", "length(longstr)", data); - my_sprintf(data,(data,"%d",i*2)); - verify_col_data("test_long_data_str","length(blb)",data); + my_sprintf(data, (data, "%d", i*2)); + verify_col_data("test_long_data_str", "length(blb)", data); /* Test length of field->max_length */ stmt= mysql_simple_prepare(mysql, "SELECT * from test_long_data_str"); check_stmt(stmt); - verify_param_count(stmt,0); - - rc = mysql_execute(stmt); - check_execute(stmt,rc); + verify_param_count(stmt, 0); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); rc= mysql_stmt_store_result(stmt); - check_execute(stmt,rc); + check_execute(stmt, rc); - result= mysql_get_metadata(stmt); + result= mysql_stmt_result_metadata(stmt); field= mysql_fetch_fields(result); /* First test what happens if STMT_ATTR_UPDATE_MAX_LENGTH is not used */ @@ -2603,13 +2551,13 @@ static void test_long_data_str1() /* Enable updating of field->max_length */ true_value= 1; mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void*) &true_value); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); rc= mysql_stmt_store_result(stmt); - check_execute(stmt,rc); + check_execute(stmt, rc); - result= mysql_get_metadata(stmt); + result= mysql_stmt_result_metadata(stmt); field= mysql_fetch_fields(result); DBUG_ASSERT(field->max_length == max_blob_length); @@ -2620,10 +2568,10 @@ static void test_long_data_str1() bind[0].buffer= (char *) &data; /* this buffer won't be altered */ bind[0].buffer_length= 16; bind[0].length= &blob_length; - rc= mysql_bind_result(stmt,bind); + rc= mysql_stmt_bind_result(stmt, bind); data[16]= 0; - DBUG_ASSERT((mysql_fetch(stmt) == 0)); + DBUG_ASSERT((mysql_stmt_fetch(stmt) == 0)); DBUG_ASSERT(strlen(data) == 16); DBUG_ASSERT(blob_length == max_blob_length); @@ -2641,14 +2589,13 @@ static void test_long_data_str1() mysql_stmt_close(stmt); /* Drop created table */ - rc = mysql_query(mysql,"DROP TABLE test_long_data_str"); + rc= mysql_query(mysql, "DROP TABLE test_long_data_str"); myquery(rc); } -/******************************************************** -* to test long data (binary) handling * -*********************************************************/ +/* Test long data (binary) handling */ + static void test_long_data_bin() { MYSQL_STMT *stmt; @@ -2661,69 +2608,61 @@ static void test_long_data_bin() myheader("test_long_data_bin"); - rc = mysql_autocommit(mysql,TRUE); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_long_data_bin"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_long_data_bin"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_long_data_bin(id int, longbin long varbinary)"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_long_data_bin(id int, longbin long varbinary)"); - myquery(rc); - - rc = mysql_commit(mysql); - myquery(rc); - - strmov(query,"INSERT INTO test_long_data_bin VALUES(?,?)"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "INSERT INTO test_long_data_bin VALUES(?, ?)"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,2); + verify_param_count(stmt, 2); - bind[0].buffer = (char *)&length; - bind[0].buffer_type = FIELD_TYPE_LONG; - bind[0].buffer_length= 0; - bind[0].length= 0; - bind[0].is_null= 0; + /* Always bzero all members of bind parameter */ + bzero((char*) bind, sizeof(bind)); + + bind[0].buffer= (char *)&length; + bind[0].buffer_type= MYSQL_TYPE_LONG; length= 0; - bind[1].buffer=data; /* string data */ - bind[1].buffer_type=FIELD_TYPE_LONG_BLOB; - bind[1].length= 0; /* Will not be used */ - bind[1].is_null= 0; - rc = mysql_bind_param(stmt,bind); + bind[1].buffer= data; /* string data */ + bind[1].buffer_type= MYSQL_TYPE_LONG_BLOB; + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - length = 10; - strmov(data,"MySQL AB"); + length= 10; + strmov(data, "MySQL AB"); /* supply data in pieces */ { int i; - for (i=0; i < 100; i++) + for (i= 0; i < 100; i++) { - rc = mysql_send_long_data(stmt,1,(char *)data,4); + rc= mysql_stmt_send_long_data(stmt, 1, (char *)data, 4); check_execute(stmt, rc); } } /* execute */ - rc = mysql_execute(stmt); - fprintf(stdout," mysql_execute() returned %d\n",rc); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); + check_execute(stmt, rc); mysql_stmt_close(stmt); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* now fetch the results ..*/ - rc = mysql_query(mysql,"SELECT LENGTH(longbin), longbin FROM test_long_data_bin"); + rc= mysql_query(mysql, "SELECT LENGTH(longbin), longbin FROM test_long_data_bin"); myquery(rc); /* get the result */ - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert(1 == my_process_result_set(result)); @@ -2731,71 +2670,63 @@ static void test_long_data_bin() } -/******************************************************** -* to test simple delete * -*********************************************************/ +/* Test simple delete */ + static void test_simple_delete() { MYSQL_STMT *stmt; int rc; - char szData[30]={0}; - int nData=1; + char szData[30]= {0}; + int nData= 1; MYSQL_RES *result; MYSQL_BIND bind[2]; ulong length[2]; myheader("test_simple_delete"); - rc = mysql_autocommit(mysql,TRUE); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_simple_delete"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_simple_delete"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE test_simple_delete(col1 int,\ + rc= mysql_query(mysql, "CREATE TABLE test_simple_delete(col1 int, \ col2 varchar(50), col3 int )"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"INSERT INTO test_simple_delete VALUES(1,'MySQL',100)"); + rc= mysql_query(mysql, "INSERT INTO test_simple_delete VALUES(1, 'MySQL', 100)"); myquery(rc); verify_affected_rows(1); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* insert by prepare */ - strmov(query,"DELETE FROM test_simple_delete WHERE col1=? AND col2=? AND col3=100"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "DELETE FROM test_simple_delete WHERE col1= ? AND col2= ? AND col3= 100"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,2); + verify_param_count(stmt, 2); + + /* Always bzero all members of bind parameter */ + bzero((char*) bind, sizeof(bind)); - nData=1; - strmov(szData,"MySQL"); - bind[1].buffer_type=FIELD_TYPE_STRING; - bind[1].buffer= szData; /* string data */ - bind[1].buffer_length=sizeof(szData); + nData= 1; + strmov(szData, "MySQL"); + bind[1].buffer_type= MYSQL_TYPE_STRING; + bind[1].buffer= szData; /* string data */ + bind[1].buffer_length= sizeof(szData); bind[1].length= &length[1]; - bind[1].is_null= 0; length[1]= 5; - bind[0].buffer=(char *)&nData; - bind[0].buffer_type=FIELD_TYPE_LONG; - bind[0].buffer_length= 0; - bind[0].length= 0; - bind[0].is_null= 0; + bind[0].buffer= (char *)&nData; + bind[0].buffer_type= MYSQL_TYPE_LONG; - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); verify_affected_rows(1); @@ -2803,15 +2734,15 @@ static void test_simple_delete() mysql_stmt_close(stmt); /* now fetch the results ..*/ - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* test the results now, only one row should exists */ - rc = mysql_query(mysql,"SELECT * FROM test_simple_delete"); + rc= mysql_query(mysql, "SELECT * FROM test_simple_delete"); myquery(rc); /* get the result */ - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert(0 == my_process_result_set(result)); @@ -2819,105 +2750,98 @@ static void test_simple_delete() } +/* Test simple update */ -/******************************************************** -* to test simple update * -*********************************************************/ static void test_update() { MYSQL_STMT *stmt; int rc; char szData[25]; - int nData=1; + int nData= 1; MYSQL_RES *result; MYSQL_BIND bind[2]; ulong length[2]; myheader("test_update"); - rc = mysql_autocommit(mysql,TRUE); - myquery(rc); - - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_update"); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_update"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_update(col1 int primary key auto_increment,\ - col2 varchar(50), col3 int )"); + rc= mysql_query(mysql, "CREATE TABLE test_update(" + "col1 int primary key auto_increment, " + "col2 varchar(50), col3 int )"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - strmov(query,"INSERT INTO test_update(col2,col3) VALUES(?,?)"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "INSERT INTO test_update(col2, col3) VALUES(?, ?)"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,2); + verify_param_count(stmt, 2); + + /* Always bzero all members of bind parameter */ + bzero((char*) bind, sizeof(bind)); /* string data */ - bind[0].buffer_type=FIELD_TYPE_STRING; - bind[0].buffer=szData; + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[0].buffer= szData; bind[0].buffer_length= sizeof(szData); bind[0].length= &length[0]; length[0]= my_sprintf(szData, (szData, "inserted-data")); - bind[0].is_null= 0; - bind[1].buffer=(char *)&nData; - bind[1].buffer_type=FIELD_TYPE_LONG; - bind[1].buffer_length= 0; - bind[1].length= 0; - bind[1].is_null= 0; + bind[1].buffer= (char *)&nData; + bind[1].buffer_type= MYSQL_TYPE_LONG; - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - nData=100; - rc = mysql_execute(stmt); + nData= 100; + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); verify_affected_rows(1); mysql_stmt_close(stmt); - strmov(query,"UPDATE test_update SET col2=? WHERE col3=?"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "UPDATE test_update SET col2= ? WHERE col3= ?"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,2); - nData=100; + verify_param_count(stmt, 2); + nData= 100; + + /* Always bzero all members of bind parameter */ + bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type=FIELD_TYPE_STRING; - bind[0].buffer=szData; + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[0].buffer= szData; bind[0].buffer_length= sizeof(szData); bind[0].length= &length[0]; length[0]= my_sprintf(szData, (szData, "updated-data")); - bind[1].buffer=(char *)&nData; - bind[1].buffer_type=FIELD_TYPE_LONG; - bind[1].buffer_length= 0; - bind[1].length= 0; - bind[1].is_null= 0; - rc = mysql_bind_param(stmt,bind); + bind[1].buffer= (char *)&nData; + bind[1].buffer_type= MYSQL_TYPE_LONG; + + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); verify_affected_rows(1); mysql_stmt_close(stmt); /* now fetch the results ..*/ - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* test the results now, only one row should exists */ - rc = mysql_query(mysql,"SELECT * FROM test_update"); + rc= mysql_query(mysql, "SELECT * FROM test_update"); myquery(rc); /* get the result */ - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert(1 == my_process_result_set(result)); @@ -2925,9 +2849,8 @@ static void test_update() } -/******************************************************** -* to test simple prepare * -*********************************************************/ +/* Test prepare without parameters */ + static void test_prepare_noparam() { MYSQL_STMT *stmt; @@ -2936,38 +2859,35 @@ static void test_prepare_noparam() myheader("test_prepare_noparam"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS my_prepare"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS my_prepare"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE my_prepare(col1 int ,col2 varchar(50))"); + rc= mysql_query(mysql, "CREATE TABLE my_prepare(col1 int, col2 varchar(50))"); myquery(rc); - /* insert by prepare */ - strmov(query,"INSERT INTO my_prepare VALUES(10,'venu')"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "INSERT INTO my_prepare VALUES(10, 'venu')"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,0); + verify_param_count(stmt, 0); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); mysql_stmt_close(stmt); /* now fetch the results ..*/ - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* test the results now, only one row should exists */ - rc = mysql_query(mysql,"SELECT * FROM my_prepare"); + rc= mysql_query(mysql, "SELECT * FROM my_prepare"); myquery(rc); /* get the result */ - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert(1 == my_process_result_set(result)); @@ -2975,103 +2895,95 @@ static void test_prepare_noparam() } -/******************************************************** -* to test simple bind result * -*********************************************************/ +/* Test simple bind result */ + static void test_bind_result() { MYSQL_STMT *stmt; int rc; int nData; - ulong length, length1; + ulong length, length1; char szData[100]; MYSQL_BIND bind[2]; my_bool is_null[2]; myheader("test_bind_result"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_result"); - myquery(rc); - - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE test_bind_result(col1 int ,col2 varchar(50))"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_bind_result(col1 int , col2 varchar(50))"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_bind_result VALUES(10,'venu')"); + rc= mysql_query(mysql, "INSERT INTO test_bind_result VALUES(10, 'venu')"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_bind_result VALUES(20,'MySQL')"); + rc= mysql_query(mysql, "INSERT INTO test_bind_result VALUES(20, 'MySQL')"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_bind_result(col2) VALUES('monty')"); + rc= mysql_query(mysql, "INSERT INTO test_bind_result(col2) VALUES('monty')"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* fetch */ - bind[0].buffer_type=FIELD_TYPE_LONG; - bind[0].buffer= (char *) &nData; /* integer data */ + bind[0].buffer_type= MYSQL_TYPE_LONG; + bind[0].buffer= (char *) &nData; /* integer data */ bind[0].is_null= &is_null[0]; bind[0].length= 0; - bind[1].buffer_type=FIELD_TYPE_STRING; - bind[1].buffer=szData; /* string data */ - bind[1].buffer_length=sizeof(szData); + bind[1].buffer_type= MYSQL_TYPE_STRING; + bind[1].buffer= szData; /* string data */ + bind[1].buffer_length= sizeof(szData); bind[1].length= &length1; bind[1].is_null= &is_null[1]; - stmt = mysql_simple_prepare(mysql, "SELECT * FROM test_bind_result"); + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_bind_result"); check_stmt(stmt); - rc = mysql_bind_result(stmt,bind); + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + 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); - assert(strcmp(szData,"venu")==0); + assert(strcmp(szData, "venu") == 0); assert(length1 == 4); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + 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); - assert(strcmp(szData,"MySQL")==0); + assert(strcmp(szData, "MySQL") == 0); assert(length1 == 5); - length=99; - rc = mysql_fetch(stmt); - check_execute(stmt,rc); - + length= 99; + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); + 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]); - assert(strcmp(szData,"monty")==0); + assert(strcmp(szData, "monty") == 0); assert(length1 == 5); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } -/******************************************************** -* to test ext bind result * -*********************************************************/ +/* Test ext bind result */ + static void test_bind_result_ext() { MYSQL_STMT *stmt; @@ -3085,33 +2997,28 @@ static void test_bind_result_ext() char szData[20], bData[20]; ulong szLength, bLength; MYSQL_BIND bind[8]; - ulong length[8]; + ulong length[8]; my_bool is_null[8]; myheader("test_bind_result_ext"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_result"); - myquery(rc); - - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE test_bind_result(c1 tinyint, c2 smallint, \ - c3 int, c4 bigint, \ - c5 float, c6 double, \ - c7 varbinary(10), \ - c8 varchar(50))"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_bind_result(c1 tinyint, " + " c2 smallint, " + " c3 int, c4 bigint, " + " c5 float, c6 double, " + " c7 varbinary(10), " + " c8 varchar(50))"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_bind_result VALUES(19,2999,3999,4999999,\ - 2345.6,5678.89563,\ - 'venu','mysql')"); + rc= mysql_query(mysql, "INSERT INTO test_bind_result " + "VALUES (19, 2999, 3999, 4999999, " + " 2345.6, 5678.89563, 'venu', 'mysql')"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); for (i= 0; i < (int) array_elements(bind); i++) @@ -3120,45 +3027,45 @@ static void test_bind_result_ext() bind[i].is_null= &is_null[i]; } - bind[0].buffer_type=MYSQL_TYPE_TINY; - bind[0].buffer=(char *)&t_data; + bind[0].buffer_type= MYSQL_TYPE_TINY; + bind[0].buffer= (char *)&t_data; - bind[1].buffer_type=MYSQL_TYPE_SHORT; - bind[2].buffer_type=MYSQL_TYPE_LONG; - - bind[3].buffer_type=MYSQL_TYPE_LONGLONG; - bind[1].buffer=(char *)&s_data; - - bind[2].buffer=(char *)&i_data; - bind[3].buffer=(char *)&b_data; + bind[1].buffer_type= MYSQL_TYPE_SHORT; + bind[2].buffer_type= MYSQL_TYPE_LONG; - bind[4].buffer_type=MYSQL_TYPE_FLOAT; - bind[4].buffer=(char *)&f_data; + bind[3].buffer_type= MYSQL_TYPE_LONGLONG; + bind[1].buffer= (char *)&s_data; - bind[5].buffer_type=MYSQL_TYPE_DOUBLE; - bind[5].buffer=(char *)&d_data; + bind[2].buffer= (char *)&i_data; + bind[3].buffer= (char *)&b_data; + + bind[4].buffer_type= MYSQL_TYPE_FLOAT; + bind[4].buffer= (char *)&f_data; + + bind[5].buffer_type= MYSQL_TYPE_DOUBLE; + bind[5].buffer= (char *)&d_data; - bind[6].buffer_type=MYSQL_TYPE_STRING; + bind[6].buffer_type= MYSQL_TYPE_STRING; bind[6].buffer= (char *)szData; bind[6].buffer_length= sizeof(szData); bind[6].length= &szLength; - bind[7].buffer_type=MYSQL_TYPE_TINY_BLOB; - bind[7].buffer=(char *)&bData; + bind[7].buffer_type= MYSQL_TYPE_TINY_BLOB; + bind[7].buffer= (char *)&bData; bind[7].length= &bLength; bind[7].buffer_length= sizeof(bData); - stmt = mysql_simple_prepare(mysql, "select * from test_bind_result"); + stmt= mysql_simple_prepare(mysql, "select * from test_bind_result"); check_stmt(stmt); - rc = mysql_bind_result(stmt,bind); + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); fprintf(stdout, "\n data (tiny) : %d", t_data); fprintf(stdout, "\n data (short) : %d", s_data); @@ -3180,25 +3087,24 @@ static void test_bind_result_ext() assert(b_data == 4999999); /*assert(f_data == 2345.60);*/ /*assert(d_data == 5678.89563);*/ - assert(strcmp(szData,"venu")==0); - assert(strncmp(bData,"mysql",5)==0); + assert(strcmp(szData, "venu") == 0); + assert(strncmp(bData, "mysql", 5) == 0); assert(szLength == 4); assert(bLength == 5); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } -/******************************************************** -* to test ext bind result * -*********************************************************/ +/* Test ext bind result */ + static void test_bind_result_ext1() { MYSQL_STMT *stmt; - uint i; + uint i; int rc; char t_data[20]; float s_data; @@ -3213,60 +3119,54 @@ static void test_bind_result_ext1() my_bool is_null[8]; myheader("test_bind_result_ext1"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_result"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE test_bind_result(c1 tinyint, c2 smallint, \ + rc= mysql_query(mysql, "CREATE TABLE test_bind_result(c1 tinyint, c2 smallint, \ c3 int, c4 bigint, \ c5 float, c6 double, \ c7 varbinary(10), \ c8 varchar(10))"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"INSERT INTO test_bind_result VALUES(120,2999,3999,54,\ - 2.6,58.89,\ - '206','6.7')"); + rc= mysql_query(mysql, "INSERT INTO test_bind_result VALUES(120, 2999, 3999, 54, \ + 2.6, 58.89, \ + '206', '6.7')"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); - bind[0].buffer_type=MYSQL_TYPE_STRING; - bind[0].buffer=(char *) t_data; + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[0].buffer= (char *) t_data; bind[0].buffer_length= sizeof(t_data); - bind[1].buffer_type=MYSQL_TYPE_FLOAT; - bind[1].buffer=(char *)&s_data; + bind[1].buffer_type= MYSQL_TYPE_FLOAT; + bind[1].buffer= (char *)&s_data; bind[1].buffer_length= 0; - bind[2].buffer_type=MYSQL_TYPE_SHORT; - bind[2].buffer=(char *)&i_data; + bind[2].buffer_type= MYSQL_TYPE_SHORT; + bind[2].buffer= (char *)&i_data; bind[2].buffer_length= 0; - bind[3].buffer_type=MYSQL_TYPE_TINY; - bind[3].buffer=(char *)&b_data; + bind[3].buffer_type= MYSQL_TYPE_TINY; + bind[3].buffer= (char *)&b_data; bind[3].buffer_length= 0; - bind[4].buffer_type=MYSQL_TYPE_LONG; - bind[4].buffer=(char *)&f_data; + bind[4].buffer_type= MYSQL_TYPE_LONG; + bind[4].buffer= (char *)&f_data; bind[4].buffer_length= 0; - bind[5].buffer_type=MYSQL_TYPE_STRING; - bind[5].buffer=(char *)d_data; + bind[5].buffer_type= MYSQL_TYPE_STRING; + bind[5].buffer= (char *)d_data; bind[5].buffer_length= sizeof(d_data); - bind[6].buffer_type=MYSQL_TYPE_LONG; - bind[6].buffer=(char *)&bData; + bind[6].buffer_type= MYSQL_TYPE_LONG; + bind[6].buffer= (char *)&bData; bind[6].buffer_length= 0; - bind[7].buffer_type=MYSQL_TYPE_DOUBLE; - bind[7].buffer=(char *)&szData; + bind[7].buffer_type= MYSQL_TYPE_DOUBLE; + bind[7].buffer= (char *)&szData; bind[7].buffer_length= 0; for (i= 0; i < array_elements(bind); i++) @@ -3275,17 +3175,17 @@ static void test_bind_result_ext1() bind[i].length= &length[i]; } - stmt = mysql_simple_prepare(mysql, "select * from test_bind_result"); + stmt= mysql_simple_prepare(mysql, "select * from test_bind_result"); check_stmt(stmt); - rc = mysql_bind_result(stmt,bind); + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); fprintf(stdout, "\n data (tiny) : %s(%lu)", t_data, length[0]); fprintf(stdout, "\n data (short) : %f(%lu)", s_data, length[1]); @@ -3298,10 +3198,10 @@ static void test_bind_result_ext1() fprintf(stdout, "\n data (bin) : %ld(%lu)", bData, length[6]); fprintf(stdout, "\n data (str) : %g(%lu)", szData, length[7]); - assert(strcmp(t_data,"120")==0); + assert(strcmp(t_data, "120") == 0); assert(i_data == 3999); assert(f_data == 2); - assert(strcmp(d_data,"58.89")==0); + assert(strcmp(d_data, "58.89") == 0); assert(b_data == 54); assert(length[0] == 3); @@ -3313,56 +3213,58 @@ static void test_bind_result_ext1() assert(length[6] == 4); assert(length[7] == 8); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } -/* - Generalized fetch conversion routine for all basic types -*/ + +/* Generalized fetch conversion routine for all basic types */ + static void bind_fetch(int row_count) -{ +{ MYSQL_STMT *stmt; int rc, i, count= row_count; - ulong bit; + ulong bit; long data[10]; float f_data; double d_data; char s_data[10]; - ulong length[10]; + ulong length[10]; MYSQL_BIND bind[7]; - my_bool is_null[7]; + my_bool is_null[7]; - stmt = mysql_simple_prepare(mysql,"INSERT INTO test_bind_fetch VALUES(?,?,?,?,?,?,?)"); + stmt= mysql_simple_prepare(mysql, "INSERT INTO test_bind_fetch VALUES " + "(?, ?, ?, ?, ?, ?, ?)"); check_stmt(stmt); verify_param_count(stmt, 7); - + + /* Always bzero all members of bind parameter */ + bzero((char*) bind, sizeof(bind)); + for (i= 0; i < (int) array_elements(bind); i++) - { + { bind[i].buffer_type= MYSQL_TYPE_LONG; bind[i].buffer= (char *) &data[i]; - bind[i].length= 0; - bind[i].is_null= 0; - } - rc = mysql_bind_param(stmt, bind); - check_execute(stmt,rc); - + } + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); + while (count--) { rc= 10+count; for (i= 0; i < (int) array_elements(bind); i++) - { + { data[i]= rc+i; rc+= 12; } - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); } - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); mysql_stmt_close(stmt); @@ -3370,7 +3272,7 @@ static void bind_fetch(int row_count) assert(row_count == (int) my_stmt_result("SELECT * FROM test_bind_fetch")); - stmt = mysql_simple_prepare(mysql,"SELECT * FROM test_bind_fetch"); + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_bind_fetch"); myquery(rc); for (i= 0; i < (int) array_elements(bind); i++) @@ -3395,19 +3297,19 @@ static void bind_fetch(int row_count) bind[6].buffer= (char *)&s_data; bind[6].buffer_length= sizeof(s_data); - rc = mysql_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_stmt_store_result(stmt); + rc= mysql_stmt_store_result(stmt); check_execute(stmt, rc); while (row_count--) { - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); fprintf(stdout, "\n"); fprintf(stdout, "\n tiny : %ld(%lu)", data[0], length[0]); @@ -3420,7 +3322,7 @@ static void bind_fetch(int row_count) bit= 1; rc= 10+row_count; - for (i=0; i < 4; i++) + for (i= 0; i < 4; i++) { assert(data[i] == rc+i); assert(length[i] == bit); @@ -3443,40 +3345,37 @@ static void bind_fetch(int row_count) { char buff[20]; long len= my_sprintf(buff, (buff, "%d", rc)); - assert(strcmp(s_data,buff)==0); + assert(strcmp(s_data, buff) == 0); assert(length[6] == (ulong) len); } } - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } -/******************************************************** -* to test fetching of date, time and ts * -*********************************************************/ + +/* Test fetching of date, time and ts */ + static void test_fetch_date() { MYSQL_STMT *stmt; - uint i; + uint i; int rc, year; char date[25], time[25], ts[25], ts_4[15], ts_6[20], dt[20]; - ulong d_length, t_length, ts_length, ts4_length, ts6_length, + ulong d_length, t_length, ts_length, ts4_length, ts6_length, dt_length, y_length; MYSQL_BIND bind[8]; my_bool is_null[8]; - ulong length[8]; + ulong length[8]; myheader("test_fetch_date"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_result"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_bind_result(c1 date, c2 time, \ + rc= mysql_query(mysql, "CREATE TABLE test_bind_result(c1 date, c2 time, \ c3 timestamp(14), \ c4 year, \ c5 datetime, \ @@ -3484,18 +3383,15 @@ static void test_fetch_date() c7 timestamp(6))"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"INSERT INTO test_bind_result VALUES('2002-01-02',\ - '12:49:00',\ + rc= mysql_query(mysql, "INSERT INTO test_bind_result VALUES('2002-01-02', \ + '12:49:00', \ '2002-01-02 17:46:59', \ - 2010,\ + 2010, \ '2010-07-10', \ - '2020','1999-12-29')"); + '2020', '1999-12-29')"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); for (i= 0; i < array_elements(bind); i++) @@ -3504,54 +3400,54 @@ static void test_fetch_date() bind[i].length= &length[i]; } - bind[0].buffer_type=MYSQL_TYPE_STRING; - bind[1]=bind[2]=bind[0]; + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[1]= bind[2]= bind[0]; - bind[0].buffer=(char *)&date; + bind[0].buffer= (char *)&date; bind[0].buffer_length= sizeof(date); bind[0].length= &d_length; - bind[1].buffer=(char *)&time; + bind[1].buffer= (char *)&time; bind[1].buffer_length= sizeof(time); bind[1].length= &t_length; - bind[2].buffer=(char *)&ts; + bind[2].buffer= (char *)&ts; bind[2].buffer_length= sizeof(ts); bind[2].length= &ts_length; - bind[3].buffer_type=MYSQL_TYPE_LONG; - bind[3].buffer=(char *)&year; + bind[3].buffer_type= MYSQL_TYPE_LONG; + bind[3].buffer= (char *)&year; bind[3].length= &y_length; - bind[4].buffer_type=MYSQL_TYPE_STRING; - bind[4].buffer=(char *)&dt; + bind[4].buffer_type= MYSQL_TYPE_STRING; + bind[4].buffer= (char *)&dt; bind[4].buffer_length= sizeof(dt); bind[4].length= &dt_length; - bind[5].buffer_type=MYSQL_TYPE_STRING; - bind[5].buffer=(char *)&ts_4; + bind[5].buffer_type= MYSQL_TYPE_STRING; + bind[5].buffer= (char *)&ts_4; bind[5].buffer_length= sizeof(ts_4); bind[5].length= &ts4_length; - bind[6].buffer_type=MYSQL_TYPE_STRING; - bind[6].buffer=(char *)&ts_6; + bind[6].buffer_type= MYSQL_TYPE_STRING; + bind[6].buffer= (char *)&ts_6; bind[6].buffer_length= sizeof(ts_6); bind[6].length= &ts6_length; assert(1 == my_stmt_result("SELECT * FROM test_bind_result")); - stmt = mysql_simple_prepare(mysql, "SELECT * FROM test_bind_result"); + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_bind_result"); check_stmt(stmt); - rc = mysql_bind_result(stmt,bind); + rc= mysql_stmt_bind_result(stmt, bind); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_execute(stmt); + ts_4[0]= '\0'; + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - - ts_4[0]='\0'; - rc = mysql_fetch(stmt); - check_execute(stmt,rc); fprintf(stdout, "\n date : %s(%lu)", date, d_length); fprintf(stdout, "\n time : %s(%lu)", time, t_length); @@ -3561,371 +3457,313 @@ static void test_fetch_date() fprintf(stdout, "\n ts(4) : %s(%lu)", ts_4, ts4_length); fprintf(stdout, "\n ts(6) : %s(%lu)", ts_6, ts6_length); - assert(strcmp(date,"2002-01-02")==0); + assert(strcmp(date, "2002-01-02") == 0); assert(d_length == 10); - assert(strcmp(time,"12:49:00")==0); + assert(strcmp(time, "12:49:00") == 0); assert(t_length == 8); - assert(strcmp(ts,"2002-01-02 17:46:59")==0); + assert(strcmp(ts, "2002-01-02 17:46:59") == 0); assert(ts_length == 19); assert(year == 2010); assert(y_length == 4); - - assert(strcmp(dt,"2010-07-10 00:00:00")==0); + + assert(strcmp(dt, "2010-07-10 00:00:00") == 0); assert(dt_length == 19); assert(ts_4[0] == '\0'); assert(ts4_length == 0); - assert(strcmp(ts_6,"1999-12-29 00:00:00")==0); + assert(strcmp(ts_6, "1999-12-29 00:00:00") == 0); assert(ts6_length == 19); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } -/******************************************************** -* to test fetching of str to all types * -*********************************************************/ + +/* Test fetching of str to all types */ + static void test_fetch_str() { int rc; myheader("test_fetch_str"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_fetch"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_fetch"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE test_bind_fetch(c1 char(10),\ - c2 char(10),\ - c3 char(20),\ - c4 char(20),\ - c5 char(30),\ - c6 char(40),\ + rc= mysql_query(mysql, "CREATE TABLE test_bind_fetch(c1 char(10), \ + c2 char(10), \ + c3 char(20), \ + c4 char(20), \ + c5 char(30), \ + c6 char(40), \ c7 char(20))"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - bind_fetch(3); } -/******************************************************** -* to test fetching of long to all types * -*********************************************************/ + +/* Test fetching of long to all types */ + static void test_fetch_long() { int rc; myheader("test_fetch_long"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_fetch"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_fetch"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_bind_fetch(c1 int unsigned,\ - c2 int unsigned,\ - c3 int,\ - c4 int,\ - c5 int,\ - c6 int unsigned,\ + rc= mysql_query(mysql, "CREATE TABLE test_bind_fetch(c1 int unsigned, \ + c2 int unsigned, \ + c3 int, \ + c4 int, \ + c5 int, \ + c6 int unsigned, \ c7 int)"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - bind_fetch(4); } -/******************************************************** -* to test fetching of short to all types * -*********************************************************/ +/* Test fetching of short to all types */ + static void test_fetch_short() { int rc; myheader("test_fetch_short"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_fetch"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_fetch"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,\ - c2 smallint,\ - c3 smallint unsigned,\ - c4 smallint,\ - c5 smallint,\ - c6 smallint,\ + rc= mysql_query(mysql, "CREATE TABLE test_bind_fetch(c1 smallint unsigned, \ + c2 smallint, \ + c3 smallint unsigned, \ + c4 smallint, \ + c5 smallint, \ + c6 smallint, \ c7 smallint unsigned)"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - bind_fetch(5); } -/******************************************************** -* to test fetching of tiny to all types * -*********************************************************/ +/* Test fetching of tiny to all types */ + static void test_fetch_tiny() { int rc; myheader("test_fetch_tiny"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_fetch"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_fetch"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_bind_fetch(c1 tinyint unsigned,\ - c2 tinyint,\ - c3 tinyint unsigned,\ - c4 tinyint,\ - c5 tinyint,\ - c6 tinyint,\ + rc= mysql_query(mysql, "CREATE TABLE test_bind_fetch(c1 tinyint unsigned, \ + c2 tinyint, \ + c3 tinyint unsigned, \ + c4 tinyint, \ + c5 tinyint, \ + c6 tinyint, \ c7 tinyint unsigned)"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - bind_fetch(3); } -/******************************************************** -* to test fetching of longlong to all types * -*********************************************************/ +/* Test fetching of longlong to all types */ + static void test_fetch_bigint() { int rc; myheader("test_fetch_bigint"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_fetch"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_fetch"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_bind_fetch(c1 bigint,\ - c2 bigint,\ - c3 bigint unsigned,\ - c4 bigint unsigned,\ - c5 bigint unsigned,\ - c6 bigint unsigned,\ + rc= mysql_query(mysql, "CREATE TABLE test_bind_fetch(c1 bigint, \ + c2 bigint, \ + c3 bigint unsigned, \ + c4 bigint unsigned, \ + c5 bigint unsigned, \ + c6 bigint unsigned, \ c7 bigint unsigned)"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - bind_fetch(2); } -/******************************************************** -* to test fetching of float to all types * -*********************************************************/ +/* Test fetching of float to all types */ + static void test_fetch_float() { int rc; myheader("test_fetch_float"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_fetch"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_fetch"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE test_bind_fetch(c1 float(3),\ - c2 float,\ - c3 float unsigned,\ - c4 float,\ - c5 float,\ - c6 float,\ + rc= mysql_query(mysql, "CREATE TABLE test_bind_fetch(c1 float(3), \ + c2 float, \ + c3 float unsigned, \ + c4 float, \ + c5 float, \ + c6 float, \ c7 float(10) unsigned)"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - bind_fetch(2); } -/******************************************************** -* to test fetching of double to all types * -*********************************************************/ + +/* Test fetching of double to all types */ + static void test_fetch_double() { int rc; myheader("test_fetch_double"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_fetch"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_fetch"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_bind_fetch(c1 double(5,2),\ - c2 double unsigned,\ - c3 double unsigned,\ - c4 double unsigned,\ - c5 double unsigned,\ - c6 double unsigned,\ - c7 double unsigned)"); + rc= mysql_query(mysql, "CREATE TABLE test_bind_fetch(c1 double(5, 2), " + "c2 double unsigned, c3 double unsigned, " + "c4 double unsigned, c5 double unsigned, " + "c6 double unsigned, c7 double unsigned)"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - bind_fetch(3); } -/******************************************************** -* to test simple prepare with all possible types * -*********************************************************/ + +/* Test simple prepare with all possible types */ + static void test_prepare_ext() { MYSQL_STMT *stmt; - uint i; int rc; char *sql; - int nData=1; - char tData=1; - short sData=10; - longlong bData=20; + int nData= 1; + char tData= 1; + short sData= 10; + longlong bData= 20; MYSQL_BIND bind[6]; myheader("test_prepare_ext"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prepare_ext"); - myquery(rc); - - rc = mysql_commit(mysql); - myquery(rc); - - sql = (char *)"CREATE TABLE test_prepare_ext\ - (\ - c1 tinyint,\ - c2 smallint,\ - c3 mediumint,\ - c4 int,\ - c5 integer,\ - c6 bigint,\ - c7 float,\ - c8 double,\ - c9 double precision,\ - c10 real,\ - c11 decimal(7,4),\ - c12 numeric(8,4),\ - c13 date,\ - c14 datetime,\ - c15 timestamp(14),\ - c16 time,\ - c17 year,\ - c18 bit,\ - c19 bool,\ - c20 char,\ - c21 char(10),\ - c22 varchar(30),\ - c23 tinyblob,\ - c24 tinytext,\ - c25 blob,\ - c26 text,\ - c27 mediumblob,\ - c28 mediumtext,\ - c29 longblob,\ - c30 longtext,\ - c31 enum('one','two','three'),\ - c32 set('monday','tuesday','wednesday'))"; - - rc = mysql_query(mysql,sql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prepare_ext"); + myquery(rc); + + sql= (char *)"CREATE TABLE test_prepare_ext\ + (\ + c1 tinyint, \ + c2 smallint, \ + c3 mediumint, \ + c4 int, \ + c5 integer, \ + c6 bigint, \ + c7 float, \ + c8 double, \ + c9 double precision, \ + c10 real, \ + c11 decimal(7, 4), \ + c12 numeric(8, 4), \ + c13 date, \ + c14 datetime, \ + c15 timestamp(14), \ + c16 time, \ + c17 year, \ + c18 bit, \ + c19 bool, \ + c20 char, \ + c21 char(10), \ + c22 varchar(30), \ + c23 tinyblob, \ + c24 tinytext, \ + c25 blob, \ + c26 text, \ + c27 mediumblob, \ + c28 mediumtext, \ + c29 longblob, \ + c30 longtext, \ + c31 enum('one', 'two', 'three'), \ + c32 set('monday', 'tuesday', 'wednesday'))"; + + rc= mysql_query(mysql, sql); myquery(rc); /* insert by prepare - all integers */ - strmov(query,(char *)"INSERT INTO test_prepare_ext(c1,c2,c3,c4,c5,c6) VALUES(?,?,?,?,?,?)"); - stmt = mysql_simple_prepare(mysql,query); + strmov(query, (char *)"INSERT INTO test_prepare_ext(c1, c2, c3, c4, c5, c6) VALUES(?, ?, ?, ?, ?, ?)"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,6); + verify_param_count(stmt, 6); + + /* Always bzero all members of bind parameter */ + bzero((char*) bind, sizeof(bind)); /*tinyint*/ - bind[0].buffer_type=FIELD_TYPE_TINY; + bind[0].buffer_type= MYSQL_TYPE_TINY; bind[0].buffer= (char *)&tData; /*smallint*/ - bind[1].buffer_type=FIELD_TYPE_SHORT; + bind[1].buffer_type= MYSQL_TYPE_SHORT; bind[1].buffer= (char *)&sData; /*mediumint*/ - bind[2].buffer_type=FIELD_TYPE_LONG; + bind[2].buffer_type= MYSQL_TYPE_LONG; bind[2].buffer= (char *)&nData; /*int*/ - bind[3].buffer_type=FIELD_TYPE_LONG; + bind[3].buffer_type= MYSQL_TYPE_LONG; bind[3].buffer= (char *)&nData; /*integer*/ - bind[4].buffer_type=FIELD_TYPE_LONG; + bind[4].buffer_type= MYSQL_TYPE_LONG; bind[4].buffer= (char *)&nData; /*bigint*/ - bind[5].buffer_type=FIELD_TYPE_LONGLONG; + bind[5].buffer_type= MYSQL_TYPE_LONGLONG; bind[5].buffer= (char *)&bData; - for (i= 0; i < array_elements(bind); i++) - { - bind[i].is_null=0; - bind[i].buffer_length= 0; - bind[i].length= 0; - } - - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); /* * integer to integer */ - for (nData=0; nData<10; nData++, tData++, sData++,bData++) + for (nData= 0; nData<10; nData++, tData++, sData++, bData++) { - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); } mysql_stmt_close(stmt); /* now fetch the results ..*/ - rc = mysql_commit(mysql); - myquery(rc); - stmt = mysql_simple_prepare(mysql,"SELECT c1,c2,c3,c4,c5,c6 FROM test_prepare_ext"); + stmt= mysql_simple_prepare(mysql, "SELECT c1, c2, c3, c4, c5, c6 " + "FROM test_prepare_ext"); check_stmt(stmt); /* get the result */ - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(nData == (int)my_process_stmt_result(stmt)); @@ -3934,10 +3772,8 @@ static void test_prepare_ext() } +/* Test real and alias names */ -/******************************************************** -* to test real and alias names * -*********************************************************/ static void test_field_names() { int rc; @@ -3945,49 +3781,43 @@ static void test_field_names() myheader("test_field_names"); - fprintf(stdout,"\n %d,%d,%d",MYSQL_TYPE_DECIMAL,MYSQL_TYPE_NEWDATE,MYSQL_TYPE_ENUM); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_field_names1"); - myquery(rc); - - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_field_names2"); - myquery(rc); - - rc = mysql_commit(mysql); + fprintf(stdout, "\n %d, %d, %d", MYSQL_TYPE_DECIMAL, MYSQL_TYPE_NEWDATE, MYSQL_TYPE_ENUM); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_field_names1"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_field_names1(id int,name varchar(50))"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_field_names2"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_field_names2(id int,name varchar(50))"); + rc= mysql_query(mysql, "CREATE TABLE test_field_names1(id int, name varchar(50))"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_field_names2(id int, name varchar(50))"); myquery(rc); /* with table name included with TRUE column name */ - rc = mysql_query(mysql,"SELECT id as 'id-alias' FROM test_field_names1"); + rc= mysql_query(mysql, "SELECT id as 'id-alias' FROM test_field_names1"); myquery(rc); - result = mysql_use_result(mysql); + result= mysql_use_result(mysql); mytest(result); assert(0 == my_process_result_set(result)); mysql_free_result(result); /* with table name included with TRUE column name */ - rc = mysql_query(mysql,"SELECT t1.id as 'id-alias',test_field_names2.name FROM test_field_names1 t1,test_field_names2"); + rc= mysql_query(mysql, "SELECT t1.id as 'id-alias', test_field_names2.name FROM test_field_names1 t1, test_field_names2"); myquery(rc); - result = mysql_use_result(mysql); + result= mysql_use_result(mysql); mytest(result); assert(0 == my_process_result_set(result)); mysql_free_result(result); } -/******************************************************** -* to test warnings * -*********************************************************/ + +/* Test warnings */ + static void test_warnings() { int rc; @@ -3997,23 +3827,23 @@ static void test_warnings() mysql_query(mysql, "DROP TABLE if exists test_non_exists"); - rc = mysql_query(mysql, "DROP TABLE if exists test_non_exists"); + rc= mysql_query(mysql, "DROP TABLE if exists test_non_exists"); myquery(rc); fprintf(stdout, "\n total warnings: %d", mysql_warning_count(mysql)); - rc = mysql_query(mysql,"SHOW WARNINGS"); + rc= mysql_query(mysql, "SHOW WARNINGS"); myquery(rc); - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert(1 == my_process_result_set(result)); mysql_free_result(result); } -/******************************************************** -* to test errors * -*********************************************************/ + +/* Test errors */ + static void test_errors() { int rc; @@ -4023,13 +3853,13 @@ static void test_errors() mysql_query(mysql, "DROP TABLE if exists test_non_exists"); - rc = mysql_query(mysql, "DROP TABLE test_non_exists"); + rc= mysql_query(mysql, "DROP TABLE test_non_exists"); myquery_r(rc); - rc = mysql_query(mysql,"SHOW ERRORS"); + rc= mysql_query(mysql, "SHOW ERRORS"); myquery(rc); - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); my_process_result_set(result); @@ -4037,10 +3867,8 @@ static void test_errors() } +/* Test simple prepare-insert */ -/******************************************************** -* to test simple prepare-insert * -*********************************************************/ static void test_insert() { MYSQL_STMT *stmt; @@ -4049,65 +3877,66 @@ static void test_insert() char tiny_data; MYSQL_RES *result; MYSQL_BIND bind[2]; - ulong length; + ulong length; myheader("test_insert"); - rc = mysql_autocommit(mysql, TRUE); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prep_insert"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prep_insert"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE test_prep_insert(col1 tinyint,\ + rc= mysql_query(mysql, "CREATE TABLE test_prep_insert(col1 tinyint, \ col2 varchar(50))"); myquery(rc); /* insert by prepare */ - stmt = mysql_simple_prepare(mysql, "INSERT INTO test_prep_insert VALUES(?,?)"); + stmt= mysql_simple_prepare(mysql, + "INSERT INTO test_prep_insert VALUES(?, ?)"); check_stmt(stmt); - verify_param_count(stmt,2); + verify_param_count(stmt, 2); + + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); /* tinyint */ - bind[0].buffer_type=FIELD_TYPE_TINY; - bind[0].buffer=(char *)&tiny_data; - bind[0].is_null= 0; - bind[0].length= 0; + bind[0].buffer_type= MYSQL_TYPE_TINY; + bind[0].buffer= (char *)&tiny_data; /* string */ - bind[1].buffer_type=FIELD_TYPE_STRING; - bind[1].buffer=str_data; - bind[1].buffer_length=sizeof(str_data);; - bind[1].is_null= 0; + bind[1].buffer_type= MYSQL_TYPE_STRING; + bind[1].buffer= str_data; + bind[1].buffer_length= sizeof(str_data);; bind[1].length= &length; - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); /* now, execute the prepared statement to insert 10 records.. */ - for (tiny_data=0; tiny_data < 3; tiny_data++) + for (tiny_data= 0; tiny_data < 3; tiny_data++) { - length = my_sprintf(str_data, (str_data, "MySQL%d",tiny_data)); - rc = mysql_execute(stmt); + length= my_sprintf(str_data, (str_data, "MySQL%d", tiny_data)); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); } mysql_stmt_close(stmt); /* now fetch the results ..*/ - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* test the results now, only one row should exists */ - rc = mysql_query(mysql,"SELECT * FROM test_prep_insert"); + rc= mysql_query(mysql, "SELECT * FROM test_prep_insert"); myquery(rc); /* get the result */ - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert((int)tiny_data == my_process_result_set(result)); @@ -4115,9 +3944,9 @@ static void test_insert() } -/******************************************************** -* to test simple prepare-resultset info * -*********************************************************/ + +/* Test simple prepare-resultset info */ + static void test_prepare_resultset() { MYSQL_STMT *stmt; @@ -4126,34 +3955,30 @@ static void test_prepare_resultset() myheader("test_prepare_resultset"); - rc = mysql_autocommit(mysql, TRUE); - myquery(rc); - - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prepare_resultset"); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prepare_resultset"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_prepare_resultset(id int,\ - name varchar(50),extra double)"); + rc= mysql_query(mysql, "CREATE TABLE test_prepare_resultset(id int, \ + name varchar(50), extra double)"); myquery(rc); - stmt = mysql_simple_prepare(mysql, "SELECT * FROM test_prepare_resultset"); + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_prepare_resultset"); check_stmt(stmt); - verify_param_count(stmt,0); + verify_param_count(stmt, 0); - result = mysql_get_metadata(stmt); + result= mysql_stmt_result_metadata(stmt); mytest(result); my_print_result_metadata(result); mysql_free_result(result); mysql_stmt_close(stmt); } -/******************************************************** -* to test field flags (verify .NET provider) * -*********************************************************/ + +/* Test field flags (verify .NET provider) */ static void test_field_flags() { @@ -4165,56 +3990,50 @@ static void test_field_flags() myheader("test_field_flags"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_field_flags"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_field_flags"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_field_flags(id int NOT NULL AUTO_INCREMENT PRIMARY KEY,\ - id1 int NOT NULL,\ - id2 int UNIQUE,\ - id3 int,\ - id4 int NOT NULL,\ - id5 int,\ - KEY(id3,id4))"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_field_flags(id int NOT NULL AUTO_INCREMENT PRIMARY KEY, \ + id1 int NOT NULL, \ + id2 int UNIQUE, \ + id3 int, \ + id4 int NOT NULL, \ + id5 int, \ + KEY(id3, id4))"); myquery(rc); /* with table name included with TRUE column name */ - rc = mysql_query(mysql,"SELECT * FROM test_field_flags"); + rc= mysql_query(mysql, "SELECT * FROM test_field_flags"); myquery(rc); - result = mysql_use_result(mysql); + result= mysql_use_result(mysql); mytest(result); - mysql_field_seek(result,0); - fputc('\n', stdout); + mysql_field_seek(result, 0); + fputc('\n', stdout); - for(i=0; i< mysql_num_fields(result); i++) + for(i= 0; i< mysql_num_fields(result); i++) { - field = mysql_fetch_field(result); - fprintf(stdout,"\n field:%d",i); + field= mysql_fetch_field(result); + fprintf(stdout, "\n field:%d", i); if (field->flags & NOT_NULL_FLAG) - fprintf(stdout,"\n NOT_NULL_FLAG"); + fprintf(stdout, "\n NOT_NULL_FLAG"); if (field->flags & PRI_KEY_FLAG) - fprintf(stdout,"\n PRI_KEY_FLAG"); + fprintf(stdout, "\n PRI_KEY_FLAG"); if (field->flags & UNIQUE_KEY_FLAG) - fprintf(stdout,"\n UNIQUE_KEY_FLAG"); + fprintf(stdout, "\n UNIQUE_KEY_FLAG"); if (field->flags & MULTIPLE_KEY_FLAG) - fprintf(stdout,"\n MULTIPLE_KEY_FLAG"); + fprintf(stdout, "\n MULTIPLE_KEY_FLAG"); if (field->flags & AUTO_INCREMENT_FLAG) - fprintf(stdout,"\n AUTO_INCREMENT_FLAG"); + fprintf(stdout, "\n AUTO_INCREMENT_FLAG"); } mysql_free_result(result); } -/************************************************************** - * Test mysql_stmt_close for open stmts * -**************************************************************/ + +/* Test mysql_stmt_close for open stmts */ + static void test_stmt_close() { MYSQL *lmysql; @@ -4223,97 +4042,100 @@ static void test_stmt_close() MYSQL_RES *result; unsigned int count; int rc; - - myheader("test_stmt_close"); + + myheader("test_stmt_close"); fprintf(stdout, "\n Establishing a test connection ..."); - if (!(lmysql = mysql_init(NULL))) - { + if (!(lmysql= mysql_init(NULL))) + { myerror("mysql_init() failed"); exit(0); } - if (!(mysql_real_connect(lmysql,opt_host,opt_user, - opt_password, current_db, opt_port, - opt_unix_socket, 0))) + if (!(mysql_real_connect(lmysql, opt_host, opt_user, + opt_password, current_db, opt_port, + opt_unix_socket, 0))) { myerror("connection failed"); exit(0); - } - fprintf(stdout," OK"); - + } + fprintf(stdout, " OK"); + /* set AUTOCOMMIT to ON*/ mysql_autocommit(lmysql, TRUE); - - rc = mysql_query(lmysql,"DROP TABLE IF EXISTS test_stmt_close"); + + rc= mysql_query(lmysql, "DROP TABLE IF EXISTS test_stmt_close"); myquery(rc); - - rc = mysql_query(lmysql,"CREATE TABLE test_stmt_close(id int)"); + + rc= mysql_query(lmysql, "CREATE TABLE test_stmt_close(id int)"); myquery(rc); - strmov(query,"DO \"nothing\""); + strmov(query, "DO \"nothing\""); stmt1= mysql_simple_prepare(lmysql, query); check_stmt(stmt1); - + verify_param_count(stmt1, 0); - - strmov(query,"INSERT INTO test_stmt_close(id) VALUES(?)"); + + strmov(query, "INSERT INTO test_stmt_close(id) VALUES(?)"); stmt_x= mysql_simple_prepare(mysql, query); check_stmt(stmt_x); verify_param_count(stmt_x, 1); - - strmov(query,"UPDATE test_stmt_close SET id=? WHERE id=?"); + + strmov(query, "UPDATE test_stmt_close SET id= ? WHERE id= ?"); stmt3= mysql_simple_prepare(lmysql, query); check_stmt(stmt3); - + verify_param_count(stmt3, 2); - - strmov(query,"SELECT * FROM test_stmt_close WHERE id=?"); + + strmov(query, "SELECT * FROM test_stmt_close WHERE id= ?"); stmt2= mysql_simple_prepare(lmysql, query); check_stmt(stmt2); verify_param_count(stmt2, 1); 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); - + /* Originally we were going to close all statements automatically in mysql_close(). This proved to not work well - users weren't able to close statements by hand once mysql_close() had been called. Now mysql_close() doesn't free any statements, so this test doesn't - serve its original destination any more. + serve its original designation any more. Here we free stmt2 and stmt3 by hande to avoid memory leaks. */ mysql_stmt_close(stmt2); mysql_stmt_close(stmt3); mysql_close(lmysql); - + + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); + + bind[0].buffer= (char *)&count; + bind[0].buffer_type= MYSQL_TYPE_LONG; count= 100; - bind[0].buffer=(char *)&count; - bind[0].buffer_type=MYSQL_TYPE_LONG; - bind[0].buffer_length= 0; - bind[0].length= 0; - bind[0].is_null=0; - rc = mysql_bind_param(stmt_x, bind); + rc= mysql_stmt_bind_param(stmt_x, bind); check_execute(stmt_x, rc); - - rc = mysql_execute(stmt_x); + + rc= mysql_stmt_execute(stmt_x); check_execute(stmt_x, rc); verify_st_affected_rows(stmt_x, 1); 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); - rc = mysql_query(mysql,"SELECT id FROM test_stmt_close"); + rc= mysql_query(mysql, "SELECT id FROM test_stmt_close"); myquery(rc); - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert(1 == my_process_result_set(result)); @@ -4321,9 +4143,8 @@ static void test_stmt_close() } -/******************************************************** - * To test simple set-variable prepare * -*********************************************************/ +/* Test simple set-variable prepare */ + static void test_set_variable() { MYSQL_STMT *stmt, *stmt1; @@ -4336,13 +4157,18 @@ static void test_set_variable() myheader("test_set_variable"); mysql_autocommit(mysql, TRUE); - - stmt1 = mysql_simple_prepare(mysql, "show variables like 'max_error_count'"); + + stmt1= mysql_simple_prepare(mysql, "show variables like 'max_error_count'"); check_stmt(stmt1); + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) get_bind, sizeof(get_bind)); + get_bind[0].buffer_type= MYSQL_TYPE_STRING; get_bind[0].buffer= (char *)var; - get_bind[0].is_null= 0; get_bind[0].length= &length; get_bind[0].buffer_length= (int)NAME_LEN; length= NAME_LEN; @@ -4352,74 +4178,76 @@ static void test_set_variable() get_bind[1].is_null= 0; get_bind[1].length= 0; - rc = mysql_execute(stmt1); + rc= mysql_stmt_execute(stmt1); check_execute(stmt1, rc); - - rc = mysql_bind_result(stmt1, get_bind); + + rc= mysql_stmt_bind_result(stmt1, get_bind); check_execute(stmt1, rc); - rc = mysql_fetch(stmt1); + rc= mysql_stmt_fetch(stmt1); check_execute(stmt1, rc); fprintf(stdout, "\n max_error_count(default): %d", get_count); def_count= get_count; - assert(strcmp(var,"max_error_count") == 0); - rc = mysql_fetch(stmt1); + assert(strcmp(var, "max_error_count") == 0); + rc= mysql_stmt_fetch(stmt1); assert(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); + bzero((char*) set_bind, sizeof(set_bind)); + set_bind[0].buffer_type= MYSQL_TYPE_LONG; set_bind[0].buffer= (char *)&set_count; - set_bind[0].is_null= 0; - set_bind[0].length= 0; - - rc = mysql_bind_param(stmt, set_bind); - check_execute(stmt,rc); - + + rc= mysql_stmt_bind_param(stmt, set_bind); + check_execute(stmt, rc); + set_count= 31; - rc= mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); mysql_commit(mysql); - rc = mysql_execute(stmt1); + rc= mysql_stmt_execute(stmt1); check_execute(stmt1, rc); - - rc = mysql_fetch(stmt1); + + rc= mysql_stmt_fetch(stmt1); check_execute(stmt1, rc); fprintf(stdout, "\n max_error_count : %d", get_count); assert(get_count == set_count); - rc = mysql_fetch(stmt1); + rc= mysql_stmt_fetch(stmt1); assert(rc == MYSQL_NO_DATA); - + /* restore back to default */ set_count= def_count; - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - - rc = mysql_execute(stmt1); + + rc= mysql_stmt_execute(stmt1); check_execute(stmt1, rc); - - rc = mysql_fetch(stmt1); + + rc= mysql_stmt_fetch(stmt1); check_execute(stmt1, rc); fprintf(stdout, "\n max_error_count(default): %d", get_count); assert(get_count == set_count); - rc = mysql_fetch(stmt1); + rc= mysql_stmt_fetch(stmt1); assert(rc == MYSQL_NO_DATA); - + mysql_stmt_close(stmt); mysql_stmt_close(stmt1); } #if NOT_USED + /* Insert meta info .. */ + static void test_insert_meta() { MYSQL_STMT *stmt; @@ -4429,35 +4257,32 @@ static void test_insert_meta() myheader("test_insert_meta"); - rc = mysql_autocommit(mysql, TRUE); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prep_insert"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prep_insert"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE test_prep_insert(col1 tinyint,\ + rc= mysql_query(mysql, "CREATE TABLE test_prep_insert(col1 tinyint, \ col2 varchar(50), col3 varchar(30))"); myquery(rc); - strmov(query,"INSERT INTO test_prep_insert VALUES(10,'venu1','test')"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "INSERT INTO test_prep_insert VALUES(10, 'venu1', 'test')"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,0); + verify_param_count(stmt, 0); result= mysql_param_result(stmt); mytest_r(result); mysql_stmt_close(stmt); - strmov(query,"INSERT INTO test_prep_insert VALUES(?,'venu',?)"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "INSERT INTO test_prep_insert VALUES(?, 'venu', ?)"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,2); + verify_param_count(stmt, 2); result= mysql_param_result(stmt); mytest(result); @@ -4468,12 +4293,12 @@ static void test_insert_meta() field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col1"); - assert(strcmp(field->name,"col1")==0); + assert(strcmp(field->name, "col1") == 0); field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col3"); - assert(strcmp(field->name,"col3")==0); + assert(strcmp(field->name, "col3") == 0); field= mysql_fetch_field(result); mytest_r(field); @@ -4482,7 +4307,9 @@ static void test_insert_meta() mysql_stmt_close(stmt); } + /* Update meta info .. */ + static void test_update_meta() { MYSQL_STMT *stmt; @@ -4492,35 +4319,32 @@ static void test_update_meta() myheader("test_update_meta"); - rc = mysql_autocommit(mysql, TRUE); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prep_update"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prep_update"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE test_prep_update(col1 tinyint,\ + rc= mysql_query(mysql, "CREATE TABLE test_prep_update(col1 tinyint, \ col2 varchar(50), col3 varchar(30))"); myquery(rc); - strmov(query,"UPDATE test_prep_update SET col1=10, col2='venu1' WHERE col3='test'"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "UPDATE test_prep_update SET col1=10, col2='venu1' WHERE col3='test'"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,0); + verify_param_count(stmt, 0); result= mysql_param_result(stmt); mytest_r(result); mysql_stmt_close(stmt); - strmov(query,"UPDATE test_prep_update SET col1=?, col2='venu' WHERE col3=?"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "UPDATE test_prep_update SET col1=?, col2='venu' WHERE col3=?"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,2); + verify_param_count(stmt, 2); result= mysql_param_result(stmt); mytest(result); @@ -4532,15 +4356,15 @@ static void test_update_meta() mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); - assert(strcmp(field->name,"col1")==0); - assert(strcmp(field->table,"test_prep_update")==0); + assert(strcmp(field->name, "col1") == 0); + assert(strcmp(field->table, "test_prep_update") == 0); field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col3"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); - assert(strcmp(field->name,"col3")==0); - assert(strcmp(field->table,"test_prep_update")==0); + assert(strcmp(field->name, "col3") == 0); + assert(strcmp(field->table, "test_prep_update") == 0); field= mysql_fetch_field(result); mytest_r(field); @@ -4549,7 +4373,9 @@ static void test_update_meta() mysql_stmt_close(stmt); } + /* Select meta info .. */ + static void test_select_meta() { MYSQL_STMT *stmt; @@ -4559,33 +4385,30 @@ static void test_select_meta() myheader("test_select_meta"); - rc = mysql_autocommit(mysql, TRUE); - myquery(rc); - - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prep_select"); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prep_select"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_prep_select(col1 tinyint,\ + rc= mysql_query(mysql, "CREATE TABLE test_prep_select(col1 tinyint, \ col2 varchar(50), col3 varchar(30))"); myquery(rc); - strmov(query,"SELECT * FROM test_prep_select WHERE col1=10"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "SELECT * FROM test_prep_select WHERE col1=10"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,0); + verify_param_count(stmt, 0); result= mysql_param_result(stmt); mytest_r(result); - strmov(query,"SELECT col1, col3 from test_prep_select WHERE col1=? AND col3='test' AND col2= ?"); - stmt = mysql_simple_prepare(mysql, query); + strmov(query, "SELECT col1, col3 from test_prep_select WHERE col1=? AND col3='test' AND col2= ?"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - verify_param_count(stmt,2); + verify_param_count(stmt, 2); result= mysql_param_result(stmt); mytest(result); @@ -4597,15 +4420,15 @@ static void test_select_meta() mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); - assert(strcmp(field->name,"col1")==0); - assert(strcmp(field->table,"test_prep_select")==0); + assert(strcmp(field->name, "col1") == 0); + assert(strcmp(field->table, "test_prep_select") == 0); field= mysql_fetch_field(result); mytest(field); fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col2"); fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); - assert(strcmp(field->name,"col2")==0); - assert(strcmp(field->table,"test_prep_select")==0); + assert(strcmp(field->name, "col2") == 0); + assert(strcmp(field->table, "test_prep_select") == 0); field= mysql_fetch_field(result); mytest_r(field); @@ -4617,6 +4440,7 @@ static void test_select_meta() /* Test FUNCTION field info / DATE_FORMAT() table_name . */ + static void test_func_fields() { int rc; @@ -4625,71 +4449,68 @@ static void test_func_fields() myheader("test_func_fields"); - rc = mysql_autocommit(mysql, TRUE); + rc= mysql_autocommit(mysql, TRUE); myquery(rc); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_dateformat"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_dateformat"); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE test_dateformat(id int, \ + rc= mysql_query(mysql, "CREATE TABLE test_dateformat(id int, \ ts timestamp)"); myquery(rc); - rc = mysql_query(mysql, "INSERT INTO test_dateformat(id) values(10)"); + rc= mysql_query(mysql, "INSERT INTO test_dateformat(id) values(10)"); myquery(rc); - rc = mysql_query(mysql, "SELECT ts FROM test_dateformat"); + rc= mysql_query(mysql, "SELECT ts FROM test_dateformat"); myquery(rc); - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); - field = mysql_fetch_field(result); + field= mysql_fetch_field(result); mytest(field); - fprintf(stdout,"\n table name: `%s` (expected: `%s`)", field->table, + fprintf(stdout, "\n table name: `%s` (expected: `%s`)", field->table, "test_dateformat"); - assert(strcmp(field->table, "test_dateformat")==0); + assert(strcmp(field->table, "test_dateformat") == 0); - field = mysql_fetch_field(result); + field= mysql_fetch_field(result); mytest_r(field); /* no more fields */ mysql_free_result(result); /* DATE_FORMAT */ - rc = mysql_query(mysql, "SELECT DATE_FORMAT(ts,'%Y') AS 'venu' FROM test_dateformat"); + rc= mysql_query(mysql, "SELECT DATE_FORMAT(ts, '%Y') AS 'venu' FROM test_dateformat"); myquery(rc); - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); - field = mysql_fetch_field(result); + field= mysql_fetch_field(result); 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'); - field = mysql_fetch_field(result); + field= mysql_fetch_field(result); mytest_r(field); /* no more fields */ mysql_free_result(result); /* FIELD ALIAS TEST */ - rc = mysql_query(mysql, "SELECT DATE_FORMAT(ts,'%Y') AS 'YEAR' FROM test_dateformat"); + rc= mysql_query(mysql, "SELECT DATE_FORMAT(ts, '%Y') AS 'YEAR' FROM test_dateformat"); myquery(rc); - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); - field = mysql_fetch_field(result); + field= mysql_fetch_field(result); mytest(field); - fprintf(stdout,"\n field name: `%s` (expected: `%s`)", field->name, "YEAR"); - fprintf(stdout,"\n field org name: `%s` (expected: `%s`)",field->org_name,""); - assert(strcmp(field->name, "YEAR")==0); + fprintf(stdout, "\n field name: `%s` (expected: `%s`)", field->name, "YEAR"); + fprintf(stdout, "\n field org name: `%s` (expected: `%s`)", field->org_name, ""); + assert(strcmp(field->name, "YEAR") == 0); assert(field->org_name[0] == '\0'); - field = mysql_fetch_field(result); + field= mysql_fetch_field(result); mytest_r(field); /* no more fields */ mysql_free_result(result); @@ -4697,6 +4518,7 @@ static void test_func_fields() /* Multiple stmts .. */ + static void test_multi_stmt() { @@ -4708,98 +4530,106 @@ static void test_multi_stmt() my_bool is_null[2]; myheader("test_multi_stmt"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_multi_table"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_multi_table"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_multi_table(id int, name char(20))"); + rc= mysql_query(mysql, "CREATE TABLE test_multi_table(id int, name char(20))"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_multi_table values(10,'mysql')"); + rc= mysql_query(mysql, "INSERT INTO test_multi_table values(10, 'mysql')"); myquery(rc); - stmt = mysql_simple_prepare(mysql, "SELECT * FROM test_multi_table WHERE id = ?"); + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_multi_table " + "WHERE id= ?"); check_stmt(stmt); - stmt2 = mysql_simple_prepare(mysql, "UPDATE test_multi_table SET name='updated' WHERE id=10"); + stmt2= mysql_simple_prepare(mysql, "UPDATE test_multi_table " + "SET name='updated' WHERE id=10"); check_stmt(stmt2); - verify_param_count(stmt,1); + verify_param_count(stmt, 1); + + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); bind[0].buffer_type= MYSQL_TYPE_SHORT; bind[0].buffer= (char *)&id; bind[0].is_null= &is_null[0]; - bind[0].buffer_length= 0; bind[0].length= &length[0]; is_null[0]= 0; length[0]= 0; - bind[1].buffer_type = MYSQL_TYPE_STRING; - bind[1].buffer = (char *)name; + bind[1].buffer_type= MYSQL_TYPE_STRING; + bind[1].buffer= (char *)name; bind[1].buffer_length= sizeof(name); - bind[1].length = &length[1]; + bind[1].length= &length[1]; bind[1].is_null= &is_null[1]; - - rc = mysql_bind_param(stmt, bind); + + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - - rc = mysql_bind_result(stmt, bind); + + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - id = 10; - rc = mysql_execute(stmt); + id= 10; + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - - id = 999; - rc = mysql_fetch(stmt); + + id= 999; + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); fprintf(stdout, "\n int_data: %d(%lu)", id, length[0]); fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); assert(id == 10); - assert(strcmp(name,"mysql")==0); + assert(strcmp(name, "mysql") == 0); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); /* alter the table schema now */ - stmt1 = mysql_simple_prepare(mysql,"DELETE FROM test_multi_table WHERE id = ? AND name=?"); + stmt1= mysql_simple_prepare(mysql, "DELETE FROM test_multi_table " + "WHERE id= ? AND name=?"); check_stmt(stmt1); - verify_param_count(stmt1,2); + verify_param_count(stmt1, 2); - rc = mysql_bind_param(stmt1, bind); + rc= mysql_stmt_bind_param(stmt1, bind); check_execute(stmt1, rc); - - rc = mysql_execute(stmt2); + + rc= mysql_stmt_execute(stmt2); check_execute(stmt2, rc); verify_st_affected_rows(stmt2, 1); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - - rc = mysql_fetch(stmt); + + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); fprintf(stdout, "\n int_data: %d(%lu)", id, length[0]); fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); assert(id == 10); - assert(strcmp(name,"updated")==0); + assert(strcmp(name, "updated") == 0); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); - rc = mysql_execute(stmt1); + rc= mysql_stmt_execute(stmt1); check_execute(stmt1, rc); verify_st_affected_rows(stmt1, 1); mysql_stmt_close(stmt1); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); assert(0 == my_stmt_result("SELECT * FROM test_multi_table")); @@ -4810,9 +4640,8 @@ static void test_multi_stmt() } -/******************************************************** -* to test simple sample - manual * -*********************************************************/ +/* Test simple sample - manual */ + static void test_manual_sample() { unsigned int param_count; @@ -4827,29 +4656,29 @@ static void test_manual_sample() myheader("test_manual_sample"); /* - Sample which is incorporated directly in the manual under Prepared - statements section (Example from mysql_execute() + Sample which is incorporated directly in the manual under Prepared + statements section (Example from mysql_stmt_execute() */ mysql_autocommit(mysql, 1); - if (mysql_query(mysql,"DROP TABLE IF EXISTS test_table")) + if (mysql_query(mysql, "DROP TABLE IF EXISTS test_table")) { fprintf(stderr, "\n drop table failed"); fprintf(stderr, "\n %s", mysql_error(mysql)); exit(0); } - if (mysql_query(mysql,"CREATE TABLE test_table(col1 int, col2 varchar(50), \ - col3 smallint,\ + if (mysql_query(mysql, "CREATE TABLE test_table(col1 int, col2 varchar(50), \ + col3 smallint, \ col4 timestamp(14))")) { fprintf(stderr, "\n create table failed"); fprintf(stderr, "\n %s", mysql_error(mysql)); exit(0); } - + /* Prepare a insert query with 3 parameters */ - strmov(query, "INSERT INTO test_table(col1,col2,col3) values(?,?,?)"); - if (!(stmt = mysql_simple_prepare(mysql,query))) + strmov(query, "INSERT INTO test_table(col1, col2, col3) values(?, ?, ?)"); + if (!(stmt= mysql_simple_prepare(mysql, query))) { fprintf(stderr, "\n prepare, insert failed"); fprintf(stderr, "\n %s", mysql_error(mysql)); @@ -4858,7 +4687,7 @@ static void test_manual_sample() fprintf(stdout, "\n prepare, insert successful"); /* Get the parameter count from the statement */ - param_count= mysql_param_count(stmt); + param_count= mysql_stmt_param_count(stmt); fprintf(stdout, "\n total parameters in insert: %d", param_count); if (param_count != 3) /* validate parameter count */ @@ -4869,28 +4698,29 @@ static void test_manual_sample() /* Bind the data for the parameters */ + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); + /* INTEGER PART */ bind[0].buffer_type= MYSQL_TYPE_LONG; bind[0].buffer= (char *)&int_data; - bind[0].is_null= 0; - bind[0].length= 0; /* STRING PART */ bind[1].buffer_type= MYSQL_TYPE_VAR_STRING; bind[1].buffer= (char *)str_data; bind[1].buffer_length= sizeof(str_data); - bind[1].is_null= 0; - bind[1].length= 0; - + /* SMALLINT PART */ bind[2].buffer_type= MYSQL_TYPE_SHORT; - bind[2].buffer= (char *)&small_data; + bind[2].buffer= (char *)&small_data; bind[2].is_null= &is_null; - bind[2].length= 0; is_null= 0; /* Bind the buffers */ - if (mysql_bind_param(stmt, bind)) + if (mysql_stmt_bind_param(stmt, bind)) { fprintf(stderr, "\n param bind failed"); fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); @@ -4899,20 +4729,20 @@ static void test_manual_sample() /* Specify the data */ int_data= 10; /* integer */ - strmov(str_data,"MySQL"); /* string */ - + strmov(str_data, "MySQL"); /* string */ + /* INSERT SMALLINT data as NULL */ is_null= 1; /* Execute the insert statement - 1*/ - if (mysql_execute(stmt)) + if (mysql_stmt_execute(stmt)) { fprintf(stderr, "\n execute 1 failed"); fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); exit(0); } - - /* Get the total rows affected */ + + /* Get the total rows affected */ affected_rows= mysql_stmt_affected_rows(stmt); fprintf(stdout, "\n total affected rows: %lld", affected_rows); @@ -4923,20 +4753,20 @@ static void test_manual_sample() } /* Re-execute the insert, by changing the values */ - int_data= 1000; - strmov(str_data,"The most popular open source database"); + int_data= 1000; + strmov(str_data, "The most popular open source database"); small_data= 1000; /* smallint */ is_null= 0; /* reset */ /* Execute the insert statement - 2*/ - if (mysql_execute(stmt)) + if (mysql_stmt_execute(stmt)) { fprintf(stderr, "\n execute 2 failed"); fprintf(stderr, "\n %s", mysql_stmt_error(stmt)); exit(0); } - - /* Get the total rows affected */ + + /* Get the total rows affected */ affected_rows= mysql_stmt_affected_rows(stmt); fprintf(stdout, "\n total affected rows: %lld", affected_rows); @@ -4956,7 +4786,7 @@ static void test_manual_sample() assert(2 == my_stmt_result("SELECT * FROM test_table")); /* DROP THE TABLE */ - if (mysql_query(mysql,"DROP TABLE test_table")) + if (mysql_query(mysql, "DROP TABLE test_table")) { fprintf(stderr, "\n drop table failed"); fprintf(stderr, "\n %s", mysql_error(mysql)); @@ -4966,9 +4796,8 @@ static void test_manual_sample() } -/******************************************************** -* to test alter table scenario in the middle of prepare * -*********************************************************/ +/* Test alter table scenario in the middle of prepare */ + static void test_prepare_alter() { MYSQL_STMT *stmt; @@ -4979,39 +4808,44 @@ static void test_prepare_alter() myheader("test_prepare_alter"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_prep_alter"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prep_alter"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_prep_alter(id int, name char(20))"); + rc= mysql_query(mysql, "CREATE TABLE test_prep_alter(id int, name char(20))"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_prep_alter values(10,'venu'),(20,'mysql')"); + rc= mysql_query(mysql, "INSERT INTO test_prep_alter values(10, 'venu'), (20, 'mysql')"); myquery(rc); - stmt = mysql_simple_prepare(mysql, "INSERT INTO test_prep_alter VALUES(?,'monty')"); + stmt= mysql_simple_prepare(mysql, "INSERT INTO test_prep_alter VALUES(?, 'monty')"); check_stmt(stmt); - verify_param_count(stmt,1); + verify_param_count(stmt, 1); + + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); is_null= 0; bind[0].buffer_type= MYSQL_TYPE_SHORT; bind[0].buffer= (char *)&id; - bind[0].buffer_length= 0; - bind[0].length= 0; bind[0].is_null= &is_null; - rc = mysql_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - - id = 30; length= 0; - rc = mysql_execute(stmt); + + id= 30; + length= 0; + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); if (thread_query((char *)"ALTER TABLE test_prep_alter change id id_new varchar(20)")) exit(0); - is_null=1; - rc = mysql_execute(stmt); + is_null= 1; + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(4 == my_stmt_result("SELECT * FROM test_prep_alter")); @@ -5019,9 +4853,8 @@ static void test_prepare_alter() mysql_stmt_close(stmt); } -/******************************************************** -* to test the support of multi-statement executions * -*********************************************************/ + +/* Test the support of multi-statement executions */ static void test_multi_statements() { @@ -5029,11 +4862,11 @@ static void test_multi_statements() MYSQL_RES *result; int rc; - const char *query="\ + const char *query= "\ DROP TABLE IF EXISTS test_multi_tab;\ -CREATE TABLE test_multi_tab(id int,name char(20));\ -INSERT INTO test_multi_tab(id) VALUES(10),(20);\ -INSERT INTO test_multi_tab VALUES(20,'insert;comma');\ +CREATE TABLE test_multi_tab(id int, name char(20));\ +INSERT INTO test_multi_tab(id) VALUES(10), (20);\ +INSERT INTO test_multi_tab VALUES(20, 'insert;comma');\ SELECT * FROM test_multi_tab;\ UPDATE test_multi_tab SET name='new;name' WHERE id=20;\ DELETE FROM test_multi_tab WHERE name='new;name';\ @@ -5052,64 +4885,64 @@ DROP TABLE IF EXISTS test_multi_tab"; First test that we get an error for multi statements (Becasue default connection is not opened with CLIENT_MULTI_STATEMENTS) */ - rc = mysql_query(mysql, query); /* syntax error */ + rc= mysql_query(mysql, query); /* syntax error */ myquery_r(rc); assert(-1 == mysql_next_result(mysql)); assert(0 == mysql_more_results(mysql)); - if (!(mysql_local = mysql_init(NULL))) - { - fprintf(stdout,"\n mysql_init() failed"); + if (!(mysql_local= mysql_init(NULL))) + { + fprintf(stdout, "\n mysql_init() failed"); exit(1); } /* Create connection that supprot multi statements */ - if (!(mysql_real_connect(mysql_local,opt_host,opt_user, - opt_password, current_db, opt_port, - opt_unix_socket, CLIENT_MULTI_STATEMENTS))) + if (!(mysql_real_connect(mysql_local, opt_host, opt_user, + opt_password, current_db, opt_port, + opt_unix_socket, CLIENT_MULTI_STATEMENTS))) { - fprintf(stdout,"\n connection failed(%s)", mysql_error(mysql_local)); + fprintf(stdout, "\n connection failed(%s)", mysql_error(mysql_local)); exit(1); } - rc = mysql_query(mysql_local, query); + rc= mysql_query(mysql_local, query); myquery(rc); - for (count=0 ; count < array_elements(rows) ; count++) + for (count= 0 ; count < array_elements(rows) ; count++) { - fprintf(stdout,"\n Query %d: ", count); + fprintf(stdout, "\n Query %d: ", count); if ((result= mysql_store_result(mysql_local))) { my_process_result_set(result); mysql_free_result(result); } else - fprintf(stdout,"OK, %lld row(s) affected, %d warning(s)\n", - mysql_affected_rows(mysql_local), - mysql_warning_count(mysql_local)); + fprintf(stdout, "OK, %lld row(s) affected, %d warning(s)\n", + mysql_affected_rows(mysql_local), + mysql_warning_count(mysql_local)); exp_value= (uint) mysql_affected_rows(mysql_local); if (rows[count] != exp_value) { fprintf(stdout, "row %d had affected rows: %d, should be %d\n", - count, exp_value, rows[count]); + count, exp_value, rows[count]); exit(1); } if (count != array_elements(rows) -1) { if (!(rc= mysql_more_results(mysql_local))) { - fprintf(stdout, - "mysql_more_result returned wrong value: %d for row %d\n", - rc, count); - exit(1); + fprintf(stdout, + "mysql_more_result returned wrong value: %d for row %d\n", + rc, count); + exit(1); } if ((rc= mysql_next_result(mysql_local))) { - exp_value= mysql_errno(mysql_local); + exp_value= mysql_errno(mysql_local); - exit(1); + exit(1); } } else @@ -5148,38 +4981,40 @@ DROP TABLE IF EXISTS test_multi_tab"; mysql_close(mysql_local); } -/******************************************************** -* Check that Prepared statement cannot contain several * -* SQL statements * -*********************************************************/ + +/* + Check that Prepared statement cannot contain several + SQL statements +*/ + static void test_prepare_multi_statements() { MYSQL *mysql_local; MYSQL_STMT *stmt; myheader("test_prepare_multi_statements"); - if (!(mysql_local = mysql_init(NULL))) - { - fprintf(stdout,"\n mysql_init() failed"); + if (!(mysql_local= mysql_init(NULL))) + { + fprintf(stdout, "\n mysql_init() failed"); exit(1); } - if (!(mysql_real_connect(mysql_local,opt_host,opt_user, + if (!(mysql_real_connect(mysql_local, opt_host, opt_user, opt_password, current_db, opt_port, opt_unix_socket, CLIENT_MULTI_STATEMENTS))) { - fprintf(stdout,"\n connection failed(%s)", mysql_error(mysql_local)); + fprintf(stdout, "\n connection failed(%s)", mysql_error(mysql_local)); exit(1); } strmov(query, "select 1; select 'another value'"); - stmt = mysql_simple_prepare(mysql_local,query); + stmt= mysql_simple_prepare(mysql_local, query); check_stmt_r(stmt); mysql_close(mysql_local); } -/******************************************************** -* to test simple bind store result * -*********************************************************/ + +/* Test simple bind store result */ + static void test_store_result() { MYSQL_STMT *stmt; @@ -5187,129 +5022,122 @@ static void test_store_result() long nData; char szData[100]; MYSQL_BIND bind[2]; - ulong length, length1; + ulong length, length1; my_bool is_null[2]; myheader("test_store_result"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_store_result"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_store_result"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_store_result(col1 int ,col2 varchar(50))"); + rc= mysql_query(mysql, "CREATE TABLE test_store_result(col1 int , col2 varchar(50))"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "INSERT INTO test_store_result VALUES(10, 'venu'), (20, 'mysql')"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_store_result VALUES(10,'venu'),(20,'mysql')"); + rc= mysql_query(mysql, "INSERT INTO test_store_result(col2) VALUES('monty')"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_store_result(col2) VALUES('monty')"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* fetch */ - bind[0].buffer_type=FIELD_TYPE_LONG; - bind[0].buffer= (char*) &nData; /* integer data */ + bind[0].buffer_type= MYSQL_TYPE_LONG; + bind[0].buffer= (char*) &nData; /* integer data */ bind[0].length= &length; bind[0].is_null= &is_null[0]; - length= 0; - bind[1].buffer_type=FIELD_TYPE_STRING; - bind[1].buffer=szData; /* string data */ - bind[1].buffer_length=sizeof(szData); + length= 0; + bind[1].buffer_type= MYSQL_TYPE_STRING; + bind[1].buffer= szData; /* string data */ + bind[1].buffer_length= sizeof(szData); bind[1].length= &length1; bind[1].is_null= &is_null[1]; length1= 0; - stmt = mysql_simple_prepare(mysql, "SELECT * FROM test_store_result"); + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_store_result"); check_stmt(stmt); - rc = mysql_bind_result(stmt,bind); + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_stmt_store_result(stmt); + rc= mysql_stmt_store_result(stmt); check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - fprintf(stdout,"\n row 1: %ld,%s(%lu)", nData, szData, length1); + fprintf(stdout, "\n row 1: %ld, %s(%lu)", nData, szData, length1); assert(nData == 10); - assert(strcmp(szData,"venu")==0); + assert(strcmp(szData, "venu") == 0); assert(length1 == 4); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - fprintf(stdout,"\n row 2: %ld,%s(%lu)",nData, szData, length1); + fprintf(stdout, "\n row 2: %ld, %s(%lu)", nData, szData, length1); assert(nData == 20); - assert(strcmp(szData,"mysql")==0); + assert(strcmp(szData, "mysql") == 0); assert(length1 == 5); - length=99; - rc = mysql_fetch(stmt); - check_execute(stmt,rc); - + length= 99; + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); + 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]); - assert(strcmp(szData,"monty")==0); + assert(strcmp(szData, "monty") == 0); assert(length1 == 5); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); - - rc = mysql_execute(stmt); + + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_stmt_store_result(stmt); + rc= mysql_stmt_store_result(stmt); check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - fprintf(stdout,"\n row 1: %ld,%s(%lu)",nData, szData, length1); + fprintf(stdout, "\n row 1: %ld, %s(%lu)", nData, szData, length1); assert(nData == 10); - assert(strcmp(szData,"venu")==0); + assert(strcmp(szData, "venu") == 0); assert(length1 == 4); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - fprintf(stdout,"\n row 2: %ld,%s(%lu)",nData, szData, length1); + fprintf(stdout, "\n row 2: %ld, %s(%lu)", nData, szData, length1); assert(nData == 20); - assert(strcmp(szData,"mysql")==0); + assert(strcmp(szData, "mysql") == 0); assert(length1 == 5); - length=99; - rc = mysql_fetch(stmt); - check_execute(stmt,rc); - + length= 99; + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); + 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]); - assert(strcmp(szData,"monty")==0); + assert(strcmp(szData, "monty") == 0); assert(length1 == 5); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } -/******************************************************** -* to test simple bind store result * -*********************************************************/ +/* Test simple bind store result */ + static void test_store_result1() { MYSQL_STMT *stmt; @@ -5317,50 +5145,44 @@ static void test_store_result1() myheader("test_store_result1"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_store_result"); - myquery(rc); - - rc = mysql_commit(mysql); - myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE test_store_result(col1 int ,col2 varchar(50))"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_store_result"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_store_result(col1 int , col2 varchar(50))"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_store_result VALUES(10,'venu'),(20,'mysql')"); + rc= mysql_query(mysql, "INSERT INTO test_store_result VALUES(10, 'venu'), (20, 'mysql')"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_store_result(col2) VALUES('monty')"); + rc= mysql_query(mysql, "INSERT INTO test_store_result(col2) VALUES('monty')"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); - stmt = mysql_simple_prepare(mysql,"SELECT * FROM test_store_result"); + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_store_result"); check_stmt(stmt); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_stmt_store_result(stmt); + rc= mysql_stmt_store_result(stmt); check_execute(stmt, rc); - rc = 0; - while (mysql_fetch(stmt) != MYSQL_NO_DATA) + rc= 0; + while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) rc++; fprintf(stdout, "\n total rows: %d", rc); assert(rc == 3); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_stmt_store_result(stmt); + rc= mysql_stmt_store_result(stmt); check_execute(stmt, rc); - rc = 0; - while (mysql_fetch(stmt) != MYSQL_NO_DATA) + rc= 0; + while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) rc++; fprintf(stdout, "\n total rows: %d", rc); assert(rc == 3); @@ -5369,9 +5191,8 @@ static void test_store_result1() } -/******************************************************** -* to test simple bind store result * -*********************************************************/ +/* Another test for bind and store result */ + static void test_store_result2() { MYSQL_STMT *stmt; @@ -5382,85 +5203,83 @@ static void test_store_result2() myheader("test_store_result2"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_store_result"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_store_result"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_store_result(col1 int ,col2 varchar(50))"); + rc= mysql_query(mysql, "CREATE TABLE test_store_result(col1 int , col2 varchar(50))"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "INSERT INTO test_store_result VALUES(10, 'venu'), (20, 'mysql')"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_store_result VALUES(10,'venu'),(20,'mysql')"); + rc= mysql_query(mysql, "INSERT INTO test_store_result(col2) VALUES('monty')"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_store_result(col2) VALUES('monty')"); + rc= mysql_commit(mysql); myquery(rc); - rc = mysql_commit(mysql); - myquery(rc); + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type=FIELD_TYPE_LONG; - bind[0].buffer= (char *) &nData; /* integer data */ + bind[0].buffer_type= MYSQL_TYPE_LONG; + bind[0].buffer= (char *) &nData; /* integer data */ bind[0].length= &length; bind[0].is_null= 0; strmov((char *)query , "SELECT col1 FROM test_store_result where col1= ?"); - stmt = mysql_simple_prepare(mysql, query); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_bind_result(stmt,bind); + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - - nData = 10; length= 0; - rc = mysql_execute(stmt); + + nData= 10; length= 0; + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - nData = 0; - rc = mysql_stmt_store_result(stmt); + nData= 0; + rc= mysql_stmt_store_result(stmt); check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - fprintf(stdout,"\n row 1: %d",nData); + fprintf(stdout, "\n row 1: %d", nData); assert(nData == 10); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); - nData = 20; - rc = mysql_execute(stmt); + nData= 20; + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - nData = 0; - rc = mysql_stmt_store_result(stmt); + nData= 0; + rc= mysql_stmt_store_result(stmt); check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - fprintf(stdout,"\n row 1: %d",nData); + fprintf(stdout, "\n row 1: %d", nData); assert(nData == 20); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } -/******************************************************** -* to test simple subselect prepare * -*********************************************************/ +/* Test simple subselect prepare */ + static void test_subselect() { -#if TO_BE_FIXED_IN_SERVER MYSQL_STMT *stmt; int rc, id; @@ -5468,56 +5287,56 @@ static void test_subselect() myheader("test_subselect"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_sub1"); - myquery(rc); - - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_sub2"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_sub1"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_sub2"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_sub1(id int)"); + rc= mysql_query(mysql, "CREATE TABLE test_sub1(id int)"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_sub2(id int, id1 int)"); + rc= mysql_query(mysql, "CREATE TABLE test_sub2(id int, id1 int)"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "INSERT INTO test_sub1 values(2)"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_sub1 values(2)"); + rc= mysql_query(mysql, "INSERT INTO test_sub2 VALUES(1, 7), (2, 7)"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_sub2 VALUES(1,7),(2,7)"); - myquery(rc); - - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); /* fetch */ - bind[0].buffer_type= FIELD_TYPE_LONG; - bind[0].buffer= (char *) &id; + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); + + bind[0].buffer_type= MYSQL_TYPE_LONG; + bind[0].buffer= (char *) &id; bind[0].length= 0; bind[0].is_null= 0; - stmt = mysql_simple_prepare(mysql, "INSERT INTO test_sub2(id) SELECT * FROM test_sub1 WHERE id=?", 100); + stmt= mysql_simple_prepare(mysql, "INSERT INTO test_sub2(id) SELECT * FROM test_sub1 WHERE id= ?"); check_stmt(stmt); - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_bind_result(stmt,bind); + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - id = 2; - rc = mysql_execute(stmt); + id= 2; + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); verify_st_affected_rows(stmt, 1); - id = 9; - rc = mysql_execute(stmt); + id= 9; + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); verify_st_affected_rows(stmt, 0); @@ -5526,101 +5345,108 @@ static void test_subselect() assert(3 == my_stmt_result("SELECT * FROM test_sub2")); - strmov((char *)query , "SELECT ROW(1,7) IN (select id, id1 from test_sub2 WHERE id1=?)"); - assert(1 == my_stmt_result("SELECT ROW(1,7) IN (select id, id1 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)")); + strmov((char *)query , "SELECT ROW(1, 7) IN (select id, id1 from test_sub2 WHERE id1= ?)"); + assert(1 == my_stmt_result("SELECT ROW(1, 7) IN (select id, id1 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)")); - stmt = mysql_simple_prepare(mysql, query, 150); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - rc = mysql_bind_param(stmt,bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_bind_result(stmt,bind); + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - id = 7; - rc = mysql_execute(stmt); + id= 7; + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - fprintf(stdout,"\n row 1: %d",id); + fprintf(stdout, "\n row 1: %d", id); assert(id == 1); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); - + id= 8; - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - fprintf(stdout,"\n row 1: %d",id); + fprintf(stdout, "\n row 1: %d", id); assert(id == 0); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); -#endif } + /* Generalized conversion routine to handle DATE, TIME and DATETIME conversion using MYSQL_TIME structure */ + static void test_bind_date_conv(uint row_count) -{ +{ MYSQL_STMT *stmt= 0; uint rc, i, count= row_count; - ulong length[4]; + ulong length[4]; MYSQL_BIND bind[4]; - my_bool is_null[4]={0}; - MYSQL_TIME tm[4]; + my_bool is_null[4]= {0}; + MYSQL_TIME tm[4]; ulong second_part; uint year, month, day, hour, minute, sec; - stmt = mysql_simple_prepare(mysql,"INSERT INTO test_date VALUES(?,?,?,?)"); + stmt= mysql_simple_prepare(mysql, "INSERT INTO test_date VALUES(?, ?, ?, ?)"); check_stmt(stmt); - verify_param_count(stmt, 4); + verify_param_count(stmt, 4); + + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); bind[0].buffer_type= MYSQL_TYPE_TIMESTAMP; bind[1].buffer_type= MYSQL_TYPE_TIME; bind[2].buffer_type= MYSQL_TYPE_DATETIME; bind[3].buffer_type= MYSQL_TYPE_DATE; - - second_part= 0; - - year=2000; - month=01; - day=10; - - hour=11; - minute=16; - sec= 20; for (i= 0; i < (int) array_elements(bind); i++) - { + { bind[i].buffer= (char *) &tm[i]; bind[i].is_null= &is_null[i]; bind[i].length= &length[i]; bind[i].buffer_length= 30; - length[i]=20; - } + length[i]= 20; + } + + second_part= 0; + + year= 2000; + month= 01; + day= 10; + + hour= 11; + minute= 16; + sec= 20; + + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); - rc = mysql_bind_param(stmt, bind); - check_execute(stmt,rc); - for (count= 0; count < row_count; count++) - { + { for (i= 0; i < (int) array_elements(bind); i++) { - tm[i].neg= 0; + tm[i].neg= 0; tm[i].second_part= second_part+count; if (bind[i].buffer_type != MYSQL_TYPE_TIME) { @@ -5637,51 +5463,51 @@ static void test_bind_date_conv(uint row_count) tm[i].second= sec+count; } else - tm[i].hour= tm[i].minute= tm[i].second = 0; - } - rc = mysql_execute(stmt); - check_execute(stmt, rc); + tm[i].hour= tm[i].minute= tm[i].second= 0; + } + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); } - rc = mysql_commit(mysql); + rc= mysql_commit(mysql); myquery(rc); mysql_stmt_close(stmt); assert(row_count == my_stmt_result("SELECT * FROM test_date")); - stmt = mysql_simple_prepare(mysql,"SELECT * FROM test_date"); + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_date"); myquery(rc); - rc = mysql_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_stmt_store_result(stmt); + rc= mysql_stmt_store_result(stmt); check_execute(stmt, rc); - for (count=0; count < row_count; count++) + for (count= 0; count < row_count; count++) { - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); fprintf(stdout, "\n"); for (i= 0; i < array_elements(bind); i++) - { + { fprintf(stdout, "\n"); - fprintf(stdout," time[%d]: %02d-%02d-%02d %02d:%02d:%02d.%02lu", - i, tm[i].year, tm[i].month, tm[i].day, + fprintf(stdout, " time[%d]: %02d-%02d-%02d %02d:%02d:%02d.%02lu", + i, tm[i].year, tm[i].month, tm[i].day, 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); assert(tm[i].month == 0 || tm[i].month == month+count); assert(tm[i].day == 0 || tm[i].day == day+count); assert(tm[i].hour == 0 || tm[i].hour == hour+count); - /* + /* minute causes problems from date<->time, don't assert, instead validate separatly in another routine */ @@ -5691,15 +5517,14 @@ static void test_bind_date_conv(uint row_count) assert(tm[i].second_part == 0 || tm[i].second_part == second_part+count); } } - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } -/* - Test DATE, TIME, DATETIME and TS with MYSQL_TIME conversion -*/ + +/* Test DATE, TIME, DATETIME and TS with MYSQL_TIME conversion */ static void test_date() { @@ -5707,25 +5532,21 @@ static void test_date() myheader("test_date"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_date"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_date"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE test_date(c1 TIMESTAMP(14), \ - c2 TIME,\ - c3 DATETIME,\ - c4 DATE)"); - myquery(rc); + rc= mysql_query(mysql, "CREATE TABLE test_date(c1 TIMESTAMP(14), \ + c2 TIME, \ + c3 DATETIME, \ + c4 DATE)"); - rc = mysql_commit(mysql); myquery(rc); test_bind_date_conv(5); } -/* - Test all time types to DATE and DATE to all types -*/ + +/* Test all time types to DATE and DATE to all types */ static void test_date_date() { @@ -5733,25 +5554,21 @@ static void test_date_date() myheader("test_date_date"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_date"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_date"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE test_date(c1 DATE, \ - c2 DATE,\ - c3 DATE,\ - c4 DATE)"); - myquery(rc); + rc= mysql_query(mysql, "CREATE TABLE test_date(c1 DATE, \ + c2 DATE, \ + c3 DATE, \ + c4 DATE)"); - rc = mysql_commit(mysql); myquery(rc); test_bind_date_conv(3); } -/* - Test all time types to TIME and TIME to all types -*/ + +/* Test all time types to TIME and TIME to all types */ static void test_date_time() { @@ -5759,25 +5576,21 @@ static void test_date_time() myheader("test_date_time"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_date"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_date"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE test_date(c1 TIME, \ - c2 TIME,\ - c3 TIME,\ - c4 TIME)"); - myquery(rc); + rc= mysql_query(mysql, "CREATE TABLE test_date(c1 TIME, \ + c2 TIME, \ + c3 TIME, \ + c4 TIME)"); - rc = mysql_commit(mysql); myquery(rc); test_bind_date_conv(3); } -/* - Test all time types to TIMESTAMP and TIMESTAMP to all types -*/ + +/* Test all time types to TIMESTAMP and TIMESTAMP to all types */ static void test_date_ts() { @@ -5785,129 +5598,123 @@ static void test_date_ts() myheader("test_date_ts"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_date"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_date"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE test_date(c1 TIMESTAMP(10), \ - c2 TIMESTAMP(14),\ - c3 TIMESTAMP,\ - c4 TIMESTAMP(6))"); - myquery(rc); + rc= mysql_query(mysql, "CREATE TABLE test_date(c1 TIMESTAMP(10), \ + c2 TIMESTAMP(14), \ + c3 TIMESTAMP, \ + c4 TIMESTAMP(6))"); - rc = mysql_commit(mysql); myquery(rc); test_bind_date_conv(2); } -/* - Test all time types to DATETIME and DATETIME to all types -*/ + +/* Test all time types to DATETIME and DATETIME to all types */ static void test_date_dt() { - int rc; + int rc; myheader("test_date_dt"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_date"); - myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE test_date(c1 datetime, \ - c2 datetime,\ - c3 datetime,\ - c4 date)"); - + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_date"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_date(c1 datetime, " + " c2 datetime, c3 datetime, c4 date)"); myquery(rc); test_bind_date_conv(2); } -/* - Misc tests to keep pure coverage happy -*/ + +/* Misc tests to keep pure coverage happy */ + static void test_pure_coverage() { MYSQL_STMT *stmt; MYSQL_BIND bind[1]; int rc; ulong length; - + myheader("test_pure_coverage"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_pure"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_pure"); myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE test_pure(c1 int, c2 varchar(20))"); + + rc= mysql_query(mysql, "CREATE TABLE test_pure(c1 int, c2 varchar(20))"); myquery(rc); - stmt = mysql_simple_prepare(mysql,"insert into test_pure(c67788) values(10)"); + stmt= mysql_simple_prepare(mysql, "insert into test_pure(c67788) values(10)"); check_stmt_r(stmt); - + /* Query without params and result should allow to bind 0 arrays */ - stmt = mysql_simple_prepare(mysql,"insert into test_pure(c2) values(10)"); + stmt= mysql_simple_prepare(mysql, "insert into test_pure(c2) values(10)"); check_stmt(stmt); - - rc = mysql_bind_param(stmt, (MYSQL_BIND*)0); + + rc= mysql_stmt_bind_param(stmt, (MYSQL_BIND*)0); check_execute(stmt, rc); - - rc = mysql_execute(stmt); + + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_bind_result(stmt, (MYSQL_BIND*)0); + rc= mysql_stmt_bind_result(stmt, (MYSQL_BIND*)0); check_execute(stmt, rc); - + mysql_stmt_close(stmt); - stmt = mysql_simple_prepare(mysql,"insert into test_pure(c2) values(?)"); + stmt= mysql_simple_prepare(mysql, "insert into test_pure(c2) values(?)"); check_stmt(stmt); + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); + bind[0].length= &length; bind[0].is_null= 0; bind[0].buffer_length= 0; bind[0].buffer_type= MYSQL_TYPE_GEOMETRY; - rc = mysql_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute_r(stmt, rc); /* unsupported buffer type */ - + bind[0].buffer_type= MYSQL_TYPE_STRING; - rc = mysql_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_stmt_store_result(stmt); - check_execute(stmt, rc); + rc= mysql_stmt_store_result(stmt); + check_execute(stmt, rc); mysql_stmt_close(stmt); - stmt = mysql_simple_prepare(mysql,"select * from test_pure"); + stmt= mysql_simple_prepare(mysql, "select * from test_pure"); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); bind[0].buffer_type= MYSQL_TYPE_GEOMETRY; - rc = mysql_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, bind); check_execute_r(stmt, rc); /* unsupported buffer type */ - rc = mysql_stmt_store_result(stmt); + rc= mysql_stmt_store_result(stmt); check_execute(stmt, rc); - - rc = mysql_stmt_store_result(stmt); + + rc= mysql_stmt_store_result(stmt); check_execute_r(stmt, rc); /* commands out of sync */ mysql_stmt_close(stmt); - mysql_query(mysql,"DROP TABLE test_pure"); - mysql_commit(mysql); + mysql_query(mysql, "DROP TABLE test_pure"); } -/* - test for string buffer fetch -*/ + +/* Test for string buffer fetch */ static void test_buffers() { @@ -5917,132 +5724,132 @@ static void test_buffers() ulong length; my_bool is_null; char buffer[20]; - + myheader("test_buffers"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_buffer"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_buffer"); myquery(rc); - - rc = mysql_query(mysql,"CREATE TABLE test_buffer(str varchar(20))"); + + rc= mysql_query(mysql, "CREATE TABLE test_buffer(str varchar(20))"); myquery(rc); - rc = mysql_query(mysql,"insert into test_buffer values('MySQL')\ - ,('Database'),('Open-Source'),('Popular')"); + rc= mysql_query(mysql, "insert into test_buffer values('MySQL')\ + , ('Database'), ('Open-Source'), ('Popular')"); myquery(rc); - - stmt = mysql_simple_prepare(mysql,"select str from test_buffer"); + + stmt= mysql_simple_prepare(mysql, "select str from test_buffer"); check_stmt(stmt); - - rc = mysql_execute(stmt); + + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - bzero(buffer, 20); /* Avoid overruns in printf() */ + bzero(buffer, 20); /* Avoid overruns in printf() */ bind[0].length= &length; bind[0].is_null= &is_null; bind[0].buffer_length= 1; bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer= (char *)buffer; - - rc = mysql_bind_result(stmt, bind); + + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - rc = mysql_stmt_store_result(stmt); + rc= mysql_stmt_store_result(stmt); check_execute(stmt, rc); - buffer[1]='X'; - rc = mysql_fetch(stmt); + buffer[1]= 'X'; + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); assert(buffer[0] == 'M'); assert(buffer[1] == 'X'); assert(length == 5); - bind[0].buffer_length=8; - rc = mysql_bind_result(stmt, bind);/* re-bind */ + bind[0].buffer_length= 8; + rc= mysql_stmt_bind_result(stmt, bind);/* re-bind */ check_execute(stmt, rc); - - rc = mysql_fetch(stmt); + + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - assert(strncmp(buffer,"Database",8) == 0); + assert(strncmp(buffer, "Database", 8) == 0); assert(length == 8); - - bind[0].buffer_length=12; - rc = mysql_bind_result(stmt, bind);/* re-bind */ + + bind[0].buffer_length= 12; + rc= mysql_stmt_bind_result(stmt, bind);/* re-bind */ check_execute(stmt, rc); - - rc = mysql_fetch(stmt); + + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - assert(strcmp(buffer,"Open-Source") == 0); + assert(strcmp(buffer, "Open-Source") == 0); assert(length == 11); - - bind[0].buffer_length=6; - rc = mysql_bind_result(stmt, bind);/* re-bind */ + + bind[0].buffer_length= 6; + rc= mysql_stmt_bind_result(stmt, bind);/* re-bind */ check_execute(stmt, rc); - - rc = mysql_fetch(stmt); + + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); fprintf(stdout, "\n data: %s (%lu)", buffer, length); - assert(strncmp(buffer,"Popula",6) == 0); + assert(strncmp(buffer, "Popula", 6) == 0); assert(length == 7); - + mysql_stmt_close(stmt); } -/* - Test the direct query execution in the middle of open stmts -*/ + +/* Test the direct query execution in the middle of open stmts */ + static void test_open_direct() { MYSQL_STMT *stmt; MYSQL_RES *result; int rc; - + myheader("test_open_direct"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_open_direct"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_open_direct"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_open_direct(id int, name char(6))"); + rc= mysql_query(mysql, "CREATE TABLE test_open_direct(id int, name char(6))"); myquery(rc); - stmt = mysql_simple_prepare(mysql,"INSERT INTO test_open_direct values(10,'mysql')"); + stmt= mysql_simple_prepare(mysql, "INSERT INTO test_open_direct values(10, 'mysql')"); check_stmt(stmt); - rc = mysql_query(mysql, "SELECT * FROM test_open_direct"); + rc= mysql_query(mysql, "SELECT * FROM test_open_direct"); myquery(rc); - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert(0 == my_process_result_set(result)); mysql_free_result(result); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); verify_st_affected_rows(stmt, 1); - - rc = mysql_query(mysql, "SELECT * FROM test_open_direct"); + + rc= mysql_query(mysql, "SELECT * FROM test_open_direct"); myquery(rc); - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert(1 == my_process_result_set(result)); mysql_free_result(result); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); verify_st_affected_rows(stmt, 1); - - rc = mysql_query(mysql, "SELECT * FROM test_open_direct"); + + rc= mysql_query(mysql, "SELECT * FROM test_open_direct"); myquery(rc); - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert(2 == my_process_result_set(result)); @@ -6051,47 +5858,47 @@ static void test_open_direct() mysql_stmt_close(stmt); /* run a direct query in the middle of a fetch */ - stmt= mysql_simple_prepare(mysql,"SELECT * FROM test_open_direct"); + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_open_direct"); check_stmt(stmt); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - rc = mysql_query(mysql,"INSERT INTO test_open_direct(id) VALUES(20)"); + rc= mysql_query(mysql, "INSERT INTO test_open_direct(id) VALUES(20)"); myquery_r(rc); - rc = mysql_stmt_close(stmt); + rc= mysql_stmt_close(stmt); check_execute(stmt, rc); - rc = mysql_query(mysql,"INSERT INTO test_open_direct(id) VALUES(20)"); + rc= mysql_query(mysql, "INSERT INTO test_open_direct(id) VALUES(20)"); myquery(rc); /* run a direct query with store result */ - stmt= mysql_simple_prepare(mysql,"SELECT * FROM test_open_direct"); + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_open_direct"); check_stmt(stmt); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_stmt_store_result(stmt); + rc= mysql_stmt_store_result(stmt); check_execute(stmt, rc); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - rc = mysql_query(mysql,"drop table test_open_direct"); + rc= mysql_query(mysql, "drop table test_open_direct"); myquery(rc); - rc = mysql_stmt_close(stmt); + rc= mysql_stmt_close(stmt); check_execute(stmt, rc); } -/* - To test fetch without prior bound buffers -*/ + +/* Test fetch without prior bound buffers */ + static void test_fetch_nobuffs() { MYSQL_STMT *stmt; @@ -6101,15 +5908,15 @@ static void test_fetch_nobuffs() myheader("test_fetch_nobuffs"); - stmt = mysql_simple_prepare(mysql,"SELECT DATABASE(), CURRENT_USER(), \ + stmt= mysql_simple_prepare(mysql, "SELECT DATABASE(), CURRENT_USER(), \ CURRENT_DATE(), CURRENT_TIME()"); check_stmt(stmt); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = 0; - while (mysql_fetch(stmt) != MYSQL_NO_DATA) + rc= 0; + while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) rc++; fprintf(stdout, "\n total rows : %d", rc); @@ -6125,14 +5932,14 @@ static void test_fetch_nobuffs() bind[2].buffer= (char *)str[2]; bind[3].buffer= (char *)str[3]; - rc = mysql_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = 0; - while (mysql_fetch(stmt) != MYSQL_NO_DATA) + rc= 0; + while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) { rc++; fprintf(stdout, "\n CURRENT_DATABASE(): %s", str[0]); @@ -6146,9 +5953,9 @@ static void test_fetch_nobuffs() mysql_stmt_close(stmt); } -/* - To test a misc bug -*/ + +/* Test a misc bug */ + static void test_ushort_bug() { MYSQL_STMT *stmt; @@ -6162,30 +5969,30 @@ static void test_ushort_bug() myheader("test_ushort_bug"); - rc= mysql_query(mysql,"DROP TABLE IF EXISTS test_ushort"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_ushort"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE test_ushort(a smallint unsigned, \ + + rc= mysql_query(mysql, "CREATE TABLE test_ushort(a smallint unsigned, \ b smallint unsigned, \ c smallint unsigned, \ d smallint unsigned)"); myquery(rc); - - rc= mysql_query(mysql,"INSERT INTO test_ushort VALUES(35999, 35999, 35999, 200)"); + + rc= mysql_query(mysql, "INSERT INTO test_ushort VALUES(35999, 35999, 35999, 200)"); myquery(rc); - - - stmt = mysql_simple_prepare(mysql,"SELECT * FROM test_ushort"); + + + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_ushort"); check_stmt(stmt); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); bind[0].buffer_type= MYSQL_TYPE_SHORT; bind[0].buffer= (char *)&short_value; bind[0].is_null= 0; bind[0].length= &s_length; - + bind[1].buffer_type= MYSQL_TYPE_LONG; bind[1].buffer= (char *)&long_value; bind[1].is_null= 0; @@ -6195,26 +6002,26 @@ static void test_ushort_bug() bind[2].buffer= (char *)&longlong_value; bind[2].is_null= 0; bind[2].length= &ll_length; - + bind[3].buffer_type= MYSQL_TYPE_TINY; bind[3].buffer= (char *)&tiny_value; bind[3].is_null= 0; bind[3].length= &t_length; - - rc = mysql_bind_result(stmt, bind); + + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - - fprintf(stdout,"\n ushort : %d (%ld)", short_value, s_length); - fprintf(stdout,"\n ulong : %ld (%ld)", long_value, l_length); - fprintf(stdout,"\n longlong : %lld (%ld)", longlong_value, ll_length); - fprintf(stdout,"\n tinyint : %d (%ld)", tiny_value, t_length); - + + fprintf(stdout, "\n ushort : %d (%ld)", short_value, s_length); + fprintf(stdout, "\n ulong : %ld (%ld)", long_value, l_length); + fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); + fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); + assert(short_value == 35999); assert(s_length == 2); - + assert(long_value == 35999); assert(l_length == 4); @@ -6223,16 +6030,16 @@ static void test_ushort_bug() assert(tiny_value == 200); assert(t_length == 1); - - rc = mysql_fetch(stmt); + + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } -/* - To test a misc smallint-signed conversion bug -*/ + +/* Test a misc smallint-signed conversion bug */ + static void test_sshort_bug() { MYSQL_STMT *stmt; @@ -6246,30 +6053,30 @@ static void test_sshort_bug() myheader("test_sshort_bug"); - rc= mysql_query(mysql,"DROP TABLE IF EXISTS test_sshort"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_sshort"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE test_sshort(a smallint signed, \ + + rc= mysql_query(mysql, "CREATE TABLE test_sshort(a smallint signed, \ b smallint signed, \ c smallint unsigned, \ d smallint unsigned)"); myquery(rc); - - rc= mysql_query(mysql,"INSERT INTO test_sshort VALUES(-5999, -5999, 35999, 200)"); + + rc= mysql_query(mysql, "INSERT INTO test_sshort VALUES(-5999, -5999, 35999, 200)"); myquery(rc); - - - stmt = mysql_simple_prepare(mysql,"SELECT * FROM test_sshort"); + + + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_sshort"); check_stmt(stmt); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); bind[0].buffer_type= MYSQL_TYPE_SHORT; bind[0].buffer= (char *)&short_value; bind[0].is_null= 0; bind[0].length= &s_length; - + bind[1].buffer_type= MYSQL_TYPE_LONG; bind[1].buffer= (char *)&long_value; bind[1].is_null= 0; @@ -6279,26 +6086,26 @@ static void test_sshort_bug() bind[2].buffer= (char *)&longlong_value; bind[2].is_null= 0; bind[2].length= &ll_length; - + bind[3].buffer_type= MYSQL_TYPE_TINY; bind[3].buffer= (char *)&tiny_value; bind[3].is_null= 0; bind[3].length= &t_length; - - rc = mysql_bind_result(stmt, bind); + + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - - fprintf(stdout,"\n sshort : %d (%ld)", short_value, s_length); - fprintf(stdout,"\n slong : %ld (%ld)", long_value, l_length); - fprintf(stdout,"\n longlong : %lld (%ld)", longlong_value, ll_length); - fprintf(stdout,"\n tinyint : %d (%ld)", tiny_value, t_length); - + + fprintf(stdout, "\n sshort : %d (%ld)", short_value, s_length); + fprintf(stdout, "\n slong : %ld (%ld)", long_value, l_length); + fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); + fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); + assert(short_value == -5999); assert(s_length == 2); - + assert(long_value == -5999); assert(l_length == 4); @@ -6307,16 +6114,16 @@ static void test_sshort_bug() assert(tiny_value == 200); assert(t_length == 1); - - rc = mysql_fetch(stmt); + + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } -/* - To test a misc tinyint-signed conversion bug -*/ + +/* Test a misc tinyint-signed conversion bug */ + static void test_stiny_bug() { MYSQL_STMT *stmt; @@ -6330,30 +6137,30 @@ static void test_stiny_bug() myheader("test_stiny_bug"); - rc= mysql_query(mysql,"DROP TABLE IF EXISTS test_stiny"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_stiny"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE test_stiny(a tinyint signed, \ + + rc= mysql_query(mysql, "CREATE TABLE test_stiny(a tinyint signed, \ b tinyint signed, \ c tinyint unsigned, \ d tinyint unsigned)"); myquery(rc); - - rc= mysql_query(mysql,"INSERT INTO test_stiny VALUES(-128, -127, 255, 0)"); + + rc= mysql_query(mysql, "INSERT INTO test_stiny VALUES(-128, -127, 255, 0)"); myquery(rc); - - - stmt = mysql_simple_prepare(mysql,"SELECT * FROM test_stiny"); + + + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_stiny"); check_stmt(stmt); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); bind[0].buffer_type= MYSQL_TYPE_SHORT; bind[0].buffer= (char *)&short_value; bind[0].is_null= 0; bind[0].length= &s_length; - + bind[1].buffer_type= MYSQL_TYPE_LONG; bind[1].buffer= (char *)&long_value; bind[1].is_null= 0; @@ -6363,26 +6170,26 @@ static void test_stiny_bug() bind[2].buffer= (char *)&longlong_value; bind[2].is_null= 0; bind[2].length= &ll_length; - + bind[3].buffer_type= MYSQL_TYPE_TINY; bind[3].buffer= (char *)&tiny_value; bind[3].is_null= 0; bind[3].length= &t_length; - - rc = mysql_bind_result(stmt, bind); + + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - - fprintf(stdout,"\n sshort : %d (%ld)", short_value, s_length); - fprintf(stdout,"\n slong : %ld (%ld)", long_value, l_length); - fprintf(stdout,"\n longlong : %lld (%ld)", longlong_value, ll_length); - fprintf(stdout,"\n tinyint : %d (%ld)", tiny_value, t_length); - + + fprintf(stdout, "\n sshort : %d (%ld)", short_value, s_length); + fprintf(stdout, "\n slong : %ld (%ld)", long_value, l_length); + fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); + fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); + assert(short_value == -128); assert(s_length == 2); - + assert(long_value == -127); assert(l_length == 4); @@ -6391,16 +6198,16 @@ static void test_stiny_bug() assert(tiny_value == 0); assert(t_length == 1); - - rc = mysql_fetch(stmt); + + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } -/******************************************************** -* to test misc field information, bug: #74 * -*********************************************************/ + +/* Test misc field information, bug: #74 */ + static void test_field_misc() { MYSQL_STMT *stmt; @@ -6412,47 +6219,47 @@ static void test_field_misc() myheader("test_field_misc"); - rc = mysql_query(mysql,"SELECT @@autocommit"); + rc= mysql_query(mysql, "SELECT @@autocommit"); myquery(rc); - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert(1 == my_process_result_set(result)); - - verify_prepare_field(result,0, - "@@autocommit","", /* field and its org name */ + + verify_prepare_field(result, 0, + "@@autocommit", "", /* field and its org name */ MYSQL_TYPE_LONGLONG, /* field type */ "", "", /* 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); - - stmt = mysql_simple_prepare(mysql,"SELECT @@autocommit"); + + stmt= mysql_simple_prepare(mysql, "SELECT @@autocommit"); check_stmt(stmt); - - rc = mysql_execute(stmt); - check_execute(stmt,rc); - result = mysql_get_metadata(stmt); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + result= mysql_stmt_result_metadata(stmt); mytest(result); - + assert(1 == my_process_stmt_result(stmt)); - - verify_prepare_field(result,0, - "@@autocommit","", /* field and its org name */ + + verify_prepare_field(result, 0, + "@@autocommit", "", /* field and its org name */ MYSQL_TYPE_LONGLONG, /* field type */ "", "", /* 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_stmt_close(stmt); - stmt = mysql_simple_prepare(mysql, "SELECT @@table_type"); + stmt= mysql_simple_prepare(mysql, "SELECT @@table_type"); check_stmt(stmt); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer= table_type; @@ -6460,94 +6267,95 @@ static void test_field_misc() bind[0].is_null= 0; bind[0].buffer_length= NAME_LEN; - rc = mysql_bind_result(stmt, bind); - check_execute(stmt,rc); + rc= mysql_stmt_bind_result(stmt, bind); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); - fprintf(stdout,"\n default table type: %s(%ld)", table_type, type_length); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); + fprintf(stdout, "\n default table type: %s(%ld)", table_type, type_length); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); - stmt = mysql_simple_prepare(mysql, "SELECT @@table_type"); + stmt= mysql_simple_prepare(mysql, "SELECT @@table_type"); check_stmt(stmt); - result = mysql_get_metadata(stmt); + result= mysql_stmt_result_metadata(stmt); mytest(result); + assert(mysql_stmt_field_count(stmt) == mysql_num_fields(result)); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); assert(1 == my_process_stmt_result(stmt)); - - verify_prepare_field(result,0, - "@@table_type","", /* field and its org name */ + + verify_prepare_field(result, 0, + "@@table_type", "", /* field and its org name */ MYSQL_TYPE_STRING, /* field type */ "", "", /* table and its org name */ - "",type_length*3,0); /* db name, length */ + "", type_length*3, 0); /* db name, length */ mysql_free_result(result); mysql_stmt_close(stmt); - stmt = mysql_simple_prepare(mysql, "SELECT @@max_error_count"); + stmt= mysql_simple_prepare(mysql, "SELECT @@max_error_count"); check_stmt(stmt); - result = mysql_get_metadata(stmt); + result= mysql_stmt_result_metadata(stmt); mytest(result); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); assert(1 == my_process_stmt_result(stmt)); - - verify_prepare_field(result,0, - "@@max_error_count","", /* field and its org name */ + + verify_prepare_field(result, 0, + "@@max_error_count", "", /* field and its org name */ MYSQL_TYPE_LONGLONG, /* field type */ "", "", /* table and its org name */ - "",10,0); /* db name, length */ + "", 10, 0); /* db name, length */ mysql_free_result(result); mysql_stmt_close(stmt); - - stmt = mysql_simple_prepare(mysql, "SELECT @@max_allowed_packet"); + + stmt= mysql_simple_prepare(mysql, "SELECT @@max_allowed_packet"); check_stmt(stmt); - result = mysql_get_metadata(stmt); + result= mysql_stmt_result_metadata(stmt); mytest(result); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); assert(1 == my_process_stmt_result(stmt)); - - verify_prepare_field(result,0, - "@@max_allowed_packet","", /* field and its org name */ + + verify_prepare_field(result, 0, + "@@max_allowed_packet", "", /* field and its org name */ MYSQL_TYPE_LONGLONG, /* field type */ "", "", /* table and its org name */ - "",10,0); /* db name, length */ + "", 10, 0); /* db name, length */ mysql_free_result(result); mysql_stmt_close(stmt); - - stmt = mysql_simple_prepare(mysql, "SELECT @@sql_warnings"); + + stmt= mysql_simple_prepare(mysql, "SELECT @@sql_warnings"); check_stmt(stmt); - - result = mysql_get_metadata(stmt); + + result= mysql_stmt_result_metadata(stmt); mytest(result); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); assert(1 == my_process_stmt_result(stmt)); - - verify_prepare_field(result,0, - "@@sql_warnings","", /* field and its org name */ + + verify_prepare_field(result, 0, + "@@sql_warnings", "", /* field and its org name */ MYSQL_TYPE_LONGLONG, /* field type */ "", "", /* table and its org name */ - "",1,0); /* db name, length */ + "", 1, 0); /* db name, length */ mysql_free_result(result); mysql_stmt_close(stmt); @@ -6555,9 +6363,10 @@ static void test_field_misc() /* - To test SET OPTION feature with prepare stmts + Test SET OPTION feature with prepare stmts bug #85 (reported by mark@mysql.com) */ + static void test_set_option() { MYSQL_STMT *stmt; @@ -6569,60 +6378,62 @@ static void test_set_option() mysql_autocommit(mysql, TRUE); /* LIMIT the rows count to 2 */ - rc= mysql_query(mysql,"SET OPTION SQL_SELECT_LIMIT=2"); + rc= mysql_query(mysql, "SET OPTION SQL_SELECT_LIMIT= 2"); myquery(rc); - rc= mysql_query(mysql,"DROP TABLE IF EXISTS test_limit"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_limit"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE test_limit(a tinyint)"); + + rc= mysql_query(mysql, "CREATE TABLE test_limit(a tinyint)"); myquery(rc); - - rc= mysql_query(mysql,"INSERT INTO test_limit VALUES(10),(20),(30),(40)"); - myquery(rc); - - fprintf(stdout,"\n with SQL_SELECT_LIMIT=2 (direct)"); - rc = mysql_query(mysql,"SELECT * FROM test_limit"); + + rc= mysql_query(mysql, "INSERT INTO test_limit VALUES(10), (20), (30), (40)"); + myquery(rc); + + fprintf(stdout, "\n with SQL_SELECT_LIMIT= 2 (direct)"); + rc= mysql_query(mysql, "SELECT * FROM test_limit"); myquery(rc); - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert(2 == my_process_result_set(result)); mysql_free_result(result); - - fprintf(stdout,"\n with SQL_SELECT_LIMIT=2 (prepare)"); - stmt = mysql_simple_prepare(mysql, "SELECT * FROM test_limit"); + + fprintf(stdout, "\n with SQL_SELECT_LIMIT=2 (prepare)"); + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_limit"); check_stmt(stmt); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); assert(2 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); - /* RESET the LIMIT the rows count to 0 */ - fprintf(stdout,"\n with SQL_SELECT_LIMIT=DEFAULT (prepare)"); - rc= mysql_query(mysql,"SET OPTION SQL_SELECT_LIMIT=DEFAULT"); + /* RESET the LIMIT the rows count to 0 */ + fprintf(stdout, "\n with SQL_SELECT_LIMIT=DEFAULT (prepare)"); + rc= mysql_query(mysql, "SET OPTION SQL_SELECT_LIMIT=DEFAULT"); myquery(rc); - - stmt = mysql_simple_prepare(mysql, "SELECT * FROM test_limit"); + + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_limit"); check_stmt(stmt); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); assert(4 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } + /* - To test a misc GRANT option + Test a misc GRANT option bug #89 (reported by mark@mysql.com) */ + static void test_prepare_grant() { int rc; @@ -6631,80 +6442,80 @@ static void test_prepare_grant() mysql_autocommit(mysql, TRUE); - rc= mysql_query(mysql,"DROP TABLE IF EXISTS test_grant"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_grant"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE test_grant(a tinyint primary key auto_increment)"); + + rc= mysql_query(mysql, "CREATE TABLE test_grant(a tinyint primary key auto_increment)"); myquery(rc); - strxmov(query,"GRANT INSERT,UPDATE,SELECT ON ", current_db, + strxmov(query, "GRANT INSERT, UPDATE, SELECT ON ", current_db, ".test_grant TO 'test_grant'@", opt_host ? opt_host : "'localhost'", NullS); - if (mysql_query(mysql,query)) + if (mysql_query(mysql, query)) { myerror("GRANT failed"); - - /* + + /* If server started with --skip-grant-tables, skip this test, else exit to indicate an error - ER_UNKNOWN_COM_ERROR = 1047 - */ - if (mysql_errno(mysql) != 1047) - exit(0); + ER_UNKNOWN_COM_ERROR= 1047 + */ + if (mysql_errno(mysql) != 1047) + exit(0); } else { MYSQL *org_mysql= mysql, *lmysql; MYSQL_STMT *stmt; - + fprintf(stdout, "\n Establishing a test connection ..."); - if (!(lmysql = mysql_init(NULL))) - { + if (!(lmysql= mysql_init(NULL))) + { myerror("mysql_init() failed"); exit(0); } - if (!(mysql_real_connect(lmysql,opt_host,"test_grant", - "", current_db, opt_port, - opt_unix_socket, 0))) + if (!(mysql_real_connect(lmysql, opt_host, "test_grant", + "", current_db, opt_port, + opt_unix_socket, 0))) { - myerror("connection failed"); + myerror("connection failed"); mysql_close(lmysql); exit(0); - } - fprintf(stdout," OK"); + } + fprintf(stdout, " OK"); mysql= lmysql; - rc = mysql_query(mysql,"INSERT INTO test_grant VALUES(NULL)"); + rc= mysql_query(mysql, "INSERT INTO test_grant VALUES(NULL)"); myquery(rc); - rc = mysql_query(mysql,"INSERT INTO test_grant(a) VALUES(NULL)"); + rc= mysql_query(mysql, "INSERT INTO test_grant(a) VALUES(NULL)"); myquery(rc); - - execute_prepare_query("INSERT INTO test_grant(a) VALUES(NULL)",1); - execute_prepare_query("INSERT INTO test_grant VALUES(NULL)",1); - execute_prepare_query("UPDATE test_grant SET a=9 WHERE a=1",1); + + execute_prepare_query("INSERT INTO test_grant(a) VALUES(NULL)", 1); + execute_prepare_query("INSERT INTO test_grant VALUES(NULL)", 1); + execute_prepare_query("UPDATE test_grant SET a=9 WHERE a=1", 1); assert(4 == my_stmt_result("SELECT a FROM test_grant")); /* Both DELETE expected to fail as user does not have DELETE privs */ - rc = mysql_query(mysql,"DELETE FROM test_grant"); + rc= mysql_query(mysql, "DELETE FROM test_grant"); myquery_r(rc); - stmt= mysql_simple_prepare(mysql,"DELETE FROM test_grant"); + stmt= mysql_simple_prepare(mysql, "DELETE FROM test_grant"); check_stmt_r(stmt); - + assert(4 == my_stmt_result("SELECT * FROM test_grant")); - - mysql_close(lmysql); + + mysql_close(lmysql); 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); assert(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); assert(1 == mysql_affected_rows(mysql)); @@ -6713,10 +6524,11 @@ static void test_prepare_grant() /* - To test a crash when invalid/corrupted .frm is used in the + Test a crash when invalid/corrupted .frm is used in the SHOW TABLE STATUS bug #93 (reported by serg@mysql.com). */ + static void test_frm_bug() { MYSQL_STMT *stmt; @@ -6732,74 +6544,74 @@ static void test_frm_bug() mysql_autocommit(mysql, TRUE); - rc= mysql_query(mysql,"drop table if exists test_frm_bug"); + rc= mysql_query(mysql, "drop table if exists test_frm_bug"); myquery(rc); - rc= mysql_query(mysql,"flush tables"); + rc= mysql_query(mysql, "flush tables"); myquery(rc); - - stmt = mysql_simple_prepare(mysql, "show variables like 'datadir'"); + + stmt= mysql_simple_prepare(mysql, "show variables like 'datadir'"); check_stmt(stmt); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer= data_dir; bind[0].buffer_length= NAME_LEN; bind[0].is_null= 0; bind[0].length= 0; - bind[1]=bind[0]; + bind[1]= bind[0]; - rc = mysql_bind_result(stmt,bind); - check_execute(stmt,rc); + rc= mysql_stmt_bind_result(stmt, bind); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - fprintf(stdout,"\n data directory: %s", data_dir); + fprintf(stdout, "\n data directory: %s", data_dir); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(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); - fprintf(stdout,"\n test_frm: %s", test_frm); + fprintf(stdout, "\n test_frm: %s", test_frm); if (!(test_file= my_fopen(test_frm, (int) (O_RDWR | O_CREAT), MYF(MY_WME)))) { - fprintf(stdout,"\n ERROR: my_fopen failed for '%s'", test_frm); - fprintf(stdout,"\n test cancelled"); - return; + fprintf(stdout, "\n ERROR: my_fopen failed for '%s'", test_frm); + fprintf(stdout, "\n test cancelled"); + return; } - fprintf(test_file,"this is a junk file for test"); + fprintf(test_file, "this is a junk file for test"); - rc = mysql_query(mysql,"SHOW TABLE STATUS like 'test_frm_bug'"); + rc= mysql_query(mysql, "SHOW TABLE STATUS like 'test_frm_bug'"); myquery(rc); - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result);/* It can't be NULL */ assert(1 == my_process_result_set(result)); - mysql_data_seek(result,0); + mysql_data_seek(result, 0); row= mysql_fetch_row(result); mytest(row); - fprintf(stdout,"\n Comment: %s", row[16]); + fprintf(stdout, "\n Comment: %s", row[16]); assert(row[16] != 0); mysql_free_result(result); mysql_stmt_close(stmt); - my_fclose(test_file,MYF(0)); - mysql_query(mysql,"drop table if exists test_frm_bug"); + my_fclose(test_file, MYF(0)); + mysql_query(mysql, "drop table if exists test_frm_bug"); } -/* - To test DECIMAL conversion -*/ + +/* Test DECIMAL conversion */ + static void test_decimal_bug() { MYSQL_STMT *stmt; @@ -6812,94 +6624,96 @@ static void test_decimal_bug() mysql_autocommit(mysql, TRUE); - rc= mysql_query(mysql,"drop table if exists test_decimal_bug"); + rc= mysql_query(mysql, "drop table if exists test_decimal_bug"); myquery(rc); - - rc = mysql_query(mysql, "create table test_decimal_bug(c1 decimal(10,2))"); + + rc= mysql_query(mysql, "create table test_decimal_bug(c1 decimal(10, 2))"); myquery(rc); - - rc = mysql_query(mysql, "insert into test_decimal_bug value(8),(10.22),(5.61)"); + + rc= mysql_query(mysql, "insert into test_decimal_bug value(8), (10.22), (5.61)"); myquery(rc); - stmt = mysql_simple_prepare(mysql,"select c1 from test_decimal_bug where c1= ?"); + stmt= mysql_simple_prepare(mysql, "select c1 from test_decimal_bug where c1= ?"); check_stmt(stmt); + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); + bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer= (char *)data; bind[0].buffer_length= 25; bind[0].is_null= &is_null; - bind[0].length= 0; - is_null= 0; - rc = mysql_bind_param(stmt, bind); - check_execute(stmt,rc); + is_null= 0; + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); strcpy(data, "8.0"); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); - data[0]=0; - rc = mysql_bind_result(stmt, bind); - check_execute(stmt,rc); + data[0]= 0; + rc= mysql_stmt_bind_result(stmt, bind); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); fprintf(stdout, "\n data: %s", data); - assert(strcmp(data, "8.00")==0); + assert(strcmp(data, "8.00") == 0); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); strcpy(data, "5.61"); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); - data[0]=0; - rc = mysql_bind_result(stmt, bind); - check_execute(stmt,rc); + data[0]= 0; + rc= mysql_stmt_bind_result(stmt, bind); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); fprintf(stdout, "\n data: %s", data); - assert(strcmp(data, "5.61")==0); + assert(strcmp(data, "5.61") == 0); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); is_null= 1; - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); strcpy(data, "10.22"); is_null= 0; - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); - data[0]=0; - rc = mysql_bind_result(stmt, bind); - check_execute(stmt,rc); + data[0]= 0; + rc= mysql_stmt_bind_result(stmt, bind); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); fprintf(stdout, "\n data: %s", data); - assert(strcmp(data, "10.22")==0); + assert(strcmp(data, "10.22") == 0); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } -/* - To test EXPLAIN bug - bug #115 (reported by mark@mysql.com & georg@php.net). -*/ +/* Test EXPLAIN bug (#115, reported by mark@mysql.com & georg@php.net). */ static void test_explain_bug() { @@ -6909,94 +6723,94 @@ static void test_explain_bug() myheader("test_explain_bug"); - mysql_autocommit(mysql,TRUE); + mysql_autocommit(mysql, TRUE); - rc = mysql_query(mysql, "DROP TABLE IF EXISTS test_explain"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_explain"); myquery(rc); - - rc = mysql_query(mysql, "CREATE TABLE test_explain(id int, name char(2))"); + + rc= mysql_query(mysql, "CREATE TABLE test_explain(id int, name char(2))"); myquery(rc); - stmt = mysql_simple_prepare(mysql, "explain test_explain"); + stmt= mysql_simple_prepare(mysql, "explain test_explain"); check_stmt(stmt); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - assert( 2 == my_process_stmt_result(stmt)); + assert( 2 == my_process_stmt_result(stmt)); - result = mysql_get_metadata(stmt); + result= mysql_stmt_result_metadata(stmt); mytest(result); - fprintf(stdout, "\n total fields in the result: %d", + fprintf(stdout, "\n total fields in the result: %d", mysql_num_fields(result)); assert(6 == mysql_num_fields(result)); - verify_prepare_field(result,0,"Field","",MYSQL_TYPE_VAR_STRING, - "","","",NAME_LEN,0); + verify_prepare_field(result, 0, "Field", "", MYSQL_TYPE_VAR_STRING, + "", "", "", NAME_LEN, 0); - verify_prepare_field(result,1,"Type","",MYSQL_TYPE_VAR_STRING, - "","","",40,0); + verify_prepare_field(result, 1, "Type", "", MYSQL_TYPE_VAR_STRING, + "", "", "", 40, 0); - verify_prepare_field(result,2,"Null","",MYSQL_TYPE_VAR_STRING, - "","","",1,0); + verify_prepare_field(result, 2, "Null", "", MYSQL_TYPE_VAR_STRING, + "", "", "", 1, 0); - verify_prepare_field(result,3,"Key","",MYSQL_TYPE_VAR_STRING, - "","","",3,0); + verify_prepare_field(result, 3, "Key", "", MYSQL_TYPE_VAR_STRING, + "", "", "", 3, 0); - verify_prepare_field(result,4,"Default","",MYSQL_TYPE_VAR_STRING, - "","","",NAME_LEN,0); + verify_prepare_field(result, 4, "Default", "", MYSQL_TYPE_VAR_STRING, + "", "", "", NAME_LEN, 0); - verify_prepare_field(result,5,"Extra","",MYSQL_TYPE_VAR_STRING, - "","","",20,0); + verify_prepare_field(result, 5, "Extra", "", MYSQL_TYPE_VAR_STRING, + "", "", "", 20, 0); mysql_free_result(result); mysql_stmt_close(stmt); - - stmt = mysql_simple_prepare(mysql, "explain select id, name FROM test_explain"); + + stmt= mysql_simple_prepare(mysql, "explain select id, name FROM test_explain"); check_stmt(stmt); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - assert( 1 == my_process_stmt_result(stmt)); + assert( 1 == my_process_stmt_result(stmt)); - result = mysql_get_metadata(stmt); + result= mysql_stmt_result_metadata(stmt); mytest(result); - fprintf(stdout, "\n total fields in the result: %d", + fprintf(stdout, "\n total fields in the result: %d", mysql_num_fields(result)); assert(10 == mysql_num_fields(result)); - verify_prepare_field(result,0,"id","",MYSQL_TYPE_LONGLONG, - "","","",3,0); + verify_prepare_field(result, 0, "id", "", MYSQL_TYPE_LONGLONG, + "", "", "", 3, 0); - verify_prepare_field(result,1,"select_type","",MYSQL_TYPE_VAR_STRING, - "","","",19,0); + verify_prepare_field(result, 1, "select_type", "", MYSQL_TYPE_VAR_STRING, + "", "", "", 19, 0); - verify_prepare_field(result,2,"table","",MYSQL_TYPE_VAR_STRING, - "","","",NAME_LEN,0); + verify_prepare_field(result, 2, "table", "", MYSQL_TYPE_VAR_STRING, + "", "", "", NAME_LEN, 0); - verify_prepare_field(result,3,"type","",MYSQL_TYPE_VAR_STRING, - "","","",10,0); + verify_prepare_field(result, 3, "type", "", MYSQL_TYPE_VAR_STRING, + "", "", "", 10, 0); - verify_prepare_field(result,4,"possible_keys","",MYSQL_TYPE_VAR_STRING, - "","","",NAME_LEN*64,0); + verify_prepare_field(result, 4, "possible_keys", "", MYSQL_TYPE_VAR_STRING, + "", "", "", NAME_LEN*64, 0); - verify_prepare_field(result,5,"key","",MYSQL_TYPE_VAR_STRING, - "","","",NAME_LEN,0); + verify_prepare_field(result, 5, "key", "", MYSQL_TYPE_VAR_STRING, + "", "", "", NAME_LEN, 0); - verify_prepare_field(result,6,"key_len","",MYSQL_TYPE_LONGLONG, - "","","",3,0); + verify_prepare_field(result, 6, "key_len", "", MYSQL_TYPE_LONGLONG, + "", "", "", 3, 0); - verify_prepare_field(result,7,"ref","",MYSQL_TYPE_VAR_STRING, - "","","",NAME_LEN*16,0); + verify_prepare_field(result, 7, "ref", "", MYSQL_TYPE_VAR_STRING, + "", "", "", NAME_LEN*16, 0); - verify_prepare_field(result,8,"rows","",MYSQL_TYPE_LONGLONG, - "","","",10,0); + verify_prepare_field(result, 8, "rows", "", MYSQL_TYPE_LONGLONG, + "", "", "", 10, 0); - verify_prepare_field(result,9,"Extra","",MYSQL_TYPE_VAR_STRING, - "","","",255,0); + verify_prepare_field(result, 9, "Extra", "", MYSQL_TYPE_VAR_STRING, + "", "", "", 255, 0); mysql_free_result(result); mysql_stmt_close(stmt); @@ -7005,131 +6819,132 @@ static void test_explain_bug() #ifdef NOT_YET_WORKING /* - To test math functions - bug #148 (reported by salle@mysql.com). + Test math functions. + Bug #148 (reported by salle@mysql.com). */ #define myerrno(n) check_errcode(n) static void check_errcode(const unsigned int err) -{ +{ if (mysql->server_version) - fprintf(stdout,"\n [MySQL-%s]",mysql->server_version); + fprintf(stdout, "\n [MySQL-%s]", mysql->server_version); else - fprintf(stdout,"\n [MySQL]"); - fprintf(stdout,"[%d] %s\n",mysql_errno(mysql),mysql_error(mysql)); + fprintf(stdout, "\n [MySQL]"); + fprintf(stdout, "[%d] %s\n", mysql_errno(mysql), mysql_error(mysql)); assert(mysql_errno(mysql) == err); } + static void test_drop_temp() { int rc; myheader("test_drop_temp"); - rc= mysql_query(mysql,"DROP DATABASE IF EXISTS test_drop_temp_db"); + rc= mysql_query(mysql, "DROP DATABASE IF EXISTS test_drop_temp_db"); myquery(rc); - rc= mysql_query(mysql,"CREATE DATABASE test_drop_temp_db"); + rc= mysql_query(mysql, "CREATE DATABASE test_drop_temp_db"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE test_drop_temp_db.t1(c1 int, c2 char(1))"); + + rc= mysql_query(mysql, "CREATE TABLE test_drop_temp_db.t1(c1 int, c2 char(1))"); myquery(rc); - rc = mysql_query(mysql,"delete from mysql.db where Db='test_drop_temp_db'"); + rc= mysql_query(mysql, "delete from mysql.db where Db='test_drop_temp_db'"); myquery(rc); - rc = mysql_query(mysql,"delete from mysql.db where Db='test_drop_temp_db'"); + rc= mysql_query(mysql, "delete from mysql.db where Db='test_drop_temp_db'"); myquery(rc); - strxmov(query,"GRANT SELECT,USAGE,DROP ON test_drop_temp_db.* TO test_temp@", + strxmov(query, "GRANT SELECT, USAGE, DROP ON test_drop_temp_db.* TO test_temp@", opt_host ? opt_host : "localhost", NullS); - if (mysql_query(mysql,query)) + if (mysql_query(mysql, query)) { myerror("GRANT failed"); - - /* + + /* If server started with --skip-grant-tables, skip this test, else exit to indicate an error - ER_UNKNOWN_COM_ERROR = 1047 - */ - if (mysql_errno(mysql) != 1047) - exit(0); + ER_UNKNOWN_COM_ERROR= 1047 + */ + if (mysql_errno(mysql) != 1047) + exit(0); } else { MYSQL *org_mysql= mysql, *lmysql; - + fprintf(stdout, "\n Establishing a test connection ..."); - if (!(lmysql = mysql_init(NULL))) - { + if (!(lmysql= mysql_init(NULL))) + { myerror("mysql_init() failed"); exit(0); } - rc = mysql_query(mysql,"flush privileges"); + rc= mysql_query(mysql, "flush privileges"); myquery(rc); - if (!(mysql_real_connect(lmysql,opt_host ? opt_host : "localhost","test_temp", - "", "test_drop_temp_db", opt_port, - opt_unix_socket, 0))) + if (!(mysql_real_connect(lmysql, opt_host ? opt_host : "localhost", "test_temp", + "", "test_drop_temp_db", opt_port, + opt_unix_socket, 0))) { mysql= lmysql; - myerror("connection failed"); + myerror("connection failed"); mysql_close(lmysql); exit(0); - } - fprintf(stdout," OK"); + } + fprintf(stdout, " OK"); mysql= lmysql; - rc = mysql_query(mysql,"INSERT INTO t1 VALUES(10,'C')"); + rc= mysql_query(mysql, "INSERT INTO t1 VALUES(10, 'C')"); myerrno((uint)1142); - rc = mysql_query(mysql,"DROP TABLE t1"); + rc= mysql_query(mysql, "DROP TABLE t1"); myerrno((uint)1142); - + mysql= org_mysql; - rc= mysql_query(mysql,"CREATE TEMPORARY TABLE test_drop_temp_db.t1(c1 int)"); + rc= mysql_query(mysql, "CREATE TEMPORARY TABLE test_drop_temp_db.t1(c1 int)"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TEMPORARY TABLE test_drop_temp_db.t2 LIKE test_drop_temp_db.t1"); + + rc= mysql_query(mysql, "CREATE TEMPORARY TABLE test_drop_temp_db.t2 LIKE test_drop_temp_db.t1"); myquery(rc); mysql= lmysql; - rc = mysql_query(mysql,"DROP TABLE t1,t2"); + rc= mysql_query(mysql, "DROP TABLE t1, t2"); myquery_r(rc); - rc = mysql_query(mysql,"DROP TEMPORARY TABLE t1"); + rc= mysql_query(mysql, "DROP TEMPORARY TABLE t1"); myquery_r(rc); - rc = mysql_query(mysql,"DROP TEMPORARY TABLE t2"); + rc= mysql_query(mysql, "DROP TEMPORARY TABLE t2"); myquery_r(rc); - - mysql_close(lmysql); + + mysql_close(lmysql); mysql= org_mysql; - rc = mysql_query(mysql,"drop database test_drop_temp_db"); + rc= mysql_query(mysql, "drop database test_drop_temp_db"); myquery(rc); assert(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); assert(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); assert(1 == mysql_affected_rows(mysql)); } } #endif -/* - To test warnings for cuted rows -*/ + +/* Test warnings for cuted rows */ + static void test_cuted_rows() { int rc, count; @@ -7137,58 +6952,58 @@ static void test_cuted_rows() myheader("test_cuted_rows"); - mysql_query(mysql, "DROP TABLE if exists t1"); + mysql_query(mysql, "DROP TABLE if exists t1"); mysql_query(mysql, "DROP TABLE if exists t2"); - rc = mysql_query(mysql, "CREATE TABLE t1(c1 tinyint)"); + rc= mysql_query(mysql, "CREATE TABLE t1(c1 tinyint)"); myquery(rc); - rc = mysql_query(mysql, "CREATE TABLE t2(c1 int not null)"); + rc= mysql_query(mysql, "CREATE TABLE t2(c1 int not null)"); myquery(rc); - rc = mysql_query(mysql, "INSERT INTO t1 values(10),(NULL),(NULL)"); + rc= mysql_query(mysql, "INSERT INTO t1 values(10), (NULL), (NULL)"); myquery(rc); count= mysql_warning_count(mysql); fprintf(stdout, "\n total warnings: %d", count); assert(count == 0); - rc = mysql_query(mysql, "INSERT INTO t2 SELECT * FROM t1"); + rc= mysql_query(mysql, "INSERT INTO t2 SELECT * FROM t1"); myquery(rc); count= mysql_warning_count(mysql); fprintf(stdout, "\n total warnings: %d", count); assert(count == 2); - rc = mysql_query(mysql, "SHOW WARNINGS"); + rc= mysql_query(mysql, "SHOW WARNINGS"); myquery(rc); - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert(2 == my_process_result_set(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)"); myquery(rc); count= mysql_warning_count(mysql); fprintf(stdout, "\n total warnings: %d", count); assert(count == 2); - rc = mysql_query(mysql, "SHOW WARNINGS"); + rc= mysql_query(mysql, "SHOW WARNINGS"); myquery(rc); - result = mysql_store_result(mysql); + result= mysql_store_result(mysql); mytest(result); assert(2 == my_process_result_set(result)); mysql_free_result(result); } -/* - To test update/binary logs -*/ + +/* Test update/binary logs */ + static void test_logs() { MYSQL_STMT *stmt; @@ -7201,138 +7016,140 @@ static void test_logs() myheader("test_logs"); - rc = mysql_query(mysql, "DROP TABLE IF EXISTS test_logs"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_logs"); myquery(rc); - rc = mysql_query(mysql, "CREATE TABLE test_logs(id smallint, name varchar(20))"); + rc= mysql_query(mysql, "CREATE TABLE test_logs(id smallint, name varchar(20))"); myquery(rc); - length= (ulong)(strmov((char *)data,"INSERT INTO test_logs VALUES(?,?)") - data); - stmt = mysql_prepare(mysql, data, length); - check_stmt(stmt); - + strmov((char *)data, "INSERT INTO test_logs VALUES(?, ?)"); + stmt= mysql_simple_prepare(mysql, data); + check_stmt(stmt); + + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); + bind[0].buffer_type= MYSQL_TYPE_SHORT; bind[0].buffer= (char *)&id; - bind[0].is_null= 0; - bind[0].length= 0; - + bind[1].buffer_type= MYSQL_TYPE_STRING; bind[1].buffer= (char *)&data; - bind[1].is_null= 0; bind[1].buffer_length= 255; bind[1].length= &length; id= 9876; - length= (ulong)(strmov((char *)data,"MySQL - Open Source Database")- data); + length= (ulong)(strmov((char *)data, "MySQL - Open Source Database")- data); - rc = mysql_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); strmov((char *)data, "'"); length= 1; - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - + strmov((char *)data, "\""); length= 1; - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - + length= (ulong)(strmov((char *)data, "my\'sql\'")-data); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - + length= (ulong)(strmov((char *)data, "my\"sql\"")-data); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); mysql_stmt_close(stmt); - length= (ulong)(strmov((char *)data,"INSERT INTO test_logs VALUES(20,'mysql')") - data); - stmt = mysql_prepare(mysql, data, length); - check_stmt(stmt); + strmov((char *)data, "INSERT INTO test_logs VALUES(20, 'mysql')"); + stmt= mysql_simple_prepare(mysql, data); + check_stmt(stmt); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); mysql_stmt_close(stmt); - length= (ulong)(strmov((char *)data, "SELECT * FROM test_logs WHERE id=?") - data); - stmt = mysql_prepare(mysql, data, length); - check_stmt(stmt); + strmov((char *)data, "SELECT * FROM test_logs WHERE id=?"); + stmt= mysql_simple_prepare(mysql, data); + check_stmt(stmt); - rc = mysql_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); bind[1].buffer_length= 255; - rc = mysql_bind_result(stmt, bind); + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); fprintf(stdout, "\n id : %d", id); fprintf(stdout, "\n name : %s(%ld)", data, length); - assert(id == 9876); + assert(id == 9876); assert(length == 19); /* Due to VARCHAR(20) */ - assert(strcmp(data,"MySQL - Open Source")==0); + assert(strcmp(data, "MySQL - Open Source") == 0); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - + fprintf(stdout, "\n name : %s(%ld)", data, length); assert(length == 1); - assert(strcmp(data,"'")==0); + assert(strcmp(data, "'") == 0); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - + fprintf(stdout, "\n name : %s(%ld)", data, length); assert(length == 1); - assert(strcmp(data,"\"")==0); + assert(strcmp(data, "\"") == 0); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - + fprintf(stdout, "\n name : %s(%ld)", data, length); assert(length == 7); - assert(strcmp(data,"my\'sql\'")==0); + assert(strcmp(data, "my\'sql\'") == 0); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - + fprintf(stdout, "\n name : %s(%ld)", data, length); assert(length == 7); - /*assert(strcmp(data,"my\"sql\"")==0); */ + /*assert(strcmp(data, "my\"sql\"") == 0); */ - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); - rc = mysql_query(mysql,"DROP TABLE test_logs"); + rc= mysql_query(mysql, "DROP TABLE test_logs"); myquery(rc); } -/* - To test 'n' statements create and close -*/ + +/* Test 'n' statements create and close */ static void test_nstmts() { @@ -7340,69 +7157,71 @@ static void test_nstmts() char query[255]; int rc; static uint i, total_stmts= 2000; - long length; MYSQL_BIND bind[1]; myheader("test_nstmts"); - mysql_autocommit(mysql,TRUE); + mysql_autocommit(mysql, TRUE); - rc = mysql_query(mysql, "DROP TABLE IF EXISTS test_nstmts"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_nstmts"); myquery(rc); - - rc = mysql_query(mysql, "CREATE TABLE test_nstmts(id int)"); + + rc= mysql_query(mysql, "CREATE TABLE test_nstmts(id int)"); myquery(rc); + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); + bind[0].buffer= (char *)&i; bind[0].buffer_type= MYSQL_TYPE_LONG; - bind[0].length= 0; - bind[0].is_null= 0; - bind[0].buffer_length= 0; - - for (i=0; i < total_stmts; i++) + + for (i= 0; i < total_stmts; i++) { fprintf(stdout, "\r stmt: %d", i); - - length = (long)(strmov(query, "insert into test_nstmts values(?)")-query); - stmt = mysql_prepare(mysql, query, length); + + strmov(query, "insert into test_nstmts values(?)"); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - rc = mysql_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); mysql_stmt_close(stmt); } - stmt = mysql_simple_prepare(mysql," select count(*) from test_nstmts"); + stmt= mysql_simple_prepare(mysql, " select count(*) from test_nstmts"); check_stmt(stmt); - rc = mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - i = 0; - rc = mysql_bind_result(stmt, bind); + i= 0; + rc= mysql_stmt_bind_result(stmt, bind); check_execute(stmt, rc); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); fprintf(stdout, "\n total rows: %d", i); assert( i == total_stmts); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); - - rc = mysql_query(mysql,"DROP TABLE test_nstmts"); + + rc= mysql_query(mysql, "DROP TABLE test_nstmts"); myquery(rc); } -/* - To test stmt seek() functions -*/ + +/* Test stmt seek() functions */ + static void test_fetch_seek() { MYSQL_STMT *stmt; @@ -7414,16 +7233,16 @@ static void test_fetch_seek() myheader("test_fetch_seek"); - rc= mysql_query(mysql,"drop table if exists test_seek"); + rc= mysql_query(mysql, "drop table if exists test_seek"); myquery(rc); - - rc = mysql_query(mysql, "create table test_seek(c1 int primary key auto_increment, c2 char(10), c3 timestamp(14))"); + + rc= mysql_query(mysql, "create table test_seek(c1 int primary key auto_increment, c2 char(10), c3 timestamp(14))"); myquery(rc); - - rc = mysql_query(mysql, "insert into test_seek(c2) values('venu'),('mysql'),('open'),('source')"); + + rc= mysql_query(mysql, "insert into test_seek(c2) values('venu'), ('mysql'), ('open'), ('source')"); myquery(rc); - stmt = mysql_simple_prepare(mysql,"select * from test_seek"); + stmt= mysql_simple_prepare(mysql, "select * from test_seek"); check_stmt(stmt); bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -7442,61 +7261,61 @@ static void test_fetch_seek() bind[2].buffer= (char *)c3; bind[2].buffer_length= sizeof(c3); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); - rc = mysql_bind_result(stmt, bind); - check_execute(stmt,rc); + rc= mysql_stmt_bind_result(stmt, bind); + check_execute(stmt, rc); - rc = mysql_stmt_store_result(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_store_result(stmt); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - fprintf(stdout, "\n row 0: %ld,%s,%s", c1,c2,c3); + fprintf(stdout, "\n row 0: %ld, %s, %s", c1, c2, c3); - row = mysql_stmt_row_tell(stmt); + row= mysql_stmt_row_tell(stmt); - row = mysql_stmt_row_seek(stmt, row); + row= mysql_stmt_row_seek(stmt, row); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - fprintf(stdout, "\n row 2: %ld,%s,%s", c1,c2,c3); + fprintf(stdout, "\n row 2: %ld, %s, %s", c1, c2, c3); - row = mysql_stmt_row_seek(stmt, row); + row= mysql_stmt_row_seek(stmt, row); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - fprintf(stdout, "\n row 2: %ld,%s,%s", c1,c2,c3); + fprintf(stdout, "\n row 2: %ld, %s, %s", c1, c2, c3); mysql_stmt_data_seek(stmt, 0); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - fprintf(stdout, "\n row 0: %ld,%s,%s", c1,c2,c3); + fprintf(stdout, "\n row 0: %ld, %s, %s", c1, c2, c3); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); } -/* - To test mysql_fetch_column() with offset -*/ + +/* Test mysql_stmt_fetch_column() with offset */ + static void test_fetch_offset() { MYSQL_STMT *stmt; @@ -7509,16 +7328,16 @@ static void test_fetch_offset() myheader("test_fetch_offset"); - rc= mysql_query(mysql,"drop table if exists test_column"); + rc= mysql_query(mysql, "drop table if exists test_column"); myquery(rc); - - rc = mysql_query(mysql, "create table test_column(a char(10))"); + + rc= mysql_query(mysql, "create table test_column(a char(10))"); myquery(rc); - - rc = mysql_query(mysql, "insert into test_column values('abcdefghij'),(null)"); + + rc= mysql_query(mysql, "insert into test_column values('abcdefghij'), (null)"); myquery(rc); - stmt = mysql_simple_prepare(mysql,"select * from test_column"); + stmt= mysql_simple_prepare(mysql, "select * from test_column"); check_stmt(stmt); bind[0].buffer_type= MYSQL_TYPE_STRING; @@ -7527,58 +7346,59 @@ static void test_fetch_offset() bind[0].is_null= &is_null; bind[0].length= &length; - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); - rc = mysql_fetch_column(stmt,bind,0,0); - check_execute_r(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + check_execute_r(stmt, rc); + + rc= mysql_stmt_bind_result(stmt, bind); + check_execute(stmt, rc); - rc = mysql_bind_result(stmt, bind); - check_execute(stmt,rc); + rc= mysql_stmt_store_result(stmt); + check_execute(stmt, rc); - rc = mysql_stmt_store_result(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); - data[0]= '\0'; - rc = mysql_fetch_column(stmt,bind,0,0); - check_execute(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + check_execute(stmt, rc); fprintf(stdout, "\n col 1: %s (%ld)", data, length); - assert(strncmp(data,"abcd",4) == 0 && length == 10); - - rc = mysql_fetch_column(stmt,bind,0,5); - check_execute(stmt,rc); + assert(strncmp(data, "abcd", 4) == 0 && length == 10); + + rc= mysql_stmt_fetch_column(stmt, bind, 0, 5); + check_execute(stmt, rc); fprintf(stdout, "\n col 1: %s (%ld)", data, length); - assert(strncmp(data,"fg",2) == 0 && length == 10); + assert(strncmp(data, "fg", 2) == 0 && length == 10); - rc = mysql_fetch_column(stmt,bind,0,9); - check_execute(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 0, 9); + check_execute(stmt, rc); fprintf(stdout, "\n col 0: %s (%ld)", data, length); - assert(strncmp(data,"j",1) == 0 && length == 10); + assert(strncmp(data, "j", 1) == 0 && length == 10); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); is_null= 0; - rc = mysql_fetch_column(stmt,bind,0,0); - check_execute(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + check_execute(stmt, rc); assert(is_null == 1); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); - rc = mysql_fetch_column(stmt,bind,1,0); - check_execute_r(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); + check_execute_r(stmt, rc); mysql_stmt_close(stmt); } -/* - To test mysql_fetch_column() -*/ + + +/* Test mysql_stmt_fetch_column() */ + static void test_fetch_column() { MYSQL_STMT *stmt; @@ -7589,16 +7409,16 @@ static void test_fetch_column() myheader("test_fetch_column"); - rc= mysql_query(mysql,"drop table if exists test_column"); + rc= mysql_query(mysql, "drop table if exists test_column"); myquery(rc); - - rc = mysql_query(mysql, "create table test_column(c1 int primary key auto_increment, c2 char(10))"); + + rc= mysql_query(mysql, "create table test_column(c1 int primary key auto_increment, c2 char(10))"); myquery(rc); - - rc = mysql_query(mysql, "insert into test_column(c2) values('venu'),('mysql')"); + + rc= mysql_query(mysql, "insert into test_column(c2) values('venu'), ('mysql')"); myquery(rc); - stmt = mysql_simple_prepare(mysql,"select * from test_column order by c2 desc"); + stmt= mysql_simple_prepare(mysql, "select * from test_column order by c2 desc"); check_stmt(stmt); bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -7612,22 +7432,22 @@ static void test_fetch_column() bind[1].is_null= 0; bind[1].length= &bl2; - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); - rc = mysql_bind_result(stmt, bind); - check_execute(stmt,rc); + rc= mysql_stmt_bind_result(stmt, bind); + check_execute(stmt, rc); - rc = mysql_stmt_store_result(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_store_result(stmt); + check_execute(stmt, rc); - rc = mysql_fetch_column(stmt,bind,1,0); /* No-op at this point */ - check_execute_r(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); /* No-op at this point */ + check_execute_r(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - fprintf(stdout, "\n row 0: %d,%s", bc1,bc2); + fprintf(stdout, "\n row 0: %d, %s", bc1, bc2); c2[0]= '\0'; l2= 0; bind[0].buffer_type= MYSQL_TYPE_STRING; @@ -7636,33 +7456,33 @@ static void test_fetch_column() bind[0].is_null= 0; bind[0].length= &l2; - rc = mysql_fetch_column(stmt,bind,1,0); - check_execute(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); + check_execute(stmt, rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - assert(strncmp(c2,"venu",4)==0 && l2 == 4); - + assert(strncmp(c2, "venu", 4) == 0 && l2 == 4); + c2[0]= '\0'; l2= 0; - rc = mysql_fetch_column(stmt,bind,1,0); - check_execute(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); + check_execute(stmt, rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - assert(strcmp(c2,"venu")==0 && l2 == 4); + assert(strcmp(c2, "venu") == 0 && l2 == 4); - c1= 0; + c1= 0; bind[0].buffer_type= MYSQL_TYPE_LONG; bind[0].buffer= (char *)&c1; bind[0].buffer_length= 0; bind[0].is_null= 0; bind[0].length= &l1; - rc = mysql_fetch_column(stmt,bind,0,0); - check_execute(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + check_execute(stmt, rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); assert(c1 == 1 && l1 == 4); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %d,%s", bc1,bc2); + fprintf(stdout, "\n row 1: %d, %s", bc1, bc2); c2[0]= '\0'; l2= 0; bind[0].buffer_type= MYSQL_TYPE_STRING; @@ -7671,136 +7491,136 @@ static void test_fetch_column() bind[0].is_null= 0; bind[0].length= &l2; - rc = mysql_fetch_column(stmt,bind,1,0); - check_execute(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); + check_execute(stmt, rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - assert(strncmp(c2,"mysq",4)==0 && l2 == 5); - + assert(strncmp(c2, "mysq", 4) == 0 && l2 == 5); + c2[0]= '\0'; l2= 0; - rc = mysql_fetch_column(stmt,bind,1,0); - check_execute(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); + check_execute(stmt, rc); fprintf(stdout, "\n col 1: %si(%ld)", c2, l2); - assert(strcmp(c2,"mysql")==0 && l2 == 5); + assert(strcmp(c2, "mysql") == 0 && l2 == 5); - c1= 0; + c1= 0; bind[0].buffer_type= MYSQL_TYPE_LONG; bind[0].buffer= (char *)&c1; bind[0].buffer_length= 0; bind[0].is_null= 0; bind[0].length= &l1; - rc = mysql_fetch_column(stmt,bind,0,0); - check_execute(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + check_execute(stmt, rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); assert(c1 == 2 && l1 == 4); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); - rc = mysql_fetch_column(stmt,bind,1,0); - check_execute_r(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); + check_execute_r(stmt, rc); mysql_stmt_close(stmt); } -/* - To test mysql_list_fields() -*/ + +/* Test mysql_list_fields() */ + static void test_list_fields() { MYSQL_RES *result; int rc; myheader("test_list_fields"); - rc= mysql_query(mysql,"drop table if exists test_list_fields"); + rc= mysql_query(mysql, "drop table if exists test_list_fields"); myquery(rc); - - rc = mysql_query(mysql, "create table test_list_fields(c1 int primary key auto_increment, c2 char(10) default 'mysql')"); + + rc= mysql_query(mysql, "create table test_list_fields(c1 int primary key auto_increment, c2 char(10) default 'mysql')"); myquery(rc); - result = mysql_list_fields(mysql, "test_list_fields",NULL); + result= mysql_list_fields(mysql, "test_list_fields", NULL); mytest(result); assert( 0 == my_process_result_set(result)); - - verify_prepare_field(result,0,"c1","c1",MYSQL_TYPE_LONG, - "test_list_fields","test_list_fields",current_db,11,"0"); - - verify_prepare_field(result,1,"c2","c2",MYSQL_TYPE_STRING, - "test_list_fields","test_list_fields",current_db,10,"mysql"); + + verify_prepare_field(result, 0, "c1", "c1", MYSQL_TYPE_LONG, + "test_list_fields", "test_list_fields", current_db, 11, "0"); + + verify_prepare_field(result, 1, "c2", "c2", MYSQL_TYPE_STRING, + "test_list_fields", "test_list_fields", current_db, 10, "mysql"); mysql_free_result(result); } -/* - To test a memory ovverun bug -*/ + +/* Test a memory ovverun bug */ + static void test_mem_overun() { char buffer[10000], field[10]; MYSQL_STMT *stmt; MYSQL_RES *field_res; - int rc,i, length; + int rc, i, length; myheader("test_mem_overun"); /* - Test a memory ovverun bug when a table had 1000 fields with + Test a memory ovverun bug when a table had 1000 fields with a row of data */ - rc= mysql_query(mysql,"drop table if exists t_mem_overun"); + rc= mysql_query(mysql, "drop table if exists t_mem_overun"); myquery(rc); - strxmov(buffer,"create table t_mem_overun(",NullS); - for (i=0; i < 1000; i++) + strxmov(buffer, "create table t_mem_overun(", NullS); + for (i= 0; i < 1000; i++) { - sprintf(field,"c%d int", i); - strxmov(buffer,buffer,field,",",NullS); + sprintf(field, "c%d int", i); + strxmov(buffer, buffer, field, ", ", NullS); } - length= (int)(strmov(buffer,buffer) - buffer); - buffer[length-1]='\0'; - strxmov(buffer,buffer,")",NullS); - - rc = mysql_real_query(mysql, buffer, length); + length= strlen(buffer); + buffer[length-2]= ')'; + buffer[--length]= '\0'; + + rc= mysql_real_query(mysql, buffer, length); myquery(rc); - strxmov(buffer,"insert into t_mem_overun values(",NullS); - for (i=0; i < 1000; i++) + strxmov(buffer, "insert into t_mem_overun values(", NullS); + for (i= 0; i < 1000; i++) { - strxmov(buffer,buffer,"1,",NullS); + strxmov(buffer, buffer, "1, ", NullS); } - length= (int)(strmov(buffer,buffer) - buffer); - buffer[length-1]='\0'; - strxmov(buffer,buffer,")",NullS); - - rc = mysql_real_query(mysql, buffer, length); + length= strlen(buffer); + buffer[length-2]= ')'; + buffer[--length]= '\0'; + + rc= mysql_real_query(mysql, buffer, length); myquery(rc); - rc = mysql_query(mysql,"select * from t_mem_overun"); + rc= mysql_query(mysql, "select * from t_mem_overun"); myquery(rc); assert(1 == my_process_result(mysql)); - - stmt = mysql_simple_prepare(mysql, "select * from t_mem_overun"); + + stmt= mysql_simple_prepare(mysql, "select * from t_mem_overun"); check_stmt(stmt); - rc = mysql_execute(stmt); - check_execute(stmt,rc); - - field_res = mysql_get_metadata(stmt); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + field_res= mysql_stmt_result_metadata(stmt); 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)); - rc = mysql_stmt_store_result(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_store_result(stmt); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); mysql_free_result(field_res); @@ -7808,9 +7628,9 @@ static void test_mem_overun() mysql_stmt_close(stmt); } -/* - To test mysql_stmt_free_result() -*/ + +/* Test mysql_stmt_free_result() */ + static void test_free_result() { MYSQL_STMT *stmt; @@ -7821,16 +7641,17 @@ static void test_free_result() myheader("test_free_result"); - rc= mysql_query(mysql,"drop table if exists test_free_result"); + rc= mysql_query(mysql, "drop table if exists test_free_result"); myquery(rc); - - rc = mysql_query(mysql, "create table test_free_result(c1 int primary key auto_increment)"); + + rc= mysql_query(mysql, "create table test_free_result(" + "c1 int primary key auto_increment)"); myquery(rc); - - rc = mysql_query(mysql, "insert into test_free_result values(),(),()"); + + rc= mysql_query(mysql, "insert into test_free_result values(), (), ()"); myquery(rc); - stmt = mysql_simple_prepare(mysql,"select * from test_free_result"); + stmt= mysql_simple_prepare(mysql, "select * from test_free_result"); check_stmt(stmt); bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -7839,14 +7660,14 @@ static void test_free_result() bind[0].is_null= 0; bind[0].length= &bl1; - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); - rc = mysql_bind_result(stmt, bind); - check_execute(stmt,rc); + rc= mysql_stmt_bind_result(stmt, bind); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); c2[0]= '\0'; l2= 0; bind[0].buffer_type= MYSQL_TYPE_STRING; @@ -7855,41 +7676,41 @@ static void test_free_result() bind[0].is_null= 0; bind[0].length= &l2; - rc = mysql_fetch_column(stmt,bind,0,0); - check_execute(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + check_execute(stmt, rc); fprintf(stdout, "\n col 0: %s(%ld)", c2, l2); - assert(strncmp(c2,"1",1)==0 && l2 == 1); + assert(strncmp(c2, "1", 1) == 0 && l2 == 1); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - c1= 0, l2= 0; + c1= 0, l2= 0; bind[0].buffer_type= MYSQL_TYPE_LONG; bind[0].buffer= (char *)&c1; bind[0].buffer_length= 0; bind[0].is_null= 0; bind[0].length= &l2; - rc = mysql_fetch_column(stmt,bind,0,0); - check_execute(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + check_execute(stmt, rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); - assert(c1 == 2 && l2 == 4); + assert(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 */ - rc = mysql_stmt_free_result(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_free_result(stmt); + check_execute(stmt, rc); - rc = mysql_query(mysql,"drop table test_free_result"); + rc= mysql_query(mysql, "drop table test_free_result"); myquery(rc); /* should be successful */ mysql_stmt_close(stmt); } -/* - To test mysql_stmt_free_result() -*/ + +/* Test mysql_stmt_store_result() */ + static void test_free_store_result() { MYSQL_STMT *stmt; @@ -7900,16 +7721,16 @@ static void test_free_store_result() myheader("test_free_store_result"); - rc= mysql_query(mysql,"drop table if exists test_free_result"); + rc= mysql_query(mysql, "drop table if exists test_free_result"); myquery(rc); - - rc = mysql_query(mysql, "create table test_free_result(c1 int primary key auto_increment)"); + + rc= mysql_query(mysql, "create table test_free_result(c1 int primary key auto_increment)"); myquery(rc); - - rc = mysql_query(mysql, "insert into test_free_result values(),(),()"); + + rc= mysql_query(mysql, "insert into test_free_result values(), (), ()"); myquery(rc); - stmt = mysql_simple_prepare(mysql,"select * from test_free_result"); + stmt= mysql_simple_prepare(mysql, "select * from test_free_result"); check_stmt(stmt); bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -7918,17 +7739,17 @@ static void test_free_store_result() bind[0].is_null= 0; bind[0].length= &bl1; - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); - rc = mysql_bind_result(stmt, bind); - check_execute(stmt,rc); + rc= mysql_stmt_bind_result(stmt, bind); + check_execute(stmt, rc); - rc = mysql_stmt_store_result(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_store_result(stmt); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); c2[0]= '\0'; l2= 0; bind[0].buffer_type= MYSQL_TYPE_STRING; @@ -7937,38 +7758,37 @@ static void test_free_store_result() bind[0].is_null= 0; bind[0].length= &l2; - rc = mysql_fetch_column(stmt,bind,0,0); - check_execute(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + check_execute(stmt, rc); fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); - assert(strncmp(c2,"1",1)==0 && l2 == 1); + assert(strncmp(c2, "1", 1) == 0 && l2 == 1); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - c1= 0, l2= 0; + c1= 0, l2= 0; bind[0].buffer_type= MYSQL_TYPE_LONG; bind[0].buffer= (char *)&c1; bind[0].buffer_length= 0; bind[0].is_null= 0; bind[0].length= &l2; - rc = mysql_fetch_column(stmt,bind,0,0); - check_execute(stmt,rc); + rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); + check_execute(stmt, rc); fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); assert(c1 == 2 && l2 == 4); - rc = mysql_stmt_free_result(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_free_result(stmt); + check_execute(stmt, rc); - rc = mysql_query(mysql,"drop table test_free_result"); - myquery(rc); + rc= mysql_query(mysql, "drop table test_free_result"); + myquery(rc); mysql_stmt_close(stmt); } -/******************************************************** - To test SQLmode -*********************************************************/ + +/* Test SQLmode */ static void test_sqlmode() { @@ -7979,125 +7799,124 @@ static void test_sqlmode() myheader("test_sqlmode"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_piping"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_piping"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_piping(name varchar(10))"); myquery(rc); - rc = mysql_query(mysql,"CREATE TABLE test_piping(name varchar(10))"); - myquery(rc); - /* PIPES_AS_CONCAT */ - strcpy(query,"SET SQL_MODE=\"PIPES_AS_CONCAT\""); - fprintf(stdout,"\n With %s", query); - rc = mysql_query(mysql,query); + strcpy(query, "SET SQL_MODE= \"PIPES_AS_CONCAT\""); + fprintf(stdout, "\n With %s", query); + rc= mysql_query(mysql, query); myquery(rc); strcpy(query, "INSERT INTO test_piping VALUES(?||?)"); - fprintf(stdout,"\n query: %s", query); - stmt = mysql_simple_prepare(mysql, query); + fprintf(stdout, "\n query: %s", query); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - fprintf(stdout,"\n total parameters: %ld", mysql_param_count(stmt)); + fprintf(stdout, "\n total parameters: %ld", mysql_stmt_param_count(stmt)); + + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer= (char *)c1; bind[0].buffer_length= 2; - bind[0].is_null= 0; - bind[0].length= 0; bind[1].buffer_type= MYSQL_TYPE_STRING; bind[1].buffer= (char *)c2; bind[1].buffer_length= 3; - bind[1].is_null= 0; - bind[1].length= 0; - rc = mysql_bind_param(stmt, bind); - check_execute(stmt,rc); + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); - strcpy(c1,"My"); strcpy(c2, "SQL"); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + strcpy(c1, "My"); strcpy(c2, "SQL"); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); mysql_stmt_close(stmt); - verify_col_data("test_piping","name","MySQL"); + verify_col_data("test_piping", "name", "MySQL"); - rc = mysql_query(mysql,"DELETE FROM test_piping"); + rc= mysql_query(mysql, "DELETE FROM test_piping"); myquery(rc); - + strcpy(query, "SELECT connection_id ()"); - fprintf(stdout,"\n query: %s", query); - stmt = mysql_simple_prepare(mysql, query); + fprintf(stdout, "\n query: %s", query); + stmt= mysql_simple_prepare(mysql, query); check_stmt_r(stmt); /* ANSI */ - strcpy(query,"SET SQL_MODE=\"ANSI\""); - fprintf(stdout,"\n With %s", query); - rc = mysql_query(mysql,query); + strcpy(query, "SET SQL_MODE= \"ANSI\""); + fprintf(stdout, "\n With %s", query); + rc= mysql_query(mysql, query); myquery(rc); strcpy(query, "INSERT INTO test_piping VALUES(?||?)"); - fprintf(stdout,"\n query: %s", query); - stmt = mysql_simple_prepare(mysql, query); + fprintf(stdout, "\n query: %s", query); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - fprintf(stdout,"\n total parameters: %ld", mysql_param_count(stmt)); + fprintf(stdout, "\n total parameters: %ld", mysql_stmt_param_count(stmt)); - rc = mysql_bind_param(stmt, bind); - check_execute(stmt,rc); + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); - strcpy(c1,"My"); strcpy(c2, "SQL"); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + strcpy(c1, "My"); strcpy(c2, "SQL"); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); mysql_stmt_close(stmt); - verify_col_data("test_piping","name","MySQL"); + verify_col_data("test_piping", "name", "MySQL"); /* ANSI mode spaces ... */ strcpy(query, "SELECT connection_id ()"); - fprintf(stdout,"\n query: %s", query); - stmt = mysql_simple_prepare(mysql, query); + fprintf(stdout, "\n query: %s", query); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); - fprintf(stdout,"\n returned 1 row\n"); + fprintf(stdout, "\n returned 1 row\n"); mysql_stmt_close(stmt); - + /* IGNORE SPACE MODE */ - strcpy(query,"SET SQL_MODE=\"IGNORE_SPACE\""); - fprintf(stdout,"\n With %s", query); - rc = mysql_query(mysql,query); + strcpy(query, "SET SQL_MODE= \"IGNORE_SPACE\""); + fprintf(stdout, "\n With %s", query); + rc= mysql_query(mysql, query); myquery(rc); strcpy(query, "SELECT connection_id ()"); - fprintf(stdout,"\n query: %s", query); - stmt = mysql_simple_prepare(mysql, query); + fprintf(stdout, "\n query: %s", query); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); - fprintf(stdout,"\n returned 1 row"); + fprintf(stdout, "\n returned 1 row"); mysql_stmt_close(stmt); } -/* - test for timestamp handling -*/ + +/* Test for timestamp handling */ + static void test_ts() { MYSQL_STMT *stmt; @@ -8111,16 +7930,13 @@ static void test_ts() myheader("test_ts"); - rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_ts"); - myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE test_ts(a DATE, b TIME, c TIMESTAMP)"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_ts"); myquery(rc); - rc = mysql_commit(mysql); + rc= mysql_query(mysql, "CREATE TABLE test_ts(a DATE, b TIME, c TIMESTAMP)"); myquery(rc); - stmt = mysql_simple_prepare(mysql,"INSERT INTO test_ts VALUES(?,?,?),(?,?,?)"); + stmt= mysql_simple_prepare(mysql, "INSERT INTO test_ts VALUES(?, ?, ?), (?, ?, ?)"); check_stmt(stmt); ts.year= 2003; @@ -8130,46 +7946,49 @@ static void test_ts() ts.minute= 07; ts.second= 46; ts.second_part= 0; - length= (long)(strmov(strts,"2003-07-12 21:07:46") - strts); + length= (long)(strmov(strts, "2003-07-12 21:07:46") - strts); + + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); bind[0].buffer_type= MYSQL_TYPE_TIMESTAMP; bind[0].buffer= (char *)&ts; bind[0].buffer_length= sizeof(ts); - bind[0].is_null= 0; - bind[0].length= 0; bind[2]= bind[1]= bind[0]; bind[3].buffer_type= MYSQL_TYPE_STRING; bind[3].buffer= (char *)strts; bind[3].buffer_length= sizeof(strts); - bind[3].is_null= 0; bind[3].length= &length; bind[5]= bind[4]= bind[3]; - rc = mysql_bind_param(stmt, bind); - check_execute(stmt,rc); + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); mysql_stmt_close(stmt); - verify_col_data("test_ts","a","2003-07-12"); - verify_col_data("test_ts","b","21:07:46"); - verify_col_data("test_ts","c","2003-07-12 21:07:46"); + verify_col_data("test_ts", "a", "2003-07-12"); + verify_col_data("test_ts", "b", "21:07:46"); + verify_col_data("test_ts", "c", "2003-07-12 21:07:46"); - stmt = mysql_simple_prepare(mysql,"SELECT * FROM test_ts"); + stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_ts"); check_stmt(stmt); - prep_res = mysql_get_metadata(stmt); + prep_res= mysql_stmt_result_metadata(stmt); mytest(prep_res); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); - assert( 2== my_process_stmt_result(stmt)); + assert(2 == my_process_stmt_result(stmt)); field_count= mysql_num_fields(prep_res); mysql_free_result(prep_res); @@ -8179,20 +7998,19 @@ static void test_ts() { int row_count= 0; - sprintf(query,"SELECT a,b,c FROM test_ts WHERE %c=?",name); - length= (long)(strmov(query,query)- query); + sprintf(query, "SELECT a, b, c FROM test_ts WHERE %c=?", name); - fprintf(stdout,"\n %s", query); - stmt = mysql_prepare(mysql, query, length); + fprintf(stdout, "\n %s", query); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - rc = mysql_bind_param(stmt, bind); - check_execute(stmt,rc); + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); - while (mysql_fetch(stmt) == 0) + while (mysql_stmt_fetch(stmt) == 0) row_count++; fprintf(stdout, "\n returned '%d' rows", row_count); @@ -8201,63 +8019,65 @@ static void test_ts() } } -/* - Test for bug #1500. -*/ + +/* Test for bug #1500. */ static void test_bug1500() { MYSQL_STMT *stmt; MYSQL_BIND bind[3]; int rc; - long int_data[3]= {2,3,4}; + long int_data[3]= {2, 3, 4}; const char *data; myheader("test_bug1500"); - rc= mysql_query(mysql,"DROP TABLE IF EXISTS test_bg1500"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bg1500"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE test_bg1500 (i INT)"); + + rc= mysql_query(mysql, "CREATE TABLE test_bg1500 (i INT)"); myquery(rc); - - rc= mysql_query(mysql,"INSERT INTO test_bg1500 VALUES (1),(2)"); + + rc= mysql_query(mysql, "INSERT INTO test_bg1500 VALUES (1), (2)"); myquery(rc); rc= mysql_commit(mysql); myquery(rc); - stmt= mysql_simple_prepare(mysql,"SELECT i FROM test_bg1500 WHERE i IN (?,?,?)"); + stmt= mysql_simple_prepare(mysql, "SELECT i FROM test_bg1500 WHERE i IN (?, ?, ?)"); check_stmt(stmt); - verify_param_count(stmt,3); + verify_param_count(stmt, 3); + + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); bind[0].buffer= (char *)int_data; - bind[0].buffer_type= FIELD_TYPE_LONG; - bind[0].is_null= 0; - bind[0].length= NULL; - bind[0].buffer_length= 0; + bind[0].buffer_type= MYSQL_TYPE_LONG; bind[2]= bind[1]= bind[0]; bind[1].buffer= (char *)(int_data + 1); bind[2].buffer= (char *)(int_data + 2); - - rc= mysql_bind_param(stmt, bind); - check_execute(stmt,rc); - - rc= mysql_execute(stmt); - check_execute(stmt,rc); - + + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + assert(1 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); - rc= mysql_query(mysql,"DROP TABLE test_bg1500"); + rc= mysql_query(mysql, "DROP TABLE test_bg1500"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE test_bg1500 (s VARCHAR(25), FULLTEXT(s))"); + + rc= mysql_query(mysql, "CREATE TABLE test_bg1500 (s VARCHAR(25), FULLTEXT(s))"); myquery(rc); - + rc= mysql_query(mysql, - "INSERT INTO test_bg1500 VALUES ('Gravedigger'), ('Greed'),('Hollow Dogs')"); + "INSERT INTO test_bg1500 VALUES ('Gravedigger'), ('Greed'), ('Hollow Dogs')"); myquery(rc); rc= mysql_commit(mysql); @@ -8266,55 +8086,54 @@ static void test_bug1500() stmt= mysql_simple_prepare(mysql, "SELECT s FROM test_bg1500 WHERE MATCH (s) AGAINST (?)"); check_stmt(stmt); - - verify_param_count(stmt,1); - + + verify_param_count(stmt, 1); + data= "Dogs"; bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer= (char *) data; bind[0].buffer_length= strlen(data); bind[0].is_null= 0; bind[0].length= 0; - - rc= mysql_bind_param(stmt, bind); - check_execute(stmt,rc); - - rc= mysql_execute(stmt); - check_execute(stmt,rc); - + + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + assert(1 == my_process_stmt_result(stmt)); - /* - FIXME If we comment out next string server will crash too :( + /* + FIXME If we comment out next string server will crash too :( This is another manifestation of bug #1663 */ mysql_stmt_close(stmt); - + /* This should work too */ stmt= mysql_simple_prepare(mysql, - "SELECT s FROM test_bg1500 WHERE MATCH (s) AGAINST (CONCAT(?,'digger'))"); + "SELECT s FROM test_bg1500 WHERE MATCH (s) AGAINST (CONCAT(?, 'digger'))"); check_stmt(stmt); - - verify_param_count(stmt,1); - + + verify_param_count(stmt, 1); + data= "Grave"; bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer= (char *) data; bind[0].buffer_length= strlen(data); - bind[0].is_null= 0; - bind[0].length= 0; - - rc= mysql_bind_param(stmt, bind); - check_execute(stmt,rc); - - rc= mysql_execute(stmt); - check_execute(stmt,rc); - + + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + assert(1 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); } + static void test_bug1946() { MYSQL_STMT *stmt; @@ -8322,14 +8141,14 @@ static void test_bug1946() const char *query= "INSERT INTO prepare_command VALUES (?)"; myheader("test_bug1946"); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS prepare_command"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS prepare_command"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE prepare_command(ID INT)"); + + rc= mysql_query(mysql, "CREATE TABLE prepare_command(ID INT)"); myquery(rc); - stmt = mysql_simple_prepare(mysql, query); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); rc= mysql_real_query(mysql, query, strlen(query)); assert(rc != 0); @@ -8337,9 +8156,10 @@ static void test_bug1946() myerror(NULL); mysql_stmt_close(stmt); - rc= mysql_query(mysql,"DROP TABLE prepare_command"); + rc= mysql_query(mysql, "DROP TABLE prepare_command"); } + static void test_parse_error_and_bad_length() { MYSQL_STMT *stmt; @@ -8348,19 +8168,21 @@ static void test_parse_error_and_bad_length() /* check that we get 4 syntax errors over the 4 calls */ myheader("test_parse_error_and_bad_length"); - rc= mysql_query(mysql,"SHOW DATABAAAA"); + rc= mysql_query(mysql, "SHOW DATABAAAA"); assert(rc); 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); fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); - stmt= mysql_simple_prepare(mysql,"SHOW DATABAAAA"); - assert(!stmt); - fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); - stmt= mysql_prepare(mysql,"SHOW DATABASES",100); + stmt= mysql_simple_prepare(mysql, "SHOW DATABAAAA"); assert(!stmt); fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); + stmt= mysql_stmt_init(mysql); + assert(stmt); + assert(mysql_stmt_prepare(stmt, "SHOW DATABASES", 100) != 0); + fprintf(stdout, "Got error (as expected): '%s'\n", mysql_stmt_error(stmt)); + mysql_stmt_close(stmt); } @@ -8379,21 +8201,21 @@ static void test_bug2247() enum { NUM_ROWS= 5 }; myheader("test_bug2247"); - + fprintf(stdout, "\nChecking if stmt_affected_rows is not affected by\n" "mysql_query ... "); /* create table and insert few rows */ - rc = mysql_query(mysql, drop); + rc= mysql_query(mysql, drop); myquery(rc); - + rc= mysql_query(mysql, create); myquery(rc); - stmt= mysql_prepare(mysql, insert, strlen(insert)); + stmt= mysql_simple_prepare(mysql, insert); check_stmt(stmt); for (i= 0; i < NUM_ROWS; ++i) { - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); } exp_count= mysql_stmt_affected_rows(stmt); @@ -8401,7 +8223,7 @@ static void test_bug2247() rc= mysql_query(mysql, select); myquery(rc); - /* + /* mysql_store_result overwrites mysql->affected_rows. Check that mysql_stmt_affected_rows() returns the same value, whereas mysql_affected_rows() value is correct. @@ -8411,7 +8233,7 @@ static void test_bug2247() assert(mysql_affected_rows(mysql) == NUM_ROWS); assert(exp_count == mysql_stmt_affected_rows(stmt)); - + rc= mysql_query(mysql, update); myquery(rc); assert(mysql_affected_rows(mysql) == NUM_ROWS); @@ -8421,10 +8243,10 @@ static void test_bug2247() mysql_stmt_close(stmt); /* check that mysql_stmt_store_result modifies mysql_stmt_affected_rows */ - stmt= mysql_prepare(mysql, select, strlen(select)); + stmt= mysql_simple_prepare(mysql, select); check_stmt(stmt); - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); rc= mysql_stmt_store_result(stmt); check_execute(stmt, rc); @@ -8435,7 +8257,7 @@ static void test_bug2247() myquery(rc); assert(mysql_affected_rows(mysql) == 1); assert(mysql_stmt_affected_rows(stmt) == exp_count); - + mysql_stmt_close(stmt); fprintf(stdout, "OK"); } @@ -8445,34 +8267,34 @@ static void test_subqueries() { MYSQL_STMT *stmt; int rc, i; - const char *query= "SELECT (SELECT SUM(a+b) FROM t2 where t1.b=t2.b GROUP BY t1.a LIMIT 1) as scalar_s, exists (select 1 from t2 where t2.a/2=t1.a) as exists_s, a in (select a+3 from t2) as in_s, (a-1,b-1) in (select a,b from t2) as in_row_s FROM t1, (select a x, b y from t2) tt WHERE x=a"; + const char *query= "SELECT (SELECT SUM(a+b) FROM t2 where t1.b=t2.b GROUP BY t1.a LIMIT 1) as scalar_s, exists (select 1 from t2 where t2.a/2=t1.a) as exists_s, a in (select a+3 from t2) as in_s, (a-1, b-1) in (select a, b from t2) as in_row_s FROM t1, (select a x, b y from t2) tt WHERE x=a"; myheader("test_subquery"); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1,t2"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1, t2"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE t1 (a int , b int);"); + + rc= mysql_query(mysql, "CREATE TABLE t1 (a int , b int);"); myquery(rc); rc= mysql_query(mysql, - "insert into t1 values (1,1), (2, 2), (3,3), (4,4), (5,5);"); + "insert into t1 values (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);"); myquery(rc); - rc= mysql_query(mysql,"create table t2 select * from t1;"); + rc= mysql_query(mysql, "create table t2 select * from t1;"); myquery(rc); - stmt= mysql_prepare(mysql, query, strlen(query)); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); for (i= 0; i < 3; i++) { - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(5 == my_process_stmt_result(stmt)); } mysql_stmt_close(stmt); - rc= mysql_query(mysql, "DROP TABLE t1,t2"); + rc= mysql_query(mysql, "DROP TABLE t1, t2"); myquery(rc); } @@ -8483,37 +8305,38 @@ static void test_bad_union() const char *query= "SELECT 1, 2 union SELECT 1"; myheader("test_bad_union"); - - stmt= mysql_prepare(mysql, query, strlen(query)); + + stmt= mysql_simple_prepare(mysql, query); assert(stmt == 0); - myerror(NULL); + myerror(NULL); } + static void test_distinct() { MYSQL_STMT *stmt; int rc, i; - const char *query= + const char *query= "SELECT 2+count(distinct b), group_concat(a) FROM t1 group by a"; myheader("test_subquery"); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE t1 (a int , b int);"); + + rc= mysql_query(mysql, "CREATE TABLE t1 (a int , b int);"); myquery(rc); rc= mysql_query(mysql, - "insert into t1 values (1,1), (2, 2), (3,3), (4,4), (5,5),\ -(1,10), (2, 20), (3,30), (4,40), (5,50);"); + "insert into t1 values (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), \ +(1, 10), (2, 20), (3, 30), (4, 40), (5, 50);"); myquery(rc); for (i= 0; i < 3; i++) { - stmt= mysql_prepare(mysql, query, strlen(query)); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(5 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); @@ -8523,8 +8346,9 @@ static void test_distinct() myquery(rc); } + /* - Test for bug#2248 "mysql_fetch without prior mysql_execute hangs" + Test for bug#2248 "mysql_fetch without prior mysql_stmt_execute hangs" */ static void test_bug2248() @@ -8533,53 +8357,54 @@ static void test_bug2248() int rc; const char *query1= "SELECT DATABASE()"; const char *query2= "INSERT INTO test_bug2248 VALUES (10)"; - + myheader("test_bug2248"); rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bug2248"); myquery(rc); - + rc= mysql_query(mysql, "CREATE TABLE test_bug2248 (id int)"); myquery(rc); - - stmt= mysql_prepare(mysql, query1, strlen(query1)); + + stmt= mysql_simple_prepare(mysql, query1); check_stmt(stmt); /* This should not hang */ - rc= mysql_fetch(stmt); - check_execute_r(stmt,rc); - + rc= mysql_stmt_fetch(stmt); + check_execute_r(stmt, rc); + /* And this too */ rc= mysql_stmt_store_result(stmt); - check_execute_r(stmt,rc); - + check_execute_r(stmt, rc); + mysql_stmt_close(stmt); - - stmt= mysql_prepare(mysql, query2, strlen(query2)); + + stmt= mysql_simple_prepare(mysql, query2); check_stmt(stmt); - - rc= mysql_execute(stmt); - check_execute(stmt,rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); /* This too should not hang but should return proper error */ - rc= mysql_fetch(stmt); - assert(rc==MYSQL_NO_DATA); - + rc= mysql_stmt_fetch(stmt); + assert(rc == MYSQL_NO_DATA); + /* This too should not hang but should not bark */ rc= mysql_stmt_store_result(stmt); - check_execute(stmt,rc); - + check_execute(stmt, rc); + /* This should return proper error */ - rc= mysql_fetch(stmt); - check_execute_r(stmt,rc); - assert(rc==MYSQL_NO_DATA); - + rc= mysql_stmt_fetch(stmt); + check_execute_r(stmt, rc); + assert(rc == MYSQL_NO_DATA); + mysql_stmt_close(stmt); - - rc= mysql_query(mysql,"DROP TABLE test_bug2248"); + + rc= mysql_query(mysql, "DROP TABLE test_bug2248"); myquery(rc); } + static void test_subqueries_ref() { MYSQL_STMT *stmt; @@ -8587,22 +8412,22 @@ static void test_subqueries_ref() const char *query= "SELECT a as ccc from t1 where a+1=(SELECT 1+ccc from t1 where ccc+1=a+1 and a=1)"; myheader("test_subquery_ref"); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE t1 (a int);"); + + rc= mysql_query(mysql, "CREATE TABLE t1 (a int);"); myquery(rc); rc= mysql_query(mysql, - "insert into t1 values (1), (2), (3), (4), (5);"); + "insert into t1 values (1), (2), (3), (4), (5);"); myquery(rc); - stmt= mysql_prepare(mysql, query, strlen(query)); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); for (i= 0; i < 3; i++) { - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(1 == my_process_stmt_result(stmt)); } @@ -8619,7 +8444,7 @@ static void test_union() int rc; myheader("test_union"); - + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1, t2"); myquery(rc); @@ -8649,14 +8474,14 @@ static void test_union() "(10, 'Azerbaijan'), (11, 'Afghanistan'), " "(12, 'Burkina Faso'), (13, 'Faroe Islands')"); myquery(rc); - + stmt= mysql_simple_prepare(mysql, "SELECT t1.name FROM t1 UNION " "SELECT t2.name FROM t2"); check_stmt(stmt); rc= mysql_stmt_execute(stmt); - check_execute(stmt,rc); + check_execute(stmt, rc); assert(20 == my_process_stmt_result(stmt)); mysql_stmt_close(stmt); @@ -8664,6 +8489,7 @@ static void test_union() myquery(rc); } + static void test_bug3117() { MYSQL_STMT *stmt; @@ -8674,51 +8500,52 @@ static void test_bug3117() int rc; myheader("test_bug3117"); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE t1 (id int auto_increment primary key)"); + + rc= mysql_query(mysql, "CREATE TABLE t1 (id int auto_increment primary key)"); myquery(rc); - stmt = mysql_simple_prepare(mysql, "SELECT LAST_INSERT_ID()"); + stmt= mysql_simple_prepare(mysql, "SELECT LAST_INSERT_ID()"); check_stmt(stmt); rc= mysql_query(mysql, "INSERT INTO t1 VALUES (NULL)"); myquery(rc); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + bzero((char*) &buffer, sizeof(buffer)); buffer.buffer_type= MYSQL_TYPE_LONGLONG; buffer.buffer_length= sizeof(lii); buffer.buffer= (char *)&lii; buffer.length= &length; buffer.is_null= &is_null; - rc= mysql_bind_result(stmt, &buffer); - check_execute(stmt,rc); + rc= mysql_stmt_bind_result(stmt, &buffer); + check_execute(stmt, rc); rc= mysql_stmt_store_result(stmt); - check_execute(stmt,rc); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); assert(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)"); myquery(rc); - rc = mysql_execute(stmt); - check_execute(stmt,rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); - rc = mysql_fetch(stmt); + rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); assert(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); @@ -8731,49 +8558,49 @@ static void test_join() { MYSQL_STMT *stmt; int rc, i, j; - const char *query[]={"SELECT * FROM t2 join t1 on (t1.a=t2.a)", - "SELECT * FROM t2 natural join t1", - "SELECT * FROM t2 join t1 using(a)", - "SELECT * FROM t2 left join t1 on(t1.a=t2.a)", - "SELECT * FROM t2 natural left join t1", - "SELECT * FROM t2 left join t1 using(a)", - "SELECT * FROM t2 right join t1 on(t1.a=t2.a)", - "SELECT * FROM t2 natural right join t1", - "SELECT * FROM t2 right join t1 using(a)"}; + const char *query[]= {"SELECT * FROM t2 join t1 on (t1.a=t2.a)", + "SELECT * FROM t2 natural join t1", + "SELECT * FROM t2 join t1 using(a)", + "SELECT * FROM t2 left join t1 on(t1.a=t2.a)", + "SELECT * FROM t2 natural left join t1", + "SELECT * FROM t2 left join t1 using(a)", + "SELECT * FROM t2 right join t1 on(t1.a=t2.a)", + "SELECT * FROM t2 natural right join t1", + "SELECT * FROM t2 right join t1 using(a)"}; myheader("test_join"); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1,t2"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1, t2"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE t1 (a int , b int);"); + + rc= mysql_query(mysql, "CREATE TABLE t1 (a int , b int);"); myquery(rc); rc= mysql_query(mysql, - "insert into t1 values (1,1), (2, 2), (3,3), (4,4), (5,5);"); + "insert into t1 values (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);"); myquery(rc); - rc= mysql_query(mysql,"CREATE TABLE t2 (a int , c int);"); + rc= mysql_query(mysql, "CREATE TABLE t2 (a int , c int);"); myquery(rc); rc= mysql_query(mysql, - "insert into t2 values (1,1), (2, 2), (3,3), (4,4), (5,5);"); + "insert into t2 values (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);"); myquery(rc); for (j= 0; j < 9; j++) { - stmt= mysql_prepare(mysql, query[j], strlen(query[j])); + stmt= mysql_simple_prepare(mysql, query[j]); check_stmt(stmt); for (i= 0; i < 3; i++) { - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(5 == my_process_stmt_result(stmt)); } mysql_stmt_close(stmt); } - rc= mysql_query(mysql, "DROP TABLE t1,t2"); + rc= mysql_query(mysql, "DROP TABLE t1, t2"); myquery(rc); } @@ -8782,44 +8609,44 @@ static void test_selecttmp() { MYSQL_STMT *stmt; int rc, i; - const char *query= "select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) from t3"; + const char *query= "select a, (select count(distinct t1.b) as sum from t1, t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) from t3"; myheader("test_select_tmp"); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1,t2,t3"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1, t2, t3"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE t1 (a int , b int);"); + + rc= mysql_query(mysql, "CREATE TABLE t1 (a int , b int);"); myquery(rc); - rc= mysql_query(mysql,"create table t2 (a int, b int);"); + rc= mysql_query(mysql, "create table t2 (a int, b int);"); myquery(rc); - rc= mysql_query(mysql,"create table t3 (a int, b int);"); + rc= mysql_query(mysql, "create table t3 (a int, b int);"); myquery(rc); rc= mysql_query(mysql, - "insert into t1 values (0,100),(1,2), (1,3), (2,2), (2,7), \ -(2,-1), (3,10);"); + "insert into t1 values (0, 100), (1, 2), (1, 3), (2, 2), (2, 7), \ +(2, -1), (3, 10);"); myquery(rc); rc= mysql_query(mysql, - "insert into t2 values (0,0), (1,1), (2,1), (3,1), (4,1);"); + "insert into t2 values (0, 0), (1, 1), (2, 1), (3, 1), (4, 1);"); myquery(rc); rc= mysql_query(mysql, - "insert into t3 values (3,3), (2,2), (1,1);"); + "insert into t3 values (3, 3), (2, 2), (1, 1);"); myquery(rc); - stmt= mysql_prepare(mysql, query, strlen(query)); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); for (i= 0; i < 3; i++) { - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(3 == my_process_stmt_result(stmt)); } mysql_stmt_close(stmt); - rc= mysql_query(mysql, "DROP TABLE t1,t2,t3"); + rc= mysql_query(mysql, "DROP TABLE t1, t2, t3"); myquery(rc); } @@ -8830,65 +8657,65 @@ static void test_create_drop() char *query; int rc, i; myheader("test_table_manipulation"); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1,t2"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1, t2"); myquery(rc); - rc= mysql_query(mysql,"create table t2 (a int);"); + rc= mysql_query(mysql, "create table t2 (a int);"); myquery(rc); - rc= mysql_query(mysql,"create table t1 (a int);"); + rc= mysql_query(mysql, "create table t1 (a int);"); myquery(rc); rc= mysql_query(mysql, "insert into t2 values (3), (2), (1);"); myquery(rc); - + query= (char*)"create table t1 (a int)"; - stmt_create= mysql_prepare(mysql, query, strlen(query)); + stmt_create= mysql_simple_prepare(mysql, query); check_stmt(stmt_create); query= (char*)"drop table t1"; - stmt_drop= mysql_prepare(mysql, query, strlen(query)); + stmt_drop= mysql_simple_prepare(mysql, query); check_stmt(stmt_drop); query= (char*)"select a in (select a from t2) from t1"; - stmt_select= mysql_prepare(mysql, query, strlen(query)); + stmt_select= mysql_simple_prepare(mysql, query); check_stmt(stmt_select); - + rc= mysql_query(mysql, "DROP TABLE t1"); myquery(rc); query= (char*)"create table t1 select a from t2"; - stmt_create_select= mysql_prepare(mysql, query, strlen(query)); + stmt_create_select= mysql_simple_prepare(mysql, query); check_stmt(stmt_create_select); for (i= 0; i < 3; i++) { - rc= mysql_execute(stmt_create); + rc= mysql_stmt_execute(stmt_create); check_execute(stmt_create, rc); fprintf(stdout, "created %i\n", i); - rc= mysql_execute(stmt_select); + rc= mysql_stmt_execute(stmt_select); check_execute(stmt_select, rc); assert(0 == my_process_stmt_result(stmt_select)); - rc= mysql_execute(stmt_drop); + rc= mysql_stmt_execute(stmt_drop); check_execute(stmt_drop, rc); fprintf(stdout, "droped %i\n", i); - rc= mysql_execute(stmt_create_select); + rc= mysql_stmt_execute(stmt_create_select); check_execute(stmt_create, rc); fprintf(stdout, "created select %i\n", i); - rc= mysql_execute(stmt_select); + rc= mysql_stmt_execute(stmt_select); check_execute(stmt_select, rc); assert(3 == my_process_stmt_result(stmt_select)); - rc= mysql_execute(stmt_drop); + rc= mysql_stmt_execute(stmt_drop); check_execute(stmt_drop, rc); fprintf(stdout, "droped %i\n", i); } - + mysql_stmt_close(stmt_create); mysql_stmt_close(stmt_drop); mysql_stmt_close(stmt_select); @@ -8905,41 +8732,41 @@ static void test_rename() const char *query= "rename table t1 to t2, t3 to t4"; int rc; myheader("test_table_manipulation"); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1,t2,t3,t4"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1, t2, t3, t4"); myquery(rc); - - stmt= mysql_prepare(mysql, query, strlen(query)); + + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - rc= mysql_query(mysql,"create table t1 (a int)"); + rc= mysql_query(mysql, "create table t1 (a int)"); myquery(rc); - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute_r(stmt, rc); fprintf(stdout, "rename without t3\n"); - rc= mysql_query(mysql,"create table t3 (a int)"); + rc= mysql_query(mysql, "create table t3 (a int)"); myquery(rc); - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); fprintf(stdout, "rename with t3\n"); - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute_r(stmt, rc); fprintf(stdout, "rename renamed\n"); - rc= mysql_query(mysql,"rename table t2 to t1, t4 to t3"); + rc= mysql_query(mysql, "rename table t2 to t1, t4 to t3"); myquery(rc); - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); fprintf(stdout, "rename reverted\n"); mysql_stmt_close(stmt); - rc= mysql_query(mysql, "DROP TABLE t2,t4"); + rc= mysql_query(mysql, "DROP TABLE t2, t4"); myquery(rc); } @@ -8950,35 +8777,36 @@ static void test_do_set() char *query; int rc, i; myheader("test_do_set"); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); myquery(rc); - rc= mysql_query(mysql,"create table t1 (a int)"); + rc= mysql_query(mysql, "create table t1 (a int)"); myquery(rc); - + query= (char*)"do @var:=(1 in (select * from t1))"; - stmt_do= mysql_prepare(mysql, query, strlen(query)); + stmt_do= mysql_simple_prepare(mysql, query); check_stmt(stmt_do); query= (char*)"set @var=(1 in (select * from t1))"; - stmt_set= mysql_prepare(mysql, query, strlen(query)); + stmt_set= mysql_simple_prepare(mysql, query); check_stmt(stmt_set); for (i= 0; i < 3; i++) { - rc= mysql_execute(stmt_do); + rc= mysql_stmt_execute(stmt_do); check_execute(stmt_do, rc); fprintf(stdout, "do %i\n", i); - rc= mysql_execute(stmt_set); + rc= mysql_stmt_execute(stmt_set); check_execute(stmt_set, rc); - fprintf(stdout, "set %i\n", i); + fprintf(stdout, "set %i\n", i); } - + mysql_stmt_close(stmt_do); mysql_stmt_close(stmt_set); } + static void test_multi() { MYSQL_STMT *stmt_delete, *stmt_update, *stmt_select1, *stmt_select2; @@ -8989,61 +8817,65 @@ static void test_multi() ulong length= 1; myheader("test_multi"); + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); + bind[0].buffer_type= MYSQL_TYPE_LONG; bind[0].buffer= (char *)¶m; - bind[0].buffer_length= 0; - bind[0].is_null= 0; bind[0].length= &length; - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1, t2"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1, t2"); myquery(rc); - rc= mysql_query(mysql,"create table t1 (a int, b int)"); + rc= mysql_query(mysql, "create table t1 (a int, b int)"); myquery(rc); - rc= mysql_query(mysql,"create table t2 (a int, b int)"); + rc= mysql_query(mysql, "create table t2 (a int, b int)"); myquery(rc); - rc= mysql_query(mysql,"insert into t1 values (3,3), (2,2), (1,1)"); + rc= mysql_query(mysql, "insert into t1 values (3, 3), (2, 2), (1, 1)"); myquery(rc); - rc= mysql_query(mysql,"insert into t2 values (3,3), (2,2), (1,1)"); + rc= mysql_query(mysql, "insert into t2 values (3, 3), (2, 2), (1, 1)"); myquery(rc); - - query= (char*)"delete t1,t2 from t1,t2 where t1.a=t2.a and t1.b=10"; - stmt_delete= mysql_prepare(mysql, query, strlen(query)); + + query= (char*)"delete t1, t2 from t1, t2 where t1.a=t2.a and t1.b=10"; + stmt_delete= mysql_simple_prepare(mysql, query); check_stmt(stmt_delete); - query= (char*)"update t1,t2 set t1.b=10,t2.b=10 where t1.a=t2.a and t1.b=?"; - stmt_update= mysql_prepare(mysql, query, strlen(query)); + query= (char*)"update t1, t2 set t1.b=10, t2.b=10 where t1.a=t2.a and t1.b=?"; + stmt_update= mysql_simple_prepare(mysql, query); check_stmt(stmt_update); query= (char*)"select * from t1"; - stmt_select1= mysql_prepare(mysql, query, strlen(query)); + stmt_select1= mysql_simple_prepare(mysql, query); check_stmt(stmt_select1); query= (char*)"select * from t2"; - stmt_select2= mysql_prepare(mysql, query, strlen(query)); + stmt_select2= mysql_simple_prepare(mysql, query); check_stmt(stmt_select2); for(i= 0; i < 3; i++) { - rc= mysql_bind_param(stmt_update, bind); - check_execute(stmt_update,rc); + rc= mysql_stmt_bind_param(stmt_update, bind); + check_execute(stmt_update, rc); - rc= mysql_execute(stmt_update); + rc= mysql_stmt_execute(stmt_update); check_execute(stmt_update, rc); fprintf(stdout, "update %ld\n", param); - - rc= mysql_execute(stmt_delete); + + rc= mysql_stmt_execute(stmt_delete); check_execute(stmt_delete, rc); fprintf(stdout, "delete %ld\n", param); - rc= mysql_execute(stmt_select1); + rc= mysql_stmt_execute(stmt_select1); check_execute(stmt_select1, rc); assert((uint)(3-param) == my_process_stmt_result(stmt_select1)); - rc= mysql_execute(stmt_select2); + rc= mysql_stmt_execute(stmt_select2); check_execute(stmt_select2, rc); assert((uint)(3-param) == my_process_stmt_result(stmt_select2)); @@ -9054,7 +8886,7 @@ static void test_multi() mysql_stmt_close(stmt_update); mysql_stmt_close(stmt_select1); mysql_stmt_close(stmt_select2); - rc= mysql_query(mysql,"drop table t1,t2"); + rc= mysql_query(mysql, "drop table t1, t2"); myquery(rc); } @@ -9067,40 +8899,40 @@ static void test_insert_select() uint i; myheader("test_insert_select"); - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1, t2"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1, t2"); myquery(rc); - rc= mysql_query(mysql,"create table t1 (a int)"); + rc= mysql_query(mysql, "create table t1 (a int)"); myquery(rc); - rc= mysql_query(mysql,"create table t2 (a int)"); + rc= mysql_query(mysql, "create table t2 (a int)"); myquery(rc); - rc= mysql_query(mysql,"insert into t2 values (1)"); + rc= mysql_query(mysql, "insert into t2 values (1)"); myquery(rc); - + query= (char*)"insert into t1 select a from t2"; - stmt_insert= mysql_prepare(mysql, query, strlen(query)); + stmt_insert= mysql_simple_prepare(mysql, query); check_stmt(stmt_insert); query= (char*)"select * from t1"; - stmt_select= mysql_prepare(mysql, query, strlen(query)); + stmt_select= mysql_simple_prepare(mysql, query); check_stmt(stmt_select); for(i= 0; i < 3; i++) { - rc= mysql_execute(stmt_insert); + rc= mysql_stmt_execute(stmt_insert); check_execute(stmt_insert, rc); fprintf(stdout, "insert %u\n", i); - - rc= mysql_execute(stmt_select); + + rc= mysql_stmt_execute(stmt_select); check_execute(stmt_select, rc); assert((i+1) == my_process_stmt_result(stmt_select)); } mysql_stmt_close(stmt_insert); mysql_stmt_close(stmt_select); - rc= mysql_query(mysql,"drop table t1,t2"); + rc= mysql_query(mysql, "drop table t1, t2"); myquery(rc); } @@ -9111,79 +8943,87 @@ static void test_bind_nagative() char *query; int rc; MYSQL_BIND bind[1]; - long my_val = 0L; - ulong my_length = 0L; - long my_null = 0L; + long my_val= 0L; + ulong my_length= 0L; + long my_null= 0L; myheader("test_insert_select"); - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); myquery(rc); - rc= mysql_query(mysql,"create temporary table t1 (c1 int unsigned)"); + rc= mysql_query(mysql, "create temporary table t1 (c1 int unsigned)"); myquery(rc); - rc= mysql_query(mysql,"INSERT INTO t1 VALUES (1),(-1)"); + rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1), (-1)"); myquery(rc); query= (char*)"INSERT INTO t1 VALUES (?)"; - stmt_insert= mysql_prepare(mysql, query, strlen(query)); + stmt_insert= mysql_simple_prepare(mysql, query); check_stmt(stmt_insert); /* bind parameters */ - bind[0].buffer_type = FIELD_TYPE_LONG; - bind[0].buffer = (char *)&my_val; - bind[0].length = &my_length; - bind[0].is_null = (char*)&my_null; + bzero((char*) bind, sizeof(bind)); + + bind[0].buffer_type= MYSQL_TYPE_LONG; + bind[0].buffer= (char *)&my_val; + bind[0].length= &my_length; + bind[0].is_null= (char*)&my_null; - rc= mysql_bind_param(stmt_insert, bind); - check_execute(stmt_insert,rc); + rc= mysql_stmt_bind_param(stmt_insert, bind); + check_execute(stmt_insert, rc); - my_val = -1; - rc= mysql_execute(stmt_insert); + my_val= -1; + rc= mysql_stmt_execute(stmt_insert); check_execute(stmt_insert, rc); mysql_stmt_close(stmt_insert); - rc= mysql_query(mysql,"drop table t1"); + rc= mysql_query(mysql, "drop table t1"); myquery(rc); } + static void test_derived() { MYSQL_STMT *stmt; int rc, i; MYSQL_BIND bind[1]; - long my_val = 0L; - ulong my_length = 0L; - long my_null = 0L; + long my_val= 0L; + ulong my_length= 0L; + long my_null= 0L; const char *query= "select count(1) from (select f.id from t1 f where f.id=?) as x"; myheader("test_derived"); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); myquery(rc); - - rc= mysql_query(mysql,"create table t1 (id int(8), primary key (id)) \ + + rc= mysql_query(mysql, "create table t1 (id int(8), primary key (id)) \ TYPE=InnoDB DEFAULT CHARSET=utf8"); myquery(rc); rc= mysql_query(mysql, "insert into t1 values (1)"); myquery(rc); - stmt= mysql_prepare(mysql, query, strlen(query)); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); - bind[0].buffer_type = FIELD_TYPE_LONG; - bind[0].buffer = (char *)&my_val; - bind[0].length = &my_length; - bind[0].is_null = (char*)&my_null; + bind[0].buffer_type= MYSQL_TYPE_LONG; + bind[0].buffer= (char *)&my_val; + bind[0].length= &my_length; + bind[0].is_null= (char*)&my_null; my_val= 1; - rc= mysql_bind_param(stmt, bind); - check_execute(stmt,rc); + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); for (i= 0; i < 3; i++) { - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(1 == my_process_stmt_result(stmt)); } @@ -9199,52 +9039,53 @@ static void test_xjoin() MYSQL_STMT *stmt; int rc, i; const char *query= - "select t.id,p1.value, n1.value, p2.value, n2.value from t3 t LEFT JOIN t1 p1 ON (p1.id=t.param1_id) LEFT JOIN t2 p2 ON (p2.id=t.param2_id) LEFT JOIN t4 n1 ON (n1.id=p1.name_id) LEFT JOIN t4 n2 ON (n2.id=p2.name_id) where t.id=1"; + "select t.id, p1.value, n1.value, p2.value, n2.value from t3 t LEFT JOIN t1 p1 ON (p1.id=t.param1_id) LEFT JOIN t2 p2 ON (p2.id=t.param2_id) LEFT JOIN t4 n1 ON (n1.id=p1.name_id) LEFT JOIN t4 n2 ON (n2.id=p2.name_id) where t.id=1"; myheader("test_xjoin"); - - rc = mysql_query(mysql, "DROP TABLE IF EXISTS t1,t2,t3,t4"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1, t2, t3, t4"); myquery(rc); - - rc= mysql_query(mysql,"create table t3 (id int(8), param1_id int(8), param2_id int(8)) TYPE=InnoDB DEFAULT CHARSET=utf8"); + + rc= mysql_query(mysql, "create table t3 (id int(8), param1_id int(8), param2_id int(8)) TYPE=InnoDB DEFAULT CHARSET=utf8"); myquery(rc); - - rc= mysql_query(mysql,"create table t1 ( id int(8), name_id int(8), value varchar(10)) TYPE=InnoDB DEFAULT CHARSET=utf8"); + + rc= mysql_query(mysql, "create table t1 ( id int(8), name_id int(8), value varchar(10)) TYPE=InnoDB DEFAULT CHARSET=utf8"); myquery(rc); - rc= mysql_query(mysql,"create table t2 (id int(8), name_id int(8), value varchar(10)) TYPE=InnoDB DEFAULT CHARSET=utf8;"); + rc= mysql_query(mysql, "create table t2 (id int(8), name_id int(8), value varchar(10)) TYPE=InnoDB DEFAULT CHARSET=utf8;"); myquery(rc); - rc= mysql_query(mysql,"create table t4(id int(8), value varchar(10)) TYPE=InnoDB DEFAULT CHARSET=utf8"); + rc= mysql_query(mysql, "create table t4(id int(8), value varchar(10)) TYPE=InnoDB DEFAULT CHARSET=utf8"); myquery(rc); - rc= mysql_query(mysql, "insert into t3 values (1,1,1),(2,2,null)"); + rc= mysql_query(mysql, "insert into t3 values (1, 1, 1), (2, 2, null)"); myquery(rc); - - rc= mysql_query(mysql, "insert into t1 values (1,1,'aaa'),(2,null,'bbb')"); + + rc= mysql_query(mysql, "insert into t1 values (1, 1, 'aaa'), (2, null, 'bbb')"); myquery(rc); - rc= mysql_query(mysql,"insert into t2 values (1,2,'ccc')"); + rc= mysql_query(mysql, "insert into t2 values (1, 2, 'ccc')"); myquery(rc); - rc= mysql_query(mysql, "insert into t4 values (1,'Name1'),(2,null)"); + rc= mysql_query(mysql, "insert into t4 values (1, 'Name1'), (2, null)"); myquery(rc); - stmt= mysql_prepare(mysql, query, strlen(query)); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); for (i= 0; i < 3; i++) { - rc= mysql_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); assert(1 == my_process_stmt_result(stmt)); } mysql_stmt_close(stmt); - rc= mysql_query(mysql, "DROP TABLE t1,t2,t3,t4"); + rc= mysql_query(mysql, "DROP TABLE t1, t2, t3, t4"); myquery(rc); } + static void test_bug3035() { MYSQL_STMT *stmt; @@ -9259,14 +9100,14 @@ static void test_bug3035() longlong int64_val; ulonglong uint64_val; double double_val, udouble_val; - char longlong_as_string[22],ulonglong_as_string[22]; + char longlong_as_string[22], ulonglong_as_string[22]; /* mins and maxes */ const int8 int8_min= -128; const int8 int8_max= 127; const uint8 uint8_min= 0; const uint8 uint8_max= 255; - + const int16 int16_min= -32768; const int16 int16_max= 32767; const uint16 uint16_min= 0; @@ -9283,11 +9124,11 @@ static void test_bug3035() const ulonglong uint64_min= 0U; const ulonglong uint64_max= ULL(18446744073709551615); - + const char *stmt_text; - + myheader("test_bug3035"); - + stmt_text= "DROP TABLE IF EXISTS t1"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); @@ -9311,7 +9152,7 @@ static void test_bug3035() bind_array[2].buffer_type= MYSQL_TYPE_SHORT; bind_array[2].buffer= (char*) &int16_val; - + bind_array[3].buffer_type= MYSQL_TYPE_SHORT; bind_array[3].buffer= (char*) &uint16_val; bind_array[3].is_unsigned= 1; @@ -9325,7 +9166,7 @@ static void test_bug3035() bind_array[6].buffer_type= MYSQL_TYPE_LONGLONG; bind_array[6].buffer= (char*) &int64_val; - + bind_array[7].buffer_type= MYSQL_TYPE_LONGLONG; bind_array[7].buffer= (char*) &uint64_val; bind_array[7].is_unsigned= 1; @@ -9351,7 +9192,7 @@ static void test_bug3035() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - + int8_val= int8_max; uint8_val= uint8_max; int16_val= int16_max; @@ -9365,7 +9206,7 @@ static void test_bug3035() check_execute(stmt, rc); stmt_text= "SELECT i8, ui8, i16, ui16, i32, ui32, i64, ui64, ui64, " - "cast(ui64 as signed),ui64, cast(ui64 as signed)" + "cast(ui64 as signed), ui64, cast(ui64 as signed)" "FROM t1 ORDER BY id ASC"; rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); @@ -9387,7 +9228,7 @@ static void test_bug3035() bind_array[11].buffer_type= MYSQL_TYPE_STRING; bind_array[11].buffer= (char*) &longlong_as_string; bind_array[11].buffer_length= sizeof(longlong_as_string); - + mysql_stmt_bind_result(stmt, bind_array); rc= mysql_stmt_fetch(stmt); @@ -9408,7 +9249,7 @@ static void test_bug3035() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - + assert(int8_val == int8_max); assert(uint8_val == uint8_max); assert(int16_val == int16_max); @@ -9423,7 +9264,7 @@ static void test_bug3035() assert(!strcmp(ulonglong_as_string, "18446744073709551615")); rc= mysql_stmt_fetch(stmt); - assert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); @@ -9431,31 +9272,32 @@ static void test_bug3035() mysql_real_query(mysql, stmt_text, strlen(stmt_text)); } + static void test_union2() { MYSQL_STMT *stmt; int rc, i; myheader("test_union2"); - + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); myquery(rc); - rc= mysql_query(mysql,"CREATE TABLE t1(col1 INT,\ - col2 VARCHAR(40), \ - col3 SMALLINT,\ + rc= mysql_query(mysql, "CREATE TABLE t1(col1 INT, \ + col2 VARCHAR(40), \ + col3 SMALLINT, \ col4 TIMESTAMP)"); myquery(rc); stmt= mysql_simple_prepare(mysql, - "select col1 FROM t1 where col1=1 union distinct \ -select col1 FROM t1 where col1=2"); + "select col1 FROM t1 where col1=1 union distinct " + "select col1 FROM t1 where col1=2"); check_stmt(stmt); for (i= 0; i < 3; i++) { rc= mysql_stmt_execute(stmt); - check_execute(stmt,rc); + check_execute(stmt, rc); assert(0 == my_process_stmt_result(stmt)); } @@ -9467,7 +9309,7 @@ select col1 FROM t1 where col1=2"); /* - This tests for various mysql_send_long_data bugs described in #1664 + This tests for various mysql_stmt_send_long_data bugs described in #1664 */ static void test_bug1664() @@ -9477,54 +9319,54 @@ static void test_bug1664() const char *data; const char *str_data= "Simple string"; MYSQL_BIND bind[2]; - const char *query= "INSERT INTO test_long_data(col2, col1) VALUES(?,?)"; - + const char *query= "INSERT INTO test_long_data(col2, col1) VALUES(?, ?)"; + myheader("test_bug1664"); - - rc= mysql_query(mysql,"DROP TABLE IF EXISTS test_long_data"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_long_data"); myquery(rc); - - rc= mysql_query(mysql,"CREATE TABLE test_long_data(col1 int, col2 long varchar)"); + + rc= mysql_query(mysql, "CREATE TABLE test_long_data(col1 int, col2 long varchar)"); myquery(rc); - + stmt= mysql_stmt_init(mysql); check_stmt(stmt); rc= mysql_stmt_prepare(stmt, query, strlen(query)); check_execute(stmt, rc); - + verify_param_count(stmt, 2); - + bzero(&bind, sizeof(bind)); - - bind[0].buffer_type= FIELD_TYPE_STRING; + + bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer= (char *)str_data; bind[0].buffer_length= strlen(str_data); bind[1].buffer= (char *)&int_data; - bind[1].buffer_type= FIELD_TYPE_LONG; - - rc= mysql_stmt_bind_param(stmt,bind); + bind[1].buffer_type= MYSQL_TYPE_LONG; + + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - + int_data= 1; - /* - Let us supply empty long_data. This should work and should + /* + Let us supply empty long_data. This should work and should not break following execution. */ data= ""; - rc= mysql_stmt_send_long_data(stmt,0,data,strlen(data)); - check_execute(stmt,rc); + rc= mysql_stmt_send_long_data(stmt, 0, data, strlen(data)); + check_execute(stmt, rc); rc= mysql_stmt_execute(stmt); - check_execute(stmt,rc); - - verify_col_data("test_long_data","col1","1"); - verify_col_data("test_long_data","col2",""); + check_execute(stmt, rc); - rc= mysql_query(mysql,"DELETE FROM test_long_data"); + verify_col_data("test_long_data", "col1", "1"); + verify_col_data("test_long_data", "col2", ""); + + rc= mysql_query(mysql, "DELETE FROM test_long_data"); myquery(rc); - + /* This should pass OK */ data= (char *)"Data"; rc= mysql_stmt_send_long_data(stmt, 0, data, strlen(data)); @@ -9532,7 +9374,7 @@ static void test_bug1664() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - + verify_col_data("test_long_data", "col1", "1"); verify_col_data("test_long_data", "col2", "Data"); @@ -9542,51 +9384,51 @@ static void test_bug1664() /* Now we are changing int parameter and don't do anything - with first parameter. Second mysql_execute() should run + with first parameter. Second mysql_stmt_execute() should run OK treating this first parameter as string parameter. */ - + int_data= 2; /* execute */ - rc = mysql_stmt_execute(stmt); + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - + verify_col_data("test_long_data", "col1", "2"); verify_col_data("test_long_data", "col2", str_data); /* clean up */ rc= mysql_query(mysql, "DELETE FROM test_long_data"); myquery(rc); - + /* - Now we are sending other long data. It should not be + Now we are sending other long data. It should not be concatened to previous. */ data= (char *)"SomeOtherData"; rc= mysql_stmt_send_long_data(stmt, 0, data, strlen(data)); check_execute(stmt, rc); - + rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); verify_col_data("test_long_data", "col1", "2"); verify_col_data("test_long_data", "col2", "SomeOtherData"); - + mysql_stmt_close(stmt); /* clean up */ rc= mysql_query(mysql, "DELETE FROM test_long_data"); myquery(rc); - + /* Now let us test how mysql_stmt_reset works. */ stmt= mysql_stmt_init(mysql); check_stmt(stmt); rc= mysql_stmt_prepare(stmt, query, strlen(query)); check_execute(stmt, rc); - rc= mysql_bind_param(stmt, bind); + rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); - + data= (char *)"SomeData"; rc= mysql_stmt_send_long_data(stmt, 0, data, strlen(data)); check_execute(stmt, rc); @@ -9596,12 +9438,12 @@ static void test_bug1664() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - + verify_col_data("test_long_data", "col1", "2"); verify_col_data("test_long_data", "col2", str_data); mysql_stmt_close(stmt); - + /* Final clean up */ rc= mysql_query(mysql, "DROP TABLE test_long_data"); myquery(rc); @@ -9614,35 +9456,31 @@ static void test_order_param() int rc; myheader("test_order_param"); - + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); myquery(rc); - rc= mysql_query(mysql,"CREATE TABLE t1(a INT, b char(10))"); + rc= mysql_query(mysql, "CREATE TABLE t1(a INT, b char(10))"); myquery(rc); stmt= mysql_simple_prepare(mysql, - "select sum(a) + 200, 1 from t1 \ -union distinct \ -select sum(a) + 200, 1 from t1 \ -group by b "); + "select sum(a) + 200, 1 from t1 " + " union distinct " + "select sum(a) + 200, 1 from t1 group by b "); check_stmt(stmt); mysql_stmt_close(stmt); - stmt= mysql_simple_prepare(mysql, - "select sum(a) + 200, ? from t1 \ -group by b \ -union distinct \ -select sum(a) + 200, 1 from t1 \ -group by b "); + stmt= mysql_simple_prepare(mysql, + "select sum(a) + 200, ? from t1 group by b " + " union distinct " + "select sum(a) + 200, 1 from t1 group by b "); check_stmt(stmt); mysql_stmt_close(stmt); stmt= mysql_simple_prepare(mysql, - "select sum(a) + 200, ? from t1 \ -union distinct \ -select sum(a) + 200, 1 from t1 \ -group by b "); + "select sum(a) + 200, ? from t1 " + " union distinct " + "select sum(a) + 200, 1 from t1 group by b "); check_stmt(stmt); mysql_stmt_close(stmt); @@ -9658,35 +9496,41 @@ static void test_union_param() int rc, i; MYSQL_BIND bind[2]; char my_val[4]; - ulong my_length = 3L; - long my_null = 0L; + ulong my_length= 3L; + long my_null= 0L; myheader("test_union_param"); strcpy(my_val, "abc"); - + query= (char*)"select ? as my_col union distinct select ?"; - stmt= mysql_prepare(mysql, query, strlen(query)); + stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); + /* + We need to bzero bind structure because mysql_stmt_bind_param checks all + its members. + */ + bzero((char*) bind, sizeof(bind)); + /* bind parameters */ - bind[0].buffer_type= FIELD_TYPE_STRING; + bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer= (char*) &my_val; bind[0].buffer_length= 4; bind[0].length= &my_length; bind[0].is_null= (char*)&my_null; - bind[1].buffer_type= FIELD_TYPE_STRING; + bind[1].buffer_type= MYSQL_TYPE_STRING; bind[1].buffer= (char*) &my_val; bind[1].buffer_length= 4; bind[1].length= &my_length; bind[1].is_null= (char*)&my_null; - rc= mysql_bind_param(stmt, bind); - check_execute(stmt,rc); + rc= mysql_stmt_bind_param(stmt, bind); + check_execute(stmt, rc); for (i= 0; i < 3; i++) { rc= mysql_stmt_execute(stmt); - check_execute(stmt,rc); + check_execute(stmt, rc); assert(1 == my_process_stmt_result(stmt)); } @@ -9716,31 +9560,31 @@ static void test_ps_i18n() /* Create table with binary columns, set session character set to cp1251, client character set to koi8, and make sure that there is conversion - on insert and no conversion on select + on insert and no conversion on select */ stmt_text= "CREATE TABLE t1 (c1 VARBINARY(255), c2 VARBINARY(255))"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); - + stmt_text= "SET CHARACTER_SET_CLIENT=koi8r, " "CHARACTER_SET_CONNECTION=cp1251, " "CHARACTER_SET_RESULTS=koi8r"; - + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); - + bzero(bind_array, sizeof(bind_array)); bind_array[0].buffer_type= MYSQL_TYPE_STRING; bind_array[0].buffer= (char*) koi8; bind_array[0].buffer_length= strlen(koi8); - + bind_array[1].buffer_type= MYSQL_TYPE_STRING; bind_array[1].buffer= (char*) koi8; bind_array[1].buffer_length= strlen(koi8); - + stmt= mysql_stmt_init(mysql); check_stmt(stmt); @@ -9784,7 +9628,7 @@ static void test_ps_i18n() assert(!memcmp(buf2, cp1251, buf1_len)); rc= mysql_stmt_fetch(stmt); - assert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); stmt_text= "DROP TABLE IF EXISTS t1"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); @@ -9796,23 +9640,23 @@ static void test_ps_i18n() binary data. Binary data must not be converted on insert, and both columns must be converted to client character set on select. */ - + stmt_text= "CREATE TABLE t1 (c1 VARCHAR(255) CHARACTER SET cp1251, " "c2 VARCHAR(255) CHARACTER SET cp1251)"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); - + stmt_text= "INSERT INTO t1 (c1, c2) VALUES (?, ?)"; rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); check_execute(stmt, rc); - + /* this data must be converted */ bind_array[0].buffer_type= MYSQL_TYPE_STRING; bind_array[0].buffer= (char*) koi8; bind_array[0].buffer_length= strlen(koi8); - + bind_array[1].buffer_type= MYSQL_TYPE_STRING; bind_array[1].buffer= (char*) koi8; bind_array[1].buffer_length= strlen(koi8); @@ -9823,16 +9667,16 @@ static void test_ps_i18n() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - + /* this data must not be converted */ bind_array[0].buffer_type= MYSQL_TYPE_BLOB; bind_array[0].buffer= (char*) cp1251; bind_array[0].buffer_length= strlen(cp1251); - + bind_array[1].buffer_type= MYSQL_TYPE_BLOB; bind_array[1].buffer= (char*) cp1251; bind_array[1].buffer_length= strlen(cp1251); - + mysql_stmt_bind_param(stmt, bind_array); mysql_stmt_send_long_data(stmt, 0, cp1251, strlen(cp1251)); @@ -9841,7 +9685,7 @@ static void test_ps_i18n() check_execute(stmt, rc); /* Fetch data and verify that rows are in koi8 */ - + stmt_text= "SELECT c1, c2 FROM t1"; /* c1 and c2 are binary so no conversion will be done on select */ @@ -9868,7 +9712,7 @@ static void test_ps_i18n() assert(!memcmp(buf1, koi8, buf1_len)); assert(!memcmp(buf2, koi8, buf1_len)); } - assert(rc == MYSQL_NO_DATA); + assert(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); stmt_text= "DROP TABLE t1"; @@ -9891,7 +9735,7 @@ static void test_bug3796() ulong out_length; const char *stmt_text; int rc; - + myheader("test_bug3796"); /* Create and fill test table */ @@ -9902,25 +9746,25 @@ static void test_bug3796() stmt_text= "CREATE TABLE t1 (a INT, b VARCHAR(30))"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); - - stmt_text= "INSERT INTO t1 VALUES(1,'ONE'), (2,'TWO')"; + + stmt_text= "INSERT INTO t1 VALUES(1, 'ONE'), (2, 'TWO')"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); /* Create statement handle and prepare it with select */ - stmt = mysql_stmt_init(mysql); + stmt= mysql_stmt_init(mysql); stmt_text= "SELECT concat(?, b) FROM t1"; rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); check_execute(stmt, rc); - + /* Bind input buffers */ bzero(bind, sizeof(bind)); bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer= (char*) concat_arg0; bind[0].buffer_length= strlen(concat_arg0); - + mysql_stmt_bind_param(stmt, bind); /* Execute the select statement */ @@ -9947,7 +9791,7 @@ static void test_bug3796() assert(strlen(canonical_buff) == out_length && strncmp(out_buff, canonical_buff, out_length) == 0); printf("Concat result: '%s'\n", out_buff); - + rc= mysql_stmt_fetch(stmt); assert(rc == MYSQL_NO_DATA); @@ -9994,7 +9838,7 @@ static struct my_option client_test_long_options[] = static void client_test_print_version(void) { fprintf(stdout, "%s Distrib %s, for %s (%s)\n\n", - my_progname,MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); + my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); } @@ -10002,18 +9846,18 @@ static void usage(void) { /* * show the usage string when the user asks for this - */ - putc('\n',stdout); + */ + putc('\n', stdout); puts("***********************************************************************\n"); puts(" Test for client-server protocol 4.1"); puts(" By Monty & Venu \n"); - puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,"); + puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software, "); puts("and you are welcome to modify and redistribute it under the GPL license\n"); puts(" Copyright (C) 1995-2003 MySQL AB "); puts("-----------------------------------------------------------------------\n"); client_test_print_version(); - fprintf(stdout,"Usage: %s [OPTIONS]\n\n", my_progname); - + fprintf(stdout, "Usage: %s [OPTIONS]\n\n", my_progname); + my_print_help(client_test_long_options); print_defaults("my", client_test_load_default_groups); my_print_variables(client_test_long_options); @@ -10023,7 +9867,7 @@ static void usage(void) static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), - char *argument) + char *argument) { switch (optid) { case '#': @@ -10035,7 +9879,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *start=argument; my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR)); opt_password= my_strdup(argument, MYF(MY_FAE)); - while (*argument) *argument++= 'x'; /* Destroy argument */ + while (*argument) *argument++= 'x'; /* Destroy argument */ if (*start) start[1]=0; } @@ -10043,7 +9887,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), tty_password= 1; break; case '?': - case 'I': /* Info */ + case 'I': /* Info */ usage(); exit(0); break; @@ -10055,12 +9899,12 @@ static void get_options(int argc, char **argv) { int ho_error; - if ((ho_error= handle_options(&argc, &argv, client_test_long_options, + if ((ho_error= handle_options(&argc, &argv, client_test_long_options, get_one_option))) exit(ho_error); if (tty_password) - opt_password=get_tty_password(NullS); + opt_password= get_tty_password(NullS); return; } @@ -10070,49 +9914,51 @@ static void get_options(int argc, char **argv) static void print_test_output() { - fprintf(stdout,"\n\n"); - fprintf(stdout,"All '%d' tests were successful (in '%d' iterations)", + fprintf(stdout, "\n\n"); + fprintf(stdout, "All '%d' tests were successful (in '%d' iterations)", test_count-1, opt_count); - fprintf(stdout,"\n Total execution time: %g SECS", total_time); + fprintf(stdout, "\n Total execution time: %g SECS", total_time); if (opt_count > 1) - fprintf(stdout," (Avg: %g SECS)", total_time/opt_count); - - fprintf(stdout,"\n\n!!! SUCCESS !!!\n"); + fprintf(stdout, " (Avg: %g SECS)", total_time/opt_count); + + fprintf(stdout, "\n\n!!! SUCCESS !!!\n"); } -/******************************************************** -* main routine * -*********************************************************/ + +/*************************************************************************** + main routine +***************************************************************************/ + int main(int argc, char **argv) -{ +{ DEBUGGER_OFF; MY_INIT(argv[0]); - load_defaults("my",client_test_load_default_groups,&argc,&argv); + load_defaults("my", client_test_load_default_groups, &argc, &argv); defaults_argv= argv; - get_options(argc,argv); - + get_options(argc, argv); + client_connect(); /* connect to server */ - + total_time= 0; - for (iter_count=1; iter_count <= opt_count; iter_count++) + for (iter_count= 1; iter_count <= opt_count; iter_count++) { /* Start of tests */ test_count= 1; - + start_time= time((time_t *)0); client_query(); /* simple client query test */ #if NOT_YET_WORKING /* Used for internal new development debugging */ - test_drop_temp(); /* to test DROP TEMPORARY TABLE Access checks */ + test_drop_temp(); /* Test DROP TEMPORARY TABLE Access checks */ #endif - test_fetch_seek(); /* to test stmt seek() functions */ + test_fetch_seek(); /* Test stmt seek() functions */ test_fetch_nobuffs(); /* to fecth without prior bound buffers */ test_open_direct(); /* direct execution in the middle of open stmts */ test_fetch_null(); /* to fetch null data */ test_ps_null_param(); /* Fetch value of null parameter */ - test_fetch_date(); /* to fetch date,time and timestamp */ + test_fetch_date(); /* to fetch date, time and timestamp */ test_fetch_str(); /* to fetch string to all types */ test_fetch_long(); /* to fetch long to all types */ test_fetch_short(); /* to fetch short to all types */ @@ -10129,12 +9975,12 @@ int main(int argc, char **argv) test_ps_conj_select(); /* prepare select with "where a=? or b=?" */ test_select_show_table();/* simple show prepare */ #if NOT_USED - /* - Enable this tests from 4.1.1 when mysql_param_result() is - supported + /* + Enable this tests from 4.1.1 when mysql_param_result() is + supported */ test_select_meta(); /* select param meta information */ - test_update_meta(); /* update param meta information */ + test_update_meta(); /* update param meta information */ test_insert_meta(); /* insert param meta information */ #endif test_func_fields(); /* test for new 4.1 MYSQL_FIELD members */ @@ -10143,21 +9989,21 @@ int main(int argc, char **argv) test_set_variable(); /* prepare with set variables */ test_select_show(); /* prepare - show test */ test_prepare_noparam(); /* prepare without parameters */ - test_bind_result(); /* result bind test */ - test_prepare_simple(); /* simple prepare */ + test_bind_result(); /* result bind test */ + test_prepare_simple(); /* simple prepare */ test_prepare(); /* prepare test */ test_null(); /* test null data handling */ test_debug_example(); /* some debugging case */ test_update(); /* prepare-update test */ test_simple_update(); /* simple prepare with update */ test_simple_delete(); /* prepare with delete */ - test_double_compare(); /* float comparision */ + test_double_compare(); /* float comparision */ client_store_result(); /* usage of mysql_store_result() */ - client_use_result(); /* usage of mysql_use_result() */ + client_use_result(); /* usage of mysql_use_result() */ test_tran_bdb(); /* transaction test on BDB table type */ - test_tran_innodb(); /* transaction test on InnoDB table type */ + test_tran_innodb(); /* transaction test on InnoDB table type */ test_prepare_ext(); /* test prepare with all types - conversion -- TODO */ + conversion -- TODO */ test_prepare_syntax(); /* syntax check for prepares */ test_field_names(); /* test for field names */ test_field_flags(); /* test to help .NET provider team */ @@ -10171,7 +10017,7 @@ int main(int argc, char **argv) test_prepare_field_result(); /* prepare meta info */ test_multi_stmt(); /* multi stmt test */ test_multi_statements();/* test multi statement execution */ - test_prepare_multi_statements(); /* check that multi statements are + test_prepare_multi_statements(); /* check that multi statements are disabled in PS */ test_store_result(); /* test the store_result */ test_store_result1(); /* test store result without buffers */ @@ -10189,72 +10035,76 @@ int main(int argc, char **argv) test_ushort_bug(); /* test a simple conv bug from php */ test_sshort_bug(); /* test a simple conv bug from php */ test_stiny_bug(); /* test a simple conv bug from php */ - test_field_misc(); /* check the field info for misc case, bug: #74 */ + test_field_misc(); /* check the field info for misc case, bug: #74 */ test_set_option(); /* test the SET OPTION feature, bug #85 */ /*TODO HF: here should be NO_EMBEDDED_ACCESS_CHECKS*/ #ifndef EMBEDDED_LIBRARY - test_prepare_grant(); /* to test the GRANT command, bug #89 */ + test_prepare_grant(); /* Test the GRANT command, bug #89 */ #endif test_frm_bug(); /* test the crash when .frm is invalid, bug #93 */ test_explain_bug(); /* test for the EXPLAIN, bug #115 */ test_decimal_bug(); /* test for the decimal bug */ test_nstmts(); /* test n statements */ - test_logs(); ; /* to test logs */ - test_cuted_rows(); /* to test for WARNINGS from cuted rows */ - test_fetch_offset(); /* to test mysql_fetch_column with offset */ - test_fetch_column(); /* to test mysql_fetch_column */ + test_logs(); ; /* Test logs */ + test_cuted_rows(); /* Test for WARNINGS from cuted rows */ + test_fetch_offset(); /* Test mysql_stmt_fetch_column with offset */ + test_fetch_column(); /* Test mysql_stmt_fetch_column */ test_mem_overun(); /* test DBD ovverun bug */ test_list_fields(); /* test COM_LIST_FIELDS for DEFAULT */ test_free_result(); /* test mysql_stmt_free_result() */ - test_free_store_result(); /* test to make sure stmt results are cleared + test_free_store_result(); /* test to make sure stmt results are cleared during stmt_free_result() */ test_sqlmode(); /* test for SQL_MODE */ test_ts(); /* test for timestamp BR#819 */ test_bug1115(); /* BUG#1115 */ test_bug1180(); /* BUG#1180 */ test_bug1500(); /* BUG#1500 */ - test_bug1644(); /* BUG#1644 */ - test_bug1946(); /* test that placeholders are allowed only in + test_bug1644(); /* BUG#1644 */ + test_bug1946(); /* test that placeholders are allowed only in prepared queries */ - test_bug2248(); /* BUG#2248 */ + test_bug2248(); /* BUG#2248 */ test_parse_error_and_bad_length(); /* test if bad length param in - mysql_prepare() triggers error */ + mysql_stmt_prepare() triggers error */ test_bug2247(); /* test that mysql_stmt_affected_rows() returns - number of rows affected by last prepared + number of rows affected by last prepared statement execution */ - test_subqueries(); /* repeatable subqueries */ + test_subqueries(); /* repeatable subqueries */ test_bad_union(); /* correct setup of UNION */ - test_distinct(); /* distinct aggregate functions */ + test_distinct(); /* distinct aggregate functions */ test_subqueries_ref(); /* outer reference in subqueries converted - Item_field -> Item_ref */ - test_union(); /* test union with prepared statements */ - test_bug3117(); /* BUG#3117: LAST_INSERT_ID() */ - test_join(); /* different kinds of join, BUG#2794 */ - test_selecttmp(); /* temporary table used in select execution */ - test_create_drop(); /* some table manipulation BUG#2811 */ - test_rename(); /* rename test */ - test_do_set(); /* DO & SET commands test BUG#3393 */ - test_multi(); /* test of multi delete & update */ + Item_field -> Item_ref */ + test_union(); /* test union with prepared statements */ + test_bug3117(); /* BUG#3117: LAST_INSERT_ID() */ + test_join(); /* different kinds of join, BUG#2794 */ + test_selecttmp(); /* temporary table used in select execution */ + test_create_drop(); /* some table manipulation BUG#2811 */ + test_rename(); /* rename test */ + test_do_set(); /* DO & SET commands test BUG#3393 */ + test_multi(); /* test of multi delete & update */ test_insert_select(); /* test INSERT ... SELECT */ test_bind_nagative(); /* bind negative to unsigned BUG#3223 */ - test_derived(); /* derived table with parameter BUG#3020 */ - test_xjoin(); /* complex join test */ + test_derived(); /* derived table with parameter BUG#3020 */ + test_xjoin(); /* complex join test */ test_bug3035(); /* inserts of INT32_MAX/UINT32_MAX */ - test_union2(); /* repeatable execution of union (Bug #3577) */ - test_bug1664(); /* test for bugs in mysql_stmt_send_long_data() + test_union2(); /* repeatable execution of union (Bug #3577) */ + test_bug1664(); /* test for bugs in mysql_stmt_send_long_data() call (Bug #1664) */ test_union_param(); - test_order_param(); /* ORDER BY with parameters in select list - (Bug #3686 */ + test_order_param(); /* ORDER BY with parameters in select list + (Bug #3686 */ test_ps_i18n(); /* test for i18n support in binary protocol */ test_bug3796(); /* test for select concat(?, <string>) */ + /* + XXX: PLEASE RUN THIS PROGRAM UNDER VALGRIND AND VERIFY THAT YOUR TEST + DOESN'T CONTAIN WARNINGS/ERRORS BEFORE YOU PUSH. + */ end_time= time((time_t *)0); total_time+= difftime(end_time, start_time); - + /* End of tests */ } - + client_disconnect(); /* disconnect from server */ free_defaults(defaults_argv); print_test_output(); @@ -10262,3 +10112,4 @@ int main(int argc, char **argv) return(0); } + |