Commit cd5ef4d9 authored by unknown's avatar unknown

item.cc:

  Fix for save_in_field to take extra bool argumnet (4.0 merge compatibility)


sql/item.cc:
  Fix for save_in_field to take extra bool argumnet (missed one)
sql/sql_prepare.cc:
  cleanups for init_param_items
parent baebdcfc
......@@ -323,6 +323,6 @@ void my_thread_end(void);
#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
#define MYSQL_STMT_HEADER 4
#define MYSQL_LONG_DATA_HEADER 8
#define MYSQL_LONG_DATA_HEADER 6
#endif
......@@ -4333,7 +4333,6 @@ mysql_send_long_data(MYSQL_STMT *stmt, uint param_number,
packet= extra_data;
int4store(packet, stmt->stmt_id); packet+=4;
int2store(packet, param_number); packet+=2;
int2store(packet, param->buffer_type); packet+=2;
/*
Note that we don't get any ok packet from the server in this case
......
......@@ -351,7 +351,7 @@ void Item_param::set_longdata(const char *str, ulong length)
}
int Item_param::save_in_field(Field *field)
int Item_param::save_in_field(Field *field, bool no_conversions)
{
if (null_value)
return (int) set_field_to_null(field);
......
......@@ -252,7 +252,7 @@ public:
longlong val_int();
String *val_str(String*);
void make_field(Send_field *field);
int save_in_field(Field *field);
int save_in_field(Field *field, bool no_conversions);
void set_null();
void set_int(longlong i);
void set_double(double i);
......
......@@ -321,14 +321,14 @@ public:
typedef struct st_prep_stmt
{
THD *thd;
Item_param *param;
Item_param **param;
Item *free_list;
MEM_ROOT mem_root;
ulong stmt_id;
uint param_count;
uint last_errno;
char last_error[MYSQL_ERRMSG_SIZE];
bool error_in_prepare, long_data_used, param_inited;
bool error_in_prepare, long_data_used;
} PREP_STMT;
......
......@@ -310,11 +310,8 @@ static bool setup_params_data(PREP_STMT *stmt)
*/
while ((param= (Item_param *)param_iterator++))
{
if (!param->long_data_supplied)
{
setup_param_functions(param,*read_pos);
read_pos+= 2;
}
setup_param_functions(param,*read_pos);
read_pos+= 2;
}
param_iterator.rewind();
}
......@@ -615,7 +612,7 @@ static bool parse_prepare_query(PREP_STMT *stmt,
mysql_log.write(thd,COM_PREPARE,"%s",packet);
mysql_init_query(thd);
thd->prepare_command=true;
thd->lex.param_count=0;
thd->lex.param_count= 0;
LEX *lex=lex_start(thd, (uchar*) packet, length);
lex->safe_to_cache_query= 0;
......@@ -630,18 +627,13 @@ static bool parse_prepare_query(PREP_STMT *stmt,
*/
static bool init_param_items(THD *thd, PREP_STMT *stmt)
{
#if TO_BE_TESTED
Item_param **to;
if (!(to= (Item_param *)
my_malloc(sizeof(Item_param*) * stmt->param_count, MYF(MY_WME))))
if (!(stmt->param= to= (Item_param **)
my_malloc(sizeof(Item_param *)*(stmt->param_count+1),
MYF(MY_WME))))
return 1;
List<Item> &params= thd->lex.param_list;
List_iterator<Item> param_iterator(params);
while ((to++ = (Item_param *)param_iterator++))
{
DBUG_PRINT("info",("param: %lx", to));
}
#endif
List_iterator<Item> param_iterator(thd->lex.param_list);
while ((*(to++) = (Item_param *)param_iterator++));
return 0;
}
......@@ -678,10 +670,10 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length)
if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(),WAIT_PRIOR);
#if 0
if (init_param_items(thd, &stmt))
goto err;
#endif
stmt.mem_root= thd->mem_root;
tree_insert(&thd->prepared_statements, (void *)&stmt, 0, (void *)0);
thd->mem_root= thd_root; // restore main mem_root
......@@ -769,8 +761,8 @@ void mysql_stmt_reset(THD *thd, char *packet)
DBUG_VOID_RETURN;
}
stmt->error_in_prepare=0;
Item_param *item= stmt->param, *end= item + stmt->param_count;
stmt->error_in_prepare= 0;
Item_param *item= *stmt->param, *end= item + stmt->param_count;
/* Free long data if used */
if (stmt->long_data_used)
......@@ -795,12 +787,10 @@ void mysql_stmt_free(THD *thd, char *packet)
if (!(stmt=find_prepared_statement(thd, stmt_id, "close")))
{
send_error(thd);
send_error(thd); // Not seen by the client
DBUG_VOID_RETURN;
}
stmt->param= 0;
my_free((char *)stmt->param, MYF(MY_ALLOW_ZERO_PTR));
/* Will call free_prep_stmt() */
tree_delete(&thd->prepared_statements, (void*) &stmt, (void *)0);
thd->last_prepared_stmt=0;
DBUG_VOID_RETURN;
......@@ -840,8 +830,7 @@ void mysql_stmt_get_longdata(THD *thd, char *pos, ulong packet_length)
ulong stmt_id= uint4korr(pos);
uint param_number= uint2korr(pos+4);
uint param_type= uint2korr(pos+6);
pos+=MYSQL_LONG_DATA_HEADER; // Point to data
pos+= MYSQL_LONG_DATA_HEADER; // Point to data
if (!(stmt=find_prepared_statement(thd, stmt_id, "get_longdata")))
{
......@@ -855,12 +844,14 @@ void mysql_stmt_get_longdata(THD *thd, char *pos, ulong packet_length)
if (param_number >= stmt->param_count)
{
stmt->error_in_prepare=1;
stmt->last_errno=ER_WRONG_ARGUMENTS;
/* Error will be sent in execute call */
stmt->error_in_prepare= 1;
stmt->last_errno= ER_WRONG_ARGUMENTS;
sprintf(stmt->last_error, ER(ER_WRONG_ARGUMENTS), "get_longdata");
DBUG_VOID_RETURN;
}
stmt->param[param_number].set_longdata(pos, packet_length-9);
Item_param *param= *(stmt->param+param_number);
param->set_longdata(pos, packet_length-MYSQL_LONG_DATA_HEADER-1);
stmt->long_data_used= 1;
DBUG_VOID_RETURN;
}
......
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