~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/haildb/haildb_engine.cc

edit

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
***********************************************************************/
72
72
 
73
73
 
74
 
#include <config.h>
 
74
#include "config.h"
75
75
#include <drizzled/table.h>
76
76
#include <drizzled/error.h>
77
 
#include <drizzled/internal/my_pthread.h>
 
77
#include "drizzled/internal/my_pthread.h"
78
78
#include <drizzled/plugin/transactional_storage_engine.h>
79
79
#include <drizzled/plugin/error_message.h>
80
80
 
88
88
#include <map>
89
89
#include <fstream>
90
90
#include <drizzled/message/table.pb.h>
91
 
#include <drizzled/internal/m_string.h>
 
91
#include "drizzled/internal/m_string.h"
92
92
 
93
 
#include <drizzled/global_charset_info.h>
 
93
#include "drizzled/global_charset_info.h"
94
94
 
95
95
#include "haildb_datadict_dump_func.h"
96
96
#include "config_table_function.h"
101
101
#include "haildb_engine.h"
102
102
 
103
103
#include <drizzled/field.h>
104
 
#include <drizzled/field/blob.h>
105
 
#include <drizzled/field/enum.h>
 
104
#include "drizzled/field/blob.h"
 
105
#include "drizzled/field/enum.h"
106
106
#include <drizzled/session.h>
 
107
#include <boost/program_options.hpp>
107
108
#include <drizzled/module/option_map.h>
 
109
#include <iostream>
108
110
#include <drizzled/charset.h>
109
 
#include <drizzled/current_session.h>
110
 
 
111
 
#include <iostream>
112
111
 
113
112
namespace po= boost::program_options;
114
 
#include <boost/program_options.hpp>
115
113
#include <boost/algorithm/string.hpp>
116
114
 
117
115
using namespace std;
273
271
  case DB_DEADLOCK:
274
272
    /* HailDB will roll back a transaction itself due to DB_DEADLOCK.
275
273
       This means we have to tell Drizzle about it */
276
 
    session->markTransactionForRollback(true);
 
274
    mark_transaction_to_rollback(session, true);
277
275
    return HA_ERR_LOCK_DEADLOCK;
278
276
 
279
277
  case DB_LOCK_WAIT_TIMEOUT:
280
 
    session->markTransactionForRollback(false);
281
278
    return HA_ERR_LOCK_WAIT_TIMEOUT;
282
279
 
283
280
  case DB_NO_REFERENCED_ROW:
356
353
  (void)options;
357
354
 
358
355
  transaction= get_trx(session);
359
 
  isolation_level= tx_isolation_to_ib_trx_level(session->getTxIsolation());
 
356
  isolation_level= tx_isolation_to_ib_trx_level((enum_tx_isolation)session_tx_isolation(session));
360
357
  *transaction= ib_trx_begin(isolation_level);
361
358
 
362
359
  return *transaction == NULL;
415
412
  ib_err_t err;
416
413
  ib_trx_t *transaction= get_trx(session);
417
414
 
418
 
  if (all)
 
415
  if (all || (!session_test_options(session, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
419
416
  {
420
417
    err= ib_trx_commit(*transaction);
421
418
 
433
430
  ib_err_t err;
434
431
  ib_trx_t *transaction= get_trx(session);
435
432
 
436
 
  if (all)
 
433
  if (all || !session_test_options(session, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
437
434
  {
438
435
    if (ib_trx_state(*transaction) == IB_TRX_NOT_STARTED)
439
436
      err= ib_trx_release(*transaction);
538
535
  doEndIndexScan();
539
536
  (void) extra(HA_EXTRA_NO_KEYREAD);
540
537
 
541
 
  if (getTable()->getShare()->getTableMessage()->options().auto_increment_value() > nr)
542
 
    nr= getTable()->getShare()->getTableMessage()->options().auto_increment_value();
 
538
  if (getTable()->getShare()->getTableProto()->options().auto_increment_value() > nr)
 
539
    nr= getTable()->getShare()->getTableProto()->options().auto_increment_value();
543
540
 
544
541
  return nr;
545
542
}
652
649
 
653
650
  /* the below is adapted from ha_innodb.cc */
654
651
 
655
 
  const uint32_t sql_command = session->getSqlCommand();
 
652
  const uint32_t sql_command = session_sql_command(session);
656
653
 
657
654
  if (sql_command == SQLCOM_DROP_TABLE) {
658
655
 
683
680
    unexpected if an obsolete consistent read view would be
684
681
    used. */
685
682
 
686
 
    enum_tx_isolation isolation_level= session->getTxIsolation();
 
683
    enum_tx_isolation isolation_level= session_tx_isolation(session);
687
684
 
688
685
    if (isolation_level != ISO_SERIALIZABLE
689
686
        && (lock_type == TL_READ || lock_type == TL_READ_NO_INSERT)
726
723
 
727
724
    if ((lock_type >= TL_WRITE_CONCURRENT_INSERT
728
725
         && lock_type <= TL_WRITE)
729
 
        && ! session->doing_tablespace_operation()
 
726
        && !session_tablespace_op(session)
730
727
        && sql_command != SQLCOM_TRUNCATE
731
728
        && sql_command != SQLCOM_CREATE_TABLE) {
732
729
 
1923
1920
  }
1924
1921
 
1925
1922
  err= ib_cursor_first(cursor);
1926
 
  if (current_session->getLex()->sql_command == SQLCOM_CREATE_TABLE
 
1923
  if (current_session->lex->sql_command == SQLCOM_CREATE_TABLE
1927
1924
      && err == DB_MISSING_HISTORY)
1928
1925
  {
1929
1926
    /* See https://bugs.launchpad.net/drizzle/+bug/556978
2126
2123
     so only support TRUNCATE and not DELETE FROM t;
2127
2124
     (this is what ha_innodb does)
2128
2125
  */
2129
 
  if (getTable()->in_use->getSqlCommand() != SQLCOM_TRUNCATE)
 
2126
  if (session_sql_command(getTable()->in_use) != SQLCOM_TRUNCATE)
2130
2127
    return HA_ERR_WRONG_COMMAND;
2131
2128
 
2132
2129
  ib_id_t id;
3147
3144
  bool r= false;
3148
3145
  va_list args;
3149
3146
  va_start(args, fmt);
3150
 
  if (not shutdown_in_progress)
3151
 
  {
3152
 
    r= plugin::ErrorMessage::vprintf(error::WARN, fmt, args);
3153
 
  }
 
3147
  if (! shutdown_in_progress)
 
3148
    r= plugin::ErrorMessage::vprintf(NULL, ERRMSG_LVL_WARN, fmt, args);
3154
3149
  else
3155
 
  {
3156
3150
    vfprintf(stderr, fmt, args);
3157
 
  }
3158
3151
  va_end(args);
3159
3152
 
3160
3153
  return (! r==true);
3539
3532
  "Transactional Storage Engine using the HailDB Library",
3540
3533
  PLUGIN_LICENSE_GPL,
3541
3534
  haildb_init,     /* Plugin Init */
3542
 
  NULL, /* depends */
 
3535
  NULL, /* system variables */
3543
3536
  init_options                /* config options   */
3544
3537
}
3545
3538
DRIZZLE_DECLARE_PLUGIN_END;