Commit e9aa3e36 authored by unknown's avatar unknown

assigning max_length parameter for Item_param (Bug #3811)


sql/item.cc:
  assigning max_length/decimal parameter for Item_param
tests/client_test.c:
  layout fixed
  test suite for bug
parent ccdbfd14
......@@ -646,6 +646,7 @@ void Item_param::set_null()
DBUG_ENTER("Item_param::set_null");
/* These are cleared after each execution by reset() method */
null_value= value_is_set= 1;
max_length= 0;
DBUG_VOID_RETURN;
}
......@@ -656,6 +657,7 @@ void Item_param::set_int(longlong i)
item_type= INT_ITEM;
value_is_set= 1;
maybe_null= 0;
max_length= 11;
DBUG_PRINT("info", ("integer: %lld", int_value));
DBUG_VOID_RETURN;
}
......@@ -667,6 +669,8 @@ void Item_param::set_double(double value)
item_type= REAL_ITEM;
value_is_set= 1;
maybe_null= 0;
decimals= NOT_FIXED_DEC;
max_length= DBL_DIG + 8;;
DBUG_PRINT("info", ("double: %lg", real_value));
DBUG_VOID_RETURN;
}
......@@ -679,6 +683,7 @@ void Item_param::set_value(const char *str, uint length)
item_type= STRING_ITEM;
value_is_set= 1;
maybe_null= 0;
max_length= length;
DBUG_PRINT("info", ("string: %s", str_value.ptr()));
DBUG_VOID_RETURN;
}
......@@ -704,6 +709,20 @@ void Item_param::set_time(TIME *tm, timestamp_type type)
item_type= STRING_ITEM;
value_is_set= 1;
maybe_null= 0;
switch(type)
{
case TIMESTAMP_DATE:
max_length= 10;
break;
case TIMESTAMP_DATETIME:
max_length= 19;
break;
case TIMESTAMP_TIME:
max_length= 8;
break;
default:
DBUG_ASSERT(0); // it should be impossible
}
}
......
......@@ -9143,7 +9143,7 @@ static void test_derived()
int rc, i;
MYSQL_BIND bind[1];
long my_val = 0L;
ulong my_length = 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";
......@@ -9640,6 +9640,47 @@ group by b ");
}
static void test_union_param()
{
MYSQL_STMT *stmt;
char *query;
int rc, i;
MYSQL_BIND bind[2];
char my_val[4];
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));
check_stmt(stmt);
/* bind parameters */
bind[0].buffer_type= FIELD_TYPE_STRING;
bind[0].buffer= &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= &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);
for (i= 0; i < 3; i++)
{
rc= mysql_stmt_execute(stmt);
check_execute(stmt,rc);
assert(1 == my_process_stmt_result(stmt));
}
mysql_stmt_close(stmt);
}
/*
Read and parse arguments and MySQL options from my.cnf
*/
......@@ -9784,6 +9825,7 @@ int main(int argc, char **argv)
start_time= time((time_t *)0);
test_union_param();
client_query(); /* simple client query test */
#if NOT_YET_WORKING
/* Used for internal new development debugging */
......
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