Commit 015a65a7 authored by venu@myvenu.com's avatar venu@myvenu.com

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

into myvenu.com:/home/venu/work/sql/dev-4.1
parents f8791c39 45dcca73
...@@ -530,6 +530,11 @@ void Item_param::set_longdata(const char *str, ulong length) ...@@ -530,6 +530,11 @@ void Item_param::set_longdata(const char *str, ulong length)
int Item_param::save_in_field(Field *field, bool no_conversions) int Item_param::save_in_field(Field *field, bool no_conversions)
{ {
THD *thd= current_thd;
if (thd->command == COM_PREPARE)
return -1;
if (null_value) if (null_value)
return (int) set_field_to_null(field); return (int) set_field_to_null(field);
......
...@@ -7467,24 +7467,26 @@ static void test_sqlmode() ...@@ -7467,24 +7467,26 @@ static void test_sqlmode()
static void test_ts() static void test_ts()
{ {
MYSQL_STMT *stmt; MYSQL_STMT *stmt;
MYSQL_BIND bind[2]; MYSQL_BIND bind[6];
MYSQL_TIME ts; MYSQL_TIME ts;
MYSQL_RES *prep_res;
char strts[30]; char strts[30];
long length; long length;
int rc; int rc, field_count;
char name;
myheader("test_ts"); myheader("test_ts");
rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_ts"); rc = mysql_query(mysql,"DROP TABLE IF EXISTS test_ts");
myquery(rc); myquery(rc);
rc= mysql_query(mysql,"CREATE TABLE test_ts(a TIMESTAMP)"); rc= mysql_query(mysql,"CREATE TABLE test_ts(a DATE, b TIME, c TIMESTAMP)");
myquery(rc); myquery(rc);
rc = mysql_commit(mysql); rc = mysql_commit(mysql);
myquery(rc); myquery(rc);
stmt = mysql_prepare(mysql,"INSERT INTO test_ts VALUES(?),(?)",40); stmt = mysql_prepare(mysql,"INSERT INTO test_ts VALUES(?,?,?),(?,?,?)",50);
mystmt_init(stmt); mystmt_init(stmt);
ts.year= 2003; ts.year= 2003;
...@@ -7495,17 +7497,21 @@ static void test_ts() ...@@ -7495,17 +7497,21 @@ static void test_ts()
ts.second= 46; ts.second= 46;
length= (long)(strmov(strts,"2003-07-12 21:07:46") - strts); length= (long)(strmov(strts,"2003-07-12 21:07:46") - strts);
bind[0].buffer_type= MYSQL_TYPE_STRING; bind[0].buffer_type= MYSQL_TYPE_TIMESTAMP;
bind[0].buffer= (char *)strts; bind[0].buffer= (char *)&ts;
bind[0].buffer_length= sizeof(strts); bind[0].buffer_length= sizeof(ts);
bind[0].is_null= 0; bind[0].is_null= 0;
bind[0].length= &length; bind[0].length= 0;
bind[1].buffer_type= MYSQL_TYPE_TIMESTAMP; bind[2]= bind[1]= bind[0];
bind[1].buffer= (char *)&ts;
bind[1].buffer_length= sizeof(ts); bind[3].buffer_type= MYSQL_TYPE_STRING;
bind[1].is_null= 0; bind[3].buffer= (char *)strts;
bind[1].length= 0; 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); rc = mysql_bind_param(stmt, bind);
mystmt(stmt,rc); mystmt(stmt,rc);
...@@ -7515,27 +7521,49 @@ static void test_ts() ...@@ -7515,27 +7521,49 @@ static void test_ts()
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
verify_col_data("test_ts","a","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_prepare(mysql,"SELECT a FROM test_ts WHERE a >= ?",50); stmt = mysql_prepare(mysql,"SELECT * FROM test_ts",50);
mystmt_init(stmt); mystmt_init(stmt);
rc = mysql_bind_param(stmt, bind); prep_res = mysql_prepare_result(stmt);
mystmt(stmt,rc); mytest(prep_res);
rc = mysql_execute(stmt); rc = mysql_execute(stmt);
mystmt(stmt,rc); mystmt(stmt,rc);
rc = mysql_fetch(stmt); myassert( 2== my_process_stmt_result(stmt));
field_count= mysql_num_fields(prep_res);
mysql_free_result(prep_res);
mysql_stmt_close(stmt);
for (name= 'a'; field_count--; name++)
{
int row_count= 0;
sprintf(query,"SELECT a,b,c FROM test_ts WHERE %c=?",name);
length= (long)(strmov(query,query)- query);
fprintf(stdout,"\n %s", query);
stmt = mysql_prepare(mysql, query, length);
mystmt_init(stmt);
rc = mysql_bind_param(stmt, bind);
mystmt(stmt,rc); mystmt(stmt,rc);
rc = mysql_fetch(stmt); rc = mysql_execute(stmt);
mystmt(stmt,rc); mystmt(stmt,rc);
rc = mysql_fetch(stmt); while (mysql_fetch(stmt) == 0)
myassert(rc == MYSQL_NO_DATA); row_count++;
fprintf(stdout, "\n returned '%d' rows", row_count);
myassert(row_count == 2);
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
}
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment