~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/handler/ha_innodb.cc

Merge Joe - More work on storing transaction log in innodb

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
#include "log0log.h"
103
103
#include "lock0lock.h"
104
104
#include "dict0crea.h"
 
105
#include "create_replication.h"
105
106
#include "btr0cur.h"
106
107
#include "btr0btr.h"
107
108
#include "fsp0fsp.h"
119
120
 
120
121
#include "ha_innodb.h"
121
122
#include "data_dictionary.h"
 
123
#include "replication_dictionary.h"
122
124
#include "internal_dictionary.h"
123
125
#include "handler0vars.h"
124
126
 
127
129
#include <string>
128
130
 
129
131
#include "plugin/innobase/handler/status_function.h"
 
132
#include "plugin/innobase/handler/replication_log.h"
 
133
 
 
134
#include <google/protobuf/io/zero_copy_stream.h>
 
135
#include <google/protobuf/io/zero_copy_stream_impl.h>
 
136
#include <google/protobuf/io/coded_stream.h>
 
137
#include <google/protobuf/text_format.h>
130
138
 
131
139
using namespace std;
132
140
using namespace drizzled;
171
179
static plugin::TableFunction* innodb_sys_foreign_tool= NULL;
172
180
static plugin::TableFunction* innodb_sys_foreign_cols_tool= NULL;
173
181
 
 
182
static plugin::TransactionApplier *replication_logger= NULL;
 
183
 
174
184
static long innobase_mirrored_log_groups, innobase_log_files_in_group,
175
185
  innobase_log_buffer_size,
176
186
  innobase_force_recovery, innobase_open_files;
955
965
  return *(trx_t**) session->getEngineData(innodb_engine_ptr);
956
966
}
957
967
 
 
968
 
 
969
plugin::ReplicationReturnCode ReplicationLog::apply(Session &session,
 
970
                                                    const message::Transaction &message)
 
971
{
 
972
  char *data= new char[message.ByteSize()];
 
973
 
 
974
  message.SerializeToArray(data, message.ByteSize());
 
975
 
 
976
  trx_t *trx= session_to_trx(&session);
 
977
 
 
978
  uint64_t trx_id= message.transaction_context().transaction_id();
 
979
  ulint error= insert_replication_message(data, message.ByteSize(), trx, trx_id);
 
980
  (void)error;
 
981
 
 
982
  delete[] data;
 
983
 
 
984
  return plugin::SUCCESS;
 
985
}
 
986
 
958
987
/********************************************************************//**
959
988
Call this function when mysqld passes control to the client. That is to
960
989
avoid deadlocks on the adaptive hash S-latch possibly held by session. For more
2345
2374
 
2346
2375
  err = innobase_start_or_create_for_mysql();
2347
2376
 
 
2377
  if (err != DB_SUCCESS)
 
2378
  {
 
2379
    goto mem_free_and_error;
 
2380
  }
 
2381
 
 
2382
  err = dict_create_sys_replication_log();
 
2383
 
2348
2384
  if (err != DB_SUCCESS) {
2349
2385
    goto mem_free_and_error;
2350
2386
  }
2423
2459
  context.registerVariable(new sys_var_bool_ptr_readonly("log-archive", &innobase_log_archive));
2424
2460
  #endif /* UNIV_LOG_ARCHIVE */  
2425
2461
 
 
2462
  context.add(new(std::nothrow)InnodbReplicationTable());
 
2463
 
 
2464
  replication_logger= new(std::nothrow)ReplicationLog();
 
2465
  context.add(replication_logger);
 
2466
 
 
2467
  if (vm.count("replication-log") and vm["replication-log"].as<bool>())
 
2468
  {
 
2469
    ReplicationLog::setup(static_cast<ReplicationLog *>(replication_logger));
 
2470
  }
 
2471
 
2426
2472
  context.registerVariable(new sys_var_bool_ptr_readonly("checksums", &innobase_use_checksums));
2427
2473
  context.registerVariable(new sys_var_bool_ptr_readonly("doublewrite", &innobase_use_doublewrite));
2428
2474
  context.registerVariable(new sys_var_bool_ptr("file-per-table", &srv_file_per_table));
2432
2478
  context.registerVariable(new sys_var_bool_ptr_readonly("use-sys-malloc", &srv_use_sys_malloc));
2433
2479
  context.registerVariable(new sys_var_bool_ptr_readonly("use-native-aio", &srv_use_native_aio));
2434
2480
 
2435
 
 
2436
2481
  /* Get the current high water mark format. */
2437
2482
  innobase_file_format_max = (char*) trx_sys_file_format_max_get();
2438
2483
  btr_search_fully_disabled = (!btr_search_enabled);
9792
9837
  context("strict-mode",
9793
9838
          po::value<bool>()->default_value(false)->zero_tokens(),
9794
9839
          "Use strict mode when evaluating create options.");
 
9840
  context("replication-log",
 
9841
          po::value<bool>()->default_value(false),
 
9842
          "Enable internal replication log.");
9795
9843
  context("lock-wait-timeout",
9796
9844
          po::value<unsigned long>()->default_value(50),
9797
9845
          "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.");