Commit f1c4e958 authored by unknown's avatar unknown

Fixed minor error message bug from work for WL#2414


mysql-test/r/federated.result:
  fixed error message
sql/ha_federated.cc:
  Minor refactoring to fix error message, resulting in big whitespace change
parent 02997c8d
...@@ -26,7 +26,7 @@ CREATE TABLE federated.t1 ( ...@@ -26,7 +26,7 @@ CREATE TABLE federated.t1 (
) )
ENGINE="FEDERATED" DEFAULT CHARSET=latin1 ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:@/too/many/items/federated/t1'; CONNECTION='mysql://root@127.0.0.1:@/too/many/items/federated/t1';
ERROR HY000: Can't create federated table. The data source connection string 'mysql://root@127.0.0.1:@/too/many/items/federated/t1' is not in the correct format ERROR HY000: Can't create federated table. The data source connection string 'mysql://root@127.0.0.1:@/too/many/items/federated/t1' is not in the correct format
CREATE TABLE federated.t1 ( CREATE TABLE federated.t1 (
`id` int(20) NOT NULL, `id` int(20) NOT NULL,
`name` varchar(32) NOT NULL default '' `name` varchar(32) NOT NULL default ''
......
...@@ -517,6 +517,25 @@ error: ...@@ -517,6 +517,25 @@ error:
} }
static int parse_url_error(FEDERATED_SHARE *share, TABLE *table, int error_num)
{
char buf[table->s->connect_string.length+1];
DBUG_ENTER("ha_federated parse_url_error");
if (share->scheme)
{
DBUG_PRINT("info",
("error: parse_url. Returning error code %d \
freeing share->scheme %lx", error_num, share->scheme));
my_free((gptr) share->scheme, MYF(0));
share->scheme= 0;
}
strnmov(buf, table->s->connect_string.str, table->s->connect_string.length+1);
buf[table->s->connect_string.length]= '\0';
my_error(error_num, MYF(0), buf);
DBUG_RETURN(error_num);
}
/* /*
Parse connection info from table->s->connect_string Parse connection info from table->s->connect_string
...@@ -577,8 +596,8 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, ...@@ -577,8 +596,8 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table,
remove addition of null terminator and store length remove addition of null terminator and store length
for each string in share for each string in share
*/ */
if ((share->username= strstr(share->scheme, "://"))) if (!(share->username= strstr(share->scheme, "://")))
{ goto error;
share->scheme[share->username - share->scheme]= '\0'; share->scheme[share->username - share->scheme]= '\0';
if (strcmp(share->scheme, "mysql") != 0) if (strcmp(share->scheme, "mysql") != 0)
...@@ -586,8 +605,9 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, ...@@ -586,8 +605,9 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table,
share->username+= 3; share->username+= 3;
if ((share->hostname= strchr(share->username, '@'))) if (!(share->hostname= strchr(share->username, '@')))
{ goto error;
share->username[share->hostname - share->username]= '\0'; share->username[share->hostname - share->username]= '\0';
share->hostname++; share->hostname++;
...@@ -614,8 +634,8 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, ...@@ -614,8 +634,8 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table,
if ((strchr(share->username, '/')) || (strchr(share->hostname, '@'))) if ((strchr(share->username, '/')) || (strchr(share->hostname, '@')))
goto error; goto error;
if ((share->database= strchr(share->hostname, '/'))) if (!(share->database= strchr(share->hostname, '/')))
{ goto error;
share->hostname[share->database - share->hostname]= '\0'; share->hostname[share->database - share->hostname]= '\0';
share->database++; share->database++;
...@@ -629,18 +649,13 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, ...@@ -629,18 +649,13 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table,
share->port= atoi(share->sport); share->port= atoi(share->sport);
} }
if ((share->table_name= strchr(share->database, '/'))) if (!(share->table_name= strchr(share->database, '/')))
{ goto error;
share->database[share->table_name - share->database]= '\0'; share->database[share->table_name - share->database]= '\0';
share->table_name++; share->table_name++;
}
else
goto error;
share->table_name_length= strlen(share->table_name); share->table_name_length= strlen(share->table_name);
}
else
goto error;
/* make sure there's not an extra / */ /* make sure there's not an extra / */
if ((strchr(share->table_name, '/'))) if ((strchr(share->table_name, '/')))
goto error; goto error;
...@@ -662,28 +677,11 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table, ...@@ -662,28 +677,11 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table,
share->scheme, share->username, share->password, share->scheme, share->username, share->password,
share->hostname, share->port, share->database, share->hostname, share->port, share->database,
share->table_name)); share->table_name));
}
else
goto error;
}
else
goto error;
DBUG_RETURN(0); DBUG_RETURN(0);
error: error:
if (share->scheme) DBUG_RETURN(parse_url_error(share, table, error_num));
{
DBUG_PRINT("info",
("error: parse_url. Returning error code %d \
freeing share->scheme %lx", error_num, share->scheme));
my_free((gptr) share->scheme, MYF(0));
share->scheme= 0;
}
/* FIXME: table->s->connect_string is NOT null terminated */
my_error(error_num, MYF(0), "invalid connection string");
DBUG_RETURN(error_num);
} }
......
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