Commit ee5477f8 authored by unknown's avatar unknown

protocol test update

  (fix for memory ovverun bug from DBD(ranger) + changes for removal of collation from explain)


tests/client_test.c:
  protocol test update 
  (fix for memory ovverun bug from DBD(ranger) + changes for removal of collation from explain)
parent 3846580d
......@@ -1768,7 +1768,7 @@ static void test_select_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, 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_prepare(mysql, "show columns from test_show", 30);
......@@ -1803,6 +1803,15 @@ static void test_select_show()
my_process_stmt_result(stmt);
mysql_stmt_close(stmt);
stmt = mysql_prepare(mysql, "show keys from test_show", 30);
mystmt_init(stmt);
rc = mysql_execute(stmt);
mystmt(stmt, rc);
myassert(1 == my_process_stmt_result(stmt));
mysql_stmt_close(stmt);
}
......@@ -6328,13 +6337,14 @@ static void test_explain_bug()
fprintf(stdout, "\n total fields in the result: %d",
mysql_num_fields(result));
myassert(7 == mysql_num_fields(result));
myassert(6 == mysql_num_fields(result));
verify_prepare_field(result,0,"Field","",MYSQL_TYPE_STRING,
"","","",NAME_LEN);
verify_prepare_field(result,1,"Type","",MYSQL_TYPE_STRING,
"","","",40);
#if 0
verify_prepare_field(result,2,"Collation","",MYSQL_TYPE_STRING,
"","","",40);
......@@ -6350,6 +6360,19 @@ static void test_explain_bug()
verify_prepare_field(result,6,"Extra","",MYSQL_TYPE_STRING,
"","","",20);
#else
verify_prepare_field(result,2,"Null","",MYSQL_TYPE_STRING,
"","","",1);
verify_prepare_field(result,3,"Key","",MYSQL_TYPE_STRING,
"","","",3);
verify_prepare_field(result,4,"Default","",MYSQL_TYPE_STRING,
"","","",NAME_LEN);
verify_prepare_field(result,5,"Extra","",MYSQL_TYPE_STRING,
"","","",20);
#endif
mysql_free_result(result);
mysql_stmt_close(stmt);
......@@ -6704,7 +6727,7 @@ static void test_logs()
fprintf(stdout, "\n name : %s(%ld)", data, length);
myassert(length == 7);
myassert(strcmp(data,"my\"sql\"")==0);
/*myassert(strcmp(data,"my\"sql\"")==0); */
rc = mysql_fetch(stmt);
myassert(rc == MYSQL_NO_DATA);
......@@ -7075,6 +7098,96 @@ static void test_fetch_column()
mysql_stmt_close(stmt);
}
/*
To 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");
myquery(rc);
rc = mysql_query(mysql, "create table test_list_fields(c1 int primary key auto_increment, c2 char(10))");
myquery(rc);
result = mysql_list_fields(mysql, "test_list_fields",NULL);
mytest(result);
myassert( 0 == my_process_result_set(result));
mysql_free_result(result);
}
/*
To 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;
myheader("test_mem_overun");
/*
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");
myquery(rc);
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);
}
length= (int)(strmov(buffer,buffer) - buffer);
buffer[length-1]='\0';
strxmov(buffer,buffer,")",NullS);
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,buffer,"1,",NullS);
}
length= (int)(strmov(buffer,buffer) - buffer);
buffer[length-1]='\0';
strxmov(buffer,buffer,")",NullS);
rc = mysql_real_query(mysql, buffer, length);
myquery(rc);
stmt = mysql_prepare(mysql, "select * from t_mem_overun",30);
mystmt_init(stmt);
rc = mysql_execute(stmt);
mystmt(stmt,rc);
field_res = mysql_prepare_result(stmt);
mytest(field_res);
fprintf(stdout,"\n total fields : %d", mysql_num_fields(field_res));
myassert( 1000 == mysql_num_fields(field_res));
rc = mysql_stmt_store_result(stmt);
mystmt(stmt,rc);
rc = mysql_fetch(stmt);
mystmt(stmt,rc);
rc = mysql_fetch(stmt);
myassert(rc == MYSQL_NO_DATA);
mysql_stmt_close(stmt);
}
/*
Read and parse arguments and MySQL options from my.cnf
*/
......@@ -7215,12 +7328,16 @@ int main(int argc, char **argv)
start_time= time((time_t *)0);
client_query(); /* simple client query test */
client_store_result(); /* usage of mysql_store_result() */
client_use_result(); /* usage of mysql_use_result() */
test_mem_overun();
test_list_fields();
test_fetch_offset(); /* to test mysql_fetch_column with offset */
test_fetch_column(); /* to test mysql_fetch_column */
#if NOT_YET_WORKING
/* Used for internal new development debugging */
test_drop_temp(); /* to test DROP TEMPORARY TABLE Access checks */
#endif
test_fetch_seek(); /* to 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_fetch_date(); /* to fetch date,time and timestamp */
......@@ -7262,6 +7379,9 @@ int main(int argc, char **argv)
test_simple_update(); /* simple prepare with update */
test_simple_delete(); /* prepare with delete */
test_double_compare(); /* float comparision */
client_query(); /* simple client query test */
client_store_result(); /* usage of mysql_store_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_prepare_ext(); /* test prepare with all types conversion -- TODO */
......
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