~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/haildb/haildb_engine.cc

Merge Monty - Change the requirement from either libinnodb to libhaildb. Also, tied it to version 2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
/*****************************************************************************
23
23
 
24
 
Copyright (C) 2000, 2009, MySQL AB & Innobase Oy. All Rights Reserved.
25
 
Copyright (C) 2008, 2009 Google Inc.
 
24
Copyright (c) 2000, 2009, MySQL AB & Innobase Oy. All Rights Reserved.
 
25
Copyright (c) 2008, 2009 Google Inc.
26
26
 
27
27
Portions of this file contain modifications contributed and copyrighted by
28
28
Google, Inc. Those modifications are gratefully acknowledged and are described
45
45
*****************************************************************************/
46
46
/***********************************************************************
47
47
 
48
 
Copyright (C) 1995, 2009, Innobase Oy. All Rights Reserved.
49
 
Copyright (C) 2009, Percona Inc.
 
48
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
 
49
Copyright (c) 2009, Percona Inc.
50
50
 
51
51
Portions of this file contain modifications contributed and copyrighted
52
52
by Percona Inc.. Those modifications are
76
76
#include <drizzled/error.h>
77
77
#include "drizzled/internal/my_pthread.h"
78
78
#include <drizzled/plugin/transactional_storage_engine.h>
79
 
#include <drizzled/plugin/error_message.h>
80
79
 
81
80
#include <fcntl.h>
82
 
#include <stdarg.h>
83
81
 
84
82
#include <string>
85
83
#include <boost/algorithm/string.hpp>
92
90
 
93
91
#include "drizzled/global_charset_info.h"
94
92
 
 
93
#include "haildb_version_func.h"
95
94
#include "haildb_datadict_dump_func.h"
96
95
#include "config_table_function.h"
97
96
#include "status_table_function.h"
98
97
 
99
 
#include <haildb.h>
 
98
#if defined(HAVE_HAILDB_H)
 
99
# include <haildb.h>
 
100
#else
 
101
# include <embedded_innodb-1.0/innodb.h>
 
102
#endif /* HAVE_HAILDB_H */
100
103
 
101
104
#include "haildb_engine.h"
102
105
 
103
106
#include <drizzled/field.h>
 
107
#include "drizzled/field/timestamp.h" // needed for UPDATE NOW()
104
108
#include "drizzled/field/blob.h"
105
109
#include "drizzled/field/enum.h"
106
110
#include <drizzled/session.h>
116
120
using namespace google;
117
121
using namespace drizzled;
118
122
 
119
 
int read_row_from_haildb(Session *session, unsigned char* buf, ib_crsr_t cursor, ib_tpl_t tuple, Table* table, bool has_hidden_primary_key, uint64_t *hidden_pkey, drizzled::memory::Root **blobroot= NULL);
 
123
int read_row_from_haildb(unsigned char* buf, ib_crsr_t cursor, ib_tpl_t tuple, Table* table, bool has_hidden_primary_key, uint64_t *hidden_pkey, drizzled::memory::Root **blobroot= NULL);
120
124
static void fill_ib_search_tpl_from_drizzle_key(ib_tpl_t search_tuple,
121
125
                                                const drizzled::KeyInfo *key_info,
122
126
                                                const unsigned char *key_ptr,
151
155
 
152
156
  ~HailDBEngine();
153
157
 
154
 
  virtual Cursor *create(Table &table)
 
158
  virtual Cursor *create(TableShare &table)
155
159
  {
156
160
    return new HailDBCursor(*this, table);
157
161
  }
165
169
 
166
170
  int doCreateTable(Session&,
167
171
                    Table& table_arg,
168
 
                    const drizzled::identifier::Table &identifier,
 
172
                    const drizzled::TableIdentifier &identifier,
169
173
                    drizzled::message::Table& proto);
170
174
 
171
 
  int doDropTable(Session&, const identifier::Table &identifier);
 
175
  int doDropTable(Session&, const TableIdentifier &identifier);
172
176
 
173
177
  int doRenameTable(drizzled::Session&,
174
 
                    const drizzled::identifier::Table&,
175
 
                    const drizzled::identifier::Table&);
 
178
                    const drizzled::TableIdentifier&,
 
179
                    const drizzled::TableIdentifier&);
176
180
 
177
181
  int doGetTableDefinition(Session& session,
178
 
                           const identifier::Table &identifier,
 
182
                           const TableIdentifier &identifier,
179
183
                           drizzled::message::Table &table_proto);
180
184
 
181
 
  bool doDoesTableExist(Session&, const identifier::Table &identifier);
 
185
  bool doDoesTableExist(Session&, const TableIdentifier &identifier);
182
186
 
183
187
private:
184
 
  void getTableNamesInSchemaFromHailDB(const drizzled::identifier::Schema &schema,
 
188
  void getTableNamesInSchemaFromHailDB(const drizzled::SchemaIdentifier &schema,
185
189
                                       drizzled::plugin::TableNameList *set_of_names,
186
 
                                       drizzled::identifier::Table::vector *identifiers);
 
190
                                       drizzled::TableIdentifiers *identifiers);
187
191
 
188
192
public:
189
193
  void doGetTableIdentifiers(drizzled::CachedDirectory &,
190
 
                             const drizzled::identifier::Schema &schema,
191
 
                             drizzled::identifier::Table::vector &identifiers);
 
194
                             const drizzled::SchemaIdentifier &schema,
 
195
                             drizzled::TableIdentifiers &identifiers);
192
196
 
193
197
  /* The following defines can be increased if necessary */
194
198
  uint32_t max_supported_keys()          const { return 1000; }
239
243
/* This is a superset of the map from innobase plugin.
240
244
   Unlike innobase plugin we don't act on errors here, we just
241
245
   map error codes. */
242
 
static int ib_err_t_to_drizzle_error(Session* session, ib_err_t err)
 
246
static int ib_err_t_to_drizzle_error(ib_err_t err)
243
247
{
244
248
  switch (err)
245
249
  {
269
273
    return HA_ERR_NO_ACTIVE_RECORD;
270
274
 
271
275
  case DB_DEADLOCK:
272
 
    /* HailDB will roll back a transaction itself due to DB_DEADLOCK.
273
 
       This means we have to tell Drizzle about it */
274
 
    session->markTransactionForRollback(true);
275
276
    return HA_ERR_LOCK_DEADLOCK;
276
277
 
277
278
  case DB_LOCK_WAIT_TIMEOUT:
353
354
  (void)options;
354
355
 
355
356
  transaction= get_trx(session);
356
 
  isolation_level= tx_isolation_to_ib_trx_level(session->getTxIsolation());
 
357
  isolation_level= tx_isolation_to_ib_trx_level((enum_tx_isolation)session_tx_isolation(session));
357
358
  *transaction= ib_trx_begin(isolation_level);
358
359
 
359
 
  return *transaction == NULL;
 
360
  return 0;
360
361
}
361
362
 
362
363
void HailDBEngine::doStartStatement(Session *session)
368
369
                    statement_savepoint_name.length());
369
370
}
370
371
 
371
 
void HailDBEngine::doEndStatement(Session *)
 
372
void HailDBEngine::doEndStatement(Session *session)
372
373
{
 
374
  doCommit(session, false);
373
375
}
374
376
 
375
377
int HailDBEngine::doSetSavepoint(Session* session,
390
392
  err= ib_savepoint_rollback(*transaction, savepoint.getName().c_str(),
391
393
                             savepoint.getName().length());
392
394
 
393
 
  return ib_err_t_to_drizzle_error(session, err);
 
395
  return ib_err_t_to_drizzle_error(err);
394
396
}
395
397
 
396
398
int HailDBEngine::doReleaseSavepoint(Session* session,
402
404
  err= ib_savepoint_release(*transaction, savepoint.getName().c_str(),
403
405
                            savepoint.getName().length());
404
406
  if (err != DB_SUCCESS)
405
 
    return ib_err_t_to_drizzle_error(session, err);
 
407
    return ib_err_t_to_drizzle_error(err);
406
408
 
407
409
  return 0;
408
410
}
412
414
  ib_err_t err;
413
415
  ib_trx_t *transaction= get_trx(session);
414
416
 
415
 
  if (all)
 
417
  if (all || (!session_test_options(session, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
416
418
  {
417
419
    err= ib_trx_commit(*transaction);
418
420
 
419
421
    if (err != DB_SUCCESS)
420
 
      return ib_err_t_to_drizzle_error(session, err);
 
422
      return ib_err_t_to_drizzle_error(err);
421
423
 
422
424
    *transaction= NULL;
423
425
  }
430
432
  ib_err_t err;
431
433
  ib_trx_t *transaction= get_trx(session);
432
434
 
433
 
  if (all)
 
435
  if (all || !session_test_options(session, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
434
436
  {
435
 
    if (ib_trx_state(*transaction) == IB_TRX_NOT_STARTED)
436
 
      err= ib_trx_release(*transaction);
437
 
    else
438
 
      err= ib_trx_rollback(*transaction);
 
437
    err= ib_trx_rollback(*transaction);
439
438
 
440
439
    if (err != DB_SUCCESS)
441
 
      return ib_err_t_to_drizzle_error(session, err);
 
440
      return ib_err_t_to_drizzle_error(err);
442
441
 
443
442
    *transaction= NULL;
444
443
  }
445
444
  else
446
445
  {
447
 
    if (ib_trx_state(*transaction) == IB_TRX_NOT_STARTED)
448
 
      return 0;
449
 
 
450
446
    err= ib_savepoint_rollback(*transaction, statement_savepoint_name.c_str(),
451
447
                               statement_savepoint_name.length());
452
448
    if (err != DB_SUCCESS)
453
 
      return ib_err_t_to_drizzle_error(session, err);
 
449
      return ib_err_t_to_drizzle_error(err);
454
450
  }
455
451
 
456
452
  return 0;
483
479
{
484
480
  uint64_t nr;
485
481
  ib_err_t err;
486
 
  ib_trx_t transaction= *get_trx(getTable()->in_use);
 
482
  ib_trx_t transaction= *get_trx(table->in_use);
487
483
  ib_cursor_attach_trx(cursor, transaction);
488
484
  tuple= ib_clust_read_tuple_create(cursor);
489
485
  err= ib_cursor_last(cursor);
494
490
  else
495
491
  {
496
492
    assert (err == DB_SUCCESS);
497
 
    err= ib_tuple_read_u64(tuple, getTable()->getShare()->sizeFields(), &nr);
 
493
    err= ib_tuple_read_u64(tuple, table->getShare()->fields, &nr);
498
494
    nr++;
499
495
  }
500
496
  ib_tuple_delete(tuple);
501
 
  tuple= NULL;
502
497
  err= ib_cursor_reset(cursor);
503
498
  assert(err == DB_SUCCESS);
504
499
  return nr;
510
505
  int error;
511
506
 
512
507
  (void) extra(HA_EXTRA_KEYREAD);
513
 
  getTable()->mark_columns_used_by_index_no_reset(getTable()->getShare()->next_number_index);
514
 
  doStartIndexScan(getTable()->getShare()->next_number_index, 1);
515
 
  if (getTable()->getShare()->next_number_keypart == 0)
 
508
  table->mark_columns_used_by_index_no_reset(table->getShare()->next_number_index);
 
509
  doStartIndexScan(table->getShare()->next_number_index, 1);
 
510
  if (table->getShare()->next_number_keypart == 0)
516
511
  {                                             // Autoincrement at key-start
517
 
    error=index_last(getTable()->getUpdateRecord());
 
512
    error=index_last(table->getUpdateRecord());
518
513
  }
519
514
  else
520
515
  {
521
516
    unsigned char key[MAX_KEY_LENGTH];
522
 
    key_copy(key, getTable()->getInsertRecord(),
523
 
             getTable()->key_info + getTable()->getShare()->next_number_index,
524
 
             getTable()->getShare()->next_number_key_offset);
525
 
    error= index_read_map(getTable()->getUpdateRecord(), key,
526
 
                          make_prev_keypart_map(getTable()->getShare()->next_number_keypart),
 
517
    key_copy(key, table->getInsertRecord(),
 
518
             table->key_info + table->getShare()->next_number_index,
 
519
             table->getShare()->next_number_key_offset);
 
520
    error= index_read_map(table->getUpdateRecord(), key,
 
521
                          make_prev_keypart_map(table->getShare()->next_number_keypart),
527
522
                          HA_READ_PREFIX_LAST);
528
523
  }
529
524
 
530
525
  if (error)
531
526
    nr=1;
532
527
  else
533
 
    nr= ((uint64_t) getTable()->found_next_number_field->
534
 
         val_int_offset(getTable()->getShare()->rec_buff_length)+1);
 
528
    nr= ((uint64_t) table->found_next_number_field->
 
529
         val_int_offset(table->getShare()->rec_buff_length)+1);
535
530
  doEndIndexScan();
536
531
  (void) extra(HA_EXTRA_NO_KEYREAD);
537
532
 
538
 
  if (getTable()->getShare()->getTableMessage()->options().auto_increment_value() > nr)
539
 
    nr= getTable()->getShare()->getTableMessage()->options().auto_increment_value();
 
533
  if (table->getShare()->getTableProto()->options().auto_increment_value() > nr)
 
534
    nr= table->getShare()->getTableProto()->options().auto_increment_value();
540
535
 
541
536
  return nr;
542
537
}
569
564
{
570
565
  pthread_mutex_lock(&haildb_mutex);
571
566
 
572
 
  HailDBEngine *a_engine= static_cast<HailDBEngine *>(getEngine());
 
567
  HailDBEngine *a_engine= static_cast<HailDBEngine *>(engine);
573
568
  share= a_engine->findOpenTable(table_name);
574
569
 
575
570
  if (!share)
583
578
      return(NULL);
584
579
    }
585
580
 
586
 
    if (getTable()->found_next_number_field)
 
581
    if (table->found_next_number_field)
587
582
    {
588
583
      share->auto_increment_value.fetch_and_store(
589
584
                                  a_engine->getInitialAutoIncrementValue(this));
612
607
  pthread_mutex_lock(&haildb_mutex);
613
608
  if (!--share->use_count)
614
609
  {
615
 
    HailDBEngine *a_engine= static_cast<HailDBEngine *>(getEngine());
 
610
    HailDBEngine *a_engine= static_cast<HailDBEngine *>(engine);
616
611
    a_engine->deleteOpenTable(share->table_name);
617
612
    delete share;
618
613
  }
649
644
 
650
645
  /* the below is adapted from ha_innodb.cc */
651
646
 
652
 
  const uint32_t sql_command = session->getSqlCommand();
 
647
  const uint32_t sql_command = session_sql_command(session);
653
648
 
654
649
  if (sql_command == SQLCOM_DROP_TABLE) {
655
650
 
680
675
    unexpected if an obsolete consistent read view would be
681
676
    used. */
682
677
 
683
 
    enum_tx_isolation isolation_level= session->getTxIsolation();
 
678
    enum_tx_isolation isolation_level= session_tx_isolation(session);
684
679
 
685
680
    if (isolation_level != ISO_SERIALIZABLE
686
681
        && (lock_type == TL_READ || lock_type == TL_READ_NO_INSERT)
723
718
 
724
719
    if ((lock_type >= TL_WRITE_CONCURRENT_INSERT
725
720
         && lock_type <= TL_WRITE)
726
 
        && ! session->doing_tablespace_operation()
 
721
        && !session_tablespace_op(session)
727
722
        && sql_command != SQLCOM_TRUNCATE
728
723
        && sql_command != SQLCOM_CREATE_TABLE) {
729
724
 
800
795
  return &name[l];
801
796
}
802
797
 
803
 
static void TableIdentifier_to_haildb_name(const identifier::Table &identifier, std::string *str)
 
798
static void TableIdentifier_to_haildb_name(const TableIdentifier &identifier, std::string *str)
804
799
{
805
800
  str->assign(table_path_to_haildb_name(identifier.getPath().c_str()));
806
801
}
807
802
 
808
803
HailDBCursor::HailDBCursor(drizzled::plugin::StorageEngine &engine_arg,
809
 
                           Table &table_arg)
 
804
                           TableShare &table_arg)
810
805
  :Cursor(engine_arg, table_arg),
811
806
   ib_lock_mode(IB_LOCK_NONE),
812
807
   write_can_replace(false),
829
824
int HailDBCursor::open(const char *name, int, uint32_t)
830
825
{
831
826
  const char* haildb_table_name= table_path_to_haildb_name(name);
832
 
  ib_err_t err= ib_table_get_id(haildb_table_name, &table_id);
 
827
  ib_err_t err= ib_cursor_open_table(haildb_table_name, NULL, &cursor);
833
828
  bool has_hidden_primary_key= false;
834
829
  ib_id_t idx_id;
835
830
 
836
831
  if (err != DB_SUCCESS)
837
 
    return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
838
 
 
839
 
  err= ib_cursor_open_table_using_id(table_id, NULL, &cursor);
840
 
  cursor_is_sec_index= false;
841
 
 
842
 
  if (err != DB_SUCCESS)
843
 
    return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
 
832
    return ib_err_t_to_drizzle_error(err);
844
833
 
845
834
  err= ib_index_get_id(haildb_table_name, "HIDDEN_PRIMARY", &idx_id);
846
835
 
852
841
  lock.init(&share->lock);
853
842
 
854
843
 
855
 
  if (getTable()->getShare()->getPrimaryKey() != MAX_KEY)
856
 
    ref_length= getTable()->key_info[getTable()->getShare()->getPrimaryKey()].key_length;
 
844
  if (table->getShare()->getPrimaryKey() != MAX_KEY)
 
845
    ref_length= table->key_info[table->getShare()->getPrimaryKey()].key_length;
857
846
  else if (share->has_hidden_primary_key)
858
847
    ref_length= sizeof(uint64_t);
859
848
  else
860
849
  {
861
 
    unsigned int keynr= get_first_unique_index(*getTable());
862
 
    ref_length= getTable()->key_info[keynr].key_length;
 
850
    unsigned int keynr= get_first_unique_index(*table);
 
851
    ref_length= table->key_info[keynr].key_length;
863
852
  }
864
853
 
865
854
  in_table_scan= false;
871
860
{
872
861
  ib_err_t err= ib_cursor_close(cursor);
873
862
  if (err != DB_SUCCESS)
874
 
    return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
 
863
    return ib_err_t_to_drizzle_error(err);
875
864
 
876
865
  free_share();
877
866
 
904
893
{
905
894
  ib_col_attr_t column_attr= IB_COL_NONE;
906
895
 
907
 
  if (field.has_constraints() && field.constraints().is_notnull())
 
896
  if (field.has_constraints() && ! field.constraints().is_nullable())
908
897
    column_attr= IB_COL_NOT_NULL;
909
898
 
910
899
  switch (field.type())
935
924
    *err= ib_table_schema_add_col(schema, field.name().c_str(), IB_INT,
936
925
                                  column_attr, 0, 4);
937
926
    break;
938
 
  case message::Table::Field::EPOCH:
 
927
  case message::Table::Field::TIMESTAMP:
939
928
    *err= ib_table_schema_add_col(schema, field.name().c_str(), IB_INT,
940
929
                                  column_attr, 0, 8);
941
930
    break;
1035
1024
 
1036
1025
int HailDBEngine::doCreateTable(Session &session,
1037
1026
                                        Table& table_obj,
1038
 
                                        const drizzled::identifier::Table &identifier,
 
1027
                                        const drizzled::TableIdentifier &identifier,
1039
1028
                                        drizzled::message::Table& table_message)
1040
1029
{
1041
1030
  ib_tbl_sch_t haildb_table_schema= NULL;
1079
1068
                        ER_CANT_CREATE_TABLE,
1080
1069
                        _("Cannot create table %s. HailDB Error %d (%s)\n"),
1081
1070
                        haildb_table_name.c_str(), haildb_err, ib_strerror(haildb_err));
1082
 
    return ib_err_t_to_drizzle_error(&session, haildb_err);
 
1071
    return ib_err_t_to_drizzle_error(haildb_err);
1083
1072
  }
1084
1073
 
1085
1074
  for (int colnr= 0; colnr < table_message.field_size() ; colnr++)
1100
1089
                            " HailDB Error %d (%s)\n"),
1101
1090
                          field.name().c_str(), haildb_table_name.c_str(),
1102
1091
                          haildb_err, ib_strerror(haildb_err));
1103
 
      return ib_err_t_to_drizzle_error(&session, haildb_err);
 
1092
      return ib_err_t_to_drizzle_error(haildb_err);
1104
1093
    }
1105
1094
    if (field_err != 0)
1106
1095
      return field_err;
1225
1214
 
1226
1215
  if (table_message.type() == message::Table::TEMPORARY)
1227
1216
  {
1228
 
    session.getMessageCache().storeTableMessage(identifier, table_message);
 
1217
    session.storeTableMessage(identifier, table_message);
1229
1218
    haildb_err= DB_SUCCESS;
1230
1219
  }
1231
1220
  else
1248
1237
                        _("Cannot create table %s. HailDB Error %d (%s)\n"),
1249
1238
                        haildb_table_name.c_str(),
1250
1239
                        haildb_err, ib_strerror(haildb_err));
1251
 
    return ib_err_t_to_drizzle_error(&session, haildb_err);
 
1240
    return ib_err_t_to_drizzle_error(haildb_err);
1252
1241
  }
1253
1242
 
1254
1243
  return 0;
1291
1280
}
1292
1281
 
1293
1282
int HailDBEngine::doDropTable(Session &session,
1294
 
                                      const identifier::Table &identifier)
 
1283
                                      const TableIdentifier &identifier)
1295
1284
{
1296
1285
  ib_trx_t haildb_schema_transaction;
1297
1286
  ib_err_t haildb_err;
1317
1306
 
1318
1307
  if (identifier.getType() == message::Table::TEMPORARY)
1319
1308
  {
1320
 
      session.getMessageCache().removeTableMessage(identifier);
 
1309
      session.removeTableMessage(identifier);
1321
1310
      delete_table_message_from_haildb(haildb_schema_transaction,
1322
1311
                                       haildb_table_name.c_str());
1323
1312
  }
1373
1362
  return 0;
1374
1363
}
1375
1364
 
1376
 
static ib_err_t rename_table_message(ib_trx_t transaction, const identifier::Table &from_identifier, const identifier::Table &to_identifier)
 
1365
static ib_err_t rename_table_message(ib_trx_t transaction, const TableIdentifier &from_identifier, const TableIdentifier &to_identifier)
1377
1366
{
1378
1367
  ib_crsr_t cursor;
1379
1368
  ib_tpl_t search_tuple;
1464
1453
}
1465
1454
 
1466
1455
int HailDBEngine::doRenameTable(drizzled::Session &session,
1467
 
                                        const drizzled::identifier::Table &from,
1468
 
                                        const drizzled::identifier::Table &to)
 
1456
                                        const drizzled::TableIdentifier &from,
 
1457
                                        const drizzled::TableIdentifier &to)
1469
1458
{
1470
1459
  ib_trx_t haildb_schema_transaction;
1471
1460
  ib_err_t err;
1475
1464
  if (to.getType() == message::Table::TEMPORARY
1476
1465
      && from.getType() == message::Table::TEMPORARY)
1477
1466
  {
1478
 
    session.getMessageCache().renameTableMessage(from, to);
 
1467
    session.renameTableMessage(from, to);
1479
1468
    return 0;
1480
1469
  }
1481
1470
 
1515
1504
  assert(rollback_err == DB_SUCCESS);
1516
1505
  rollback_err= ib_trx_rollback(haildb_schema_transaction);
1517
1506
  assert(rollback_err == DB_SUCCESS);
1518
 
  return ib_err_t_to_drizzle_error(&session, err);
 
1507
  return ib_err_t_to_drizzle_error(err);
1519
1508
}
1520
1509
 
1521
1510
void HailDBEngine::getTableNamesInSchemaFromHailDB(
1522
 
                                 const drizzled::identifier::Schema &schema,
 
1511
                                 const drizzled::SchemaIdentifier &schema,
1523
1512
                                 drizzled::plugin::TableNameList *set_of_names,
1524
 
                                 drizzled::identifier::Table::vector *identifiers)
 
1513
                                 drizzled::TableIdentifiers *identifiers)
1525
1514
{
1526
1515
  ib_trx_t   transaction;
1527
1516
  ib_crsr_t  cursor;
1551
1540
    {
1552
1541
      BOOST_FOREACH(std::string table_name, haildb_system_table_names)
1553
1542
      {
1554
 
        identifiers->push_back(identifier::Table(schema.getSchemaName(),
 
1543
        identifiers->push_back(TableIdentifier(schema.getSchemaName(),
1555
1544
                                               table_name));
1556
1545
      }
1557
1546
    }
1594
1583
      if (set_of_names)
1595
1584
        set_of_names->insert(just_table_name);
1596
1585
      if (identifiers)
1597
 
        identifiers->push_back(identifier::Table(schema.getSchemaName(), just_table_name));
 
1586
        identifiers->push_back(TableIdentifier(schema.getSchemaName(), just_table_name));
1598
1587
    }
1599
1588
 
1600
1589
 
1613
1602
}
1614
1603
 
1615
1604
void HailDBEngine::doGetTableIdentifiers(drizzled::CachedDirectory &,
1616
 
                                                 const drizzled::identifier::Schema &schema,
1617
 
                                                 drizzled::identifier::Table::vector &identifiers)
 
1605
                                                 const drizzled::SchemaIdentifier &schema,
 
1606
                                                 drizzled::TableIdentifiers &identifiers)
1618
1607
{
1619
1608
  getTableNamesInSchemaFromHailDB(schema, NULL, &identifiers);
1620
1609
}
1739
1728
}
1740
1729
 
1741
1730
int HailDBEngine::doGetTableDefinition(Session &session,
1742
 
                                               const identifier::Table &identifier,
 
1731
                                               const TableIdentifier &identifier,
1743
1732
                                               drizzled::message::Table &table)
1744
1733
{
1745
1734
  ib_crsr_t haildb_cursor= NULL;
1746
1735
  string haildb_table_name;
1747
1736
 
1748
1737
  /* Check temporary tables!? */
1749
 
  if (session.getMessageCache().getTableMessage(identifier, table))
 
1738
  if (session.getTableMessage(identifier, table))
1750
1739
    return EEXIST;
1751
1740
 
1752
1741
  TableIdentifier_to_haildb_name(identifier, &haildb_table_name);
1768
1757
}
1769
1758
 
1770
1759
bool HailDBEngine::doDoesTableExist(Session &,
1771
 
                                    const identifier::Table& identifier)
 
1760
                                    const TableIdentifier& identifier)
1772
1761
{
1773
1762
  ib_crsr_t haildb_cursor;
1774
1763
  string haildb_table_name;
1793
1782
  return("BTREE");
1794
1783
}
1795
1784
 
1796
 
static ib_err_t write_row_to_haildb_tuple(const unsigned char* buf,
1797
 
                                          Field **fields, ib_tpl_t tuple)
 
1785
static ib_err_t write_row_to_haildb_tuple(Field **fields, ib_tpl_t tuple)
1798
1786
{
1799
1787
  int colnr= 0;
1800
1788
  ib_err_t err= DB_ERROR;
1801
 
  ptrdiff_t row_offset= buf - (*fields)->getTable()->getInsertRecord();
1802
1789
 
1803
1790
  for (Field **field= fields; *field; field++, colnr++)
1804
1791
  {
1805
 
    (**field).move_field_offset(row_offset);
1806
 
 
1807
1792
    if (! (**field).isWriteSet() && (**field).is_null())
1808
 
    {
1809
 
      (**field).move_field_offset(-row_offset);
1810
1793
      continue;
1811
 
    }
1812
1794
 
1813
1795
    if ((**field).is_null())
1814
1796
    {
1815
1797
      err= ib_col_set_value(tuple, colnr, NULL, IB_SQL_NULL);
1816
1798
      assert(err == DB_SUCCESS);
1817
 
      (**field).move_field_offset(-row_offset);
1818
1799
      continue;
1819
1800
    }
1820
1801
 
1826
1807
      */
1827
1808
      String str;
1828
1809
      (**field).setReadSet();
1829
 
      (**field).val_str_internal(&str);
 
1810
      (**field).val_str(&str);
1830
1811
      err= ib_col_set_value(tuple, colnr, str.ptr(), str.length());
1831
1812
    }
1832
1813
    else if ((**field).type() == DRIZZLE_TYPE_ENUM)
1852
1833
    }
1853
1834
 
1854
1835
    assert (err == DB_SUCCESS);
1855
 
 
1856
 
    (**field).move_field_offset(-row_offset);
1857
1836
  }
1858
1837
 
1859
1838
  return err;
1898
1877
  ib_err_t err;
1899
1878
  int ret= 0;
1900
1879
 
1901
 
  ib_trx_t transaction= *get_trx(getTable()->in_use);
 
1880
  ib_trx_t transaction= *get_trx(table->in_use);
1902
1881
 
1903
1882
  tuple= ib_clust_read_tuple_create(cursor);
1904
1883
 
1905
 
  if (cursor_is_sec_index)
1906
 
  {
1907
 
    err= ib_cursor_close(cursor);
1908
 
    assert(err == DB_SUCCESS);
1909
 
 
1910
 
    err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
1911
 
 
1912
 
    if (err != DB_SUCCESS)
1913
 
      return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
1914
 
 
1915
 
    cursor_is_sec_index= false;
1916
 
  }
1917
 
  else
1918
 
  {
1919
 
    ib_cursor_attach_trx(cursor, transaction);
1920
 
  }
 
1884
  ib_cursor_attach_trx(cursor, transaction);
1921
1885
 
1922
1886
  err= ib_cursor_first(cursor);
1923
1887
  if (current_session->lex->sql_command == SQLCOM_CREATE_TABLE
1935
1899
     * yuck.
1936
1900
     */
1937
1901
 
1938
 
    HailDBEngine *storage_engine= static_cast<HailDBEngine*>(getEngine());
 
1902
    HailDBEngine *storage_engine= static_cast<HailDBEngine*>(engine);
1939
1903
    err= ib_cursor_reset(cursor);
1940
1904
    storage_engine->doCommit(current_session, true);
1941
1905
    storage_engine->doStartTransaction(current_session, START_TRANS_NO_OPTIONS);
1942
 
    transaction= *get_trx(getTable()->in_use);
 
1906
    transaction= *get_trx(table->in_use);
1943
1907
    assert(err == DB_SUCCESS);
1944
1908
    ib_cursor_attach_trx(cursor, transaction);
1945
1909
    err= ib_cursor_first(cursor);
1948
1912
  assert(err == DB_SUCCESS || err == DB_END_OF_INDEX);
1949
1913
 
1950
1914
 
1951
 
  if (getTable()->next_number_field)
 
1915
  if (table->next_number_field)
1952
1916
  {
1953
1917
    update_auto_increment();
1954
1918
 
1955
 
    uint64_t temp_auto= getTable()->next_number_field->val_int();
 
1919
    uint64_t temp_auto= table->next_number_field->val_int();
1956
1920
 
1957
 
    if (temp_auto <= innobase_get_int_col_max_value(getTable()->next_number_field))
 
1921
    if (temp_auto <= innobase_get_int_col_max_value(table->next_number_field))
1958
1922
    {
1959
1923
      while (true)
1960
1924
      {
1976
1940
 
1977
1941
  }
1978
1942
 
1979
 
  write_row_to_haildb_tuple(record, getTable()->getFields(), tuple);
 
1943
  write_row_to_haildb_tuple(table->getFields(), tuple);
1980
1944
 
1981
1945
  if (share->has_hidden_primary_key)
1982
1946
  {
1983
 
    err= ib_tuple_write_u64(tuple, getTable()->getShare()->sizeFields(),
1984
 
                            share->hidden_pkey_auto_increment_value.fetch_and_increment());
 
1947
    err= ib_tuple_write_u64(tuple, table->getShare()->fields, share->hidden_pkey_auto_increment_value.fetch_and_increment());
1985
1948
  }
1986
1949
 
1987
1950
  err= ib_cursor_insert_row(cursor, tuple);
1990
1953
  {
1991
1954
    if (write_can_replace)
1992
1955
    {
1993
 
      store_key_value_from_haildb(getTable()->key_info + getTable()->getShare()->getPrimaryKey(),
 
1956
      store_key_value_from_haildb(table->key_info + table->getShare()->getPrimaryKey(),
1994
1957
                                  ref, ref_length, record);
1995
1958
 
1996
1959
      ib_tpl_t search_tuple= ib_clust_search_tuple_create(cursor);
1997
1960
 
1998
1961
      fill_ib_search_tpl_from_drizzle_key(search_tuple,
1999
 
                                          getTable()->key_info + 0,
 
1962
                                          table->key_info + 0,
2000
1963
                                          ref, ref_length);
2001
1964
 
2002
1965
      int res;
2010
1973
      err= ib_cursor_first(cursor);
2011
1974
      assert(err == DB_SUCCESS || err == DB_END_OF_INDEX);
2012
1975
 
2013
 
      write_row_to_haildb_tuple(record, getTable()->getFields(), tuple);
 
1976
      write_row_to_haildb_tuple(table->getFields(), tuple);
2014
1977
 
2015
1978
      err= ib_cursor_insert_row(cursor, tuple);
2016
1979
      assert(err==DB_SUCCESS); // probably be nice and process errors
2019
1982
      ret= HA_ERR_FOUND_DUPP_KEY;
2020
1983
  }
2021
1984
  else if (err != DB_SUCCESS)
2022
 
    ret= ib_err_t_to_drizzle_error(getTable()->getSession(), err);
 
1985
    ret= ib_err_t_to_drizzle_error(err);
2023
1986
 
2024
1987
  tuple= ib_tuple_clear(tuple);
2025
1988
  ib_tuple_delete(tuple);
2026
 
  tuple= NULL;
2027
1989
  err= ib_cursor_reset(cursor);
2028
1990
 
2029
1991
  return ret;
2030
1992
}
2031
1993
 
2032
 
int HailDBCursor::doUpdateRecord(const unsigned char *old_data,
2033
 
                                 unsigned char *new_data)
 
1994
int HailDBCursor::doUpdateRecord(const unsigned char *,
 
1995
                                         unsigned char *)
2034
1996
{
2035
1997
  ib_tpl_t update_tuple;
2036
1998
  ib_err_t err;
2037
 
  bool created_tuple= false;
2038
1999
 
2039
2000
  update_tuple= ib_clust_read_tuple_create(cursor);
2040
2001
 
2041
 
  if (tuple == NULL)
2042
 
  {
2043
 
    ib_trx_t transaction= *get_trx(getTable()->in_use);
2044
 
 
2045
 
    if (cursor_is_sec_index)
2046
 
    {
2047
 
      err= ib_cursor_close(cursor);
2048
 
      assert(err == DB_SUCCESS);
2049
 
 
2050
 
      err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
2051
 
 
2052
 
      if (err != DB_SUCCESS)
2053
 
        return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2054
 
      cursor_is_sec_index= false;
2055
 
    }
2056
 
    else
2057
 
    {
2058
 
      ib_cursor_attach_trx(cursor, transaction);
2059
 
    }
2060
 
 
2061
 
    store_key_value_from_haildb(getTable()->key_info + getTable()->getShare()->getPrimaryKey(),
2062
 
                                  ref, ref_length, old_data);
2063
 
 
2064
 
    ib_tpl_t search_tuple= ib_clust_search_tuple_create(cursor);
2065
 
 
2066
 
    fill_ib_search_tpl_from_drizzle_key(search_tuple,
2067
 
                                        getTable()->key_info + 0,
2068
 
                                        ref, ref_length);
2069
 
 
2070
 
    err= ib_cursor_set_lock_mode(cursor, IB_LOCK_X);
2071
 
    assert(err == DB_SUCCESS);
2072
 
 
2073
 
    int res;
2074
 
    err= ib_cursor_moveto(cursor, search_tuple, IB_CUR_GE, &res);
2075
 
    assert(err == DB_SUCCESS);
2076
 
 
2077
 
    tuple= ib_clust_read_tuple_create(cursor);
2078
 
 
2079
 
    err= ib_cursor_read_row(cursor, tuple);
2080
 
    assert(err == DB_SUCCESS);// FIXME
2081
 
 
2082
 
    created_tuple= true;
2083
 
  }
2084
 
 
2085
2002
  err= ib_tuple_copy(update_tuple, tuple);
2086
2003
  assert(err == DB_SUCCESS);
2087
2004
 
2088
 
  write_row_to_haildb_tuple(new_data, getTable()->getFields(), update_tuple);
 
2005
  write_row_to_haildb_tuple(table->getFields(), update_tuple);
2089
2006
 
2090
2007
  err= ib_cursor_update_row(cursor, tuple, update_tuple);
2091
2008
 
2092
2009
  ib_tuple_delete(update_tuple);
2093
2010
 
2094
 
  if (created_tuple)
2095
 
  {
2096
 
    ib_err_t ib_err= ib_cursor_reset(cursor); //fixme check error
2097
 
    assert(ib_err == DB_SUCCESS);
2098
 
    tuple= ib_tuple_clear(tuple);
2099
 
    ib_tuple_delete(tuple);
2100
 
    tuple= NULL;
2101
 
  }
2102
 
 
2103
2011
  advance_cursor= true;
2104
2012
 
2105
 
  return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
 
2013
  if (err == DB_SUCCESS)
 
2014
    return 0;
 
2015
  else if (err == DB_DUPLICATE_KEY)
 
2016
    return HA_ERR_FOUND_DUPP_KEY;
 
2017
  else
 
2018
    return -1;
2106
2019
}
2107
2020
 
2108
2021
int HailDBCursor::doDeleteRecord(const unsigned char *)
2109
2022
{
2110
2023
  ib_err_t err;
2111
2024
 
2112
 
  assert(ib_cursor_is_positioned(cursor) == IB_TRUE);
2113
2025
  err= ib_cursor_delete_row(cursor);
 
2026
  if (err != DB_SUCCESS)
 
2027
    return -1; // FIXME
2114
2028
 
2115
2029
  advance_cursor= true;
2116
 
 
2117
 
  return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
 
2030
  return 0;
2118
2031
}
2119
2032
 
2120
2033
int HailDBCursor::delete_all_rows(void)
2121
2034
{
2122
2035
  /* I *think* ib_truncate is non-transactional....
2123
2036
     so only support TRUNCATE and not DELETE FROM t;
2124
 
     (this is what ha_innodb does)
 
2037
     (this is what ha_haildb does)
2125
2038
  */
2126
 
  if (getTable()->in_use->getSqlCommand() != SQLCOM_TRUNCATE)
 
2039
  if (session_sql_command(table->in_use) != SQLCOM_TRUNCATE)
2127
2040
    return HA_ERR_WRONG_COMMAND;
2128
2041
 
2129
2042
  ib_id_t id;
2131
2044
 
2132
2045
  ib_trx_t transaction= ib_trx_begin(IB_TRX_REPEATABLE_READ);
2133
2046
 
2134
 
  if (cursor_is_sec_index)
2135
 
  {
2136
 
    err= ib_cursor_close(cursor);
2137
 
    assert(err == DB_SUCCESS);
2138
 
 
2139
 
    err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
2140
 
 
2141
 
    if (err != DB_SUCCESS)
2142
 
      return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2143
 
    cursor_is_sec_index= false;
2144
 
  }
2145
 
  else
2146
 
  {
2147
 
    ib_cursor_attach_trx(cursor, transaction);
2148
 
  }
 
2047
  ib_cursor_attach_trx(cursor, transaction);
2149
2048
 
2150
2049
  err= ib_schema_lock_exclusive(transaction);
2151
2050
  if (err != DB_SUCCESS)
2152
2051
  {
2153
2052
    ib_err_t rollback_err= ib_trx_rollback(transaction);
2154
2053
 
2155
 
    push_warning_printf(getTable()->in_use, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
 
2054
    push_warning_printf(table->in_use, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
2156
2055
                        ER_CANT_DELETE_FILE,
2157
2056
                        _("Cannot Lock HailDB Data Dictionary. HailDB Error %d (%s)\n"),
2158
2057
                        err, ib_strerror(err));
2181
2080
  ib_schema_unlock(transaction);
2182
2081
  ib_err_t rollback_err= ib_trx_rollback(transaction);
2183
2082
  assert(rollback_err == DB_SUCCESS);
2184
 
  return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
 
2083
  return err;
2185
2084
}
2186
2085
 
2187
2086
int HailDBCursor::doStartTableScan(bool)
2188
2087
{
2189
 
  ib_err_t err= DB_SUCCESS;
 
2088
  ib_err_t err;
2190
2089
  ib_trx_t transaction;
2191
2090
 
2192
2091
  if (in_table_scan)
2193
2092
    doEndTableScan();
2194
2093
  in_table_scan= true;
2195
2094
 
2196
 
  transaction= *get_trx(getTable()->in_use);
 
2095
  transaction= *get_trx(table->in_use);
2197
2096
 
2198
2097
  assert(transaction != NULL);
2199
2098
 
2200
 
  if (cursor_is_sec_index)
2201
 
  {
2202
 
    err= ib_cursor_close(cursor);
2203
 
    assert(err == DB_SUCCESS);
2204
 
 
2205
 
    err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
2206
 
    cursor_is_sec_index= false;
2207
 
  }
2208
 
  else
2209
 
  {
2210
 
    ib_cursor_attach_trx(cursor, transaction);
2211
 
  }
2212
 
 
2213
 
  if (err != DB_SUCCESS)
2214
 
    return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
 
2099
  ib_cursor_attach_trx(cursor, transaction);
2215
2100
 
2216
2101
  err= ib_cursor_set_lock_mode(cursor, ib_lock_mode);
2217
2102
  assert(err == DB_SUCCESS); // FIXME
2221
2106
  err= ib_cursor_first(cursor);
2222
2107
  if (err != DB_SUCCESS && err != DB_END_OF_INDEX)
2223
2108
  {
2224
 
    int reset_err= ib_cursor_reset(cursor);
2225
 
    assert(reset_err == DB_SUCCESS);
2226
 
    return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
 
2109
    previous_error= ib_err_t_to_drizzle_error(err);
 
2110
    err= ib_cursor_reset(cursor);
 
2111
    return previous_error;
2227
2112
  }
2228
2113
 
2229
2114
  advance_cursor= false;
2230
2115
 
 
2116
  previous_error= 0;
2231
2117
  return(0);
2232
2118
}
2233
2119
 
2234
 
int read_row_from_haildb(Session *session, unsigned char* buf, ib_crsr_t cursor, ib_tpl_t tuple, Table* table, bool has_hidden_primary_key, uint64_t *hidden_pkey, drizzled::memory::Root **blobroot)
 
2120
int read_row_from_haildb(unsigned char* buf, ib_crsr_t cursor, ib_tpl_t tuple, Table* table, bool has_hidden_primary_key, uint64_t *hidden_pkey, drizzled::memory::Root **blobroot)
2235
2121
{
2236
2122
  ib_err_t err;
2237
2123
  ptrdiff_t row_offset= buf - table->getInsertRecord();
2238
2124
 
2239
2125
  err= ib_cursor_read_row(cursor, tuple);
2240
2126
 
2241
 
  if (err == DB_RECORD_NOT_FOUND)
 
2127
  if (err != DB_SUCCESS) // FIXME
2242
2128
    return HA_ERR_END_OF_FILE;
2243
 
  if (err != DB_SUCCESS)
2244
 
    return ib_err_t_to_drizzle_error(session, err);
2245
2129
 
2246
2130
  int colnr= 0;
2247
2131
 
2248
2132
  /* We need the primary key for ::position() to work */
2249
 
  if (table->getShare()->getPrimaryKey() != MAX_KEY)
2250
 
    table->mark_columns_used_by_index_no_reset(table->getShare()->getPrimaryKey());
 
2133
  if (table->s->getPrimaryKey() != MAX_KEY)
 
2134
    table->mark_columns_used_by_index_no_reset(table->s->getPrimaryKey());
2251
2135
 
2252
2136
  for (Field **field= table->getFields() ; *field ; field++, colnr++)
2253
2137
  {
2254
2138
    if (! (**field).isReadSet())
2255
 
      (**field).setReadSet(); /* Fucking broken API screws us royally. */
 
2139
      continue;
2256
2140
 
2257
2141
    (**field).move_field_offset(row_offset);
2258
2142
 
2262
2146
    if (length == IB_SQL_NULL)
2263
2147
    {
2264
2148
      (**field).set_null();
2265
 
      (**field).move_field_offset(-row_offset);
2266
2149
      continue;
2267
2150
    }
2268
2151
    else
2306
2189
 
2307
2190
    (**field).move_field_offset(-row_offset);
2308
2191
 
2309
 
    if (err != DB_SUCCESS)
2310
 
      return ib_err_t_to_drizzle_error(session, err);
2311
2192
  }
2312
2193
 
2313
2194
  if (has_hidden_primary_key)
2315
2196
    err= ib_tuple_read_u64(tuple, colnr, hidden_pkey);
2316
2197
  }
2317
2198
 
2318
 
  return ib_err_t_to_drizzle_error(session, err);
 
2199
  return 0;
2319
2200
}
2320
2201
 
2321
2202
int HailDBCursor::rnd_next(unsigned char *buf)
2323
2204
  ib_err_t err;
2324
2205
  int ret;
2325
2206
 
 
2207
  if (previous_error)
 
2208
    return previous_error;
 
2209
 
2326
2210
  if (advance_cursor)
2327
 
  {
2328
2211
    err= ib_cursor_next(cursor);
2329
 
    if (err != DB_SUCCESS)
2330
 
      return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2331
 
  }
2332
2212
 
2333
2213
  tuple= ib_tuple_clear(tuple);
2334
 
  ret= read_row_from_haildb(getTable()->getSession(), buf, cursor, tuple,
2335
 
                            getTable(),
 
2214
  ret= read_row_from_haildb(buf, cursor, tuple, table,
2336
2215
                            share->has_hidden_primary_key,
2337
2216
                            &hidden_autoinc_pkey_position);
2338
2217
 
2345
2224
  ib_err_t err;
2346
2225
 
2347
2226
  ib_tuple_delete(tuple);
2348
 
  tuple= NULL;
2349
2227
  err= ib_cursor_reset(cursor);
2350
2228
  assert(err == DB_SUCCESS);
2351
2229
  in_table_scan= false;
2352
 
  return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
 
2230
  previous_error= 0;
 
2231
  return 0;
2353
2232
}
2354
2233
 
2355
2234
int HailDBCursor::rnd_pos(unsigned char *buf, unsigned char *pos)
2363
2242
  {
2364
2243
    err= ib_col_set_value(search_tuple, 0,
2365
2244
                          ((uint64_t*)(pos)), sizeof(uint64_t));
2366
 
    if (err != DB_SUCCESS)
2367
 
      return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2368
2245
  }
2369
2246
  else
2370
2247
  {
2371
2248
    unsigned int keynr;
2372
 
    if (getTable()->getShare()->getPrimaryKey() != MAX_KEY)
2373
 
      keynr= getTable()->getShare()->getPrimaryKey();
 
2249
    if (table->getShare()->getPrimaryKey() != MAX_KEY)
 
2250
      keynr= table->getShare()->getPrimaryKey();
2374
2251
    else
2375
 
      keynr= get_first_unique_index(*getTable());
 
2252
      keynr= get_first_unique_index(*table);
2376
2253
 
2377
2254
    fill_ib_search_tpl_from_drizzle_key(search_tuple,
2378
 
                                        getTable()->key_info + keynr,
 
2255
                                        table->key_info + keynr,
2379
2256
                                        pos, ref_length);
2380
2257
  }
2381
2258
 
2382
2259
  err= ib_cursor_moveto(cursor, search_tuple, IB_CUR_GE, &res);
2383
 
  if (err != DB_SUCCESS)
2384
 
    return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
 
2260
  assert(err == DB_SUCCESS);
2385
2261
 
2386
2262
  assert(res==0);
2387
2263
  if (res != 0)
2392
2268
  tuple= ib_tuple_clear(tuple);
2393
2269
 
2394
2270
  if (ret == 0)
2395
 
    ret= read_row_from_haildb(getTable()->getSession(), buf, cursor, tuple,
2396
 
                              getTable(),
 
2271
    ret= read_row_from_haildb(buf, cursor, tuple, table,
2397
2272
                              share->has_hidden_primary_key,
2398
2273
                              &hidden_autoinc_pkey_position);
2399
2274
 
2431
2306
      }
2432
2307
 
2433
2308
      String str;
2434
 
      field->val_str_internal(&str);
 
2309
      field->val_str(&str);
2435
2310
 
2436
2311
      *ref++= (char)(str.length() & 0x000000ff);
2437
2312
      *ref++= (char)((str.length()>>8) & 0x000000ff);
2464
2339
  else
2465
2340
  {
2466
2341
    unsigned int keynr;
2467
 
    if (getTable()->getShare()->getPrimaryKey() != MAX_KEY)
2468
 
      keynr= getTable()->getShare()->getPrimaryKey();
 
2342
    if (table->getShare()->getPrimaryKey() != MAX_KEY)
 
2343
      keynr= table->getShare()->getPrimaryKey();
2469
2344
    else
2470
 
      keynr= get_first_unique_index(*getTable());
 
2345
      keynr= get_first_unique_index(*table);
2471
2346
 
2472
 
    store_key_value_from_haildb(getTable()->key_info + keynr,
 
2347
    store_key_value_from_haildb(table->key_info + keynr,
2473
2348
                                ref, ref_length, record);
2474
2349
  }
2475
2350
 
2478
2353
 
2479
2354
double HailDBCursor::scan_time()
2480
2355
{
2481
 
  ib_table_stats_t table_stats;
2482
 
  ib_err_t err;
2483
 
 
2484
 
  err= ib_get_table_statistics(cursor, &table_stats, sizeof(table_stats));
2485
 
 
2486
 
  /* Approximate I/O seeks for full table scan */
2487
 
  return (double) (table_stats.stat_clustered_index_size / 16384);
 
2356
  return 0.1;
2488
2357
}
2489
2358
 
2490
2359
int HailDBCursor::info(uint32_t flag)
2491
2360
{
2492
 
  ib_table_stats_t table_stats;
2493
 
  ib_err_t err;
2494
 
 
2495
 
  if (flag & HA_STATUS_VARIABLE)
2496
 
  {
2497
 
    err= ib_get_table_statistics(cursor, &table_stats, sizeof(table_stats));
2498
 
 
2499
 
    stats.records= table_stats.stat_n_rows;
2500
 
 
2501
 
    if (table_stats.stat_n_rows < 2)
2502
 
      stats.records= 2;
2503
 
 
2504
 
    stats.deleted= 0;
2505
 
    stats.data_file_length= table_stats.stat_clustered_index_size;
2506
 
    stats.index_file_length= table_stats.stat_sum_of_other_index_sizes;
2507
 
 
2508
 
    stats.mean_rec_length= stats.data_file_length / stats.records;
2509
 
  }
 
2361
  stats.records= 2;
2510
2362
 
2511
2363
  if (flag & HA_STATUS_AUTO)
2512
2364
    stats.auto_increment_value= 1;
2513
 
 
2514
 
  if (flag & HA_STATUS_ERRKEY) {
2515
 
    const char *err_table_name;
2516
 
    const char *err_index_name;
2517
 
 
2518
 
    ib_trx_t transaction= *get_trx(getTable()->in_use);
2519
 
 
2520
 
    err= ib_get_duplicate_key(transaction, &err_table_name, &err_index_name);
2521
 
 
2522
 
    errkey= UINT32_MAX;
2523
 
 
2524
 
    for (unsigned int i = 0; i < getTable()->getShare()->keys; i++)
2525
 
    {
2526
 
      if (strcmp(err_index_name, getTable()->key_info[i].name) == 0)
2527
 
      {
2528
 
        errkey= i;
2529
 
        break;
2530
 
      }
2531
 
    }
2532
 
 
2533
 
  }
2534
 
 
2535
 
  if (flag & HA_STATUS_CONST)
2536
 
  {
2537
 
    for (unsigned int i = 0; i < getTable()->getShare()->sizeKeys(); i++)
2538
 
    {
2539
 
      const char* index_name= getTable()->key_info[i].name;
2540
 
      uint64_t ncols;
2541
 
      int64_t *n_diff;
2542
 
      ha_rows rec_per_key;
2543
 
 
2544
 
      err= ib_get_index_stat_n_diff_key_vals(cursor, index_name,
2545
 
                                             &ncols, &n_diff);
2546
 
 
2547
 
      if (err != DB_SUCCESS)
2548
 
        return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2549
 
 
2550
 
      for (unsigned int j=0; j < getTable()->key_info[i].key_parts; j++)
2551
 
      {
2552
 
        if (n_diff[j+1] == 0)
2553
 
          rec_per_key= stats.records;
2554
 
        else
2555
 
          rec_per_key= stats.records / n_diff[j+1];
2556
 
 
2557
 
        /* We import this heuristic from ha_innodb, which says
2558
 
           that MySQL favours table scans too much over index searches,
2559
 
           so we pretend our index selectivity is 2 times better. */
2560
 
 
2561
 
        rec_per_key= rec_per_key / 2;
2562
 
 
2563
 
        if (rec_per_key == 0)
2564
 
          rec_per_key= 1;
2565
 
 
2566
 
        getTable()->key_info[i].rec_per_key[j]=
2567
 
          rec_per_key >= ~(ulong) 0 ? ~(ulong) 0 :
2568
 
          (ulong) rec_per_key;
2569
 
      }
2570
 
 
2571
 
      free(n_diff);
2572
 
    }
2573
 
  }
2574
 
 
2575
2365
  return(0);
2576
2366
}
2577
2367
 
2578
2368
int HailDBCursor::doStartIndexScan(uint32_t keynr, bool)
2579
2369
{
2580
 
  ib_err_t err;
2581
 
  ib_trx_t transaction= *get_trx(getTable()->in_use);
 
2370
  ib_trx_t transaction= *get_trx(table->in_use);
2582
2371
 
2583
2372
  active_index= keynr;
2584
2373
 
 
2374
  ib_cursor_attach_trx(cursor, transaction);
 
2375
 
2585
2376
  if (active_index == 0 && ! share->has_hidden_primary_key)
2586
2377
  {
2587
 
    if (cursor_is_sec_index)
2588
 
    {
2589
 
      err= ib_cursor_close(cursor);
2590
 
      assert(err == DB_SUCCESS);
2591
 
 
2592
 
      err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
2593
 
 
2594
 
      if (err != DB_SUCCESS)
2595
 
        return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2596
 
 
2597
 
    }
2598
 
    else
2599
 
    {
2600
 
      ib_cursor_attach_trx(cursor, transaction);
2601
 
    }
2602
 
 
2603
 
    cursor_is_sec_index= false;
2604
2378
    tuple= ib_clust_read_tuple_create(cursor);
2605
2379
  }
2606
2380
  else
2607
2381
  {
 
2382
    ib_err_t err;
2608
2383
    ib_id_t index_id;
2609
 
    err= ib_index_get_id(table_path_to_haildb_name(getShare()->getPath()),
2610
 
                         getShare()->getKeyInfo(keynr).name,
 
2384
    err= ib_index_get_id(table_path_to_haildb_name(table_share->getPath()),
 
2385
                         table_share->getKeyInfo(keynr).name,
2611
2386
                         &index_id);
2612
2387
    if (err != DB_SUCCESS)
2613
 
      return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
 
2388
      return -1;
2614
2389
 
2615
2390
    err= ib_cursor_close(cursor);
2616
2391
    assert(err == DB_SUCCESS);
2617
 
 
2618
2392
    err= ib_cursor_open_index_using_id(index_id, transaction, &cursor);
2619
2393
 
2620
2394
    if (err != DB_SUCCESS)
2621
 
      return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2622
 
 
2623
 
    cursor_is_sec_index= true;
 
2395
      return -1;
2624
2396
 
2625
2397
    tuple= ib_clust_read_tuple_create(cursor);
2626
2398
    ib_cursor_set_cluster_access(cursor);
2627
2399
  }
2628
2400
 
2629
 
  err= ib_cursor_set_lock_mode(cursor, ib_lock_mode);
 
2401
  ib_err_t err= ib_cursor_set_lock_mode(cursor, ib_lock_mode);
2630
2402
  assert(err == DB_SUCCESS);
2631
2403
 
2632
2404
  advance_cursor= false;
2757
2529
    search_tuple= ib_sec_search_tuple_create(cursor);
2758
2530
 
2759
2531
  fill_ib_search_tpl_from_drizzle_key(search_tuple,
2760
 
                                      getTable()->key_info + active_index,
 
2532
                                      table->key_info + active_index,
2761
2533
                                      key_ptr, key_len);
2762
2534
 
2763
2535
  err= ib_cursor_moveto(cursor, search_tuple, search_mode, &res);
2765
2537
 
2766
2538
  if ((err == DB_RECORD_NOT_FOUND || err == DB_END_OF_INDEX))
2767
2539
  {
2768
 
    getTable()->status= STATUS_NOT_FOUND;
 
2540
    table->status= STATUS_NOT_FOUND;
2769
2541
    return HA_ERR_KEY_NOT_FOUND;
2770
2542
  }
2771
2543
 
2772
2544
  if (err != DB_SUCCESS)
2773
2545
  {
2774
 
    return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
 
2546
    return ib_err_t_to_drizzle_error(err);
2775
2547
  }
2776
2548
 
2777
2549
  tuple= ib_tuple_clear(tuple);
2778
 
  ret= read_row_from_haildb(getTable()->getSession(), buf, cursor, tuple,
2779
 
                            getTable(),
 
2550
  ret= read_row_from_haildb(buf, cursor, tuple, table,
2780
2551
                            share->has_hidden_primary_key,
2781
2552
                            &hidden_autoinc_pkey_position,
2782
2553
                            (allocate_blobs)? &blobroot : NULL);
2783
2554
  if (ret == 0)
2784
 
    getTable()->status= 0;
 
2555
    table->status= 0;
2785
2556
  else
2786
 
    getTable()->status= STATUS_NOT_FOUND;
 
2557
    table->status= STATUS_NOT_FOUND;
2787
2558
 
2788
2559
  advance_cursor= true;
2789
2560
 
2805
2576
  /* works only with key prefixes */
2806
2577
  assert(((keypart_map_arg + 1) & keypart_map_arg) == 0);
2807
2578
 
2808
 
  KeyPartInfo *key_part_found= getTable()->getShare()->getKeyInfo(key_position).key_part;
2809
 
  KeyPartInfo *end_key_part_found= key_part_found + getTable()->getShare()->getKeyInfo(key_position).key_parts;
 
2579
  KeyPartInfo *key_part_found= table->s->getKeyInfo(key_position).key_part;
 
2580
  KeyPartInfo *end_key_part_found= key_part_found + table->s->getKeyInfo(key_position).key_parts;
2810
2581
  uint32_t length= 0;
2811
2582
 
2812
2583
  while (key_part_found < end_key_part_found && keypart_map_arg)
2853
2624
  return 0;
2854
2625
}
2855
2626
 
2856
 
int HailDBCursor::analyze(Session*)
2857
 
{
2858
 
  ib_err_t err;
2859
 
 
2860
 
  err= ib_update_table_statistics(cursor);
2861
 
 
2862
 
  return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2863
 
}
2864
 
 
2865
2627
int HailDBCursor::index_next(unsigned char *buf)
2866
2628
{
2867
2629
  int ret= HA_ERR_END_OF_FILE;
2874
2636
  }
2875
2637
 
2876
2638
  tuple= ib_tuple_clear(tuple);
2877
 
  ret= read_row_from_haildb(getTable()->getSession(), buf, cursor, tuple,
2878
 
                            getTable(),
 
2639
  ret= read_row_from_haildb(buf, cursor, tuple, table,
2879
2640
                            share->has_hidden_primary_key,
2880
2641
                            &hidden_autoinc_pkey_position);
2881
2642
 
2903
2664
      if (err == DB_END_OF_INDEX)
2904
2665
        return HA_ERR_END_OF_FILE;
2905
2666
      else
2906
 
        return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
 
2667
        return -1; // FIXME
2907
2668
    }
2908
2669
  }
2909
2670
 
2910
2671
  tuple= ib_tuple_clear(tuple);
2911
 
  ret= read_row_from_haildb(getTable()->getSession(), buf, cursor, tuple,
2912
 
                            getTable(),
 
2672
  ret= read_row_from_haildb(buf, cursor, tuple, table,
2913
2673
                            share->has_hidden_primary_key,
2914
2674
                            &hidden_autoinc_pkey_position);
2915
2675
 
2926
2686
 
2927
2687
  err= ib_cursor_first(cursor);
2928
2688
  if (err != DB_SUCCESS)
2929
 
    return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
 
2689
    return ib_err_t_to_drizzle_error(err);
2930
2690
 
2931
2691
  tuple= ib_tuple_clear(tuple);
2932
 
  ret= read_row_from_haildb(getTable()->getSession(), buf, cursor, tuple,
2933
 
                            getTable(),
 
2692
  ret= read_row_from_haildb(buf, cursor, tuple, table,
2934
2693
                            share->has_hidden_primary_key,
2935
2694
                            &hidden_autoinc_pkey_position);
2936
2695
 
2947
2706
 
2948
2707
  err= ib_cursor_last(cursor);
2949
2708
  if (err != DB_SUCCESS)
2950
 
    return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
 
2709
    return ib_err_t_to_drizzle_error(err);
2951
2710
 
2952
2711
  tuple= ib_tuple_clear(tuple);
2953
 
  ret= read_row_from_haildb(getTable()->getSession(), buf, cursor, tuple,
2954
 
                            getTable(),
 
2712
  ret= read_row_from_haildb(buf, cursor, tuple, table,
2955
2713
                            share->has_hidden_primary_key,
2956
2714
                            &hidden_autoinc_pkey_position);
2957
2715
  advance_cursor= true;
3043
2801
  return err;
3044
2802
}
3045
2803
 
 
2804
static bool  innobase_use_checksums= true;
 
2805
static char*  innobase_data_home_dir      = NULL;
 
2806
static char*  innobase_log_group_home_dir   = NULL;
3046
2807
static bool innobase_use_doublewrite= true;
 
2808
static unsigned long srv_io_capacity= 200;
 
2809
static unsigned long innobase_fast_shutdown= 1;
3047
2810
static bool srv_file_per_table= false;
3048
2811
static bool innobase_adaptive_hash_index;
3049
2812
static bool srv_adaptive_flushing;
3051
2814
static bool innobase_rollback_on_timeout;
3052
2815
static bool innobase_create_status_file;
3053
2816
static bool srv_use_sys_malloc;
3054
 
static string innobase_file_format_name;
3055
 
typedef constrained_check<unsigned int, 1000, 1> autoextend_constraint;
3056
 
static autoextend_constraint srv_auto_extend_increment;
3057
 
typedef constrained_check<size_t, SIZE_MAX, 5242880, 1048576> buffer_pool_constraint;
3058
 
static buffer_pool_constraint innobase_buffer_pool_size;
3059
 
typedef constrained_check<size_t, SIZE_MAX, 512, 1024> additional_mem_pool_constraint;
3060
 
static additional_mem_pool_constraint innobase_additional_mem_pool_size;
3061
 
static bool  innobase_use_checksums= true;
3062
 
typedef constrained_check<unsigned int, UINT_MAX, 100> io_capacity_constraint;
3063
 
typedef constrained_check<uint32_t, 2, 0> trinary_constraint;
3064
 
static trinary_constraint innobase_fast_shutdown;
3065
 
static trinary_constraint srv_flush_log_at_trx_commit;
3066
 
typedef constrained_check<uint32_t, 6, 0> force_recovery_constraint;
3067
 
static force_recovery_constraint innobase_force_recovery;
3068
 
typedef constrained_check<int64_t, INT64_MAX, 1024*1024, 1024*1024> log_file_constraint;
3069
 
static log_file_constraint haildb_log_file_size;
3070
 
 
3071
 
static io_capacity_constraint srv_io_capacity;
3072
 
typedef constrained_check<unsigned int, 100, 2> log_files_in_group_constraint;
3073
 
static log_files_in_group_constraint haildb_log_files_in_group;
3074
 
typedef constrained_check<unsigned int, 1024*1024*1024, 1> lock_wait_constraint;
3075
 
static lock_wait_constraint innobase_lock_wait_timeout;
3076
 
typedef constrained_check<long, LONG_MAX, 256*1024, 1024> log_buffer_size_constraint;
3077
 
static log_buffer_size_constraint innobase_log_buffer_size;
3078
 
typedef constrained_check<unsigned int, 97, 5> lru_old_blocks_constraint;
3079
 
static lru_old_blocks_constraint innobase_lru_old_blocks_pct;
3080
 
typedef constrained_check<unsigned int, 99, 0> max_dirty_pages_constraint;
3081
 
static max_dirty_pages_constraint haildb_max_dirty_pages_pct;
3082
 
static uint64_constraint haildb_max_purge_lag;
3083
 
static uint64_constraint haildb_sync_spin_loops;
3084
 
typedef constrained_check<uint32_t, UINT32_MAX, 10> open_files_constraint;
3085
 
static open_files_constraint haildb_open_files;
3086
 
typedef constrained_check<unsigned int, 64, 1> io_threads_constraint;
3087
 
static io_threads_constraint haildb_read_io_threads;
3088
 
static io_threads_constraint haildb_write_io_threads;
3089
 
 
3090
 
 
3091
 
static uint32_t innobase_lru_block_access_recency;
3092
 
 
3093
 
 
3094
 
 
3095
 
static int haildb_file_format_name_validate(Session*, set_var *var)
3096
 
{
3097
 
 
3098
 
  const char *format= var->value->str_value.ptr();
3099
 
  if (format == NULL)
3100
 
    return 1;
3101
 
 
3102
 
  ib_err_t err= ib_cfg_set_text("file_format", format);
3103
 
 
3104
 
  if (err == DB_SUCCESS)
3105
 
  {
3106
 
    innobase_file_format_name= format;
3107
 
    return 0;
3108
 
  }
3109
 
  else
3110
 
    return 1;
3111
 
}
3112
 
 
3113
 
static void haildb_lru_old_blocks_pct_update(Session*, sql_var_t)
3114
 
{
3115
 
  int ret= ib_cfg_set_int("lru_old_blocks_pct", static_cast<uint32_t>(innobase_lru_old_blocks_pct));
3116
 
  (void)ret;
3117
 
}
3118
 
 
3119
 
static void haildb_lru_block_access_recency_update(Session*, sql_var_t)
3120
 
{
3121
 
  int ret= ib_cfg_set_int("lru_block_access_recency", static_cast<uint32_t>(innobase_lru_block_access_recency));
3122
 
  (void)ret;
3123
 
}
3124
 
 
3125
 
static void haildb_status_file_update(Session*, sql_var_t)
3126
 
{
3127
 
  ib_err_t err;
3128
 
 
3129
 
  if (innobase_create_status_file)
3130
 
    err= ib_cfg_set_bool_on("status_file");
3131
 
  else
3132
 
    err= ib_cfg_set_bool_off("status_file");
3133
 
  (void)err;
3134
 
}
3135
 
 
3136
 
extern "C" int haildb_errmsg_callback(ib_msg_stream_t, const char *fmt, ...);
3137
 
namespace drizzled
3138
 
{
3139
 
extern bool volatile shutdown_in_progress;
3140
 
}
3141
 
 
3142
 
extern "C" int haildb_errmsg_callback(ib_msg_stream_t, const char *fmt, ...)
3143
 
{
3144
 
  bool r= false;
3145
 
  va_list args;
3146
 
  va_start(args, fmt);
3147
 
  if (not shutdown_in_progress)
3148
 
  {
3149
 
    r= plugin::ErrorMessage::vprintf(error::WARN, fmt, args);
3150
 
  }
3151
 
  else
3152
 
  {
3153
 
    vfprintf(stderr, fmt, args);
3154
 
  }
3155
 
  va_end(args);
3156
 
 
3157
 
  return (! r==true);
3158
 
}
 
2817
static char*  innobase_file_format_name   = const_cast<char *>("Barracuda");
 
2818
static char*  innobase_unix_file_flush_method   = NULL;
 
2819
static unsigned long srv_flush_log_at_trx_commit;
 
2820
static unsigned long srv_max_buf_pool_modified_pct;
 
2821
static unsigned long srv_max_purge_lag;
 
2822
static unsigned long innobase_lru_old_blocks_pct;
 
2823
static unsigned long innobase_lru_block_access_recency;
 
2824
static unsigned long innobase_read_io_threads;
 
2825
static unsigned long innobase_write_io_threads;
 
2826
static unsigned int srv_auto_extend_increment;
 
2827
static unsigned long innobase_lock_wait_timeout;
 
2828
static unsigned long srv_n_spin_wait_rounds;
 
2829
static int64_t innobase_buffer_pool_size;
 
2830
static long innobase_open_files;
 
2831
static long innobase_additional_mem_pool_size;
 
2832
static long innobase_force_recovery;
 
2833
static long innobase_log_buffer_size;
 
2834
static char  default_haildb_data_file_path[]= "ibdata1:10M:autoextend";
 
2835
static char* haildb_data_file_path= NULL;
 
2836
 
 
2837
static int64_t haildb_log_file_size;
 
2838
static int64_t haildb_log_files_in_group;
3159
2839
 
3160
2840
static int haildb_init(drizzled::module::Context &context)
3161
2841
{
3177
2857
  innobase_print_verbose_log= (vm.count("disable-print-verbose-log")) ? false : true;
3178
2858
  srv_use_sys_malloc= (vm.count("use-internal-malloc")) ? false : true;
3179
2859
 
 
2860
  if (vm.count("additional-mem-pool-size"))
 
2861
  {
 
2862
    if (innobase_additional_mem_pool_size > LONG_MAX || innobase_additional_mem_pool_size < 512*1024L)
 
2863
    {
 
2864
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of additional-mem-pool-size"));
 
2865
      exit(-1);
 
2866
    }
 
2867
    innobase_additional_mem_pool_size/= 1024;
 
2868
    innobase_additional_mem_pool_size*= 1024;
 
2869
  }
 
2870
 
 
2871
  if (vm.count("autoextend-increment"))
 
2872
  {
 
2873
    if (srv_auto_extend_increment > 1000L || srv_auto_extend_increment < 1L)
 
2874
    {
 
2875
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of autoextend-increment"));
 
2876
      exit(-1);
 
2877
    }
 
2878
  }
 
2879
 
 
2880
  if (vm.count("buffer-pool-size"))
 
2881
  {
 
2882
    if (innobase_buffer_pool_size > INT64_MAX || innobase_buffer_pool_size < 5*1024*1024L)
 
2883
    {
 
2884
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of buffer-pool-size"));
 
2885
      exit(-1);
 
2886
    }
 
2887
    innobase_buffer_pool_size/= 1024*1024L;
 
2888
    innobase_buffer_pool_size*= 1024*1024L;
 
2889
  }
 
2890
 
 
2891
  if (vm.count("io-capacity"))
 
2892
  {
 
2893
    if (srv_io_capacity > (unsigned long)~0L || srv_io_capacity < 100)
 
2894
    {
 
2895
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of io-capacity"));
 
2896
      exit(-1);
 
2897
    }
 
2898
  }
 
2899
 
 
2900
  if (vm.count("fast-shutdown"))
 
2901
  {
 
2902
    if (innobase_fast_shutdown > 2)
 
2903
    {
 
2904
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of fast-shutdown"));
 
2905
      exit(-1);
 
2906
    }
 
2907
  }
 
2908
 
 
2909
  if (vm.count("flush-log-at-trx-commit"))
 
2910
  {
 
2911
    if (srv_flush_log_at_trx_commit > 2)
 
2912
    {
 
2913
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of flush-log-at-trx-commit"));
 
2914
      exit(-1);
 
2915
    }
 
2916
  }
 
2917
 
 
2918
  if (vm.count("force-recovery"))
 
2919
  {
 
2920
    if (innobase_force_recovery > 6)
 
2921
    {
 
2922
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of force-recovery"));
 
2923
      exit(-1);
 
2924
    }
 
2925
  }
 
2926
 
 
2927
  if (vm.count("log-file-size"))
 
2928
  {
 
2929
    if (haildb_log_file_size > INT64_MAX || haildb_log_file_size < 1*1024*1024L)
 
2930
    {
 
2931
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-file-size"));
 
2932
      exit(-1);
 
2933
    }
 
2934
    haildb_log_file_size/= 1024*1024L;
 
2935
    haildb_log_file_size*= 1024*1024L;
 
2936
  }
 
2937
 
 
2938
  if (vm.count("log-files-in-group"))
 
2939
  {
 
2940
    if (haildb_log_files_in_group > 100 || haildb_log_files_in_group < 2)
 
2941
    {
 
2942
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-files-in-group"));
 
2943
      exit(-1);
 
2944
    }
 
2945
  }
 
2946
 
 
2947
  if (vm.count("lock-wait-timeout"))
 
2948
  {
 
2949
    if (innobase_lock_wait_timeout > 1024*1024*1024 || innobase_lock_wait_timeout < 1)
 
2950
    {
 
2951
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lock-wait-timeout"));
 
2952
      exit(-1);
 
2953
    }
 
2954
  }
 
2955
 
 
2956
  if (vm.count("log-buffer-size"))
 
2957
  {
 
2958
    if (innobase_log_buffer_size > LONG_MAX || innobase_log_buffer_size < 256*1024L)
 
2959
    {
 
2960
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-buffer-size"));
 
2961
      exit(-1);
 
2962
    }
 
2963
    innobase_log_buffer_size/= 1024;
 
2964
    innobase_log_buffer_size*= 1024;
 
2965
  }
 
2966
 
 
2967
  if (vm.count("lru-old-blocks-pct"))
 
2968
  {
 
2969
    if (innobase_lru_old_blocks_pct > 95 || innobase_lru_old_blocks_pct < 5)
 
2970
    {
 
2971
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lru-old-blocks-pct"));
 
2972
      exit(-1);
 
2973
    }
 
2974
  }
 
2975
 
 
2976
  if (vm.count("lru-block-access-recency"))
 
2977
  {
 
2978
    if (innobase_lru_block_access_recency > ULONG_MAX)
 
2979
    {
 
2980
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lru-block-access-recency"));
 
2981
      exit(-1);
 
2982
    }
 
2983
  }
 
2984
 
 
2985
  if (vm.count("max-dirty-pages-pct"))
 
2986
  {
 
2987
    if (srv_max_buf_pool_modified_pct > 99)
 
2988
    {
 
2989
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of max-dirty-pages-pct"));
 
2990
      exit(-1);
 
2991
    }
 
2992
  }
 
2993
 
 
2994
  if (vm.count("max-purge-lag"))
 
2995
  {
 
2996
    if (srv_max_purge_lag > (unsigned long)~0L)
 
2997
    {
 
2998
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of max-purge-lag"));
 
2999
      exit(-1);
 
3000
    }
 
3001
  }
 
3002
 
 
3003
  if (vm.count("open-files"))
 
3004
  {
 
3005
    if (innobase_open_files > LONG_MAX || innobase_open_files < 10L)
 
3006
    {
 
3007
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of open-files"));
 
3008
      exit(-1);
 
3009
    }
 
3010
  }
 
3011
 
 
3012
  if (vm.count("read-io-threads"))
 
3013
  {
 
3014
    if (innobase_read_io_threads > 64 || innobase_read_io_threads < 1)
 
3015
    {
 
3016
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of read-io-threads"));
 
3017
      exit(-1);
 
3018
    }
 
3019
  }
 
3020
 
 
3021
  if (vm.count("sync-spin-loops"))
 
3022
  {
 
3023
    if (srv_n_spin_wait_rounds > (unsigned long)~0L)
 
3024
    {
 
3025
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of sync_spin_loops"));
 
3026
      exit(-1);
 
3027
    }
 
3028
  }
 
3029
 
 
3030
  if (vm.count("data-home-dir"))
 
3031
  {
 
3032
    innobase_data_home_dir= const_cast<char *>(vm["data-home-dir"].as<string>().c_str());
 
3033
  }
 
3034
 
 
3035
  if (vm.count("file-format"))
 
3036
  {
 
3037
    innobase_file_format_name= const_cast<char *>(vm["file-format"].as<string>().c_str());
 
3038
  }
 
3039
 
 
3040
  if (vm.count("log-group-home-dir"))
 
3041
  {
 
3042
    innobase_log_group_home_dir= const_cast<char *>(vm["log-group-home-dir"].as<string>().c_str());
 
3043
  }
 
3044
 
 
3045
  if (vm.count("flush-method"))
 
3046
  {
 
3047
    innobase_unix_file_flush_method= const_cast<char *>(vm["flush-method"].as<string>().c_str());
 
3048
  }
 
3049
 
 
3050
  if (vm.count("data-file-path"))
 
3051
  {
 
3052
    haildb_data_file_path= const_cast<char *>(vm["data-file-path"].as<string>().c_str());
 
3053
  }
3180
3054
 
3181
3055
  ib_err_t err;
3182
3056
 
3184
3058
  if (err != DB_SUCCESS)
3185
3059
    goto haildb_error;
3186
3060
 
3187
 
  ib_logger_set(haildb_errmsg_callback, NULL);
3188
 
 
3189
 
  if (not vm["data-home-dir"].as<string>().empty())
3190
 
  {
3191
 
    err= ib_cfg_set_text("data_home_dir", vm["data-home-dir"].as<string>().c_str());
3192
 
    if (err != DB_SUCCESS)
3193
 
      goto haildb_error;
3194
 
  }
3195
 
 
3196
 
  if (vm.count("log-group-home-dir"))
3197
 
  {
3198
 
    err= ib_cfg_set_text("log_group_home_dir", vm["log-group-home-dir"].as<string>().c_str());
3199
 
    if (err != DB_SUCCESS)
3200
 
      goto haildb_error;
3201
 
  }
 
3061
  if (innobase_data_home_dir)
 
3062
  {
 
3063
    err= ib_cfg_set_text("data_home_dir", innobase_data_home_dir);
 
3064
    if (err != DB_SUCCESS)
 
3065
      goto haildb_error;
 
3066
  }
 
3067
 
 
3068
  if (innobase_log_group_home_dir)
 
3069
  {
 
3070
    err= ib_cfg_set_text("log_group_home_dir", innobase_log_group_home_dir);
 
3071
    if (err != DB_SUCCESS)
 
3072
      goto haildb_error;
 
3073
  }
 
3074
 
 
3075
  if (haildb_data_file_path == NULL)
 
3076
    haildb_data_file_path= default_haildb_data_file_path;
3202
3077
 
3203
3078
  if (innobase_print_verbose_log)
3204
3079
    err= ib_cfg_set_bool_on("print_verbose_log");
3240
3115
  if (err != DB_SUCCESS)
3241
3116
    goto haildb_error;
3242
3117
 
3243
 
  err= ib_cfg_set_int("additional_mem_pool_size", innobase_additional_mem_pool_size.get());
3244
 
  if (err != DB_SUCCESS)
3245
 
    goto haildb_error;
3246
 
 
3247
 
  err= ib_cfg_set_int("autoextend_increment", srv_auto_extend_increment.get());
3248
 
  if (err != DB_SUCCESS)
3249
 
    goto haildb_error;
3250
 
 
3251
 
  err= ib_cfg_set_int("buffer_pool_size", innobase_buffer_pool_size.get());
3252
 
  if (err != DB_SUCCESS)
3253
 
    goto haildb_error;
3254
 
 
3255
 
  err= ib_cfg_set_int("io_capacity", srv_io_capacity.get());
 
3118
  err= ib_cfg_set_int("additional_mem_pool_size", innobase_additional_mem_pool_size);
 
3119
  if (err != DB_SUCCESS)
 
3120
    goto haildb_error;
 
3121
 
 
3122
  err= ib_cfg_set_int("autoextend_increment", srv_auto_extend_increment);
 
3123
  if (err != DB_SUCCESS)
 
3124
    goto haildb_error;
 
3125
 
 
3126
  err= ib_cfg_set_int("buffer_pool_size", innobase_buffer_pool_size);
 
3127
  if (err != DB_SUCCESS)
 
3128
    goto haildb_error;
 
3129
 
 
3130
  err= ib_cfg_set_int("io_capacity", srv_io_capacity);
3256
3131
  if (err != DB_SUCCESS)
3257
3132
    goto haildb_error;
3258
3133
 
3264
3139
  if (err != DB_SUCCESS)
3265
3140
    goto haildb_error;
3266
3141
 
3267
 
  err= ib_cfg_set_int("flush_log_at_trx_commit",
3268
 
                      srv_flush_log_at_trx_commit.get());
 
3142
  err= ib_cfg_set_int("flush_log_at_trx_commit", srv_flush_log_at_trx_commit);
3269
3143
  if (err != DB_SUCCESS)
3270
3144
    goto haildb_error;
3271
3145
 
3272
 
  if (vm.count("flush-method") != 0)
 
3146
  if (innobase_unix_file_flush_method)
3273
3147
  {
3274
 
    err= ib_cfg_set_text("flush_method", 
3275
 
                         vm["flush-method"].as<string>().c_str());
 
3148
    err= ib_cfg_set_text("flush_method", innobase_unix_file_flush_method);
3276
3149
    if (err != DB_SUCCESS)
3277
3150
      goto haildb_error;
3278
3151
  }
3279
3152
 
3280
 
  err= ib_cfg_set_int("force_recovery",
3281
 
                      innobase_force_recovery.get());
3282
 
  if (err != DB_SUCCESS)
3283
 
    goto haildb_error;
3284
 
 
3285
 
  err= ib_cfg_set_text("data_file_path", vm["data-file-path"].as<string>().c_str());
3286
 
  if (err != DB_SUCCESS)
3287
 
    goto haildb_error;
3288
 
 
3289
 
  err= ib_cfg_set_int("log_file_size", haildb_log_file_size.get());
3290
 
  if (err != DB_SUCCESS)
3291
 
    goto haildb_error;
3292
 
 
3293
 
  err= ib_cfg_set_int("log_buffer_size", innobase_log_buffer_size.get());
3294
 
  if (err != DB_SUCCESS)
3295
 
    goto haildb_error;
3296
 
 
3297
 
  err= ib_cfg_set_int("log_files_in_group", haildb_log_files_in_group.get());
 
3153
  err= ib_cfg_set_int("force_recovery", innobase_force_recovery);
 
3154
  if (err != DB_SUCCESS)
 
3155
    goto haildb_error;
 
3156
 
 
3157
  err= ib_cfg_set_text("data_file_path", haildb_data_file_path);
 
3158
  if (err != DB_SUCCESS)
 
3159
    goto haildb_error;
 
3160
 
 
3161
  err= ib_cfg_set_int("log_file_size", haildb_log_file_size);
 
3162
  if (err != DB_SUCCESS)
 
3163
    goto haildb_error;
 
3164
 
 
3165
  err= ib_cfg_set_int("log_buffer_size", innobase_log_buffer_size);
 
3166
  if (err != DB_SUCCESS)
 
3167
    goto haildb_error;
 
3168
 
 
3169
  err= ib_cfg_set_int("log_files_in_group", haildb_log_files_in_group);
3298
3170
  if (err != DB_SUCCESS)
3299
3171
    goto haildb_error;
3300
3172
 
3302
3174
  if (err != DB_SUCCESS)
3303
3175
    goto haildb_error;
3304
3176
 
3305
 
  err= ib_cfg_set_int("lock_wait_timeout", innobase_lock_wait_timeout.get());
3306
 
  if (err != DB_SUCCESS)
3307
 
    goto haildb_error;
3308
 
 
3309
 
  err= ib_cfg_set_int("max_dirty_pages_pct", haildb_max_dirty_pages_pct.get());
3310
 
  if (err != DB_SUCCESS)
3311
 
    goto haildb_error;
3312
 
 
3313
 
  err= ib_cfg_set_int("max_purge_lag", haildb_max_purge_lag.get());
3314
 
  if (err != DB_SUCCESS)
3315
 
    goto haildb_error;
3316
 
 
3317
 
  err= ib_cfg_set_int("open_files", haildb_open_files.get());
3318
 
  if (err != DB_SUCCESS)
3319
 
    goto haildb_error;
3320
 
 
3321
 
  err= ib_cfg_set_int("read_io_threads", haildb_read_io_threads.get());
3322
 
  if (err != DB_SUCCESS)
3323
 
    goto haildb_error;
3324
 
 
3325
 
  err= ib_cfg_set_int("write_io_threads", haildb_write_io_threads.get());
3326
 
  if (err != DB_SUCCESS)
3327
 
    goto haildb_error;
3328
 
 
3329
 
  err= ib_cfg_set_int("sync_spin_loops", haildb_sync_spin_loops.get());
 
3177
  err= ib_cfg_set_int("lock_wait_timeout", innobase_lock_wait_timeout);
 
3178
  if (err != DB_SUCCESS)
 
3179
    goto haildb_error;
 
3180
 
 
3181
  err= ib_cfg_set_int("max_dirty_pages_pct", srv_max_buf_pool_modified_pct);
 
3182
  if (err != DB_SUCCESS)
 
3183
    goto haildb_error;
 
3184
 
 
3185
  err= ib_cfg_set_int("max_purge_lag", srv_max_purge_lag);
 
3186
  if (err != DB_SUCCESS)
 
3187
    goto haildb_error;
 
3188
 
 
3189
  err= ib_cfg_set_int("open_files", innobase_open_files);
 
3190
  if (err != DB_SUCCESS)
 
3191
    goto haildb_error;
 
3192
 
 
3193
  err= ib_cfg_set_int("read_io_threads", innobase_read_io_threads);
 
3194
  if (err != DB_SUCCESS)
 
3195
    goto haildb_error;
 
3196
 
 
3197
  err= ib_cfg_set_int("write_io_threads", innobase_write_io_threads);
 
3198
  if (err != DB_SUCCESS)
 
3199
    goto haildb_error;
 
3200
 
 
3201
  err= ib_cfg_set_int("sync_spin_loops", srv_n_spin_wait_rounds);
3330
3202
  if (err != DB_SUCCESS)
3331
3203
    goto haildb_error;
3332
3204
 
3338
3210
  if (err != DB_SUCCESS)
3339
3211
    goto haildb_error;
3340
3212
 
3341
 
  err= ib_startup(innobase_file_format_name.c_str());
 
3213
  err= ib_startup(innobase_file_format_name);
3342
3214
  if (err != DB_SUCCESS)
3343
3215
    goto haildb_error;
3344
3216
 
3346
3218
 
3347
3219
  haildb_engine= new HailDBEngine("InnoDB");
3348
3220
  context.add(haildb_engine);
3349
 
  context.registerVariable(new sys_var_bool_ptr_readonly("adaptive_hash_index",
3350
 
                                                         &innobase_adaptive_hash_index));
3351
 
  context.registerVariable(new sys_var_bool_ptr_readonly("adaptive_flushing",
3352
 
                                                         &srv_adaptive_flushing));
3353
 
  context.registerVariable(new sys_var_constrained_value_readonly<size_t>("additional_mem_pool_size",innobase_additional_mem_pool_size));
3354
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("autoextend_increment", srv_auto_extend_increment));
3355
 
  context.registerVariable(new sys_var_constrained_value_readonly<size_t>("buffer_pool_size", innobase_buffer_pool_size));
3356
 
  context.registerVariable(new sys_var_bool_ptr_readonly("checksums",
3357
 
                                                         &innobase_use_checksums));
3358
 
  context.registerVariable(new sys_var_bool_ptr_readonly("doublewrite",
3359
 
                                                         &innobase_use_doublewrite));
3360
 
  context.registerVariable(new sys_var_const_string_val("data_file_path",
3361
 
                                                vm["data-file-path"].as<string>()));
3362
 
  context.registerVariable(new sys_var_const_string_val("data_home_dir",
3363
 
                                                vm["data-home-dir"].as<string>()));
3364
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("io_capacity", srv_io_capacity));
3365
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("fast_shutdown", innobase_fast_shutdown));
3366
 
  context.registerVariable(new sys_var_bool_ptr_readonly("file_per_table",
3367
 
                                                         &srv_file_per_table));
3368
 
  context.registerVariable(new sys_var_bool_ptr_readonly("rollback_on_timeout",
3369
 
                                                         &innobase_rollback_on_timeout));
3370
 
  context.registerVariable(new sys_var_bool_ptr_readonly("print_verbose_log",
3371
 
                                                         &innobase_print_verbose_log));
3372
 
  context.registerVariable(new sys_var_bool_ptr("status_file",
3373
 
                                                &innobase_create_status_file,
3374
 
                                                haildb_status_file_update));
3375
 
  context.registerVariable(new sys_var_bool_ptr_readonly("use_sys_malloc",
3376
 
                                                         &srv_use_sys_malloc));
3377
 
  context.registerVariable(new sys_var_std_string("file_format",
3378
 
                                                  innobase_file_format_name,
3379
 
                                                  haildb_file_format_name_validate));
3380
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("flush_log_at_trx_commit", srv_flush_log_at_trx_commit));
3381
 
  context.registerVariable(new sys_var_const_string_val("flush_method",
3382
 
                                                vm.count("flush-method") ?  vm["flush-method"].as<string>() : ""));
3383
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("force_recovery", innobase_force_recovery));
3384
 
  context.registerVariable(new sys_var_const_string_val("log_group_home_dir",
3385
 
                                                vm.count("log-group-home-dir") ?  vm["log-group-home-dir"].as<string>() : ""));
3386
 
  context.registerVariable(new sys_var_constrained_value<int64_t>("log_file_size", haildb_log_file_size));
3387
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("log_files_in_group", haildb_log_files_in_group));
3388
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("lock_wait_timeout", innobase_lock_wait_timeout));
3389
 
  context.registerVariable(new sys_var_constrained_value_readonly<long>("log_buffer_size", innobase_log_buffer_size));
3390
 
  context.registerVariable(new sys_var_constrained_value<unsigned int>("lru_old_blocks_pct", innobase_lru_old_blocks_pct, haildb_lru_old_blocks_pct_update));
3391
 
  context.registerVariable(new sys_var_uint32_t_ptr("lru_block_access_recency",
3392
 
                                                    &innobase_lru_block_access_recency,
3393
 
                                                    haildb_lru_block_access_recency_update));
3394
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("max_dirty_pages_pct", haildb_max_dirty_pages_pct));
3395
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("max_purge_lag", haildb_max_purge_lag));
3396
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("sync_spin_loops", haildb_sync_spin_loops));
3397
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("open_files", haildb_open_files));
3398
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("read_io_threads", haildb_read_io_threads));
3399
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("write_io_threads", haildb_write_io_threads));
3400
3221
 
 
3222
  haildb_version_func_initialize(context);
3401
3223
  haildb_datadict_dump_func_initialize(context);
3402
3224
  config_table_function_initialize(context);
3403
3225
  status_table_function_initialize(context);
3415
3237
  ib_err_t err;
3416
3238
  ib_shutdown_t shutdown_flag= IB_SHUTDOWN_NORMAL;
3417
3239
 
3418
 
  if (innobase_fast_shutdown.get() == 1)
 
3240
  if (innobase_fast_shutdown == 1)
3419
3241
    shutdown_flag= IB_SHUTDOWN_NO_IBUFMERGE_PURGE;
3420
 
  else if (innobase_fast_shutdown.get() == 2)
 
3242
  else if (innobase_fast_shutdown == 2)
3421
3243
    shutdown_flag= IB_SHUTDOWN_NO_BUFPOOL_FLUSH;
3422
3244
 
3423
3245
  err= ib_shutdown(shutdown_flag);
3429
3251
 
3430
3252
}
3431
3253
 
 
3254
static char haildb_file_format_name_storage[100];
 
3255
 
 
3256
static int haildb_file_format_name_validate(Session*, drizzle_sys_var*,
 
3257
                                            void *save,
 
3258
                                            drizzle_value *value)
 
3259
{
 
3260
  ib_err_t err;
 
3261
  char buff[100];
 
3262
  int len= sizeof(buff);
 
3263
  const char *format= value->val_str(value, buff, &len);
 
3264
 
 
3265
  *static_cast<const char**>(save)= NULL;
 
3266
 
 
3267
  if (format == NULL)
 
3268
    return 1;
 
3269
 
 
3270
  err= ib_cfg_set_text("file_format", format);
 
3271
 
 
3272
  if (err == DB_SUCCESS)
 
3273
  {
 
3274
    strncpy(haildb_file_format_name_storage, format, sizeof(haildb_file_format_name_storage));;
 
3275
    haildb_file_format_name_storage[sizeof(haildb_file_format_name_storage)-1]= 0;
 
3276
 
 
3277
    *static_cast<const char**>(save)= haildb_file_format_name_storage;
 
3278
    return 0;
 
3279
  }
 
3280
  else
 
3281
    return 1;
 
3282
}
 
3283
 
 
3284
static void haildb_file_format_name_update(Session*, drizzle_sys_var*,
 
3285
                                           void *var_ptr,
 
3286
                                           const void *save)
 
3287
 
 
3288
{
 
3289
  const char* format;
 
3290
 
 
3291
  assert(var_ptr != NULL);
 
3292
  assert(save != NULL);
 
3293
 
 
3294
  format= *static_cast<const char*const*>(save);
 
3295
 
 
3296
  /* Format is already set in validate */
 
3297
  memmove(haildb_file_format_name_storage, format, sizeof(haildb_file_format_name_storage));;
 
3298
  haildb_file_format_name_storage[sizeof(haildb_file_format_name_storage)-1]= 0;
 
3299
 
 
3300
  *static_cast<const char**>(var_ptr)= haildb_file_format_name_storage;
 
3301
}
 
3302
 
 
3303
static void haildb_lru_old_blocks_pct_update(Session*, drizzle_sys_var*,
 
3304
                                             void *,
 
3305
                                             const void *save)
 
3306
 
 
3307
{
 
3308
  unsigned long pct;
 
3309
 
 
3310
  pct= *static_cast<const unsigned long*>(save);
 
3311
 
 
3312
  ib_err_t err= ib_cfg_set_int("lru_old_blocks_pct", pct);
 
3313
  if (err == DB_SUCCESS)
 
3314
    innobase_lru_old_blocks_pct= pct;
 
3315
}
 
3316
 
 
3317
static void haildb_lru_block_access_recency_update(Session*, drizzle_sys_var*,
 
3318
                                                   void *,
 
3319
                                                   const void *save)
 
3320
 
 
3321
{
 
3322
  unsigned long ms;
 
3323
 
 
3324
  ms= *static_cast<const unsigned long*>(save);
 
3325
 
 
3326
  ib_err_t err= ib_cfg_set_int("lru_block_access_recency", ms);
 
3327
 
 
3328
  if (err == DB_SUCCESS)
 
3329
    innobase_lru_block_access_recency= ms;
 
3330
}
 
3331
 
 
3332
static void haildb_status_file_update(Session*, drizzle_sys_var*,
 
3333
                                      void *,
 
3334
                                      const void *save)
 
3335
 
 
3336
{
 
3337
  bool status_file_enabled;
 
3338
  ib_err_t err;
 
3339
 
 
3340
  status_file_enabled= *static_cast<const bool*>(save);
 
3341
 
 
3342
 
 
3343
  if (status_file_enabled)
 
3344
    err= ib_cfg_set_bool_on("status_file");
 
3345
  else
 
3346
    err= ib_cfg_set_bool_off("status_file");
 
3347
 
 
3348
  if (err == DB_SUCCESS)
 
3349
    innobase_create_status_file= status_file_enabled;
 
3350
}
 
3351
 
 
3352
static DRIZZLE_SYSVAR_BOOL(adaptive_hash_index, innobase_adaptive_hash_index,
 
3353
  PLUGIN_VAR_NOCMDARG,
 
3354
  "Enable HailDB adaptive hash index (enabled by default).  ",
 
3355
  NULL, NULL, true);
 
3356
 
 
3357
static DRIZZLE_SYSVAR_BOOL(adaptive_flushing, srv_adaptive_flushing,
 
3358
  PLUGIN_VAR_NOCMDARG,
 
3359
  "Attempt flushing dirty pages to avoid IO bursts at checkpoints.",
 
3360
  NULL, NULL, true);
 
3361
 
 
3362
static DRIZZLE_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size,
 
3363
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
3364
  "Size of a memory pool HailDB uses to store data dictionary information and other internal data structures.",
 
3365
  NULL, NULL, 8*1024*1024L, 512*1024L, LONG_MAX, 1024);
 
3366
 
 
3367
static DRIZZLE_SYSVAR_UINT(autoextend_increment, srv_auto_extend_increment,
 
3368
  PLUGIN_VAR_RQCMDARG,
 
3369
  "Data file autoextend increment in megabytes",
 
3370
  NULL, NULL, 8L, 1L, 1000L, 0);
 
3371
 
 
3372
static DRIZZLE_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size,
 
3373
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
3374
  "The size of the memory buffer HailDB uses to cache data and indexes of its tables.",
 
3375
  NULL, NULL, 128*1024*1024L, 5*1024*1024L, INT64_MAX, 1024*1024L);
 
3376
 
 
3377
static DRIZZLE_SYSVAR_BOOL(checksums, innobase_use_checksums,
 
3378
  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
3379
  "Enable HailDB checksums validation (enabled by default). "
 
3380
  "Disable with --skip-haildb-checksums.",
 
3381
  NULL, NULL, true);
 
3382
 
 
3383
static DRIZZLE_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
 
3384
  PLUGIN_VAR_READONLY,
 
3385
  "The common part for HailDB table spaces.",
 
3386
  NULL, NULL, NULL);
 
3387
 
 
3388
static DRIZZLE_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
 
3389
  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
3390
  "Enable HailDB doublewrite buffer (enabled by default). "
 
3391
  "Disable with --skip-haildb-doublewrite.",
 
3392
  NULL, NULL, true);
 
3393
 
 
3394
static DRIZZLE_SYSVAR_ULONG(io_capacity, srv_io_capacity,
 
3395
  PLUGIN_VAR_RQCMDARG,
 
3396
  "Number of IOPs the server can do. Tunes the background IO rate",
 
3397
  NULL, NULL, 200, 100, ~0L, 0);
 
3398
 
 
3399
static DRIZZLE_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
 
3400
  PLUGIN_VAR_OPCMDARG,
 
3401
  "Speeds up the shutdown process of the HailDB storage engine. Possible "
 
3402
  "values are 0, 1 (faster)"
 
3403
  " or 2 (fastest - crash-like)"
 
3404
  ".",
 
3405
  NULL, NULL, 1, 0, 2, 0);
 
3406
 
 
3407
static DRIZZLE_SYSVAR_BOOL(file_per_table, srv_file_per_table,
 
3408
  PLUGIN_VAR_NOCMDARG,
 
3409
  "Stores each HailDB table to an .ibd file in the database dir.",
 
3410
  NULL, NULL, false);
 
3411
 
 
3412
static DRIZZLE_SYSVAR_STR(file_format, innobase_file_format_name,
 
3413
  PLUGIN_VAR_RQCMDARG,
 
3414
  "File format to use for new tables in .ibd files.",
 
3415
  haildb_file_format_name_validate,
 
3416
  haildb_file_format_name_update, "Barracuda");
 
3417
 
 
3418
static DRIZZLE_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
 
3419
  PLUGIN_VAR_OPCMDARG,
 
3420
  "Set to 0 (write and flush once per second),"
 
3421
  " 1 (write and flush at each commit)"
 
3422
  " or 2 (write at commit, flush once per second).",
 
3423
  NULL, NULL, 1, 0, 2, 0);
 
3424
 
 
3425
static DRIZZLE_SYSVAR_STR(flush_method, innobase_unix_file_flush_method,
 
3426
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
3427
  "With which method to flush data.", NULL, NULL, NULL);
 
3428
 
 
3429
static DRIZZLE_SYSVAR_LONG(force_recovery, innobase_force_recovery,
 
3430
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
3431
  "Helps to save your data in case the disk image of the database becomes corrupt.",
 
3432
  NULL, NULL, 0, 0, 6, 0);
 
3433
 
 
3434
static DRIZZLE_SYSVAR_STR(data_file_path, haildb_data_file_path,
 
3435
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
3436
  "Path to individual files and their sizes.",
 
3437
  NULL, NULL, NULL);
 
3438
 
 
3439
static DRIZZLE_SYSVAR_STR(log_group_home_dir, innobase_log_group_home_dir,
 
3440
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
3441
  "Path to HailDB log files.", NULL, NULL, NULL);
 
3442
 
 
3443
static DRIZZLE_SYSVAR_LONGLONG(log_file_size, haildb_log_file_size,
 
3444
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
3445
  "Size of each log file in a log group.",
 
3446
  NULL, NULL, 20*1024*1024L, 1*1024*1024L, INT64_MAX, 1024*1024L);
 
3447
 
 
3448
static DRIZZLE_SYSVAR_LONGLONG(log_files_in_group, haildb_log_files_in_group,
 
3449
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
3450
  "Number of log files in the log group. HailDB writes to the files in a circular fashion. Value 3 is recommended here.",
 
3451
  NULL, NULL, 2, 2, 100, 0);
 
3452
 
 
3453
static DRIZZLE_SYSVAR_ULONG(lock_wait_timeout, innobase_lock_wait_timeout,
 
3454
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
3455
  "Timeout in seconds an HailDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.",
 
3456
  NULL, NULL, 5, 1, 1024 * 1024 * 1024, 0);
 
3457
 
 
3458
static DRIZZLE_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
 
3459
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
3460
  "The size of the buffer which HailDB uses to write log to the log files on disk.",
 
3461
  NULL, NULL, 8*1024*1024L, 256*1024L, LONG_MAX, 1024);
 
3462
 
 
3463
static DRIZZLE_SYSVAR_ULONG(lru_old_blocks_pct, innobase_lru_old_blocks_pct,
 
3464
  PLUGIN_VAR_RQCMDARG,
 
3465
  "Sets the point in the LRU list from where all pages are classified as "
 
3466
  "old (Advanced users)",
 
3467
  NULL,
 
3468
  haildb_lru_old_blocks_pct_update, 37, 5, 95, 0);
 
3469
 
 
3470
static DRIZZLE_SYSVAR_ULONG(lru_block_access_recency, innobase_lru_block_access_recency,
 
3471
  PLUGIN_VAR_RQCMDARG,
 
3472
  "Milliseconds between accesses to a block at which it is made young. "
 
3473
  "0=disabled (Advanced users)",
 
3474
  NULL,
 
3475
  haildb_lru_block_access_recency_update, 0, 0, ULONG_MAX, 0);
 
3476
 
 
3477
 
 
3478
static DRIZZLE_SYSVAR_ULONG(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
 
3479
  PLUGIN_VAR_RQCMDARG,
 
3480
  "Percentage of dirty pages allowed in bufferpool.",
 
3481
  NULL, NULL, 75, 0, 99, 0);
 
3482
 
 
3483
static DRIZZLE_SYSVAR_ULONG(max_purge_lag, srv_max_purge_lag,
 
3484
  PLUGIN_VAR_RQCMDARG,
 
3485
  "Desired maximum length of the purge queue (0 = no limit)",
 
3486
  NULL, NULL, 0, 0, ~0L, 0);
 
3487
 
 
3488
static DRIZZLE_SYSVAR_BOOL(rollback_on_timeout, innobase_rollback_on_timeout,
 
3489
  PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
 
3490
  "Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)",
 
3491
  NULL, NULL, false);
 
3492
 
 
3493
static DRIZZLE_SYSVAR_LONG(open_files, innobase_open_files,
 
3494
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
3495
  "How many files at the maximum HailDB keeps open at the same time.",
 
3496
  NULL, NULL, 300L, 10L, LONG_MAX, 0);
 
3497
 
 
3498
static DRIZZLE_SYSVAR_ULONG(read_io_threads, innobase_read_io_threads,
 
3499
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
3500
  "Number of background read I/O threads in HailDB.",
 
3501
  NULL, NULL, 4, 1, 64, 0);
 
3502
 
 
3503
static DRIZZLE_SYSVAR_ULONG(write_io_threads, innobase_write_io_threads,
 
3504
  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
3505
  "Number of background write I/O threads in HailDB.",
 
3506
  NULL, NULL, 4, 1, 64, 0);
 
3507
 
 
3508
static DRIZZLE_SYSVAR_BOOL(print_verbose_log, innobase_print_verbose_log,
 
3509
  PLUGIN_VAR_NOCMDARG,
 
3510
  "Disable if you want to reduce the number of messages written to the log (default: enabled).",
 
3511
  NULL, NULL, true);
 
3512
 
 
3513
static DRIZZLE_SYSVAR_BOOL(status_file, innobase_create_status_file,
 
3514
  PLUGIN_VAR_OPCMDARG,
 
3515
  "Enable SHOW HAILDB STATUS output in the log",
 
3516
  NULL, haildb_status_file_update, false);
 
3517
 
 
3518
static DRIZZLE_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
 
3519
  PLUGIN_VAR_RQCMDARG,
 
3520
  "Count of spin-loop rounds in HailDB mutexes (30 by default)",
 
3521
  NULL, NULL, 30L, 0L, ~0L, 0);
 
3522
 
 
3523
static DRIZZLE_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
 
3524
  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
 
3525
  "Use OS memory allocator instead of HailDB's internal memory allocator",
 
3526
  NULL, NULL, true);
3432
3527
 
3433
3528
static void init_options(drizzled::module::option_context &context)
3434
3529
{
3437
3532
  context("disable-adaptive-flushing",
3438
3533
          N_("Do not attempt to flush dirty pages to avoid IO bursts at checkpoints."));
3439
3534
  context("additional-mem-pool-size",
3440
 
          po::value<additional_mem_pool_constraint>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
 
3535
          po::value<long>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
3441
3536
          N_("Size of a memory pool HailDB uses to store data dictionary information and other internal data structures."));
3442
3537
  context("autoextend-increment",
3443
 
          po::value<autoextend_constraint>(&srv_auto_extend_increment)->default_value(8),
 
3538
          po::value<unsigned int>(&srv_auto_extend_increment)->default_value(8L),
3444
3539
          N_("Data file autoextend increment in megabytes"));
3445
3540
  context("buffer-pool-size",
3446
 
          po::value<buffer_pool_constraint>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
 
3541
          po::value<int64_t>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
3447
3542
          N_("The size of the memory buffer HailDB uses to cache data and indexes of its tables."));
3448
3543
  context("data-home-dir",
3449
 
          po::value<string>()->default_value(""),
 
3544
          po::value<string>(),
3450
3545
          N_("The common part for HailDB table spaces."));
3451
3546
  context("disable-checksums",
3452
3547
          N_("Disable HailDB checksums validation (enabled by default)."));
3453
3548
  context("disable-doublewrite",
3454
3549
          N_("Disable HailDB doublewrite buffer (enabled by default)."));
3455
3550
  context("io-capacity",
3456
 
          po::value<io_capacity_constraint>(&srv_io_capacity)->default_value(200),
 
3551
          po::value<unsigned long>(&srv_io_capacity)->default_value(200),
3457
3552
          N_("Number of IOPs the server can do. Tunes the background IO rate"));
3458
3553
  context("fast-shutdown",
3459
 
          po::value<trinary_constraint>(&innobase_fast_shutdown)->default_value(1),
 
3554
          po::value<unsigned long>(&innobase_fast_shutdown)->default_value(1),
3460
3555
          N_("Speeds up the shutdown process of the HailDB storage engine. Possible values are 0, 1 (faster) or 2 (fastest - crash-like)."));
3461
3556
  context("file-per-table",
3462
3557
          po::value<bool>(&srv_file_per_table)->default_value(false)->zero_tokens(),
3463
3558
          N_("Stores each HailDB table to an .ibd file in the database dir."));
3464
3559
  context("file-format",
3465
 
          po::value<string>(&innobase_file_format_name)->default_value("Barracuda"),
 
3560
          po::value<string>(),
3466
3561
          N_("File format to use for new tables in .ibd files."));
3467
3562
  context("flush-log-at-trx-commit",
3468
 
          po::value<trinary_constraint>(&srv_flush_log_at_trx_commit)->default_value(1),
 
3563
          po::value<unsigned long>(&srv_flush_log_at_trx_commit)->default_value(1),
3469
3564
          N_("Set to 0 (write and flush once per second),1 (write and flush at each commit) or 2 (write at commit, flush once per second)."));
3470
3565
  context("flush-method",
3471
3566
          po::value<string>(),
3472
3567
          N_("With which method to flush data."));
3473
3568
  context("force-recovery",
3474
 
          po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
 
3569
          po::value<long>(&innobase_force_recovery)->default_value(0),
3475
3570
          N_("Helps to save your data in case the disk image of the database becomes corrupt."));
3476
3571
  context("data-file-path",
3477
 
          po::value<string>()->default_value("ibdata1:10M:autoextend"),
 
3572
          po::value<string>(),
 
3573
          N_("Path to individual files and their sizes."));
 
3574
  context("log-group-home-dir",
 
3575
          po::value<string>(),
3478
3576
          N_("Path to individual files and their sizes."));
3479
3577
  context("log-group-home-dir",
3480
3578
          po::value<string>(),
3481
3579
          N_("Path to HailDB log files."));
3482
3580
  context("log-file-size",
3483
 
          po::value<log_file_constraint>(&haildb_log_file_size)->default_value(20*1024*1024L),
 
3581
          po::value<int64_t>(&haildb_log_file_size)->default_value(20*1024*1024L),
3484
3582
          N_("Size of each log file in a log group."));
3485
3583
  context("haildb-log-files-in-group",
3486
 
          po::value<log_files_in_group_constraint>(&haildb_log_files_in_group)->default_value(2),
 
3584
          po::value<int64_t>(&haildb_log_files_in_group)->default_value(2),
3487
3585
          N_("Number of log files in the log group. HailDB writes to the files in a circular fashion. Value 3 is recommended here."));
3488
3586
  context("lock-wait-timeout",
3489
 
          po::value<lock_wait_constraint>(&innobase_lock_wait_timeout)->default_value(5),
 
3587
          po::value<unsigned long>(&innobase_lock_wait_timeout)->default_value(5),
3490
3588
          N_("Timeout in seconds an HailDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout."));
3491
3589
  context("log-buffer-size",
3492
 
        po::value<log_buffer_size_constraint>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
 
3590
        po::value<long>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
3493
3591
        N_("The size of the buffer which HailDB uses to write log to the log files on disk."));
3494
3592
  context("lru-old-blocks-pct",
3495
 
          po::value<lru_old_blocks_constraint>(&innobase_lru_old_blocks_pct)->default_value(37),
 
3593
          po::value<unsigned long>(&innobase_lru_old_blocks_pct)->default_value(37),
3496
3594
          N_("Sets the point in the LRU list from where all pages are classified as old (Advanced users)"));
3497
3595
  context("lru-block-access-recency",
3498
 
          po::value<uint32_t>(&innobase_lru_block_access_recency)->default_value(0),
 
3596
          po::value<unsigned long>(&innobase_lru_block_access_recency)->default_value(0),
3499
3597
          N_("Milliseconds between accesses to a block at which it is made young. 0=disabled (Advanced users)"));
3500
3598
  context("max-dirty-pages-pct",
3501
 
          po::value<max_dirty_pages_constraint>(&haildb_max_dirty_pages_pct)->default_value(75),
 
3599
          po::value<unsigned long>(&srv_max_buf_pool_modified_pct)->default_value(75),
3502
3600
          N_("Percentage of dirty pages allowed in bufferpool."));
3503
3601
  context("max-purge-lag",
3504
 
          po::value<uint64_constraint>(&haildb_max_purge_lag)->default_value(0),
 
3602
          po::value<unsigned long>(&srv_max_purge_lag)->default_value(0),
3505
3603
          N_("Desired maximum length of the purge queue (0 = no limit)"));
3506
3604
  context("rollback-on-timeout",
3507
3605
          po::value<bool>(&innobase_rollback_on_timeout)->default_value(false)->zero_tokens(),
3508
3606
          N_("Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)"));
3509
3607
  context("open-files",
3510
 
          po::value<open_files_constraint>(&haildb_open_files)->default_value(300),
 
3608
          po::value<long>(&innobase_open_files)->default_value(300),
3511
3609
          N_("How many files at the maximum HailDB keeps open at the same time."));
3512
3610
  context("read-io-threads",
3513
 
          po::value<io_threads_constraint>(&haildb_read_io_threads)->default_value(4),
 
3611
          po::value<unsigned long>(&innobase_read_io_threads)->default_value(4),
3514
3612
          N_("Number of background read I/O threads in HailDB."));
3515
3613
  context("write-io-threads",
3516
 
          po::value<io_threads_constraint>(&haildb_write_io_threads)->default_value(4),
 
3614
          po::value<unsigned long>(&innobase_write_io_threads)->default_value(4),
3517
3615
          N_("Number of background write I/O threads in HailDB."));
3518
3616
  context("disable-print-verbose-log",
3519
3617
          N_("Disable if you want to reduce the number of messages written to the log (default: enabled)."));
3521
3619
          po::value<bool>(&innobase_create_status_file)->default_value(false)->zero_tokens(),
3522
3620
          N_("Enable SHOW HAILDB STATUS output in the log"));
3523
3621
  context("sync-spin-loops",
3524
 
          po::value<uint64_constraint>(&haildb_sync_spin_loops)->default_value(30L),
 
3622
          po::value<unsigned long>(&srv_n_spin_wait_rounds)->default_value(30L),
3525
3623
          N_("Count of spin-loop rounds in HailDB mutexes (30 by default)"));
3526
3624
  context("use-internal-malloc",
3527
3625
          N_("Use HailDB's internal memory allocator instead of the OS memory allocator"));
3528
3626
}
3529
3627
 
 
3628
static drizzle_sys_var* innobase_system_variables[]= {
 
3629
  DRIZZLE_SYSVAR(adaptive_hash_index),
 
3630
  DRIZZLE_SYSVAR(adaptive_flushing),
 
3631
  DRIZZLE_SYSVAR(additional_mem_pool_size),
 
3632
  DRIZZLE_SYSVAR(autoextend_increment),
 
3633
  DRIZZLE_SYSVAR(buffer_pool_size),
 
3634
  DRIZZLE_SYSVAR(checksums),
 
3635
  DRIZZLE_SYSVAR(data_home_dir),
 
3636
  DRIZZLE_SYSVAR(doublewrite),
 
3637
  DRIZZLE_SYSVAR(io_capacity),
 
3638
  DRIZZLE_SYSVAR(fast_shutdown),
 
3639
  DRIZZLE_SYSVAR(file_per_table),
 
3640
  DRIZZLE_SYSVAR(file_format),
 
3641
  DRIZZLE_SYSVAR(flush_log_at_trx_commit),
 
3642
  DRIZZLE_SYSVAR(flush_method),
 
3643
  DRIZZLE_SYSVAR(force_recovery),
 
3644
  DRIZZLE_SYSVAR(log_group_home_dir),
 
3645
  DRIZZLE_SYSVAR(data_file_path),
 
3646
  DRIZZLE_SYSVAR(lock_wait_timeout),
 
3647
  DRIZZLE_SYSVAR(log_file_size),
 
3648
  DRIZZLE_SYSVAR(log_files_in_group),
 
3649
  DRIZZLE_SYSVAR(log_buffer_size),
 
3650
  DRIZZLE_SYSVAR(lru_old_blocks_pct),
 
3651
  DRIZZLE_SYSVAR(lru_block_access_recency),
 
3652
  DRIZZLE_SYSVAR(max_dirty_pages_pct),
 
3653
  DRIZZLE_SYSVAR(max_purge_lag),
 
3654
  DRIZZLE_SYSVAR(open_files),
 
3655
  DRIZZLE_SYSVAR(read_io_threads),
 
3656
  DRIZZLE_SYSVAR(rollback_on_timeout),
 
3657
  DRIZZLE_SYSVAR(write_io_threads),
 
3658
  DRIZZLE_SYSVAR(print_verbose_log),
 
3659
  DRIZZLE_SYSVAR(status_file),
 
3660
  DRIZZLE_SYSVAR(sync_spin_loops),
 
3661
  DRIZZLE_SYSVAR(use_sys_malloc),
 
3662
  NULL
 
3663
};
 
3664
 
3530
3665
DRIZZLE_DECLARE_PLUGIN
3531
3666
{
3532
3667
  DRIZZLE_VERSION_ID,
3536
3671
  "Transactional Storage Engine using the HailDB Library",
3537
3672
  PLUGIN_LICENSE_GPL,
3538
3673
  haildb_init,     /* Plugin Init */
3539
 
  NULL, /* depends */
 
3674
  innobase_system_variables, /* system variables */
3540
3675
  init_options                /* config options   */
3541
3676
}
3542
3677
DRIZZLE_DECLARE_PLUGIN_END;