~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/haildb/haildb_engine.cc

  • Committer: tdavies
  • Date: 2010-10-13 01:29:12 UTC
  • mto: (1842.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1843.
  • Revision ID: tdavies@molly-20101013012912-vl72hg1y99qgqz5m
File: /drizzled/xid.h. Changed struct name of 'st_drizzle_xid' to 'drizzle_xid', changed it to a C++ class and added constructor initialization list 

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
152
155
 
153
156
  ~HailDBEngine();
154
157
 
155
 
  virtual Cursor *create(Table &table)
 
158
  virtual Cursor *create(TableShare &table)
156
159
  {
157
160
    return new HailDBCursor(*this, table);
158
161
  }
184
187
private:
185
188
  void getTableNamesInSchemaFromHailDB(const drizzled::SchemaIdentifier &schema,
186
189
                                       drizzled::plugin::TableNameList *set_of_names,
187
 
                                       drizzled::TableIdentifier::vector *identifiers);
 
190
                                       drizzled::TableIdentifiers *identifiers);
188
191
 
189
192
public:
190
193
  void doGetTableIdentifiers(drizzled::CachedDirectory &,
191
194
                             const drizzled::SchemaIdentifier &schema,
192
 
                             drizzled::TableIdentifier::vector &identifiers);
 
195
                             drizzled::TableIdentifiers &identifiers);
193
196
 
194
197
  /* The following defines can be increased if necessary */
195
198
  uint32_t max_supported_keys()          const { return 1000; }
354
357
  isolation_level= tx_isolation_to_ib_trx_level((enum_tx_isolation)session_tx_isolation(session));
355
358
  *transaction= ib_trx_begin(isolation_level);
356
359
 
357
 
  return *transaction == NULL;
 
360
  return 0;
358
361
}
359
362
 
360
363
void HailDBEngine::doStartStatement(Session *session)
366
369
                    statement_savepoint_name.length());
367
370
}
368
371
 
369
 
void HailDBEngine::doEndStatement(Session *)
 
372
void HailDBEngine::doEndStatement(Session *session)
370
373
{
 
374
  doCommit(session, false);
371
375
}
372
376
 
373
377
int HailDBEngine::doSetSavepoint(Session* session,
475
479
{
476
480
  uint64_t nr;
477
481
  ib_err_t err;
478
 
  ib_trx_t transaction= *get_trx(getTable()->in_use);
 
482
  ib_trx_t transaction= *get_trx(table->in_use);
479
483
  ib_cursor_attach_trx(cursor, transaction);
480
484
  tuple= ib_clust_read_tuple_create(cursor);
481
485
  err= ib_cursor_last(cursor);
486
490
  else
487
491
  {
488
492
    assert (err == DB_SUCCESS);
489
 
    err= ib_tuple_read_u64(tuple, getTable()->getShare()->fields, &nr);
 
493
    err= ib_tuple_read_u64(tuple, table->getShare()->fields, &nr);
490
494
    nr++;
491
495
  }
492
496
  ib_tuple_delete(tuple);
493
 
  tuple= NULL;
494
497
  err= ib_cursor_reset(cursor);
495
498
  assert(err == DB_SUCCESS);
496
499
  return nr;
502
505
  int error;
503
506
 
504
507
  (void) extra(HA_EXTRA_KEYREAD);
505
 
  getTable()->mark_columns_used_by_index_no_reset(getTable()->getShare()->next_number_index);
506
 
  doStartIndexScan(getTable()->getShare()->next_number_index, 1);
507
 
  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)
508
511
  {                                             // Autoincrement at key-start
509
 
    error=index_last(getTable()->getUpdateRecord());
 
512
    error=index_last(table->getUpdateRecord());
510
513
  }
511
514
  else
512
515
  {
513
516
    unsigned char key[MAX_KEY_LENGTH];
514
 
    key_copy(key, getTable()->getInsertRecord(),
515
 
             getTable()->key_info + getTable()->getShare()->next_number_index,
516
 
             getTable()->getShare()->next_number_key_offset);
517
 
    error= index_read_map(getTable()->getUpdateRecord(), key,
518
 
                          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),
519
522
                          HA_READ_PREFIX_LAST);
520
523
  }
521
524
 
522
525
  if (error)
523
526
    nr=1;
524
527
  else
525
 
    nr= ((uint64_t) getTable()->found_next_number_field->
526
 
         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);
527
530
  doEndIndexScan();
528
531
  (void) extra(HA_EXTRA_NO_KEYREAD);
529
532
 
530
 
  if (getTable()->getShare()->getTableProto()->options().auto_increment_value() > nr)
531
 
    nr= getTable()->getShare()->getTableProto()->options().auto_increment_value();
 
533
  if (table->getShare()->getTableProto()->options().auto_increment_value() > nr)
 
534
    nr= table->getShare()->getTableProto()->options().auto_increment_value();
532
535
 
533
536
  return nr;
534
537
}
561
564
{
562
565
  pthread_mutex_lock(&haildb_mutex);
563
566
 
564
 
  HailDBEngine *a_engine= static_cast<HailDBEngine *>(getEngine());
 
567
  HailDBEngine *a_engine= static_cast<HailDBEngine *>(engine);
565
568
  share= a_engine->findOpenTable(table_name);
566
569
 
567
570
  if (!share)
575
578
      return(NULL);
576
579
    }
577
580
 
578
 
    if (getTable()->found_next_number_field)
 
581
    if (table->found_next_number_field)
579
582
    {
580
583
      share->auto_increment_value.fetch_and_store(
581
584
                                  a_engine->getInitialAutoIncrementValue(this));
604
607
  pthread_mutex_lock(&haildb_mutex);
605
608
  if (!--share->use_count)
606
609
  {
607
 
    HailDBEngine *a_engine= static_cast<HailDBEngine *>(getEngine());
 
610
    HailDBEngine *a_engine= static_cast<HailDBEngine *>(engine);
608
611
    a_engine->deleteOpenTable(share->table_name);
609
612
    delete share;
610
613
  }
798
801
}
799
802
 
800
803
HailDBCursor::HailDBCursor(drizzled::plugin::StorageEngine &engine_arg,
801
 
                           Table &table_arg)
 
804
                           TableShare &table_arg)
802
805
  :Cursor(engine_arg, table_arg),
803
806
   ib_lock_mode(IB_LOCK_NONE),
804
807
   write_can_replace(false),
821
824
int HailDBCursor::open(const char *name, int, uint32_t)
822
825
{
823
826
  const char* haildb_table_name= table_path_to_haildb_name(name);
824
 
  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);
825
828
  bool has_hidden_primary_key= false;
826
829
  ib_id_t idx_id;
827
830
 
828
831
  if (err != DB_SUCCESS)
829
832
    return ib_err_t_to_drizzle_error(err);
830
833
 
831
 
  err= ib_cursor_open_table_using_id(table_id, NULL, &cursor);
832
 
  cursor_is_sec_index= false;
833
 
 
834
 
  if (err != DB_SUCCESS)
835
 
    return ib_err_t_to_drizzle_error(err);
836
 
 
837
834
  err= ib_index_get_id(haildb_table_name, "HIDDEN_PRIMARY", &idx_id);
838
835
 
839
836
  if (err == DB_SUCCESS)
844
841
  lock.init(&share->lock);
845
842
 
846
843
 
847
 
  if (getTable()->getShare()->getPrimaryKey() != MAX_KEY)
848
 
    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;
849
846
  else if (share->has_hidden_primary_key)
850
847
    ref_length= sizeof(uint64_t);
851
848
  else
852
849
  {
853
 
    unsigned int keynr= get_first_unique_index(*getTable());
854
 
    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;
855
852
  }
856
853
 
857
854
  in_table_scan= false;
1217
1214
 
1218
1215
  if (table_message.type() == message::Table::TEMPORARY)
1219
1216
  {
1220
 
    session.getMessageCache().storeTableMessage(identifier, table_message);
 
1217
    session.storeTableMessage(identifier, table_message);
1221
1218
    haildb_err= DB_SUCCESS;
1222
1219
  }
1223
1220
  else
1309
1306
 
1310
1307
  if (identifier.getType() == message::Table::TEMPORARY)
1311
1308
  {
1312
 
      session.getMessageCache().removeTableMessage(identifier);
 
1309
      session.removeTableMessage(identifier);
1313
1310
      delete_table_message_from_haildb(haildb_schema_transaction,
1314
1311
                                       haildb_table_name.c_str());
1315
1312
  }
1467
1464
  if (to.getType() == message::Table::TEMPORARY
1468
1465
      && from.getType() == message::Table::TEMPORARY)
1469
1466
  {
1470
 
    session.getMessageCache().renameTableMessage(from, to);
 
1467
    session.renameTableMessage(from, to);
1471
1468
    return 0;
1472
1469
  }
1473
1470
 
1513
1510
void HailDBEngine::getTableNamesInSchemaFromHailDB(
1514
1511
                                 const drizzled::SchemaIdentifier &schema,
1515
1512
                                 drizzled::plugin::TableNameList *set_of_names,
1516
 
                                 drizzled::TableIdentifier::vector *identifiers)
 
1513
                                 drizzled::TableIdentifiers *identifiers)
1517
1514
{
1518
1515
  ib_trx_t   transaction;
1519
1516
  ib_crsr_t  cursor;
1606
1603
 
1607
1604
void HailDBEngine::doGetTableIdentifiers(drizzled::CachedDirectory &,
1608
1605
                                                 const drizzled::SchemaIdentifier &schema,
1609
 
                                                 drizzled::TableIdentifier::vector &identifiers)
 
1606
                                                 drizzled::TableIdentifiers &identifiers)
1610
1607
{
1611
1608
  getTableNamesInSchemaFromHailDB(schema, NULL, &identifiers);
1612
1609
}
1738
1735
  string haildb_table_name;
1739
1736
 
1740
1737
  /* Check temporary tables!? */
1741
 
  if (session.getMessageCache().getTableMessage(identifier, table))
 
1738
  if (session.getTableMessage(identifier, table))
1742
1739
    return EEXIST;
1743
1740
 
1744
1741
  TableIdentifier_to_haildb_name(identifier, &haildb_table_name);
1785
1782
  return("BTREE");
1786
1783
}
1787
1784
 
1788
 
static ib_err_t write_row_to_haildb_tuple(const unsigned char* buf,
1789
 
                                          Field **fields, ib_tpl_t tuple)
 
1785
static ib_err_t write_row_to_haildb_tuple(Field **fields, ib_tpl_t tuple)
1790
1786
{
1791
1787
  int colnr= 0;
1792
1788
  ib_err_t err= DB_ERROR;
1793
 
  ptrdiff_t row_offset= buf - (*fields)->getTable()->getInsertRecord();
1794
1789
 
1795
1790
  for (Field **field= fields; *field; field++, colnr++)
1796
1791
  {
1797
 
    (**field).move_field_offset(row_offset);
1798
 
 
1799
1792
    if (! (**field).isWriteSet() && (**field).is_null())
1800
 
    {
1801
 
      (**field).move_field_offset(-row_offset);
1802
1793
      continue;
1803
 
    }
1804
1794
 
1805
1795
    if ((**field).is_null())
1806
1796
    {
1807
1797
      err= ib_col_set_value(tuple, colnr, NULL, IB_SQL_NULL);
1808
1798
      assert(err == DB_SUCCESS);
1809
 
      (**field).move_field_offset(-row_offset);
1810
1799
      continue;
1811
1800
    }
1812
1801
 
1818
1807
      */
1819
1808
      String str;
1820
1809
      (**field).setReadSet();
1821
 
      (**field).val_str_internal(&str);
 
1810
      (**field).val_str(&str);
1822
1811
      err= ib_col_set_value(tuple, colnr, str.ptr(), str.length());
1823
1812
    }
1824
1813
    else if ((**field).type() == DRIZZLE_TYPE_ENUM)
1844
1833
    }
1845
1834
 
1846
1835
    assert (err == DB_SUCCESS);
1847
 
 
1848
 
    (**field).move_field_offset(-row_offset);
1849
1836
  }
1850
1837
 
1851
1838
  return err;
1890
1877
  ib_err_t err;
1891
1878
  int ret= 0;
1892
1879
 
1893
 
  ib_trx_t transaction= *get_trx(getTable()->in_use);
 
1880
  ib_trx_t transaction= *get_trx(table->in_use);
1894
1881
 
1895
1882
  tuple= ib_clust_read_tuple_create(cursor);
1896
1883
 
1897
 
  if (cursor_is_sec_index)
1898
 
  {
1899
 
    err= ib_cursor_close(cursor);
1900
 
    assert(err == DB_SUCCESS);
1901
 
 
1902
 
    err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
1903
 
 
1904
 
    if (err != DB_SUCCESS)
1905
 
      return ib_err_t_to_drizzle_error(err);
1906
 
 
1907
 
    cursor_is_sec_index= false;
1908
 
  }
1909
 
  else
1910
 
  {
1911
 
    ib_cursor_attach_trx(cursor, transaction);
1912
 
  }
 
1884
  ib_cursor_attach_trx(cursor, transaction);
1913
1885
 
1914
1886
  err= ib_cursor_first(cursor);
1915
1887
  if (current_session->lex->sql_command == SQLCOM_CREATE_TABLE
1927
1899
     * yuck.
1928
1900
     */
1929
1901
 
1930
 
    HailDBEngine *storage_engine= static_cast<HailDBEngine*>(getEngine());
 
1902
    HailDBEngine *storage_engine= static_cast<HailDBEngine*>(engine);
1931
1903
    err= ib_cursor_reset(cursor);
1932
1904
    storage_engine->doCommit(current_session, true);
1933
1905
    storage_engine->doStartTransaction(current_session, START_TRANS_NO_OPTIONS);
1934
 
    transaction= *get_trx(getTable()->in_use);
 
1906
    transaction= *get_trx(table->in_use);
1935
1907
    assert(err == DB_SUCCESS);
1936
1908
    ib_cursor_attach_trx(cursor, transaction);
1937
1909
    err= ib_cursor_first(cursor);
1940
1912
  assert(err == DB_SUCCESS || err == DB_END_OF_INDEX);
1941
1913
 
1942
1914
 
1943
 
  if (getTable()->next_number_field)
 
1915
  if (table->next_number_field)
1944
1916
  {
1945
1917
    update_auto_increment();
1946
1918
 
1947
 
    uint64_t temp_auto= getTable()->next_number_field->val_int();
 
1919
    uint64_t temp_auto= table->next_number_field->val_int();
1948
1920
 
1949
 
    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))
1950
1922
    {
1951
1923
      while (true)
1952
1924
      {
1968
1940
 
1969
1941
  }
1970
1942
 
1971
 
  write_row_to_haildb_tuple(record, getTable()->getFields(), tuple);
 
1943
  write_row_to_haildb_tuple(table->getFields(), tuple);
1972
1944
 
1973
1945
  if (share->has_hidden_primary_key)
1974
1946
  {
1975
 
    err= ib_tuple_write_u64(tuple, getTable()->getShare()->fields, 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());
1976
1948
  }
1977
1949
 
1978
1950
  err= ib_cursor_insert_row(cursor, tuple);
1981
1953
  {
1982
1954
    if (write_can_replace)
1983
1955
    {
1984
 
      store_key_value_from_haildb(getTable()->key_info + getTable()->getShare()->getPrimaryKey(),
 
1956
      store_key_value_from_haildb(table->key_info + table->getShare()->getPrimaryKey(),
1985
1957
                                  ref, ref_length, record);
1986
1958
 
1987
1959
      ib_tpl_t search_tuple= ib_clust_search_tuple_create(cursor);
1988
1960
 
1989
1961
      fill_ib_search_tpl_from_drizzle_key(search_tuple,
1990
 
                                          getTable()->key_info + 0,
 
1962
                                          table->key_info + 0,
1991
1963
                                          ref, ref_length);
1992
1964
 
1993
1965
      int res;
2001
1973
      err= ib_cursor_first(cursor);
2002
1974
      assert(err == DB_SUCCESS || err == DB_END_OF_INDEX);
2003
1975
 
2004
 
      write_row_to_haildb_tuple(record, getTable()->getFields(), tuple);
 
1976
      write_row_to_haildb_tuple(table->getFields(), tuple);
2005
1977
 
2006
1978
      err= ib_cursor_insert_row(cursor, tuple);
2007
1979
      assert(err==DB_SUCCESS); // probably be nice and process errors
2014
1986
 
2015
1987
  tuple= ib_tuple_clear(tuple);
2016
1988
  ib_tuple_delete(tuple);
2017
 
  tuple= NULL;
2018
1989
  err= ib_cursor_reset(cursor);
2019
1990
 
2020
1991
  return ret;
2021
1992
}
2022
1993
 
2023
 
int HailDBCursor::doUpdateRecord(const unsigned char *old_data,
2024
 
                                 unsigned char *new_data)
 
1994
int HailDBCursor::doUpdateRecord(const unsigned char *,
 
1995
                                         unsigned char *)
2025
1996
{
2026
1997
  ib_tpl_t update_tuple;
2027
1998
  ib_err_t err;
2028
 
  bool created_tuple= false;
2029
1999
 
2030
2000
  update_tuple= ib_clust_read_tuple_create(cursor);
2031
2001
 
2032
 
  if (tuple == NULL)
2033
 
  {
2034
 
    ib_trx_t transaction= *get_trx(getTable()->in_use);
2035
 
 
2036
 
    if (cursor_is_sec_index)
2037
 
    {
2038
 
      err= ib_cursor_close(cursor);
2039
 
      assert(err == DB_SUCCESS);
2040
 
 
2041
 
      err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
2042
 
 
2043
 
      if (err != DB_SUCCESS)
2044
 
        return ib_err_t_to_drizzle_error(err);
2045
 
      cursor_is_sec_index= false;
2046
 
    }
2047
 
    else
2048
 
    {
2049
 
      ib_cursor_attach_trx(cursor, transaction);
2050
 
    }
2051
 
 
2052
 
    store_key_value_from_haildb(getTable()->key_info + getTable()->getShare()->getPrimaryKey(),
2053
 
                                  ref, ref_length, old_data);
2054
 
 
2055
 
    ib_tpl_t search_tuple= ib_clust_search_tuple_create(cursor);
2056
 
 
2057
 
    fill_ib_search_tpl_from_drizzle_key(search_tuple,
2058
 
                                        getTable()->key_info + 0,
2059
 
                                        ref, ref_length);
2060
 
 
2061
 
    err= ib_cursor_set_lock_mode(cursor, IB_LOCK_X);
2062
 
    assert(err == DB_SUCCESS);
2063
 
 
2064
 
    int res;
2065
 
    err= ib_cursor_moveto(cursor, search_tuple, IB_CUR_GE, &res);
2066
 
    assert(err == DB_SUCCESS);
2067
 
 
2068
 
    tuple= ib_clust_read_tuple_create(cursor);
2069
 
 
2070
 
    err= ib_cursor_read_row(cursor, tuple);
2071
 
    assert(err == DB_SUCCESS);// FIXME
2072
 
 
2073
 
    created_tuple= true;
2074
 
  }
2075
 
 
2076
2002
  err= ib_tuple_copy(update_tuple, tuple);
2077
2003
  assert(err == DB_SUCCESS);
2078
2004
 
2079
 
  write_row_to_haildb_tuple(new_data, getTable()->getFields(), update_tuple);
 
2005
  write_row_to_haildb_tuple(table->getFields(), update_tuple);
2080
2006
 
2081
2007
  err= ib_cursor_update_row(cursor, tuple, update_tuple);
2082
2008
 
2083
2009
  ib_tuple_delete(update_tuple);
2084
2010
 
2085
 
  if (created_tuple)
2086
 
  {
2087
 
    ib_err_t ib_err= ib_cursor_reset(cursor); //fixme check error
2088
 
    assert(ib_err == DB_SUCCESS);
2089
 
    tuple= ib_tuple_clear(tuple);
2090
 
    ib_tuple_delete(tuple);
2091
 
    tuple= NULL;
2092
 
  }
2093
 
 
2094
2011
  advance_cursor= true;
2095
2012
 
2096
 
  return ib_err_t_to_drizzle_error(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;
2097
2019
}
2098
2020
 
2099
2021
int HailDBCursor::doDeleteRecord(const unsigned char *)
2100
2022
{
2101
2023
  ib_err_t err;
2102
2024
 
2103
 
  assert(ib_cursor_is_positioned(cursor) == IB_TRUE);
2104
2025
  err= ib_cursor_delete_row(cursor);
 
2026
  if (err != DB_SUCCESS)
 
2027
    return -1; // FIXME
2105
2028
 
2106
2029
  advance_cursor= true;
2107
 
 
2108
 
  return ib_err_t_to_drizzle_error(err);
 
2030
  return 0;
2109
2031
}
2110
2032
 
2111
2033
int HailDBCursor::delete_all_rows(void)
2112
2034
{
2113
2035
  /* I *think* ib_truncate is non-transactional....
2114
2036
     so only support TRUNCATE and not DELETE FROM t;
2115
 
     (this is what ha_innodb does)
 
2037
     (this is what ha_haildb does)
2116
2038
  */
2117
 
  if (session_sql_command(getTable()->in_use) != SQLCOM_TRUNCATE)
 
2039
  if (session_sql_command(table->in_use) != SQLCOM_TRUNCATE)
2118
2040
    return HA_ERR_WRONG_COMMAND;
2119
2041
 
2120
2042
  ib_id_t id;
2122
2044
 
2123
2045
  ib_trx_t transaction= ib_trx_begin(IB_TRX_REPEATABLE_READ);
2124
2046
 
2125
 
  if (cursor_is_sec_index)
2126
 
  {
2127
 
    err= ib_cursor_close(cursor);
2128
 
    assert(err == DB_SUCCESS);
2129
 
 
2130
 
    err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
2131
 
 
2132
 
    if (err != DB_SUCCESS)
2133
 
      return ib_err_t_to_drizzle_error(err);
2134
 
    cursor_is_sec_index= false;
2135
 
  }
2136
 
  else
2137
 
  {
2138
 
    ib_cursor_attach_trx(cursor, transaction);
2139
 
  }
 
2047
  ib_cursor_attach_trx(cursor, transaction);
2140
2048
 
2141
2049
  err= ib_schema_lock_exclusive(transaction);
2142
2050
  if (err != DB_SUCCESS)
2143
2051
  {
2144
2052
    ib_err_t rollback_err= ib_trx_rollback(transaction);
2145
2053
 
2146
 
    push_warning_printf(getTable()->in_use, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
 
2054
    push_warning_printf(table->in_use, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
2147
2055
                        ER_CANT_DELETE_FILE,
2148
2056
                        _("Cannot Lock HailDB Data Dictionary. HailDB Error %d (%s)\n"),
2149
2057
                        err, ib_strerror(err));
2172
2080
  ib_schema_unlock(transaction);
2173
2081
  ib_err_t rollback_err= ib_trx_rollback(transaction);
2174
2082
  assert(rollback_err == DB_SUCCESS);
2175
 
  return ib_err_t_to_drizzle_error(err);
 
2083
  return err;
2176
2084
}
2177
2085
 
2178
2086
int HailDBCursor::doStartTableScan(bool)
2179
2087
{
2180
 
  ib_err_t err= DB_SUCCESS;
 
2088
  ib_err_t err;
2181
2089
  ib_trx_t transaction;
2182
2090
 
2183
2091
  if (in_table_scan)
2184
2092
    doEndTableScan();
2185
2093
  in_table_scan= true;
2186
2094
 
2187
 
  transaction= *get_trx(getTable()->in_use);
 
2095
  transaction= *get_trx(table->in_use);
2188
2096
 
2189
2097
  assert(transaction != NULL);
2190
2098
 
2191
 
  if (cursor_is_sec_index)
2192
 
  {
2193
 
    err= ib_cursor_close(cursor);
2194
 
    assert(err == DB_SUCCESS);
2195
 
 
2196
 
    err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
2197
 
    cursor_is_sec_index= false;
2198
 
  }
2199
 
  else
2200
 
  {
2201
 
    ib_cursor_attach_trx(cursor, transaction);
2202
 
  }
2203
 
 
2204
 
  if (err != DB_SUCCESS)
2205
 
    return ib_err_t_to_drizzle_error(err);
 
2099
  ib_cursor_attach_trx(cursor, transaction);
2206
2100
 
2207
2101
  err= ib_cursor_set_lock_mode(cursor, ib_lock_mode);
2208
2102
  assert(err == DB_SUCCESS); // FIXME
2230
2124
 
2231
2125
  err= ib_cursor_read_row(cursor, tuple);
2232
2126
 
2233
 
  if (err == DB_RECORD_NOT_FOUND)
 
2127
  if (err != DB_SUCCESS) // FIXME
2234
2128
    return HA_ERR_END_OF_FILE;
2235
 
  if (err != DB_SUCCESS)
2236
 
    return ib_err_t_to_drizzle_error(err);
2237
2129
 
2238
2130
  int colnr= 0;
2239
2131
 
2244
2136
  for (Field **field= table->getFields() ; *field ; field++, colnr++)
2245
2137
  {
2246
2138
    if (! (**field).isReadSet())
2247
 
      (**field).setReadSet(); /* Fucking broken API screws us royally. */
 
2139
      continue;
2248
2140
 
2249
2141
    (**field).move_field_offset(row_offset);
2250
2142
 
2254
2146
    if (length == IB_SQL_NULL)
2255
2147
    {
2256
2148
      (**field).set_null();
2257
 
      (**field).move_field_offset(-row_offset);
2258
2149
      continue;
2259
2150
    }
2260
2151
    else
2298
2189
 
2299
2190
    (**field).move_field_offset(-row_offset);
2300
2191
 
2301
 
    if (err != DB_SUCCESS)
2302
 
      return ib_err_t_to_drizzle_error(err);
2303
2192
  }
2304
2193
 
2305
2194
  if (has_hidden_primary_key)
2307
2196
    err= ib_tuple_read_u64(tuple, colnr, hidden_pkey);
2308
2197
  }
2309
2198
 
2310
 
  return ib_err_t_to_drizzle_error(err);
 
2199
  return 0;
2311
2200
}
2312
2201
 
2313
2202
int HailDBCursor::rnd_next(unsigned char *buf)
2319
2208
    return previous_error;
2320
2209
 
2321
2210
  if (advance_cursor)
2322
 
  {
2323
2211
    err= ib_cursor_next(cursor);
2324
 
    if (err != DB_SUCCESS)
2325
 
      return ib_err_t_to_drizzle_error(err);
2326
 
  }
2327
2212
 
2328
2213
  tuple= ib_tuple_clear(tuple);
2329
 
  ret= read_row_from_haildb(buf, cursor, tuple, getTable(),
 
2214
  ret= read_row_from_haildb(buf, cursor, tuple, table,
2330
2215
                            share->has_hidden_primary_key,
2331
2216
                            &hidden_autoinc_pkey_position);
2332
2217
 
2339
2224
  ib_err_t err;
2340
2225
 
2341
2226
  ib_tuple_delete(tuple);
2342
 
  tuple= NULL;
2343
2227
  err= ib_cursor_reset(cursor);
2344
2228
  assert(err == DB_SUCCESS);
2345
2229
  in_table_scan= false;
2346
2230
  previous_error= 0;
2347
 
  return ib_err_t_to_drizzle_error(err);
 
2231
  return 0;
2348
2232
}
2349
2233
 
2350
2234
int HailDBCursor::rnd_pos(unsigned char *buf, unsigned char *pos)
2358
2242
  {
2359
2243
    err= ib_col_set_value(search_tuple, 0,
2360
2244
                          ((uint64_t*)(pos)), sizeof(uint64_t));
2361
 
    if (err != DB_SUCCESS)
2362
 
      return ib_err_t_to_drizzle_error(err);
2363
2245
  }
2364
2246
  else
2365
2247
  {
2366
2248
    unsigned int keynr;
2367
 
    if (getTable()->getShare()->getPrimaryKey() != MAX_KEY)
2368
 
      keynr= getTable()->getShare()->getPrimaryKey();
 
2249
    if (table->getShare()->getPrimaryKey() != MAX_KEY)
 
2250
      keynr= table->getShare()->getPrimaryKey();
2369
2251
    else
2370
 
      keynr= get_first_unique_index(*getTable());
 
2252
      keynr= get_first_unique_index(*table);
2371
2253
 
2372
2254
    fill_ib_search_tpl_from_drizzle_key(search_tuple,
2373
 
                                        getTable()->key_info + keynr,
 
2255
                                        table->key_info + keynr,
2374
2256
                                        pos, ref_length);
2375
2257
  }
2376
2258
 
2377
2259
  err= ib_cursor_moveto(cursor, search_tuple, IB_CUR_GE, &res);
2378
 
  if (err != DB_SUCCESS)
2379
 
    return ib_err_t_to_drizzle_error(err);
 
2260
  assert(err == DB_SUCCESS);
2380
2261
 
2381
2262
  assert(res==0);
2382
2263
  if (res != 0)
2387
2268
  tuple= ib_tuple_clear(tuple);
2388
2269
 
2389
2270
  if (ret == 0)
2390
 
    ret= read_row_from_haildb(buf, cursor, tuple, getTable(),
 
2271
    ret= read_row_from_haildb(buf, cursor, tuple, table,
2391
2272
                              share->has_hidden_primary_key,
2392
2273
                              &hidden_autoinc_pkey_position);
2393
2274
 
2425
2306
      }
2426
2307
 
2427
2308
      String str;
2428
 
      field->val_str_internal(&str);
 
2309
      field->val_str(&str);
2429
2310
 
2430
2311
      *ref++= (char)(str.length() & 0x000000ff);
2431
2312
      *ref++= (char)((str.length()>>8) & 0x000000ff);
2458
2339
  else
2459
2340
  {
2460
2341
    unsigned int keynr;
2461
 
    if (getTable()->getShare()->getPrimaryKey() != MAX_KEY)
2462
 
      keynr= getTable()->getShare()->getPrimaryKey();
 
2342
    if (table->getShare()->getPrimaryKey() != MAX_KEY)
 
2343
      keynr= table->getShare()->getPrimaryKey();
2463
2344
    else
2464
 
      keynr= get_first_unique_index(*getTable());
 
2345
      keynr= get_first_unique_index(*table);
2465
2346
 
2466
 
    store_key_value_from_haildb(getTable()->key_info + keynr,
 
2347
    store_key_value_from_haildb(table->key_info + keynr,
2467
2348
                                ref, ref_length, record);
2468
2349
  }
2469
2350
 
2472
2353
 
2473
2354
double HailDBCursor::scan_time()
2474
2355
{
2475
 
  ib_table_stats_t table_stats;
2476
 
  ib_err_t err;
2477
 
 
2478
 
  err= ib_get_table_statistics(cursor, &table_stats, sizeof(table_stats));
2479
 
 
2480
 
  /* Approximate I/O seeks for full table scan */
2481
 
  return (double) (table_stats.stat_clustered_index_size / 16384);
 
2356
  return 0.1;
2482
2357
}
2483
2358
 
2484
2359
int HailDBCursor::info(uint32_t flag)
2485
2360
{
2486
 
  ib_table_stats_t table_stats;
2487
 
  ib_err_t err;
2488
 
 
2489
 
  if (flag & HA_STATUS_VARIABLE)
2490
 
  {
2491
 
    err= ib_get_table_statistics(cursor, &table_stats, sizeof(table_stats));
2492
 
 
2493
 
    stats.records= table_stats.stat_n_rows;
2494
 
 
2495
 
    if (table_stats.stat_n_rows < 2)
2496
 
      stats.records= 2;
2497
 
 
2498
 
    stats.deleted= 0;
2499
 
    stats.data_file_length= table_stats.stat_clustered_index_size;
2500
 
    stats.index_file_length= table_stats.stat_sum_of_other_index_sizes;
2501
 
 
2502
 
    stats.mean_rec_length= stats.data_file_length / stats.records;
2503
 
  }
 
2361
  stats.records= 2;
2504
2362
 
2505
2363
  if (flag & HA_STATUS_AUTO)
2506
2364
    stats.auto_increment_value= 1;
2507
 
 
2508
 
  if (flag & HA_STATUS_ERRKEY) {
2509
 
    const char *err_table_name;
2510
 
    const char *err_index_name;
2511
 
 
2512
 
    ib_trx_t transaction= *get_trx(getTable()->in_use);
2513
 
 
2514
 
    err= ib_get_duplicate_key(transaction, &err_table_name, &err_index_name);
2515
 
 
2516
 
    errkey= -1;
2517
 
 
2518
 
    for (unsigned int i = 0; i < getTable()->getShare()->keys; i++)
2519
 
    {
2520
 
      if (strcmp(err_index_name, getTable()->key_info[i].name) == 0)
2521
 
      {
2522
 
        errkey= i;
2523
 
        break;
2524
 
      }
2525
 
    }
2526
 
 
2527
 
  }
2528
 
 
2529
2365
  return(0);
2530
2366
}
2531
2367
 
2532
2368
int HailDBCursor::doStartIndexScan(uint32_t keynr, bool)
2533
2369
{
2534
 
  ib_err_t err;
2535
 
  ib_trx_t transaction= *get_trx(getTable()->in_use);
 
2370
  ib_trx_t transaction= *get_trx(table->in_use);
2536
2371
 
2537
2372
  active_index= keynr;
2538
2373
 
 
2374
  ib_cursor_attach_trx(cursor, transaction);
 
2375
 
2539
2376
  if (active_index == 0 && ! share->has_hidden_primary_key)
2540
2377
  {
2541
 
    if (cursor_is_sec_index)
2542
 
    {
2543
 
      err= ib_cursor_close(cursor);
2544
 
      assert(err == DB_SUCCESS);
2545
 
 
2546
 
      err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
2547
 
 
2548
 
      if (err != DB_SUCCESS)
2549
 
        return ib_err_t_to_drizzle_error(err);
2550
 
 
2551
 
    }
2552
 
    else
2553
 
    {
2554
 
      ib_cursor_attach_trx(cursor, transaction);
2555
 
    }
2556
 
 
2557
 
    cursor_is_sec_index= false;
2558
2378
    tuple= ib_clust_read_tuple_create(cursor);
2559
2379
  }
2560
2380
  else
2561
2381
  {
 
2382
    ib_err_t err;
2562
2383
    ib_id_t index_id;
2563
 
    err= ib_index_get_id(table_path_to_haildb_name(getShare()->getPath()),
2564
 
                         getShare()->getKeyInfo(keynr).name,
 
2384
    err= ib_index_get_id(table_path_to_haildb_name(table_share->getPath()),
 
2385
                         table_share->getKeyInfo(keynr).name,
2565
2386
                         &index_id);
2566
2387
    if (err != DB_SUCCESS)
2567
 
      return ib_err_t_to_drizzle_error(err);
 
2388
      return -1;
2568
2389
 
2569
2390
    err= ib_cursor_close(cursor);
2570
2391
    assert(err == DB_SUCCESS);
2571
 
 
2572
2392
    err= ib_cursor_open_index_using_id(index_id, transaction, &cursor);
2573
2393
 
2574
2394
    if (err != DB_SUCCESS)
2575
 
      return ib_err_t_to_drizzle_error(err);
2576
 
 
2577
 
    cursor_is_sec_index= true;
 
2395
      return -1;
2578
2396
 
2579
2397
    tuple= ib_clust_read_tuple_create(cursor);
2580
2398
    ib_cursor_set_cluster_access(cursor);
2581
2399
  }
2582
2400
 
2583
 
  err= ib_cursor_set_lock_mode(cursor, ib_lock_mode);
 
2401
  ib_err_t err= ib_cursor_set_lock_mode(cursor, ib_lock_mode);
2584
2402
  assert(err == DB_SUCCESS);
2585
2403
 
2586
2404
  advance_cursor= false;
2711
2529
    search_tuple= ib_sec_search_tuple_create(cursor);
2712
2530
 
2713
2531
  fill_ib_search_tpl_from_drizzle_key(search_tuple,
2714
 
                                      getTable()->key_info + active_index,
 
2532
                                      table->key_info + active_index,
2715
2533
                                      key_ptr, key_len);
2716
2534
 
2717
2535
  err= ib_cursor_moveto(cursor, search_tuple, search_mode, &res);
2719
2537
 
2720
2538
  if ((err == DB_RECORD_NOT_FOUND || err == DB_END_OF_INDEX))
2721
2539
  {
2722
 
    getTable()->status= STATUS_NOT_FOUND;
 
2540
    table->status= STATUS_NOT_FOUND;
2723
2541
    return HA_ERR_KEY_NOT_FOUND;
2724
2542
  }
2725
2543
 
2729
2547
  }
2730
2548
 
2731
2549
  tuple= ib_tuple_clear(tuple);
2732
 
  ret= read_row_from_haildb(buf, cursor, tuple, getTable(),
 
2550
  ret= read_row_from_haildb(buf, cursor, tuple, table,
2733
2551
                            share->has_hidden_primary_key,
2734
2552
                            &hidden_autoinc_pkey_position,
2735
2553
                            (allocate_blobs)? &blobroot : NULL);
2736
2554
  if (ret == 0)
2737
 
    getTable()->status= 0;
 
2555
    table->status= 0;
2738
2556
  else
2739
 
    getTable()->status= STATUS_NOT_FOUND;
 
2557
    table->status= STATUS_NOT_FOUND;
2740
2558
 
2741
2559
  advance_cursor= true;
2742
2560
 
2758
2576
  /* works only with key prefixes */
2759
2577
  assert(((keypart_map_arg + 1) & keypart_map_arg) == 0);
2760
2578
 
2761
 
  KeyPartInfo *key_part_found= getTable()->getShare()->getKeyInfo(key_position).key_part;
2762
 
  KeyPartInfo *end_key_part_found= key_part_found + getTable()->getShare()->getKeyInfo(key_position).key_parts;
 
2579
  KeyPartInfo *key_part_found= table->getShare()->getKeyInfo(key_position).key_part;
 
2580
  KeyPartInfo *end_key_part_found= key_part_found + table->getShare()->getKeyInfo(key_position).key_parts;
2763
2581
  uint32_t length= 0;
2764
2582
 
2765
2583
  while (key_part_found < end_key_part_found && keypart_map_arg)
2818
2636
  }
2819
2637
 
2820
2638
  tuple= ib_tuple_clear(tuple);
2821
 
  ret= read_row_from_haildb(buf, cursor, tuple, getTable(),
 
2639
  ret= read_row_from_haildb(buf, cursor, tuple, table,
2822
2640
                            share->has_hidden_primary_key,
2823
2641
                            &hidden_autoinc_pkey_position);
2824
2642
 
2846
2664
      if (err == DB_END_OF_INDEX)
2847
2665
        return HA_ERR_END_OF_FILE;
2848
2666
      else
2849
 
        return ib_err_t_to_drizzle_error(err);
 
2667
        return -1; // FIXME
2850
2668
    }
2851
2669
  }
2852
2670
 
2853
2671
  tuple= ib_tuple_clear(tuple);
2854
 
  ret= read_row_from_haildb(buf, cursor, tuple, getTable(),
 
2672
  ret= read_row_from_haildb(buf, cursor, tuple, table,
2855
2673
                            share->has_hidden_primary_key,
2856
2674
                            &hidden_autoinc_pkey_position);
2857
2675
 
2871
2689
    return ib_err_t_to_drizzle_error(err);
2872
2690
 
2873
2691
  tuple= ib_tuple_clear(tuple);
2874
 
  ret= read_row_from_haildb(buf, cursor, tuple, getTable(),
 
2692
  ret= read_row_from_haildb(buf, cursor, tuple, table,
2875
2693
                            share->has_hidden_primary_key,
2876
2694
                            &hidden_autoinc_pkey_position);
2877
2695
 
2891
2709
    return ib_err_t_to_drizzle_error(err);
2892
2710
 
2893
2711
  tuple= ib_tuple_clear(tuple);
2894
 
  ret= read_row_from_haildb(buf, cursor, tuple, getTable(),
 
2712
  ret= read_row_from_haildb(buf, cursor, tuple, table,
2895
2713
                            share->has_hidden_primary_key,
2896
2714
                            &hidden_autoinc_pkey_position);
2897
2715
  advance_cursor= true;
2983
2801
  return err;
2984
2802
}
2985
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;
2986
2807
static bool innobase_use_doublewrite= true;
 
2808
static unsigned long srv_io_capacity= 200;
 
2809
static unsigned long innobase_fast_shutdown= 1;
2987
2810
static bool srv_file_per_table= false;
2988
2811
static bool innobase_adaptive_hash_index;
2989
2812
static bool srv_adaptive_flushing;
2991
2814
static bool innobase_rollback_on_timeout;
2992
2815
static bool innobase_create_status_file;
2993
2816
static bool srv_use_sys_malloc;
2994
 
static string innobase_file_format_name;
2995
 
typedef constrained_check<unsigned int, 1000, 1> autoextend_constraint;
2996
 
static autoextend_constraint srv_auto_extend_increment;
2997
 
typedef constrained_check<size_t, SIZE_MAX, 5242880, 1048576> buffer_pool_constraint;
2998
 
static buffer_pool_constraint innobase_buffer_pool_size;
2999
 
typedef constrained_check<size_t, SIZE_MAX, 512, 1024> additional_mem_pool_constraint;
3000
 
static additional_mem_pool_constraint innobase_additional_mem_pool_size;
3001
 
static bool  innobase_use_checksums= true;
3002
 
typedef constrained_check<unsigned int, UINT_MAX, 100> io_capacity_constraint;
3003
 
typedef constrained_check<uint32_t, 2, 0> trinary_constraint;
3004
 
static trinary_constraint innobase_fast_shutdown;
3005
 
static trinary_constraint srv_flush_log_at_trx_commit;
3006
 
typedef constrained_check<uint32_t, 6, 0> force_recovery_constraint;
3007
 
static force_recovery_constraint innobase_force_recovery;
3008
 
typedef constrained_check<int64_t, INT64_MAX, 1024*1024, 1024*1024> log_file_constraint;
3009
 
static log_file_constraint haildb_log_file_size;
3010
 
 
3011
 
static io_capacity_constraint srv_io_capacity;
3012
 
typedef constrained_check<unsigned int, 100, 2> log_files_in_group_constraint;
3013
 
static log_files_in_group_constraint haildb_log_files_in_group;
3014
 
typedef constrained_check<unsigned int, 1024*1024*1024, 1> lock_wait_constraint;
3015
 
static lock_wait_constraint innobase_lock_wait_timeout;
3016
 
typedef constrained_check<long, LONG_MAX, 256*1024, 1024> log_buffer_size_constraint;
3017
 
static log_buffer_size_constraint innobase_log_buffer_size;
3018
 
typedef constrained_check<unsigned int, 97, 5> lru_old_blocks_constraint;
3019
 
static lru_old_blocks_constraint innobase_lru_old_blocks_pct;
3020
 
typedef constrained_check<unsigned int, 99, 0> max_dirty_pages_constraint;
3021
 
static max_dirty_pages_constraint haildb_max_dirty_pages_pct;
3022
 
static uint64_constraint haildb_max_purge_lag;
3023
 
static uint64_constraint haildb_sync_spin_loops;
3024
 
typedef constrained_check<uint32_t, UINT32_MAX, 10> open_files_constraint;
3025
 
static open_files_constraint haildb_open_files;
3026
 
typedef constrained_check<unsigned int, 64, 1> io_threads_constraint;
3027
 
static io_threads_constraint haildb_read_io_threads;
3028
 
static io_threads_constraint haildb_write_io_threads;
3029
 
 
3030
 
 
3031
 
static uint32_t innobase_lru_block_access_recency;
3032
 
 
3033
 
 
3034
 
 
3035
 
static int haildb_file_format_name_validate(Session*, set_var *var)
3036
 
{
3037
 
 
3038
 
  const char *format= var->value->str_value.ptr();
3039
 
  if (format == NULL)
3040
 
    return 1;
3041
 
 
3042
 
  ib_err_t err= ib_cfg_set_text("file_format", format);
3043
 
 
3044
 
  if (err == DB_SUCCESS)
3045
 
  {
3046
 
    innobase_file_format_name= format;
3047
 
    return 0;
3048
 
  }
3049
 
  else
3050
 
    return 1;
3051
 
}
3052
 
 
3053
 
static void haildb_lru_old_blocks_pct_update(Session*, sql_var_t)
3054
 
{
3055
 
  int ret= ib_cfg_set_int("lru_old_blocks_pct", static_cast<uint32_t>(innobase_lru_old_blocks_pct));
3056
 
  (void)ret;
3057
 
}
3058
 
 
3059
 
static void haildb_lru_block_access_recency_update(Session*, sql_var_t)
3060
 
{
3061
 
  int ret= ib_cfg_set_int("lru_block_access_recency", static_cast<uint32_t>(innobase_lru_block_access_recency));
3062
 
  (void)ret;
3063
 
}
3064
 
 
3065
 
static void haildb_status_file_update(Session*, sql_var_t)
3066
 
{
3067
 
  ib_err_t err;
3068
 
 
3069
 
  if (innobase_create_status_file)
3070
 
    err= ib_cfg_set_bool_on("status_file");
3071
 
  else
3072
 
    err= ib_cfg_set_bool_off("status_file");
3073
 
  (void)err;
3074
 
}
3075
 
 
3076
 
extern "C" int haildb_errmsg_callback(ib_msg_stream_t, const char *fmt, ...);
3077
 
namespace drizzled
3078
 
{
3079
 
extern bool volatile shutdown_in_progress;
3080
 
}
3081
 
 
3082
 
extern "C" int haildb_errmsg_callback(ib_msg_stream_t, const char *fmt, ...)
3083
 
{
3084
 
  bool r= false;
3085
 
  va_list args;
3086
 
  va_start(args, fmt);
3087
 
  if (! shutdown_in_progress)
3088
 
    r= plugin::ErrorMessage::vprintf(NULL, ERRMSG_LVL_WARN, fmt, args);
3089
 
  else
3090
 
    vfprintf(stderr, fmt, args);
3091
 
  va_end(args);
3092
 
 
3093
 
  return (! r==true);
3094
 
}
 
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;
3095
2839
 
3096
2840
static int haildb_init(drizzled::module::Context &context)
3097
2841
{
3113
2857
  innobase_print_verbose_log= (vm.count("disable-print-verbose-log")) ? false : true;
3114
2858
  srv_use_sys_malloc= (vm.count("use-internal-malloc")) ? false : true;
3115
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
  }
3116
3054
 
3117
3055
  ib_err_t err;
3118
3056
 
3120
3058
  if (err != DB_SUCCESS)
3121
3059
    goto haildb_error;
3122
3060
 
3123
 
  ib_logger_set(haildb_errmsg_callback, NULL);
3124
 
 
3125
 
  if (not vm["data-home-dir"].as<string>().empty())
3126
 
  {
3127
 
    err= ib_cfg_set_text("data_home_dir", vm["data-home-dir"].as<string>().c_str());
3128
 
    if (err != DB_SUCCESS)
3129
 
      goto haildb_error;
3130
 
  }
3131
 
 
3132
 
  if (vm.count("log-group-home-dir"))
3133
 
  {
3134
 
    err= ib_cfg_set_text("log_group_home_dir", vm["log-group-home-dir"].as<string>().c_str());
3135
 
    if (err != DB_SUCCESS)
3136
 
      goto haildb_error;
3137
 
  }
 
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;
3138
3077
 
3139
3078
  if (innobase_print_verbose_log)
3140
3079
    err= ib_cfg_set_bool_on("print_verbose_log");
3176
3115
  if (err != DB_SUCCESS)
3177
3116
    goto haildb_error;
3178
3117
 
3179
 
  err= ib_cfg_set_int("additional_mem_pool_size", innobase_additional_mem_pool_size.get());
3180
 
  if (err != DB_SUCCESS)
3181
 
    goto haildb_error;
3182
 
 
3183
 
  err= ib_cfg_set_int("autoextend_increment", srv_auto_extend_increment.get());
3184
 
  if (err != DB_SUCCESS)
3185
 
    goto haildb_error;
3186
 
 
3187
 
  err= ib_cfg_set_int("buffer_pool_size", innobase_buffer_pool_size.get());
3188
 
  if (err != DB_SUCCESS)
3189
 
    goto haildb_error;
3190
 
 
3191
 
  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);
3192
3131
  if (err != DB_SUCCESS)
3193
3132
    goto haildb_error;
3194
3133
 
3200
3139
  if (err != DB_SUCCESS)
3201
3140
    goto haildb_error;
3202
3141
 
3203
 
  err= ib_cfg_set_int("flush_log_at_trx_commit",
3204
 
                      srv_flush_log_at_trx_commit.get());
 
3142
  err= ib_cfg_set_int("flush_log_at_trx_commit", srv_flush_log_at_trx_commit);
3205
3143
  if (err != DB_SUCCESS)
3206
3144
    goto haildb_error;
3207
3145
 
3208
 
  if (vm.count("flush-method") != 0)
 
3146
  if (innobase_unix_file_flush_method)
3209
3147
  {
3210
 
    err= ib_cfg_set_text("flush_method", 
3211
 
                         vm["flush-method"].as<string>().c_str());
 
3148
    err= ib_cfg_set_text("flush_method", innobase_unix_file_flush_method);
3212
3149
    if (err != DB_SUCCESS)
3213
3150
      goto haildb_error;
3214
3151
  }
3215
3152
 
3216
 
  err= ib_cfg_set_int("force_recovery",
3217
 
                      innobase_force_recovery.get());
3218
 
  if (err != DB_SUCCESS)
3219
 
    goto haildb_error;
3220
 
 
3221
 
  err= ib_cfg_set_text("data_file_path", vm["data-file-path"].as<string>().c_str());
3222
 
  if (err != DB_SUCCESS)
3223
 
    goto haildb_error;
3224
 
 
3225
 
  err= ib_cfg_set_int("log_file_size", haildb_log_file_size.get());
3226
 
  if (err != DB_SUCCESS)
3227
 
    goto haildb_error;
3228
 
 
3229
 
  err= ib_cfg_set_int("log_buffer_size", innobase_log_buffer_size.get());
3230
 
  if (err != DB_SUCCESS)
3231
 
    goto haildb_error;
3232
 
 
3233
 
  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);
3234
3170
  if (err != DB_SUCCESS)
3235
3171
    goto haildb_error;
3236
3172
 
3238
3174
  if (err != DB_SUCCESS)
3239
3175
    goto haildb_error;
3240
3176
 
3241
 
  err= ib_cfg_set_int("lock_wait_timeout", innobase_lock_wait_timeout.get());
3242
 
  if (err != DB_SUCCESS)
3243
 
    goto haildb_error;
3244
 
 
3245
 
  err= ib_cfg_set_int("max_dirty_pages_pct", haildb_max_dirty_pages_pct.get());
3246
 
  if (err != DB_SUCCESS)
3247
 
    goto haildb_error;
3248
 
 
3249
 
  err= ib_cfg_set_int("max_purge_lag", haildb_max_purge_lag.get());
3250
 
  if (err != DB_SUCCESS)
3251
 
    goto haildb_error;
3252
 
 
3253
 
  err= ib_cfg_set_int("open_files", haildb_open_files.get());
3254
 
  if (err != DB_SUCCESS)
3255
 
    goto haildb_error;
3256
 
 
3257
 
  err= ib_cfg_set_int("read_io_threads", haildb_read_io_threads.get());
3258
 
  if (err != DB_SUCCESS)
3259
 
    goto haildb_error;
3260
 
 
3261
 
  err= ib_cfg_set_int("write_io_threads", haildb_write_io_threads.get());
3262
 
  if (err != DB_SUCCESS)
3263
 
    goto haildb_error;
3264
 
 
3265
 
  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);
3266
3202
  if (err != DB_SUCCESS)
3267
3203
    goto haildb_error;
3268
3204
 
3274
3210
  if (err != DB_SUCCESS)
3275
3211
    goto haildb_error;
3276
3212
 
3277
 
  err= ib_startup(innobase_file_format_name.c_str());
 
3213
  err= ib_startup(innobase_file_format_name);
3278
3214
  if (err != DB_SUCCESS)
3279
3215
    goto haildb_error;
3280
3216
 
3282
3218
 
3283
3219
  haildb_engine= new HailDBEngine("InnoDB");
3284
3220
  context.add(haildb_engine);
3285
 
  context.registerVariable(new sys_var_bool_ptr_readonly("adaptive_hash_index",
3286
 
                                                         &innobase_adaptive_hash_index));
3287
 
  context.registerVariable(new sys_var_bool_ptr_readonly("adaptive_flushing",
3288
 
                                                         &srv_adaptive_flushing));
3289
 
  context.registerVariable(new sys_var_constrained_value_readonly<size_t>("additional_mem_pool_size",innobase_additional_mem_pool_size));
3290
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("autoextend_increment", srv_auto_extend_increment));
3291
 
  context.registerVariable(new sys_var_constrained_value_readonly<size_t>("buffer_pool_size", innobase_buffer_pool_size));
3292
 
  context.registerVariable(new sys_var_bool_ptr_readonly("checksums",
3293
 
                                                         &innobase_use_checksums));
3294
 
  context.registerVariable(new sys_var_bool_ptr_readonly("doublewrite",
3295
 
                                                         &innobase_use_doublewrite));
3296
 
  context.registerVariable(new sys_var_const_string_val("data_file_path",
3297
 
                                                vm["data-file-path"].as<string>()));
3298
 
  context.registerVariable(new sys_var_const_string_val("data_home_dir",
3299
 
                                                vm["data-home-dir"].as<string>()));
3300
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("io_capacity", srv_io_capacity));
3301
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("fast_shutdown", innobase_fast_shutdown));
3302
 
  context.registerVariable(new sys_var_bool_ptr_readonly("file_per_table",
3303
 
                                                         &srv_file_per_table));
3304
 
  context.registerVariable(new sys_var_bool_ptr_readonly("rollback_on_timeout",
3305
 
                                                         &innobase_rollback_on_timeout));
3306
 
  context.registerVariable(new sys_var_bool_ptr_readonly("print_verbose_log",
3307
 
                                                         &innobase_print_verbose_log));
3308
 
  context.registerVariable(new sys_var_bool_ptr("status_file",
3309
 
                                                &innobase_create_status_file,
3310
 
                                                haildb_status_file_update));
3311
 
  context.registerVariable(new sys_var_bool_ptr_readonly("use_sys_malloc",
3312
 
                                                         &srv_use_sys_malloc));
3313
 
  context.registerVariable(new sys_var_std_string("file_format",
3314
 
                                                  innobase_file_format_name,
3315
 
                                                  haildb_file_format_name_validate));
3316
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("flush_log_at_trx_commit", srv_flush_log_at_trx_commit));
3317
 
  context.registerVariable(new sys_var_const_string_val("flush_method",
3318
 
                                                vm.count("flush-method") ?  vm["flush-method"].as<string>() : ""));
3319
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("force_recovery", innobase_force_recovery));
3320
 
  context.registerVariable(new sys_var_const_string_val("log_group_home_dir",
3321
 
                                                vm.count("log-group-home-dir") ?  vm["log-group-home-dir"].as<string>() : ""));
3322
 
  context.registerVariable(new sys_var_constrained_value<int64_t>("log_file_size", haildb_log_file_size));
3323
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("log_files_in_group", haildb_log_files_in_group));
3324
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("lock_wait_timeout", innobase_lock_wait_timeout));
3325
 
  context.registerVariable(new sys_var_constrained_value_readonly<long>("log_buffer_size", innobase_log_buffer_size));
3326
 
  context.registerVariable(new sys_var_constrained_value<unsigned int>("lru_old_blocks_pct", innobase_lru_old_blocks_pct, haildb_lru_old_blocks_pct_update));
3327
 
  context.registerVariable(new sys_var_uint32_t_ptr("lru_block_access_recency",
3328
 
                                                    &innobase_lru_block_access_recency,
3329
 
                                                    haildb_lru_block_access_recency_update));
3330
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("max_dirty_pages_pct", haildb_max_dirty_pages_pct));
3331
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("max_purge_lag", haildb_max_purge_lag));
3332
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("sync_spin_loops", haildb_sync_spin_loops));
3333
 
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("open_files", haildb_open_files));
3334
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("read_io_threads", haildb_read_io_threads));
3335
 
  context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("write_io_threads", haildb_write_io_threads));
3336
3221
 
 
3222
  haildb_version_func_initialize(context);
3337
3223
  haildb_datadict_dump_func_initialize(context);
3338
3224
  config_table_function_initialize(context);
3339
3225
  status_table_function_initialize(context);
3351
3237
  ib_err_t err;
3352
3238
  ib_shutdown_t shutdown_flag= IB_SHUTDOWN_NORMAL;
3353
3239
 
3354
 
  if (innobase_fast_shutdown.get() == 1)
 
3240
  if (innobase_fast_shutdown == 1)
3355
3241
    shutdown_flag= IB_SHUTDOWN_NO_IBUFMERGE_PURGE;
3356
 
  else if (innobase_fast_shutdown.get() == 2)
 
3242
  else if (innobase_fast_shutdown == 2)
3357
3243
    shutdown_flag= IB_SHUTDOWN_NO_BUFPOOL_FLUSH;
3358
3244
 
3359
3245
  err= ib_shutdown(shutdown_flag);
3365
3251
 
3366
3252
}
3367
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);
3368
3527
 
3369
3528
static void init_options(drizzled::module::option_context &context)
3370
3529
{
3373
3532
  context("disable-adaptive-flushing",
3374
3533
          N_("Do not attempt to flush dirty pages to avoid IO bursts at checkpoints."));
3375
3534
  context("additional-mem-pool-size",
3376
 
          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),
3377
3536
          N_("Size of a memory pool HailDB uses to store data dictionary information and other internal data structures."));
3378
3537
  context("autoextend-increment",
3379
 
          po::value<autoextend_constraint>(&srv_auto_extend_increment)->default_value(8),
 
3538
          po::value<unsigned int>(&srv_auto_extend_increment)->default_value(8L),
3380
3539
          N_("Data file autoextend increment in megabytes"));
3381
3540
  context("buffer-pool-size",
3382
 
          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),
3383
3542
          N_("The size of the memory buffer HailDB uses to cache data and indexes of its tables."));
3384
3543
  context("data-home-dir",
3385
 
          po::value<string>()->default_value(""),
 
3544
          po::value<string>(),
3386
3545
          N_("The common part for HailDB table spaces."));
3387
3546
  context("disable-checksums",
3388
3547
          N_("Disable HailDB checksums validation (enabled by default)."));
3389
3548
  context("disable-doublewrite",
3390
3549
          N_("Disable HailDB doublewrite buffer (enabled by default)."));
3391
3550
  context("io-capacity",
3392
 
          po::value<io_capacity_constraint>(&srv_io_capacity)->default_value(200),
 
3551
          po::value<unsigned long>(&srv_io_capacity)->default_value(200),
3393
3552
          N_("Number of IOPs the server can do. Tunes the background IO rate"));
3394
3553
  context("fast-shutdown",
3395
 
          po::value<trinary_constraint>(&innobase_fast_shutdown)->default_value(1),
 
3554
          po::value<unsigned long>(&innobase_fast_shutdown)->default_value(1),
3396
3555
          N_("Speeds up the shutdown process of the HailDB storage engine. Possible values are 0, 1 (faster) or 2 (fastest - crash-like)."));
3397
3556
  context("file-per-table",
3398
3557
          po::value<bool>(&srv_file_per_table)->default_value(false)->zero_tokens(),
3399
3558
          N_("Stores each HailDB table to an .ibd file in the database dir."));
3400
3559
  context("file-format",
3401
 
          po::value<string>(&innobase_file_format_name)->default_value("Barracuda"),
 
3560
          po::value<string>(),
3402
3561
          N_("File format to use for new tables in .ibd files."));
3403
3562
  context("flush-log-at-trx-commit",
3404
 
          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),
3405
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)."));
3406
3565
  context("flush-method",
3407
3566
          po::value<string>(),
3408
3567
          N_("With which method to flush data."));
3409
3568
  context("force-recovery",
3410
 
          po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
 
3569
          po::value<long>(&innobase_force_recovery)->default_value(0),
3411
3570
          N_("Helps to save your data in case the disk image of the database becomes corrupt."));
3412
3571
  context("data-file-path",
3413
 
          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>(),
3414
3576
          N_("Path to individual files and their sizes."));
3415
3577
  context("log-group-home-dir",
3416
3578
          po::value<string>(),
3417
3579
          N_("Path to HailDB log files."));
3418
3580
  context("log-file-size",
3419
 
          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),
3420
3582
          N_("Size of each log file in a log group."));
3421
3583
  context("haildb-log-files-in-group",
3422
 
          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),
3423
3585
          N_("Number of log files in the log group. HailDB writes to the files in a circular fashion. Value 3 is recommended here."));
3424
3586
  context("lock-wait-timeout",
3425
 
          po::value<lock_wait_constraint>(&innobase_lock_wait_timeout)->default_value(5),
 
3587
          po::value<unsigned long>(&innobase_lock_wait_timeout)->default_value(5),
3426
3588
          N_("Timeout in seconds an HailDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout."));
3427
3589
  context("log-buffer-size",
3428
 
        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),
3429
3591
        N_("The size of the buffer which HailDB uses to write log to the log files on disk."));
3430
3592
  context("lru-old-blocks-pct",
3431
 
          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),
3432
3594
          N_("Sets the point in the LRU list from where all pages are classified as old (Advanced users)"));
3433
3595
  context("lru-block-access-recency",
3434
 
          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),
3435
3597
          N_("Milliseconds between accesses to a block at which it is made young. 0=disabled (Advanced users)"));
3436
3598
  context("max-dirty-pages-pct",
3437
 
          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),
3438
3600
          N_("Percentage of dirty pages allowed in bufferpool."));
3439
3601
  context("max-purge-lag",
3440
 
          po::value<uint64_constraint>(&haildb_max_purge_lag)->default_value(0),
 
3602
          po::value<unsigned long>(&srv_max_purge_lag)->default_value(0),
3441
3603
          N_("Desired maximum length of the purge queue (0 = no limit)"));
3442
3604
  context("rollback-on-timeout",
3443
3605
          po::value<bool>(&innobase_rollback_on_timeout)->default_value(false)->zero_tokens(),
3444
3606
          N_("Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)"));
3445
3607
  context("open-files",
3446
 
          po::value<open_files_constraint>(&haildb_open_files)->default_value(300),
 
3608
          po::value<long>(&innobase_open_files)->default_value(300),
3447
3609
          N_("How many files at the maximum HailDB keeps open at the same time."));
3448
3610
  context("read-io-threads",
3449
 
          po::value<io_threads_constraint>(&haildb_read_io_threads)->default_value(4),
 
3611
          po::value<unsigned long>(&innobase_read_io_threads)->default_value(4),
3450
3612
          N_("Number of background read I/O threads in HailDB."));
3451
3613
  context("write-io-threads",
3452
 
          po::value<io_threads_constraint>(&haildb_write_io_threads)->default_value(4),
 
3614
          po::value<unsigned long>(&innobase_write_io_threads)->default_value(4),
3453
3615
          N_("Number of background write I/O threads in HailDB."));
3454
3616
  context("disable-print-verbose-log",
3455
3617
          N_("Disable if you want to reduce the number of messages written to the log (default: enabled)."));
3457
3619
          po::value<bool>(&innobase_create_status_file)->default_value(false)->zero_tokens(),
3458
3620
          N_("Enable SHOW HAILDB STATUS output in the log"));
3459
3621
  context("sync-spin-loops",
3460
 
          po::value<uint64_constraint>(&haildb_sync_spin_loops)->default_value(30L),
 
3622
          po::value<unsigned long>(&srv_n_spin_wait_rounds)->default_value(30L),
3461
3623
          N_("Count of spin-loop rounds in HailDB mutexes (30 by default)"));
3462
3624
  context("use-internal-malloc",
3463
3625
          N_("Use HailDB's internal memory allocator instead of the OS memory allocator"));
3464
3626
}
3465
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
 
3466
3665
DRIZZLE_DECLARE_PLUGIN
3467
3666
{
3468
3667
  DRIZZLE_VERSION_ID,
3472
3671
  "Transactional Storage Engine using the HailDB Library",
3473
3672
  PLUGIN_LICENSE_GPL,
3474
3673
  haildb_init,     /* Plugin Init */
3475
 
  NULL, /* system variables */
 
3674
  innobase_system_variables, /* system variables */
3476
3675
  init_options                /* config options   */
3477
3676
}
3478
3677
DRIZZLE_DECLARE_PLUGIN_END;