2019
1976
ret= HA_ERR_FOUND_DUPP_KEY;
2021
1978
else if (err != DB_SUCCESS)
2022
ret= ib_err_t_to_drizzle_error(getTable()->getSession(), err);
1979
ret= ib_err_t_to_drizzle_error(err);
2024
1981
tuple= ib_tuple_clear(tuple);
2025
1982
ib_tuple_delete(tuple);
2027
1983
err= ib_cursor_reset(cursor);
2032
int HailDBCursor::doUpdateRecord(const unsigned char *old_data,
2033
unsigned char *new_data)
1988
int HailDBCursor::doUpdateRecord(const unsigned char *,
2035
1991
ib_tpl_t update_tuple;
2037
bool created_tuple= false;
2039
1994
update_tuple= ib_clust_read_tuple_create(cursor);
2043
ib_trx_t transaction= *get_trx(getTable()->in_use);
2045
if (cursor_is_sec_index)
2047
err= ib_cursor_close(cursor);
2048
assert(err == DB_SUCCESS);
2050
err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
2052
if (err != DB_SUCCESS)
2053
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2054
cursor_is_sec_index= false;
2058
ib_cursor_attach_trx(cursor, transaction);
2061
store_key_value_from_haildb(getTable()->key_info + getTable()->getShare()->getPrimaryKey(),
2062
ref, ref_length, old_data);
2064
ib_tpl_t search_tuple= ib_clust_search_tuple_create(cursor);
2066
fill_ib_search_tpl_from_drizzle_key(search_tuple,
2067
getTable()->key_info + 0,
2070
err= ib_cursor_set_lock_mode(cursor, IB_LOCK_X);
2071
assert(err == DB_SUCCESS);
2074
err= ib_cursor_moveto(cursor, search_tuple, IB_CUR_GE, &res);
2075
assert(err == DB_SUCCESS);
2077
tuple= ib_clust_read_tuple_create(cursor);
2079
err= ib_cursor_read_row(cursor, tuple);
2080
assert(err == DB_SUCCESS);// FIXME
2082
created_tuple= true;
2085
1996
err= ib_tuple_copy(update_tuple, tuple);
2086
1997
assert(err == DB_SUCCESS);
2088
write_row_to_haildb_tuple(new_data, getTable()->getFields(), update_tuple);
1999
write_row_to_haildb_tuple(getTable()->getFields(), update_tuple);
2090
2001
err= ib_cursor_update_row(cursor, tuple, update_tuple);
2092
2003
ib_tuple_delete(update_tuple);
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);
2103
2005
advance_cursor= true;
2105
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2007
if (err == DB_SUCCESS)
2009
else if (err == DB_DUPLICATE_KEY)
2010
return HA_ERR_FOUND_DUPP_KEY;
2108
2015
int HailDBCursor::doDeleteRecord(const unsigned char *)
2112
assert(ib_cursor_is_positioned(cursor) == IB_TRUE);
2113
2019
err= ib_cursor_delete_row(cursor);
2020
if (err != DB_SUCCESS)
2115
2023
advance_cursor= true;
2117
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2120
2027
int HailDBCursor::delete_all_rows(void)
2122
2029
/* I *think* ib_truncate is non-transactional....
2123
2030
so only support TRUNCATE and not DELETE FROM t;
2124
(this is what ha_innodb does)
2031
(this is what ha_haildb does)
2126
if (getTable()->in_use->getSqlCommand() != SQLCOM_TRUNCATE)
2033
if (session_sql_command(getTable()->in_use) != SQLCOM_TRUNCATE)
2127
2034
return HA_ERR_WRONG_COMMAND;
2511
2380
if (flag & HA_STATUS_AUTO)
2512
2381
stats.auto_increment_value= 1;
2514
if (flag & HA_STATUS_ERRKEY) {
2515
const char *err_table_name;
2516
const char *err_index_name;
2518
ib_trx_t transaction= *get_trx(getTable()->in_use);
2520
err= ib_get_duplicate_key(transaction, &err_table_name, &err_index_name);
2524
for (unsigned int i = 0; i < getTable()->getShare()->keys; i++)
2526
if (strcmp(err_index_name, getTable()->key_info[i].name) == 0)
2535
if (flag & HA_STATUS_CONST)
2537
for (unsigned int i = 0; i < getTable()->getShare()->sizeKeys(); i++)
2539
const char* index_name= getTable()->key_info[i].name;
2542
ha_rows rec_per_key;
2544
err= ib_get_index_stat_n_diff_key_vals(cursor, index_name,
2547
if (err != DB_SUCCESS)
2548
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2550
for (unsigned int j=0; j < getTable()->key_info[i].key_parts; j++)
2552
if (n_diff[j+1] == 0)
2553
rec_per_key= stats.records;
2555
rec_per_key= stats.records / n_diff[j+1];
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. */
2561
rec_per_key= rec_per_key / 2;
2563
if (rec_per_key == 0)
2566
getTable()->key_info[i].rec_per_key[j]=
2567
rec_per_key >= ~(ulong) 0 ? ~(ulong) 0 :
2568
(ulong) rec_per_key;
2578
2385
int HailDBCursor::doStartIndexScan(uint32_t keynr, bool)
2581
2387
ib_trx_t transaction= *get_trx(getTable()->in_use);
2583
2389
active_index= keynr;
2391
ib_cursor_attach_trx(cursor, transaction);
2585
2393
if (active_index == 0 && ! share->has_hidden_primary_key)
2587
if (cursor_is_sec_index)
2589
err= ib_cursor_close(cursor);
2590
assert(err == DB_SUCCESS);
2592
err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
2594
if (err != DB_SUCCESS)
2595
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2600
ib_cursor_attach_trx(cursor, transaction);
2603
cursor_is_sec_index= false;
2604
2395
tuple= ib_clust_read_tuple_create(cursor);
2608
2400
ib_id_t index_id;
2609
2401
err= ib_index_get_id(table_path_to_haildb_name(getShare()->getPath()),
2610
2402
getShare()->getKeyInfo(keynr).name,
2612
2404
if (err != DB_SUCCESS)
2613
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2615
2407
err= ib_cursor_close(cursor);
2616
2408
assert(err == DB_SUCCESS);
2618
2409
err= ib_cursor_open_index_using_id(index_id, transaction, &cursor);
2620
2411
if (err != DB_SUCCESS)
2621
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2623
cursor_is_sec_index= true;
2625
2414
tuple= ib_clust_read_tuple_create(cursor);
2626
2415
ib_cursor_set_cluster_access(cursor);
2629
err= ib_cursor_set_lock_mode(cursor, ib_lock_mode);
2418
ib_err_t err= ib_cursor_set_lock_mode(cursor, ib_lock_mode);
2630
2419
assert(err == DB_SUCCESS);
2632
2421
advance_cursor= false;
3051
2831
static bool innobase_rollback_on_timeout;
3052
2832
static bool innobase_create_status_file;
3053
2833
static bool srv_use_sys_malloc;
3054
static string innobase_file_format_name;
2834
static char* innobase_file_format_name = const_cast<char *>("Barracuda");
2835
static char* innobase_unix_file_flush_method = NULL;
2836
static unsigned long srv_flush_log_at_trx_commit;
2837
static unsigned long srv_max_buf_pool_modified_pct;
2838
static unsigned long srv_max_purge_lag;
2839
static unsigned long innobase_lru_old_blocks_pct;
2840
static unsigned long innobase_lru_block_access_recency;
2841
static unsigned long innobase_read_io_threads;
2842
static unsigned long innobase_write_io_threads;
3055
2843
typedef constrained_check<unsigned int, 1000, 1> autoextend_constraint;
3056
2844
static autoextend_constraint srv_auto_extend_increment;
2845
static unsigned long innobase_lock_wait_timeout;
2846
static unsigned long srv_n_spin_wait_rounds;
3057
2847
typedef constrained_check<size_t, SIZE_MAX, 5242880, 1048576> buffer_pool_constraint;
3058
2848
static buffer_pool_constraint innobase_buffer_pool_size;
3059
2849
typedef constrained_check<size_t, SIZE_MAX, 512, 1024> additional_mem_pool_constraint;
3060
2850
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;
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;
3091
static uint32_t innobase_lru_block_access_recency;
3095
static int haildb_file_format_name_validate(Session*, set_var *var)
3098
const char *format= var->value->str_value.ptr();
3102
ib_err_t err= ib_cfg_set_text("file_format", format);
3104
if (err == DB_SUCCESS)
3106
innobase_file_format_name= format;
3113
static void haildb_lru_old_blocks_pct_update(Session*, sql_var_t)
3115
int ret= ib_cfg_set_int("lru_old_blocks_pct", static_cast<uint32_t>(innobase_lru_old_blocks_pct));
3119
static void haildb_lru_block_access_recency_update(Session*, sql_var_t)
3121
int ret= ib_cfg_set_int("lru_block_access_recency", static_cast<uint32_t>(innobase_lru_block_access_recency));
3125
static void haildb_status_file_update(Session*, sql_var_t)
3129
if (innobase_create_status_file)
3130
err= ib_cfg_set_bool_on("status_file");
3132
err= ib_cfg_set_bool_off("status_file");
3136
extern "C" int haildb_errmsg_callback(ib_msg_stream_t, const char *fmt, ...);
3139
extern bool volatile shutdown_in_progress;
3142
extern "C" int haildb_errmsg_callback(ib_msg_stream_t, const char *fmt, ...)
3146
va_start(args, fmt);
3147
if (not shutdown_in_progress)
3149
r= plugin::ErrorMessage::vprintf(error::WARN, fmt, args);
3153
vfprintf(stderr, fmt, args);
2851
static long innobase_open_files;
2852
static long innobase_force_recovery;
2853
static long innobase_log_buffer_size;
2854
static char default_haildb_data_file_path[]= "ibdata1:10M:autoextend";
2855
static char* haildb_data_file_path= NULL;
2857
static int64_t haildb_log_file_size;
2858
static int64_t haildb_log_files_in_group;
3160
2860
static int haildb_init(drizzled::module::Context &context)
3177
2877
innobase_print_verbose_log= (vm.count("disable-print-verbose-log")) ? false : true;
3178
2878
srv_use_sys_malloc= (vm.count("use-internal-malloc")) ? false : true;
2880
if (vm.count("io-capacity"))
2882
if (srv_io_capacity > (unsigned long)~0L || srv_io_capacity < 100)
2884
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of io-capacity"));
2889
if (vm.count("fast-shutdown"))
2891
if (innobase_fast_shutdown > 2)
2893
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of fast-shutdown"));
2898
if (vm.count("flush-log-at-trx-commit"))
2900
if (srv_flush_log_at_trx_commit > 2)
2902
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of flush-log-at-trx-commit"));
2907
if (vm.count("force-recovery"))
2909
if (innobase_force_recovery > 6)
2911
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of force-recovery"));
2916
if (vm.count("log-file-size"))
2918
if (haildb_log_file_size > INT64_MAX || haildb_log_file_size < 1*1024*1024L)
2920
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-file-size"));
2923
haildb_log_file_size/= 1024*1024L;
2924
haildb_log_file_size*= 1024*1024L;
2927
if (vm.count("log-files-in-group"))
2929
if (haildb_log_files_in_group > 100 || haildb_log_files_in_group < 2)
2931
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-files-in-group"));
2936
if (vm.count("lock-wait-timeout"))
2938
if (innobase_lock_wait_timeout > 1024*1024*1024 || innobase_lock_wait_timeout < 1)
2940
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lock-wait-timeout"));
2945
if (vm.count("log-buffer-size"))
2947
if (innobase_log_buffer_size > LONG_MAX || innobase_log_buffer_size < 256*1024L)
2949
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-buffer-size"));
2952
innobase_log_buffer_size/= 1024;
2953
innobase_log_buffer_size*= 1024;
2956
if (vm.count("lru-old-blocks-pct"))
2958
if (innobase_lru_old_blocks_pct > 95 || innobase_lru_old_blocks_pct < 5)
2960
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lru-old-blocks-pct"));
2965
if (vm.count("lru-block-access-recency"))
2967
if (innobase_lru_block_access_recency > ULONG_MAX)
2969
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lru-block-access-recency"));
2974
if (vm.count("max-dirty-pages-pct"))
2976
if (srv_max_buf_pool_modified_pct > 99)
2978
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of max-dirty-pages-pct"));
2983
if (vm.count("max-purge-lag"))
2985
if (srv_max_purge_lag > (unsigned long)~0L)
2987
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of max-purge-lag"));
2992
if (vm.count("open-files"))
2994
if (innobase_open_files > LONG_MAX || innobase_open_files < 10L)
2996
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of open-files"));
3001
if (vm.count("read-io-threads"))
3003
if (innobase_read_io_threads > 64 || innobase_read_io_threads < 1)
3005
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of read-io-threads"));
3010
if (vm.count("sync-spin-loops"))
3012
if (srv_n_spin_wait_rounds > (unsigned long)~0L)
3014
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of sync_spin_loops"));
3019
if (vm.count("data-home-dir"))
3021
innobase_data_home_dir= const_cast<char *>(vm["data-home-dir"].as<string>().c_str());
3024
if (vm.count("file-format"))
3026
innobase_file_format_name= const_cast<char *>(vm["file-format"].as<string>().c_str());
3029
if (vm.count("log-group-home-dir"))
3031
innobase_log_group_home_dir= const_cast<char *>(vm["log-group-home-dir"].as<string>().c_str());
3034
if (vm.count("flush-method"))
3036
innobase_unix_file_flush_method= const_cast<char *>(vm["flush-method"].as<string>().c_str());
3039
if (vm.count("data-file-path"))
3041
haildb_data_file_path= const_cast<char *>(vm["data-file-path"].as<string>().c_str());
3353
3214
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("additional_mem_pool_size",innobase_additional_mem_pool_size));
3354
3215
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("autoextend_increment", srv_auto_extend_increment));
3355
3216
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));
3401
3218
haildb_datadict_dump_func_initialize(context);
3402
3219
config_table_function_initialize(context);
3249
static char haildb_file_format_name_storage[100];
3251
static int haildb_file_format_name_validate(Session*, drizzle_sys_var*,
3253
drizzle_value *value)
3257
int len= sizeof(buff);
3258
const char *format= value->val_str(value, buff, &len);
3260
*static_cast<const char**>(save)= NULL;
3265
err= ib_cfg_set_text("file_format", format);
3267
if (err == DB_SUCCESS)
3269
strncpy(haildb_file_format_name_storage, format, sizeof(haildb_file_format_name_storage));;
3270
haildb_file_format_name_storage[sizeof(haildb_file_format_name_storage)-1]= 0;
3272
*static_cast<const char**>(save)= haildb_file_format_name_storage;
3279
static void haildb_file_format_name_update(Session*, drizzle_sys_var*,
3286
assert(var_ptr != NULL);
3287
assert(save != NULL);
3289
format= *static_cast<const char*const*>(save);
3291
/* Format is already set in validate */
3292
memmove(haildb_file_format_name_storage, format, sizeof(haildb_file_format_name_storage));;
3293
haildb_file_format_name_storage[sizeof(haildb_file_format_name_storage)-1]= 0;
3295
*static_cast<const char**>(var_ptr)= haildb_file_format_name_storage;
3298
static void haildb_lru_old_blocks_pct_update(Session*, drizzle_sys_var*,
3305
pct= *static_cast<const unsigned long*>(save);
3307
ib_err_t err= ib_cfg_set_int("lru_old_blocks_pct", pct);
3308
if (err == DB_SUCCESS)
3309
innobase_lru_old_blocks_pct= pct;
3312
static void haildb_lru_block_access_recency_update(Session*, drizzle_sys_var*,
3319
ms= *static_cast<const unsigned long*>(save);
3321
ib_err_t err= ib_cfg_set_int("lru_block_access_recency", ms);
3323
if (err == DB_SUCCESS)
3324
innobase_lru_block_access_recency= ms;
3327
static void haildb_status_file_update(Session*, drizzle_sys_var*,
3332
bool status_file_enabled;
3335
status_file_enabled= *static_cast<const bool*>(save);
3338
if (status_file_enabled)
3339
err= ib_cfg_set_bool_on("status_file");
3341
err= ib_cfg_set_bool_off("status_file");
3343
if (err == DB_SUCCESS)
3344
innobase_create_status_file= status_file_enabled;
3347
static DRIZZLE_SYSVAR_BOOL(checksums, innobase_use_checksums,
3348
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
3349
"Enable HailDB checksums validation (enabled by default). "
3350
"Disable with --skip-haildb-checksums.",
3353
static DRIZZLE_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
3354
PLUGIN_VAR_READONLY,
3355
"The common part for HailDB table spaces.",
3358
static DRIZZLE_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
3359
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
3360
"Enable HailDB doublewrite buffer (enabled by default). "
3361
"Disable with --skip-haildb-doublewrite.",
3364
static DRIZZLE_SYSVAR_ULONG(io_capacity, srv_io_capacity,
3365
PLUGIN_VAR_RQCMDARG,
3366
"Number of IOPs the server can do. Tunes the background IO rate",
3367
NULL, NULL, 200, 100, ~0L, 0);
3369
static DRIZZLE_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
3370
PLUGIN_VAR_OPCMDARG,
3371
"Speeds up the shutdown process of the HailDB storage engine. Possible "
3372
"values are 0, 1 (faster)"
3373
" or 2 (fastest - crash-like)"
3375
NULL, NULL, 1, 0, 2, 0);
3377
static DRIZZLE_SYSVAR_BOOL(file_per_table, srv_file_per_table,
3378
PLUGIN_VAR_NOCMDARG,
3379
"Stores each HailDB table to an .ibd file in the database dir.",
3382
static DRIZZLE_SYSVAR_STR(file_format, innobase_file_format_name,
3383
PLUGIN_VAR_RQCMDARG,
3384
"File format to use for new tables in .ibd files.",
3385
haildb_file_format_name_validate,
3386
haildb_file_format_name_update, "Barracuda");
3388
static DRIZZLE_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
3389
PLUGIN_VAR_OPCMDARG,
3390
"Set to 0 (write and flush once per second),"
3391
" 1 (write and flush at each commit)"
3392
" or 2 (write at commit, flush once per second).",
3393
NULL, NULL, 1, 0, 2, 0);
3395
static DRIZZLE_SYSVAR_STR(flush_method, innobase_unix_file_flush_method,
3396
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3397
"With which method to flush data.", NULL, NULL, NULL);
3399
static DRIZZLE_SYSVAR_LONG(force_recovery, innobase_force_recovery,
3400
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3401
"Helps to save your data in case the disk image of the database becomes corrupt.",
3402
NULL, NULL, 0, 0, 6, 0);
3404
static DRIZZLE_SYSVAR_STR(data_file_path, haildb_data_file_path,
3405
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3406
"Path to individual files and their sizes.",
3409
static DRIZZLE_SYSVAR_STR(log_group_home_dir, innobase_log_group_home_dir,
3410
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3411
"Path to HailDB log files.", NULL, NULL, NULL);
3413
static DRIZZLE_SYSVAR_LONGLONG(log_file_size, haildb_log_file_size,
3414
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3415
"Size of each log file in a log group.",
3416
NULL, NULL, 20*1024*1024L, 1*1024*1024L, INT64_MAX, 1024*1024L);
3418
static DRIZZLE_SYSVAR_LONGLONG(log_files_in_group, haildb_log_files_in_group,
3419
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3420
"Number of log files in the log group. HailDB writes to the files in a circular fashion. Value 3 is recommended here.",
3421
NULL, NULL, 2, 2, 100, 0);
3423
static DRIZZLE_SYSVAR_ULONG(lock_wait_timeout, innobase_lock_wait_timeout,
3424
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3425
"Timeout in seconds an HailDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.",
3426
NULL, NULL, 5, 1, 1024 * 1024 * 1024, 0);
3428
static DRIZZLE_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
3429
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3430
"The size of the buffer which HailDB uses to write log to the log files on disk.",
3431
NULL, NULL, 8*1024*1024L, 256*1024L, LONG_MAX, 1024);
3433
static DRIZZLE_SYSVAR_ULONG(lru_old_blocks_pct, innobase_lru_old_blocks_pct,
3434
PLUGIN_VAR_RQCMDARG,
3435
"Sets the point in the LRU list from where all pages are classified as "
3436
"old (Advanced users)",
3438
haildb_lru_old_blocks_pct_update, 37, 5, 95, 0);
3440
static DRIZZLE_SYSVAR_ULONG(lru_block_access_recency, innobase_lru_block_access_recency,
3441
PLUGIN_VAR_RQCMDARG,
3442
"Milliseconds between accesses to a block at which it is made young. "
3443
"0=disabled (Advanced users)",
3445
haildb_lru_block_access_recency_update, 0, 0, ULONG_MAX, 0);
3448
static DRIZZLE_SYSVAR_ULONG(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
3449
PLUGIN_VAR_RQCMDARG,
3450
"Percentage of dirty pages allowed in bufferpool.",
3451
NULL, NULL, 75, 0, 99, 0);
3453
static DRIZZLE_SYSVAR_ULONG(max_purge_lag, srv_max_purge_lag,
3454
PLUGIN_VAR_RQCMDARG,
3455
"Desired maximum length of the purge queue (0 = no limit)",
3456
NULL, NULL, 0, 0, ~0L, 0);
3458
static DRIZZLE_SYSVAR_BOOL(rollback_on_timeout, innobase_rollback_on_timeout,
3459
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
3460
"Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)",
3463
static DRIZZLE_SYSVAR_LONG(open_files, innobase_open_files,
3464
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3465
"How many files at the maximum HailDB keeps open at the same time.",
3466
NULL, NULL, 300L, 10L, LONG_MAX, 0);
3468
static DRIZZLE_SYSVAR_ULONG(read_io_threads, innobase_read_io_threads,
3469
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3470
"Number of background read I/O threads in HailDB.",
3471
NULL, NULL, 4, 1, 64, 0);
3473
static DRIZZLE_SYSVAR_ULONG(write_io_threads, innobase_write_io_threads,
3474
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3475
"Number of background write I/O threads in HailDB.",
3476
NULL, NULL, 4, 1, 64, 0);
3478
static DRIZZLE_SYSVAR_BOOL(print_verbose_log, innobase_print_verbose_log,
3479
PLUGIN_VAR_NOCMDARG,
3480
"Disable if you want to reduce the number of messages written to the log (default: enabled).",
3483
static DRIZZLE_SYSVAR_BOOL(status_file, innobase_create_status_file,
3484
PLUGIN_VAR_OPCMDARG,
3485
"Enable SHOW HAILDB STATUS output in the log",
3486
NULL, haildb_status_file_update, false);
3488
static DRIZZLE_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
3489
PLUGIN_VAR_RQCMDARG,
3490
"Count of spin-loop rounds in HailDB mutexes (30 by default)",
3491
NULL, NULL, 30L, 0L, ~0L, 0);
3493
static DRIZZLE_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
3494
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
3495
"Use OS memory allocator instead of HailDB's internal memory allocator",
3433
3498
static void init_options(drizzled::module::option_context &context)
3446
3511
po::value<buffer_pool_constraint>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
3447
3512
N_("The size of the memory buffer HailDB uses to cache data and indexes of its tables."));
3448
3513
context("data-home-dir",
3449
po::value<string>()->default_value(""),
3514
po::value<string>(),
3450
3515
N_("The common part for HailDB table spaces."));
3451
3516
context("disable-checksums",
3452
3517
N_("Disable HailDB checksums validation (enabled by default)."));
3453
3518
context("disable-doublewrite",
3454
3519
N_("Disable HailDB doublewrite buffer (enabled by default)."));
3455
3520
context("io-capacity",
3456
po::value<io_capacity_constraint>(&srv_io_capacity)->default_value(200),
3521
po::value<unsigned long>(&srv_io_capacity)->default_value(200),
3457
3522
N_("Number of IOPs the server can do. Tunes the background IO rate"));
3458
3523
context("fast-shutdown",
3459
po::value<trinary_constraint>(&innobase_fast_shutdown)->default_value(1),
3524
po::value<unsigned long>(&innobase_fast_shutdown)->default_value(1),
3460
3525
N_("Speeds up the shutdown process of the HailDB storage engine. Possible values are 0, 1 (faster) or 2 (fastest - crash-like)."));
3461
3526
context("file-per-table",
3462
3527
po::value<bool>(&srv_file_per_table)->default_value(false)->zero_tokens(),
3463
3528
N_("Stores each HailDB table to an .ibd file in the database dir."));
3464
3529
context("file-format",
3465
po::value<string>(&innobase_file_format_name)->default_value("Barracuda"),
3530
po::value<string>(),
3466
3531
N_("File format to use for new tables in .ibd files."));
3467
3532
context("flush-log-at-trx-commit",
3468
po::value<trinary_constraint>(&srv_flush_log_at_trx_commit)->default_value(1),
3533
po::value<unsigned long>(&srv_flush_log_at_trx_commit)->default_value(1),
3469
3534
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
3535
context("flush-method",
3471
3536
po::value<string>(),
3472
3537
N_("With which method to flush data."));
3473
3538
context("force-recovery",
3474
po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
3539
po::value<long>(&innobase_force_recovery)->default_value(0),
3475
3540
N_("Helps to save your data in case the disk image of the database becomes corrupt."));
3476
3541
context("data-file-path",
3477
po::value<string>()->default_value("ibdata1:10M:autoextend"),
3542
po::value<string>(),
3543
N_("Path to individual files and their sizes."));
3544
context("log-group-home-dir",
3545
po::value<string>(),
3478
3546
N_("Path to individual files and their sizes."));
3479
3547
context("log-group-home-dir",
3480
3548
po::value<string>(),
3481
3549
N_("Path to HailDB log files."));
3482
3550
context("log-file-size",
3483
po::value<log_file_constraint>(&haildb_log_file_size)->default_value(20*1024*1024L),
3551
po::value<int64_t>(&haildb_log_file_size)->default_value(20*1024*1024L),
3484
3552
N_("Size of each log file in a log group."));
3485
3553
context("haildb-log-files-in-group",
3486
po::value<log_files_in_group_constraint>(&haildb_log_files_in_group)->default_value(2),
3554
po::value<int64_t>(&haildb_log_files_in_group)->default_value(2),
3487
3555
N_("Number of log files in the log group. HailDB writes to the files in a circular fashion. Value 3 is recommended here."));
3488
3556
context("lock-wait-timeout",
3489
po::value<lock_wait_constraint>(&innobase_lock_wait_timeout)->default_value(5),
3557
po::value<unsigned long>(&innobase_lock_wait_timeout)->default_value(5),
3490
3558
N_("Timeout in seconds an HailDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout."));
3491
3559
context("log-buffer-size",
3492
po::value<log_buffer_size_constraint>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
3560
po::value<long>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
3493
3561
N_("The size of the buffer which HailDB uses to write log to the log files on disk."));
3494
3562
context("lru-old-blocks-pct",
3495
po::value<lru_old_blocks_constraint>(&innobase_lru_old_blocks_pct)->default_value(37),
3563
po::value<unsigned long>(&innobase_lru_old_blocks_pct)->default_value(37),
3496
3564
N_("Sets the point in the LRU list from where all pages are classified as old (Advanced users)"));
3497
3565
context("lru-block-access-recency",
3498
po::value<uint32_t>(&innobase_lru_block_access_recency)->default_value(0),
3566
po::value<unsigned long>(&innobase_lru_block_access_recency)->default_value(0),
3499
3567
N_("Milliseconds between accesses to a block at which it is made young. 0=disabled (Advanced users)"));
3500
3568
context("max-dirty-pages-pct",
3501
po::value<max_dirty_pages_constraint>(&haildb_max_dirty_pages_pct)->default_value(75),
3569
po::value<unsigned long>(&srv_max_buf_pool_modified_pct)->default_value(75),
3502
3570
N_("Percentage of dirty pages allowed in bufferpool."));
3503
3571
context("max-purge-lag",
3504
po::value<uint64_constraint>(&haildb_max_purge_lag)->default_value(0),
3572
po::value<unsigned long>(&srv_max_purge_lag)->default_value(0),
3505
3573
N_("Desired maximum length of the purge queue (0 = no limit)"));
3506
3574
context("rollback-on-timeout",
3507
3575
po::value<bool>(&innobase_rollback_on_timeout)->default_value(false)->zero_tokens(),
3508
3576
N_("Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)"));
3509
3577
context("open-files",
3510
po::value<open_files_constraint>(&haildb_open_files)->default_value(300),
3578
po::value<long>(&innobase_open_files)->default_value(300),
3511
3579
N_("How many files at the maximum HailDB keeps open at the same time."));
3512
3580
context("read-io-threads",
3513
po::value<io_threads_constraint>(&haildb_read_io_threads)->default_value(4),
3581
po::value<unsigned long>(&innobase_read_io_threads)->default_value(4),
3514
3582
N_("Number of background read I/O threads in HailDB."));
3515
3583
context("write-io-threads",
3516
po::value<io_threads_constraint>(&haildb_write_io_threads)->default_value(4),
3584
po::value<unsigned long>(&innobase_write_io_threads)->default_value(4),
3517
3585
N_("Number of background write I/O threads in HailDB."));
3518
3586
context("disable-print-verbose-log",
3519
3587
N_("Disable if you want to reduce the number of messages written to the log (default: enabled)."));
3521
3589
po::value<bool>(&innobase_create_status_file)->default_value(false)->zero_tokens(),
3522
3590
N_("Enable SHOW HAILDB STATUS output in the log"));
3523
3591
context("sync-spin-loops",
3524
po::value<uint64_constraint>(&haildb_sync_spin_loops)->default_value(30L),
3592
po::value<unsigned long>(&srv_n_spin_wait_rounds)->default_value(30L),
3525
3593
N_("Count of spin-loop rounds in HailDB mutexes (30 by default)"));
3526
3594
context("use-internal-malloc",
3527
3595
N_("Use HailDB's internal memory allocator instead of the OS memory allocator"));
3598
static drizzle_sys_var* innobase_system_variables[]= {
3599
DRIZZLE_SYSVAR(checksums),
3600
DRIZZLE_SYSVAR(data_home_dir),
3601
DRIZZLE_SYSVAR(doublewrite),
3602
DRIZZLE_SYSVAR(io_capacity),
3603
DRIZZLE_SYSVAR(fast_shutdown),
3604
DRIZZLE_SYSVAR(file_per_table),
3605
DRIZZLE_SYSVAR(file_format),
3606
DRIZZLE_SYSVAR(flush_log_at_trx_commit),
3607
DRIZZLE_SYSVAR(flush_method),
3608
DRIZZLE_SYSVAR(force_recovery),
3609
DRIZZLE_SYSVAR(log_group_home_dir),
3610
DRIZZLE_SYSVAR(data_file_path),
3611
DRIZZLE_SYSVAR(lock_wait_timeout),
3612
DRIZZLE_SYSVAR(log_file_size),
3613
DRIZZLE_SYSVAR(log_files_in_group),
3614
DRIZZLE_SYSVAR(log_buffer_size),
3615
DRIZZLE_SYSVAR(lru_old_blocks_pct),
3616
DRIZZLE_SYSVAR(lru_block_access_recency),
3617
DRIZZLE_SYSVAR(max_dirty_pages_pct),
3618
DRIZZLE_SYSVAR(max_purge_lag),
3619
DRIZZLE_SYSVAR(open_files),
3620
DRIZZLE_SYSVAR(read_io_threads),
3621
DRIZZLE_SYSVAR(rollback_on_timeout),
3622
DRIZZLE_SYSVAR(write_io_threads),
3623
DRIZZLE_SYSVAR(print_verbose_log),
3624
DRIZZLE_SYSVAR(status_file),
3625
DRIZZLE_SYSVAR(sync_spin_loops),
3626
DRIZZLE_SYSVAR(use_sys_malloc),
3530
3630
DRIZZLE_DECLARE_PLUGIN
3532
3632
DRIZZLE_VERSION_ID,