diff options
author | unknown <hf@deer.(none)> | 2004-07-22 20:54:25 +0500 |
---|---|---|
committer | unknown <hf@deer.(none)> | 2004-07-22 20:54:25 +0500 |
commit | 2cd7e4cdefec2bd529a5de78e0d8c8adb636b036 (patch) | |
tree | ecfe787be62082cf510021730f7750916b699945 /libmysqld | |
parent | be922a58e91ec1df465ec2451787549d6aadbbcf (diff) | |
download | mariadb-git-2cd7e4cdefec2bd529a5de78e0d8c8adb636b036.tar.gz |
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)
Diffstat (limited to 'libmysqld')
-rw-r--r-- | libmysqld/lib_sql.cc | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 0adf9aeb86a..e3d68fbb8eb 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -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, |