39
39
#include "drizzled/unireg.h" // for mysql_frm_type
40
40
#include "drizzled/field/timestamp.h"
41
41
#include "drizzled/message/table.pb.h"
42
#include "drizzled/plugin/client.h"
43
44
using namespace std;
44
45
using namespace drizzled;
362
363
in each engine independently. The two-phase commit protocol
364
365
- all participating engines support two-phase commit (provide
365
StorageEngine::prepare PSEA API call) and
366
plugin::StorageEngine::prepare PSEA API call) and
366
367
- transactions in at least two engines modify data (i.e. are
427
428
At the end of a statement, server call
428
429
ha_autocommit_or_rollback() is invoked. This call in turn
429
invokes StorageEngine::prepare() for every involved engine.
430
Prepare is followed by a call to StorageEngine::commit_one_phase()
431
If a one-phase commit will suffice, StorageEngine::prepare() is not
432
invoked and the server only calls StorageEngine::commit_one_phase().
430
invokes plugin::StorageEngine::prepare() for every involved engine.
431
Prepare is followed by a call to plugin::StorageEngine::commit_one_phase()
432
If a one-phase commit will suffice, plugin::StorageEngine::prepare() is not
433
invoked and the server only calls plugin::StorageEngine::commit_one_phase().
433
434
At statement commit, the statement-related read-write engine
434
435
flag is propagated to the corresponding flag in the normal
435
436
transaction. When the commit is complete, the list of registered
620
621
for (; ha_info && !error; ha_info= ha_info->next())
623
StorageEngine *engine= ha_info->engine();
624
plugin::StorageEngine *engine= ha_info->engine();
625
626
Do not call two-phase commit if this particular
626
627
transaction is read-only. This allows for simpler
669
670
for (; ha_info; ha_info= ha_info_next)
672
StorageEngine *engine= ha_info->engine();
673
plugin::StorageEngine *engine= ha_info->engine();
673
674
if ((err= engine->commit(session, all)))
675
676
my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
712
713
for (; ha_info; ha_info= ha_info_next)
715
StorageEngine *engine= ha_info->engine();
716
plugin::StorageEngine *engine= ha_info->engine();
716
717
if ((err= engine->rollback(session, all)))
717
718
{ // cannot happen
718
719
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
804
804
field_list.push_back(new Item_int("bqual_length", 0, MY_INT32_NUM_DECIMAL_DIGITS));
805
805
field_list.push_back(new Item_empty_string("data",XIDDATASIZE));
807
if (protocol->sendFields(&field_list))
807
if (session->client->sendFields(&field_list))
810
810
pthread_mutex_lock(&LOCK_xid_cache);
813
813
if (xs->xa_state==XA_PREPARED)
815
protocol->prepareForResend();
816
protocol->store((int64_t)xs->xid.formatID);
817
protocol->store((int64_t)xs->xid.gtrid_length);
818
protocol->store((int64_t)xs->xid.bqual_length);
819
protocol->store(xs->xid.data, xs->xid.gtrid_length+xs->xid.bqual_length);
820
if (protocol->write())
815
session->client->store((int64_t)xs->xid.formatID);
816
session->client->store((int64_t)xs->xid.gtrid_length);
817
session->client->store((int64_t)xs->xid.bqual_length);
818
session->client->store(xs->xid.data,
819
xs->xid.gtrid_length+xs->xid.bqual_length);
820
if (session->client->flush())
822
822
pthread_mutex_unlock(&LOCK_xid_cache);
845
845
for (ha_info= sv->ha_list; ha_info; ha_info= ha_info->next())
848
StorageEngine *engine= ha_info->engine();
848
plugin::StorageEngine *engine= ha_info->engine();
850
850
if ((err= engine->savepoint_rollback(session,
851
851
(void *)(sv+1))))
864
864
ha_info= ha_info_next)
867
StorageEngine *engine= ha_info->engine();
867
plugin::StorageEngine *engine= ha_info->engine();
868
868
if ((err= engine->rollback(session, !(0))))
869
869
{ // cannot happen
870
870
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
892
892
for (; ha_info; ha_info= ha_info->next())
895
StorageEngine *engine= ha_info->engine();
895
plugin::StorageEngine *engine= ha_info->engine();
897
897
#ifdef NOT_IMPLEMENTED /*- TODO (examine this againt the original code base) */
898
898
if (! engine->savepoint_set)
925
925
for (; ha_info; ha_info= ha_info->next())
928
StorageEngine *engine= ha_info->engine();
928
plugin::StorageEngine *engine= ha_info->engine();
929
929
/* Savepoint life time is enclosed into transaction life time. */
931
931
if ((err= engine->savepoint_release(session,
2604
2604
const char *file, uint32_t file_len,
2605
2605
const char *status, uint32_t status_len)
2607
plugin::Protocol *protocol= session->protocol;
2608
protocol->prepareForResend();
2609
protocol->store(type, type_len);
2610
protocol->store(file, file_len);
2611
protocol->store(status, status_len);
2612
if (protocol->write())
2607
session->client->store(type, type_len);
2608
session->client->store(file, file_len);
2609
session->client->store(status, status_len);
2610
if (session->client->flush())
2617
bool ha_show_status(Session *session, StorageEngine *engine, enum ha_stat_type stat)
2615
bool ha_show_status(Session *session, plugin::StorageEngine *engine, enum ha_stat_type stat)
2619
2617
List<Item> field_list;
2620
plugin::Protocol *protocol= session->protocol;
2623
2620
field_list.push_back(new Item_empty_string("Type",10));
2624
2621
field_list.push_back(new Item_empty_string("Name",FN_REFLEN));
2625
2622
field_list.push_back(new Item_empty_string("Status",10));
2627
if (protocol->sendFields(&field_list))
2624
if (session->client->sendFields(&field_list))
2630
2627
result= engine->show_status(session, stat_print, stat) ? 1 : 0;
2695
2692
We cache the table flags if the locking succeeded. Otherwise, we
2696
2693
keep them as they were when they were fetched in ha_open().
2698
DRIZZLE_EXTERNAL_LOCK(lock_type);
2700
2696
int error= external_lock(session, lock_type);
2701
2698
if (error == 0)
2702
2699
cached_table_flags= table_flags();
2742
2738
mark_trx_read_write();
2744
2740
if (unlikely(error= write_row(buf)))
2747
2745
if (unlikely(log_row_for_replication(table, 0, buf)))
2748
return HA_ERR_RBR_LOGGING_FAILED; /* purecov: inspected */
2746
return HA_ERR_RBR_LOGGING_FAILED;
2750
DRIZZLE_INSERT_ROW_END();
2765
2762
mark_trx_read_write();
2767
2764
if (unlikely(error= update_row(old_data, new_data)))
2770
2769
if (unlikely(log_row_for_replication(table, old_data, new_data)))
2771
2770
return HA_ERR_RBR_LOGGING_FAILED;