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

Function create_server

sql/sql_servers.cc:1121–1188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1119*/
1120
1121int create_server(THD *thd, LEX_SERVER_OPTIONS *server_options)
1122{
1123 int error= ER_FOREIGN_SERVER_EXISTS;
1124 FOREIGN_SERVER *server;
1125
1126 DBUG_ENTER("create_server");
1127 DBUG_PRINT("info", ("server_options->server_name %s",
1128 server_options->server_name.str));
1129
1130 mysql_rwlock_wrlock(&THR_LOCK_servers);
1131
1132 /* hit the memory first */
1133 if (my_hash_search(&servers_cache, (uchar*) server_options->server_name.str,
1134 server_options->server_name.length))
1135 {
1136 if (thd->lex->create_info.or_replace())
1137 {
1138 if (unlikely((error= drop_server_internal(thd, server_options))))
1139 goto end;
1140 }
1141 else if (thd->lex->create_info.if_not_exists())
1142 {
1143 push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
1144 ER_FOREIGN_SERVER_EXISTS,
1145 ER_THD(thd, ER_FOREIGN_SERVER_EXISTS),
1146 server_options->server_name.str);
1147 error= 0;
1148 goto end;
1149 }
1150 else
1151 goto end;
1152 }
1153
1154 if (!(server= prepare_server_struct_for_insert(server_options)))
1155 {
1156 /* purecov: begin inspected */
1157 error= ER_OUT_OF_RESOURCES;
1158 goto end;
1159 /* purecov: end */
1160 }
1161
1162 error= insert_server(thd, server);
1163
1164 DBUG_PRINT("info", ("error returned %d", error));
1165
1166end:
1167 mysql_rwlock_unlock(&THR_LOCK_servers);
1168
1169 if (unlikely(error))
1170 DBUG_PRINT("info", ("problem creating server <%s>: %d",
1171 server_options->server_name.str, error));
1172
1173 switch (error) {
1174 case 0:
1175 my_ok(thd);
1176 break;
1177 case ER_CANNOT_LOAD_FROM_TABLE_V2:
1178 my_error(error, MYF(0), "mysql", MYSQL_SERVERS_NAME.str);

Callers 1

sql_parse.ccFile · 0.85

Calls 9

my_hash_searchFunction · 0.85
drop_server_internalFunction · 0.85
push_warning_printfFunction · 0.85
insert_serverFunction · 0.85
my_okFunction · 0.85
my_errorFunction · 0.85
or_replaceMethod · 0.80
if_not_existsMethod · 0.80

Tested by

no test coverage detected