Commit 3cc18262 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#4676 get alter table truncate partition working on 5.5 refs[t:4676]

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@41588 c7de825b-a66e-492c-adef-691d508d4ae1
parent a21f7941
...@@ -6171,7 +6171,11 @@ get_row_type_for_key(DB *file) ...@@ -6171,7 +6171,11 @@ get_row_type_for_key(DB *file)
} }
enum row_type enum row_type
#if MYSQL_VERSION_ID >= 50521
ha_tokudb::get_row_type(void) const
#else
ha_tokudb::get_row_type(void) ha_tokudb::get_row_type(void)
#endif
{ {
return get_row_type_for_key(share->file); return get_row_type_for_key(share->file);
} }
...@@ -8108,8 +8112,7 @@ volatile int ha_tokudb_truncate_wait = 0; // debug ...@@ -8108,8 +8112,7 @@ volatile int ha_tokudb_truncate_wait = 0; // debug
int ha_tokudb::truncate() { int ha_tokudb::truncate() {
TOKUDB_DBUG_ENTER("truncate"); TOKUDB_DBUG_ENTER("truncate");
while (ha_tokudb_truncate_wait) sleep(1); // debug while (ha_tokudb_truncate_wait) sleep(1); // debug
int error = delete_all_rows_internal();
int error = delete_all_rows();
TOKUDB_DBUG_RETURN(error); TOKUDB_DBUG_RETURN(error);
} }
...@@ -8122,10 +8125,21 @@ int ha_tokudb::truncate() { ...@@ -8122,10 +8125,21 @@ int ha_tokudb::truncate() {
// locks: if we have an exclusive table write lock, all of the concurrency // locks: if we have an exclusive table write lock, all of the concurrency
// issues go away. // issues go away.
// returns: 0 if success // returns: 0 if success
int ha_tokudb::delete_all_rows() { int ha_tokudb::delete_all_rows() {
TOKUDB_DBUG_ENTER("delete_all_rows"); TOKUDB_DBUG_ENTER("delete_all_rows");
int error = 0; int error = 0;
if (thd_sql_command(ha_thd()) != SQLCOM_TRUNCATE) {
share->try_table_lock = true;
error = HA_ERR_WRONG_COMMAND;
}
if (error == 0)
error = delete_all_rows_internal();
TOKUDB_DBUG_RETURN(error);
}
int ha_tokudb::delete_all_rows_internal() {
TOKUDB_DBUG_ENTER("delete_all_rows_internal");
int error = 0;
uint curr_num_DBs = 0; uint curr_num_DBs = 0;
DB_TXN* txn = NULL; DB_TXN* txn = NULL;
...@@ -8135,12 +8149,6 @@ int ha_tokudb::delete_all_rows() { ...@@ -8135,12 +8149,6 @@ int ha_tokudb::delete_all_rows() {
error = db_env->txn_begin(db_env, 0, &txn, 0); error = db_env->txn_begin(db_env, 0, &txn, 0);
if (error) { goto cleanup; } if (error) { goto cleanup; }
if (thd_sql_command(ha_thd()) != SQLCOM_TRUNCATE) {
share->try_table_lock = true;
error = HA_ERR_WRONG_COMMAND;
goto cleanup;
}
curr_num_DBs = table->s->keys + test(hidden_primary_key); curr_num_DBs = table->s->keys + test(hidden_primary_key);
for (uint i = 0; i < curr_num_DBs; i++) { for (uint i = 0; i < curr_num_DBs; i++) {
error = share->key_file[i]->pre_acquire_fileops_lock( error = share->key_file[i]->pre_acquire_fileops_lock(
......
...@@ -657,7 +657,11 @@ class ha_tokudb : public handler { ...@@ -657,7 +657,11 @@ class ha_tokudb : public handler {
THD* thd THD* thd
); );
#if MYSQL_VERSION_ID >= 50521
enum row_type get_row_type() const;
#else
enum row_type get_row_type(); enum row_type get_row_type();
#endif
private: private:
int read_full_row(uchar * buf); int read_full_row(uchar * buf);
...@@ -665,6 +669,7 @@ class ha_tokudb : public handler { ...@@ -665,6 +669,7 @@ class ha_tokudb : public handler {
int get_next(uchar* buf, int direction); int get_next(uchar* buf, int direction);
int read_data_from_range_query_buff(uchar* buf, bool need_val); int read_data_from_range_query_buff(uchar* buf, bool need_val);
void invalidate_bulk_fetch(); void invalidate_bulk_fetch();
int delete_all_rows_internal();
}; };
int open_status_dictionary(DB** ptr, const char* name, DB_TXN* txn); int open_status_dictionary(DB** ptr, const char* name, DB_TXN* txn);
......
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