diff options
author | hf@deer.(none) <> | 2003-07-23 15:23:20 +0500 |
---|---|---|
committer | hf@deer.(none) <> | 2003-07-23 15:23:20 +0500 |
commit | a4f899dfc0a96ab95e64b11a1890736feab72d3b (patch) | |
tree | 4f5589680b89450eee716ef28e4b85348fdb2c1f /libmysqld | |
parent | 2e35e6f866adce1c2a4d8397c8a259a3c5a9e02f (diff) | |
download | mariadb-git-a4f899dfc0a96ab95e64b11a1890736feab72d3b.tar.gz |
SCRUM - adding client into embedded server
error handling fixed
fetch_lengths made to work differently in embedded and client cases
Diffstat (limited to 'libmysqld')
-rw-r--r-- | libmysqld/lib_sql.cc | 10 | ||||
-rw-r--r-- | libmysqld/libmysqld.c | 35 |
2 files changed, 34 insertions, 11 deletions
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index f7b69b51d46..6d7b71c61be 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -76,8 +76,13 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, if (!skip_check) result= thd->net.last_errno ? -1 : 0; - mysql->last_error= thd->net.last_error; - mysql->net.last_errno= thd->net.last_errno; + if ((mysql->net.last_errno= thd->net.last_errno)) + { + memcpy(mysql->net.last_error, thd->net.last_error, + sizeof(mysql->net.last_error)); + memcpy(mysql->net.sqlstate, thd->net.sqlstate, + sizeof(mysql->net.sqlstate)); + } mysql->warning_count= ((THD*)mysql->thd)->total_warn_count; return result; } @@ -292,7 +297,6 @@ void init_embedded_mysql(MYSQL *mysql, int client_flag, char *db) { THD *thd = (THD *)mysql->thd; thd->mysql= mysql; - mysql->last_error= thd->net.last_error; } void *create_embedded_thd(int client_flag, char *db) diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index b6278ab3c0b..357c13c5826 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -144,25 +144,42 @@ static inline int mysql_init_charset(MYSQL *mysql) if (!mysql->charset) { - mysql->last_errno=CR_CANT_READ_CHARSET; - strmov(mysql->sqlstate, "HY0000"); + mysql->net.last_errno=CR_CANT_READ_CHARSET; + strmov(mysql->net.sqlstate, "HY0000"); if (mysql->options.charset_dir) - sprintf(mysql->last_error,ER(mysql->last_errno), + sprintf(mysql->net.last_error,ER(mysql->net.last_errno), charset_name ? charset_name : "unknown", mysql->options.charset_dir); else { char cs_dir_name[FN_REFLEN]; get_charsets_dir(cs_dir_name); - sprintf(mysql->last_error,ER(mysql->last_errno), + sprintf(mysql->net.last_error,ER(mysql->net.last_errno), charset_name ? charset_name : "unknown", cs_dir_name); } - return mysql->last_errno; + return mysql->net.last_errno; } return 0; } +/************************************************************************** + Get column lengths of the current row + If one uses mysql_use_result, res->lengths contains the length information, + else the lengths are calculated from the offset between pointers. +**************************************************************************/ + +static void emb_fetch_lengths(ulong *to, MYSQL_ROW column, uint field_count) +{ + MYSQL_ROW end; + + for (end=column + field_count; column != end ; column++,to++) + { + *to= *column ? strlen(*column) : 0; + } +} + + /* ** Note that the mysql argument must be initialized with mysql_init() ** before calling mysql_real_connect ! @@ -178,6 +195,7 @@ static MYSQL_METHODS embedded_methods= emb_advanced_command, emb_mysql_store_result, emb_mysql_use_result, + emb_fetch_lengths }; MYSQL * STDCALL @@ -259,7 +277,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, DBUG_RETURN(mysql); error: - DBUG_PRINT("error",("message: %u (%s)",mysql->last_errno,mysql->last_error)); + DBUG_PRINT("error",("message: %u (%s)",mysql->net.last_errno,mysql->net.last_error)); { /* Free alloced memory */ my_bool free_me=mysql->free_me; @@ -320,7 +338,7 @@ void STDCALL mysql_close(MYSQL *mysql) static my_bool STDCALL emb_mysql_read_query_result(MYSQL *mysql) { - if (mysql->last_errno) + if (mysql->net.last_errno) return -1; if (mysql->field_count) @@ -342,7 +360,8 @@ static MYSQL_RES * STDCALL emb_mysql_store_result(MYSQL *mysql) MYSQL_RES *result= mysql->result; if (!result) return 0; - + + result->methods= mysql->methods; mysql->result= NULL; *result->data->prev_ptr= 0; result->eof= 1; |