Commit 451b3959 authored by Rich Prohaska's avatar Rich Prohaska

#104 write frm for existing tables before the txn is committed

parent b8418504
set default_storage_engine='tokudb';
drop table if exists t;
create table t (x int, y int, primary key (x));
alter table t drop primary key, add primary key(x);
drop table t;
set default_storage_engine='tokudb';
drop table if exists t;
create table t (x int, y int, primary key (x)) partition by hash(x) partitions 1;
alter table t drop primary key, add primary key(x);
drop table t;
set default_storage_engine='tokudb';
set tokudb_disable_hot_alter=1;
drop table if exists t;
create table t (x int, y int, primary key (x));
alter table t change column y newy int;
drop table t;
set default_storage_engine='tokudb';
set tokudb_disable_hot_alter=1;
drop table if exists t;
create table t (x int, y int, primary key (x)) partition by hash(x) partitions 2;
alter table t change column y newy int;
drop table t;
source include/have_tokudb.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t;
enable_warnings;
create table t (x int, y int, primary key (x));
alter table t drop primary key, add primary key(x);
drop table t;
source include/have_tokudb.inc;
source include/have_partition.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t;
enable_warnings;
create table t (x int, y int, primary key (x)) partition by hash(x) partitions 1;
alter table t drop primary key, add primary key(x);
drop table t;
source include/have_tokudb.inc;
set default_storage_engine='tokudb';
set tokudb_disable_hot_alter=1;
disable_warnings;
drop table if exists t;
enable_warnings;
create table t (x int, y int, primary key (x));
alter table t change column y newy int;
drop table t;
source include/have_tokudb.inc;
source include/have_partition.inc;
set default_storage_engine='tokudb';
set tokudb_disable_hot_alter=1;
disable_warnings;
drop table if exists t;
enable_warnings;
create table t (x int, y int, primary key (x)) partition by hash(x) partitions 2;
alter table t change column y newy int;
drop table t;
...@@ -681,10 +681,6 @@ public: ...@@ -681,10 +681,6 @@ public:
// Returns true of the 5.6 inplace alter table interface is used. // Returns true of the 5.6 inplace alter table interface is used.
bool try_hot_alter_table(); bool try_hot_alter_table();
// We need a txn in the mysql_alter_table function to write new frm data, so this function
// gets called to sometimes create one.
void prepare_for_alter();
// Used by the partition storage engine to provide new frm data for the table. // Used by the partition storage engine to provide new frm data for the table.
int new_alter_table_frm_data(const uchar *frm_data, size_t frm_len); int new_alter_table_frm_data(const uchar *frm_data, size_t frm_len);
#endif #endif
......
...@@ -98,29 +98,6 @@ bool ha_tokudb::try_hot_alter_table() { ...@@ -98,29 +98,6 @@ bool ha_tokudb::try_hot_alter_table() {
DBUG_RETURN(!disable_hot_alter); DBUG_RETURN(!disable_hot_alter);
} }
void ha_tokudb::prepare_for_alter() {
TOKUDB_DBUG_ENTER("prepare_for_alter");
// this is here because mysql commits the transaction before prepare_for_alter is called.
// we need a transaction to add indexes, drop indexes, and write the new frm data, so we
// create one. this transaction will be retired by mysql alter table when it commits
//
// if we remove the commit before prepare_for_alter, then this is not needed.
transaction = NULL;
THD *thd = ha_thd();
tokudb_trx_data *trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
assert(trx);
// for partitioned tables, a transaction may already exist,
// as we call prepare_for_alter on all partitions
if (!trx->sub_sp_level) {
int error = create_txn(thd, trx);
assert(error == 0);
assert(thd->in_sub_stmt == 0);
}
transaction = trx->sub_sp_level;
DBUG_VOID_RETURN;
}
int ha_tokudb::new_alter_table_frm_data(const uchar *frm_data, size_t frm_len) { int ha_tokudb::new_alter_table_frm_data(const uchar *frm_data, size_t frm_len) {
return write_frm_data(frm_data, frm_len); return write_frm_data(frm_data, frm_len);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment