diff options
author | ingo@mysql.com <> | 2004-03-30 19:22:14 +0200 |
---|---|---|
committer | ingo@mysql.com <> | 2004-03-30 19:22:14 +0200 |
commit | 85ec87a09445906dc1273c614434b1de5d2b5bea (patch) | |
tree | 1aadd9023a8717250c99b8a10791977beac9c8eb /sql/unireg.cc | |
parent | 6a636a4d07a90c29ab7b47dca557124df6dee9fd (diff) | |
download | mariadb-git-85ec87a09445906dc1273c614434b1de5d2b5bea.tar.gz |
Worklog#1563 - Support of on-line CREATE/DROP INDEX.
This is to enable table handlers to implement online create/drop index.
It consists of some parts:
- New default handler methods in handler.h
- Split of mysql_alter_table. It decides if only one kind of
alteration is to be done (e.g. only create indexes or only drop
indexes etc.) It then calls the specialized new handler method if
the handler implements it. Otherwise it calls real_alter_table.
- The parser sets flags for each alter operation detected in a
command. These are used by mysql_alter_table for the decision.
- mysql_prepare_table is pulled out of mysql_create_table. This is
also used by mysql_create_index to prepare the key structure array
for the handler. It is also used by mysql_create_index and
mysql_drop_index to prepare a call to mysql_create_frm.
- mysql_create_frm is pulled out of rea_create_table for use by
mysql_create_index and mysql_drop_index after the index is
created/dropped.
Thanks to Antony who supplied most of the changes.
Diffstat (limited to 'sql/unireg.cc')
-rw-r--r-- | sql/unireg.cc | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc index 6f127b57f64..350dc7e5a43 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -47,10 +47,11 @@ static bool make_empty_rec(int file, enum db_type table_type, uint reclength,uint null_fields); -int rea_create_table(THD *thd, my_string file_name, +int mysql_create_frm(THD *thd, my_string file_name, HA_CREATE_INFO *create_info, List<create_field> &create_fields, - uint keys, KEY *key_info) + uint keys, KEY *key_info, + handler *db_file) { uint reclength,info_length,screens,key_info_length,maxlength,null_fields; File file; @@ -58,13 +59,13 @@ int rea_create_table(THD *thd, my_string file_name, uchar fileinfo[64],forminfo[288],*keybuff; TYPELIB formnames; uchar *screen_buff; - handler *db_file; DBUG_ENTER("rea_create_table"); formnames.type_names=0; if (!(screen_buff=pack_screens(create_fields,&info_length,&screens,0))) DBUG_RETURN(1); - db_file=get_new_handler((TABLE*) 0, create_info->db_type); + if (db_file == NULL) + db_file=get_new_handler((TABLE*) 0, create_info->db_type); if (pack_header(forminfo, create_info->db_type,create_fields,info_length, screens, create_info->table_options, db_file)) { @@ -155,8 +156,7 @@ int rea_create_table(THD *thd, my_string file_name, if (opt_sync_frm && !(create_info->options & HA_LEX_CREATE_TMP_TABLE) && my_sync(file, MYF(MY_WME))) goto err2; - if (my_close(file,MYF(MY_WME)) || - ha_create_table(file_name,create_info,0)) + if (my_close(file,MYF(MY_WME))) goto err3; DBUG_RETURN(0); @@ -166,6 +166,23 @@ err: err2: VOID(my_close(file,MYF(MY_WME))); err3: + DBUG_RETURN(1); +} /* mysql_create_frm */ + +int rea_create_table(THD *thd, my_string file_name, + HA_CREATE_INFO *create_info, + List<create_field> &create_fields, + uint keys, KEY *key_info) +{ + DBUG_ENTER("rea_create_table"); + + if (mysql_create_frm(thd, file_name, create_info, + create_fields, keys, key_info, NULL) || + ha_create_table(file_name,create_info,0)) + goto err; + DBUG_RETURN(0); + +err: my_delete(file_name,MYF(0)); DBUG_RETURN(1); } /* rea_create_table */ |