Commit 5fa224b6 authored by unknown's avatar unknown

Remove bind_length + Fix the client-test


tests/client_test.c:
  Fix the tests
include/mysql.h:
  Remove bind_length
libmysql/libmysql.c:
  Remove bind_length
parent 8823fa22
...@@ -481,7 +481,6 @@ typedef struct st_mysql_bind ...@@ -481,7 +481,6 @@ typedef struct st_mysql_bind
unsigned long buffer_length; /* buffer length */ unsigned long buffer_length; /* buffer length */
/* The following are for internal use. Set by mysql_bind_param */ /* The following are for internal use. Set by mysql_bind_param */
unsigned long bind_length; /* Default length of data */
unsigned int param_number; /* For null count and error messages */ unsigned int param_number; /* For null count and error messages */
my_bool long_data_used; /* If used with mysql_send_long_data */ my_bool long_data_used; /* If used with mysql_send_long_data */
void (*store_param_func)(NET *net, struct st_mysql_bind *param); void (*store_param_func)(NET *net, struct st_mysql_bind *param);
......
...@@ -4058,7 +4058,7 @@ static void store_param_double(NET *net, MYSQL_BIND *param) ...@@ -4058,7 +4058,7 @@ static void store_param_double(NET *net, MYSQL_BIND *param)
static void store_param_str(NET *net, MYSQL_BIND *param) static void store_param_str(NET *net, MYSQL_BIND *param)
{ {
ulong length= *param->length; ulong length= min(*param->length, param->buffer_length);
char *to= (char *) net_store_length((char *) net->write_pos, length); char *to= (char *) net_store_length((char *) net->write_pos, length);
memcpy(to, param->buffer, length); memcpy(to, param->buffer, length);
net->write_pos= (uchar*) to+length; net->write_pos= (uchar*) to+length;
...@@ -4107,7 +4107,7 @@ static my_bool store_param(MYSQL_STMT *stmt, MYSQL_BIND *param) ...@@ -4107,7 +4107,7 @@ static my_bool store_param(MYSQL_STMT *stmt, MYSQL_BIND *param)
{ {
/* /*
Param->length should ALWAYS point to the correct length for the type Param->length should ALWAYS point to the correct length for the type
Either to the length pointer given by the user or param->bind_length Either to the length pointer given by the user or param->buffer_length
*/ */
if ((my_realloc_str(net, 9 + *param->length))) if ((my_realloc_str(net, 9 + *param->length)))
DBUG_RETURN(1); DBUG_RETURN(1);
...@@ -4277,12 +4277,14 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind) ...@@ -4277,12 +4277,14 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
param++) param++)
{ {
param->param_number= count++; param->param_number= count++;
param->long_data_used= 0;
/* /*
If param->length is not given, change it to point to bind_length. If param->length is not given, change it to point to buffer_length.
This way we can always use *param->length to get the length of data This way we can always use *param->length to get the length of data
*/ */
if (!param->length) if (!param->length)
param->length= &param->bind_length; param->length= &param->buffer_length;
/* If param->is_null is not set, then the value can never be NULL */ /* If param->is_null is not set, then the value can never be NULL */
if (!param->is_null) if (!param->is_null)
...@@ -4295,33 +4297,33 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind) ...@@ -4295,33 +4297,33 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
break; break;
case MYSQL_TYPE_TINY: case MYSQL_TYPE_TINY:
/* Force param->length as this is fixed for this type */ /* Force param->length as this is fixed for this type */
param->length= &param->bind_length; param->length= &param->buffer_length;
param->bind_length= param->buffer_length= 1; param->buffer_length= 1;
param->store_param_func= store_param_tinyint; param->store_param_func= store_param_tinyint;
break; break;
case MYSQL_TYPE_SHORT: case MYSQL_TYPE_SHORT:
param->length= &param->bind_length; param->length= &param->buffer_length;
param->bind_length= param->buffer_length= 2; param->buffer_length= 2;
param->store_param_func= store_param_short; param->store_param_func= store_param_short;
break; break;
case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONG:
param->length= &param->bind_length; param->length= &param->buffer_length;
param->bind_length= param->buffer_length= 4; param->buffer_length= 4;
param->store_param_func= store_param_int32; param->store_param_func= store_param_int32;
break; break;
case MYSQL_TYPE_LONGLONG: case MYSQL_TYPE_LONGLONG:
param->length= &param->bind_length; param->length= &param->buffer_length;
param->bind_length= param->buffer_length= 8; param->buffer_length= 8;
param->store_param_func= store_param_int64; param->store_param_func= store_param_int64;
break; break;
case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_FLOAT:
param->length= &param->bind_length; param->length= &param->buffer_length;
param->bind_length= param->buffer_length= 4; param->buffer_length= 4;
param->store_param_func= store_param_float; param->store_param_func= store_param_float;
break; break;
case MYSQL_TYPE_DOUBLE: case MYSQL_TYPE_DOUBLE:
param->length= &param->bind_length; param->length= &param->buffer_length;
param->bind_length= param->buffer_length= 8; param->buffer_length= 8;
param->store_param_func= store_param_double; param->store_param_func= store_param_double;
break; break;
case MYSQL_TYPE_TINY_BLOB: case MYSQL_TYPE_TINY_BLOB:
...@@ -4330,7 +4332,6 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind) ...@@ -4330,7 +4332,6 @@ my_bool STDCALL mysql_bind_param(MYSQL_STMT *stmt, MYSQL_BIND * bind)
case MYSQL_TYPE_BLOB: case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_VAR_STRING: case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_STRING: case MYSQL_TYPE_STRING:
param->bind_length= param->buffer_length;
param->store_param_func= store_param_str; param->store_param_func= store_param_str;
break; break;
default: default:
...@@ -4586,6 +4587,7 @@ static void send_data_str(MYSQL_BIND *param, char *value, uint length) ...@@ -4586,6 +4587,7 @@ static void send_data_str(MYSQL_BIND *param, char *value, uint length)
} }
default: default:
*param->length= length; *param->length= length;
length= min(length, param->buffer_length);
memcpy(buffer, value, length); memcpy(buffer, value, length);
buffer[length]='\0'; buffer[length]='\0';
} }
...@@ -4804,9 +4806,10 @@ static void fetch_result_double(MYSQL_BIND *param, uchar **row) ...@@ -4804,9 +4806,10 @@ static void fetch_result_double(MYSQL_BIND *param, uchar **row)
static void fetch_result_str(MYSQL_BIND *param, uchar **row) static void fetch_result_str(MYSQL_BIND *param, uchar **row)
{ {
ulong length= net_field_length(row); ulong length= net_field_length(row);
memcpy(param->buffer, (char *)*row, length); ulong copy_length= min(length, param->buffer_length);
*(param->buffer+length)= '\0'; memcpy(param->buffer, (char *)*row, copy_length);
*param->length= length; *(param->buffer+copy_length)= '\0';
*param->length= length; // return total length
*row+= length; *row+= length;
} }
...@@ -4882,7 +4885,7 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind) ...@@ -4882,7 +4885,7 @@ my_bool STDCALL mysql_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
DBUG_RETURN(1); DBUG_RETURN(1);
} }
if (!param->length) if (!param->length)
param->length= &param->bind_length; param->length= &param->buffer_length;
*param->length= (long)get_binary_length(param->buffer_type); *param->length= (long)get_binary_length(param->buffer_type);
} }
stmt->res_buffers= 1; stmt->res_buffers= 1;
......
...@@ -46,12 +46,28 @@ static my_bool tty_password=0; ...@@ -46,12 +46,28 @@ static my_bool tty_password=0;
static MYSQL *mysql=0; static MYSQL *mysql=0;
static char query[255]; static char query[255];
static char current_db[]= "client_test_db"; static char current_db[]= "client_test_db";
static unsigned int test_count= 0;
static unsigned int opt_count= 0;
static unsigned int iter_count= 0;
#define myheader(str) { fprintf(stdout,"\n\n#######################\n"); \ #define myheader(str) \
fprintf(stdout,"%s",str); \ { \
fprintf(stdout,"\n#######################\n"); \ fprintf(stdout,"\n\n#####################################\n"); \
} fprintf(stdout,"%d of (%d/%d): %s",test_count++, iter_count,\
opt_count, str); \
fprintf(stdout," \n#####################################\n"); \
}
#define myheader_r(str) \
{ \
fprintf(stdout,"\n\n#####################################\n"); \
fprintf(stdout,"%s", str); \
fprintf(stdout," \n#####################################\n"); \
}
/*
TODO: un comment this in 4.1.1 when it supports mysql_param_result
and also enable all meta_param_result tests
*/
#ifndef mysql_param_result #ifndef mysql_param_result
#define mysql_param_result mysql_prepare_result #define mysql_param_result mysql_prepare_result
#endif #endif
...@@ -143,7 +159,7 @@ static void client_connect() ...@@ -143,7 +159,7 @@ static void client_connect()
{ {
int rc; int rc;
char buff[255]; char buff[255];
myheader("client_connect"); myheader_r("client_connect");
if (!(mysql = mysql_init(NULL))) if (!(mysql = mysql_init(NULL)))
{ {
...@@ -174,7 +190,7 @@ static void client_connect() ...@@ -174,7 +190,7 @@ static void client_connect()
*********************************************************/ *********************************************************/
static void client_disconnect() static void client_disconnect()
{ {
myheader("client_disconnect"); myheader_r("client_disconnect");
if (mysql) if (mysql)
{ {
...@@ -1570,10 +1586,10 @@ static void test_select() ...@@ -1570,10 +1586,10 @@ static void test_select()
/* string data */ /* string data */
nData=10; nData=10;
strmov(szData,(char *)"venu"); strcpy(szData,(char *)"venu");
bind[1].buffer_type=FIELD_TYPE_STRING; bind[1].buffer_type=FIELD_TYPE_STRING;
bind[1].buffer=szData; bind[1].buffer=(char *)&szData;
bind[1].buffer_length= sizeof(szData); /* Max string lenth */ bind[1].buffer_length= 4;
bind[1].length= &length[1]; bind[1].length= &length[1];
length[1]= 4; length[1]= 4;
bind[1].is_null=0; bind[1].is_null=0;
...@@ -2106,6 +2122,7 @@ static void test_simple_delete() ...@@ -2106,6 +2122,7 @@ static void test_simple_delete()
bind[1].buffer= szData; /* string data */ bind[1].buffer= szData; /* string data */
bind[1].buffer_length=sizeof(szData); bind[1].buffer_length=sizeof(szData);
bind[1].length= &length[1]; bind[1].length= &length[1];
bind[1].is_null= 0;
length[1]= 5; length[1]= 5;
bind[0].buffer=(char *)&nData; bind[0].buffer=(char *)&nData;
...@@ -2633,6 +2650,139 @@ static void test_bind_result_ext1() ...@@ -2633,6 +2650,139 @@ static void test_bind_result_ext1()
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
} }
/*
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;
long data[10];
float f_data;
double d_data;
char s_data[10];
ulong length[10];
MYSQL_BIND bind[7];
my_bool is_null[7];
stmt = mysql_prepare(mysql,"INSERT INTO test_bind_fetch VALUES(?,?,?,?,?,?,?)",100);
mystmt_init(stmt);
verify_param_count(stmt, 7);
for (i= 0; i < (int) array_elements(bind); i++)
{
bind[i].buffer_type= MYSQL_TYPE_LONG;
bind[i].buffer= (char *) &data[i];
bind[i].is_null= 0;
}
rc = mysql_bind_param(stmt, bind);
mystmt(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);
mystmt(stmt, rc);
}
rc = mysql_commit(mysql);
myquery(rc);
mysql_stmt_close(stmt);
myassert(row_count == (int)
my_stmt_result("SELECT * FROM test_bind_fetch",50));
stmt = mysql_prepare(mysql,"SELECT * FROM test_bind_fetch",50);
myquery(rc);
for (i= 0; i < (int) array_elements(bind); i++)
{
bind[i].buffer= (char *) &data[i];
bind[i].length= &length[i];
bind[i].is_null= &is_null[i];
}
bind[0].buffer_type= MYSQL_TYPE_TINY;
bind[1].buffer_type= MYSQL_TYPE_SHORT;
bind[2].buffer_type= MYSQL_TYPE_LONG;
bind[3].buffer_type= MYSQL_TYPE_LONGLONG;
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= (char *)&s_data;
bind[6].buffer_length= sizeof(s_data);
rc = mysql_bind_result(stmt, bind);
mystmt(stmt, rc);
rc = mysql_execute(stmt);
mystmt(stmt, rc);
rc = mysql_stmt_store_result(stmt);
mystmt(stmt, rc);
while (row_count--)
{
rc = mysql_fetch(stmt);
mystmt(stmt,rc);
fprintf(stdout, "\n");
fprintf(stdout, "\n tiny : %ld(%lu)", data[0], length[0]);
fprintf(stdout, "\n short : %ld(%lu)", data[1], length[1]);
fprintf(stdout, "\n int : %ld(%lu)", data[2], length[2]);
fprintf(stdout, "\n longlong : %ld(%lu)", data[3], length[3]);
fprintf(stdout, "\n float : %f(%lu)", f_data, length[4]);
fprintf(stdout, "\n double : %g(%lu)", d_data, length[5]);
fprintf(stdout, "\n char : %s(%lu)", s_data, length[6]);
bit= 1;
rc= 10+row_count;
for (i=0; i < 4; i++)
{
myassert(data[i] == rc+i);
myassert(length[i] == bit);
bit<<= 1;
rc+= 12;
}
/* FLOAT */
rc+= i;
myassert((int)f_data == rc);
myassert(length[4] == 4);
/* DOUBLE */
rc+= 13;
myassert((int)d_data == rc);
myassert(length[5] == 8);
/* CHAR */
rc+= 13;
{
char buff[20];
long len= my_sprintf(buff, (buff, "%d", rc));
myassert(strcmp(s_data,buff)==0);
myassert(length[6] == (ulong) len);
}
}
rc = mysql_fetch(stmt);
myassert(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt);
}
/******************************************************** /********************************************************
* to test fetching of date, time and ts * * to test fetching of date, time and ts *
*********************************************************/ *********************************************************/
...@@ -2773,26 +2923,17 @@ static void test_fetch_date() ...@@ -2773,26 +2923,17 @@ static void test_fetch_date()
*********************************************************/ *********************************************************/
static void test_fetch_str() static void test_fetch_str()
{ {
MYSQL_STMT *stmt; int rc;
int rc, i, round;
ulong bit;
long data[10];
float f_data;
double d_data;
char s_data[10];
ulong length[10];
MYSQL_BIND bind[7];
my_bool is_null[7];
myheader("test_fetch_str"); myheader("test_fetch_str");
rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_str"); rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_fetch");
myquery(rc); myquery(rc);
rc = mysql_commit(mysql); rc = mysql_commit(mysql);
myquery(rc); myquery(rc);
rc = mysql_query(mysql,"CREATE TABLE test_bind_str(c1 char(10),\ rc = mysql_query(mysql,"CREATE TABLE test_bind_fetch(c1 char(10),\
c2 char(10),\ c2 char(10),\
c3 char(20),\ c3 char(20),\
c4 char(20),\ c4 char(20),\
...@@ -2804,106 +2945,7 @@ static void test_fetch_str() ...@@ -2804,106 +2945,7 @@ static void test_fetch_str()
rc = mysql_commit(mysql); rc = mysql_commit(mysql);
myquery(rc); myquery(rc);
stmt = mysql_prepare(mysql,"INSERT INTO test_bind_str VALUES(?,?,?,?,?,?,?)",100); bind_fetch(3);
myquery(rc);
verify_param_count(stmt, 7);
round= 0;
for (i= 0; i < (int) array_elements(bind); i++)
{
bind[i].buffer_type= MYSQL_TYPE_LONG;
bind[i].buffer= &data[i];
bind[i].is_null= 0;
data[i]= round+i+1;
round= (round +10)*10;
}
rc = mysql_bind_param(stmt, bind);
mystmt(stmt,rc);
rc = mysql_execute(stmt);
mystmt(stmt, rc);
rc = mysql_commit(mysql);
myquery(rc);
mysql_stmt_close(stmt);
myassert(1 == my_stmt_result("SELECT * FROM test_bind_str",50));
stmt = mysql_prepare(mysql,"SELECT * FROM test_bind_str",50);
myquery(rc);
for (i= 0; i < (int) array_elements(bind); i++)
{
bind[i].buffer= (char *) &data[i];
bind[i].length= &length[i];
bind[i].is_null= &is_null[i];
}
bind[0].buffer_type= MYSQL_TYPE_TINY;
bind[1].buffer_type= MYSQL_TYPE_SHORT;
bind[2].buffer_type= MYSQL_TYPE_LONG;
bind[3].buffer_type= MYSQL_TYPE_LONGLONG;
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= (char *)&s_data;
rc = mysql_bind_result(stmt, bind);
mystmt(stmt, rc);
rc = mysql_execute(stmt);
mystmt(stmt, rc);
rc = mysql_fetch(stmt);
mystmt(stmt,rc);
fprintf(stdout, "\n tiny : %ld(%lu)", data[0], length[0]);
fprintf(stdout, "\n short : %ld(%lu)", data[1], length[1]);
fprintf(stdout, "\n int : %ld(%lu)", data[2], length[2]);
fprintf(stdout, "\n longlong : %ld(%lu)", data[3], length[3]);
fprintf(stdout, "\n float : %f(%lu)", f_data, length[4]);
fprintf(stdout, "\n double : %g(%lu)", d_data, length[5]);
fprintf(stdout, "\n char : %s(%lu)", s_data, length[6]);
round= 0;
bit= 1;
for (i=0; i < 4; i++)
{
myassert(data[i] == round+i+1);
myassert(length[i] == bit);
round= (round+10)*10;
bit<<= 1;
}
/* FLOAT */
myassert((int)f_data == round+1+i);
myassert(length[4] == 4);
/* DOUBLE */
round= (round+10)*10;
myassert((int)d_data == round+2+i);
myassert(length[5] == 8);
/* CHAR */
round= (round+10)*10;
{
char buff[20];
long len= my_sprintf(buff, (buff, "%d", round+3+i));
myassert(strcmp(s_data,buff)==0);
myassert(length[6] == (ulong) len);
}
rc = mysql_fetch(stmt);
myassert(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt);
} }
/******************************************************** /********************************************************
...@@ -2911,26 +2953,17 @@ static void test_fetch_str() ...@@ -2911,26 +2953,17 @@ static void test_fetch_str()
*********************************************************/ *********************************************************/
static void test_fetch_long() static void test_fetch_long()
{ {
MYSQL_STMT *stmt; int rc;
int rc, i, round;
ulong bit;
long data[10];
float f_data;
double d_data;
char s_data[10];
ulong length[10];
MYSQL_BIND bind[7];
my_bool is_null[7];
myheader("test_fetch_long"); myheader("test_fetch_long");
rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_long"); rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_fetch");
myquery(rc); myquery(rc);
rc = mysql_commit(mysql); rc = mysql_commit(mysql);
myquery(rc); myquery(rc);
rc = mysql_query(mysql,"CREATE TABLE test_bind_long(c1 int unsigned,\ rc = mysql_query(mysql,"CREATE TABLE test_bind_fetch(c1 int unsigned,\
c2 int unsigned,\ c2 int unsigned,\
c3 int,\ c3 int,\
c4 int,\ c4 int,\
...@@ -2942,108 +2975,7 @@ static void test_fetch_long() ...@@ -2942,108 +2975,7 @@ static void test_fetch_long()
rc = mysql_commit(mysql); rc = mysql_commit(mysql);
myquery(rc); myquery(rc);
stmt = mysql_prepare(mysql,"INSERT INTO test_bind_long VALUES(?,?,?,?,?,?,?)",100); bind_fetch(4);
myquery(rc);
verify_param_count(stmt, 7);
round= 0;
for (i=0; i < 7; i++)
{
bind[i].buffer_type= MYSQL_TYPE_LONG;
bind[i].buffer= (char *) &data[i];
bind[i].is_null=0;
data[i]= round+i+1;
round= (round +10)*10;
}
rc = mysql_bind_param(stmt, bind);
mystmt(stmt,rc);
rc = mysql_execute(stmt);
mystmt(stmt, rc);
rc = mysql_commit(mysql);
myquery(rc);
mysql_stmt_close(stmt);
myassert(1 == my_stmt_result("SELECT * FROM test_bind_long",50));
stmt = mysql_prepare(mysql,"SELECT * FROM test_bind_long",50);
myquery(rc);
bind[0].buffer_type= MYSQL_TYPE_TINY;
bind[1].buffer_type= MYSQL_TYPE_SHORT;
bind[2].buffer_type= MYSQL_TYPE_LONG;
bind[3].buffer_type= MYSQL_TYPE_LONGLONG;
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= (char *)&s_data;
bind[6].buffer_length= sizeof(s_data);
for (i= 0; i < (int) array_elements(bind); i++)
{
bind[i].buffer= (char*) &data[i];
bind[i].length= &length[i];
bind[i].is_null= &is_null[i];
}
rc = mysql_bind_result(stmt, bind);
mystmt(stmt, rc);
rc = mysql_execute(stmt);
mystmt(stmt, rc);
rc = mysql_fetch(stmt);
mystmt(stmt,rc);
fprintf(stdout, "\n tiny : %ld(%lu)", data[0], length[0]);
fprintf(stdout, "\n short : %ld(%lu)", data[1], length[1]);
fprintf(stdout, "\n int : %ld(%lu)", data[2], length[2]);
fprintf(stdout, "\n longlong : %ld(%lu)", data[3], length[3]);
fprintf(stdout, "\n float : %f(%lu)", f_data, length[4]);
fprintf(stdout, "\n double : %g(%lu)", d_data, length[5]);
fprintf(stdout, "\n char : %s(%lu)", s_data, length[6]);
round= 0;
bit= 1;
for (i=0; i < 4; i++)
{
myassert(data[i] == round+i+1);
myassert(length[i] == bit);
round= (round+10)*10;
bit<<= 1;
}
/* FLOAT */
myassert((int)f_data == round+1+i);
myassert(length[4] == 4);
/* DOUBLE */
round= (round+10)*10;
myassert((int)d_data == round+2+i);
myassert(length[5] == 8);
/* CHAR */
round= (round+10)*10;
{
char buff[20];
long len= my_sprintf(buff, (buff, "%d", round+3+i));
myassert(strcmp(s_data,buff)==0);
myassert(length[6] == (ulong) len);
}
rc = mysql_fetch(stmt);
myassert(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt);
} }
...@@ -3052,30 +2984,17 @@ static void test_fetch_long() ...@@ -3052,30 +2984,17 @@ static void test_fetch_long()
*********************************************************/ *********************************************************/
static void test_fetch_short() static void test_fetch_short()
{ {
MYSQL_STMT *stmt; int rc;
int rc, i, round;
ulong bit;
long data[10];
char tiny_data;
short int short_data;
long long_data;
longlong longlong_data;
float f_data;
double d_data;
char s_data[10];
MYSQL_BIND bind[7];
ulong length[10];
my_bool is_null[7];
myheader("test_fetch_short"); myheader("test_fetch_short");
rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_long"); rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_fetch");
myquery(rc); myquery(rc);
rc = mysql_commit(mysql); rc = mysql_commit(mysql);
myquery(rc); myquery(rc);
rc = mysql_query(mysql,"CREATE TABLE test_bind_long(c1 smallint unsigned,\ rc = mysql_query(mysql,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,\
c2 smallint,\ c2 smallint,\
c3 smallint unsigned,\ c3 smallint unsigned,\
c4 smallint,\ c4 smallint,\
...@@ -3086,113 +3005,9 @@ static void test_fetch_short() ...@@ -3086,113 +3005,9 @@ static void test_fetch_short()
rc = mysql_commit(mysql); rc = mysql_commit(mysql);
myquery(rc); myquery(rc);
stmt = mysql_prepare(mysql,"INSERT INTO test_bind_long VALUES(?,?,?,?,?,?,?)",100); bind_fetch(5);
myquery(rc); }
verify_param_count(stmt, 7);
round= 0;
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= &length[i];
bind[i].is_null= 0;
data[i]= round+i+1;
round= (round +10)*2;
}
rc = mysql_bind_param(stmt, bind);
mystmt(stmt,rc);
rc = mysql_execute(stmt);
mystmt(stmt, rc);
rc = mysql_commit(mysql);
myquery(rc);
mysql_stmt_close(stmt);
myassert(1 == my_stmt_result("SELECT * FROM test_bind_long",50));
stmt = mysql_prepare(mysql,"SELECT * FROM test_bind_long",50);
myquery(rc);
for (i=0; i < 7; i++)
{
bind[i].length= &length[i];
bind[i].is_null= &is_null[i];
}
bind[0].buffer_type= MYSQL_TYPE_TINY;
bind[0].buffer= (char*) &tiny_data;
bind[1].buffer_type= MYSQL_TYPE_SHORT;
bind[1].buffer= (char*) &short_data;
bind[2].buffer_type= MYSQL_TYPE_LONG;
bind[1].buffer= (char*) &long_data;
bind[3].buffer_type= MYSQL_TYPE_LONGLONG;
bind[1].buffer= (char*) &longlong_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= (char *)&s_data;
bind[6].buffer_length= sizeof(s_data);
rc = mysql_bind_result(stmt, bind);
mystmt(stmt, rc);
rc = mysql_execute(stmt);
mystmt(stmt, rc);
rc = mysql_fetch(stmt);
mystmt(stmt,rc);
fprintf(stdout, "\n tiny : %d(%lu)", tiny_data, length[0]);
fprintf(stdout, "\n short : %d(%lu)", short_data, length[1]);
fprintf(stdout, "\n int : %ld(%lu)", long_data, length[2]);
fprintf(stdout, "\n longlong : %ld(%lu)", (long) longlong_data, length[3]);
fprintf(stdout, "\n float : %f(%lu)", f_data, length[4]);
fprintf(stdout, "\n double : %g(%lu)", d_data, length[5]);
fprintf(stdout, "\n char : %s(%lu)", s_data, length[6]);
round= 0;
bit= 1;
for (i=0; i < 4; i++)
{
myassert(data[i] == round+i+1);
myassert(length[i] == bit);
round= (round+10)*2;
bit<<= 1;
}
/* FLOAT */
myassert((int)f_data == round+1+i);
myassert(length[4] == 4);
/* DOUBLE */
round= (round+10)*2;
myassert((int)d_data == round+2+i);
myassert(length[5] == 8);
/* CHAR */
round= (round+10)*2;
{
char buff[20];
long len= my_sprintf(buff, (buff, "%d", round+3+i));
myassert(strcmp(s_data,buff)==0);
myassert(length[6] == (ulong) len);
}
rc = mysql_fetch(stmt);
myassert(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt);
}
/******************************************************** /********************************************************
...@@ -3200,26 +3015,17 @@ static void test_fetch_short() ...@@ -3200,26 +3015,17 @@ static void test_fetch_short()
*********************************************************/ *********************************************************/
static void test_fetch_tiny() static void test_fetch_tiny()
{ {
MYSQL_STMT *stmt; int rc;
int rc, i;
ulong bit;
long data[10];
ulong length[10];
float f_data;
double d_data;
char s_data[10];
MYSQL_BIND bind[7];
my_bool is_null[7];
myheader("test_fetch_tiny"); myheader("test_fetch_tiny");
rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_long"); rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_fetch");
myquery(rc); myquery(rc);
rc = mysql_commit(mysql); rc = mysql_commit(mysql);
myquery(rc); myquery(rc);
rc = mysql_query(mysql,"CREATE TABLE test_bind_long(c1 tinyint unsigned,\ rc = mysql_query(mysql,"CREATE TABLE test_bind_fetch(c1 tinyint unsigned,\
c2 tinyint,\ c2 tinyint,\
c3 tinyint unsigned,\ c3 tinyint unsigned,\
c4 tinyint,\ c4 tinyint,\
...@@ -3230,109 +3036,9 @@ static void test_fetch_tiny() ...@@ -3230,109 +3036,9 @@ static void test_fetch_tiny()
rc = mysql_commit(mysql); rc = mysql_commit(mysql);
myquery(rc); myquery(rc);
stmt = mysql_prepare(mysql,"INSERT INTO test_bind_long VALUES(?,?,?,?,?,?,?)",100);
myquery(rc);
verify_param_count(stmt, 7);
rc= 10;
for (i= 0; i < (int) array_elements(bind); i++)
{
bind[i].buffer_type= MYSQL_TYPE_LONG;
bind[i].buffer= (char *) &data[i];
bind[i].is_null= 0;
data[i]= rc+i;
rc+= 10;
}
rc = mysql_bind_param(stmt, bind);
mystmt(stmt,rc);
rc = mysql_execute(stmt); bind_fetch(3);
mystmt(stmt, rc);
rc = mysql_commit(mysql);
myquery(rc);
mysql_stmt_close(stmt);
myassert(1 == my_stmt_result("SELECT * FROM test_bind_long",50));
stmt = mysql_prepare(mysql,"SELECT * FROM test_bind_long",50);
myquery(rc);
for (i= 0; i < (int) array_elements(bind); i++)
{
bind[i].buffer= (char *) &data[i];
bind[i].length= &length[i];
bind[i].is_null= &is_null[i];
}
bind[0].buffer_type= MYSQL_TYPE_TINY;
bind[1].buffer_type= MYSQL_TYPE_SHORT;
bind[2].buffer_type= MYSQL_TYPE_LONG;
bind[3].buffer_type= MYSQL_TYPE_LONGLONG;
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= (char *)&s_data;
bind[6].buffer_length= sizeof(s_data);
rc = mysql_bind_result(stmt, bind);
mystmt(stmt, rc);
rc = mysql_execute(stmt);
mystmt(stmt, rc);
rc = mysql_fetch(stmt);
mystmt(stmt,rc);
fprintf(stdout, "\n tiny : %ld(%lu)", data[0], length[0]);
fprintf(stdout, "\n short : %ld(%lu)", data[1], length[1]);
fprintf(stdout, "\n int : %ld(%lu)", data[2], length[2]);
fprintf(stdout, "\n longlong : %ld(%lu)", data[3], length[3]);
fprintf(stdout, "\n float : %f(%lu)", f_data, length[4]);
fprintf(stdout, "\n double : %g(%lu)", d_data, length[5]);
fprintf(stdout, "\n char : %s(%lu)", s_data, length[6]);
bit= 1;
rc= 10;
for (i=0; i < 4; i++)
{
myassert(data[i] == rc+i);
myassert(length[i] == bit);
bit<<= 1;
rc+= 10;
}
/* FLOAT */
rc+= i;
myassert((int)f_data == rc);
myassert(length[4] == 4);
/* DOUBLE */
rc+= 11;
myassert((int)d_data == rc);
myassert(length[5] == 8);
/* CHAR */
rc+= 11;
{
char buff[20];
long len= my_sprintf(buff, (buff, "%d", rc));
myassert(strcmp(s_data,buff)==0);
myassert(length[6] == (ulong) len);
}
rc = mysql_fetch(stmt);
myassert(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt);
} }
...@@ -3341,26 +3047,17 @@ static void test_fetch_tiny() ...@@ -3341,26 +3047,17 @@ static void test_fetch_tiny()
*********************************************************/ *********************************************************/
static void test_fetch_bigint() static void test_fetch_bigint()
{ {
MYSQL_STMT *stmt; int rc;
int rc, i, round;
ulong bit;
long data[10];
float f_data;
double d_data;
char s_data[10];
MYSQL_BIND bind[7];
ulong length[7];
my_bool is_null[7];
myheader("test_fetch_bigint"); myheader("test_fetch_bigint");
rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_long"); rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_fetch");
myquery(rc); myquery(rc);
rc = mysql_commit(mysql); rc = mysql_commit(mysql);
myquery(rc); myquery(rc);
rc = mysql_query(mysql,"CREATE TABLE test_bind_long(c1 bigint,\ rc = mysql_query(mysql,"CREATE TABLE test_bind_fetch(c1 bigint,\
c2 bigint,\ c2 bigint,\
c3 bigint unsigned,\ c3 bigint unsigned,\
c4 bigint unsigned,\ c4 bigint unsigned,\
...@@ -3371,110 +3068,9 @@ static void test_fetch_bigint() ...@@ -3371,110 +3068,9 @@ static void test_fetch_bigint()
rc = mysql_commit(mysql); rc = mysql_commit(mysql);
myquery(rc); myquery(rc);
stmt = mysql_prepare(mysql,"INSERT INTO test_bind_long VALUES(?,?,?,?,?,?,?)",100);
myquery(rc);
verify_param_count(stmt, 7);
round= 0;
for (i= 0; i < (int) array_elements(bind); i++)
{
bind[i].buffer_type= MYSQL_TYPE_LONG;
bind[i].buffer= (char *)&data[i];
bind[i].is_null = &is_null[i];
bind[i].length= &length[i];
length[i]= 0;
data[i]= round+i+1;
round= (round +10)*10;
}
rc = mysql_bind_param(stmt, bind);
mystmt(stmt,rc);
rc = mysql_execute(stmt); bind_fetch(2);
mystmt(stmt, rc);
rc = mysql_commit(mysql);
myquery(rc);
mysql_stmt_close(stmt);
myassert(1 == my_stmt_result("SELECT * FROM test_bind_long",50));
stmt = mysql_prepare(mysql,"SELECT * FROM test_bind_long",50);
myquery(rc);
for (i= 0; i < (int) array_elements(bind); i++)
{
bind[i].buffer= (char *)&data[i];
bind[i].length= &length[i];
bind[i].is_null= 0;
}
bind[0].buffer_type= MYSQL_TYPE_TINY;
bind[1].buffer_type= MYSQL_TYPE_SHORT;
bind[2].buffer_type= MYSQL_TYPE_LONG;
bind[3].buffer_type= MYSQL_TYPE_LONGLONG;
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= (char *)&s_data;
bind[6].buffer_length= sizeof(s_data);
rc = mysql_bind_result(stmt, bind);
mystmt(stmt, rc);
rc = mysql_execute(stmt);
mystmt(stmt, rc);
rc = mysql_fetch(stmt);
mystmt(stmt,rc);
fprintf(stdout, "\n tiny : %ld(%lu)", data[0], length[0]);
fprintf(stdout, "\n short : %ld(%lu)", data[1], length[1]);
fprintf(stdout, "\n int : %ld(%lu)", data[2], length[2]);
fprintf(stdout, "\n longlong : %ld(%lu)", data[3], length[3]);
fprintf(stdout, "\n float : %f(%lu)", f_data, length[4]);
fprintf(stdout, "\n double : %g(%lu)", d_data, length[5]);
fprintf(stdout, "\n char : %s(%lu)", s_data, length[6]);
round= 0;
bit= 1;
for (i=0; i < 4; i++)
{
myassert(data[i] == round+i+1);
myassert(length[i] == bit);
round= (round+10)*10;
bit<<= 1;
}
/* FLOAT */
myassert((int)f_data == round+1+i);
myassert(length[4] == 4);
/* DOUBLE */
round= (round+10)*10;
myassert((int)d_data == round+2+i);
myassert(length[5] == 8);
/* CHAR */
round= (round+10)*10;
{
char buff[20];
long len= my_sprintf(buff, (buff, "%d", round+3+i));
myassert(strcmp(s_data,buff)==0);
myassert(length[6] == (ulong) len);
}
rc = mysql_fetch(stmt);
myassert(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt);
} }
...@@ -3483,26 +3079,17 @@ static void test_fetch_bigint() ...@@ -3483,26 +3079,17 @@ static void test_fetch_bigint()
*********************************************************/ *********************************************************/
static void test_fetch_float() static void test_fetch_float()
{ {
MYSQL_STMT *stmt; int rc;
int rc, i, round;
ulong bit;
long data[10];
float f_data;
double d_data;
char s_data[10];
MYSQL_BIND bind[7];
ulong length[10];
my_bool is_null[7];
myheader("test_fetch_float"); myheader("test_fetch_float");
rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_long"); rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_fetch");
myquery(rc); myquery(rc);
rc = mysql_commit(mysql); rc = mysql_commit(mysql);
myquery(rc); myquery(rc);
rc = mysql_query(mysql,"CREATE TABLE test_bind_long(c1 float(3),\ rc = mysql_query(mysql,"CREATE TABLE test_bind_fetch(c1 float(3),\
c2 float,\ c2 float,\
c3 float unsigned,\ c3 float unsigned,\
c4 float,\ c4 float,\
...@@ -3513,109 +3100,9 @@ static void test_fetch_float() ...@@ -3513,109 +3100,9 @@ static void test_fetch_float()
rc = mysql_commit(mysql); rc = mysql_commit(mysql);
myquery(rc); myquery(rc);
stmt = mysql_prepare(mysql,"INSERT INTO test_bind_long VALUES(?,?,?,?,?,?,?)",100);
myquery(rc);
verify_param_count(stmt, 7);
round= 0;
for (i= 0; i < (int) array_elements(bind); i++)
{
bind[i].buffer_type= MYSQL_TYPE_LONG;
bind[i].buffer= (char *)&data[i];
bind[i].is_null= 0;
data[i]= round+i+1;
round= (round +10)*2;
}
rc = mysql_bind_param(stmt, bind);
mystmt(stmt,rc);
rc = mysql_execute(stmt);
mystmt(stmt, rc);
rc = mysql_commit(mysql);
myquery(rc);
mysql_stmt_close(stmt);
myassert(1 == my_stmt_result("SELECT * FROM test_bind_long",50));
stmt = mysql_prepare(mysql,"SELECT * FROM test_bind_long",50);
myquery(rc);
for (i= 0; i < (int) array_elements(bind); i++)
{
bind[i].buffer= (char *)&data[i];
bind[i].length= &length[i];
bind[i].is_null= &is_null[i];
length[i]=0;
}
bind[0].buffer_type= MYSQL_TYPE_TINY;
bind[1].buffer_type= MYSQL_TYPE_SHORT;
bind[2].buffer_type= MYSQL_TYPE_LONG;
bind[3].buffer_type= MYSQL_TYPE_LONGLONG;
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= (char *) &s_data;
bind[6].buffer_length= sizeof(s_data);
rc = mysql_bind_result(stmt, bind);
mystmt(stmt, rc);
rc = mysql_execute(stmt);
mystmt(stmt, rc);
rc = mysql_fetch(stmt);
mystmt(stmt,rc);
fprintf(stdout, "\n tiny : %ld(%lu)", data[0], length[0]);
fprintf(stdout, "\n short : %ld(%lu)", data[1], length[1]);
fprintf(stdout, "\n int : %ld(%lu)", data[2], length[2]);
fprintf(stdout, "\n longlong : %ld(%lu)", data[3], length[3]);
fprintf(stdout, "\n float : %f(%lu)", f_data, length[4]);
fprintf(stdout, "\n double : %g(%lu)", d_data, length[5]);
fprintf(stdout, "\n char : %s(%lu)", s_data, length[6]);
round= 0;
bit= 1;
for (i=0; i < 4; i++) bind_fetch(2);
{
myassert(data[i] == round+i+1);
myassert(length[i] == bit);
round= (round+10)*2;
bit<<= 1;
}
/* FLOAT */
myassert((int)f_data == round+1+i);
myassert(length[4] == 4);
/* DOUBLE */
round= (round+10)*2;
myassert((int)d_data == round+2+i);
myassert(length[5] == 8);
/* CHAR */
round= (round+10)*2;
{
char buff[20];
long len= my_sprintf(buff, (buff, "%d", round+3+i));
myassert(strcmp(s_data,buff)==0);
myassert(length[6] == (ulong) len);
}
rc = mysql_fetch(stmt);
myassert(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt);
} }
/******************************************************** /********************************************************
...@@ -3623,26 +3110,17 @@ static void test_fetch_float() ...@@ -3623,26 +3110,17 @@ static void test_fetch_float()
*********************************************************/ *********************************************************/
static void test_fetch_double() static void test_fetch_double()
{ {
MYSQL_STMT *stmt; int rc;
int rc, i, round;
ulong bit;
long data[10];
float f_data;
double d_data;
char s_data[10];
MYSQL_BIND bind[7];
my_bool is_null[7];
ulong length[7];
myheader("test_fetch_double"); myheader("test_fetch_double");
rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_long"); rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_bind_fetch");
myquery(rc); myquery(rc);
rc = mysql_commit(mysql); rc = mysql_commit(mysql);
myquery(rc); myquery(rc);
rc = mysql_query(mysql,"CREATE TABLE test_bind_long(c1 double(5,2),\ rc = mysql_query(mysql,"CREATE TABLE test_bind_fetch(c1 double(5,2),\
c2 double unsigned,\ c2 double unsigned,\
c3 double unsigned,\ c3 double unsigned,\
c4 double unsigned,\ c4 double unsigned,\
...@@ -3653,107 +3131,9 @@ static void test_fetch_double() ...@@ -3653,107 +3131,9 @@ static void test_fetch_double()
rc = mysql_commit(mysql); rc = mysql_commit(mysql);
myquery(rc); myquery(rc);
stmt = mysql_prepare(mysql,"INSERT INTO test_bind_long VALUES(?,?,?,?,?,?,?)",100);
myquery(rc);
verify_param_count(stmt, 7);
round= 0;
for (i= 0; i < (int) array_elements(bind); i++)
{
bind[i].buffer_type= MYSQL_TYPE_LONG;
bind[i].buffer= (char *)&data[i];
bind[i].is_null= 0;
data[i]= round+i+1;
round= (round +10)*10;
}
rc = mysql_bind_param(stmt, bind);
mystmt(stmt,rc);
rc = mysql_execute(stmt); bind_fetch(3);
mystmt(stmt, rc);
rc = mysql_commit(mysql);
myquery(rc);
mysql_stmt_close(stmt);
myassert(1 == my_stmt_result("SELECT * FROM test_bind_long",50));
stmt = mysql_prepare(mysql,"SELECT * FROM test_bind_long",50);
myquery(rc);
for (i= 0; i < (int) array_elements(bind); i++)
{
bind[i].buffer= (char *)&data[i];
bind[i].length= &length[i];
bind[i].is_null= &is_null[i];
}
bind[0].buffer_type= MYSQL_TYPE_TINY;
bind[1].buffer_type= MYSQL_TYPE_SHORT;
bind[2].buffer_type= MYSQL_TYPE_LONG;
bind[3].buffer_type= MYSQL_TYPE_LONGLONG;
bind[4].buffer_type= MYSQL_TYPE_STRING;
bind[4].buffer= (char *)&s_data;
bind[4].buffer_length= sizeof(s_data);
bind[5].buffer_type= MYSQL_TYPE_FLOAT;
bind[5].buffer= (char *)&f_data;
bind[6].buffer_type= MYSQL_TYPE_DOUBLE;
bind[6].buffer= (char *)&d_data;
rc = mysql_bind_result(stmt, bind);
mystmt(stmt, rc);
rc = mysql_execute(stmt);
mystmt(stmt, rc);
rc = mysql_fetch(stmt);
mystmt(stmt,rc);
fprintf(stdout, "\n tiny : %ld(%lu)", data[0], length[0]);
fprintf(stdout, "\n short : %ld(%lu)", data[1], length[1]);
fprintf(stdout, "\n int : %ld(%lu)", data[2], length[2]);
fprintf(stdout, "\n longlong : %ld(%lu)", data[3], length[3]);
fprintf(stdout, "\n float : %f(%lu)", f_data, length[5]);
fprintf(stdout, "\n double : %g(%lu)", d_data, length[6]);
fprintf(stdout, "\n char : %s(%lu)", s_data, length[4]);
round= 0;
bit= 1;
for (i=0; i < 4; i++)
{
myassert(data[i] == round+i+1);
myassert(length[i] == bit);
round= (round+10)*10;
bit<<= 1;
}
/* CHAR */
{
char buff[20];
long len= my_sprintf(buff, (buff, "%d", round+1+i));
myassert(strcmp(s_data,buff)==0);
myassert(length[4] == (ulong) len);
}
/* FLOAT */
round= (round+10)*10;
myassert((int)f_data == round+2+i);
myassert(length[5] == 4);
/* DOUBLE */
round= (round+10)*10;
myassert((int)d_data == round+3+i);
myassert(length[6] == 8);
rc = mysql_fetch(stmt);
myassert(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt);
} }
/******************************************************** /********************************************************
...@@ -3820,7 +3200,7 @@ static void test_prepare_ext() ...@@ -3820,7 +3200,7 @@ static void test_prepare_ext()
/* insert by prepare - all integers */ /* insert by prepare - all integers */
strmov(query,(char *)"INSERT INTO test_prepare_ext(c1,c2,c3,c4,c5,c6) VALUES(?,?,?,?,?,?)"); strmov(query,(char *)"INSERT INTO test_prepare_ext(c1,c2,c3,c4,c5,c6) VALUES(?,?,?,?,?,?)");
stmt = mysql_prepare(mysql,query, strlen(query)); stmt = mysql_prepare(mysql,query, strlen(query));
myquery(rc); mystmt_init(stmt);
verify_param_count(stmt,6); verify_param_count(stmt,6);
...@@ -4992,7 +4372,7 @@ static void test_store_result() ...@@ -4992,7 +4372,7 @@ static void test_store_result()
bind[0].buffer_type=FIELD_TYPE_LONG; bind[0].buffer_type=FIELD_TYPE_LONG;
bind[0].buffer= (char*) &nData; /* integer data */ bind[0].buffer= (char*) &nData; /* integer data */
bind[0].length= &length; bind[0].length= &length;
bind[1].is_null= &is_null[1]; bind[0].is_null= &is_null[0];
length= 0; length= 0;
bind[1].buffer_type=FIELD_TYPE_STRING; bind[1].buffer_type=FIELD_TYPE_STRING;
...@@ -5035,11 +4415,11 @@ static void test_store_result() ...@@ -5035,11 +4415,11 @@ static void test_store_result()
rc = mysql_fetch(stmt); rc = mysql_fetch(stmt);
mystmt(stmt,rc); mystmt(stmt,rc);
if (is_null[1]) if (is_null[0])
fprintf(stdout,"\n row 3: NULL,%s(%lu)", szData, length1); fprintf(stdout,"\n row 3: NULL,%s(%lu)", szData, length1);
else else
fprintf(stdout,"\n row 3: %ld,%s(%lu)", nData, szData, length1); fprintf(stdout,"\n row 3: %ld,%s(%lu)", nData, szData, length1);
myassert(is_null[1]); myassert(is_null[0]);
myassert(strcmp(szData,"monty")==0); myassert(strcmp(szData,"monty")==0);
myassert(length1 == 5); myassert(length1 == 5);
...@@ -5072,11 +4452,11 @@ static void test_store_result() ...@@ -5072,11 +4452,11 @@ static void test_store_result()
rc = mysql_fetch(stmt); rc = mysql_fetch(stmt);
mystmt(stmt,rc); mystmt(stmt,rc);
if (is_null[1]) if (is_null[0])
fprintf(stdout,"\n row 3: NULL,%s(%lu)", szData, length1); fprintf(stdout,"\n row 3: NULL,%s(%lu)", szData, length1);
else else
fprintf(stdout,"\n row 3: %ld,%s(%lu)", nData, szData, length1); fprintf(stdout,"\n row 3: %ld,%s(%lu)", nData, szData, length1);
myassert(is_null[1]); myassert(is_null[0]);
myassert(strcmp(szData,"monty")==0); myassert(strcmp(szData,"monty")==0);
myassert(length1 == 5); myassert(length1 == 5);
...@@ -5183,8 +4563,6 @@ static void test_store_result2() ...@@ -5183,8 +4563,6 @@ static void test_store_result2()
rc = mysql_commit(mysql); rc = mysql_commit(mysql);
myquery(rc); myquery(rc);
/* fetch */
bind[0].buffer_type=FIELD_TYPE_LONG; bind[0].buffer_type=FIELD_TYPE_LONG;
bind[0].buffer= (char *) &nData; /* integer data */ bind[0].buffer= (char *) &nData; /* integer data */
bind[0].length= &length; bind[0].length= &length;
...@@ -5337,6 +4715,8 @@ static struct my_option myctest_long_options[] = ...@@ -5337,6 +4715,8 @@ static struct my_option myctest_long_options[] =
(char **) &opt_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (char **) &opt_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"socket", 'S', "Socket file to use for connection", (char **) &opt_unix_socket, {"socket", 'S', "Socket file to use for connection", (char **) &opt_unix_socket,
(char **) &opt_unix_socket, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (char **) &opt_unix_socket, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"count", 't', "Number of times test to be executed", (char **) &opt_count,
(char **) &opt_count, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
...@@ -5369,6 +4749,8 @@ static void usage(void) ...@@ -5369,6 +4749,8 @@ static void usage(void)
fprintf(stdout,"\ fprintf(stdout,"\
-u, --user=# User for login if not current user.\n"); -u, --user=# User for login if not current user.\n");
#endif #endif
fprintf(stdout,"\
-t, --count=... Execute the test count times.\n");
fprintf(stdout,"*********************************************************************\n"); fprintf(stdout,"*********************************************************************\n");
} }
...@@ -5404,7 +4786,6 @@ static const char *load_default_groups[]= { "client",0 }; ...@@ -5404,7 +4786,6 @@ static const char *load_default_groups[]= { "client",0 };
static void get_options(int argc, char **argv) static void get_options(int argc, char **argv)
{ {
int ho_error; int ho_error;
load_defaults("my",load_default_groups,&argc,&argv); load_defaults("my",load_default_groups,&argc,&argv);
if ((ho_error=handle_options(&argc,&argv, myctest_long_options, if ((ho_error=handle_options(&argc,&argv, myctest_long_options,
...@@ -5414,6 +4795,8 @@ static void get_options(int argc, char **argv) ...@@ -5414,6 +4795,8 @@ static void get_options(int argc, char **argv)
/*free_defaults(argv);*/ /*free_defaults(argv);*/
if (tty_password) if (tty_password)
opt_password=get_tty_password(NullS); opt_password=get_tty_password(NullS);
if (!opt_count)
opt_count= 1;
return; return;
} }
...@@ -5427,87 +4810,96 @@ int main(int argc, char **argv) ...@@ -5427,87 +4810,96 @@ int main(int argc, char **argv)
client_connect(); /* connect to server */ client_connect(); /* connect to server */
/* Start of tests */ for (iter_count=1; iter_count <= opt_count; iter_count++)
test_multi_query(); {
test_select_show(); /* test show syntax */ /* Start of tests */
test_prepare_alter(); /* change table schema in middle of prepare */ test_count= 0;
test_manual_sample(); /* sample in the manual */
test_bind_result(); /* result bind test */ test_multi_query();
test_fetch_null(); /* to fetch null data */ test_select_show(); /* test show syntax */
test_fetch_date(); /* to fetch date,time and timestamp */ test_prepare_alter(); /* change table schema in middle of prepare */
test_fetch_str(); /* to fetch string to all types */ test_manual_sample(); /* sample in the manual */
test_fetch_long(); /* to fetch long to all types */ test_bind_result(); /* result bind test */
test_fetch_short(); /* to fetch short to all types */ test_fetch_null(); /* to fetch null data */
test_fetch_tiny(); /* to fetch tiny to all types */ test_fetch_date(); /* to fetch date,time and timestamp */
test_fetch_bigint(); /* to fetch bigint to all types */ test_fetch_str(); /* to fetch string to all types */
test_fetch_float(); /* to fetch float to all types */ test_fetch_long(); /* to fetch long to all types */
test_fetch_double(); /* to fetch double to all types */ test_fetch_short(); /* to fetch short to all types */
test_bind_result_ext(); /* result bind test - extension */ test_fetch_tiny(); /* to fetch tiny to all types */
test_bind_result_ext1(); /* result bind test - extension */ test_fetch_bigint(); /* to fetch bigint to all types */
test_select_direct(); /* direct select - protocol_simple debug */ test_fetch_float(); /* to fetch float to all types */
test_select_prepare(); /* prepare select - protocol_prep debug */ test_fetch_double(); /* to fetch double to all types */
test_select_direct(); /* direct select - protocol_simple debug */ test_bind_result_ext(); /* result bind test - extension */
test_select(); /* simple select test */ test_bind_result_ext1(); /* result bind test - extension */
test_select_version(); /* select with variables */ test_select_direct(); /* direct select - protocol_simple debug */
test_set_variable(); /* set variable prepare */ test_select_prepare(); /* prepare select - protocol_prep debug */
test_select(); /* simple select test */
test_select_version(); /* select with variables */
test_set_variable(); /* set variable prepare */
#if NOT_USED #if NOT_USED
test_select_meta(); /* select param meta information */ /*
test_update_meta(); /* update param meta information */ Enable this tests from 4.1.1 when mysql_param_result() is
test_insert_meta(); /* insert param meta information */ supported
*/
test_select_meta(); /* select param meta information */
test_update_meta(); /* update param meta information */
test_insert_meta(); /* insert param meta information */
#endif #endif
test_simple_update(); /* simple update test */ test_simple_update(); /* simple update test */
test_func_fields(); /* test for new 4.1 MYSQL_FIELD members */ test_func_fields(); /* test for new 4.1 MYSQL_FIELD members */
test_long_data(); /* test for sending text data in chunks */ test_long_data(); /* test for sending text data in chunks */
test_insert(); /* simple insert test - prepare */ test_insert(); /* simple insert test - prepare */
test_set_variable(); /* prepare with set variables */ test_set_variable(); /* prepare with set variables */
test_tran_innodb(); /* test for mysql_commit(), rollback() and autocommit() */ test_tran_innodb(); /* test for mysql_commit(), rollback() and
test_select_show(); /* prepare - show test */ autocommit() */
test_null(); /* test null data handling */ test_select_show(); /* prepare - show test */
test_simple_update(); /* simple prepare - update */ test_null(); /* test null data handling */
test_prepare_noparam(); /* prepare without parameters */ test_simple_update(); /* simple prepare - update */
test_select(); /* simple prepare-select */ test_prepare_noparam(); /* prepare without parameters */
test_insert(); /* prepare with insert */ test_select(); /* simple prepare-select */
test_bind_result(); /* result bind test */ test_insert(); /* prepare with insert */
test_long_data(); /* long data handling in pieces */ test_bind_result(); /* result bind test */
test_prepare_simple(); /* simple prepare */ test_long_data(); /* long data handling in pieces */
test_prepare(); /* prepare test */ test_prepare_simple(); /* simple prepare */
test_null(); /* test null data handling */ test_prepare(); /* prepare test */
test_debug_example(); /* some debugging case */ test_null(); /* test null data handling */
test_update(); /* prepare-update test */ test_debug_example(); /* some debugging case */
test_simple_update(); /* simple prepare with update */ test_update(); /* prepare-update test */
test_long_data(); /* long data handling in pieces */ test_simple_update(); /* simple prepare with update */
test_simple_delete(); /* prepare with delete */ test_long_data(); /* long data handling in pieces */
test_field_names(); /* test for field names */ test_simple_delete(); /* prepare with delete */
test_double_compare(); /* float comparision */ test_field_names(); /* test for field names */
client_query(); /* simple client query test */ test_double_compare(); /* float comparision */
client_store_result(); /* usage of mysql_store_result() */ client_query(); /* simple client query test */
client_use_result(); /* usage of mysql_use_result() */ client_store_result(); /* usage of mysql_store_result() */
test_tran_bdb(); /* transaction test on BDB table type */ client_use_result(); /* usage of mysql_use_result() */
test_tran_innodb(); /* transaction test on InnoDB table type */ test_tran_bdb(); /* transaction test on BDB table type */
test_prepare_ext(); /* test prepare with all types conversion -- TODO */ test_tran_innodb(); /* transaction test on InnoDB table type */
test_prepare_syntax(); /* syntax check for prepares */ test_prepare_ext(); /* test prepare with all types conversion -- TODO */
test_prepare_field_result(); /* prepare meta info */ test_prepare_syntax(); /* syntax check for prepares */
test_prepare_resultset(); /* prepare meta info test */ test_prepare_field_result(); /* prepare meta info */
test_field_names(); /* test for field names */ test_prepare_resultset(); /* prepare meta info test */
test_field_flags(); /* test to help .NET provider team */ test_field_names(); /* test for field names */
test_long_data_str(); /* long data handling */ test_field_flags(); /* test to help .NET provider team */
test_long_data_str1(); /* yet another long data handling */ test_long_data_str(); /* long data handling */
test_long_data_bin(); /* long binary insertion */ test_long_data_str1(); /* yet another long data handling */
test_warnings(); /* show warnings test */ test_long_data_bin(); /* long binary insertion */
test_errors(); /* show errors test */ test_warnings(); /* show warnings test */
test_select_simple(); /* simple select prepare */ test_errors(); /* show errors test */
test_prepare_resultset();/* prepare meta info test */ test_select_simple(); /* simple select prepare */
test_func_fields(); /* FUNCTION field info */ test_prepare_resultset();/* prepare meta info test */
/*test_stmt_close(); */ /* mysql_stmt_close() test -- hangs */ test_func_fields(); /* FUNCTION field info */
test_prepare_field_result(); /* prepare meta info */ /*test_stmt_close(); */ /* mysql_stmt_close() test -- hangs */
test_multi_stmt(); /* multi stmt test */ test_prepare_field_result(); /* prepare meta info */
test_store_result(); /* test the store_result */ test_multi_stmt(); /* multi stmt test */
test_store_result1(); /* test store result without buffers */ test_store_result(); /* test the store_result */
test_store_result2(); /* test store result for misc case */ test_store_result1(); /* test store result without buffers */
test_multi_stmt(); /* test multi stmt */ test_store_result2(); /* test store result for misc case */
test_subselect(); /* test subselect prepare */ test_multi_stmt(); /* test multi stmt */
test_multi_query(); /* test multi query exec */ test_subselect(); /* test subselect prepare */
/* End of tests */ test_multi_query(); /* test multi query exec */
/* End of tests */
}
client_disconnect(); /* disconnect from server */ client_disconnect(); /* disconnect from server */
fprintf(stdout,"\n\nSUCCESS !!!\n"); fprintf(stdout,"\n\nSUCCESS !!!\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment