Commit c583e264 authored by unknown's avatar unknown

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.


include/sql_common.h:
  Declare auxiliary functions to manipulate mysql.net.last_er* and 
  mysql_stmt.last_er*
libmysql/libmysql.c:
  Use helper functions to set an error in MYSQL or MYSQL_STMT
libmysqld/lib_sql.cc:
  Use helper functions to set an error in MYSQL or MYSQL_STMT
sql-common/client.c:
  Use helper functions to set an error in MYSQL or MYSQL_STMT
parent 98a07054
......@@ -36,8 +36,10 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
const unsigned char *arg, ulong arg_length,
my_bool skip_check, MYSQL_STMT *stmt);
unsigned long cli_safe_read(MYSQL *mysql);
void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode,
const char *sqlstate);
void net_clear_error(NET *net);
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);
#ifdef __cplusplus
}
......
This diff is collapsed.
......@@ -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);
}
......
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