Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-10-10 14:46:45+02:00, tomas@stripped +2 -0
ndb handler cleanup
- removal of m_active_trans
- replacing it with m_thd_ndb
- removal of usage of current_thd when possible
- removal of some unused helper functions
sql/ha_ndbcluster.cc@stripped, 2007-10-10 14:46:42+02:00, tomas@stripped +51
-70
ndb handler cleanup
- removal of m_active_trans
- replacing it with m_thd_ndb
- removal of usage of current_thd when possible
- removal of some unused helper functions
sql/ha_ndbcluster.h@stripped, 2007-10-10 14:46:42+02:00, tomas@stripped +1
-3
ndb handler cleanup
- removal of m_active_trans
- replacing it with m_thd_ndb
- removal of usage of current_thd when possible
- removal of some unused helper functions
diff -Nrup a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
--- a/sql/ha_ndbcluster.cc 2007-10-08 22:20:44 +02:00
+++ b/sql/ha_ndbcluster.cc 2007-10-10 14:46:42 +02:00
@@ -432,7 +432,7 @@ int execute_no_commit(ha_ndbcluster *h,
DBUG_ENTER("execute_no_commit");
h->release_completed_operations(trans, force_release);
const NdbOperation *first= trans->getFirstDefinedOperation();
- Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
+ Thd_ndb *thd_ndb= h->m_thd_ndb;
if (trans->execute(NdbTransaction::NoCommit,
NdbOperation::AO_IgnoreError,
h->m_force_send))
@@ -448,11 +448,10 @@ int execute_no_commit(ha_ndbcluster *h,
}
inline
-int execute_commit(NdbTransaction *trans, int force_send, int ignore_error)
+int execute_commit(Thd_ndb *thd_ndb, NdbTransaction *trans, int force_send, int
ignore_error)
{
DBUG_ENTER("execute_commit");
const NdbOperation *first= trans->getFirstDefinedOperation();
- Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
if (trans->execute(NdbTransaction::Commit,
NdbOperation::AO_IgnoreError,
force_send))
@@ -473,19 +472,6 @@ int execute_commit(NdbTransaction *trans
}
inline
-int execute_commit(ha_ndbcluster *h, NdbTransaction *trans)
-{
- int res= execute_commit(trans, h->m_force_send, h->m_ignore_no_key);
- return res;
-}
-
-inline
-int execute_commit(THD *thd, NdbTransaction *trans)
-{
- return execute_commit(trans, thd->variables.ndb_force_send, FALSE);
-}
-
-inline
int execute_no_commit_ie(ha_ndbcluster *h, NdbTransaction *trans,
bool force_release)
{
@@ -494,7 +480,7 @@ int execute_no_commit_ie(ha_ndbcluster *
int res= trans->execute(NdbTransaction::NoCommit,
NdbOperation::AO_IgnoreError,
h->m_force_send);
- Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
+ Thd_ndb *thd_ndb= h->m_thd_ndb;
thd_ndb->m_unsent_bytes= 0;
DBUG_RETURN(res);
}
@@ -2312,7 +2298,7 @@ static void shrink_varchar(Field* field,
int ha_ndbcluster::pk_read(const uchar *key, uint key_len, uchar *buf,
uint32 part_id)
{
- NdbConnection *trans= m_active_trans;
+ NdbConnection *trans= m_thd_ndb->trans;
NdbOperation *op;
uchar *row;
int res;
@@ -2365,7 +2351,7 @@ int ha_ndbcluster::pk_read(const uchar *
int ha_ndbcluster::complemented_read(const uchar *old_data, uchar *new_data,
uint32 old_part_id)
{
- NdbTransaction *trans= m_active_trans;
+ NdbTransaction *trans= m_thd_ndb->trans;
NdbOperation *op;
DBUG_ENTER("complemented_read");
@@ -2522,7 +2508,7 @@ static char dummy_row[1];
int ha_ndbcluster::peek_indexed_rows(const uchar *record,
bool check_pk)
{
- NdbTransaction *trans= m_active_trans;
+ NdbTransaction *trans= m_thd_ndb->trans;
NdbOperation *op;
const NdbOperation *first, *last;
uint i;
@@ -2623,7 +2609,7 @@ int ha_ndbcluster::peek_indexed_rows(con
int ha_ndbcluster::unique_index_read(const uchar *key,
uint key_len, uchar *buf)
{
- NdbTransaction *trans= m_active_trans;
+ NdbTransaction *trans= m_thd_ndb->trans;
NdbOperation *op;
uchar *row;
DBUG_ENTER("ha_ndbcluster::unique_index_read");
@@ -2704,7 +2690,7 @@ inline int ha_ndbcluster::fetch_next(Ndb
DBUG_ENTER("fetch_next");
int local_check;
int error;
- NdbTransaction *trans= m_active_trans;
+ NdbTransaction *trans= m_thd_ndb->trans;
if ((error= scan_handle_lock_tuple(cursor, trans)) != 0)
DBUG_RETURN(error);
@@ -2806,7 +2792,7 @@ inline int ha_ndbcluster::next_result(uc
}
else
{
- DBUG_RETURN(ndb_err(m_active_trans));
+ DBUG_RETURN(ndb_err(m_thd_ndb->trans));
}
}
@@ -2845,8 +2831,8 @@ ha_ndbcluster::pk_unique_index_read_key(
ndb_record= m_ndb_record_fragment;
}
}
- op= m_active_trans->readTuple(key_rec, (const char *)key,
- ndb_record, (char *)buf, lm, mask);
+ op= m_thd_ndb->trans->readTuple(key_rec, (const char *)key,
+ ndb_record, (char *)buf, lm, mask);
if (uses_blob_value(table->read_set) &&
get_blob_values(op, buf, table->read_set) != 0)
@@ -3135,7 +3121,7 @@ int ha_ndbcluster::ordered_index_scan(co
bool sorted, bool descending,
uchar* buf, part_id_range *part_spec)
{
- NdbTransaction *trans= m_active_trans;
+ NdbTransaction *trans= m_thd_ndb->trans;
NdbIndexScanOperation *op;
struct ordered_index_scan_data data;
uchar *mask;
@@ -3242,7 +3228,7 @@ int ha_ndbcluster::full_table_scan(const
uchar *buf)
{
NdbScanOperation *op;
- NdbTransaction *trans= m_active_trans;
+ NdbTransaction *trans= m_thd_ndb->trans;
part_id_range part_spec;
uchar *mask= (uchar *)(table->read_set->bitmap);
const NdbRecord *ndb_record= m_ndb_record;
@@ -3357,7 +3343,7 @@ int ha_ndbcluster::write_row(uchar *reco
{
DBUG_ENTER("ha_ndbcluster::write_row");
#ifdef HAVE_NDB_BINLOG
- if (m_share == ndb_apply_status_share && current_thd->slave_thread)
+ if (m_share == ndb_apply_status_share && table->in_use->slave_thread)
{
uint32 sid, master_server_id= active_mi->master_server_id;
memcpy(&sid, table->field[0]->ptr + (record - table->record[0]),
sizeof(sid));
@@ -3381,7 +3367,7 @@ int ha_ndbcluster::ndb_write_row(uchar *
bool batched_update)
{
bool has_auto_increment;
- NdbTransaction *trans= m_active_trans;
+ NdbTransaction *trans= m_thd_ndb->trans;
NdbOperation *op;
THD *thd= table->in_use;
Thd_ndb *thd_ndb= get_thd_ndb(thd);
@@ -3854,7 +3840,7 @@ int ha_ndbcluster::update_row(const ucha
{
THD *thd= table->in_use;
Thd_ndb *thd_ndb= get_thd_ndb(thd);
- NdbTransaction *trans= m_active_trans;
+ NdbTransaction *trans= m_thd_ndb->trans;
NdbScanOperation* cursor= m_active_cursor;
NdbOperation *op;
uint32 old_part_id= 0, new_part_id= 0;
@@ -3939,7 +3925,7 @@ int ha_ndbcluster::update_row(const ucha
// Undo delete_row(old_data)
undo_res= ndb_write_row((uchar *)old_data, TRUE, batched_update);
if (undo_res)
- push_warning(current_thd,
+ push_warning(thd,
MYSQL_ERROR::WARN_LEVEL_WARN,
undo_res,
"NDB failed undoing delete at primary key update");
@@ -4098,7 +4084,7 @@ int ha_ndbcluster::ndb_delete_row(const
{
THD *thd= table->in_use;
Thd_ndb *thd_ndb= get_thd_ndb(thd);
- NdbTransaction *trans= m_active_trans;
+ NdbTransaction *trans= m_thd_ndb->trans;
NdbScanOperation* cursor= m_active_cursor;
NdbOperation *op;
uint32 part_id;
@@ -4599,7 +4585,7 @@ int ha_ndbcluster::rnd_init(bool scan)
int ha_ndbcluster::close_scan()
{
- NdbTransaction *trans= m_active_trans;
+ NdbTransaction *trans= m_thd_ndb->trans;
int error;
DBUG_ENTER("close_scan");
@@ -4984,7 +4970,7 @@ int ha_ndbcluster::reset()
int
ha_ndbcluster::flush_bulk_insert()
{
- NdbTransaction *trans= m_active_trans;
+ NdbTransaction *trans= m_thd_ndb->trans;
DBUG_ENTER("ha_ndbcluster::flush_bulk_insert");
DBUG_PRINT("info", ("Sending inserts to NDB, rows_inserted: %d",
(int)m_rows_inserted));
@@ -4998,7 +4984,7 @@ ha_ndbcluster::flush_bulk_insert()
}
else
{
- if (execute_commit(this,trans) != 0)
+ if (execute_commit(m_thd_ndb, trans, m_force_send, m_ignore_no_key) != 0)
{
no_uncommitted_rows_execute_failure();
DBUG_RETURN(ndb_err(trans));
@@ -5051,8 +5037,8 @@ int ha_ndbcluster::end_bulk_insert()
DBUG_ENTER("end_bulk_insert");
// Check if last inserts need to be flushed
- THD *thd= current_thd;
- Thd_ndb *thd_ndb= get_thd_ndb(thd);
+ THD *thd= table->in_use;
+ Thd_ndb *thd_ndb= m_thd_ndb;
if ((thd->options & OPTION_ALLOW_BATCH) == 0 &&
thd_ndb->m_unsent_bytes)
{
@@ -5293,8 +5279,8 @@ int ha_ndbcluster::init_handler_for_stat
MySQL Server calls external lock
Other handlers in the same stmt or transaction should use
- the same NDB transaction. This is done by setting up the m_active_trans
- pointer to point to the NDB transaction.
+ the same NDB transaction. This is done by setting up the m_thd_ndb
+ pointer to point to the NDB transaction object.
*/
DBUG_ENTER("ha_ndbcluster::init_handler_for_statement");
@@ -5304,8 +5290,8 @@ int ha_ndbcluster::init_handler_for_stat
m_autoincrement_prefetch=
(ha_rows) thd->variables.ndb_autoincrement_prefetch_sz;
- m_active_trans= thd_ndb->trans;
- DBUG_ASSERT(m_active_trans);
+ m_thd_ndb= thd_ndb;
+ DBUG_ASSERT(m_thd_ndb->trans);
// Start of transaction
m_rows_changed= 0;
m_ops_pending= 0;
@@ -5410,7 +5396,7 @@ int ha_ndbcluster::external_lock(THD *th
And since the handler is no longer part of the transaction
it can't have open cursors, ops or blobs pending.
*/
- m_active_trans= NULL;
+ m_thd_ndb= NULL;
if (m_active_cursor)
DBUG_PRINT("warning", ("m_active_cursor != NULL"));
@@ -5520,11 +5506,11 @@ static int ndbcluster_commit(handlerton
if (thd->slave_thread)
{
- res= execute_commit(trans, 1, TRUE);
+ res= execute_commit(thd_ndb, trans, 1, TRUE);
}
else
{
- res= execute_commit(thd,trans);
+ res= execute_commit(thd_ndb, trans, thd->variables.ndb_force_send, FALSE);
}
if (res != 0)
@@ -6782,7 +6768,7 @@ int ha_ndbcluster::rename_table(const ch
const NDBTAB *ndbtab= ndbtab_g2.get_table();
if (share)
- ndbcluster_read_binlog_replication(current_thd, ndb, share, ndbtab, ::server_id);
+ ndbcluster_read_binlog_replication(thd, ndb, share, ndbtab, ::server_id);
/* always create an event for the table */
String event_name(INJECTOR_EVENT_LEN);
@@ -7161,7 +7147,7 @@ void ha_ndbcluster::get_auto_increment(u
ha_ndbcluster::ha_ndbcluster(handlerton *hton, TABLE_SHARE *table_arg):
handler(hton, table_arg),
- m_active_trans(NULL),
+ m_thd_ndb(NULL),
m_active_cursor(NULL),
m_table(NULL),
m_table_info(NULL),
@@ -7254,12 +7240,8 @@ ha_ndbcluster::~ha_ndbcluster()
m_row_buffer_size= 0;
// Check for open cursor/transaction
- if (m_active_cursor) {
- }
DBUG_ASSERT(m_active_cursor == NULL);
- if (m_active_trans) {
- }
- DBUG_ASSERT(m_active_trans == NULL);
+ DBUG_ASSERT(m_thd_ndb == NULL);
// Discard any generated condition
DBUG_PRINT("info", ("Deleting generated condition"));
@@ -8716,6 +8698,7 @@ ha_ndbcluster::records_in_range(uint inx
NDB_INDEX_DATA& d=m_index[inx];
const NDBINDEX* index= d.index;
Ndb* ndb=get_ndb();
+ NdbTransaction* active_trans= m_thd_ndb ? m_thd_ndb->trans : 0;
NdbTransaction* trans=NULL;
NdbIndexScanOperation* op=NULL;
int res=0;
@@ -8749,7 +8732,7 @@ ha_ndbcluster::records_in_range(uint inx
}
// Define scan op for the range
- if ((trans=m_active_trans) == NULL ||
+ if ((trans=active_trans) == NULL ||
trans->commitStatus() != NdbTransaction::Started)
{
DBUG_PRINT("info", ("no active trans"));
@@ -8778,9 +8761,9 @@ ha_ndbcluster::records_in_range(uint inx
d.index_stat_query_count++;
} while (0);
- if (trans != m_active_trans && rows == 0)
+ if (trans != active_trans && rows == 0)
rows = 1;
- if (trans != m_active_trans && trans != NULL)
+ if (trans != active_trans && trans != NULL)
ndb->closeTransaction(trans);
if (res != 0)
DBUG_RETURN(HA_POS_ERROR);
@@ -9907,7 +9890,7 @@ ha_ndbcluster::release_completed_operati
}
if (!force_release)
{
- if (get_thd_ndb(current_thd)->query_state & NDB_QUERY_MULTI_READ_RANGE)
+ if (m_thd_ndb->query_state & NDB_QUERY_MULTI_READ_RANGE)
{
/* We are batching reads and have not consumed all fetched
rows yet, releasing operation records is unsafe
@@ -10006,7 +9989,7 @@ ha_ndbcluster::read_multi_range_first(KE
NDB_INDEX_TYPE cur_index_type= get_index_type(active_index);
ulong reclength= table_share->reclength;
NdbOperation* op;
- Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
+ Thd_ndb *thd_ndb= m_thd_ndb;
struct read_multi_callback_data data;
DBUG_ENTER("ha_ndbcluster::read_multi_range_first");
@@ -10065,7 +10048,7 @@ ha_ndbcluster::read_multi_range_first(KE
DBUG_ASSERT(cur_index_type != UNDEFINED_INDEX);
- const NdbOperation* lastOp= m_active_trans->getLastDefinedOperation();
+ const NdbOperation* lastOp= m_thd_ndb->trans->getLastDefinedOperation();
NdbOperation::LockMode lm=
(NdbOperation::LockMode)get_ndb_lock_type(m_lock.type, table->read_set);
uchar *row_buf= (uchar *)buffer->buffer;
@@ -10128,7 +10111,7 @@ ha_ndbcluster::read_multi_range_first(KE
if (!(op= pk_unique_index_read_key(active_index,
r->start_key.key,
row_buf, lm)))
- ERR_RETURN(m_active_trans->getNdbError());
+ ERR_RETURN(m_thd_ndb->trans->getNdbError());
if (m_user_defined_partitioning &&
(cur_index_type == PRIMARY_KEY_ORDERED_INDEX ||
@@ -10164,12 +10147,12 @@ ha_ndbcluster::read_multi_range_first(KE
else
mask= (uchar *)(table->read_set->bitmap);
- NdbIndexScanOperation *scanOp= m_active_trans->scanIndex
+ NdbIndexScanOperation *scanOp= m_thd_ndb->trans->scanIndex
(m_index[active_index].ndb_record_key, read_multi_bounds_callback,
&data, num_scan_ranges, m_index[active_index].ndb_record_row, lm,
mask, flags, parallelism, 0);
if (!scanOp)
- ERR_RETURN(m_active_trans->getNdbError());
+ ERR_RETURN(m_thd_ndb->trans->getNdbError());
m_active_cursor= scanOp;
/*
@@ -10195,9 +10178,9 @@ ha_ndbcluster::read_multi_range_first(KE
* Set first operation in multi range
*/
m_current_multi_operation=
- lastOp ? lastOp->next() : m_active_trans->getFirstDefinedOperation();
- if (execute_no_commit_ie(this, m_active_trans, true))
- ERR_RETURN(m_active_trans->getNdbError());
+ lastOp ? lastOp->next() : m_thd_ndb->trans->getFirstDefinedOperation();
+ if (execute_no_commit_ie(this, m_thd_ndb->trans, true))
+ ERR_RETURN(m_thd_ndb->trans->getNdbError());
m_multi_range_result_ptr= buffer->buffer;
@@ -10228,7 +10211,7 @@ ha_ndbcluster::read_multi_range_next(KEY
KEY_MULTI_RANGE *old_multi_range_curr= multi_range_curr;
multi_range_curr= old_multi_range_curr + 1;
const NdbOperation *op= m_current_multi_operation;
- m_current_multi_operation= m_active_trans->getNextCompletedOperation(op);
+ m_current_multi_operation= m_thd_ndb->trans->getNextCompletedOperation(op);
const uchar *src_row= m_multi_range_result_ptr;
m_multi_range_result_ptr= src_row + table_share->reclength;
@@ -10247,7 +10230,7 @@ ha_ndbcluster::read_multi_range_next(KEY
}
else if (error.classification != NdbError::NoDataFound)
{
- DBUG_RETURN(ndb_err(m_active_trans));
+ DBUG_RETURN(ndb_err(m_thd_ndb->trans));
}
/* No row found, so fall through to try the next range. */
@@ -10322,8 +10305,7 @@ ha_ndbcluster::read_multi_range_next(KEY
if (multi_range_curr == multi_range_end)
{
- Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
- thd_ndb->query_state&= NDB_QUERY_NORMAL;
+ m_thd_ndb->query_state&= NDB_QUERY_NORMAL;
DBUG_RETURN(HA_ERR_END_OF_FILE);
}
@@ -10578,7 +10560,7 @@ pthread_handler_t ndb_util_thread_func(v
if ((share->use_count - (int) (share->op != 0) - (int) (share->op != 0))
<= 0)
continue; // injector thread is the only user, skip statistics
- share->util_lock= current_thd; // Mark that util thread has lock
+ share->util_lock= thd; // Mark that util thread has lock
#endif /* HAVE_NDB_BINLOG */
/* ndb_share reference temporary, free below */
share->use_count++; /* Make sure the table can't be closed */
@@ -10889,10 +10871,9 @@ uint32 ha_ndbcluster::calculate_key_hash
int ret_val;
Uint64 tmp[4096];
void *buf= (void*)&tmp[0];
- Ndb *ndb;
+ Ndb *ndb= m_thd_ndb->ndb;
DBUG_ENTER("ha_ndbcluster::calculate_key_hash_value");
- ndb= check_ndb_in_thd(current_thd);
do
{
Field *field= *field_array;
diff -Nrup a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h
--- a/sql/ha_ndbcluster.h 2007-10-08 21:54:54 +02:00
+++ b/sql/ha_ndbcluster.h 2007-10-10 14:46:42 +02:00
@@ -637,8 +637,6 @@ private:
int write_conflict_row(NdbTransaction*, const NdbOperation*, NdbError&);
friend int check_completed_operations(Thd_ndb*, ha_ndbcluster*, NdbTransaction*,
const NdbOperation*);
- friend int execute_commit(ha_ndbcluster*, NdbTransaction*);
- friend int execute_commit(NdbTransaction *, int, int);
friend int execute_no_commit_ignore_no_key(ha_ndbcluster*, NdbTransaction*);
friend int execute_no_commit(ha_ndbcluster*, NdbTransaction*, bool);
friend int execute_no_commit_ie(ha_ndbcluster*, NdbTransaction*, bool);
@@ -647,7 +645,7 @@ private:
int start_statement(THD *thd, Thd_ndb *thd_ndb, Ndb* ndb);
int init_handler_for_statement(THD *thd, Thd_ndb *thd_ndb);
- NdbTransaction *m_active_trans;
+ Thd_ndb *m_thd_ndb;
NdbScanOperation *m_active_cursor;
const NdbDictionary::Table *m_table;
/*
| Thread |
|---|
| • bk commit into 5.1 tree (tomas:1.2624) | tomas | 10 Oct |