diff options
author | unknown <marty@linux.site> | 2006-04-11 21:06:48 +0200 |
---|---|---|
committer | unknown <marty@linux.site> | 2006-04-11 21:06:48 +0200 |
commit | 0d310faac286592c0eb32fe403325bc096a572a9 (patch) | |
tree | fb2a951346eb96c48f98b1079222ace2b06dfee4 /sql | |
parent | 39bf253c0e2c3d16bc7b3566961f8de5bb39494a (diff) | |
parent | 0b5fe0f8df94308ec2589ed7cd314c878fd8cfe1 (diff) | |
download | mariadb-git-0d310faac286592c0eb32fe403325bc096a572a9.tar.gz |
Merge mskold@bk-internal.mysql.com:/home/bk/mysql-5.1-new
into linux.site:/home/marty/MySQL/mysql-5.1-new
sql/ha_partition.cc:
Auto merged
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_ndbcluster.cc | 38 | ||||
-rw-r--r-- | sql/ha_ndbcluster.h | 3 | ||||
-rw-r--r-- | sql/ha_partition.cc | 4 | ||||
-rw-r--r-- | sql/ha_partition.h | 3 | ||||
-rw-r--r-- | sql/handler.h | 4 | ||||
-rw-r--r-- | sql/sql_table.cc | 32 | ||||
-rw-r--r-- | sql/unireg.cc | 2 |
7 files changed, 53 insertions, 33 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 2ba5c353421..28e026b8a10 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -4696,8 +4696,9 @@ int ha_ndbcluster::create(const char *name, DBUG_RETURN(my_errno); } -int ha_ndbcluster::create_handler_files(const char *file) +int ha_ndbcluster::create_handler_files(const char *file, HA_CREATE_INFO *info) { + char path[FN_REFLEN]; const char *name; Ndb* ndb; const NDBTAB *tab; @@ -4707,16 +4708,21 @@ int ha_ndbcluster::create_handler_files(const char *file) DBUG_ENTER("create_handler_files"); + DBUG_PRINT("enter", ("file: %s", file)); if (!(ndb= get_ndb())) DBUG_RETURN(HA_ERR_NO_CONNECTION); NDBDICT *dict= ndb->getDictionary(); - if (!(tab= dict->getTable(m_tabname))) + if (!info->frm_only) DBUG_RETURN(0); // Must be a create, ignore since frm is saved in create + set_dbname(file); + set_tabname(file); + DBUG_PRINT("info", ("m_dbname: %s, m_tabname: %s", m_dbname, m_tabname)); + if (!(tab= dict->getTable(m_tabname))) + DBUG_RETURN(0); // Unkown table, must be temporary table + DBUG_ASSERT(get_ndb_share_state(m_share) == NSS_ALTERED); - name= table->s->normalized_path.str; - DBUG_PRINT("enter", ("m_tabname: %s, path: %s", m_tabname, name)); - if (readfrm(name, &data, &length) || + if (readfrm(file, &data, &length) || packfrm(data, length, &pack_data, &pack_length)) { DBUG_PRINT("info", ("Missing frm for %s", m_tabname)); @@ -4732,6 +4738,7 @@ int ha_ndbcluster::create_handler_files(const char *file) my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR)); my_free((char*)pack_data, MYF(MY_ALLOW_ZERO_PTR)); } + set_ndb_share_state(m_share, NSS_INITIAL); free_share(&m_share); // Decrease ref_count @@ -4839,6 +4846,15 @@ int ha_ndbcluster::create_ndb_index(const char *name, } /* + Prepare for an on-line alter table +*/ +void ha_ndbcluster::prepare_for_alter() +{ + ndbcluster_get_share(m_share); // Increase ref_count + set_ndb_share_state(m_share, NSS_ALTERED); +} + +/* Add an index on-line to a table */ int ha_ndbcluster::add_index(TABLE *table_arg, @@ -4850,7 +4866,7 @@ int ha_ndbcluster::add_index(TABLE *table_arg, int error= 0; uint idx; - DBUG_ASSERT(m_share->state == NSS_INITIAL); + DBUG_ASSERT(m_share->state == NSS_ALTERED); for (idx= 0; idx < num_of_keys; idx++) { KEY *key= key_info + idx; @@ -4866,10 +4882,10 @@ int ha_ndbcluster::add_index(TABLE *table_arg, if((error= create_index(key_info[idx].name, key, idx_type, idx))) break; } - if (!error) + if (error) { - ndbcluster_get_share(m_share); // Increase ref_count - set_ndb_share_state(m_share, NSS_ALTERED); + set_ndb_share_state(m_share, NSS_INITIAL); + free_share(&m_share); // Decrease ref_count } DBUG_RETURN(error); } @@ -4894,7 +4910,7 @@ int ha_ndbcluster::prepare_drop_index(TABLE *table_arg, uint *key_num, uint num_of_keys) { DBUG_ENTER("ha_ndbcluster::prepare_drop_index"); - DBUG_ASSERT(m_share->state == NSS_INITIAL); + DBUG_ASSERT(m_share->state == NSS_ALTERED); // Mark indexes for deletion uint idx; for (idx= 0; idx < num_of_keys; idx++) @@ -4907,8 +4923,6 @@ int ha_ndbcluster::prepare_drop_index(TABLE *table_arg, Thd_ndb *thd_ndb= get_thd_ndb(thd); Ndb *ndb= thd_ndb->ndb; renumber_indexes(ndb, table_arg); - ndbcluster_get_share(m_share); // Increase ref_count - set_ndb_share_state(m_share, NSS_ALTERED); DBUG_RETURN(0); } diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 7dfec18fcb6..b375e30338f 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -595,6 +595,7 @@ class ha_ndbcluster: public handler const char * table_type() const; const char ** bas_ext() const; ulong table_flags(void) const; + void prepare_for_alter(); int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys); int prepare_drop_index(TABLE *table_arg, uint *key_num, uint num_of_keys); int final_drop_index(TABLE *table_arg); @@ -609,7 +610,7 @@ class ha_ndbcluster: public handler int rename_table(const char *from, const char *to); int delete_table(const char *name); int create(const char *name, TABLE *form, HA_CREATE_INFO *info); - int create_handler_files(const char *file); + int create_handler_files(const char *file, HA_CREATE_INFO *info); int get_default_no_partitions(ulonglong max_rows); bool get_no_parts(const char *name, uint *no_parts); void set_auto_partitions(partition_info *part_info); diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index af020511dfd..3ee9a2954eb 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -562,6 +562,7 @@ int ha_partition::rename_table(const char *from, const char *to) SYNOPSIS create_handler_files() name Full path of table name + create_info Create info generated for CREATE TABLE RETURN VALUE >0 Error @@ -575,7 +576,8 @@ int ha_partition::rename_table(const char *from, const char *to) and types of engines in the partitions. */ -int ha_partition::create_handler_files(const char *name) +int ha_partition::create_handler_files(const char *name, + HA_CREATE_INFO *create_info) { DBUG_ENTER("ha_partition::create_handler_files()"); diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 96b615df71a..ecaa7e1e8fa 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -179,7 +179,8 @@ public: virtual int rename_table(const char *from, const char *to); virtual int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); - virtual int create_handler_files(const char *name); + virtual int create_handler_files(const char *name, + HA_CREATE_INFO *create_info); virtual void update_create_info(HA_CREATE_INFO *create_info); virtual char *update_table_comment(const char *comment); virtual int change_partitions(HA_CREATE_INFO *create_info, diff --git a/sql/handler.h b/sql/handler.h index 261a813bbfa..e93fdfe67e3 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1338,6 +1338,7 @@ public: virtual ulong index_flags(uint idx, uint part, bool all_parts) const =0; + virtual void prepare_for_alter() { return; } virtual int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) { return (HA_ERR_WRONG_COMMAND); } virtual int prepare_drop_index(TABLE *table_arg, uint *key_num, @@ -1378,7 +1379,8 @@ public: virtual void drop_table(const char *name); virtual int create(const char *name, TABLE *form, HA_CREATE_INFO *info)=0; - virtual int create_handler_files(const char *name) { return FALSE;} + virtual int create_handler_files(const char *name, HA_CREATE_INFO *info) + { return FALSE;} virtual int change_partitions(HA_CREATE_INFO *create_info, const char *path, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2687b64841f..0c08c960785 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -347,7 +347,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) lpt->create_info, lpt->new_create_list, lpt->key_count, lpt->key_info_buffer, lpt->table->file)) || ((flags & WFRM_CREATE_HANDLER_FILES) && - lpt->table->file->create_handler_files(path))) + lpt->table->file->create_handler_files(path, lpt->create_info))) { error= 1; goto end; @@ -3964,6 +3964,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, 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 path[FN_REFLEN]; char reg_path[FN_REFLEN+1]; ha_rows copied,deleted; ulonglong next_insert_id; @@ -4000,6 +4001,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (!new_db || !my_strcasecmp(table_alias_charset, new_db, db)) new_db= db; build_table_filename(reg_path, sizeof(reg_path), db, table_name, reg_ext); + build_table_filename(path, sizeof(path), db, table_name, ""); used_fields=create_info->used_fields; @@ -4773,6 +4775,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, KEY_PART_INFO *part_end; DBUG_PRINT("info", ("No new_table, checking add/drop index")); + table->file->prepare_for_alter(); if (index_add_count) { #ifdef XXX_TO_BE_DONE_LATER_BY_WL3020_AND_WL1892 @@ -4788,7 +4791,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, error= (mysql_create_frm(thd, reg_path, db, table_name, create_info, prepared_create_list, key_count, key_info_buffer, table->file) || - table->file->create_handler_files(reg_path)); + table->file->create_handler_files(path, create_info)); VOID(pthread_mutex_unlock(&LOCK_open)); if (error) goto err; @@ -4834,7 +4837,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, error= (mysql_create_frm(thd, reg_path, db, table_name, create_info, prepared_create_list, key_count, key_info_buffer, table->file) || - table->file->create_handler_files(reg_path)); + table->file->create_handler_files(path, create_info)); VOID(pthread_mutex_unlock(&LOCK_open)); if (error) goto err; @@ -4904,19 +4907,16 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, } /*end of if (index_drop_count)*/ - if (index_add_count || index_drop_count) - { - /* - The final .frm file is already created as a temporary file - and will be renamed to the original table name later. - */ + /* + The final .frm file is already created as a temporary file + and will be renamed to the original table name later. + */ - /* Need to commit before a table is unlocked (NDB requirement). */ - DBUG_PRINT("info", ("Committing after add/drop index")); - if (ha_commit_stmt(thd) || ha_commit(thd)) - goto err; - committed= 1; - } + /* Need to commit before a table is unlocked (NDB requirement). */ + DBUG_PRINT("info", ("Committing before unlocking table")); + if (ha_commit_stmt(thd) || ha_commit(thd)) + goto err; + committed= 1; } /*end of if (! new_table) for add/drop index*/ @@ -5061,7 +5061,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, VOID(pthread_mutex_lock(&LOCK_open)); } /* Tell the handler that a new frm file is in place. */ - if (table->file->create_handler_files(reg_path)) + if (table->file->create_handler_files(path, create_info)) { VOID(pthread_mutex_unlock(&LOCK_open)); goto err; diff --git a/sql/unireg.cc b/sql/unireg.cc index 7cb79e866f9..bb197181e2a 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -330,7 +330,7 @@ int rea_create_table(THD *thd, const char *path, // Make sure mysql_create_frm din't remove extension DBUG_ASSERT(*fn_rext(frm_name)); - if (file->create_handler_files(path)) + if (file->create_handler_files(path, create_info)) goto err_handler; if (!create_info->frm_only && ha_create_table(thd, path, db, table_name, create_info,0)) |