summaryrefslogtreecommitdiff
path: root/sql/unireg.cc
diff options
context:
space:
mode:
authorunknown <ingo@mysql.com>2004-03-30 19:22:14 +0200
committerunknown <ingo@mysql.com>2004-03-30 19:22:14 +0200
commitf5297edcae7167e3c8e4eaa06bfa8353e4c4b81d (patch)
tree1aadd9023a8717250c99b8a10791977beac9c8eb /sql/unireg.cc
parent85c7ce36879f0dfc68e26a13b384dc48d79d8100 (diff)
downloadmariadb-git-f5297edcae7167e3c8e4eaa06bfa8353e4c4b81d.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. sql/handler.h: Worklog#1563 - Support of on-line CREATE/DROP INDEX. New virtual handler methods with default implementation and return flags. sql/mysql_priv.h: Worklog#1563 - Support of on-line CREATE/DROP INDEX. New function prototypes. mysql_prepare_table is pulled out of mysql_create_table. It prepares a table structure, which is used by mysql_create_table, mysql_create_index and mysql_drop_index. real_alter_table is pulled out of mysql_alter_table. The latter only looks if the requested operation can be done by specialized functions or else calls real_alter_table, which does the real thing. mysql_add_column and mysql_drop_colunm are for future use. They simply call real_alter_table. mysql_create_frm is pulled out of rea_create_table. It is called also from mysql_create_index and mysql_drop_index after successful create/drop index. mysql_alter_table prototype is extended by the new alter_flags argument. sql/sql_base.cc: Worklog#1563 - Support of on-line CREATE/DROP INDEX. mysql_create_index and mysql_drop_index moved to sql_table.cc. sql/sql_lex.h: Worklog#1563 - Support of on-line CREATE/DROP INDEX. Definitions for the new alter_flags. sql/sql_parse.cc: Worklog#1563 - Support of on-line CREATE/DROP INDEX. Extend the calls to mysql_alter_table by the new alter_flags argument. sql/sql_table.cc: Worklog#1563 - Support of on-line CREATE/DROP INDEX. mysql_prepare_table is pulled out of mysql_create_table. mysql_create_index and mysql_drop_index are changed so that they use the new handler functions if the handler implements them. mysql_add_column and mysql_drop_column are for future use. They simply call real_alter_table. mysql_alter_table only decides which function to use for the requested operation. real_alter_table implements most of what mysql_alter_table did before. sql/sql_yacc.yy: Worklog#1563 - Support of on-line CREATE/DROP INDEX. Set the alter_flags where appropriate. sql/unireg.cc: Worklog#1563 - Support of on-line CREATE/DROP INDEX. mysql_create_frm is pulled out of rea_create_table.
Diffstat (limited to 'sql/unireg.cc')
-rw-r--r--sql/unireg.cc29
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 */