Commit f1c4e958 authored by unknown's avatar unknown
Browse files

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
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ CREATE TABLE federated.t1 (
    )
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
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 (
`id` int(20) NOT NULL,
`name` varchar(32) NOT NULL default ''
+88 −90
Original line number Diff line number Diff line
@@ -517,6 +517,25 @@ static int check_foreign_data_source(
}


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,8 +596,8 @@ 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, "://")))
  {
  if (!(share->username= strstr(share->scheme, "://")))
    goto error;
  share->scheme[share->username - share->scheme]= '\0';

  if (strcmp(share->scheme, "mysql") != 0)
@@ -586,8 +605,9 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table,

  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->hostname++;

@@ -614,8 +634,8 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table,
  if ((strchr(share->username, '/')) || (strchr(share->hostname, '@')))
    goto error;

      if ((share->database= strchr(share->hostname, '/')))
      {
  if (!(share->database= strchr(share->hostname, '/')))
    goto error;
  share->hostname[share->database - share->hostname]= '\0';
  share->database++;

@@ -629,18 +649,13 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table,
      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->table_name++;
        }
        else
          goto error;

  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;
@@ -662,28 +677,11 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table,
              share->scheme, share->username, share->password,
              share->hostname, share->port, share->database,
              share->table_name));
    }
    else
      goto error;
  }
  else
    goto error;

  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));
}