Commit 97a913e3 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: freshen up CREATE SERVER code

* pass LEX_STRING's from the parser, don't ignore the length only to strlen later
* init LEX::server_options only for SERVER commands, not for every statement
* don't put temporary values into a global persistent memroot

but really it's just scratching a surface
parent a50ddebb
...@@ -523,21 +523,6 @@ void lex_start(THD *thd) ...@@ -523,21 +523,6 @@ void lex_start(THD *thd)
lex->select_lex.nest_level_base= &lex->unit; lex->select_lex.nest_level_base= &lex->unit;
lex->allow_sum_func= 0; lex->allow_sum_func= 0;
lex->in_sum_func= NULL; lex->in_sum_func= NULL;
/*
ok, there must be a better solution for this, long-term
I tried "bzero" in the sql_yacc.yy code, but that for
some reason made the values zero, even if they were set
*/
lex->server_options.server_name= 0;
lex->server_options.server_name_length= 0;
lex->server_options.host= 0;
lex->server_options.db= 0;
lex->server_options.username= 0;
lex->server_options.password= 0;
lex->server_options.scheme= 0;
lex->server_options.socket= 0;
lex->server_options.owner= 0;
lex->server_options.port= -1;
lex->is_lex_started= TRUE; lex->is_lex_started= TRUE;
lex->used_tables= 0; lex->used_tables= 0;
......
...@@ -202,8 +202,13 @@ typedef Mem_root_array<ORDER*, true> Group_list_ptrs; ...@@ -202,8 +202,13 @@ typedef Mem_root_array<ORDER*, true> Group_list_ptrs;
typedef struct st_lex_server_options typedef struct st_lex_server_options
{ {
long port; long port;
uint server_name_length; LEX_STRING server_name, host, db, username, password, scheme, socket, owner;
char *server_name, *host, *db, *username, *password, *scheme, *socket, *owner; void reset(LEX_STRING name)
{
server_name= name;
host= db= username= password= scheme= socket= owner= null_lex_str;
port= -1;
}
} LEX_SERVER_OPTIONS; } LEX_SERVER_OPTIONS;
......
...@@ -5481,8 +5481,8 @@ create_sp_error: ...@@ -5481,8 +5481,8 @@ create_sp_error:
if ((error= create_server(thd, &lex->server_options))) if ((error= create_server(thd, &lex->server_options)))
{ {
DBUG_PRINT("info", ("problem creating server <%s>", DBUG_PRINT("info", ("problem creating server <%s>",
lex->server_options.server_name)); lex->server_options.server_name.str));
my_error(error, MYF(0), lex->server_options.server_name); my_error(error, MYF(0), lex->server_options.server_name.str);
break; break;
} }
my_ok(thd, 1); my_ok(thd, 1);
...@@ -5500,8 +5500,8 @@ create_sp_error: ...@@ -5500,8 +5500,8 @@ create_sp_error:
if ((error= alter_server(thd, &lex->server_options))) if ((error= alter_server(thd, &lex->server_options)))
{ {
DBUG_PRINT("info", ("problem altering server <%s>", DBUG_PRINT("info", ("problem altering server <%s>",
lex->server_options.server_name)); lex->server_options.server_name.str));
my_error(error, MYF(0), lex->server_options.server_name); my_error(error, MYF(0), lex->server_options.server_name.str);
break; break;
} }
my_ok(thd, 1); my_ok(thd, 1);
...@@ -5521,8 +5521,8 @@ create_sp_error: ...@@ -5521,8 +5521,8 @@ create_sp_error:
if (! lex->check_exists && err_code == ER_FOREIGN_SERVER_DOESNT_EXIST) if (! lex->check_exists && err_code == ER_FOREIGN_SERVER_DOESNT_EXIST)
{ {
DBUG_PRINT("info", ("problem dropping server %s", DBUG_PRINT("info", ("problem dropping server %s",
lex->server_options.server_name)); lex->server_options.server_name.str));
my_error(err_code, MYF(0), lex->server_options.server_name); my_error(err_code, MYF(0), lex->server_options.server_name.str);
} }
else else
{ {
......
...@@ -64,9 +64,7 @@ static int insert_server_record_into_cache(FOREIGN_SERVER *server); ...@@ -64,9 +64,7 @@ static int insert_server_record_into_cache(FOREIGN_SERVER *server);
static FOREIGN_SERVER * static FOREIGN_SERVER *
prepare_server_struct_for_insert(LEX_SERVER_OPTIONS *server_options); prepare_server_struct_for_insert(LEX_SERVER_OPTIONS *server_options);
/* drop functions */ /* drop functions */
static int delete_server_record(TABLE *table, static int delete_server_record(TABLE *table, LEX_STRING *name);
char *server_name,
size_t server_name_length);
static int delete_server_record_in_cache(LEX_SERVER_OPTIONS *server_options); static int delete_server_record_in_cache(LEX_SERVER_OPTIONS *server_options);
/* update functions */ /* update functions */
...@@ -81,8 +79,6 @@ static int update_server_record_in_cache(FOREIGN_SERVER *existing, ...@@ -81,8 +79,6 @@ static int update_server_record_in_cache(FOREIGN_SERVER *existing,
/* utility functions */ /* utility functions */
static void merge_server_struct(FOREIGN_SERVER *from, FOREIGN_SERVER *to); static void merge_server_struct(FOREIGN_SERVER *from, FOREIGN_SERVER *to);
static uchar *servers_cache_get_key(FOREIGN_SERVER *server, size_t *length, static uchar *servers_cache_get_key(FOREIGN_SERVER *server, size_t *length,
my_bool not_used __attribute__((unused))) my_bool not_used __attribute__((unused)))
{ {
...@@ -603,12 +599,10 @@ int drop_server(THD *thd, LEX_SERVER_OPTIONS *server_options) ...@@ -603,12 +599,10 @@ int drop_server(THD *thd, LEX_SERVER_OPTIONS *server_options)
int error; int error;
TABLE_LIST tables; TABLE_LIST tables;
TABLE *table; TABLE *table;
LEX_STRING name= { server_options->server_name,
server_options->server_name_length };
DBUG_ENTER("drop_server"); DBUG_ENTER("drop_server");
DBUG_PRINT("info", ("server name server->server_name %s", DBUG_PRINT("info", ("server name server->server_name %s",
server_options->server_name)); server_options->server_name.str));
tables.init_one_table("mysql", 5, "servers", 7, "servers", TL_WRITE); tables.init_one_table("mysql", 5, "servers", 7, "servers", TL_WRITE);
...@@ -624,12 +618,12 @@ int drop_server(THD *thd, LEX_SERVER_OPTIONS *server_options) ...@@ -624,12 +618,12 @@ int drop_server(THD *thd, LEX_SERVER_OPTIONS *server_options)
goto end; goto end;
} }
error= delete_server_record(table, name.str, name.length); error= delete_server_record(table, &server_options->server_name);
/* close the servers table before we call closed_cached_connection_tables */ /* close the servers table before we call closed_cached_connection_tables */
close_mysql_tables(thd); close_mysql_tables(thd);
if (close_cached_connection_tables(thd, &name)) if (close_cached_connection_tables(thd, &server_options->server_name))
{ {
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_UNKNOWN_ERROR, "Server connection in use"); ER_UNKNOWN_ERROR, "Server connection in use");
...@@ -666,19 +660,19 @@ delete_server_record_in_cache(LEX_SERVER_OPTIONS *server_options) ...@@ -666,19 +660,19 @@ delete_server_record_in_cache(LEX_SERVER_OPTIONS *server_options)
FOREIGN_SERVER *server; FOREIGN_SERVER *server;
DBUG_ENTER("delete_server_record_in_cache"); DBUG_ENTER("delete_server_record_in_cache");
DBUG_PRINT("info",("trying to obtain server name %s length %d", DBUG_PRINT("info",("trying to obtain server name %s length %zu",
server_options->server_name, server_options->server_name.str,
server_options->server_name_length)); server_options->server_name.length));
if (!(server= (FOREIGN_SERVER *) if (!(server= (FOREIGN_SERVER *)
my_hash_search(&servers_cache, my_hash_search(&servers_cache,
(uchar*) server_options->server_name, (uchar*) server_options->server_name.str,
server_options->server_name_length))) server_options->server_name.length)))
{ {
DBUG_PRINT("info", ("server_name %s length %d not found!", DBUG_PRINT("info", ("server_name %s length %zu not found!",
server_options->server_name, server_options->server_name.str,
server_options->server_name_length)); server_options->server_name.length));
goto end; goto end;
} }
/* /*
...@@ -937,8 +931,7 @@ end: ...@@ -937,8 +931,7 @@ end:
*/ */
static int static int
delete_server_record(TABLE *table, delete_server_record(TABLE *table, LEX_STRING *name)
char *server_name, size_t server_name_length)
{ {
int error; int error;
DBUG_ENTER("delete_server_record"); DBUG_ENTER("delete_server_record");
...@@ -946,7 +939,7 @@ delete_server_record(TABLE *table, ...@@ -946,7 +939,7 @@ delete_server_record(TABLE *table,
table->use_all_columns(); table->use_all_columns();
/* set the field that's the PK to the value we're looking for */ /* set the field that's the PK to the value we're looking for */
table->field[0]->store(server_name, server_name_length, system_charset_info); table->field[0]->store(name->str, name->length, system_charset_info);
if ((error= table->file->ha_index_read_idx_map(table->record[0], 0, if ((error= table->file->ha_index_read_idx_map(table->record[0], 0,
(uchar *)table->field[0]->ptr, (uchar *)table->field[0]->ptr,
...@@ -989,13 +982,13 @@ int create_server(THD *thd, LEX_SERVER_OPTIONS *server_options) ...@@ -989,13 +982,13 @@ int create_server(THD *thd, LEX_SERVER_OPTIONS *server_options)
DBUG_ENTER("create_server"); DBUG_ENTER("create_server");
DBUG_PRINT("info", ("server_options->server_name %s", DBUG_PRINT("info", ("server_options->server_name %s",
server_options->server_name)); server_options->server_name.str));
mysql_rwlock_wrlock(&THR_LOCK_servers); mysql_rwlock_wrlock(&THR_LOCK_servers);
/* hit the memory first */ /* hit the memory first */
if (my_hash_search(&servers_cache, (uchar*) server_options->server_name, if (my_hash_search(&servers_cache, (uchar*) server_options->server_name.str,
server_options->server_name_length)) server_options->server_name.length))
goto end; goto end;
...@@ -1034,31 +1027,26 @@ end: ...@@ -1034,31 +1027,26 @@ end:
int alter_server(THD *thd, LEX_SERVER_OPTIONS *server_options) int alter_server(THD *thd, LEX_SERVER_OPTIONS *server_options)
{ {
int error= ER_FOREIGN_SERVER_DOESNT_EXIST; int error= ER_FOREIGN_SERVER_DOESNT_EXIST;
FOREIGN_SERVER *altered, *existing; FOREIGN_SERVER altered, *existing;
LEX_STRING name= { server_options->server_name,
server_options->server_name_length };
DBUG_ENTER("alter_server"); DBUG_ENTER("alter_server");
DBUG_PRINT("info", ("server_options->server_name %s", DBUG_PRINT("info", ("server_options->server_name %s",
server_options->server_name)); server_options->server_name.str));
mysql_rwlock_wrlock(&THR_LOCK_servers); mysql_rwlock_wrlock(&THR_LOCK_servers);
if (!(existing= (FOREIGN_SERVER *) my_hash_search(&servers_cache, if (!(existing= (FOREIGN_SERVER *) my_hash_search(&servers_cache,
(uchar*) name.str, (uchar*) server_options->server_name.str,
name.length))) server_options->server_name.length)))
goto end; goto end;
altered= (FOREIGN_SERVER *)alloc_root(&mem, prepare_server_struct_for_update(server_options, existing, &altered);
sizeof(FOREIGN_SERVER));
prepare_server_struct_for_update(server_options, existing, altered);
error= update_server(thd, existing, altered); error= update_server(thd, existing, &altered);
/* close the servers table before we call closed_cached_connection_tables */ /* close the servers table before we call closed_cached_connection_tables */
close_mysql_tables(thd); close_mysql_tables(thd);
if (close_cached_connection_tables(thd, &name)) if (close_cached_connection_tables(thd, &server_options->server_name))
{ {
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_UNKNOWN_ERROR, "Server connection in use"); ER_UNKNOWN_ERROR, "Server connection in use");
...@@ -1089,50 +1077,37 @@ end: ...@@ -1089,50 +1077,37 @@ end:
static FOREIGN_SERVER * static FOREIGN_SERVER *
prepare_server_struct_for_insert(LEX_SERVER_OPTIONS *server_options) prepare_server_struct_for_insert(LEX_SERVER_OPTIONS *server_options)
{ {
char *unset_ptr= (char*)"";
FOREIGN_SERVER *server; FOREIGN_SERVER *server;
DBUG_ENTER("prepare_server_struct"); DBUG_ENTER("prepare_server_struct");
if (!(server= (FOREIGN_SERVER *)alloc_root(&mem, sizeof(FOREIGN_SERVER)))) if (!(server= (FOREIGN_SERVER *)alloc_root(&mem, sizeof(FOREIGN_SERVER))))
DBUG_RETURN(NULL); /* purecov: inspected */ DBUG_RETURN(NULL); /* purecov: inspected */
/* these two MUST be set */ #define SET_SERVER_OR_RETURN(X, DEFAULT) \
if (!(server->server_name= strdup_root(&mem, server_options->server_name))) do { \
DBUG_RETURN(NULL); /* purecov: inspected */ if (!(server->X= server_options->X.str ? \
server->server_name_length= server_options->server_name_length; strmake_root(&mem, server_options->X.str, \
server_options->X.length) : "")) \
DBUG_RETURN(NULL); \
} while(0)
if (!(server->host= server_options->host ? /* name and scheme are always set (the parser guarantees it) */
strdup_root(&mem, server_options->host) : unset_ptr)) SET_SERVER_OR_RETURN(server_name, NULL);
DBUG_RETURN(NULL); /* purecov: inspected */ SET_SERVER_OR_RETURN(scheme, NULL);
if (!(server->db= server_options->db ? SET_SERVER_OR_RETURN(host, "");
strdup_root(&mem, server_options->db) : unset_ptr)) SET_SERVER_OR_RETURN(db, "");
DBUG_RETURN(NULL); /* purecov: inspected */ SET_SERVER_OR_RETURN(username, "");
SET_SERVER_OR_RETURN(password, "");
SET_SERVER_OR_RETURN(socket, "");
SET_SERVER_OR_RETURN(owner, "");
if (!(server->username= server_options->username ? server->server_name_length= server_options->server_name.length;
strdup_root(&mem, server_options->username) : unset_ptr))
DBUG_RETURN(NULL); /* purecov: inspected */
if (!(server->password= server_options->password ?
strdup_root(&mem, server_options->password) : unset_ptr))
DBUG_RETURN(NULL); /* purecov: inspected */
/* set to 0 if not specified */ /* set to 0 if not specified */
server->port= server_options->port > -1 ? server->port= server_options->port > -1 ?
server_options->port : 0; server_options->port : 0;
if (!(server->socket= server_options->socket ?
strdup_root(&mem, server_options->socket) : unset_ptr))
DBUG_RETURN(NULL); /* purecov: inspected */
if (!(server->scheme= server_options->scheme ?
strdup_root(&mem, server_options->scheme) : unset_ptr))
DBUG_RETURN(NULL); /* purecov: inspected */
if (!(server->owner= server_options->owner ?
strdup_root(&mem, server_options->owner) : unset_ptr))
DBUG_RETURN(NULL); /* purecov: inspected */
DBUG_RETURN(server); DBUG_RETURN(server);
} }
...@@ -1156,8 +1131,8 @@ prepare_server_struct_for_update(LEX_SERVER_OPTIONS *server_options, ...@@ -1156,8 +1131,8 @@ prepare_server_struct_for_update(LEX_SERVER_OPTIONS *server_options,
{ {
DBUG_ENTER("prepare_server_struct_for_update"); DBUG_ENTER("prepare_server_struct_for_update");
altered->server_name= strdup_root(&mem, server_options->server_name); altered->server_name= existing->server_name;
altered->server_name_length= server_options->server_name_length; altered->server_name_length= existing->server_name_length;
DBUG_PRINT("info", ("existing name %s altered name %s", DBUG_PRINT("info", ("existing name %s altered name %s",
existing->server_name, altered->server_name)); existing->server_name, altered->server_name));
...@@ -1165,23 +1140,21 @@ prepare_server_struct_for_update(LEX_SERVER_OPTIONS *server_options, ...@@ -1165,23 +1140,21 @@ prepare_server_struct_for_update(LEX_SERVER_OPTIONS *server_options,
The logic here is this: is this value set AND is it different The logic here is this: is this value set AND is it different
than the existing value? than the existing value?
*/ */
altered->host= #define SET_ALTERED(X) \
(server_options->host && (strcmp(server_options->host, existing->host))) ? do { \
strdup_root(&mem, server_options->host) : 0; altered->X= \
(server_options->X.str && strcmp(server_options->X.str, existing->X)) \
altered->db= ? strmake_root(&mem, server_options->X.str, server_options->X.length) \
(server_options->db && (strcmp(server_options->db, existing->db))) ? : 0; \
strdup_root(&mem, server_options->db) : 0; } while(0)
altered->username= SET_ALTERED(host);
(server_options->username && SET_ALTERED(db);
(strcmp(server_options->username, existing->username))) ? SET_ALTERED(username);
strdup_root(&mem, server_options->username) : 0; SET_ALTERED(password);
SET_ALTERED(socket);
altered->password= SET_ALTERED(scheme);
(server_options->password && SET_ALTERED(owner);
(strcmp(server_options->password, existing->password))) ?
strdup_root(&mem, server_options->password) : 0;
/* /*
port is initialised to -1, so if unset, it will be -1 port is initialised to -1, so if unset, it will be -1
...@@ -1190,21 +1163,6 @@ prepare_server_struct_for_update(LEX_SERVER_OPTIONS *server_options, ...@@ -1190,21 +1163,6 @@ prepare_server_struct_for_update(LEX_SERVER_OPTIONS *server_options,
server_options->port != existing->port) ? server_options->port != existing->port) ?
server_options->port : -1; server_options->port : -1;
altered->socket=
(server_options->socket &&
(strcmp(server_options->socket, existing->socket))) ?
strdup_root(&mem, server_options->socket) : 0;
altered->scheme=
(server_options->scheme &&
(strcmp(server_options->scheme, existing->scheme))) ?
strdup_root(&mem, server_options->scheme) : 0;
altered->owner=
(server_options->owner &&
(strcmp(server_options->owner, existing->owner))) ?
strdup_root(&mem, server_options->owner) : 0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -1272,13 +1230,13 @@ static FOREIGN_SERVER *clone_server(MEM_ROOT *mem, const FOREIGN_SERVER *server, ...@@ -1272,13 +1230,13 @@ static FOREIGN_SERVER *clone_server(MEM_ROOT *mem, const FOREIGN_SERVER *server,
buffer->server_name_length= server->server_name_length; buffer->server_name_length= server->server_name_length;
/* TODO: We need to examine which of these can really be NULL */ /* TODO: We need to examine which of these can really be NULL */
buffer->db= server->db ? strdup_root(mem, server->db) : NULL; buffer->db= safe_strdup_root(mem, server->db);
buffer->scheme= server->scheme ? strdup_root(mem, server->scheme) : NULL; buffer->scheme= safe_strdup_root(mem, server->scheme);
buffer->username= server->username? strdup_root(mem, server->username): NULL; buffer->username= safe_strdup_root(mem, server->username);
buffer->password= server->password? strdup_root(mem, server->password): NULL; buffer->password= safe_strdup_root(mem, server->password);
buffer->socket= server->socket ? strdup_root(mem, server->socket) : NULL; buffer->socket= safe_strdup_root(mem, server->socket);
buffer->owner= server->owner ? strdup_root(mem, server->owner) : NULL; buffer->owner= safe_strdup_root(mem, server->owner);
buffer->host= server->host ? strdup_root(mem, server->host) : NULL; buffer->host= safe_strdup_root(mem, server->host);
DBUG_RETURN(buffer); DBUG_RETURN(buffer);
} }
......
...@@ -26,10 +26,10 @@ typedef struct st_mem_root MEM_ROOT; ...@@ -26,10 +26,10 @@ typedef struct st_mem_root MEM_ROOT;
/* structs */ /* structs */
typedef struct st_federated_server typedef struct st_federated_server
{ {
char *server_name; const char *server_name;
long port; long port;
uint server_name_length; uint server_name_length;
char *db, *scheme, *username, *password, *socket, *owner, *host, *sport; const char *db, *scheme, *username, *password, *socket, *owner, *host, *sport;
} FOREIGN_SERVER; } FOREIGN_SERVER;
/* cache handlers */ /* cache handlers */
......
...@@ -2494,16 +2494,11 @@ create: ...@@ -2494,16 +2494,11 @@ create:
; ;
server_def: server_def:
SERVER_SYM SERVER_SYM ident_or_text
ident_or_text { Lex->server_options.reset($2); }
FOREIGN DATA_SYM WRAPPER_SYM FOREIGN DATA_SYM WRAPPER_SYM ident_or_text
ident_or_text
OPTIONS_SYM '(' server_options_list ')' OPTIONS_SYM '(' server_options_list ')'
{ { Lex->server_options.scheme= $7; }
Lex->server_options.server_name= $2.str;
Lex->server_options.server_name_length= $2.length;
Lex->server_options.scheme= $6.str;
}
; ;
server_options_list: server_options_list:
...@@ -2514,27 +2509,33 @@ server_options_list: ...@@ -2514,27 +2509,33 @@ server_options_list:
server_option: server_option:
USER TEXT_STRING_sys USER TEXT_STRING_sys
{ {
Lex->server_options.username= $2.str; MYSQL_YYABORT_UNLESS(Lex->server_options.username.str == 0);
Lex->server_options.username= $2;
} }
| HOST_SYM TEXT_STRING_sys | HOST_SYM TEXT_STRING_sys
{ {
Lex->server_options.host= $2.str; MYSQL_YYABORT_UNLESS(Lex->server_options.host.str == 0);
Lex->server_options.host= $2;
} }
| DATABASE TEXT_STRING_sys | DATABASE TEXT_STRING_sys
{ {
Lex->server_options.db= $2.str; MYSQL_YYABORT_UNLESS(Lex->server_options.db.str == 0);
Lex->server_options.db= $2;
} }
| OWNER_SYM TEXT_STRING_sys | OWNER_SYM TEXT_STRING_sys
{ {
Lex->server_options.owner= $2.str; MYSQL_YYABORT_UNLESS(Lex->server_options.owner.str == 0);
Lex->server_options.owner= $2;
} }
| PASSWORD TEXT_STRING_sys | PASSWORD TEXT_STRING_sys
{ {
Lex->server_options.password= $2.str; MYSQL_YYABORT_UNLESS(Lex->server_options.password.str == 0);
Lex->server_options.password= $2;
} }
| SOCKET_SYM TEXT_STRING_sys | SOCKET_SYM TEXT_STRING_sys
{ {
Lex->server_options.socket= $2.str; MYSQL_YYABORT_UNLESS(Lex->server_options.socket.str == 0);
Lex->server_options.socket= $2;
} }
| PORT_SYM ulong_num | PORT_SYM ulong_num
{ {
...@@ -7243,13 +7244,12 @@ alter: ...@@ -7243,13 +7244,12 @@ alter:
LEX *lex= Lex; LEX *lex= Lex;
lex->alter_tablespace_info->ts_cmd_type= ALTER_ACCESS_MODE_TABLESPACE; lex->alter_tablespace_info->ts_cmd_type= ALTER_ACCESS_MODE_TABLESPACE;
} }
| ALTER SERVER_SYM ident_or_text OPTIONS_SYM '(' server_options_list ')' | ALTER SERVER_SYM ident_or_text
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->sql_command= SQLCOM_ALTER_SERVER; lex->sql_command= SQLCOM_ALTER_SERVER;
lex->server_options.server_name= $3.str; lex->server_options.reset($3);
lex->server_options.server_name_length= $3.length; } OPTIONS_SYM '(' server_options_list ')' { }
}
; ;
ev_alter_on_schedule_completion: ev_alter_on_schedule_completion:
...@@ -11863,8 +11863,7 @@ drop: ...@@ -11863,8 +11863,7 @@ drop:
{ {
Lex->sql_command = SQLCOM_DROP_SERVER; Lex->sql_command = SQLCOM_DROP_SERVER;
Lex->check_exists= $3; Lex->check_exists= $3;
Lex->server_options.server_name= $4.str; Lex->server_options.reset($4);
Lex->server_options.server_name_length= $4.length;
} }
; ;
......
...@@ -626,17 +626,17 @@ int get_connection(MEM_ROOT *mem_root, FEDERATED_SHARE *share) ...@@ -626,17 +626,17 @@ int get_connection(MEM_ROOT *mem_root, FEDERATED_SHARE *share)
at the address of the share. at the address of the share.
*/ */
share->server_name_length= server->server_name_length; share->server_name_length= server->server_name_length;
share->server_name= server->server_name; share->server_name= const_cast<char*>(server->server_name);
share->username= server->username; share->username= const_cast<char*>(server->username);
share->password= server->password; share->password= const_cast<char*>(server->password);
share->database= server->db; share->database= const_cast<char*>(server->db);
share->port= server->port > MIN_PORT && server->port < 65536 ? share->port= server->port > MIN_PORT && server->port < 65536 ?
(ushort) server->port : MYSQL_PORT; (ushort) server->port : MYSQL_PORT;
share->hostname= server->host; share->hostname= const_cast<char*>(server->host);
if (!(share->socket= server->socket) && if (!(share->socket= const_cast<char*>(server->socket)) &&
!strcmp(share->hostname, my_localhost)) !strcmp(share->hostname, my_localhost))
share->socket= (char *) MYSQL_UNIX_ADDR; share->socket= (char *) MYSQL_UNIX_ADDR;
share->scheme= server->scheme; share->scheme= const_cast<char*>(server->scheme);
DBUG_PRINT("info", ("share->username %s", share->username)); DBUG_PRINT("info", ("share->username %s", share->username));
DBUG_PRINT("info", ("share->password %s", share->password)); DBUG_PRINT("info", ("share->password %s", share->password));
......
...@@ -566,17 +566,17 @@ int get_connection(MEM_ROOT *mem_root, FEDERATEDX_SHARE *share) ...@@ -566,17 +566,17 @@ int get_connection(MEM_ROOT *mem_root, FEDERATEDX_SHARE *share)
at the address of the share. at the address of the share.
*/ */
share->server_name_length= server->server_name_length; share->server_name_length= server->server_name_length;
share->server_name= server->server_name; share->server_name= const_cast<char*>(server->server_name);
share->username= server->username; share->username= const_cast<char*>(server->username);
share->password= server->password; share->password= const_cast<char*>(server->password);
share->database= server->db; share->database= const_cast<char*>(server->db);
share->port= server->port > MIN_PORT && server->port < 65536 ? share->port= server->port > MIN_PORT && server->port < 65536 ?
(ushort) server->port : MYSQL_PORT; (ushort) server->port : MYSQL_PORT;
share->hostname= server->host; share->hostname= const_cast<char*>(server->host);
if (!(share->socket= server->socket) && if (!(share->socket= const_cast<char*>(server->socket)) &&
!strcmp(share->hostname, my_localhost)) !strcmp(share->hostname, my_localhost))
share->socket= (char *) MYSQL_UNIX_ADDR; share->socket= (char *) MYSQL_UNIX_ADDR;
share->scheme= server->scheme; share->scheme= const_cast<char*>(server->scheme);
DBUG_PRINT("info", ("share->username: %s", share->username)); DBUG_PRINT("info", ("share->username: %s", share->username));
DBUG_PRINT("info", ("share->password: %s", share->password)); DBUG_PRINT("info", ("share->password: %s", share->password));
......
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