From aec302676a839c41e69399bf73091273f1c0b60f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Feb 2005 00:29:57 -0800 Subject: [PATCH] WL #2094 Federated Storage Handler This is the first changeset of suggested changes recommended in Kostja's review of my patch, 1.1846, which includes only functionality changes. Style changes/Documentation patch to follow. include/mysql.h: removed declaration of cli_fetch_lengths per Kostja's suggestion libmysql/libmysql.c: moved mysql_fetch_lengths to client.c (for server to access) per Kostja's suggestion sql-common/client.c: added back 'static' to function definition, added mysql_fetch_lengths sql/ha_federated.cc: changed to use defines as opposed to hardcoded values sql/ha_federated.h: took out duplicate table_flag, fixed a resolve mistake --- include/mysql.h | 2 -- libmysql/libmysql.c | 19 ------------------- sql-common/client.c | 21 ++++++++++++++++++++- sql/ha_federated.cc | 11 ++++------- sql/ha_federated.h | 7 +++---- 5 files changed, 27 insertions(+), 33 deletions(-) diff --git a/include/mysql.h b/include/mysql.h index 828d38f5ec4..b87b865608e 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -499,8 +499,6 @@ MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET offset); MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result); unsigned long * STDCALL mysql_fetch_lengths(MYSQL_RES *result); -void STDCALL cli_fetch_lengths(unsigned long *to, MYSQL_ROW column, - unsigned int field_count); MYSQL_FIELD * STDCALL mysql_fetch_field(MYSQL_RES *result); MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table, const char *wild); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 1ef29210c0b..20a000f1e4d 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1115,25 +1115,6 @@ mysql_fetch_field(MYSQL_RES *result) } -/************************************************************************** - 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. -**************************************************************************/ - -ulong * STDCALL -mysql_fetch_lengths(MYSQL_RES *res) -{ - MYSQL_ROW column; - - if (!(column=res->current_row)) - return 0; /* Something is wrong */ - if (res->data) - (*res->methods->fetch_lengths)(res->lengths, column, res->field_count); - return res->lengths; -} - - /************************************************************************** Move to a specific row and column **************************************************************************/ diff --git a/sql-common/client.c b/sql-common/client.c index 2e60b8aad24..aece4230fe0 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1121,7 +1121,7 @@ void mysql_read_default_options(struct st_mysql_options *options, else the lengths are calculated from the offset between pointers. **************************************************************************/ -void cli_fetch_lengths(ulong *to, MYSQL_ROW column, +static void cli_fetch_lengths(ulong *to, MYSQL_ROW column, unsigned int field_count) { ulong *prev_length; @@ -2628,6 +2628,25 @@ mysql_fetch_row(MYSQL_RES *res) } +/************************************************************************** + 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. +**************************************************************************/ + +ulong * STDCALL +mysql_fetch_lengths(MYSQL_RES *res) +{ + MYSQL_ROW column; + + if (!(column=res->current_row)) + return 0; /* Something is wrong */ + if (res->data) + (*res->methods->fetch_lengths)(res->lengths, column, res->field_count); + return res->lengths; +} + + int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) { diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index ae6cb1f76be..cf704f9f569 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -560,10 +560,10 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, if (!share->port) { - if (strcmp(share->hostname, "localhost") == 0) - share->socket= my_strdup("/tmp/mysql.sock", MYF(0)); + if (strcmp(share->hostname, my_localhost) == 0) + share->socket= my_strdup(MYSQL_UNIX_ADDR, MYF(0)); else - share->port= 3306; + share->port= MYSQL_PORT; } DBUG_PRINT("ha_federated::parse_url", @@ -616,8 +616,7 @@ uint ha_federated::convert_row_to_internal_format(byte *record, MYSQL_ROW row) DBUG_ENTER("ha_federated::convert_row_to_internal_format"); num_fields= mysql_num_fields(result); - lengths= (ulong*) my_malloc(num_fields * sizeof(ulong), MYF(0)); - cli_fetch_lengths((ulong*) lengths, row, num_fields); + lengths= mysql_fetch_lengths(result); memset(record, 0, table->s->null_bytes); @@ -628,8 +627,6 @@ uint ha_federated::convert_row_to_internal_format(byte *record, MYSQL_ROW row) else (*field)->store(row[x], lengths[x], &my_charset_bin); } - my_free((gptr) lengths, MYF(0)); - lengths= 0; DBUG_RETURN(0); } diff --git a/sql/ha_federated.h b/sql/ha_federated.h index f685aa9e3f9..22fc03e9eec 100755 --- a/sql/ha_federated.h +++ b/sql/ha_federated.h @@ -76,7 +76,6 @@ private: return errorcode otherwise */ uint convert_row_to_internal_format(byte *buf, MYSQL_ROW row); - bool create_where_from_key(String *to, KEY *key_info, const byte *key, uint key_length); bool create_where_from_key(String *to, KEY *key_info, const byte *key, uint key_length); @@ -106,9 +105,9 @@ public: */ ulong table_flags() const { - return (HA_TABLE_SCAN_ON_INDEX | HA_NOT_EXACT_COUNT | - HA_PRIMARY_KEY_IN_READ_INDEX | HA_FILE_BASED | HA_AUTO_PART_KEY | - HA_TABLE_SCAN_ON_INDEX | HA_CAN_INDEX_BLOBS); + return (HA_TABLE_SCAN_ON_INDEX | HA_NOT_EXACT_COUNT | + HA_PRIMARY_KEY_IN_READ_INDEX | HA_FILE_BASED | + HA_AUTO_PART_KEY | HA_CAN_INDEX_BLOBS); } /* This is a bitmap of flags that says how the storage engine