summaryrefslogtreecommitdiff
path: root/sql/ha_federated.cc
diff options
context:
space:
mode:
authorunknown <eric@mysql.com>2005-09-13 11:59:19 -0700
committerunknown <eric@mysql.com>2005-09-13 11:59:19 -0700
commitf1c4e958cd1b276543710600def1644126f56752 (patch)
treef8ec62a1a158afb10128ce191625e32e510bf74e /sql/ha_federated.cc
parent02997c8d9915b6d3980a40e946b40221dd197ba9 (diff)
downloadmariadb-git-f1c4e958cd1b276543710600def1644126f56752.tar.gz
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
Diffstat (limited to 'sql/ha_federated.cc')
-rw-r--r--sql/ha_federated.cc178
1 files changed, 88 insertions, 90 deletions
diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc
index 02a110811c0..5cc5b7aa32c 100644
--- a/sql/ha_federated.cc
+++ b/sql/ha_federated.cc
@@ -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
@@ -577,113 +596,92 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table,
remove addition of null terminator and store length
for each string in share
*/
- if ((share->username= strstr(share->scheme, "://")))
- {
- share->scheme[share->username - share->scheme]= '\0';
-
- if (strcmp(share->scheme, "mysql") != 0)
- goto error;
+ if (!(share->username= strstr(share->scheme, "://")))
+ goto error;
+ share->scheme[share->username - share->scheme]= '\0';
- share->username+= 3;
+ if (strcmp(share->scheme, "mysql") != 0)
+ goto error;
- if ((share->hostname= strchr(share->username, '@')))
- {
- share->username[share->hostname - share->username]= '\0';
- share->hostname++;
+ share->username+= 3;
- if ((share->password= strchr(share->username, ':')))
- {
- share->username[share->password - share->username]= '\0';
- share->password++;
- share->username= share->username;
- /* make sure there isn't an extra / or @ */
- if ((strchr(share->password, '/') || strchr(share->hostname, '@')))
- goto error;
- /*
- Found that if the string is:
- user:@hostname:port/database/table
- Then password is a null string, so set to NULL
- */
- if ((share->password[0] == '\0'))
- share->password= NULL;
- }
- else
- share->username= share->username;
+ if (!(share->hostname= strchr(share->username, '@')))
+ goto error;
+
+ share->username[share->hostname - share->username]= '\0';
+ share->hostname++;
- /* make sure there isn't an extra / or @ */
- if ((strchr(share->username, '/')) || (strchr(share->hostname, '@')))
- goto error;
+ if ((share->password= strchr(share->username, ':')))
+ {
+ share->username[share->password - share->username]= '\0';
+ share->password++;
+ share->username= share->username;
+ /* make sure there isn't an extra / or @ */
+ if ((strchr(share->password, '/') || strchr(share->hostname, '@')))
+ goto error;
+ /*
+ Found that if the string is:
+ user:@hostname:port/database/table
+ Then password is a null string, so set to NULL
+ */
+ if ((share->password[0] == '\0'))
+ share->password= NULL;
+ }
+ else
+ share->username= share->username;
- if ((share->database= strchr(share->hostname, '/')))
- {
- share->hostname[share->database - share->hostname]= '\0';
- share->database++;
+ /* make sure there isn't an extra / or @ */
+ if ((strchr(share->username, '/')) || (strchr(share->hostname, '@')))
+ goto error;
- if ((share->sport= strchr(share->hostname, ':')))
- {
- share->hostname[share->sport - share->hostname]= '\0';
- share->sport++;
- if (share->sport[0] == '\0')
- share->sport= NULL;
- else
- share->port= atoi(share->sport);
- }
+ if (!(share->database= strchr(share->hostname, '/')))
+ goto error;
+ share->hostname[share->database - share->hostname]= '\0';
+ share->database++;
- if ((share->table_name= strchr(share->database, '/')))
- {
- share->database[share->table_name - share->database]= '\0';
- share->table_name++;
- }
- else
- goto error;
+ if ((share->sport= strchr(share->hostname, ':')))
+ {
+ share->hostname[share->sport - share->hostname]= '\0';
+ share->sport++;
+ if (share->sport[0] == '\0')
+ share->sport= NULL;
+ else
+ share->port= atoi(share->sport);
+ }
- share->table_name_length= strlen(share->table_name);
- }
- else
- goto error;
- /* make sure there's not an extra / */
- if ((strchr(share->table_name, '/')))
- goto error;
+ if (!(share->table_name= strchr(share->database, '/')))
+ goto error;
+ share->database[share->table_name - share->database]= '\0';
+ share->table_name++;
- if (share->hostname[0] == '\0')
- share->hostname= NULL;
+ share->table_name_length= strlen(share->table_name);
+
+ /* make sure there's not an extra / */
+ if ((strchr(share->table_name, '/')))
+ goto error;
- if (!share->port)
- {
- if (strcmp(share->hostname, my_localhost) == 0)
- share->socket= my_strdup(MYSQL_UNIX_ADDR, MYF(0));
- else
- share->port= MYSQL_PORT;
- }
+ if (share->hostname[0] == '\0')
+ share->hostname= NULL;
- DBUG_PRINT("info",
- ("scheme %s username %s password %s \
- hostname %s port %d database %s tablename %s\n",
- share->scheme, share->username, share->password,
- share->hostname, share->port, share->database,
- share->table_name));
- }
+ if (!share->port)
+ {
+ if (strcmp(share->hostname, my_localhost) == 0)
+ share->socket= my_strdup(MYSQL_UNIX_ADDR, MYF(0));
else
- goto error;
+ share->port= MYSQL_PORT;
}
- else
- goto error;
+
+ DBUG_PRINT("info",
+ ("scheme %s username %s password %s \
+ hostname %s port %d database %s tablename %s\n",
+ share->scheme, share->username, share->password,
+ share->hostname, share->port, share->database,
+ share->table_name));
DBUG_RETURN(0);
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;
- }
- /* FIXME: table->s->connect_string is NOT null terminated */
- my_error(error_num, MYF(0), "invalid connection string");
- DBUG_RETURN(error_num);
-
+ DBUG_RETURN(parse_url_error(share, table, error_num));
}