int drop_server(THD *thd, LEX_SERVER_OPTIONS *server_options) { int error; TABLE_LIST tables; TABLE *table; LEX_STRING name= { server_options->server_name, server_options->server_name_length }; DBUG_ENTER("drop_server"); DBUG_PRINT("info", ("server name server->server_name %s", server_options->server_name)); bzero((char*) &tables, sizeof(tables)); tables.db= (char*) "mysql"; tables.alias= tables.table_name= (char*) "servers"; rw_wrlock(&THR_LOCK_servers); /* hit the memory hit first */ if ((error= delete_server_record_in_cache(server_options))) goto end; if (! (table= open_ltable(thd, &tables, TL_WRITE, 0))) { error= my_errno; goto end; } error= delete_server_record(table, name.str, name.length); /* close the servers table before we call closed_cached_connection_tables */ close_thread_tables(thd); if (close_cached_connection_tables(thd, TRUE, &name)) { push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, "Server connection in use"); } end: rw_unlock(&THR_LOCK_servers); DBUG_RETURN(error); }
int alter_server(THD *thd, LEX_SERVER_OPTIONS *server_options) { int error= ER_FOREIGN_SERVER_DOESNT_EXIST; FOREIGN_SERVER *altered, *existing; LEX_STRING name= { server_options->server_name, server_options->server_name_length }; DBUG_ENTER("alter_server"); DBUG_PRINT("info", ("server_options->server_name %s", server_options->server_name)); rw_wrlock(&THR_LOCK_servers); if (!(existing= (FOREIGN_SERVER *) hash_search(&servers_cache, (uchar*) name.str, name.length))) goto end; altered= (FOREIGN_SERVER *)alloc_root(&mem, sizeof(FOREIGN_SERVER)); prepare_server_struct_for_update(server_options, existing, altered); error= update_server(thd, existing, altered); /* close the servers table before we call closed_cached_connection_tables */ close_thread_tables(thd); if (close_cached_connection_tables(thd, FALSE, &name)) { push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, "Server connection in use"); } end: DBUG_PRINT("info", ("error returned %d", error)); rw_unlock(&THR_LOCK_servers); DBUG_RETURN(error); }
int mrn_add_index_param(MRN_SHARE *share, KEY *key_info, int i) { int error; char *param_string = NULL; #if MYSQL_VERSION_ID >= 50500 int title_length; char *sprit_ptr[2]; char *tmp_ptr, *start_ptr; #endif THD *thd = current_thd; MRN_DBUG_ENTER_FUNCTION(); #if MYSQL_VERSION_ID >= 50500 if (key_info->comment.length == 0) { if (share->key_tokenizer[i]) { my_free(share->key_tokenizer[i]); } share->key_tokenizer[i] = mrn_my_strdup(mrn_default_tokenizer, MYF(MY_WME)); if (!share->key_tokenizer[i]) { error = HA_ERR_OUT_OF_MEM; goto error; } share->key_tokenizer_length[i] = strlen(share->key_tokenizer[i]); DBUG_RETURN(0); } DBUG_PRINT("info", ("mroonga create comment string")); if ( !(param_string = mrn_my_strndup(key_info->comment.str, key_info->comment.length, MYF(MY_WME))) ) { error = HA_ERR_OUT_OF_MEM; goto error_alloc_param_string; } DBUG_PRINT("info", ("mroonga comment string=%s", param_string)); sprit_ptr[0] = param_string; while (sprit_ptr[0]) { if ((sprit_ptr[1] = strchr(sprit_ptr[0], ','))) { *sprit_ptr[1] = '\0'; sprit_ptr[1]++; } tmp_ptr = sprit_ptr[0]; sprit_ptr[0] = sprit_ptr[1]; while (*tmp_ptr == ' ' || *tmp_ptr == '\r' || *tmp_ptr == '\n' || *tmp_ptr == '\t') tmp_ptr++; if (*tmp_ptr == '\0') continue; title_length = 0; start_ptr = tmp_ptr; while (*start_ptr != ' ' && *start_ptr != '\'' && *start_ptr != '"' && *start_ptr != '\0' && *start_ptr != '\r' && *start_ptr != '\n' && *start_ptr != '\t') { title_length++; start_ptr++; } switch (title_length) { case 5: MRN_PARAM_STR_LIST("table", index_table, i); break; case 6: push_warning_printf(thd, MRN_SEVERITY_WARNING, ER_WARN_DEPRECATED_SYNTAX, ER(ER_WARN_DEPRECATED_SYNTAX), "parser", "tokenizer"); MRN_PARAM_STR_LIST("parser", key_tokenizer, i); break; case 9: MRN_PARAM_STR_LIST("tokenizer", key_tokenizer, i); break; default: break; } } #endif if (!share->key_tokenizer[i]) { share->key_tokenizer[i] = mrn_my_strdup(mrn_default_tokenizer, MYF(MY_WME)); if (!share->key_tokenizer[i]) { error = HA_ERR_OUT_OF_MEM; goto error; } share->key_tokenizer_length[i] = strlen(share->key_tokenizer[i]); } if (param_string) my_free(param_string); DBUG_RETURN(0); error: if (param_string) my_free(param_string); #if MYSQL_VERSION_ID >= 50500 error_alloc_param_string: #endif DBUG_RETURN(error); }