2019
1977
ret= HA_ERR_FOUND_DUPP_KEY;
2021
1979
else if (err != DB_SUCCESS)
2022
ret= ib_err_t_to_drizzle_error(getTable()->getSession(), err);
1980
ret= ib_err_t_to_drizzle_error(err);
2024
1982
tuple= ib_tuple_clear(tuple);
2025
1983
ib_tuple_delete(tuple);
2027
1984
err= ib_cursor_reset(cursor);
2032
int HailDBCursor::doUpdateRecord(const unsigned char *old_data,
2033
unsigned char *new_data)
1989
int HailDBCursor::doUpdateRecord(const unsigned char *,
2035
1992
ib_tpl_t update_tuple;
2037
bool created_tuple= false;
2039
1995
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
1997
err= ib_tuple_copy(update_tuple, tuple);
2086
1998
assert(err == DB_SUCCESS);
2088
write_row_to_haildb_tuple(new_data, getTable()->getFields(), update_tuple);
2000
write_row_to_haildb_tuple(getTable()->getFields(), update_tuple);
2090
2002
err= ib_cursor_update_row(cursor, tuple, update_tuple);
2092
2004
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
2006
advance_cursor= true;
2105
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2008
if (err == DB_SUCCESS)
2010
else if (err == DB_DUPLICATE_KEY)
2011
return HA_ERR_FOUND_DUPP_KEY;
2108
2016
int HailDBCursor::doDeleteRecord(const unsigned char *)
2112
assert(ib_cursor_is_positioned(cursor) == IB_TRUE);
2113
2020
err= ib_cursor_delete_row(cursor);
2021
if (err != DB_SUCCESS)
2115
2024
advance_cursor= true;
2117
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2120
2028
int HailDBCursor::delete_all_rows(void)
2122
2030
/* I *think* ib_truncate is non-transactional....
2123
2031
so only support TRUNCATE and not DELETE FROM t;
2124
(this is what ha_innodb does)
2032
(this is what ha_haildb does)
2126
if (getTable()->in_use->getSqlCommand() != SQLCOM_TRUNCATE)
2034
if (session_sql_command(getTable()->in_use) != SQLCOM_TRUNCATE)
2127
2035
return HA_ERR_WRONG_COMMAND;
2511
2381
if (flag & HA_STATUS_AUTO)
2512
2382
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
2386
int HailDBCursor::doStartIndexScan(uint32_t keynr, bool)
2581
2388
ib_trx_t transaction= *get_trx(getTable()->in_use);
2583
2390
active_index= keynr;
2392
ib_cursor_attach_trx(cursor, transaction);
2585
2394
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
2396
tuple= ib_clust_read_tuple_create(cursor);
2608
2401
ib_id_t index_id;
2609
2402
err= ib_index_get_id(table_path_to_haildb_name(getShare()->getPath()),
2610
2403
getShare()->getKeyInfo(keynr).name,
2612
2405
if (err != DB_SUCCESS)
2613
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2615
2408
err= ib_cursor_close(cursor);
2616
2409
assert(err == DB_SUCCESS);
2618
2410
err= ib_cursor_open_index_using_id(index_id, transaction, &cursor);
2620
2412
if (err != DB_SUCCESS)
2621
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2623
cursor_is_sec_index= true;
2625
2415
tuple= ib_clust_read_tuple_create(cursor);
2626
2416
ib_cursor_set_cluster_access(cursor);
2629
err= ib_cursor_set_lock_mode(cursor, ib_lock_mode);
2419
ib_err_t err= ib_cursor_set_lock_mode(cursor, ib_lock_mode);
2630
2420
assert(err == DB_SUCCESS);
2632
2422
advance_cursor= false;
3051
2832
static bool innobase_rollback_on_timeout;
3052
2833
static bool innobase_create_status_file;
3053
2834
static bool srv_use_sys_malloc;
3054
static string innobase_file_format_name;
3055
typedef constrained_check<unsigned int, 1000, 1> autoextend_constraint;
3056
static autoextend_constraint srv_auto_extend_increment;
3057
typedef constrained_check<size_t, SIZE_MAX, 5242880, 1048576> buffer_pool_constraint;
3058
static buffer_pool_constraint innobase_buffer_pool_size;
3059
typedef constrained_check<size_t, SIZE_MAX, 512, 1024> additional_mem_pool_constraint;
3060
static additional_mem_pool_constraint innobase_additional_mem_pool_size;
3061
static bool innobase_use_checksums= true;
3062
typedef constrained_check<unsigned int, UINT_MAX, 100> io_capacity_constraint;
3063
typedef constrained_check<uint32_t, 2, 0> trinary_constraint;
3064
static trinary_constraint innobase_fast_shutdown;
3065
static trinary_constraint srv_flush_log_at_trx_commit;
3066
typedef constrained_check<uint32_t, 6, 0> force_recovery_constraint;
3067
static force_recovery_constraint innobase_force_recovery;
3068
typedef constrained_check<int64_t, INT64_MAX, 1024*1024, 1024*1024> log_file_constraint;
3069
static log_file_constraint haildb_log_file_size;
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);
2835
static char* innobase_file_format_name = const_cast<char *>("Barracuda");
2836
static char* innobase_unix_file_flush_method = NULL;
2837
static unsigned long srv_flush_log_at_trx_commit;
2838
static unsigned long srv_max_buf_pool_modified_pct;
2839
static unsigned long srv_max_purge_lag;
2840
static unsigned long innobase_lru_old_blocks_pct;
2841
static unsigned long innobase_lru_block_access_recency;
2842
static unsigned long innobase_read_io_threads;
2843
static unsigned long innobase_write_io_threads;
2844
static unsigned int srv_auto_extend_increment;
2845
static unsigned long innobase_lock_wait_timeout;
2846
static unsigned long srv_n_spin_wait_rounds;
2847
static int64_t innobase_buffer_pool_size;
2848
static long innobase_open_files;
2849
static long innobase_additional_mem_pool_size;
2850
static long innobase_force_recovery;
2851
static long innobase_log_buffer_size;
2852
static char default_haildb_data_file_path[]= "ibdata1:10M:autoextend";
2853
static char* haildb_data_file_path= NULL;
2855
static int64_t haildb_log_file_size;
2856
static int64_t haildb_log_files_in_group;
3160
2858
static int haildb_init(drizzled::module::Context &context)
3177
2875
innobase_print_verbose_log= (vm.count("disable-print-verbose-log")) ? false : true;
3178
2876
srv_use_sys_malloc= (vm.count("use-internal-malloc")) ? false : true;
2878
if (vm.count("additional-mem-pool-size"))
2880
if (innobase_additional_mem_pool_size > LONG_MAX || innobase_additional_mem_pool_size < 512*1024L)
2882
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of additional-mem-pool-size"));
2885
innobase_additional_mem_pool_size/= 1024;
2886
innobase_additional_mem_pool_size*= 1024;
2889
if (vm.count("autoextend-increment"))
2891
if (srv_auto_extend_increment > 1000L || srv_auto_extend_increment < 1L)
2893
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of autoextend-increment"));
2898
if (vm.count("buffer-pool-size"))
2900
if (innobase_buffer_pool_size > INT64_MAX || innobase_buffer_pool_size < 5*1024*1024L)
2902
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of buffer-pool-size"));
2905
innobase_buffer_pool_size/= 1024*1024L;
2906
innobase_buffer_pool_size*= 1024*1024L;
2909
if (vm.count("io-capacity"))
2911
if (srv_io_capacity > (unsigned long)~0L || srv_io_capacity < 100)
2913
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of io-capacity"));
2918
if (vm.count("fast-shutdown"))
2920
if (innobase_fast_shutdown > 2)
2922
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of fast-shutdown"));
2927
if (vm.count("flush-log-at-trx-commit"))
2929
if (srv_flush_log_at_trx_commit > 2)
2931
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of flush-log-at-trx-commit"));
2936
if (vm.count("force-recovery"))
2938
if (innobase_force_recovery > 6)
2940
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of force-recovery"));
2945
if (vm.count("log-file-size"))
2947
if (haildb_log_file_size > INT64_MAX || haildb_log_file_size < 1*1024*1024L)
2949
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-file-size"));
2952
haildb_log_file_size/= 1024*1024L;
2953
haildb_log_file_size*= 1024*1024L;
2956
if (vm.count("log-files-in-group"))
2958
if (haildb_log_files_in_group > 100 || haildb_log_files_in_group < 2)
2960
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-files-in-group"));
2965
if (vm.count("lock-wait-timeout"))
2967
if (innobase_lock_wait_timeout > 1024*1024*1024 || innobase_lock_wait_timeout < 1)
2969
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lock-wait-timeout"));
2974
if (vm.count("log-buffer-size"))
2976
if (innobase_log_buffer_size > LONG_MAX || innobase_log_buffer_size < 256*1024L)
2978
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of log-buffer-size"));
2981
innobase_log_buffer_size/= 1024;
2982
innobase_log_buffer_size*= 1024;
2985
if (vm.count("lru-old-blocks-pct"))
2987
if (innobase_lru_old_blocks_pct > 95 || innobase_lru_old_blocks_pct < 5)
2989
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lru-old-blocks-pct"));
2994
if (vm.count("lru-block-access-recency"))
2996
if (innobase_lru_block_access_recency > ULONG_MAX)
2998
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of lru-block-access-recency"));
3003
if (vm.count("max-dirty-pages-pct"))
3005
if (srv_max_buf_pool_modified_pct > 99)
3007
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of max-dirty-pages-pct"));
3012
if (vm.count("max-purge-lag"))
3014
if (srv_max_purge_lag > (unsigned long)~0L)
3016
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of max-purge-lag"));
3021
if (vm.count("open-files"))
3023
if (innobase_open_files > LONG_MAX || innobase_open_files < 10L)
3025
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of open-files"));
3030
if (vm.count("read-io-threads"))
3032
if (innobase_read_io_threads > 64 || innobase_read_io_threads < 1)
3034
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of read-io-threads"));
3039
if (vm.count("sync-spin-loops"))
3041
if (srv_n_spin_wait_rounds > (unsigned long)~0L)
3043
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of sync_spin_loops"));
3048
if (vm.count("data-home-dir"))
3050
innobase_data_home_dir= const_cast<char *>(vm["data-home-dir"].as<string>().c_str());
3053
if (vm.count("file-format"))
3055
innobase_file_format_name= const_cast<char *>(vm["file-format"].as<string>().c_str());
3058
if (vm.count("log-group-home-dir"))
3060
innobase_log_group_home_dir= const_cast<char *>(vm["log-group-home-dir"].as<string>().c_str());
3063
if (vm.count("flush-method"))
3065
innobase_unix_file_flush_method= const_cast<char *>(vm["flush-method"].as<string>().c_str());
3068
if (vm.count("data-file-path"))
3070
haildb_data_file_path= const_cast<char *>(vm["data-file-path"].as<string>().c_str());
3347
3237
haildb_engine= new HailDBEngine("InnoDB");
3348
3238
context.add(haildb_engine);
3349
context.registerVariable(new sys_var_bool_ptr_readonly("adaptive_hash_index",
3350
&innobase_adaptive_hash_index));
3351
context.registerVariable(new sys_var_bool_ptr_readonly("adaptive_flushing",
3352
&srv_adaptive_flushing));
3353
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("additional_mem_pool_size",innobase_additional_mem_pool_size));
3354
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("autoextend_increment", srv_auto_extend_increment));
3355
context.registerVariable(new sys_var_constrained_value_readonly<size_t>("buffer_pool_size", innobase_buffer_pool_size));
3356
context.registerVariable(new sys_var_bool_ptr_readonly("checksums",
3357
&innobase_use_checksums));
3358
context.registerVariable(new sys_var_bool_ptr_readonly("doublewrite",
3359
&innobase_use_doublewrite));
3360
context.registerVariable(new sys_var_const_string_val("data_file_path",
3361
vm["data-file-path"].as<string>()));
3362
context.registerVariable(new sys_var_const_string_val("data_home_dir",
3363
vm["data-home-dir"].as<string>()));
3364
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("io_capacity", srv_io_capacity));
3365
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("fast_shutdown", innobase_fast_shutdown));
3366
context.registerVariable(new sys_var_bool_ptr_readonly("file_per_table",
3367
&srv_file_per_table));
3368
context.registerVariable(new sys_var_bool_ptr_readonly("rollback_on_timeout",
3369
&innobase_rollback_on_timeout));
3370
context.registerVariable(new sys_var_bool_ptr_readonly("print_verbose_log",
3371
&innobase_print_verbose_log));
3372
context.registerVariable(new sys_var_bool_ptr("status_file",
3373
&innobase_create_status_file,
3374
haildb_status_file_update));
3375
context.registerVariable(new sys_var_bool_ptr_readonly("use_sys_malloc",
3376
&srv_use_sys_malloc));
3377
context.registerVariable(new sys_var_std_string("file_format",
3378
innobase_file_format_name,
3379
haildb_file_format_name_validate));
3380
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("flush_log_at_trx_commit", srv_flush_log_at_trx_commit));
3381
context.registerVariable(new sys_var_const_string_val("flush_method",
3382
vm.count("flush-method") ? vm["flush-method"].as<string>() : ""));
3383
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("force_recovery", innobase_force_recovery));
3384
context.registerVariable(new sys_var_const_string_val("log_group_home_dir",
3385
vm.count("log-group-home-dir") ? vm["log-group-home-dir"].as<string>() : ""));
3386
context.registerVariable(new sys_var_constrained_value<int64_t>("log_file_size", haildb_log_file_size));
3387
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("log_files_in_group", haildb_log_files_in_group));
3388
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("lock_wait_timeout", innobase_lock_wait_timeout));
3389
context.registerVariable(new sys_var_constrained_value_readonly<long>("log_buffer_size", innobase_log_buffer_size));
3390
context.registerVariable(new sys_var_constrained_value<unsigned int>("lru_old_blocks_pct", innobase_lru_old_blocks_pct, haildb_lru_old_blocks_pct_update));
3391
context.registerVariable(new sys_var_uint32_t_ptr("lru_block_access_recency",
3392
&innobase_lru_block_access_recency,
3393
haildb_lru_block_access_recency_update));
3394
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("max_dirty_pages_pct", haildb_max_dirty_pages_pct));
3395
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("max_purge_lag", haildb_max_purge_lag));
3396
context.registerVariable(new sys_var_constrained_value_readonly<uint64_t>("sync_spin_loops", haildb_sync_spin_loops));
3397
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("open_files", haildb_open_files));
3398
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("read_io_threads", haildb_read_io_threads));
3399
context.registerVariable(new sys_var_constrained_value_readonly<unsigned int>("write_io_threads", haildb_write_io_threads));
3401
3240
haildb_datadict_dump_func_initialize(context);
3402
3241
config_table_function_initialize(context);
3271
static char haildb_file_format_name_storage[100];
3273
static int haildb_file_format_name_validate(Session*, drizzle_sys_var*,
3275
drizzle_value *value)
3279
int len= sizeof(buff);
3280
const char *format= value->val_str(value, buff, &len);
3282
*static_cast<const char**>(save)= NULL;
3287
err= ib_cfg_set_text("file_format", format);
3289
if (err == DB_SUCCESS)
3291
strncpy(haildb_file_format_name_storage, format, sizeof(haildb_file_format_name_storage));;
3292
haildb_file_format_name_storage[sizeof(haildb_file_format_name_storage)-1]= 0;
3294
*static_cast<const char**>(save)= haildb_file_format_name_storage;
3301
static void haildb_file_format_name_update(Session*, drizzle_sys_var*,
3308
assert(var_ptr != NULL);
3309
assert(save != NULL);
3311
format= *static_cast<const char*const*>(save);
3313
/* Format is already set in validate */
3314
memmove(haildb_file_format_name_storage, format, sizeof(haildb_file_format_name_storage));;
3315
haildb_file_format_name_storage[sizeof(haildb_file_format_name_storage)-1]= 0;
3317
*static_cast<const char**>(var_ptr)= haildb_file_format_name_storage;
3320
static void haildb_lru_old_blocks_pct_update(Session*, drizzle_sys_var*,
3327
pct= *static_cast<const unsigned long*>(save);
3329
ib_err_t err= ib_cfg_set_int("lru_old_blocks_pct", pct);
3330
if (err == DB_SUCCESS)
3331
innobase_lru_old_blocks_pct= pct;
3334
static void haildb_lru_block_access_recency_update(Session*, drizzle_sys_var*,
3341
ms= *static_cast<const unsigned long*>(save);
3343
ib_err_t err= ib_cfg_set_int("lru_block_access_recency", ms);
3345
if (err == DB_SUCCESS)
3346
innobase_lru_block_access_recency= ms;
3349
static void haildb_status_file_update(Session*, drizzle_sys_var*,
3354
bool status_file_enabled;
3357
status_file_enabled= *static_cast<const bool*>(save);
3360
if (status_file_enabled)
3361
err= ib_cfg_set_bool_on("status_file");
3363
err= ib_cfg_set_bool_off("status_file");
3365
if (err == DB_SUCCESS)
3366
innobase_create_status_file= status_file_enabled;
3369
static DRIZZLE_SYSVAR_BOOL(adaptive_hash_index, innobase_adaptive_hash_index,
3370
PLUGIN_VAR_NOCMDARG,
3371
"Enable HailDB adaptive hash index (enabled by default). ",
3374
static DRIZZLE_SYSVAR_BOOL(adaptive_flushing, srv_adaptive_flushing,
3375
PLUGIN_VAR_NOCMDARG,
3376
"Attempt flushing dirty pages to avoid IO bursts at checkpoints.",
3379
static DRIZZLE_SYSVAR_LONG(additional_mem_pool_size, innobase_additional_mem_pool_size,
3380
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3381
"Size of a memory pool HailDB uses to store data dictionary information and other internal data structures.",
3382
NULL, NULL, 8*1024*1024L, 512*1024L, LONG_MAX, 1024);
3384
static DRIZZLE_SYSVAR_UINT(autoextend_increment, srv_auto_extend_increment,
3385
PLUGIN_VAR_RQCMDARG,
3386
"Data file autoextend increment in megabytes",
3387
NULL, NULL, 8L, 1L, 1000L, 0);
3389
static DRIZZLE_SYSVAR_LONGLONG(buffer_pool_size, innobase_buffer_pool_size,
3390
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3391
"The size of the memory buffer HailDB uses to cache data and indexes of its tables.",
3392
NULL, NULL, 128*1024*1024L, 5*1024*1024L, INT64_MAX, 1024*1024L);
3394
static DRIZZLE_SYSVAR_BOOL(checksums, innobase_use_checksums,
3395
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
3396
"Enable HailDB checksums validation (enabled by default). "
3397
"Disable with --skip-haildb-checksums.",
3400
static DRIZZLE_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
3401
PLUGIN_VAR_READONLY,
3402
"The common part for HailDB table spaces.",
3405
static DRIZZLE_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
3406
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
3407
"Enable HailDB doublewrite buffer (enabled by default). "
3408
"Disable with --skip-haildb-doublewrite.",
3411
static DRIZZLE_SYSVAR_ULONG(io_capacity, srv_io_capacity,
3412
PLUGIN_VAR_RQCMDARG,
3413
"Number of IOPs the server can do. Tunes the background IO rate",
3414
NULL, NULL, 200, 100, ~0L, 0);
3416
static DRIZZLE_SYSVAR_ULONG(fast_shutdown, innobase_fast_shutdown,
3417
PLUGIN_VAR_OPCMDARG,
3418
"Speeds up the shutdown process of the HailDB storage engine. Possible "
3419
"values are 0, 1 (faster)"
3420
" or 2 (fastest - crash-like)"
3422
NULL, NULL, 1, 0, 2, 0);
3424
static DRIZZLE_SYSVAR_BOOL(file_per_table, srv_file_per_table,
3425
PLUGIN_VAR_NOCMDARG,
3426
"Stores each HailDB table to an .ibd file in the database dir.",
3429
static DRIZZLE_SYSVAR_STR(file_format, innobase_file_format_name,
3430
PLUGIN_VAR_RQCMDARG,
3431
"File format to use for new tables in .ibd files.",
3432
haildb_file_format_name_validate,
3433
haildb_file_format_name_update, "Barracuda");
3435
static DRIZZLE_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
3436
PLUGIN_VAR_OPCMDARG,
3437
"Set to 0 (write and flush once per second),"
3438
" 1 (write and flush at each commit)"
3439
" or 2 (write at commit, flush once per second).",
3440
NULL, NULL, 1, 0, 2, 0);
3442
static DRIZZLE_SYSVAR_STR(flush_method, innobase_unix_file_flush_method,
3443
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3444
"With which method to flush data.", NULL, NULL, NULL);
3446
static DRIZZLE_SYSVAR_LONG(force_recovery, innobase_force_recovery,
3447
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3448
"Helps to save your data in case the disk image of the database becomes corrupt.",
3449
NULL, NULL, 0, 0, 6, 0);
3451
static DRIZZLE_SYSVAR_STR(data_file_path, haildb_data_file_path,
3452
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3453
"Path to individual files and their sizes.",
3456
static DRIZZLE_SYSVAR_STR(log_group_home_dir, innobase_log_group_home_dir,
3457
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3458
"Path to HailDB log files.", NULL, NULL, NULL);
3460
static DRIZZLE_SYSVAR_LONGLONG(log_file_size, haildb_log_file_size,
3461
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3462
"Size of each log file in a log group.",
3463
NULL, NULL, 20*1024*1024L, 1*1024*1024L, INT64_MAX, 1024*1024L);
3465
static DRIZZLE_SYSVAR_LONGLONG(log_files_in_group, haildb_log_files_in_group,
3466
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3467
"Number of log files in the log group. HailDB writes to the files in a circular fashion. Value 3 is recommended here.",
3468
NULL, NULL, 2, 2, 100, 0);
3470
static DRIZZLE_SYSVAR_ULONG(lock_wait_timeout, innobase_lock_wait_timeout,
3471
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3472
"Timeout in seconds an HailDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.",
3473
NULL, NULL, 5, 1, 1024 * 1024 * 1024, 0);
3475
static DRIZZLE_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
3476
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3477
"The size of the buffer which HailDB uses to write log to the log files on disk.",
3478
NULL, NULL, 8*1024*1024L, 256*1024L, LONG_MAX, 1024);
3480
static DRIZZLE_SYSVAR_ULONG(lru_old_blocks_pct, innobase_lru_old_blocks_pct,
3481
PLUGIN_VAR_RQCMDARG,
3482
"Sets the point in the LRU list from where all pages are classified as "
3483
"old (Advanced users)",
3485
haildb_lru_old_blocks_pct_update, 37, 5, 95, 0);
3487
static DRIZZLE_SYSVAR_ULONG(lru_block_access_recency, innobase_lru_block_access_recency,
3488
PLUGIN_VAR_RQCMDARG,
3489
"Milliseconds between accesses to a block at which it is made young. "
3490
"0=disabled (Advanced users)",
3492
haildb_lru_block_access_recency_update, 0, 0, ULONG_MAX, 0);
3495
static DRIZZLE_SYSVAR_ULONG(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
3496
PLUGIN_VAR_RQCMDARG,
3497
"Percentage of dirty pages allowed in bufferpool.",
3498
NULL, NULL, 75, 0, 99, 0);
3500
static DRIZZLE_SYSVAR_ULONG(max_purge_lag, srv_max_purge_lag,
3501
PLUGIN_VAR_RQCMDARG,
3502
"Desired maximum length of the purge queue (0 = no limit)",
3503
NULL, NULL, 0, 0, ~0L, 0);
3505
static DRIZZLE_SYSVAR_BOOL(rollback_on_timeout, innobase_rollback_on_timeout,
3506
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
3507
"Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)",
3510
static DRIZZLE_SYSVAR_LONG(open_files, innobase_open_files,
3511
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3512
"How many files at the maximum HailDB keeps open at the same time.",
3513
NULL, NULL, 300L, 10L, LONG_MAX, 0);
3515
static DRIZZLE_SYSVAR_ULONG(read_io_threads, innobase_read_io_threads,
3516
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3517
"Number of background read I/O threads in HailDB.",
3518
NULL, NULL, 4, 1, 64, 0);
3520
static DRIZZLE_SYSVAR_ULONG(write_io_threads, innobase_write_io_threads,
3521
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3522
"Number of background write I/O threads in HailDB.",
3523
NULL, NULL, 4, 1, 64, 0);
3525
static DRIZZLE_SYSVAR_BOOL(print_verbose_log, innobase_print_verbose_log,
3526
PLUGIN_VAR_NOCMDARG,
3527
"Disable if you want to reduce the number of messages written to the log (default: enabled).",
3530
static DRIZZLE_SYSVAR_BOOL(status_file, innobase_create_status_file,
3531
PLUGIN_VAR_OPCMDARG,
3532
"Enable SHOW HAILDB STATUS output in the log",
3533
NULL, haildb_status_file_update, false);
3535
static DRIZZLE_SYSVAR_ULONG(sync_spin_loops, srv_n_spin_wait_rounds,
3536
PLUGIN_VAR_RQCMDARG,
3537
"Count of spin-loop rounds in HailDB mutexes (30 by default)",
3538
NULL, NULL, 30L, 0L, ~0L, 0);
3540
static DRIZZLE_SYSVAR_BOOL(use_sys_malloc, srv_use_sys_malloc,
3541
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
3542
"Use OS memory allocator instead of HailDB's internal memory allocator",
3433
3545
static void init_options(drizzled::module::option_context &context)
3437
3549
context("disable-adaptive-flushing",
3438
3550
N_("Do not attempt to flush dirty pages to avoid IO bursts at checkpoints."));
3439
3551
context("additional-mem-pool-size",
3440
po::value<additional_mem_pool_constraint>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
3552
po::value<long>(&innobase_additional_mem_pool_size)->default_value(8*1024*1024L),
3441
3553
N_("Size of a memory pool HailDB uses to store data dictionary information and other internal data structures."));
3442
3554
context("autoextend-increment",
3443
po::value<autoextend_constraint>(&srv_auto_extend_increment)->default_value(8),
3555
po::value<unsigned int>(&srv_auto_extend_increment)->default_value(8L),
3444
3556
N_("Data file autoextend increment in megabytes"));
3445
3557
context("buffer-pool-size",
3446
po::value<buffer_pool_constraint>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
3558
po::value<int64_t>(&innobase_buffer_pool_size)->default_value(128*1024*1024L),
3447
3559
N_("The size of the memory buffer HailDB uses to cache data and indexes of its tables."));
3448
3560
context("data-home-dir",
3449
po::value<string>()->default_value(""),
3561
po::value<string>(),
3450
3562
N_("The common part for HailDB table spaces."));
3451
3563
context("disable-checksums",
3452
3564
N_("Disable HailDB checksums validation (enabled by default)."));
3453
3565
context("disable-doublewrite",
3454
3566
N_("Disable HailDB doublewrite buffer (enabled by default)."));
3455
3567
context("io-capacity",
3456
po::value<io_capacity_constraint>(&srv_io_capacity)->default_value(200),
3568
po::value<unsigned long>(&srv_io_capacity)->default_value(200),
3457
3569
N_("Number of IOPs the server can do. Tunes the background IO rate"));
3458
3570
context("fast-shutdown",
3459
po::value<trinary_constraint>(&innobase_fast_shutdown)->default_value(1),
3571
po::value<unsigned long>(&innobase_fast_shutdown)->default_value(1),
3460
3572
N_("Speeds up the shutdown process of the HailDB storage engine. Possible values are 0, 1 (faster) or 2 (fastest - crash-like)."));
3461
3573
context("file-per-table",
3462
3574
po::value<bool>(&srv_file_per_table)->default_value(false)->zero_tokens(),
3463
3575
N_("Stores each HailDB table to an .ibd file in the database dir."));
3464
3576
context("file-format",
3465
po::value<string>(&innobase_file_format_name)->default_value("Barracuda"),
3577
po::value<string>(),
3466
3578
N_("File format to use for new tables in .ibd files."));
3467
3579
context("flush-log-at-trx-commit",
3468
po::value<trinary_constraint>(&srv_flush_log_at_trx_commit)->default_value(1),
3580
po::value<unsigned long>(&srv_flush_log_at_trx_commit)->default_value(1),
3469
3581
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
3582
context("flush-method",
3471
3583
po::value<string>(),
3472
3584
N_("With which method to flush data."));
3473
3585
context("force-recovery",
3474
po::value<force_recovery_constraint>(&innobase_force_recovery)->default_value(0),
3586
po::value<long>(&innobase_force_recovery)->default_value(0),
3475
3587
N_("Helps to save your data in case the disk image of the database becomes corrupt."));
3476
3588
context("data-file-path",
3477
po::value<string>()->default_value("ibdata1:10M:autoextend"),
3589
po::value<string>(),
3590
N_("Path to individual files and their sizes."));
3591
context("log-group-home-dir",
3592
po::value<string>(),
3478
3593
N_("Path to individual files and their sizes."));
3479
3594
context("log-group-home-dir",
3480
3595
po::value<string>(),
3481
3596
N_("Path to HailDB log files."));
3482
3597
context("log-file-size",
3483
po::value<log_file_constraint>(&haildb_log_file_size)->default_value(20*1024*1024L),
3598
po::value<int64_t>(&haildb_log_file_size)->default_value(20*1024*1024L),
3484
3599
N_("Size of each log file in a log group."));
3485
3600
context("haildb-log-files-in-group",
3486
po::value<log_files_in_group_constraint>(&haildb_log_files_in_group)->default_value(2),
3601
po::value<int64_t>(&haildb_log_files_in_group)->default_value(2),
3487
3602
N_("Number of log files in the log group. HailDB writes to the files in a circular fashion. Value 3 is recommended here."));
3488
3603
context("lock-wait-timeout",
3489
po::value<lock_wait_constraint>(&innobase_lock_wait_timeout)->default_value(5),
3604
po::value<unsigned long>(&innobase_lock_wait_timeout)->default_value(5),
3490
3605
N_("Timeout in seconds an HailDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout."));
3491
3606
context("log-buffer-size",
3492
po::value<log_buffer_size_constraint>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
3607
po::value<long>(&innobase_log_buffer_size)->default_value(8*1024*1024L),
3493
3608
N_("The size of the buffer which HailDB uses to write log to the log files on disk."));
3494
3609
context("lru-old-blocks-pct",
3495
po::value<lru_old_blocks_constraint>(&innobase_lru_old_blocks_pct)->default_value(37),
3610
po::value<unsigned long>(&innobase_lru_old_blocks_pct)->default_value(37),
3496
3611
N_("Sets the point in the LRU list from where all pages are classified as old (Advanced users)"));
3497
3612
context("lru-block-access-recency",
3498
po::value<uint32_t>(&innobase_lru_block_access_recency)->default_value(0),
3613
po::value<unsigned long>(&innobase_lru_block_access_recency)->default_value(0),
3499
3614
N_("Milliseconds between accesses to a block at which it is made young. 0=disabled (Advanced users)"));
3500
3615
context("max-dirty-pages-pct",
3501
po::value<max_dirty_pages_constraint>(&haildb_max_dirty_pages_pct)->default_value(75),
3616
po::value<unsigned long>(&srv_max_buf_pool_modified_pct)->default_value(75),
3502
3617
N_("Percentage of dirty pages allowed in bufferpool."));
3503
3618
context("max-purge-lag",
3504
po::value<uint64_constraint>(&haildb_max_purge_lag)->default_value(0),
3619
po::value<unsigned long>(&srv_max_purge_lag)->default_value(0),
3505
3620
N_("Desired maximum length of the purge queue (0 = no limit)"));
3506
3621
context("rollback-on-timeout",
3507
3622
po::value<bool>(&innobase_rollback_on_timeout)->default_value(false)->zero_tokens(),
3508
3623
N_("Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)"));
3509
3624
context("open-files",
3510
po::value<open_files_constraint>(&haildb_open_files)->default_value(300),
3625
po::value<long>(&innobase_open_files)->default_value(300),
3511
3626
N_("How many files at the maximum HailDB keeps open at the same time."));
3512
3627
context("read-io-threads",
3513
po::value<io_threads_constraint>(&haildb_read_io_threads)->default_value(4),
3628
po::value<unsigned long>(&innobase_read_io_threads)->default_value(4),
3514
3629
N_("Number of background read I/O threads in HailDB."));
3515
3630
context("write-io-threads",
3516
po::value<io_threads_constraint>(&haildb_write_io_threads)->default_value(4),
3631
po::value<unsigned long>(&innobase_write_io_threads)->default_value(4),
3517
3632
N_("Number of background write I/O threads in HailDB."));
3518
3633
context("disable-print-verbose-log",
3519
3634
N_("Disable if you want to reduce the number of messages written to the log (default: enabled)."));
3521
3636
po::value<bool>(&innobase_create_status_file)->default_value(false)->zero_tokens(),
3522
3637
N_("Enable SHOW HAILDB STATUS output in the log"));
3523
3638
context("sync-spin-loops",
3524
po::value<uint64_constraint>(&haildb_sync_spin_loops)->default_value(30L),
3639
po::value<unsigned long>(&srv_n_spin_wait_rounds)->default_value(30L),
3525
3640
N_("Count of spin-loop rounds in HailDB mutexes (30 by default)"));
3526
3641
context("use-internal-malloc",
3527
3642
N_("Use HailDB's internal memory allocator instead of the OS memory allocator"));
3645
static drizzle_sys_var* innobase_system_variables[]= {
3646
DRIZZLE_SYSVAR(adaptive_hash_index),
3647
DRIZZLE_SYSVAR(adaptive_flushing),
3648
DRIZZLE_SYSVAR(additional_mem_pool_size),
3649
DRIZZLE_SYSVAR(autoextend_increment),
3650
DRIZZLE_SYSVAR(buffer_pool_size),
3651
DRIZZLE_SYSVAR(checksums),
3652
DRIZZLE_SYSVAR(data_home_dir),
3653
DRIZZLE_SYSVAR(doublewrite),
3654
DRIZZLE_SYSVAR(io_capacity),
3655
DRIZZLE_SYSVAR(fast_shutdown),
3656
DRIZZLE_SYSVAR(file_per_table),
3657
DRIZZLE_SYSVAR(file_format),
3658
DRIZZLE_SYSVAR(flush_log_at_trx_commit),
3659
DRIZZLE_SYSVAR(flush_method),
3660
DRIZZLE_SYSVAR(force_recovery),
3661
DRIZZLE_SYSVAR(log_group_home_dir),
3662
DRIZZLE_SYSVAR(data_file_path),
3663
DRIZZLE_SYSVAR(lock_wait_timeout),
3664
DRIZZLE_SYSVAR(log_file_size),
3665
DRIZZLE_SYSVAR(log_files_in_group),
3666
DRIZZLE_SYSVAR(log_buffer_size),
3667
DRIZZLE_SYSVAR(lru_old_blocks_pct),
3668
DRIZZLE_SYSVAR(lru_block_access_recency),
3669
DRIZZLE_SYSVAR(max_dirty_pages_pct),
3670
DRIZZLE_SYSVAR(max_purge_lag),
3671
DRIZZLE_SYSVAR(open_files),
3672
DRIZZLE_SYSVAR(read_io_threads),
3673
DRIZZLE_SYSVAR(rollback_on_timeout),
3674
DRIZZLE_SYSVAR(write_io_threads),
3675
DRIZZLE_SYSVAR(print_verbose_log),
3676
DRIZZLE_SYSVAR(status_file),
3677
DRIZZLE_SYSVAR(sync_spin_loops),
3678
DRIZZLE_SYSVAR(use_sys_malloc),
3530
3682
DRIZZLE_DECLARE_PLUGIN
3532
3684
DRIZZLE_VERSION_ID,