Commit 32b628f4 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

refs #5343 save frm data for partitioned tables in 5.5

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@46785 c7de825b-a66e-492c-adef-691d508d4ae1
parent 6322d300
...@@ -1226,6 +1226,7 @@ static int generate_row_for_put( ...@@ -1226,6 +1226,7 @@ static int generate_row_for_put(
ha_tokudb::ha_tokudb(handlerton * hton, TABLE_SHARE * table_arg):handler(hton, table_arg) ha_tokudb::ha_tokudb(handlerton * hton, TABLE_SHARE * table_arg):handler(hton, table_arg)
// flags defined in sql\handler.h // flags defined in sql\handler.h
{ {
share = NULL;
int_table_flags = HA_REC_NOT_IN_SEQ | HA_NULL_IN_KEY | HA_CAN_INDEX_BLOBS | HA_PRIMARY_KEY_IN_READ_INDEX | int_table_flags = HA_REC_NOT_IN_SEQ | HA_NULL_IN_KEY | HA_CAN_INDEX_BLOBS | HA_PRIMARY_KEY_IN_READ_INDEX |
HA_FILE_BASED | HA_AUTO_PART_KEY | HA_TABLE_SCAN_ON_INDEX | HA_CAN_WRITE_DURING_OPTIMIZE; HA_FILE_BASED | HA_AUTO_PART_KEY | HA_TABLE_SCAN_ON_INDEX | HA_CAN_WRITE_DURING_OPTIMIZE;
alloc_ptr = NULL; alloc_ptr = NULL;
...@@ -1686,7 +1687,7 @@ int ha_tokudb::initialize_share( ...@@ -1686,7 +1687,7 @@ int ha_tokudb::initialize_share(
// verify frm file is what we expect it to be // verify frm file is what we expect it to be
// only for tables that are not partitioned // only for tables that are not partitioned
// //
if (table->part_info == NULL) { if (TOKU_PARTITION_WRITE_FRM_DATA || table->part_info == NULL) {
error = verify_frm_data(table->s->path.str, txn); error = verify_frm_data(table->s->path.str, txn);
if (error) { if (error) {
goto exit; goto exit;
...@@ -2064,7 +2065,7 @@ cleanup: ...@@ -2064,7 +2065,7 @@ cleanup:
} }
int ha_tokudb::write_frm_data(DB* db, DB_TXN* txn, const char* frm_name) { int ha_tokudb::write_frm_data(DB* db, DB_TXN* txn, const char* frm_name) {
TOKUDB_DBUG_ENTER("ha_tokudb::write_frm_data, %s", frm_name); TOKUDB_DBUG_ENTER("ha_tokudb::write_frm_data %p %p %p %s", this, db, txn, frm_name);
uchar* frm_data = NULL; uchar* frm_data = NULL;
size_t frm_len = 0; size_t frm_len = 0;
...@@ -6723,7 +6724,7 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in ...@@ -6723,7 +6724,7 @@ int ha_tokudb::create(const char *name, TABLE * form, HA_CREATE_INFO * create_in
if (error) { goto cleanup; } if (error) { goto cleanup; }
// only for tables that are not partitioned // only for tables that are not partitioned
if (form->part_info == NULL) { if (TOKU_PARTITION_WRITE_FRM_DATA || form->part_info == NULL) {
error = write_frm_data(status_block, txn, form->s->path.str); error = write_frm_data(status_block, txn, form->s->path.str);
if (error) { goto cleanup; } if (error) { goto cleanup; }
} }
......
...@@ -529,6 +529,7 @@ public: ...@@ -529,6 +529,7 @@ public:
int alter_table_add_or_drop_column(TABLE *altered_table, Alter_inplace_info *ha_alter_info); int alter_table_add_or_drop_column(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
void print_alter_info(TABLE *altered_table, Alter_inplace_info *ha_alter_info); void print_alter_info(TABLE *altered_table, Alter_inplace_info *ha_alter_info);
public: public:
int create_handler_files(const char *name, const char *old_name, int action_flag, HA_CREATE_INFO *info);
#endif #endif
#if TOKU_INCLUDE_ALTER_55 #if TOKU_INCLUDE_ALTER_55
public: public:
......
...@@ -162,9 +162,12 @@ ha_tokudb::new_alter_table_frm_data(const uchar *frm_data, size_t frm_len) { ...@@ -162,9 +162,12 @@ ha_tokudb::new_alter_table_frm_data(const uchar *frm_data, size_t frm_len) {
TOKUDB_DBUG_ENTER("new_alter_table_path"); TOKUDB_DBUG_ENTER("new_alter_table_path");
int error = 0; int error = 0;
if (table->part_info == NULL) { if (TOKU_PARTITION_WRITE_FRM_DATA || table->part_info == NULL) {
// write frmdata to status // write frmdata to status
DB_TXN *txn = transaction; // use alter table transaction THD *thd = ha_thd();
tokudb_trx_data *trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
assert(trx);
DB_TXN *txn = trx->stmt; // use alter table transaction
assert(txn); assert(txn);
error = write_to_status(share->status_block, hatoku_frm_data, (void *)frm_data, (uint)frm_len, txn); error = write_to_status(share->status_block, hatoku_frm_data, (void *)frm_data, (uint)frm_len, txn);
} }
......
...@@ -495,15 +495,8 @@ ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info * ...@@ -495,15 +495,8 @@ ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *
bool result = false; // success bool result = false; // success
if (commit) { if (commit) {
if (altered_table->part_info == NULL) { if (TOKU_PARTITION_WRITE_FRM_DATA || altered_table->part_info == NULL) {
// read frm data for the altered table int error = write_frm_data(share->status_block, ctx->alter_txn, altered_table->s->path.str);
uchar *frm_data; size_t frm_len;
int error = readfrm(altered_table->s->path.str, &frm_data, &frm_len);
if (!error) {
// transactionally write frm data to status
error = write_to_status(share->status_block, hatoku_frm_data, (void *)frm_data, (uint)frm_len, ctx->alter_txn);
my_free(frm_data);
}
if (error) { if (error) {
commit = false; commit = false;
result = true; result = true;
...@@ -512,10 +505,6 @@ ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info * ...@@ -512,10 +505,6 @@ ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *
} }
} }
THD *thd = ha_thd();
tokudb_trx_data *trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
assert(trx->stmt == ctx->alter_txn);
if (!commit) { if (!commit) {
// abort the alter transaction NOW so that any alters are rolled back. this allows the following restores to work. // abort the alter transaction NOW so that any alters are rolled back. this allows the following restores to work.
THD *thd = ha_thd(); THD *thd = ha_thd();
...@@ -558,4 +547,19 @@ ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info * ...@@ -558,4 +547,19 @@ ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *
DBUG_RETURN(result); DBUG_RETURN(result);
} }
int
ha_tokudb::create_handler_files(const char *name, const char *old_name, int action_flag, HA_CREATE_INFO *info) {
TOKUDB_DBUG_ENTER("create_handler_files");
int error = 0;
if (action_flag == CHF_CREATE_FLAG) {
THD *thd = ha_thd();
tokudb_trx_data *trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
if (trx && trx->stmt && share) {
int error = write_frm_data(share->status_block, trx->stmt, name);
assert(error == 0);
}
}
DBUG_RETURN(error);
}
#endif #endif
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#define TOKU_INCLUDE_ALTER_55 1 #define TOKU_INCLUDE_ALTER_55 1
#define TOKU_INCLUDE_ROW_TYPE_COMPRESSION 1 #define TOKU_INCLUDE_ROW_TYPE_COMPRESSION 1
#define TOKU_INCLUDE_XA 1 #define TOKU_INCLUDE_XA 1
#define TOKU_PARTITION_WRITE_FRM_DATA 1
#endif #endif
#if 50100 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID < 50299 #if 50100 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID < 50299
......
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