diff options
author | unknown <andrey@lmy004.> | 2006-01-11 12:01:36 +0100 |
---|---|---|
committer | unknown <andrey@lmy004.> | 2006-01-11 12:01:36 +0100 |
commit | 0d732a1470dc443c636493f2b6d4db269b250241 (patch) | |
tree | bdae416c995fa909938346e38c2f7252848f05d3 /sql | |
parent | 923b97736fa461c67f49491bf872c1417e7d2a7f (diff) | |
parent | 641ce5e97e64fc89e497ee903bca03bef9476665 (diff) | |
download | mariadb-git-0d732a1470dc443c636493f2b6d4db269b250241.tar.gz |
manual merge
sql/Makefile.am:
Auto merged
sql/lex.h:
Auto merged
sql/sql_lex.h:
Auto merged
sql/sql_parse.cc:
Auto merged
Diffstat (limited to 'sql')
-rw-r--r-- | sql/Makefile.am | 2 | ||||
-rw-r--r-- | sql/ha_berkeley.cc | 1 | ||||
-rw-r--r-- | sql/ha_blackhole.cc | 1 | ||||
-rw-r--r-- | sql/ha_federated.cc | 1 | ||||
-rw-r--r-- | sql/ha_heap.cc | 1 | ||||
-rw-r--r-- | sql/ha_myisam.cc | 1 | ||||
-rw-r--r-- | sql/ha_myisammrg.cc | 1 | ||||
-rw-r--r-- | sql/ha_ndbcluster.cc | 111 | ||||
-rw-r--r-- | sql/ha_ndbcluster.h | 1 | ||||
-rw-r--r-- | sql/ha_partition.cc | 1 | ||||
-rw-r--r-- | sql/handler.h | 81 | ||||
-rw-r--r-- | sql/lex.h | 19 | ||||
-rw-r--r-- | sql/log.cc | 1 | ||||
-rw-r--r-- | sql/mysql_priv.h | 1 | ||||
-rw-r--r-- | sql/share/errmsg.txt | 46 | ||||
-rw-r--r-- | sql/sql_lex.h | 8 | ||||
-rw-r--r-- | sql/sql_parse.cc | 6 | ||||
-rw-r--r-- | sql/sql_tablespace.cc | 50 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 577 |
19 files changed, 714 insertions, 196 deletions
diff --git a/sql/Makefile.am b/sql/Makefile.am index 214bf0dbb88..ddbfdb88ba5 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -99,7 +99,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \ sp_cache.cc parse_file.cc sql_trigger.cc \ event_executor.cc event.cc event_timed.cc \ sql_plugin.cc sql_binlog.cc \ - handlerton.cc + handlerton.cc sql_tablespace.cc EXTRA_mysqld_SOURCES = ha_innodb.cc ha_berkeley.cc ha_archive.cc \ ha_innodb.h ha_berkeley.h ha_archive.h \ ha_blackhole.cc ha_federated.cc ha_ndbcluster.cc \ diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 01d6ceed3f2..fb9ed2de117 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -149,6 +149,7 @@ handlerton berkeley_hton = { NULL, /* Start Consistent Snapshot */ berkeley_flush_logs, /* Flush logs */ berkeley_show_status, /* Show status */ + NULL, /* Alter Tablespace */ HTON_CLOSE_CURSORS_AT_COMMIT | HTON_FLUSH_AFTER_RENAME }; diff --git a/sql/ha_blackhole.cc b/sql/ha_blackhole.cc index 615836b9867..38e03d4d1f7 100644 --- a/sql/ha_blackhole.cc +++ b/sql/ha_blackhole.cc @@ -57,6 +57,7 @@ handlerton blackhole_hton= { NULL, /* Start Consistent Snapshot */ NULL, /* Flush logs */ NULL, /* Show status */ + NULL, /* Alter Tablespace */ HTON_CAN_RECREATE }; diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index bc087ac25e7..b218b52bfd9 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -394,6 +394,7 @@ handlerton federated_hton= { NULL, /* Start Consistent Snapshot */ NULL, /* Flush logs */ NULL, /* Show status */ + NULL, /* Alter Tablespace */ HTON_ALTER_NOT_SUPPORTED }; diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index a83a95ac863..bcb0bf07774 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -54,6 +54,7 @@ handlerton heap_hton= { NULL, /* Start Consistent Snapshot */ NULL, /* Flush logs */ NULL, /* Show status */ + NULL, /* Alter Tablespace */ HTON_CAN_RECREATE }; diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 41000564e53..87bc2148b03 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -86,6 +86,7 @@ handlerton myisam_hton= { NULL, /* Start Consistent Snapshot */ NULL, /* Flush logs */ NULL, /* Show status */ + NULL, /* Alter Tablespace */ HTON_CAN_RECREATE }; diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index ccb3475e34f..601fe94bf11 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -64,6 +64,7 @@ handlerton myisammrg_hton= { NULL, /* Start Consistent Snapshot */ NULL, /* Flush logs */ NULL, /* Show status */ + NULL, /* Alter Tablespace */ HTON_CAN_RECREATE }; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 0cef2d1521c..7bc3af2c3aa 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -57,6 +57,7 @@ static int ndbcluster_close_connection(THD *thd); static int ndbcluster_commit(THD *thd, bool all); static int ndbcluster_rollback(THD *thd, bool all); static handler* ndbcluster_create_handler(TABLE_SHARE *table); +static int ndbcluster_alter_tablespace(THD* thd, st_alter_tablespace *info); handlerton ndbcluster_hton = { MYSQL_HANDLERTON_INTERFACE_VERSION, @@ -86,6 +87,7 @@ handlerton ndbcluster_hton = { NULL, /* Start Consistent Snapshot */ NULL, /* Flush logs */ ndbcluster_show_status, /* Show status */ + ndbcluster_alter_tablespace, HTON_NO_FLAGS }; @@ -4019,13 +4021,8 @@ int ha_ndbcluster::create(const char *name, field->pack_length())); if ((my_errno= create_ndb_column(col, field, info))) DBUG_RETURN(my_errno); - - if ( -#ifdef NDB_DISKDATA - info->store_on_disk || -#else - getenv("NDB_DEFAULT_DISK")) -#endif + + if (info->store_on_disk || getenv("NDB_DEFAULT_DISK")) col.setStorageType(NdbDictionary::Column::StorageTypeDisk); else col.setStorageType(NdbDictionary::Column::StorageTypeMemory); @@ -4045,14 +4042,11 @@ int ha_ndbcluster::create(const char *name, NdbDictionary::Column::StorageTypeMemory); } -#ifdef NDB_DISKDATA if (info->store_on_disk) if (info->tablespace) tab.setTablespace(info->tablespace); else tab.setTablespace("DEFAULT-TS"); -#endif - // No primary key, create shadow key as 64 bit, auto increment if (form->s->primary_key == MAX_KEY) { @@ -8315,7 +8309,6 @@ bool ha_ndbcluster::check_if_incompatible_data(HA_CREATE_INFO *info, return COMPATIBLE_DATA_YES; } -#ifdef NDB_DISKDATA bool set_up_tablespace(st_alter_tablespace *info, NdbDictionary::Tablespace *ndb_ts) { @@ -8356,21 +8349,25 @@ bool set_up_undofile(st_alter_tablespace *info, return false; } -int ha_ndbcluster::alter_tablespace(st_alter_tablespace *info) +int ndbcluster_alter_tablespace(THD* thd, st_alter_tablespace *info) { - Ndb *ndb; - NDBDICT *dict; - int error; DBUG_ENTER("ha_ndbcluster::alter_tablespace"); - if (check_ndb_connection()) + + Ndb *ndb= check_ndb_in_thd(thd); + if (ndb == NULL) { - DBUG_RETURN(my_errno= HA_ERR_NO_CONNECTION); + DBUG_RETURN(HA_ERR_NO_CONNECTION); } - ndb= get_ndb(); - dict= ndb->getDictionary(); + + NDBDICT *dict = ndb->getDictionary(); + int error; + const char * errmsg; + switch (info->ts_cmd_type){ case (CREATE_TABLESPACE): { + error= ER_CREATE_TABLESPACE_FAILED; + NdbDictionary::Tablespace ndb_ts; NdbDictionary::Datafile ndb_df; if (set_up_tablespace(info, &ndb_ts)) @@ -8381,23 +8378,24 @@ int ha_ndbcluster::alter_tablespace(st_alter_tablespace *info) { DBUG_RETURN(1); } - if (error= dict->createTablespace(ndb_ts)) + errmsg= "TABLESPACE"; + if (dict->createTablespace(ndb_ts)) { DBUG_PRINT("error", ("createTablespace returned %d", error)); - my_error(ER_CREATE_TABLESPACE_FAILED, MYF(0), "TABLESPACE"); - DBUG_RETURN(1); + goto ndberror; } DBUG_PRINT("info", ("Successfully created Tablespace")); - if (error= dict->createDatafile(ndb_df)) + errmsg= "DATAFILE"; + if (dict->createDatafile(ndb_df)) { DBUG_PRINT("error", ("createDatafile returned %d", error)); - my_error(ER_CREATE_TABLESPACE_FAILED, MYF(0), "DATAFILE"); - DBUG_RETURN(1); + goto ndberror; } break; } case (ALTER_TABLESPACE): { + error= ER_ALTER_TABLESPACE_FAILED; if (info->ts_alter_tablespace_type == ALTER_TABLESPACE_ADD_FILE) { NdbDictionary::Datafile ndb_df; @@ -8405,11 +8403,10 @@ int ha_ndbcluster::alter_tablespace(st_alter_tablespace *info) { DBUG_RETURN(1); } - if (error= dict->createDatafile(ndb_df)) + errmsg= " CREATE DATAFILE"; + if (dict->createDatafile(ndb_df)) { - DBUG_PRINT("error", ("createDatafile returned %d", error)); - my_error(ER_ALTER_TABLESPACE_FAILED, MYF(0), "CREATE DATAFILE"); - DBUG_RETURN(1); + goto ndberror; } } else if(info->ts_alter_tablespace_type == ALTER_TABLESPACE_DROP_FILE) @@ -8418,11 +8415,10 @@ int ha_ndbcluster::alter_tablespace(st_alter_tablespace *info) info->data_file_name); if (strcmp(df.getPath(), info->data_file_name) == 0) { - if (error= dict->dropDatafile(df)) + errmsg= " DROP DATAFILE"; + if (dict->dropDatafile(df)) { - DBUG_PRINT("error", ("createDatafile returned %d", error)); - my_error(ER_ALTER_TABLESPACE_FAILED, MYF(0), " DROP DATAFILE"); - DBUG_RETURN(1); + goto ndberror; } } else @@ -8442,6 +8438,7 @@ int ha_ndbcluster::alter_tablespace(st_alter_tablespace *info) } case (CREATE_LOGFILE_GROUP): { + error= ER_CREATE_TABLESPACE_FAILED; NdbDictionary::LogfileGroup ndb_lg; NdbDictionary::Undofile ndb_uf; if (info->undo_file_name == NULL) @@ -8455,27 +8452,26 @@ int ha_ndbcluster::alter_tablespace(st_alter_tablespace *info) { DBUG_RETURN(1); } - if (error= dict->createLogfileGroup(ndb_lg)) + errmsg= "LOGFILE GROUP"; + if (dict->createLogfileGroup(ndb_lg)) { - DBUG_PRINT("error", ("createLogfileGroup returned %d", error)); - my_error(ER_CREATE_TABLESPACE_FAILED, MYF(0), "LOGFILE GROUP"); - DBUG_RETURN(1); + goto ndberror; } DBUG_PRINT("info", ("Successfully created Logfile Group")); if (set_up_undofile(info, &ndb_uf)) { DBUG_RETURN(1); } - if (error= dict->createUndofile(ndb_uf)) + errmsg= "UNDOFILE"; + if (dict->createUndofile(ndb_uf)) { - DBUG_PRINT("error", ("createUndofile returned %d", error)); - my_error(ER_CREATE_TABLESPACE_FAILED, MYF(0), "UNDOFILE"); - DBUG_RETURN(1); + goto ndberror; } break; } case (ALTER_LOGFILE_GROUP): { + error= ER_ALTER_TABLESPACE_FAILED; if (info->undo_file_name == NULL) { /* @@ -8488,32 +8484,30 @@ int ha_ndbcluster::alter_tablespace(st_alter_tablespace *info) { DBUG_RETURN(1); } - if (error= dict->createUndofile(ndb_uf)) + errmsg= "CREATE UNDOFILE"; + if (dict->createUndofile(ndb_uf)) { - DBUG_PRINT("error", ("createUndofile returned %d", error)); - my_error(ER_ALTER_TABLESPACE_FAILED, MYF(0), "CREATE UNDOFILE"); - DBUG_RETURN(1); + goto ndberror; } break; } case (DROP_TABLESPACE): { - if (error= dict->dropTablespace( - dict->getTablespace(info->tablespace_name))) + error= ER_DROP_TABLESPACE_FAILED; + errmsg= "TABLESPACE"; + if (dict->dropTablespace(dict->getTablespace(info->tablespace_name))) { - DBUG_PRINT("error", ("dropTablespace returned %d", error)); - my_error(ER_DROP_TABLESPACE_FAILED, MYF(0), "TABLESPACE"); - DBUG_RETURN(1); + goto ndberror; } break; } case (DROP_LOGFILE_GROUP): { - if (error= dict->dropLogfileGroup(dict->getLogfileGroup(info->logfile_group_name))) + error= ER_DROP_TABLESPACE_FAILED; + errmsg= "LOGFILE GROUP"; + if (dict->dropLogfileGroup(dict->getLogfileGroup(info->logfile_group_name))) { - DBUG_PRINT("error", ("dropLogfileGroup returned %d", error)); - my_error(ER_DROP_TABLESPACE_FAILED, MYF(0), "LOGFILE GROUP"); - DBUG_RETURN(1); + goto ndberror; } break; } @@ -8531,6 +8525,13 @@ int ha_ndbcluster::alter_tablespace(st_alter_tablespace *info) } } DBUG_RETURN(FALSE); + +ndberror: + const NdbError err= dict->getNdbError(); + ERR_PRINT(err); + ndb_to_mysql_error(&err); + + my_error(error, MYF(0), errmsg); + DBUG_RETURN(1); } -#endif /* NDB_DISKDATA */ diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 01d14786600..f05c1c32a1a 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -511,6 +511,7 @@ class ha_ndbcluster: public handler bool eq_range, bool sorted, byte* buf); int read_range_next(); + int alter_tablespace(st_alter_tablespace *info); /** * Multi range stuff diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index ce483bb5c57..d7549c1a95b 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -96,6 +96,7 @@ handlerton partition_hton = { NULL, /* Start Consistent Snapshot */ NULL, /* Flush logs */ NULL, /* Show status */ + NULL, /* Alter Tablespace */ HTON_NOT_USER_SELECTABLE | HTON_HIDDEN }; diff --git a/sql/handler.h b/sql/handler.h index 36449fb1307..f6680679a35 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -315,6 +315,82 @@ typedef struct xid_t XID; #define MAX_XID_LIST_SIZE (1024*128) #endif +/* + These structures are used to pass information from a set of SQL commands + on add/drop/change tablespace definitions to the proper hton. +*/ +#define UNDEF_NODEGROUP 65535 +enum ts_command_type +{ + TS_CMD_NOT_DEFINED = -1, + CREATE_TABLESPACE = 0, + ALTER_TABLESPACE = 1, + CREATE_LOGFILE_GROUP = 2, + ALTER_LOGFILE_GROUP = 3, + DROP_TABLESPACE = 4, + DROP_LOGFILE_GROUP = 5, + CHANGE_FILE_TABLESPACE = 6, + ALTER_ACCESS_MODE_TABLESPACE = 7 +}; + +enum ts_alter_tablespace_type +{ + TS_ALTER_TABLESPACE_TYPE_NOT_DEFINED = -1, + ALTER_TABLESPACE_ADD_FILE = 1, + ALTER_TABLESPACE_DROP_FILE = 2 +}; + +enum tablespace_access_mode +{ + TS_NOT_DEFINED= -1, + TS_READ_ONLY = 0, + TS_READ_WRITE = 1, + TS_NOT_ACCESSIBLE = 2 +}; + +class st_alter_tablespace : public Sql_alloc +{ + public: + const char *tablespace_name; + const char *logfile_group_name; + enum ts_command_type ts_cmd_type; + enum ts_alter_tablespace_type ts_alter_tablespace_type; + const char *data_file_name; + const char *undo_file_name; + const char *redo_file_name; + ulonglong extent_size; + ulonglong undo_buffer_size; + ulonglong redo_buffer_size; + ulonglong initial_size; + ulonglong autoextend_size; + ulonglong max_size; + uint nodegroup_id; + enum legacy_db_type storage_engine; + bool wait_until_completed; + const char *ts_comment; + enum tablespace_access_mode ts_access_mode; + st_alter_tablespace() + { + tablespace_name= NULL; + logfile_group_name= "DEFAULT_LG"; //Default log file group + ts_cmd_type= TS_CMD_NOT_DEFINED; + data_file_name= NULL; + undo_file_name= NULL; + redo_file_name= NULL; + extent_size= 1024*1024; //Default 1 MByte + undo_buffer_size= 8*1024*1024; //Default 8 MByte + redo_buffer_size= 8*1024*1024; //Default 8 MByte + initial_size= 128*1024*1024; //Default 128 MByte + autoextend_size= 0; //No autoextension as default + max_size= 0; //Max size == initial size => no extension + storage_engine= DB_TYPE_UNKNOWN; + nodegroup_id= UNDEF_NODEGROUP; + wait_until_completed= TRUE; + ts_comment= NULL; + ts_access_mode= TS_NOT_DEFINED; + } +}; + /* The handler for a table type. Will be included in the TABLE structure */ struct st_table; @@ -434,6 +510,7 @@ typedef struct int (*start_consistent_snapshot)(THD *thd); bool (*flush_logs)(); bool (*show_status)(THD *thd, stat_print_fn *print, enum ha_stat_type stat); + int (*alter_tablespace)(THD *thd, st_alter_tablespace *ts_info); uint32 flags; /* global handler flags */ } handlerton; @@ -732,7 +809,7 @@ typedef struct st_ha_create_information { CHARSET_INFO *table_charset, *default_table_charset; LEX_STRING connect_string; - const char *comment,*password; + const char *comment,*password, *tablespace; const char *data_file_name, *index_file_name; const char *alias; ulonglong max_rows,min_rows; @@ -752,6 +829,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 */ } HA_CREATE_INFO; @@ -830,7 +908,6 @@ typedef struct st_handler_buffer byte *end_of_used_area; /* End of area that was used by handler */ } HANDLER_BUFFER; - class handler :public Sql_alloc { #ifdef WITH_PARTITION_STORAGE_ENGINE diff --git a/sql/lex.h b/sql/lex.h index ad78b86a4c4..29c693c2c74 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -59,6 +59,7 @@ static SYMBOL symbols[] = { { "<<", SYM(SHIFT_LEFT)}, { ">>", SYM(SHIFT_RIGHT)}, { "<=>", SYM(EQUAL_SYM)}, + { "ACCESSIBLE", SYM(ACCESSIBLE_SYM)}, { "ACTION", SYM(ACTION)}, { "ADD", SYM(ADD)}, { "AFTER", SYM(AFTER_SYM)}, @@ -77,6 +78,7 @@ static SYMBOL symbols[] = { { "AT", SYM(AT_SYM)}, { "AUTHORS", SYM(AUTHORS_SYM)}, { "AUTO_INCREMENT", SYM(AUTO_INC)}, + { "AUTOEXTEND_SIZE", SYM(AUTOEXTEND_SIZE_SYM)}, { "AVG", SYM(AVG_SYM)}, { "AVG_ROW_LENGTH", SYM(AVG_ROW_LENGTH)}, { "BACKUP", SYM(BACKUP_SYM)}, @@ -143,6 +145,7 @@ static SYMBOL symbols[] = { { "DATA", SYM(DATA_SYM)}, { "DATABASE", SYM(DATABASE)}, { "DATABASES", SYM(DATABASES)}, + { "DATAFILE", SYM(DATAFILE_SYM)}, { "DATE", SYM(DATE_SYM)}, { "DATETIME", SYM(DATETIME)}, { "DAY", SYM(DAY_SYM)}, @@ -167,6 +170,7 @@ static SYMBOL symbols[] = { { "DISABLE", SYM(DISABLE_SYM)}, { "DISABLED", SYM(DISABLED_SYM)}, { "DISCARD", SYM(DISCARD)}, + { "DISK", SYM(DISK_SYM)}, { "DISTINCT", SYM(DISTINCT)}, { "DISTINCTROW", SYM(DISTINCT)}, /* Access likes this */ { "DIV", SYM(DIV_SYM)}, @@ -200,6 +204,7 @@ static SYMBOL symbols[] = { { "EXPANSION", SYM(EXPANSION_SYM)}, { "EXPLAIN", SYM(DESCRIBE)}, { "EXTENDED", SYM(EXTENDED_SYM)}, + { "EXTENT_SIZE", SYM(EXTENT_SIZE_SYM)}, { "FALSE", SYM(FALSE_SYM)}, { "FAST", SYM(FAST_SYM)}, { "FETCH", SYM(FETCH_SYM)}, @@ -248,6 +253,7 @@ static SYMBOL symbols[] = { { "INDEX", SYM(INDEX_SYM)}, { "INDEXES", SYM(INDEXES)}, { "INFILE", SYM(INFILE)}, + { "INITIAL_SIZE", SYM(INITIAL_SIZE_SYM)}, { "INNER", SYM(INNER_SYM)}, { "INNOBASE", SYM(INNOBASE_SYM)}, { "INNODB", SYM(INNOBASE_SYM)}, @@ -299,6 +305,7 @@ static SYMBOL symbols[] = { { "LOCALTIMESTAMP", SYM(NOW_SYM)}, { "LOCK", SYM(LOCK_SYM)}, { "LOCKS", SYM(LOCKS_SYM)}, + { "LOGFILE", SYM(LOGFILE_SYM)}, { "LOGS", SYM(LOGS_SYM)}, { "LONG", SYM(LONG_SYM)}, { "LONGBLOB", SYM(LONGBLOB)}, @@ -324,6 +331,7 @@ static SYMBOL symbols[] = { { "MAX_CONNECTIONS_PER_HOUR", SYM(MAX_CONNECTIONS_PER_HOUR)}, { "MAX_QUERIES_PER_HOUR", SYM(MAX_QUERIES_PER_HOUR)}, { "MAX_ROWS", SYM(MAX_ROWS)}, + { "MAX_SIZE", SYM(MAX_SIZE_SYM)}, { "MAX_UPDATES_PER_HOUR", SYM(MAX_UPDATES_PER_HOUR)}, { "MAX_USER_CONNECTIONS", SYM(MAX_USER_CONNECTIONS_SYM)}, { "MAXVALUE", SYM(MAX_VALUE_SYM)}, @@ -331,6 +339,7 @@ static SYMBOL symbols[] = { { "MEDIUMBLOB", SYM(MEDIUMBLOB)}, { "MEDIUMINT", SYM(MEDIUMINT)}, { "MEDIUMTEXT", SYM(MEDIUMTEXT)}, + { "MEMORY", SYM(MEMORY_SYM)}, { "MERGE", SYM(MERGE_SYM)}, { "MICROSECOND", SYM(MICROSECOND_SYM)}, { "MIDDLEINT", SYM(MEDIUMINT)}, /* For powerbuilder */ @@ -358,7 +367,8 @@ static SYMBOL symbols[] = { { "NEW", SYM(NEW_SYM)}, { "NEXT", SYM(NEXT_SYM)}, { "NO", SYM(NO_SYM)}, - { "NODEGROUP", SYM(NODEGROUP_SYM)}, + { "NO_WAIT", SYM(NO_WAIT_SYM)}, + { "NODEGROUP", SYM(NODEGROUP_SYM)}, { "NONE", SYM(NONE_SYM)}, { "NOT", SYM(NOT_SYM)}, { "NO_WRITE_TO_BINLOG", SYM(NO_WRITE_TO_BINLOG)}, @@ -408,9 +418,13 @@ static SYMBOL symbols[] = { { "RAID_TYPE", SYM(RAID_TYPE)}, { "RANGE", SYM(RANGE_SYM)}, { "READ", SYM(READ_SYM)}, + { "READ_ONLY", SYM(READ_ONLY_SYM)}, + { "READ_WRITE", SYM(READ_WRITE_SYM)}, { "READS", SYM(READS_SYM)}, { "REAL", SYM(REAL)}, { "RECOVER", SYM(RECOVER_SYM)}, + { "REDO_BUFFER_SIZE", SYM(REDO_BUFFER_SIZE_SYM)}, + { "REDOFILE", SYM(REDOFILE_SYM)}, { "REDUNDANT", SYM(REDUNDANT_SYM)}, { "REFERENCES", SYM(REFERENCES)}, { "REGEXP", SYM(REGEXP)}, @@ -532,6 +546,8 @@ static SYMBOL symbols[] = { { "TYPES", SYM(TYPES_SYM)}, { "UNCOMMITTED", SYM(UNCOMMITTED_SYM)}, { "UNDEFINED", SYM(UNDEFINED_SYM)}, + { "UNDO_BUFFER_SIZE", SYM(UNDO_BUFFER_SIZE_SYM)}, + { "UNDOFILE", SYM(UNDOFILE_SYM)}, { "UNDO", SYM(UNDO_SYM)}, { "UNICODE", SYM(UNICODE_SYM)}, { "UNION", SYM(UNION_SYM)}, @@ -558,6 +574,7 @@ static SYMBOL symbols[] = { { "VARCHARACTER", SYM(VARCHAR)}, { "VARIABLES", SYM(VARIABLES)}, { "VARYING", SYM(VARYING)}, + { "WAIT", SYM(WAIT_SYM)}, { "WARNINGS", SYM(WARNINGS)}, { "WEEK", SYM(WEEK_SYM)}, { "WHEN", SYM(WHEN_SYM)}, diff --git a/sql/log.cc b/sql/log.cc index 45ce7776d1a..fe95419fffd 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -88,6 +88,7 @@ handlerton binlog_hton = { NULL, /* Start Consistent Snapshot */ NULL, /* Flush logs */ NULL, /* Show status */ + NULL, /* Alter Tablespace */ HTON_NOT_USER_SELECTABLE | HTON_HIDDEN }; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index ffee875a7e9..b3bc49b31d1 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -691,6 +691,7 @@ TABLE *create_virtual_tmp_table(THD *thd, List<create_field> &field_list); bool mysql_xa_recover(THD *thd); bool check_simple_select(); +int mysql_alter_tablespace(THD* thd, st_alter_tablespace *ts_info); SORT_FIELD * make_unireg_sortorder(ORDER *order, uint *length); int setup_order(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 6065ae7c04f..7f76686f953 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5727,41 +5727,23 @@ ER_WRONG_VALUE eng "Incorrect %-.32s value: '%-.128s'" ER_NO_PARTITION_FOR_GIVEN_VALUE eng "Table has no partition for value %ld" +ER_TABLESPACE_OPTION_ONLY_ONCE + eng "It is not allowed to specify %s more than once" +ER_CREATE_TABLESPACE_FAILED + eng "Failed to create %s" +ER_DROP_TABLESPACE_FAILED + eng "Failed to drop %s" +ER_TABLESPACE_AUTO_EXTEND_ERROR + eng "The handler doesn't support autoextend of tablespaces" +ER_WRONG_SIZE_NUMBER + eng "A size parameter was incorrectly specified, either number or on the form 10M" +ER_SIZE_OVERFLOW_ERROR + eng "The size number was correct but we don't allow the digit part to be more than 2 billion" +ER_ALTER_TABLESPACE_FAILED + eng "Failed to alter: %s" ER_BINLOG_ROW_LOGGING_FAILED eng "Writing one row to the row-based binary log failed" ER_BINLOG_ROW_WRONG_TABLE_DEF eng "Table definition on master and slave does not match" ER_BINLOG_ROW_RBR_TO_SBR eng "Slave running with --log-slave-updates must use row-based binary logging to be able to replicate row-based binary log events" -ER_EVENT_ALREADY_EXISTS - eng "Event '%-.64s' already exists" -ER_EVENT_STORE_FAILED - eng "Failed to store event %s. Error code %d from storage engine." -ER_EVENT_DOES_NOT_EXIST - eng "Unknown event '%-.64s'" -ER_EVENT_CANT_ALTER - eng "Failed to alter event '%-.64s'" -ER_EVENT_DROP_FAILED - eng "Failed to drop %s" -ER_EVENT_INTERVAL_NOT_POSITIVE - eng "INTERVAL must be positive" -ER_EVENT_ENDS_BEFORE_STARTS - eng "ENDS must be after STARTS" -ER_EVENT_EXEC_TIME_IN_THE_PAST - eng "Activation (AT) time is in the past" -ER_EVENT_OPEN_TABLE_FAILED - eng "Failed to open mysql.event" -ER_EVENT_NEITHER_M_EXPR_NOR_M_AT - eng "No datetime expression provided" -ER_EVENT_COL_COUNT_DOESNT_MATCH - eng "Column count of %s.%s is wrong. Table probably corrupted" -ER_EVENT_CANNOT_LOAD_FROM_TABLE - eng "Cannot load from mysql.event. Table probably corrupted" -ER_EVENT_CANNOT_DELETE - eng "Failed to delete the event from mysql.event" -ER_EVENT_COMPILE_ERROR - eng "Error during compilation of event's body" -ER_EVENT_SAME_NAME - eng "Same old and new event name" -ER_EVENT_DATA_TOO_LONG - eng "Data for column '%s' too long" diff --git a/sql/sql_lex.h b/sql/sql_lex.h index f250ce9ac32..669cb7f8d47 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -25,6 +25,7 @@ class sp_head; class sp_name; class sp_instr; class sp_pcontext; +class st_alter_tablespace; class partition_info; class event_timed; @@ -93,6 +94,7 @@ enum enum_sql_command { SQLCOM_XA_START, SQLCOM_XA_END, SQLCOM_XA_PREPARE, SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER, SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE, + SQLCOM_ALTER_TABLESPACE, SQLCOM_INSTALL_PLUGIN, SQLCOM_UNINSTALL_PLUGIN, SQLCOM_SHOW_AUTHORS, SQLCOM_BINLOG_BASE64_EVENT, SQLCOM_SHOW_PLUGINS, @@ -960,6 +962,12 @@ typedef struct st_lex during replication ("LOCAL 'filename' REPLACE INTO" part). */ const uchar *fname_start, *fname_end; + + /* + Reference to a struct that contains information in various commands + to add/create/drop/change table spaces. + */ + st_alter_tablespace *alter_tablespace_info; bool escape_used; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 3302a30b558..cb115adaffb 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4877,6 +4877,12 @@ end_with_restore_list: case SQLCOM_XA_RECOVER: res= mysql_xa_recover(thd); break; + case SQLCOM_ALTER_TABLESPACE: + if (check_access(thd, ALTER_ACL, thd->db, 0, 1, 0, thd->db ? is_schema_db(thd->db) : 0)) + break; + if (!(res= mysql_alter_tablespace(thd, lex->alter_tablespace_info))) + send_ok(thd); + break; case SQLCOM_INSTALL_PLUGIN: if (! (res= mysql_install_plugin(thd, &thd->lex->comment, &thd->lex->ident))) diff --git a/sql/sql_tablespace.cc b/sql/sql_tablespace.cc new file mode 100644 index 00000000000..0c99180365e --- /dev/null +++ b/sql/sql_tablespace.cc @@ -0,0 +1,50 @@ +/* Copyright (C) 2000-2004 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* drop and alter of tablespaces */ + +#include "mysql_priv.h" + +int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info) +{ + int error= HA_ADMIN_NOT_IMPLEMENTED; + handlerton *hton; + + DBUG_ENTER("mysql_alter_tablespace"); + /* + If the user haven't defined an engine, this will fallback to using the + default storage engine. + */ + hton= ha_resolve_by_legacy_type(thd, ts_info->storage_engine); + + if (hton->alter_tablespace && (error= hton->alter_tablespace(thd, ts_info))) + { + if (error == HA_ADMIN_NOT_IMPLEMENTED) + { + my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), ""); + } + else if (error == 1) + { + DBUG_RETURN(1); + } + else + { + my_error(error, MYF(0)); + } + DBUG_RETURN(error); + } + DBUG_RETURN(FALSE); +} diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index dd5355200d1..cb377e97f52 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -121,6 +121,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token END_OF_INPUT %token ABORT_SYM +%token ACCESSIBLE_SYM %token ACTION %token ADD %token ADDDATE_SYM @@ -142,6 +143,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token ATAN %token AUTHORS_SYM %token AUTO_INC +%token AUTOEXTEND_SIZE_SYM %token AVG_ROW_LENGTH %token AVG_SYM %token BACKUP_SYM @@ -212,6 +214,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token CURTIME %token DATABASE %token DATABASES +%token DATAFILE_SYM %token DATA_SYM %token DATETIME %token DATE_ADD_INTERVAL @@ -242,6 +245,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token DISABLE_SYM %token DISABLED_SYM %token DISCARD +%token DISK_SYM %token DISTINCT %token DIV_SYM %token DOUBLE_SYM @@ -278,6 +282,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token EXPANSION_SYM %token EXPORT_SET %token EXTENDED_SYM +%token EXTENT_SIZE_SYM %token EXTRACT_SYM %token FALSE_SYM %token FAST_SYM @@ -340,6 +345,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token INDEXES %token INDEX_SYM %token INFILE +%token INITIAL_SIZE_SYM %token INNER_SYM %token INNOBASE_SYM %token INOUT_SYM @@ -386,6 +392,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token LOCATOR_SYM %token LOCKS_SYM %token LOCK_SYM +%token LOGFILE_SYM %token LOGS_SYM %token LOG_SYM %token LONGBLOB @@ -416,6 +423,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token MAX_CONNECTIONS_PER_HOUR %token MAX_QUERIES_PER_HOUR %token MAX_ROWS +%token MAX_SIZE_SYM %token MAX_SYM %token MAX_UPDATES_PER_HOUR %token MAX_USER_CONNECTIONS_SYM @@ -424,6 +432,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token MEDIUMINT %token MEDIUMTEXT %token MEDIUM_SYM +%token MEMORY_SYM %token MERGE_SYM %token MICROSECOND_SYM %token MIGRATE_SYM @@ -460,6 +469,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token NOT_SYM %token NOW_SYM %token NO_SYM +%token NO_WAIT_SYM %token NO_WRITE_TO_BINLOG %token NULL_SYM %token NUM @@ -516,9 +526,13 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token RAND %token RANGE_SYM %token READS_SYM +%token READ_ONLY_SYM %token READ_SYM +%token READ_WRITE_SYM %token REAL %token RECOVER_SYM +%token REDO_BUFFER_SIZE_SYM +%token REDOFILE_SYM %token REDUNDANT_SYM %token REFERENCES %token REGEXP @@ -642,6 +656,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token ULONGLONG_NUM %token UNCOMMITTED_SYM %token UNDEFINED_SYM +%token UNDO_BUFFER_SIZE_SYM +%token UNDOFILE_SYM %token UNDERSCORE_CHARSET %token UNDO_SYM %token UNICODE_SYM @@ -672,6 +688,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token VARIANCE_SYM %token VARYING %token VIEW_SYM +%token WAIT_SYM %token WARNINGS %token WEEK_SYM %token WHEN_SYM @@ -740,7 +757,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ulong_num raid_types merge_insert_types %type <ulonglong_number> - ulonglong_num + ulonglong_num size_number %type <longlong_number> part_bit_expr @@ -1307,18 +1324,6 @@ create: YYTHD->client_capabilities |= $<ulong_num>4; sp->restore_thd_mem_root(YYTHD); } - | CREATE - { - Lex->create_view_mode= VIEW_CREATE_NEW; - Lex->create_view_algorithm= VIEW_ALGORITHM_UNDEFINED; - Lex->create_view_suid= TRUE; - } - view_or_trigger - {} - | CREATE USER clear_privileges grant_list - { - Lex->sql_command = SQLCOM_CREATE_USER; - } | CREATE EVENT_SYM opt_if_not_exists sp_name /* BE CAREFUL when you add a new rule to update the block where @@ -1376,90 +1381,29 @@ create: */ Lex->sql_command= SQLCOM_CREATE_EVENT; } - ; - -ev_schedule_time: EVERY_SYM expr interval + | CREATE { - LEX *lex=Lex; - if (!lex->et_compile_phase) - { - switch (lex->et->init_interval(YYTHD , $2, $3)) { - case EVEX_PARSE_ERROR: - yyerror(ER(ER_SYNTAX_ERROR)); - YYABORT; - break; - case EVEX_BAD_PARAMS: - my_error(ER_EVENT_INTERVAL_NOT_POSITIVE, MYF(0)); - YYABORT; - break; - } - } - } - ev_starts - ev_ends - | AT_SYM expr - { - LEX *lex=Lex; - if (!lex->et_compile_phase) - { - switch (lex->et->init_execute_at(YYTHD, $2)) { - case EVEX_PARSE_ERROR: - yyerror(ER(ER_SYNTAX_ERROR)); - YYABORT; - break; - case EVEX_BAD_PARAMS: - my_error(ER_EVENT_EXEC_TIME_IN_THE_PAST, MYF(0)); - YYABORT; - break; - } - } - } - ; - -ev_status: /* empty */ {$<ulong_num>$= 0;} - | ENABLED_SYM - { - LEX *lex=Lex; - if (!lex->et_compile_phase) - lex->et->status= MYSQL_EVENT_ENABLED; - $<ulong_num>$= 1; - } - | DISABLED_SYM - { - LEX *lex=Lex; - - if (!lex->et_compile_phase) - lex->et->status= MYSQL_EVENT_DISABLED; - $<ulong_num>$= 1; + Lex->create_view_mode= VIEW_CREATE_NEW; + Lex->create_view_algorithm= VIEW_ALGORITHM_UNDEFINED; + Lex->create_view_suid= TRUE; + } + view_or_trigger + {} + | CREATE USER clear_privileges grant_list + { + Lex->sql_command = SQLCOM_CREATE_USER; } - ; -ev_starts: /* empty */ - | STARTS_SYM expr + | CREATE LOGFILE_SYM GROUP logfile_group_info { LEX *lex= Lex; - if (!lex->et_compile_phase) - lex->et->init_starts(YYTHD, $2); + lex->alter_tablespace_info->ts_cmd_type= CREATE_LOGFILE_GROUP; } - ; -ev_ends: /* empty */ - | ENDS_SYM expr + | CREATE TABLESPACE tablespace_info { LEX *lex= Lex; - if (!lex->et_compile_phase) - { - switch (lex->et->init_ends(YYTHD, $2)) { - case EVEX_PARSE_ERROR: - yyerror(ER(ER_SYNTAX_ERROR)); - YYABORT; - break; - case EVEX_BAD_PARAMS: - my_error(ER_EVENT_ENDS_BEFORE_STARTS, MYF(0)); - YYABORT; - break; - } - } + lex->alter_tablespace_info->ts_cmd_type= CREATE_TABLESPACE; } - ; + ; ev_on_completion: /* empty */ {$<ulong_num>$= 0;} | ON COMPLETION_SYM PRESERVE_SYM { @@ -2849,6 +2793,382 @@ trg_event: | DELETE_SYM { Lex->trg_chistics.event= TRG_EVENT_DELETE; } ; +/* + This part of the parser contains common code for all TABLESPACE + commands. + CREATE TABLESPACE name ... + ALTER TABLESPACE name CHANGE DATAFILE ... + ALTER TABLESPACE name ADD DATAFILE ... + ALTER TABLESPACE name access_mode + CREATE LOGFILE GROUP name ... + ALTER LOGFILE GROUP name ADD UNDOFILE .. + ALTER LOGFILE GROUP name ADD REDOFILE .. + DROP TABLESPACE name + DROP LOGFILE GROUP name +*/ +change_tablespace_access: + tablespace_name + ts_access_mode + ; + +change_tablespace_info: + tablespace_name + CHANGE ts_datafile + change_ts_option_list + ; + +tablespace_info: + tablespace_name + ADD ts_datafile + opt_logfile_group_name + tablespace_option_list + ; + +opt_logfile_group_name: + /* empty */ {} + | USE_SYM LOGFILE_SYM GROUP ident + { + LEX *lex= Lex; + lex->alter_tablespace_info->logfile_group_name= $4.str; + }; + +alter_tablespace_info: + tablespace_name + ADD ts_datafile + alter_tablespace_option_list + { + Lex->alter_tablespace_info->ts_alter_tablespace_type= ALTER_TABLESPACE_ADD_FILE; + } + | + tablespace_name + DROP ts_datafile + alter_tablespace_option_list + { + Lex->alter_tablespace_info->ts_alter_tablespace_type= ALTER_TABLESPACE_DROP_FILE; + }; + +logfile_group_info: + logfile_group_name + add_log_file + logfile_group_option_list + ; + +alter_logfile_group_info: + logfile_group_name + add_log_file + alter_logfile_group_option_list + ; + +add_log_file: + ADD lg_undofile + | ADD lg_redofile + ; + +change_ts_option_list: + /* empty */ {} + change_ts_options + ; + +change_ts_options: + change_ts_option + | change_ts_options change_ts_option + | change_ts_options ',' change_ts_option + ; + +change_ts_option: + opt_ts_initial_size + | opt_ts_autoextend_size + | opt_ts_max_size + ; + +tablespace_option_list: + /* empty */ {} + tablespace_options + ; + +tablespace_options: + tablespace_option + | tablespace_options tablespace_option + | tablespace_options ',' tablespace_option + ; + +tablespace_option: + opt_ts_initial_size + | opt_ts_autoextend_size + | opt_ts_max_size + | opt_ts_extent_size + | opt_ts_nodegroup + | opt_ts_engine + | ts_wait + | opt_ts_comment + ; + +alter_tablespace_option_list: + /* empty */ {} + alter_tablespace_options + ; + +alter_tablespace_options: + alter_tablespace_option + | alter_tablespace_options alter_tablespace_option + | alter_tablespace_options ',' alter_tablespace_option + ; + +alter_tablespace_option: + opt_ts_initial_size + | opt_ts_autoextend_size + | opt_ts_max_size + | opt_ts_engine + | ts_wait + ; + +logfile_group_option_list: + /* empty */ {} + logfile_group_options + ; + +logfile_group_options: + logfile_group_option + | logfile_group_options logfile_group_option + | logfile_group_options ',' logfile_group_option + ; + +logfile_group_option: + opt_ts_initial_size + | opt_ts_undo_buffer_size + | opt_ts_redo_buffer_size + | opt_ts_nodegroup + | opt_ts_engine + | ts_wait + | opt_ts_comment + ; + +alter_logfile_group_option_list: + /* empty */ {} + alter_logfile_group_options + ; + +alter_logfile_group_options: + alter_logfile_group_option + | alter_logfile_group_options alter_logfile_group_option + | alter_logfile_group_options ',' alter_logfile_group_option + ; + +alter_logfile_group_option: + opt_ts_initial_size + | opt_ts_engine + | ts_wait + ; + + +ts_datafile: + DATAFILE_SYM TEXT_STRING_sys + { + LEX *lex= Lex; + lex->alter_tablespace_info->data_file_name= $2.str; + }; + +lg_undofile: + UNDOFILE_SYM TEXT_STRING_sys + { + LEX *lex= Lex; + lex->alter_tablespace_info->undo_file_name= $2.str; + }; + +lg_redofile: + REDOFILE_SYM TEXT_STRING_sys + { + LEX *lex= Lex; + lex->alter_tablespace_info->redo_file_name= $2.str; + }; + +tablespace_name: + ident + { + LEX *lex= Lex; + lex->alter_tablespace_info= new st_alter_tablespace(); + lex->alter_tablespace_info->tablespace_name= $1.str; + lex->sql_command= SQLCOM_ALTER_TABLESPACE; + }; + +logfile_group_name: + ident + { + LEX *lex= Lex; + lex->alter_tablespace_info= new st_alter_tablespace(); + lex->alter_tablespace_info->logfile_group_name= $1.str; + lex->sql_command= SQLCOM_ALTER_TABLESPACE; + }; + +ts_access_mode: + READ_ONLY_SYM + { + LEX *lex= Lex; + lex->alter_tablespace_info->ts_access_mode= TS_READ_ONLY; + } + | READ_WRITE_SYM + { + LEX *lex= Lex; + lex->alter_tablespace_info->ts_access_mode= TS_READ_WRITE; + } + | NOT_SYM ACCESSIBLE_SYM + { + LEX *lex= Lex; + lex->alter_tablespace_info->ts_access_mode= TS_NOT_ACCESSIBLE; + }; + +opt_ts_initial_size: + INITIAL_SIZE_SYM opt_equal size_number + { + LEX *lex= Lex; + lex->alter_tablespace_info->initial_size= $3; + }; + +opt_ts_autoextend_size: + AUTOEXTEND_SIZE_SYM opt_equal size_number + { + LEX *lex= Lex; + lex->alter_tablespace_info->autoextend_size= $3; + }; + +opt_ts_max_size: + MAX_SIZE_SYM opt_equal size_number + { + LEX *lex= Lex; + lex->alter_tablespace_info->max_size= $3; + }; + +opt_ts_extent_size: + EXTENT_SIZE_SYM opt_equal size_number + { + LEX *lex= Lex; + lex->alter_tablespace_info->extent_size= $3; + }; + +opt_ts_undo_buffer_size: + UNDO_BUFFER_SIZE_SYM opt_equal size_number + { + LEX *lex= Lex; + lex->alter_tablespace_info->undo_buffer_size= $3; + }; + +opt_ts_redo_buffer_size: + REDO_BUFFER_SIZE_SYM opt_equal size_number + { + LEX *lex= Lex; + lex->alter_tablespace_info->redo_buffer_size= $3; + }; + +opt_ts_nodegroup: + NODEGROUP_SYM opt_equal ulong_num + { + LEX *lex= Lex; + if (lex->alter_tablespace_info->nodegroup_id != UNDEF_NODEGROUP) + { + my_error(ER_TABLESPACE_OPTION_ONLY_ONCE,MYF(0),"NODEGROUP"); + YYABORT; + } + lex->alter_tablespace_info->nodegroup_id= $3; + }; + +opt_ts_comment: + COMMENT_SYM opt_equal TEXT_STRING_sys + { + LEX *lex= Lex; + if (lex->alter_tablespace_info->ts_comment != NULL) + { + my_error(ER_TABLESPACE_OPTION_ONLY_ONCE,MYF(0),"COMMENT"); + YYABORT; + } + lex->alter_tablespace_info->ts_comment= $3.str; + }; + +opt_ts_engine: + opt_storage ENGINE_SYM opt_equal storage_engines + { + LEX *lex= Lex; + if (lex->alter_tablespace_info->storage_engine != DB_TYPE_UNKNOWN) + { + my_error(ER_TABLESPACE_OPTION_ONLY_ONCE,MYF(0), + "STORAGE ENGINE"); + YYABORT; + } + lex->alter_tablespace_info->storage_engine= $4->db_type; + }; + +opt_ts_wait: + /* empty */ + | ts_wait + ; + +ts_wait: + WAIT_SYM + { + LEX *lex= Lex; + lex->alter_tablespace_info->wait_until_completed= TRUE; + } + | NO_WAIT_SYM + { + LEX *lex= Lex; + if (!(lex->alter_tablespace_info->wait_until_completed)) + { + my_error(ER_TABLESPACE_OPTION_ONLY_ONCE,MYF(0),"NO_WAIT"); + YYABORT; + } + lex->alter_tablespace_info->wait_until_completed= FALSE; + }; + +size_number: + ulong_num { $$= $1;} + | IDENT + { + ulonglong number, test_number; + uint text_shift_number= 0; + longlong prefix_number; + char *end_ptr; + char *start_ptr= $1.str; + uint str_len= strlen(start_ptr); + int error; + prefix_number= my_strtoll10(start_ptr, &end_ptr, &error); + if ((start_ptr + str_len - 1) == end_ptr) + { + switch (end_ptr[0]) + { + case 'g': + case 'G': + text_shift_number+=10; + case 'm': + case 'M': + text_shift_number+=10; + case 'k': + case 'K': + text_shift_number+=10; + break; + default: + { + my_error(ER_WRONG_SIZE_NUMBER, MYF(0)); + YYABORT; + } + } + if (prefix_number >> 31) + { + my_error(ER_SIZE_OVERFLOW_ERROR, MYF(0)); + YYABORT; + } + number= prefix_number << text_shift_number; + } + else + { + my_error(ER_WRONG_SIZE_NUMBER, MYF(0)); + YYABORT; + } + $$= number; + } + ; + +/* + End tablespace part +*/ create2: '(' create2a {} @@ -3507,6 +3827,9 @@ create_table_option: | INSERT_METHOD opt_equal merge_insert_types { Lex->create_info.merge_insert_method= $3; Lex->create_info.used_fields|= HA_CREATE_USED_INSERT_METHOD;} | 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;} | 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; } ; @@ -4326,8 +4649,28 @@ alter: YYABORT; } Lex->sql_command= SQLCOM_ALTER_EVENT; - } - ; + } + | ALTER TABLESPACE alter_tablespace_info + { + LEX *lex= Lex; + lex->alter_tablespace_info->ts_cmd_type= ALTER_TABLESPACE; + } + | ALTER LOGFILE_SYM GROUP alter_logfile_group_info + { + LEX *lex= Lex; + lex->alter_tablespace_info->ts_cmd_type= ALTER_LOGFILE_GROUP; + } + | ALTER TABLESPACE change_tablespace_info + { + LEX *lex= Lex; + lex->alter_tablespace_info->ts_cmd_type= CHANGE_FILE_TABLESPACE; + } + | ALTER TABLESPACE change_tablespace_access + { + LEX *lex= Lex; + lex->alter_tablespace_info->ts_cmd_type= ALTER_ACCESS_MODE_TABLESPACE; + } + ; ev_on_schedule: /* empty */ { $<ulong_num>$= 0;} | ON SCHEDULE_SYM ev_schedule_time @@ -4346,12 +4689,6 @@ ev_rename_to: /* empty */ { $<ulong_num>$= 0;} } ; -ev_opt_sql_stmt: /* empty*/ { $<ulong_num>$= 0;} - | DO_SYM ev_sql_stmt - { - $<ulong_num>$= 1; - } - ; ident_or_empty: /* empty */ { $$= 0; } @@ -7044,12 +7381,6 @@ drop: lex->sql_command= SQLCOM_DROP_VIEW; lex->drop_if_exists= $3; } - | DROP TRIGGER_SYM sp_name - { - LEX *lex= Lex; - lex->sql_command= SQLCOM_DROP_TRIGGER; - lex->spname= $3; - } | DROP EVENT_SYM if_exists sp_name { LEX *lex=Lex; @@ -7072,7 +7403,23 @@ drop: lex->sql_command = SQLCOM_DROP_EVENT; lex->drop_if_exists= $3; } - ; + | DROP TRIGGER_SYM sp_name + { + LEX *lex= Lex; + lex->sql_command= SQLCOM_DROP_TRIGGER; + lex->spname= $3; + } + | DROP TABLESPACE tablespace_name opt_ts_engine opt_ts_wait + { + LEX *lex= Lex; + lex->alter_tablespace_info->ts_cmd_type= DROP_TABLESPACE; + } + | DROP LOGFILE_SYM GROUP logfile_group_name opt_ts_engine opt_ts_wait + { + LEX *lex= Lex; + lex->alter_tablespace_info->ts_cmd_type= DROP_LOGFILE_GROUP; + } + ; table_list: table_name @@ -8529,6 +8876,12 @@ TEXT_STRING_literal: ident: IDENT_sys { $$=$1; } + | READ_ONLY_SYM + { + THD *thd= YYTHD; + $$.str= thd->strmake("read_only",9); + $$.length= 9; + } | keyword { THD *thd= YYTHD; @@ -8652,6 +9005,7 @@ keyword_sp: | ANY_SYM {} | AT_SYM {} | AUTO_INC {} + | AUTOEXTEND_SIZE_SYM {} | AVG_ROW_LENGTH {} | AVG_SYM {} | BERKELEY_DB_SYM {} @@ -8677,6 +9031,7 @@ keyword_sp: | CONSISTENT_SYM {} | CUBE_SYM {} | DATA_SYM {} + | DATAFILE_SYM {} | DATETIME {} | DATE_SYM {} | DAY_SYM {} @@ -8686,6 +9041,7 @@ keyword_sp: | DIRECTORY_SYM {} | DISABLED_SYM {} | DISCARD {} + | DISK_SYM {} | DUMPFILE {} | DUPLICATE_SYM {} | DYNAMIC_SYM {} @@ -8700,6 +9056,7 @@ keyword_sp: | EVERY_SYM {} | EXPANSION_SYM {} | EXTENDED_SYM {} + | EXTENT_SIZE_SYM {} | FAST_SYM {} | FOUND_SYM {} | DISABLE_SYM {} @@ -8722,6 +9079,7 @@ keyword_sp: | INVOKER_SYM {} | IMPORT {} | INDEXES {} + | INITIAL_SIZE_SYM {} | ISOLATION {} | ISSUER_SYM {} | INNOBASE_SYM {} @@ -8735,6 +9093,7 @@ keyword_sp: | LIST_SYM {} | LOCAL_SYM {} | LOCKS_SYM {} + | LOGFILE_SYM {} | LOGS_SYM {} | MAX_ROWS {} | MASTER_SYM {} @@ -8754,10 +9113,12 @@ keyword_sp: | MASTER_SSL_KEY_SYM {} | MAX_CONNECTIONS_PER_HOUR {} | MAX_QUERIES_PER_HOUR {} + | MAX_SIZE_SYM {} | MAX_UPDATES_PER_HOUR {} | MAX_USER_CONNECTIONS_SYM {} | MAX_VALUE_SYM {} | MEDIUM_SYM {} + | MEMORY_SYM {} | MERGE_SYM {} | MICROSECOND_SYM {} | MIGRATE_SYM {} @@ -8777,7 +9138,8 @@ keyword_sp: | NDBCLUSTER_SYM {} | NEXT_SYM {} | NEW_SYM {} - | NODEGROUP_SYM {} + | NO_WAIT_SYM {} + | NODEGROUP_SYM {} | NONE_SYM {} | NVARCHAR_SYM {} | OFFSET_SYM {} @@ -8805,6 +9167,8 @@ keyword_sp: | RAID_STRIPED_SYM {} | RAID_TYPE {} | RECOVER_SYM {} + | REDO_BUFFER_SIZE_SYM {} + | REDOFILE_SYM {} | REDUNDANT_SYM {} | RELAY_LOG_FILE_SYM {} | RELAY_LOG_POS_SYM {} @@ -8863,6 +9227,8 @@ keyword_sp: | FUNCTION_SYM {} | UNCOMMITTED_SYM {} | UNDEFINED_SYM {} + | UNDO_BUFFER_SIZE_SYM {} + | UNDOFILE_SYM {} | UNKNOWN_SYM {} | UNTIL_SYM {} | USER {} @@ -8871,6 +9237,7 @@ keyword_sp: | VIEW_SYM {} | VALUE_SYM {} | WARNINGS {} + | WAIT_SYM {} | WEEK_SYM {} | WORK_SYM {} | X509_SYM {} |