mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Changed mysql_next_result() to return int instead of bool
Changed ~Item_func_in() to call cleanup() (to fix memory leak) Fixed test_multi_statements() test in client_test
This commit is contained in:
@ -604,7 +604,7 @@ MYSQL_RES *STDCALL mysql_param_result(MYSQL_STMT *stmt);
|
||||
my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt);
|
||||
int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt);
|
||||
my_bool STDCALL mysql_more_results(MYSQL *mysql);
|
||||
my_bool STDCALL mysql_next_result(MYSQL *mysql);
|
||||
int STDCALL mysql_next_result(MYSQL *mysql);
|
||||
MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt,
|
||||
MYSQL_ROW_OFFSET offset);
|
||||
MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt);
|
||||
|
@ -3317,7 +3317,7 @@ my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt)
|
||||
my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt)
|
||||
{
|
||||
MYSQL *mysql;
|
||||
DBUG_ENTER("mysql_stmt_close");
|
||||
DBUG_ENTER("mysql_stmt_free_result");
|
||||
|
||||
DBUG_ASSERT(stmt != 0);
|
||||
|
||||
@ -3498,10 +3498,18 @@ my_bool STDCALL mysql_more_results(MYSQL *mysql)
|
||||
Reads and returns the next query results
|
||||
*/
|
||||
|
||||
my_bool STDCALL mysql_next_result(MYSQL *mysql)
|
||||
int STDCALL mysql_next_result(MYSQL *mysql)
|
||||
{
|
||||
DBUG_ENTER("mysql_next_result");
|
||||
|
||||
if (mysql->status != MYSQL_STATUS_READY)
|
||||
{
|
||||
strmov(mysql->net.sqlstate, unknown_sqlstate);
|
||||
strmov(mysql->net.last_error,
|
||||
ER(mysql->net.last_errno=CR_COMMANDS_OUT_OF_SYNC));
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
mysql->net.last_error[0]= 0;
|
||||
mysql->net.last_errno= 0;
|
||||
strmov(mysql->net.sqlstate, not_error_sqlstate);
|
||||
@ -3510,9 +3518,10 @@ my_bool STDCALL mysql_next_result(MYSQL *mysql)
|
||||
if (mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS)
|
||||
DBUG_RETURN((*mysql->methods->read_query_result)(mysql));
|
||||
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(-1); /* No more results */
|
||||
}
|
||||
|
||||
|
||||
MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql)
|
||||
{
|
||||
return (*mysql->methods->use_result)(mysql);
|
||||
|
@ -1375,6 +1375,7 @@ cmp_item* cmp_item::get_comparator(Item *item)
|
||||
return 0; // to satisfy compiler :)
|
||||
}
|
||||
|
||||
|
||||
cmp_item* cmp_item_sort_string::make_same()
|
||||
{
|
||||
return new cmp_item_sort_string_in_static(cmp_charset);
|
||||
@ -1395,6 +1396,23 @@ cmp_item* cmp_item_row::make_same()
|
||||
return new cmp_item_row();
|
||||
}
|
||||
|
||||
|
||||
cmp_item_row::~cmp_item_row()
|
||||
{
|
||||
DBUG_ENTER("~cmp_item_row");
|
||||
DBUG_PRINT("enter",("this: %lx", this));
|
||||
if (comparators)
|
||||
{
|
||||
for (uint i= 0; i < n; i++)
|
||||
{
|
||||
if (comparators[i])
|
||||
delete comparators[i];
|
||||
}
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
void cmp_item_row::store_value(Item *item)
|
||||
{
|
||||
THD *thd= current_thd;
|
||||
@ -1404,18 +1422,16 @@ void cmp_item_row::store_value(Item *item)
|
||||
item->bring_value();
|
||||
item->null_value= 0;
|
||||
for (uint i=0; i < n; i++)
|
||||
if ((comparators[i]= cmp_item::get_comparator(item->el(i))))
|
||||
{
|
||||
if (!(comparators[i]= cmp_item::get_comparator(item->el(i))))
|
||||
break; // new failed
|
||||
comparators[i]->store_value(item->el(i));
|
||||
item->null_value|= item->el(i)->null_value;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void cmp_item_row::store_value_by_template(cmp_item *t, Item *item)
|
||||
{
|
||||
cmp_item_row *tmpl= (cmp_item_row*) t;
|
||||
@ -1430,19 +1446,17 @@ void cmp_item_row::store_value_by_template(cmp_item *t, Item *item)
|
||||
item->bring_value();
|
||||
item->null_value= 0;
|
||||
for (uint i=0; i < n; i++)
|
||||
if ((comparators[i]= tmpl->comparators[i]->make_same()))
|
||||
{
|
||||
if (!(comparators[i]= tmpl->comparators[i]->make_same()))
|
||||
break; // new failed
|
||||
comparators[i]->store_value_by_template(tmpl->comparators[i],
|
||||
item->el(i));
|
||||
item->null_value|= item->el(i)->null_value;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int cmp_item_row::cmp(Item *arg)
|
||||
{
|
||||
arg->null_value= 0;
|
||||
@ -1454,25 +1468,31 @@ int cmp_item_row::cmp(Item *arg)
|
||||
bool was_null= 0;
|
||||
arg->bring_value();
|
||||
for (uint i=0; i < n; i++)
|
||||
{
|
||||
if (comparators[i]->cmp(arg->el(i)))
|
||||
{
|
||||
if (!arg->el(i)->null_value)
|
||||
return 1;
|
||||
was_null= 1;
|
||||
}
|
||||
}
|
||||
return (arg->null_value= was_null);
|
||||
}
|
||||
|
||||
|
||||
int cmp_item_row::compare(cmp_item *c)
|
||||
{
|
||||
int res;
|
||||
cmp_item_row *cmp= (cmp_item_row *) c;
|
||||
for (uint i=0; i < n; i++)
|
||||
{
|
||||
int res;
|
||||
if ((res= comparators[i]->compare(cmp->comparators[i])))
|
||||
return res;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool Item_func_in::nulls_in_row()
|
||||
{
|
||||
Item **arg,**arg_end;
|
||||
@ -1484,6 +1504,7 @@ bool Item_func_in::nulls_in_row()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y)
|
||||
{
|
||||
return cs->coll->strnncollsp(cs,
|
||||
@ -1491,6 +1512,7 @@ static int srtcmp_in(CHARSET_INFO *cs, const String *x,const String *y)
|
||||
(unsigned char *) y->ptr(),y->length());
|
||||
}
|
||||
|
||||
|
||||
void Item_func_in::fix_length_and_dec()
|
||||
{
|
||||
Item **arg, **arg_end;
|
||||
|
@ -638,17 +638,7 @@ class cmp_item_row :public cmp_item
|
||||
uint n;
|
||||
public:
|
||||
cmp_item_row(): comparators(0), n(0) {}
|
||||
~cmp_item_row()
|
||||
{
|
||||
if (comparators)
|
||||
{
|
||||
for (uint i= 0; i < n; i++)
|
||||
{
|
||||
if (comparators[i])
|
||||
delete comparators[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
~cmp_item_row();
|
||||
void store_value(Item *item);
|
||||
int cmp(Item *arg);
|
||||
int compare(cmp_item *arg);
|
||||
@ -715,7 +705,10 @@ class Item_func_in :public Item_int_func
|
||||
}
|
||||
longlong val_int();
|
||||
void fix_length_and_dec();
|
||||
~Item_func_in() {}
|
||||
~Item_func_in()
|
||||
{
|
||||
cleanup(); /* This is not called by Item::~Item() */
|
||||
}
|
||||
void cleanup()
|
||||
{
|
||||
delete array;
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user