Commit 467de398 authored by kostja@bodhi.(none)'s avatar kostja@bodhi.(none)

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

into  bodhi.(none):/opt/local/work/mysql-5.1-12713-new
parents 4cab1109 8d1af60d
......@@ -785,5 +785,28 @@ void mysql_query_cache_invalidate4(MYSQL_THD thd,
}
#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
......@@ -216,10 +216,12 @@ inline void free_share(NDB_SHARE **share, bool have_lock= FALSE)
inline
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
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);
......@@ -561,7 +561,7 @@ static my_bool closecon_handlerton(THD *thd, plugin_ref plugin,
be rolled back already
*/
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);
return FALSE;
}
......@@ -1509,7 +1509,7 @@ void handler::ha_statistic_increment(ulong SSV::*offset) 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
......
......@@ -1215,10 +1215,10 @@ binlog_trans_log_savepos(THD *thd, my_off_t *pos)
{
DBUG_ENTER("binlog_trans_log_savepos");
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();
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());
*pos= trx_data->position();
DBUG_PRINT("return", ("*pos: %lu", (ulong) *pos));
......@@ -1247,12 +1247,12 @@ binlog_trans_log_truncate(THD *thd, my_off_t pos)
DBUG_ENTER("binlog_trans_log_truncate");
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 */
DBUG_ASSERT(pos != ~(my_off_t) 0);
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);
DBUG_VOID_RETURN;
}
......@@ -1283,9 +1283,9 @@ int binlog_init(void *p)
static int binlog_close_connection(handlerton *hton, THD *thd)
{
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());
thd->ha_data[binlog_hton->slot]= 0;
thd_set_ha_data(thd, binlog_hton, NULL);
trx_data->~binlog_trx_data();
my_free((uchar*)trx_data, MYF(0));
return 0;
......@@ -1408,7 +1408,7 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all)
{
DBUG_ENTER("binlog_commit");
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())
{
......@@ -1435,7 +1435,7 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
DBUG_ENTER("binlog_rollback");
int error=0;
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()) {
trx_data->reset();
......@@ -3251,23 +3251,22 @@ int THD::binlog_setup_trx_data()
{
DBUG_ENTER("THD::binlog_setup_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)
DBUG_RETURN(0); // Already set up
ha_data[binlog_hton->slot]= trx_data=
(binlog_trx_data*) my_malloc(sizeof(binlog_trx_data), MYF(MY_ZEROFILL));
trx_data= (binlog_trx_data*) my_malloc(sizeof(binlog_trx_data), MYF(MY_ZEROFILL));
if (!trx_data ||
open_cached_file(&trx_data->trans_log, mysql_tmpdir,
LOG_PREFIX, binlog_cache_size, MYF(MY_WME)))
{
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
}
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);
}
......@@ -3303,7 +3302,7 @@ int THD::binlog_setup_trx_data()
void
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_PRINT("enter", ("trx_data: 0x%lx trx_data->before_stmt_pos: %lu",
(long) trx_data,
......@@ -3323,7 +3322,7 @@ THD::binlog_start_trans_and_stmt()
void THD::binlog_set_stmt_begin() {
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
......@@ -3333,14 +3332,15 @@ void THD::binlog_set_stmt_begin() {
*/
my_off_t pos= 0;
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;
}
int THD::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));
if (trx_data)
DBUG_PRINT("enter", ("trx_data->before_stmt_pos=%lu",
......@@ -3403,7 +3403,7 @@ Rows_log_event*
THD::binlog_get_pending_rows_event() const
{
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
trx_data, prepare_pending_rows_event() has never been called
......@@ -3416,11 +3416,11 @@ THD::binlog_get_pending_rows_event() const
void
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_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);
trx_data->set_pending(ev);
......@@ -3443,7 +3443,7 @@ MYSQL_BIN_LOG::flush_and_set_pending_rows_event(THD *thd,
int error= 0;
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);
......@@ -3594,7 +3594,7 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info)
goto err;
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;
my_off_t trans_log_pos= my_b_tell(trans_log);
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)
DBUG_ENTER("TC_LOG_BINLOG::log");
Xid_log_event xle(thd, xid);
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
note that the return value is inverted.
......
......@@ -241,8 +241,8 @@ public:
private:
ulong m_size; // Number of elements in the types array
field_type *m_type; // Array of type descriptors
uint16 *m_field_metadata;
uint m_field_metadata_size;
uint16 *m_field_metadata;
uchar *m_null_bits;
uchar *m_memory;
};
......
......@@ -3169,7 +3169,7 @@ int ha_federated::external_lock(THD *thd, int lock_type)
#ifdef XXX_SUPERCEDED_BY_WL2952
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"));
if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
......@@ -3200,7 +3200,7 @@ int ha_federated::external_lock(THD *thd, int lock_type)
DBUG_PRINT("info", ("error setting autocommit FALSE: %d", error));
DBUG_RETURN(error);
}
thd->ha_data[ht->slot]= this;
thd_set_ha_data(thd, ht, this);
trans_register_ha(thd, TRUE, ht);
/*
Send a lock table to the remote end.
......@@ -3230,7 +3230,7 @@ int ha_federated::external_lock(THD *thd, int lock_type)
static int federated_commit(handlerton *hton, THD *thd, bool all)
{
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");
if (all)
......@@ -3245,7 +3245,7 @@ static int federated_commit(handlerton *hton, THD *thd, bool all)
if (error && !return_val)
return_val= error;
}
thd->ha_data[hton->slot]= NULL;
thd_set_ha_data(thd, hton, NULL);
}
DBUG_PRINT("info", ("error val: %d", return_val));
......@@ -3256,7 +3256,7 @@ static int federated_commit(handlerton *hton, THD *thd, bool all)
static int federated_rollback(handlerton *hton, THD *thd, bool all)
{
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");
if (all)
......@@ -3271,7 +3271,7 @@ static int federated_rollback(handlerton *hton, THD *thd, bool all)
if (error && !return_val)
return_val= error;
}
thd->ha_data[hton->slot]= NULL;
thd_set_ha_data(thd, hton, NULL);
}
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