1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Fixes for bugs in embedded library:

#4700 (Unsigned value returned as signed)
    just no appropriate checking
#4701 (Errors returned earlier than expected)
    all errors returned from send_command()
#4702 (Result isn't freed properly if there's no retrieval)
    flush_use_result has only 'client' version and should
    be made 'virtual'


include/mysql.h:
  flush_use_result 'virtual' method added to MYSQL (#4701)
include/sql_common.h:
  no flush_use_result() now (#4702)
libmysql/libmysql.c:
  call of the flush_use_result changed (#4702)
libmysqld/lib_sql.cc:
  now errors returned from emb_advanced_command() or from emb_read_rows()
  depending on if number of returned fields is not 0 (#4701)
  emb_flush_use_result() implementation (#4702)
sql-common/client.c:
  cli_flush_use_result() implementation (#4702)
sql/sql_prepare.cc:
  unsigned flag now checked (#4700)
This commit is contained in:
unknown
2004-07-22 20:54:25 +05:00
parent be922a58e9
commit 2cd7e4cdef
6 changed files with 29 additions and 7 deletions

View File

@@ -84,6 +84,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;
thd->store_globals(); // Fix if more than one connect
/*
@@ -107,17 +108,32 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
if (!skip_check)
result= thd->net.last_errno ? -1 : 0;
embedded_get_error(mysql);
if (!mysql->field_count)
embedded_get_error(mysql);
mysql->server_status= thd->server_status;
mysql->warning_count= ((THD*)mysql->thd)->total_warn_count;
return result;
}
static void emb_flush_use_result(MYSQL *mysql)
{
MYSQL_DATA *data= ((THD*)(mysql->thd))->data;
if (data)
{
free_rows(data);
((THD*)(mysql->thd))->data= NULL;
}
}
static MYSQL_DATA *
emb_read_rows(MYSQL *mysql, MYSQL_FIELD *mysql_fields __attribute__((unused)),
unsigned int fields __attribute__((unused)))
{
MYSQL_DATA *result= ((THD*)mysql->thd)->data;
embedded_get_error(mysql);
if (mysql->net.last_errno)
return NULL;
if (!result)
{
if (!(result=(MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA),
@@ -227,6 +243,9 @@ int emb_read_binary_rows(MYSQL_STMT *stmt)
int emb_unbuffered_fetch(MYSQL *mysql, char **row)
{
MYSQL_DATA *data= ((THD*)mysql->thd)->data;
embedded_get_error(mysql);
if (mysql->net.last_errno)
return mysql->net.last_errno;
if (!data || !data->data)
{
*row= NULL;
@@ -293,6 +312,7 @@ MYSQL_METHODS embedded_methods=
emb_read_rows,
emb_mysql_store_result,
emb_fetch_lengths,
emb_flush_use_result,
emb_list_fields,
emb_read_prepare_result,
emb_stmt_execute,