diff options
author | Sergei Golubchik <serg@mariadb.org> | 2014-11-16 13:15:35 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2014-12-04 10:41:51 +0100 |
commit | 20c3b2ff807b07610ed9012f31fce0ba68d522b0 (patch) | |
tree | 5133874c82e30bc8a7277589f2f62aceeb53ca45 /sql/sql_servers.cc | |
parent | 97a913e31c161dbd18f4fcb9cc00f23640497e03 (diff) | |
download | mariadb-git-20c3b2ff807b07610ed9012f31fce0ba68d522b0.tar.gz |
MDEV-6311 Add errors on CREATE SERVER
fail CREATE SERVER foreign data wrapper is "mysql"
and neither HOST nor SOCKET are specified.
Also default PORT to 3306 (again, only for foreign
data wrapper "mysql")
Diffstat (limited to 'sql/sql_servers.cc')
-rw-r--r-- | sql/sql_servers.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc index 670ad182e8b..1fd46027725 100644 --- a/sql/sql_servers.cc +++ b/sql/sql_servers.cc @@ -1078,6 +1078,7 @@ static FOREIGN_SERVER * prepare_server_struct_for_insert(LEX_SERVER_OPTIONS *server_options) { FOREIGN_SERVER *server; + ulong default_port= 0; DBUG_ENTER("prepare_server_struct"); if (!(server= (FOREIGN_SERVER *)alloc_root(&mem, sizeof(FOREIGN_SERVER)))) @@ -1095,6 +1096,18 @@ prepare_server_struct_for_insert(LEX_SERVER_OPTIONS *server_options) SET_SERVER_OR_RETURN(server_name, NULL); SET_SERVER_OR_RETURN(scheme, NULL); + /* scheme-specific checks */ + if (!strcasecmp(server->scheme, "mysql")) + { + default_port= MYSQL_PORT; + if (!server_options->host.str && !server_options->socket.str) + { + my_error(ER_CANT_CREATE_FEDERATED_TABLE, MYF(0), + "either HOST or SOCKET must be set"); + DBUG_RETURN(NULL); + } + } + SET_SERVER_OR_RETURN(host, ""); SET_SERVER_OR_RETURN(db, ""); SET_SERVER_OR_RETURN(username, ""); @@ -1104,9 +1117,9 @@ prepare_server_struct_for_insert(LEX_SERVER_OPTIONS *server_options) server->server_name_length= server_options->server_name.length; - /* set to 0 if not specified */ + /* set to default_port if not specified */ server->port= server_options->port > -1 ? - server_options->port : 0; + server_options->port : default_port; DBUG_RETURN(server); } |