Commit 96f8d086 authored by kostja@bodhi.(none)'s avatar kostja@bodhi.(none)

Cleanup: use helper functions to set an error in MYSQL or MYSQL_STMT.

No functionality added or changed.
This is a pre-requisite for the fix for Bug#12713 Error in a stored 
function called from a SELECT doesn't cause ROLLBACK of statem

Address post-review comments.
parent cd72fffa
...@@ -36,8 +36,10 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command, ...@@ -36,8 +36,10 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
const unsigned char *arg, ulong arg_length, const unsigned char *arg, ulong arg_length,
my_bool skip_check, MYSQL_STMT *stmt); my_bool skip_check, MYSQL_STMT *stmt);
unsigned long cli_safe_read(MYSQL *mysql); unsigned long cli_safe_read(MYSQL *mysql);
void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode, void net_clear_error(NET *net);
const char *sqlstate); void set_stmt_errmsg(MYSQL_STMT *stmt, NET *net);
void set_stmt_error(MYSQL_STMT *stmt, int errcode, const char *sqlstate,
const char *err);
void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate); void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
This diff is collapsed.
...@@ -81,8 +81,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, ...@@ -81,8 +81,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
/* Check that we are calling the client functions in right order */ /* Check that we are calling the client functions in right order */
if (mysql->status != MYSQL_STATUS_READY) if (mysql->status != MYSQL_STATUS_READY)
{ {
strmov(net->last_error, set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
ER(net->last_errno=CR_COMMANDS_OUT_OF_SYNC));
return 1; return 1;
} }
...@@ -90,7 +89,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, ...@@ -90,7 +89,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
thd->clear_error(); thd->clear_error();
mysql->affected_rows= ~(my_ulonglong) 0; mysql->affected_rows= ~(my_ulonglong) 0;
mysql->field_count= 0; mysql->field_count= 0;
net->last_errno= 0; net_clear_error(net);
thd->current_stmt= stmt; thd->current_stmt= stmt;
thd->store_globals(); // Fix if more than one connect thd->store_globals(); // Fix if more than one connect
...@@ -245,8 +244,7 @@ static my_bool emb_read_query_result(MYSQL *mysql) ...@@ -245,8 +244,7 @@ static my_bool emb_read_query_result(MYSQL *mysql)
mysql->fields= res->embedded_info->fields_list; mysql->fields= res->embedded_info->fields_list;
mysql->affected_rows= res->embedded_info->affected_rows; mysql->affected_rows= res->embedded_info->affected_rows;
mysql->insert_id= res->embedded_info->insert_id; mysql->insert_id= res->embedded_info->insert_id;
mysql->net.last_errno= 0; net_clear_error(&mysql->net);
mysql->net.last_error[0]= 0;
mysql->info= 0; mysql->info= 0;
if (res->embedded_info->info[0]) if (res->embedded_info->info[0])
...@@ -288,7 +286,7 @@ static int emb_stmt_execute(MYSQL_STMT *stmt) ...@@ -288,7 +286,7 @@ static int emb_stmt_execute(MYSQL_STMT *stmt)
if (res) if (res)
{ {
NET *net= &stmt->mysql->net; NET *net= &stmt->mysql->net;
set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); set_stmt_errmsg(stmt, net);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -299,14 +297,12 @@ int emb_read_binary_rows(MYSQL_STMT *stmt) ...@@ -299,14 +297,12 @@ int emb_read_binary_rows(MYSQL_STMT *stmt)
MYSQL_DATA *data; MYSQL_DATA *data;
if (!(data= emb_read_rows(stmt->mysql, 0, 0))) if (!(data= emb_read_rows(stmt->mysql, 0, 0)))
{ {
set_stmt_errmsg(stmt, stmt->mysql->net.last_error, set_stmt_errmsg(stmt, &stmt->mysql->net);
stmt->mysql->net.last_errno, stmt->mysql->net.sqlstate);
return 1; return 1;
} }
stmt->result= *data; stmt->result= *data;
my_free((char *) data, MYF(0)); my_free((char *) data, MYF(0));
set_stmt_errmsg(stmt, stmt->mysql->net.last_error, set_stmt_errmsg(stmt, &stmt->mysql->net);
stmt->mysql->net.last_errno, stmt->mysql->net.sqlstate);
return 0; return 0;
} }
...@@ -320,16 +316,14 @@ int emb_read_rows_from_cursor(MYSQL_STMT *stmt) ...@@ -320,16 +316,14 @@ int emb_read_rows_from_cursor(MYSQL_STMT *stmt)
if (res->embedded_info->last_errno) if (res->embedded_info->last_errno)
{ {
embedded_get_error(mysql, res); embedded_get_error(mysql, res);
set_stmt_errmsg(stmt, mysql->net.last_error, set_stmt_errmsg(stmt, &mysql->net);
mysql->net.last_errno, mysql->net.sqlstate);
return 1; return 1;
} }
thd->cur_data= res; thd->cur_data= res;
mysql->warning_count= res->embedded_info->warning_count; mysql->warning_count= res->embedded_info->warning_count;
mysql->server_status= res->embedded_info->server_status; mysql->server_status= res->embedded_info->server_status;
mysql->net.last_errno= 0; net_clear_error(&mysql->net);
mysql->net.last_error[0]= 0;
return emb_read_binary_rows(stmt); return emb_read_binary_rows(stmt);
} }
......
This diff is collapsed.
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