MCPcopy Create free account
hub / github.com/MariaDB/server / prepare_server_struct_for_insert

Function prepare_server_struct_for_insert

sql/sql_servers.cc:1265–1314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1263*/
1264
1265static FOREIGN_SERVER *
1266prepare_server_struct_for_insert(LEX_SERVER_OPTIONS *server_options)
1267{
1268 FOREIGN_SERVER *server;
1269 ulong default_port= 0;
1270 DBUG_ENTER("prepare_server_struct");
1271
1272 if (!(server= (FOREIGN_SERVER *)alloc_root(&mem, sizeof(FOREIGN_SERVER))))
1273 DBUG_RETURN(NULL); /* purecov: inspected */
1274
1275#define SET_SERVER_OR_RETURN(X, DEFAULT) \
1276 do { \
1277 if (!(server->X= server_options->X.str ? \
1278 strmake_root(&mem, server_options->X.str, \
1279 server_options->X.length) : "")) \
1280 DBUG_RETURN(NULL); \
1281 } while(0)
1282
1283 /* name and scheme are always set (the parser guarantees it) */
1284 SET_SERVER_OR_RETURN(server_name, NULL);
1285 SET_SERVER_OR_RETURN(scheme, NULL);
1286
1287 /* scheme-specific checks */
1288 if (!strcasecmp(server->scheme, "mysql"))
1289 {
1290 default_port= MYSQL_PORT;
1291 if (!server_options->host.str && !server_options->socket.str)
1292 {
1293 my_error(ER_CANT_CREATE_FEDERATED_TABLE, MYF(0),
1294 "either HOST or SOCKET must be set");
1295 DBUG_RETURN(NULL);
1296 }
1297 }
1298
1299 SET_SERVER_OR_RETURN(host, "");
1300 SET_SERVER_OR_RETURN(db, "");
1301 SET_SERVER_OR_RETURN(username, "");
1302 SET_SERVER_OR_RETURN(password, "");
1303 SET_SERVER_OR_RETURN(socket, "");
1304 SET_SERVER_OR_RETURN(owner, "");
1305 copy_option_list(&mem, server, server_options->option_list);
1306
1307 server->server_name_length= server_options->server_name.length;
1308
1309 /* set to default_port if not specified */
1310 server->port= server_options->port > -1 ?
1311 server_options->port : default_port;
1312
1313 DBUG_RETURN(server);
1314}
1315
1316/*
1317

Callers 1

create_serverFunction · 0.85

Calls 3

alloc_rootFunction · 0.85
my_errorFunction · 0.85
copy_option_listFunction · 0.85

Tested by

no test coverage detected