Commit aec30267 authored by unknown's avatar unknown

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
parent 65492347
...@@ -499,8 +499,6 @@ MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result, ...@@ -499,8 +499,6 @@ MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result,
MYSQL_FIELD_OFFSET offset); MYSQL_FIELD_OFFSET offset);
MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result); MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result);
unsigned long * STDCALL mysql_fetch_lengths(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_FIELD * STDCALL mysql_fetch_field(MYSQL_RES *result);
MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table, MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
const char *wild); const char *wild);
......
...@@ -1115,25 +1115,6 @@ mysql_fetch_field(MYSQL_RES *result) ...@@ -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 Move to a specific row and column
**************************************************************************/ **************************************************************************/
......
...@@ -1121,7 +1121,7 @@ void mysql_read_default_options(struct st_mysql_options *options, ...@@ -1121,7 +1121,7 @@ void mysql_read_default_options(struct st_mysql_options *options,
else the lengths are calculated from the offset between pointers. 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) unsigned int field_count)
{ {
ulong *prev_length; ulong *prev_length;
...@@ -2628,6 +2628,25 @@ mysql_fetch_row(MYSQL_RES *res) ...@@ -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 int STDCALL
mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
{ {
......
...@@ -560,10 +560,10 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, ...@@ -560,10 +560,10 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table,
if (!share->port) if (!share->port)
{ {
if (strcmp(share->hostname, "localhost") == 0) if (strcmp(share->hostname, my_localhost) == 0)
share->socket= my_strdup("/tmp/mysql.sock", MYF(0)); share->socket= my_strdup(MYSQL_UNIX_ADDR, MYF(0));
else else
share->port= 3306; share->port= MYSQL_PORT;
} }
DBUG_PRINT("ha_federated::parse_url", DBUG_PRINT("ha_federated::parse_url",
...@@ -616,8 +616,7 @@ uint ha_federated::convert_row_to_internal_format(byte *record, MYSQL_ROW row) ...@@ -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"); DBUG_ENTER("ha_federated::convert_row_to_internal_format");
num_fields= mysql_num_fields(result); num_fields= mysql_num_fields(result);
lengths= (ulong*) my_malloc(num_fields * sizeof(ulong), MYF(0)); lengths= mysql_fetch_lengths(result);
cli_fetch_lengths((ulong*) lengths, row, num_fields);
memset(record, 0, table->s->null_bytes); memset(record, 0, table->s->null_bytes);
...@@ -628,8 +627,6 @@ uint ha_federated::convert_row_to_internal_format(byte *record, MYSQL_ROW row) ...@@ -628,8 +627,6 @@ uint ha_federated::convert_row_to_internal_format(byte *record, MYSQL_ROW row)
else else
(*field)->store(row[x], lengths[x], &my_charset_bin); (*field)->store(row[x], lengths[x], &my_charset_bin);
} }
my_free((gptr) lengths, MYF(0));
lengths= 0;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
...@@ -76,7 +76,6 @@ class ha_federated: public handler ...@@ -76,7 +76,6 @@ class ha_federated: public handler
return errorcode otherwise return errorcode otherwise
*/ */
uint convert_row_to_internal_format(byte *buf, MYSQL_ROW row); 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, bool create_where_from_key(String *to, KEY *key_info,
const byte *key, uint key_length); const byte *key, uint key_length);
...@@ -106,9 +105,9 @@ class ha_federated: public handler ...@@ -106,9 +105,9 @@ class ha_federated: public handler
*/ */
ulong table_flags() const ulong table_flags() const
{ {
return (HA_TABLE_SCAN_ON_INDEX | HA_NOT_EXACT_COUNT | return (HA_TABLE_SCAN_ON_INDEX | HA_NOT_EXACT_COUNT |
HA_PRIMARY_KEY_IN_READ_INDEX | HA_FILE_BASED | HA_AUTO_PART_KEY | HA_PRIMARY_KEY_IN_READ_INDEX | HA_FILE_BASED |
HA_TABLE_SCAN_ON_INDEX | HA_CAN_INDEX_BLOBS); HA_AUTO_PART_KEY | HA_CAN_INDEX_BLOBS);
} }
/* /*
This is a bitmap of flags that says how the storage engine This is a bitmap of flags that says how the storage engine
......
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