summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorunknown <heikki@hundin.mysql.fi>2003-10-13 11:20:19 +0300
committerunknown <heikki@hundin.mysql.fi>2003-10-13 11:20:19 +0300
commitd212ba604b22f8fad80489319a7ddc09d126ba67 (patch)
tree5d5b7191e57ae4eafdff3f6a259ba37729217404 /sql/sql_table.cc
parent1862f671606e086c68228903abb64d9727f95b72 (diff)
downloadmariadb-git-d212ba604b22f8fad80489319a7ddc09d126ba67.tar.gz
Many files:
ALTER TABLE ... DISCARD/IMPORT TABLESPACE Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x sql/ha_innodb.cc: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/sql_class.cc: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/sql_parse.cc: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/sql_table.cc: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/ha_innodb.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/handler.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/lex.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/mysql_priv.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/sql_class.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/sql_lex.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE sql/sql_yacc.yy: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/ha/ha0ha.c: Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x innobase/ha/hash0hash.c: Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x innobase/buf/buf0buf.c: Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x innobase/buf/buf0flu.c: Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x innobase/buf/buf0lru.c: Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x innobase/buf/buf0rea.c: Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x innobase/btr/btr0btr.c: Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x innobase/btr/btr0sea.c: Track crash in buf_LRU_block_remove_hashed_page + 1807 reported in MySQL-3.23.5x innobase/fil/fil0fil.c: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/include/buf0buf.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/include/ha0ha.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/include/hash0hash.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/include/row0mysql.h: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/include/buf0buf.ic: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/include/ha0ha.ic: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/include/ibuf0ibuf.ic: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/page/page0page.c: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/row/row0mysql.c: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/row/row0purge.c: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/row/row0uins.c: ALTER TABLE ... DISCARD/IMPORT TABLESPACE innobase/row/row0umod.c: ALTER TABLE ... DISCARD/IMPORT TABLESPACE
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc77
1 files changed, 72 insertions, 5 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 16afd592e59..3840e29f04a 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1748,6 +1748,70 @@ int mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt)
&handler::check));
}
+/* table_list should contain just one table */
+int mysql_discard_or_import_tablespace(THD *thd,
+ TABLE_LIST *table_list,
+ enum tablespace_op_type tablespace_op)
+{
+ TABLE *table;
+ my_bool discard;
+ int error;
+ DBUG_ENTER("mysql_discard_or_import_tablespace");
+
+ /* Note that DISCARD/IMPORT TABLESPACE always is the only operation in an
+ ALTER TABLE */
+
+ thd->proc_info="discard_or_import_tablespace";
+
+ if (tablespace_op == DISCARD_TABLESPACE)
+ discard = TRUE;
+ else
+ discard = FALSE;
+
+ thd->tablespace_op=TRUE; /* we set this flag so that ha_innobase::open
+ and ::external_lock() do not complain when we
+ lock the table */
+ mysql_ha_closeall(thd, table_list);
+
+ if (!(table=open_ltable(thd,table_list,TL_WRITE)))
+ {
+ thd->tablespace_op=FALSE;
+ DBUG_RETURN(-1);
+ }
+
+ thd->tablespace_op=FALSE;
+
+ error=table->file->discard_or_import_tablespace(discard);
+
+ thd->proc_info="end";
+
+ if (error)
+ goto err;
+
+ /* The 0 in the call below means 'not in a transaction', which means
+ immediate invalidation; that is probably what we wish here */
+ query_cache_invalidate3(thd, table_list, 0);
+
+ /* The ALTER TABLE is always in its own transaction */
+ error = ha_commit_stmt(thd);
+ if (ha_commit(thd))
+ error=1;
+ if (error)
+ goto err;
+ mysql_update_log.write(thd, thd->query,thd->query_length);
+ if (mysql_bin_log.is_open())
+ {
+ Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
+ mysql_bin_log.write(&qinfo);
+ }
+err:
+ close_thread_tables(thd);
+ if (error == 0) {
+ send_ok(thd);
+ DBUG_RETURN(0);
+ }
+ DBUG_RETURN(error);
+}
int mysql_alter_table(THD *thd,char *new_db, char *new_name,
HA_CREATE_INFO *create_info,
@@ -1759,6 +1823,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
bool drop_primary,
enum enum_duplicates handle_duplicates,
enum enum_enable_or_disable keys_onoff,
+ enum tablespace_op_type tablespace_op,
bool simple_alter)
{
TABLE *table,*new_table;
@@ -1771,6 +1836,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
ulonglong next_insert_id;
uint save_time_stamp,db_create_options, used_fields;
enum db_type old_db_type,new_db_type;
+ thr_lock_type lock_type;
DBUG_ENTER("mysql_alter_table");
thd->proc_info="init";
@@ -1781,6 +1847,10 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
used_fields=create_info->used_fields;
mysql_ha_closeall(thd, table_list);
+
+ if (tablespace_op != NO_TABLESPACE_OP)
+ DBUG_RETURN(mysql_discard_or_import_tablespace(thd,table_list,
+ tablespace_op));
if (!(table=open_ltable(thd,table_list,TL_WRITE_ALLOW_READ)))
DBUG_RETURN(-1);
@@ -1834,8 +1904,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
if (create_info->row_type == ROW_TYPE_NOT_USED)
create_info->row_type=table->row_type;
- /* In some simple cases we need not to recreate the table */
-
thd->proc_info="setup";
if (simple_alter && !table->tmp_table)
{
@@ -1860,6 +1928,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
VOID(pthread_mutex_unlock(&LOCK_open));
}
+
if (!error)
{
switch (keys_onoff) {
@@ -2395,8 +2464,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
goto err;
}
}
-
- /* The ALTER TABLE is always in it's own transaction */
+ /* The ALTER TABLE is always in its own transaction */
error = ha_commit_stmt(thd);
if (ha_commit(thd))
error=1;
@@ -2695,4 +2763,3 @@ int mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt)
table->table=0;
DBUG_RETURN(-1);
}
-