Commit d1694f7a authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-5.1-runtime

into  bodhi.(none):/opt/local/work/mysql-5.1-12713-new


sql/handler.cc:
  Auto merged
sql/log.cc:
  Auto merged
parents 31460885 3b85708a
...@@ -785,5 +785,28 @@ void mysql_query_cache_invalidate4(MYSQL_THD thd, ...@@ -785,5 +785,28 @@ void mysql_query_cache_invalidate4(MYSQL_THD thd,
} }
#endif #endif
#ifdef __cplusplus
/**
Provide a handler data getter to simplify coding
*/
inline
void *
thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton)
{
return *thd_ha_data(thd, hton);
}
/**
Provide a handler data setter to simplify coding
*/
inline
void
thd_set_ha_data(const MYSQL_THD thd, const struct handlerton *hton,
const void *ha_data)
{
*thd_ha_data(thd, hton)= (void*) ha_data;
}
#endif
#endif #endif
...@@ -216,10 +216,12 @@ inline void free_share(NDB_SHARE **share, bool have_lock= FALSE) ...@@ -216,10 +216,12 @@ inline void free_share(NDB_SHARE **share, bool have_lock= FALSE)
inline inline
Thd_ndb * Thd_ndb *
get_thd_ndb(THD *thd) { return (Thd_ndb *) thd->ha_data[ndbcluster_hton->slot]; } get_thd_ndb(THD *thd)
{ return (Thd_ndb *) thd_get_ha_data(thd, ndbcluster_hton); }
inline inline
void void
set_thd_ndb(THD *thd, Thd_ndb *thd_ndb) { thd->ha_data[ndbcluster_hton->slot]= thd_ndb; } set_thd_ndb(THD *thd, Thd_ndb *thd_ndb)
{ thd_set_ha_data(thd, ndbcluster_hton, thd_ndb); }
Ndb* check_ndb_in_thd(THD* thd); Ndb* check_ndb_in_thd(THD* thd);
...@@ -561,7 +561,7 @@ static my_bool closecon_handlerton(THD *thd, plugin_ref plugin, ...@@ -561,7 +561,7 @@ static my_bool closecon_handlerton(THD *thd, plugin_ref plugin,
be rolled back already be rolled back already
*/ */
if (hton->state == SHOW_OPTION_YES && hton->close_connection && if (hton->state == SHOW_OPTION_YES && hton->close_connection &&
thd->ha_data[hton->slot]) thd_get_ha_data(thd, hton))
hton->close_connection(hton, thd); hton->close_connection(hton, thd);
return FALSE; return FALSE;
} }
...@@ -1509,7 +1509,7 @@ void handler::ha_statistic_increment(ulong SSV::*offset) const ...@@ -1509,7 +1509,7 @@ void handler::ha_statistic_increment(ulong SSV::*offset) const
void **handler::ha_data(THD *thd) const void **handler::ha_data(THD *thd) const
{ {
return (void **) thd->ha_data + ht->slot; return thd_ha_data(thd, ht);
} }
THD *handler::ha_thd(void) const THD *handler::ha_thd(void) const
......
...@@ -1215,10 +1215,10 @@ binlog_trans_log_savepos(THD *thd, my_off_t *pos) ...@@ -1215,10 +1215,10 @@ binlog_trans_log_savepos(THD *thd, my_off_t *pos)
{ {
DBUG_ENTER("binlog_trans_log_savepos"); DBUG_ENTER("binlog_trans_log_savepos");
DBUG_ASSERT(pos != NULL); DBUG_ASSERT(pos != NULL);
if (thd->ha_data[binlog_hton->slot] == NULL) if (thd_get_ha_data(thd, binlog_hton) == NULL)
thd->binlog_setup_trx_data(); thd->binlog_setup_trx_data();
binlog_trx_data *const trx_data= binlog_trx_data *const trx_data=
(binlog_trx_data*) thd->ha_data[binlog_hton->slot]; (binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
DBUG_ASSERT(mysql_bin_log.is_open()); DBUG_ASSERT(mysql_bin_log.is_open());
*pos= trx_data->position(); *pos= trx_data->position();
DBUG_PRINT("return", ("*pos: %lu", (ulong) *pos)); DBUG_PRINT("return", ("*pos: %lu", (ulong) *pos));
...@@ -1247,12 +1247,12 @@ binlog_trans_log_truncate(THD *thd, my_off_t pos) ...@@ -1247,12 +1247,12 @@ binlog_trans_log_truncate(THD *thd, my_off_t pos)
DBUG_ENTER("binlog_trans_log_truncate"); DBUG_ENTER("binlog_trans_log_truncate");
DBUG_PRINT("enter", ("pos: %lu", (ulong) pos)); DBUG_PRINT("enter", ("pos: %lu", (ulong) pos));
DBUG_ASSERT(thd->ha_data[binlog_hton->slot] != NULL); DBUG_ASSERT(thd_get_ha_data(thd, binlog_hton) != NULL);
/* Only true if binlog_trans_log_savepos() wasn't called before */ /* Only true if binlog_trans_log_savepos() wasn't called before */
DBUG_ASSERT(pos != ~(my_off_t) 0); DBUG_ASSERT(pos != ~(my_off_t) 0);
binlog_trx_data *const trx_data= binlog_trx_data *const trx_data=
(binlog_trx_data*) thd->ha_data[binlog_hton->slot]; (binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
trx_data->truncate(pos); trx_data->truncate(pos);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -1283,9 +1283,9 @@ int binlog_init(void *p) ...@@ -1283,9 +1283,9 @@ int binlog_init(void *p)
static int binlog_close_connection(handlerton *hton, THD *thd) static int binlog_close_connection(handlerton *hton, THD *thd)
{ {
binlog_trx_data *const trx_data= binlog_trx_data *const trx_data=
(binlog_trx_data*) thd->ha_data[binlog_hton->slot]; (binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
DBUG_ASSERT(trx_data->empty()); DBUG_ASSERT(trx_data->empty());
thd->ha_data[binlog_hton->slot]= 0; thd_set_ha_data(thd, binlog_hton, NULL);
trx_data->~binlog_trx_data(); trx_data->~binlog_trx_data();
my_free((uchar*)trx_data, MYF(0)); my_free((uchar*)trx_data, MYF(0));
return 0; return 0;
...@@ -1408,7 +1408,7 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all) ...@@ -1408,7 +1408,7 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all)
{ {
DBUG_ENTER("binlog_commit"); DBUG_ENTER("binlog_commit");
binlog_trx_data *const trx_data= binlog_trx_data *const trx_data=
(binlog_trx_data*) thd->ha_data[binlog_hton->slot]; (binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
if (trx_data->empty()) if (trx_data->empty())
{ {
...@@ -1435,7 +1435,7 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all) ...@@ -1435,7 +1435,7 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
DBUG_ENTER("binlog_rollback"); DBUG_ENTER("binlog_rollback");
int error=0; int error=0;
binlog_trx_data *const trx_data= binlog_trx_data *const trx_data=
(binlog_trx_data*) thd->ha_data[binlog_hton->slot]; (binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
if (trx_data->empty()) { if (trx_data->empty()) {
trx_data->reset(); trx_data->reset();
...@@ -3251,23 +3251,22 @@ int THD::binlog_setup_trx_data() ...@@ -3251,23 +3251,22 @@ int THD::binlog_setup_trx_data()
{ {
DBUG_ENTER("THD::binlog_setup_trx_data"); DBUG_ENTER("THD::binlog_setup_trx_data");
binlog_trx_data *trx_data= binlog_trx_data *trx_data=
(binlog_trx_data*) ha_data[binlog_hton->slot]; (binlog_trx_data*) thd_get_ha_data(this, binlog_hton);
if (trx_data) if (trx_data)
DBUG_RETURN(0); // Already set up DBUG_RETURN(0); // Already set up
ha_data[binlog_hton->slot]= trx_data= trx_data= (binlog_trx_data*) my_malloc(sizeof(binlog_trx_data), MYF(MY_ZEROFILL));
(binlog_trx_data*) my_malloc(sizeof(binlog_trx_data), MYF(MY_ZEROFILL));
if (!trx_data || if (!trx_data ||
open_cached_file(&trx_data->trans_log, mysql_tmpdir, open_cached_file(&trx_data->trans_log, mysql_tmpdir,
LOG_PREFIX, binlog_cache_size, MYF(MY_WME))) LOG_PREFIX, binlog_cache_size, MYF(MY_WME)))
{ {
my_free((uchar*)trx_data, MYF(MY_ALLOW_ZERO_PTR)); my_free((uchar*)trx_data, MYF(MY_ALLOW_ZERO_PTR));
ha_data[binlog_hton->slot]= 0;
DBUG_RETURN(1); // Didn't manage to set it up DBUG_RETURN(1); // Didn't manage to set it up
} }
thd_set_ha_data(this, binlog_hton, trx_data);
trx_data= new (ha_data[binlog_hton->slot]) binlog_trx_data; trx_data= new (thd_get_ha_data(this, binlog_hton)) binlog_trx_data;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -3303,7 +3302,7 @@ int THD::binlog_setup_trx_data() ...@@ -3303,7 +3302,7 @@ int THD::binlog_setup_trx_data()
void void
THD::binlog_start_trans_and_stmt() THD::binlog_start_trans_and_stmt()
{ {
binlog_trx_data *trx_data= (binlog_trx_data*) ha_data[binlog_hton->slot]; binlog_trx_data *trx_data= (binlog_trx_data*) thd_get_ha_data(this, binlog_hton);
DBUG_ENTER("binlog_start_trans_and_stmt"); DBUG_ENTER("binlog_start_trans_and_stmt");
DBUG_PRINT("enter", ("trx_data: 0x%lx trx_data->before_stmt_pos: %lu", DBUG_PRINT("enter", ("trx_data: 0x%lx trx_data->before_stmt_pos: %lu",
(long) trx_data, (long) trx_data,
...@@ -3323,7 +3322,7 @@ THD::binlog_start_trans_and_stmt() ...@@ -3323,7 +3322,7 @@ THD::binlog_start_trans_and_stmt()
void THD::binlog_set_stmt_begin() { void THD::binlog_set_stmt_begin() {
binlog_trx_data *trx_data= binlog_trx_data *trx_data=
(binlog_trx_data*) ha_data[binlog_hton->slot]; (binlog_trx_data*) thd_get_ha_data(this, binlog_hton);
/* /*
The call to binlog_trans_log_savepos() might create the trx_data The call to binlog_trans_log_savepos() might create the trx_data
...@@ -3333,14 +3332,15 @@ void THD::binlog_set_stmt_begin() { ...@@ -3333,14 +3332,15 @@ void THD::binlog_set_stmt_begin() {
*/ */
my_off_t pos= 0; my_off_t pos= 0;
binlog_trans_log_savepos(this, &pos); binlog_trans_log_savepos(this, &pos);
trx_data= (binlog_trx_data*) ha_data[binlog_hton->slot]; trx_data= (binlog_trx_data*) thd_get_ha_data(this, binlog_hton);
trx_data->before_stmt_pos= pos; trx_data->before_stmt_pos= pos;
} }
int THD::binlog_flush_transaction_cache() int THD::binlog_flush_transaction_cache()
{ {
DBUG_ENTER("binlog_flush_transaction_cache"); DBUG_ENTER("binlog_flush_transaction_cache");
binlog_trx_data *trx_data= (binlog_trx_data*) ha_data[binlog_hton->slot]; binlog_trx_data *trx_data= (binlog_trx_data*)
thd_get_ha_data(this, binlog_hton);
DBUG_PRINT("enter", ("trx_data=0x%lu", (ulong) trx_data)); DBUG_PRINT("enter", ("trx_data=0x%lu", (ulong) trx_data));
if (trx_data) if (trx_data)
DBUG_PRINT("enter", ("trx_data->before_stmt_pos=%lu", DBUG_PRINT("enter", ("trx_data->before_stmt_pos=%lu",
...@@ -3403,7 +3403,7 @@ Rows_log_event* ...@@ -3403,7 +3403,7 @@ Rows_log_event*
THD::binlog_get_pending_rows_event() const THD::binlog_get_pending_rows_event() const
{ {
binlog_trx_data *const trx_data= binlog_trx_data *const trx_data=
(binlog_trx_data*) ha_data[binlog_hton->slot]; (binlog_trx_data*) thd_get_ha_data(this, binlog_hton);
/* /*
This is less than ideal, but here's the story: If there is no This is less than ideal, but here's the story: If there is no
trx_data, prepare_pending_rows_event() has never been called trx_data, prepare_pending_rows_event() has never been called
...@@ -3416,11 +3416,11 @@ THD::binlog_get_pending_rows_event() const ...@@ -3416,11 +3416,11 @@ THD::binlog_get_pending_rows_event() const
void void
THD::binlog_set_pending_rows_event(Rows_log_event* ev) THD::binlog_set_pending_rows_event(Rows_log_event* ev)
{ {
if (ha_data[binlog_hton->slot] == NULL) if (thd_get_ha_data(this, binlog_hton) == NULL)
binlog_setup_trx_data(); binlog_setup_trx_data();
binlog_trx_data *const trx_data= binlog_trx_data *const trx_data=
(binlog_trx_data*) ha_data[binlog_hton->slot]; (binlog_trx_data*) thd_get_ha_data(this, binlog_hton);
DBUG_ASSERT(trx_data); DBUG_ASSERT(trx_data);
trx_data->set_pending(ev); trx_data->set_pending(ev);
...@@ -3443,7 +3443,7 @@ MYSQL_BIN_LOG::flush_and_set_pending_rows_event(THD *thd, ...@@ -3443,7 +3443,7 @@ MYSQL_BIN_LOG::flush_and_set_pending_rows_event(THD *thd,
int error= 0; int error= 0;
binlog_trx_data *const trx_data= binlog_trx_data *const trx_data=
(binlog_trx_data*) thd->ha_data[binlog_hton->slot]; (binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
DBUG_ASSERT(trx_data); DBUG_ASSERT(trx_data);
...@@ -3594,7 +3594,7 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info) ...@@ -3594,7 +3594,7 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info)
goto err; goto err;
binlog_trx_data *const trx_data= binlog_trx_data *const trx_data=
(binlog_trx_data*) thd->ha_data[binlog_hton->slot]; (binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
IO_CACHE *trans_log= &trx_data->trans_log; IO_CACHE *trans_log= &trx_data->trans_log;
my_off_t trans_log_pos= my_b_tell(trans_log); my_off_t trans_log_pos= my_b_tell(trans_log);
if (event_info->get_cache_stmt() || trans_log_pos != 0) if (event_info->get_cache_stmt() || trans_log_pos != 0)
...@@ -5031,7 +5031,7 @@ int TC_LOG_BINLOG::log_xid(THD *thd, my_xid xid) ...@@ -5031,7 +5031,7 @@ int TC_LOG_BINLOG::log_xid(THD *thd, my_xid xid)
DBUG_ENTER("TC_LOG_BINLOG::log"); DBUG_ENTER("TC_LOG_BINLOG::log");
Xid_log_event xle(thd, xid); Xid_log_event xle(thd, xid);
binlog_trx_data *trx_data= binlog_trx_data *trx_data=
(binlog_trx_data*) thd->ha_data[binlog_hton->slot]; (binlog_trx_data*) thd_get_ha_data(thd, binlog_hton);
/* /*
We always commit the entire transaction when writing an XID. Also We always commit the entire transaction when writing an XID. Also
note that the return value is inverted. note that the return value is inverted.
......
...@@ -241,8 +241,8 @@ class table_def ...@@ -241,8 +241,8 @@ class table_def
private: private:
ulong m_size; // Number of elements in the types array ulong m_size; // Number of elements in the types array
field_type *m_type; // Array of type descriptors field_type *m_type; // Array of type descriptors
uint16 *m_field_metadata;
uint m_field_metadata_size; uint m_field_metadata_size;
uint16 *m_field_metadata;
uchar *m_null_bits; uchar *m_null_bits;
uchar *m_memory; uchar *m_memory;
}; };
......
...@@ -3169,7 +3169,7 @@ int ha_federated::external_lock(THD *thd, int lock_type) ...@@ -3169,7 +3169,7 @@ int ha_federated::external_lock(THD *thd, int lock_type)
#ifdef XXX_SUPERCEDED_BY_WL2952 #ifdef XXX_SUPERCEDED_BY_WL2952
if (lock_type != F_UNLCK) if (lock_type != F_UNLCK)
{ {
ha_federated *trx= (ha_federated *)thd->ha_data[ht->slot]; ha_federated *trx= (ha_federated *)thd_get_ha_data(thd, ht);
DBUG_PRINT("info",("federated not lock F_UNLCK")); DBUG_PRINT("info",("federated not lock F_UNLCK"));
if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
...@@ -3200,7 +3200,7 @@ int ha_federated::external_lock(THD *thd, int lock_type) ...@@ -3200,7 +3200,7 @@ int ha_federated::external_lock(THD *thd, int lock_type)
DBUG_PRINT("info", ("error setting autocommit FALSE: %d", error)); DBUG_PRINT("info", ("error setting autocommit FALSE: %d", error));
DBUG_RETURN(error); DBUG_RETURN(error);
} }
thd->ha_data[ht->slot]= this; thd_set_ha_data(thd, ht, this);
trans_register_ha(thd, TRUE, ht); trans_register_ha(thd, TRUE, ht);
/* /*
Send a lock table to the remote end. Send a lock table to the remote end.
...@@ -3230,7 +3230,7 @@ int ha_federated::external_lock(THD *thd, int lock_type) ...@@ -3230,7 +3230,7 @@ int ha_federated::external_lock(THD *thd, int lock_type)
static int federated_commit(handlerton *hton, THD *thd, bool all) static int federated_commit(handlerton *hton, THD *thd, bool all)
{ {
int return_val= 0; int return_val= 0;
ha_federated *trx= (ha_federated *)thd->ha_data[hton->slot]; ha_federated *trx= (ha_federated *) thd_get_ha_data(thd, hton);
DBUG_ENTER("federated_commit"); DBUG_ENTER("federated_commit");
if (all) if (all)
...@@ -3245,7 +3245,7 @@ static int federated_commit(handlerton *hton, THD *thd, bool all) ...@@ -3245,7 +3245,7 @@ static int federated_commit(handlerton *hton, THD *thd, bool all)
if (error && !return_val) if (error && !return_val)
return_val= error; return_val= error;
} }
thd->ha_data[hton->slot]= NULL; thd_set_ha_data(thd, hton, NULL);
} }
DBUG_PRINT("info", ("error val: %d", return_val)); DBUG_PRINT("info", ("error val: %d", return_val));
...@@ -3256,7 +3256,7 @@ static int federated_commit(handlerton *hton, THD *thd, bool all) ...@@ -3256,7 +3256,7 @@ static int federated_commit(handlerton *hton, THD *thd, bool all)
static int federated_rollback(handlerton *hton, THD *thd, bool all) static int federated_rollback(handlerton *hton, THD *thd, bool all)
{ {
int return_val= 0; int return_val= 0;
ha_federated *trx= (ha_federated *)thd->ha_data[hton->slot]; ha_federated *trx= (ha_federated *)thd_get_ha_data(thd, hton);
DBUG_ENTER("federated_rollback"); DBUG_ENTER("federated_rollback");
if (all) if (all)
...@@ -3271,7 +3271,7 @@ static int federated_rollback(handlerton *hton, THD *thd, bool all) ...@@ -3271,7 +3271,7 @@ static int federated_rollback(handlerton *hton, THD *thd, bool all)
if (error && !return_val) if (error && !return_val)
return_val= error; return_val= error;
} }
thd->ha_data[hton->slot]= NULL; thd_set_ha_data(thd, hton, NULL);
} }
DBUG_PRINT("info", ("error val: %d", return_val)); DBUG_PRINT("info", ("error val: %d", return_val));
......
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