1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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.
This commit is contained in:
kostja@bodhi.(none)
2007-10-31 17:16:53 +03:00
parent cd72fffa5f
commit 96f8d086f8
4 changed files with 144 additions and 184 deletions

View File

@ -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 */
if (mysql->status != MYSQL_STATUS_READY)
{
strmov(net->last_error,
ER(net->last_errno=CR_COMMANDS_OUT_OF_SYNC));
set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
return 1;
}
@ -90,7 +89,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
thd->clear_error();
mysql->affected_rows= ~(my_ulonglong) 0;
mysql->field_count= 0;
net->last_errno= 0;
net_clear_error(net);
thd->current_stmt= stmt;
thd->store_globals(); // Fix if more than one connect
@ -245,8 +244,7 @@ static my_bool emb_read_query_result(MYSQL *mysql)
mysql->fields= res->embedded_info->fields_list;
mysql->affected_rows= res->embedded_info->affected_rows;
mysql->insert_id= res->embedded_info->insert_id;
mysql->net.last_errno= 0;
mysql->net.last_error[0]= 0;
net_clear_error(&mysql->net);
mysql->info= 0;
if (res->embedded_info->info[0])
@ -288,7 +286,7 @@ static int emb_stmt_execute(MYSQL_STMT *stmt)
if (res)
{
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(0);
@ -299,14 +297,12 @@ int emb_read_binary_rows(MYSQL_STMT *stmt)
MYSQL_DATA *data;
if (!(data= emb_read_rows(stmt->mysql, 0, 0)))
{
set_stmt_errmsg(stmt, stmt->mysql->net.last_error,
stmt->mysql->net.last_errno, stmt->mysql->net.sqlstate);
set_stmt_errmsg(stmt, &stmt->mysql->net);
return 1;
}
stmt->result= *data;
my_free((char *) data, MYF(0));
set_stmt_errmsg(stmt, stmt->mysql->net.last_error,
stmt->mysql->net.last_errno, stmt->mysql->net.sqlstate);
set_stmt_errmsg(stmt, &stmt->mysql->net);
return 0;
}
@ -320,16 +316,14 @@ int emb_read_rows_from_cursor(MYSQL_STMT *stmt)
if (res->embedded_info->last_errno)
{
embedded_get_error(mysql, res);
set_stmt_errmsg(stmt, mysql->net.last_error,
mysql->net.last_errno, mysql->net.sqlstate);
set_stmt_errmsg(stmt, &mysql->net);
return 1;
}
thd->cur_data= res;
mysql->warning_count= res->embedded_info->warning_count;
mysql->server_status= res->embedded_info->server_status;
mysql->net.last_errno= 0;
mysql->net.last_error[0]= 0;
net_clear_error(&mysql->net);
return emb_read_binary_rows(stmt);
}