diff options
author | unknown <kent@kent-amd64.(none)> | 2006-12-31 01:04:59 +0100 |
---|---|---|
committer | unknown <kent@kent-amd64.(none)> | 2006-12-31 01:04:59 +0100 |
commit | 002d7efa478878565805810dda4bb37bd5dcd32e (patch) | |
tree | b030e2a97457bcce43d57b586e30ec006bca32d5 /sql | |
parent | 3099886cda04701283645d1c59d04c7b2e66966c (diff) | |
parent | 0968cc9dec13ddc3352eeff73aa8ebb3eecb0213 (diff) | |
download | mariadb-git-002d7efa478878565805810dda4bb37bd5dcd32e.tar.gz |
Merge kboortz@bk-internal.mysql.com:/home/bk/mysql-5.1
into mysql.com:/home/kent/bk/main/mysql-5.1
sql/ha_ndbcluster_binlog.cc:
Auto merged
sql/sql_plugin.cc:
Auto merged
storage/ndb/include/kernel/signaldata/Extent.hpp:
Auto merged
storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp:
Auto merged
storage/ndb/src/kernel/blocks/diskpage.hpp:
Auto merged
storage/ndb/src/kernel/blocks/lgman.cpp:
Auto merged
storage/ndb/src/kernel/blocks/print_file.cpp:
Auto merged
storage/ndb/src/kernel/blocks/tsman.cpp:
Auto merged
storage/ndb/src/kernel/blocks/tsman.hpp:
Auto merged
storage/ndb/ndbapi-examples/mgmapi_logevent2/mgmapi_logevent2.cpp:
Auto merged
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_ndbcluster.cc | 76 | ||||
-rw-r--r-- | sql/ha_ndbcluster.h | 2 | ||||
-rw-r--r-- | sql/ha_ndbcluster_binlog.cc | 82 | ||||
-rw-r--r-- | sql/handler.h | 4 | ||||
-rw-r--r-- | sql/sql_plugin.cc | 2 | ||||
-rw-r--r-- | sql/sql_show.cc | 4 | ||||
-rw-r--r-- | sql/sql_table.cc | 11 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 6 |
8 files changed, 108 insertions, 79 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index a7a1a0536c5..5614cc3ecd8 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -133,7 +133,6 @@ static uint ndbcluster_alter_table_flags(uint flags) } static int ndbcluster_inited= 0; -int ndbcluster_util_inited= 0; static Ndb* g_ndb= NULL; Ndb_cluster_connection* g_ndb_cluster_connection= NULL; @@ -157,6 +156,7 @@ static int ndb_get_table_statistics(ha_ndbcluster*, bool, Ndb*, const NDBTAB *, // Util thread variables pthread_t ndb_util_thread; +int ndb_util_thread_running= 0; pthread_mutex_t LOCK_ndb_util_thread; pthread_cond_t COND_ndb_util_thread; pthread_handler_t ndb_util_thread_func(void *arg); @@ -3477,8 +3477,9 @@ int ha_ndbcluster::read_range_first_to_buf(const key_range *start_key, { if (m_active_cursor && (error= close_scan())) DBUG_RETURN(error); - DBUG_RETURN(pk_read(start_key->key, start_key->length, buf, - part_spec.start_part)); + error= pk_read(start_key->key, start_key->length, buf, + part_spec.start_part); + DBUG_RETURN(error == HA_ERR_KEY_NOT_FOUND ? HA_ERR_END_OF_FILE : error); } break; case UNIQUE_ORDERED_INDEX: @@ -3489,7 +3490,9 @@ int ha_ndbcluster::read_range_first_to_buf(const key_range *start_key, { if (m_active_cursor && (error= close_scan())) DBUG_RETURN(error); - DBUG_RETURN(unique_index_read(start_key->key, start_key->length, buf)); + + error= unique_index_read(start_key->key, start_key->length, buf); + DBUG_RETURN(error == HA_ERR_KEY_NOT_FOUND ? HA_ERR_END_OF_FILE : error); } else if (type == UNIQUE_INDEX) DBUG_RETURN(unique_index_scan(key_info, @@ -4803,7 +4806,7 @@ int ha_ndbcluster::create(const char *name, if ((my_errno= create_ndb_column(col, field, info))) DBUG_RETURN(my_errno); - if (info->store_on_disk || getenv("NDB_DEFAULT_DISK")) + if (info->storage_media == HA_SM_DISK || getenv("NDB_DEFAULT_DISK")) col.setStorageType(NdbDictionary::Column::StorageTypeDisk); else col.setStorageType(NdbDictionary::Column::StorageTypeMemory); @@ -4823,7 +4826,7 @@ int ha_ndbcluster::create(const char *name, NdbDictionary::Column::StorageTypeMemory); } - if (info->store_on_disk) + if (info->storage_media == HA_SM_DISK) { if (info->tablespace) tab.setTablespace(info->tablespace); @@ -4832,8 +4835,18 @@ int ha_ndbcluster::create(const char *name, } else if (info->tablespace) { + if (info->storage_media == HA_SM_MEMORY) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_ILLEGAL_HA_CREATE_OPTION, + ER(ER_ILLEGAL_HA_CREATE_OPTION), + ndbcluster_hton_name, + "TABLESPACE currently only supported for " + "STORAGE DISK"); + DBUG_RETURN(HA_ERR_UNSUPPORTED); + } tab.setTablespace(info->tablespace); - info->store_on_disk = true; //if use tablespace, that also means store on disk + info->storage_media = HA_SM_DISK; //if use tablespace, that also means store on disk } // No primary key, create shadow key as 64 bit, auto increment @@ -6716,6 +6729,12 @@ static int ndbcluster_init(void *p) goto ndbcluster_init_error; } + /* Wait for the util thread to start */ + pthread_mutex_lock(&LOCK_ndb_util_thread); + while (!ndb_util_thread_running) + pthread_cond_wait(&COND_ndb_util_thread, &LOCK_ndb_util_thread); + pthread_mutex_unlock(&LOCK_ndb_util_thread); + ndbcluster_inited= 1; DBUG_RETURN(FALSE); @@ -6738,6 +6757,27 @@ static int ndbcluster_end(handlerton *hton, ha_panic_function type) if (!ndbcluster_inited) DBUG_RETURN(0); + ndbcluster_inited= 0; + + /* wait for util thread to finish */ + pthread_mutex_lock(&LOCK_ndb_util_thread); + if (ndb_util_thread_running > 0) + { + pthread_cond_signal(&COND_ndb_util_thread); + pthread_mutex_unlock(&LOCK_ndb_util_thread); + + pthread_mutex_lock(&LOCK_ndb_util_thread); + while (ndb_util_thread_running > 0) + { + struct timespec abstime; + set_timespec(abstime, 1); + pthread_cond_timedwait(&COND_ndb_util_thread, + &LOCK_ndb_util_thread, + &abstime); + } + } + pthread_mutex_unlock(&LOCK_ndb_util_thread); + #ifdef HAVE_NDB_BINLOG { @@ -6784,7 +6824,6 @@ static int ndbcluster_end(handlerton *hton, ha_panic_function type) pthread_mutex_destroy(&ndbcluster_mutex); pthread_mutex_destroy(&LOCK_ndb_util_thread); pthread_cond_destroy(&COND_ndb_util_thread); - ndbcluster_inited= 0; DBUG_RETURN(0); } @@ -7298,7 +7337,7 @@ static void print_share(const char* where, NDB_SHARE* share) fprintf(DBUG_FILE, "%s %s.%s: use_count: %u, commit_count: %llu\n", where, share->db, share->table_name, share->use_count, - share->commit_count); + (long long unsigned int) share->commit_count); fprintf(DBUG_FILE, " - key: %s, key_length: %d\n", share->key, share->key_length); @@ -8330,6 +8369,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) { thd->cleanup(); delete thd; + ndb_util_thread_running= 0; DBUG_RETURN(NULL); } thd->init_for_queries(); @@ -8342,6 +8382,9 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) thd->main_security_ctx.priv_user = 0; thd->current_stmt_binlog_row_based= TRUE; // If in mixed mode + ndb_util_thread_running= 1; + pthread_cond_signal(&COND_ndb_util_thread); + /* wait for mysql server to start */ @@ -8350,8 +8393,6 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused))) pthread_cond_wait(&COND_server_started, &LOCK_server_started); pthread_mutex_unlock(&LOCK_server_started); - ndbcluster_util_inited= 1; - /* Wait for cluster to start */ @@ -8533,6 +8574,9 @@ ndb_util_thread_end: net_end(&thd->net); thd->cleanup(); delete thd; + pthread_mutex_lock(&LOCK_ndb_util_thread); + ndb_util_thread_running= 0; + pthread_mutex_unlock(&LOCK_ndb_util_thread); DBUG_PRINT("exit", ("ndb_util_thread")); my_thread_end(); pthread_exit(0); @@ -9945,7 +9989,7 @@ int ha_ndbcluster::generate_scan_filter_from_key(NdbScanOperation *op, /* get table space info for SHOW CREATE TABLE */ -char* ha_ndbcluster::get_tablespace_name(THD *thd) +char* ha_ndbcluster::get_tablespace_name(THD *thd, char* name, uint name_len) { Ndb *ndb= check_ndb_in_thd(thd); NDBDICT *ndbdict= ndb->getDictionary(); @@ -9963,7 +10007,13 @@ char* ha_ndbcluster::get_tablespace_name(THD *thd) ndberr= ndbdict->getNdbError(); if(ndberr.classification != NdbError::NoError) goto err; - return (my_strdup(ts.getName(), MYF(0))); + if (name) + { + strxnmov(name, name_len, ts.getName(), NullS); + return name; + } + else + return (my_strdup(ts.getName(), MYF(0))); } err: if (ndberr.status == NdbError::TemporaryError) diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index c4bf5901386..50f24c7a4cf 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -823,7 +823,7 @@ private: uint set_up_partition_info(partition_info *part_info, TABLE *table, void *tab); - char* get_tablespace_name(THD *thd); + char* get_tablespace_name(THD *thd, char *name, uint name_len); int set_range_data(void *tab, partition_info* part_info); int set_list_data(void *tab, partition_info* part_info); int complemented_read(const byte *old_data, byte *new_data, diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index e189f7df588..38b640d5f55 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -80,6 +80,8 @@ THD *injector_thd= 0; static Ndb *injector_ndb= 0; static Ndb *schema_ndb= 0; +static int ndbcluster_binlog_inited= 0; + /* Mutex and condition used for interacting between client sql thread and injector thread @@ -557,29 +559,28 @@ ndbcluster_binlog_log_query(handlerton *hton, THD *thd, enum_binlog_command binl DBUG_VOID_RETURN; } + /* - End use of the NDB Cluster table handler - - free all global variables allocated by - ndbcluster_init() + End use of the NDB Cluster binlog + - wait for binlog thread to shutdown */ static int ndbcluster_binlog_end(THD *thd) { - DBUG_ENTER("ndb_binlog_end"); + DBUG_ENTER("ndbcluster_binlog_end"); - if (!ndbcluster_util_inited) + if (!ndbcluster_binlog_inited) DBUG_RETURN(0); - - // Kill ndb utility thread - (void) pthread_mutex_lock(&LOCK_ndb_util_thread); - DBUG_PRINT("exit",("killing ndb util thread: %lx", ndb_util_thread)); - (void) pthread_cond_signal(&COND_ndb_util_thread); - (void) pthread_mutex_unlock(&LOCK_ndb_util_thread); + ndbcluster_binlog_inited= 0; #ifdef HAVE_NDB_BINLOG /* wait for injector thread to finish */ + pthread_mutex_lock(&injector_mutex); if (ndb_binlog_thread_running > 0) { + pthread_cond_signal(&injector_cond); + pthread_mutex_unlock(&injector_mutex); + pthread_mutex_lock(&injector_mutex); while (ndb_binlog_thread_running > 0) { @@ -587,8 +588,9 @@ static int ndbcluster_binlog_end(THD *thd) set_timespec(abstime, 1); pthread_cond_timedwait(&injector_cond, &injector_mutex, &abstime); } - pthread_mutex_unlock(&injector_mutex); } + pthread_mutex_unlock(&injector_mutex); + /* remove all shares */ { @@ -616,8 +618,10 @@ static int ndbcluster_binlog_end(THD *thd) } pthread_mutex_unlock(&ndbcluster_mutex); } + + pthread_mutex_destroy(&injector_mutex); + pthread_cond_destroy(&injector_cond); #endif - ndbcluster_util_inited= 0; DBUG_RETURN(0); } @@ -2285,31 +2289,21 @@ int ndbcluster_binlog_start() DBUG_RETURN(-1); } - /* - Wait for the ndb injector thread to finish starting up. - */ + ndbcluster_binlog_inited= 1; + + /* Wait for the injector thread to start */ pthread_mutex_lock(&injector_mutex); while (!ndb_binlog_thread_running) pthread_cond_wait(&injector_cond, &injector_mutex); pthread_mutex_unlock(&injector_mutex); - + if (ndb_binlog_thread_running < 0) DBUG_RETURN(-1); + DBUG_RETURN(0); } -static void ndbcluster_binlog_close_connection(THD *thd) -{ - DBUG_ENTER("ndbcluster_binlog_close_connection"); - const char *save_info= thd->proc_info; - thd->proc_info= "ndbcluster_binlog_close_connection"; - do_ndbcluster_binlog_close_connection= BCCC_exit; - while (ndb_binlog_thread_running > 0) - sleep(1); - thd->proc_info= save_info; - DBUG_VOID_RETURN; -} /************************************************************** Internal helper functions for creating/dropping ndb events @@ -3541,7 +3535,7 @@ restart: if (abort_loop) goto err; schema_res= s_ndb->pollEvents(100, &schema_gci); - } while (ndb_latest_received_binlog_epoch == schema_gci); + } while (schema_gci == 0 || ndb_latest_received_binlog_epoch == schema_gci); if (ndb_binlog_running) { Uint64 gci= i_ndb->getLatestGCI(); @@ -3952,15 +3946,12 @@ restart: goto restart; } err: + sql_print_information("Stopping Cluster Binlog"); DBUG_PRINT("info",("Shutting down cluster binlog thread")); thd->proc_info= "Shutting down"; close_thread_tables(thd); pthread_mutex_lock(&injector_mutex); /* don't mess with the injector_ndb anymore from other threads */ - uint ndb_obj_cnt= 1; // g_ndb - ndb_obj_cnt+= injector_ndb == 0 ? 0 : 1; - ndb_obj_cnt+= schema_ndb == 0 ? 0 : 1; - ndb_obj_cnt+= ndbcluster_util_inited ? 1 : 0; injector_thd= 0; injector_ndb= 0; p_latest_trans_gci= 0; @@ -3968,29 +3959,6 @@ err: pthread_mutex_unlock(&injector_mutex); thd->db= 0; // as not to try to free memory - if (!ndb_extra_logging) - sql_print_information("Stopping Cluster Binlog"); - else - sql_print_information("Stopping Cluster Binlog: %u(%u)", - g_ndb_cluster_connection->get_active_ndb_objects(), - ndb_obj_cnt); - - /** - * Add extra wait loop to make user "user" ndb-object go away... - * otherwise user thread can have ongoing SUB_DATA - */ - int sleep_cnt= 0; - while (sleep_cnt < 300 && - g_ndb_cluster_connection->get_active_ndb_objects() > ndb_obj_cnt) - { - my_sleep(10000); // 10ms - sleep_cnt++; - } - if (ndb_extra_logging) - sql_print_information("Stopping Cluster Binlog: waited %ums %u(%u)", - 10*sleep_cnt, g_ndb_cluster_connection->get_active_ndb_objects(), - ndb_obj_cnt); - if (ndb_apply_status_share) { free_share(&ndb_apply_status_share); @@ -4046,8 +4014,8 @@ err: hash_free(&ndb_schema_objects); - // Placed here to avoid a memory leak; TODO: check if needed net_end(&thd->net); + thd->cleanup(); delete thd; ndb_binlog_thread_running= -1; diff --git a/sql/handler.h b/sql/handler.h index f13aa972400..592159ec428 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -763,7 +763,7 @@ typedef struct st_ha_create_information bool table_existed; /* 1 in create if table existed */ bool frm_only; /* 1 if no ha_create_table() */ bool varchar; /* 1 if table has a VARCHAR */ - bool store_on_disk; /* 1 if table stored on disk */ + enum ha_storage_media storage_media; /* DEFAULT, DISK or MEMORY */ } HA_CREATE_INFO; @@ -1409,7 +1409,7 @@ public: { return FALSE; } virtual char* get_foreign_key_create_info() { return(NULL);} /* gets foreign key create string from InnoDB */ - virtual char* get_tablespace_name(THD *thd) + virtual char* get_tablespace_name(THD *thd, char *name, uint name_len) { return(NULL);} /* gets tablespace name from handler */ /* used in ALTER TABLE; 1 if changing storage engine is allowed */ virtual bool can_switch_engines() { return 1; } diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index ea3e88fefa7..1d711b7835c 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -982,7 +982,7 @@ my_bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func, { rw_rdlock(&THR_LOCK_plugin); for (uint i=idx; i < total; i++) - if (plugins[i]->state & state_mask) + if (plugins[i] && plugins[i]->state & state_mask) plugins[i]=0; rw_unlock(&THR_LOCK_plugin); } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 2c122bcd5dd..c4bb6a8fc92 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1266,7 +1266,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet, to the CREATE TABLE statement */ - if ((for_str= file->get_tablespace_name(thd))) + if ((for_str= file->get_tablespace_name(thd,0,0))) { packet->append(STRING_WITH_LEN(" /*!50100 TABLESPACE ")); packet->append(for_str, strlen(for_str)); @@ -3973,7 +3973,7 @@ static void store_schema_partitions_record(THD *thd, TABLE *schema_table, strlen(part_elem->tablespace_name), cs); else { - char *ts= showing_table->file->get_tablespace_name(thd); + char *ts= showing_table->file->get_tablespace_name(thd,0,0); if(ts) { table->field[24]->store(ts, strlen(ts), cs); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index dcc723cf4b6..7057c783701 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5306,7 +5306,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, int error; char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN]; char new_alias_buff[FN_REFLEN], *table_name, *db, *new_alias, *alias; - char index_file[FN_REFLEN], data_file[FN_REFLEN]; + char index_file[FN_REFLEN], data_file[FN_REFLEN], tablespace[FN_LEN]; char path[FN_REFLEN]; char reg_path[FN_REFLEN+1]; ha_rows copied,deleted; @@ -5629,6 +5629,15 @@ view_err: if (!(used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE)) create_info->key_block_size= table->s->key_block_size; + if (!create_info->tablespace && create_info->storage_media != HA_SM_MEMORY) + { + /* + Regular alter table of disk stored table (no tablespace/storage change) + Copy tablespace name + */ + if ((table->file->get_tablespace_name(thd, tablespace, FN_LEN))) + create_info->tablespace= tablespace; + } restore_record(table, s->default_values); // Empty record for DEFAULT List_iterator<Alter_drop> drop_it(alter_info->drop_list); List_iterator<create_field> def_it(fields); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index eb415f8b408..4d8eda06faf 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4008,8 +4008,8 @@ create_table_option: | DATA_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys { Lex->create_info.data_file_name= $4.str; Lex->create_info.used_fields|= HA_CREATE_USED_DATADIR; } | INDEX_SYM DIRECTORY_SYM opt_equal TEXT_STRING_sys { Lex->create_info.index_file_name= $4.str; Lex->create_info.used_fields|= HA_CREATE_USED_INDEXDIR; } | TABLESPACE ident {Lex->create_info.tablespace= $2.str;} - | STORAGE_SYM DISK_SYM {Lex->create_info.store_on_disk= TRUE;} - | STORAGE_SYM MEMORY_SYM {Lex->create_info.store_on_disk= FALSE;} + | STORAGE_SYM DISK_SYM {Lex->create_info.storage_media= HA_SM_DISK;} + | STORAGE_SYM MEMORY_SYM {Lex->create_info.storage_media= HA_SM_MEMORY;} | CONNECTION_SYM opt_equal TEXT_STRING_sys { Lex->create_info.connect_string.str= $3.str; Lex->create_info.connect_string.length= $3.length; Lex->create_info.used_fields|= HA_CREATE_USED_CONNECTION; } | KEY_BLOCK_SIZE opt_equal ulong_num { @@ -4751,6 +4751,7 @@ alter: lex->alter_info.reset(); lex->alter_info.flags= 0; lex->no_write_to_binlog= 0; + lex->create_info.storage_media= HA_SM_DEFAULT; } alter_commands {} @@ -8417,6 +8418,7 @@ show_param: if (!lex->select_lex.add_table_to_list(YYTHD, $3, NULL,0)) YYABORT; lex->only_view= 0; + lex->create_info.storage_media= HA_SM_DEFAULT; } | CREATE VIEW_SYM table_ident { |