1
/***********************************************************************
2
Copyright (c) 2008 Innobase Oy. All rights reserved.
3
Copyright (c) 2008 Oracle. All rights reserved.
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
************************************************************************/
31
#include "srv0start.h"
32
#include "trx0sys.h" /* for trx_sys_file_format_name_to_id() */
33
#include "ut0mem.h" /* for ut_malloc() */
35
/* If set then we rollback the transaction on DB_LOCK_WAIT_TIMEOUT error. */
36
extern ibool ses_rollback_on_timeout;
38
typedef enum ib_cfg_flag {
40
IB_CFG_FLAG_READONLY_AFTER_STARTUP, /* can be modified only before
42
IB_CFG_FLAG_READONLY /* cannot be modified */
45
typedef struct ib_cfg_var {
46
const char* name; /* config var name */
47
ib_cfg_type_t type; /* config var type */
48
ib_cfg_flag_t flag; /* config var flag */
49
ib_uint64_t min_val;/* minimum allowed value for numeric types,
50
ignored for other types */
51
ib_int64_t max_val;/* maximum allowed value for numeric types,
52
ignored for other types */
53
ib_bool_t (*validate)(const struct ib_cfg_var*, const void*); /*
54
function used to validate a new variable's
55
value when setting it */
56
ib_bool_t (*set)(struct ib_cfg_var*, const void*); /* function
57
used to set the variable's value */
58
ib_bool_t (*get)(const struct ib_cfg_var*, void*); /* function
59
used to get the variable's value */
60
void* tank; /* opaque storage that may be used by the
61
set() and get() functions */
64
/***********************************************************************
65
Assign src to dst according to type. */
70
/* out: IB_TRUE if assigned (type is known) */
71
ib_cfg_type_t type, /* in: type of src and dst */
72
void* dst, /* out: destination */
73
const void* src) /* in: source */
78
*(ib_bool_t*) dst = *(const ib_bool_t*) src;
84
*(ulint*) dst = *(const ulint*) src;
90
*(ulong*) dst = *(const ulong*) src;
98
str = *(const char**) src;
100
/* Release any previously allocated value. */
101
if (*(char**) dst != NULL) {
102
ut_free(*(char**) dst);
105
len = ut_strlen(str) + 1;
107
/* Since we are using ut_malloc(), it's guaranteed
108
to be freed during shutdown. */
109
*(char**) dst = ut_malloc(len);
110
ut_strcpy(*(char**) dst, str);
116
*(ib_cb_t*) dst = *(ib_cb_t*) src;
125
/***********************************************************************
126
A generic function used for ib_cfg_var_t::validate() to check a numeric
127
type for min/max allowed value overflow. */
130
ib_cfg_var_validate_numeric(
131
/*========================*/
132
/* out: IB_TRUE if value is in range */
133
const struct ib_cfg_var* cfg_var,/* in/out: configuration variable to
135
const void* value) /* in: value to check */
137
switch (cfg_var->type) {
144
if ((ulint) cfg_var->min_val <= v
145
&& v <= (ulint) cfg_var->max_val) {
159
if ((ulong) cfg_var->min_val <= v
160
&& v <= (ulong) cfg_var->max_val) {
176
/***********************************************************************
177
A generic function used for ib_cfg_var_t::set() that stores the value
178
of the configuration parameter in the location pointed by
179
ib_cfg_var_t::tank. */
182
ib_cfg_var_set_generic(
183
/*===================*/
184
/* out: IB_TRUE if set successfully */
185
struct ib_cfg_var* cfg_var,/* in/out: configuration variable to
187
const void* value) /* in: value to set */
189
if (cfg_var->validate != NULL) {
190
if (!cfg_var->validate(cfg_var, value)) {
195
return(ib_cfg_assign(cfg_var->type, cfg_var->tank, value));
198
/***********************************************************************
199
A generic function used for ib_cfg_var_t::get() that retrieves the value
200
of the configuration parameter from the location pointed by
201
ib_cfg_var_t::tank. */
204
ib_cfg_var_get_generic(
205
/*===================*/
207
retrieved successfully */
208
const struct ib_cfg_var* cfg_var,/* in: configuration
209
variable whose value to
211
void* value) /* out: place to store
212
the retrieved value */
214
return(ib_cfg_assign(cfg_var->type, value, cfg_var->tank));
217
/***********************************************************************
218
Set the value of the config variable "adaptive_hash_index". */
221
ib_cfg_var_set_adaptive_hash_index(
222
/*===============================*/
223
/* out: IB_TRUE if set successfully */
224
struct ib_cfg_var* cfg_var,/* in/out: configuration variable to
226
"adaptive_hash_index" */
227
const void* value) /* in: value to set, must point to
228
ib_bool_t variable */
230
ut_a(strcasecmp(cfg_var->name, "adaptive_hash_index") == 0);
231
ut_a(cfg_var->type == IB_CFG_IBOOL);
233
btr_search_enabled = !(*(const ib_bool_t*) value);
238
/***********************************************************************
239
Retrieve the value of the config variable "adaptive_hash_index". */
242
ib_cfg_var_get_adaptive_hash_index(
243
/*===============================*/
245
retrieved successfully */
246
const struct ib_cfg_var* cfg_var,/* in: configuration
247
variable whose value to
249
"adaptive_hash_index" */
250
void* value) /* out: place to store
251
the retrieved value, must
252
point to ib_bool_t variable */
254
ut_a(strcasecmp(cfg_var->name, "adaptive_hash_index") == 0);
255
ut_a(cfg_var->type == IB_CFG_IBOOL);
257
*(ib_bool_t*) value = !btr_search_enabled;
262
/***********************************************************************
263
Set the value of the config variable "data_file_path". */
266
ib_cfg_var_set_data_file_path(
267
/*==========================*/
268
/* out: IB_TRUE if set successfully */
269
struct ib_cfg_var* cfg_var,/* in/out: configuration variable to
272
const void* value) /* in: value to set, must point to
275
const char* value_str;
277
ut_a(strcasecmp(cfg_var->name, "data_file_path") == 0);
278
ut_a(cfg_var->type == IB_CFG_TEXT);
280
value_str = *(char**) value;
282
return(srv_parse_data_file_paths_and_sizes(value_str));
285
/***********************************************************************
286
Retrieve the value of the config variable "data_file_path". */
289
ib_cfg_var_get_data_file_path(
290
/*==========================*/
292
retrieved successfully */
293
const struct ib_cfg_var* cfg_var,/* in: configuration
294
variable whose value to
297
void* value) /* out: place to store
298
the retrieved value, must
299
point to char* variable */
301
ut_a(strcasecmp(cfg_var->name, "data_file_path") == 0);
302
ut_a(cfg_var->type == IB_CFG_TEXT);
304
*(char**) value = srv_data_file_paths_and_sizes;
309
/***********************************************************************
310
Set the value of the config variable "file_format". */
313
ib_cfg_var_set_file_format(
314
/*=======================*/
315
/* out: IB_TRUE if set successfully */
316
struct ib_cfg_var* cfg_var,/* in/out: configuration variable to
317
manipulate, must be "file_format" */
318
const void* value) /* in: value to set, must point to
323
ut_a(strcasecmp(cfg_var->name, "file_format") == 0);
324
ut_a(cfg_var->type == IB_CFG_TEXT);
326
format_id = trx_sys_file_format_name_to_id(*(char**) value);
328
if (format_id > DICT_TF_FORMAT_MAX) {
332
srv_file_format = format_id;
337
/***********************************************************************
338
Retrieve the value of the config variable "file_format". */
341
ib_cfg_var_get_file_format(
342
/*=======================*/
344
retrieved successfully */
345
const struct ib_cfg_var* cfg_var,/* in: configuration
346
variable whose value to
349
void* value) /* out: place to store
350
the retrieved value, must
351
point to char* variable */
353
ut_a(strcasecmp(cfg_var->name, "file_format") == 0);
354
ut_a(cfg_var->type == IB_CFG_TEXT);
356
*(const char**) value = trx_sys_file_format_id_to_name(
362
/***********************************************************************
363
Set the value of the config variable "log_group_home_dir". */
366
ib_cfg_var_set_log_group_home_dir(
367
/*==============================*/
368
/* out: IB_TRUE if set successfully */
369
struct ib_cfg_var* cfg_var,/* in/out: configuration variable to
371
"log_group_home_dir" */
372
const void* value) /* in: value to set, must point to
375
const char* value_str;
377
ut_a(strcasecmp(cfg_var->name, "log_group_home_dir") == 0);
378
ut_a(cfg_var->type == IB_CFG_TEXT);
380
ut_a(srv_log_group_home_dir == NULL);
382
value_str = *(char**) value;
384
return(srv_parse_log_group_home_dirs(value_str));
387
/***********************************************************************
388
Retrieve the value of the config variable "log_group_home_dir". */
391
ib_cfg_var_get_log_group_home_dir(
392
/*==============================*/
394
retrieved successfully */
395
const struct ib_cfg_var* cfg_var,/* in: configuration
396
variable whose value to
398
"log_group_home_dir" */
399
void* value) /* out: place to store
400
the retrieved value, must
401
point to char* variable */
403
ut_a(strcasecmp(cfg_var->name, "log_group_home_dir") == 0);
404
ut_a(cfg_var->type == IB_CFG_TEXT);
406
*(const char**) value = NULL;
411
/* There is no ib_cfg_var_set_version() */
413
/***********************************************************************
414
Retrieve the value of the config variable "version". */
417
ib_cfg_var_get_version(
418
/*===================*/
420
retrieved successfully */
421
const struct ib_cfg_var* cfg_var,/* in: configuration
422
variable whose value to
425
void* value) /* out: place to store
426
the retrieved value, must
427
point to char* variable */
429
ut_a(strcasecmp(cfg_var->name, "version") == 0);
430
ut_a(cfg_var->type == IB_CFG_TEXT);
432
*(const char**) value = INNODB_VERSION_STR;
437
static ib_cfg_var_t cfg_vars[] = {
438
{STRUCT_FLD(name, "adaptive_hash_index"),
439
STRUCT_FLD(type, IB_CFG_IBOOL),
440
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY_AFTER_STARTUP),
441
STRUCT_FLD(min_val, 0),
442
STRUCT_FLD(max_val, 0),
443
STRUCT_FLD(validate, NULL),
444
STRUCT_FLD(set, ib_cfg_var_set_adaptive_hash_index),
445
STRUCT_FLD(get, ib_cfg_var_get_adaptive_hash_index),
446
STRUCT_FLD(tank, NULL)},
448
{STRUCT_FLD(name, "additional_mem_pool_size"),
449
STRUCT_FLD(type, IB_CFG_ULINT),
450
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY_AFTER_STARTUP),
451
STRUCT_FLD(min_val, 512 * 1024),
452
STRUCT_FLD(max_val, ~0L),
453
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
454
STRUCT_FLD(set, ib_cfg_var_set_generic),
455
STRUCT_FLD(get, ib_cfg_var_get_generic),
456
STRUCT_FLD(tank, &srv_mem_pool_size)},
458
{STRUCT_FLD(name, "autoextend_increment"),
459
STRUCT_FLD(type, IB_CFG_ULONG),
460
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
461
STRUCT_FLD(min_val, 1),
462
STRUCT_FLD(max_val, 1000),
463
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
464
STRUCT_FLD(set, ib_cfg_var_set_generic),
465
STRUCT_FLD(get, ib_cfg_var_get_generic),
466
STRUCT_FLD(tank, &srv_auto_extend_increment)},
468
{STRUCT_FLD(name, "buffer_pool_size"),
469
STRUCT_FLD(type, IB_CFG_ULINT),
470
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY_AFTER_STARTUP),
471
STRUCT_FLD(min_val, 5 * 1024 * 1024),
472
STRUCT_FLD(max_val, ULINT_MAX),
473
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
474
STRUCT_FLD(set, ib_cfg_var_set_generic),
475
STRUCT_FLD(get, ib_cfg_var_get_generic),
476
STRUCT_FLD(tank, &srv_buf_pool_size)},
478
{STRUCT_FLD(name, "checksums"),
479
STRUCT_FLD(type, IB_CFG_IBOOL),
480
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY_AFTER_STARTUP),
481
STRUCT_FLD(min_val, 0),
482
STRUCT_FLD(max_val, 0),
483
STRUCT_FLD(validate, NULL),
484
STRUCT_FLD(set, ib_cfg_var_set_generic),
485
STRUCT_FLD(get, ib_cfg_var_get_generic),
486
STRUCT_FLD(tank, &srv_use_checksums)},
488
{STRUCT_FLD(name, "commit_concurrency"),
489
STRUCT_FLD(type, IB_CFG_ULONG),
490
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
491
STRUCT_FLD(min_val, 0),
492
STRUCT_FLD(max_val, 1000),
493
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
494
STRUCT_FLD(set, ib_cfg_var_set_generic),
495
STRUCT_FLD(get, ib_cfg_var_get_generic),
496
STRUCT_FLD(tank, &srv_commit_concurrency)},
498
{STRUCT_FLD(name, "concurrency_tickets"),
499
STRUCT_FLD(type, IB_CFG_ULONG),
500
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
501
STRUCT_FLD(min_val, 1),
502
STRUCT_FLD(max_val, ~0L),
503
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
504
STRUCT_FLD(set, ib_cfg_var_set_generic),
505
STRUCT_FLD(get, ib_cfg_var_get_generic),
506
STRUCT_FLD(tank, &srv_n_free_tickets_to_enter)},
508
{STRUCT_FLD(name, "data_file_path"),
509
STRUCT_FLD(type, IB_CFG_TEXT),
510
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY_AFTER_STARTUP),
511
STRUCT_FLD(min_val, 0),
512
STRUCT_FLD(max_val, 0),
513
STRUCT_FLD(validate, NULL),
514
STRUCT_FLD(set, ib_cfg_var_set_data_file_path),
515
STRUCT_FLD(get, ib_cfg_var_get_data_file_path),
516
STRUCT_FLD(tank, NULL)},
518
{STRUCT_FLD(name, "data_home_dir"),
519
STRUCT_FLD(type, IB_CFG_TEXT),
520
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY_AFTER_STARTUP),
521
STRUCT_FLD(min_val, 0),
522
STRUCT_FLD(max_val, 0),
523
STRUCT_FLD(validate, NULL),
524
STRUCT_FLD(set, ib_cfg_var_set_generic),
525
STRUCT_FLD(get, ib_cfg_var_get_generic),
526
STRUCT_FLD(tank, &srv_data_home)},
528
{STRUCT_FLD(name, "doublewrite"),
529
STRUCT_FLD(type, IB_CFG_IBOOL),
530
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY_AFTER_STARTUP),
531
STRUCT_FLD(min_val, 0),
532
STRUCT_FLD(max_val, 0),
533
STRUCT_FLD(validate, NULL),
534
STRUCT_FLD(set, ib_cfg_var_set_generic),
535
STRUCT_FLD(get, ib_cfg_var_get_generic),
536
STRUCT_FLD(tank, &srv_use_doublewrite_buf)},
538
{STRUCT_FLD(name, "fast_shutdown"),
539
STRUCT_FLD(type, IB_CFG_ULINT),
540
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
541
STRUCT_FLD(min_val, 0),
542
STRUCT_FLD(max_val, 2),
543
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
544
STRUCT_FLD(set, ib_cfg_var_set_generic),
545
STRUCT_FLD(get, ib_cfg_var_get_generic),
546
STRUCT_FLD(tank, &srv_fast_shutdown)},
548
{STRUCT_FLD(name, "file_format"),
549
STRUCT_FLD(type, IB_CFG_TEXT),
550
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
551
STRUCT_FLD(min_val, 0),
552
STRUCT_FLD(max_val, 0),
553
STRUCT_FLD(validate, NULL /* validation is done inside
554
ib_cfg_var_set_file_format */),
555
STRUCT_FLD(set, ib_cfg_var_set_file_format),
556
STRUCT_FLD(get, ib_cfg_var_get_file_format),
557
STRUCT_FLD(tank, NULL)},
559
{STRUCT_FLD(name, "file_io_threads"),
560
STRUCT_FLD(type, IB_CFG_ULINT),
561
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY_AFTER_STARTUP),
562
STRUCT_FLD(min_val, 4),
563
STRUCT_FLD(max_val, 64),
564
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
565
STRUCT_FLD(set, ib_cfg_var_set_generic),
566
STRUCT_FLD(get, ib_cfg_var_get_generic),
567
STRUCT_FLD(tank, &srv_n_file_io_threads)},
569
{STRUCT_FLD(name, "file_per_table"),
570
STRUCT_FLD(type, IB_CFG_IBOOL),
571
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
572
STRUCT_FLD(min_val, 0),
573
STRUCT_FLD(max_val, 0),
574
STRUCT_FLD(validate, NULL),
575
STRUCT_FLD(set, ib_cfg_var_set_generic),
576
STRUCT_FLD(get, ib_cfg_var_get_generic),
577
STRUCT_FLD(tank, &srv_file_per_table)},
579
{STRUCT_FLD(name, "flush_log_at_trx_commit"),
580
STRUCT_FLD(type, IB_CFG_ULONG),
581
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
582
STRUCT_FLD(min_val, 0),
583
STRUCT_FLD(max_val, 2),
584
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
585
STRUCT_FLD(set, ib_cfg_var_set_generic),
586
STRUCT_FLD(get, ib_cfg_var_get_generic),
587
STRUCT_FLD(tank, &srv_flush_log_at_trx_commit)},
589
{STRUCT_FLD(name, "flush_method"),
590
STRUCT_FLD(type, IB_CFG_TEXT),
591
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY_AFTER_STARTUP),
592
STRUCT_FLD(min_val, 0),
593
STRUCT_FLD(max_val, 0),
594
STRUCT_FLD(validate, NULL),
595
STRUCT_FLD(set, ib_cfg_var_set_generic),
596
STRUCT_FLD(get, ib_cfg_var_get_generic),
597
STRUCT_FLD(tank, &srv_file_flush_method_str)},
599
{STRUCT_FLD(name, "force_recovery"),
600
STRUCT_FLD(type, IB_CFG_ULINT),
601
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY_AFTER_STARTUP),
602
STRUCT_FLD(min_val, 0),
603
STRUCT_FLD(max_val, 6),
604
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
605
STRUCT_FLD(set, ib_cfg_var_set_generic),
606
STRUCT_FLD(get, ib_cfg_var_get_generic),
607
STRUCT_FLD(tank, &srv_force_recovery)},
609
{STRUCT_FLD(name, "lock_wait_timeout"),
610
STRUCT_FLD(type, IB_CFG_ULINT),
611
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
612
STRUCT_FLD(min_val, 1),
613
STRUCT_FLD(max_val, 1024 * 1024 * 1024),
614
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
615
STRUCT_FLD(set, ib_cfg_var_set_generic),
616
STRUCT_FLD(get, ib_cfg_var_get_generic),
617
STRUCT_FLD(tank, &ses_lock_wait_timeout)},
619
{STRUCT_FLD(name, "log_buffer_size"),
620
STRUCT_FLD(type, IB_CFG_ULINT),
621
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY_AFTER_STARTUP),
622
STRUCT_FLD(min_val, 256 * 1024),
623
STRUCT_FLD(max_val, ~0L),
624
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
625
STRUCT_FLD(set, ib_cfg_var_set_generic),
626
STRUCT_FLD(get, ib_cfg_var_get_generic),
627
STRUCT_FLD(tank, &srv_log_buffer_size)},
629
{STRUCT_FLD(name, "log_file_size"),
630
STRUCT_FLD(type, IB_CFG_ULINT),
631
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY_AFTER_STARTUP),
632
STRUCT_FLD(min_val, 1024 * 1024),
633
STRUCT_FLD(max_val, ULINT_MAX),
634
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
635
STRUCT_FLD(set, ib_cfg_var_set_generic),
636
STRUCT_FLD(get, ib_cfg_var_get_generic),
637
STRUCT_FLD(tank, &srv_log_file_size)},
639
{STRUCT_FLD(name, "log_files_in_group"),
640
STRUCT_FLD(type, IB_CFG_ULINT),
641
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY_AFTER_STARTUP),
642
STRUCT_FLD(min_val, 2),
643
STRUCT_FLD(max_val, 100),
644
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
645
STRUCT_FLD(set, ib_cfg_var_set_generic),
646
STRUCT_FLD(get, ib_cfg_var_get_generic),
647
STRUCT_FLD(tank, &srv_n_log_files)},
649
{STRUCT_FLD(name, "log_group_home_dir"),
650
STRUCT_FLD(type, IB_CFG_TEXT),
651
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY_AFTER_STARTUP),
652
STRUCT_FLD(min_val, 0),
653
STRUCT_FLD(max_val, 0),
654
STRUCT_FLD(validate, NULL),
655
STRUCT_FLD(set, ib_cfg_var_set_log_group_home_dir),
656
STRUCT_FLD(get, ib_cfg_var_get_log_group_home_dir),
657
STRUCT_FLD(tank, NULL)},
659
{STRUCT_FLD(name, "max_dirty_pages_pct"),
660
STRUCT_FLD(type, IB_CFG_ULONG),
661
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
662
STRUCT_FLD(min_val, 0),
663
STRUCT_FLD(max_val, 100),
664
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
665
STRUCT_FLD(set, ib_cfg_var_set_generic),
666
STRUCT_FLD(get, ib_cfg_var_get_generic),
667
STRUCT_FLD(tank, &srv_max_buf_pool_modified_pct)},
669
{STRUCT_FLD(name, "max_purge_lag"),
670
STRUCT_FLD(type, IB_CFG_ULONG),
671
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
672
STRUCT_FLD(min_val, 0),
673
STRUCT_FLD(max_val, ~0L),
674
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
675
STRUCT_FLD(set, ib_cfg_var_set_generic),
676
STRUCT_FLD(get, ib_cfg_var_get_generic),
677
STRUCT_FLD(tank, &srv_max_purge_lag)},
679
{STRUCT_FLD(name, "mirrored_log_groups"),
680
STRUCT_FLD(type, IB_CFG_ULINT),
681
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY_AFTER_STARTUP),
682
STRUCT_FLD(min_val, 1),
683
STRUCT_FLD(max_val, 10),
684
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
685
STRUCT_FLD(set, ib_cfg_var_set_generic),
686
STRUCT_FLD(get, ib_cfg_var_get_generic),
687
STRUCT_FLD(tank, &srv_n_log_groups)},
689
{STRUCT_FLD(name, "open_files"),
690
STRUCT_FLD(type, IB_CFG_ULINT),
691
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY_AFTER_STARTUP),
692
STRUCT_FLD(min_val, 10),
693
STRUCT_FLD(max_val, ~0L),
694
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
695
STRUCT_FLD(set, ib_cfg_var_set_generic),
696
STRUCT_FLD(get, ib_cfg_var_get_generic),
697
STRUCT_FLD(tank, &srv_max_n_open_files)},
699
/* New, not present in InnoDB/MySQL */
700
{STRUCT_FLD(name, "pre_rollback_hook"),
701
STRUCT_FLD(type, IB_CFG_CB),
702
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
703
STRUCT_FLD(min_val, 0),
704
STRUCT_FLD(max_val, 0),
705
STRUCT_FLD(validate, NULL),
706
STRUCT_FLD(set, ib_cfg_var_set_generic),
707
STRUCT_FLD(get, ib_cfg_var_get_generic),
708
STRUCT_FLD(tank, &recv_pre_rollback_hook)},
710
/* New, not present in InnoDB/MySQL */
711
{STRUCT_FLD(name, "print_verbose_log"),
712
STRUCT_FLD(type, IB_CFG_IBOOL),
713
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
714
STRUCT_FLD(min_val, 0),
715
STRUCT_FLD(max_val, 0),
716
STRUCT_FLD(validate, NULL),
717
STRUCT_FLD(set, ib_cfg_var_set_generic),
718
STRUCT_FLD(get, ib_cfg_var_get_generic),
719
STRUCT_FLD(tank, &srv_print_verbose_log)},
721
/* New, not present in InnoDB/MySQL */
722
{STRUCT_FLD(name, "rollback_on_timeout"),
723
STRUCT_FLD(type, IB_CFG_IBOOL),
724
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
725
STRUCT_FLD(min_val, 0),
726
STRUCT_FLD(max_val, 0),
727
STRUCT_FLD(validate, NULL),
728
STRUCT_FLD(set, ib_cfg_var_set_generic),
729
STRUCT_FLD(get, ib_cfg_var_get_generic),
730
STRUCT_FLD(tank, &ses_rollback_on_timeout)},
732
{STRUCT_FLD(name, "stats_sample_pages"),
733
STRUCT_FLD(type, IB_CFG_ULINT),
734
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
735
STRUCT_FLD(min_val, 1),
736
STRUCT_FLD(max_val, ULINT_MAX),
737
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
738
STRUCT_FLD(set, ib_cfg_var_set_generic),
739
STRUCT_FLD(get, ib_cfg_var_get_generic),
740
STRUCT_FLD(tank, &srv_stats_sample_pages)},
742
{STRUCT_FLD(name, "status_file"),
743
STRUCT_FLD(type, IB_CFG_IBOOL),
744
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
745
STRUCT_FLD(min_val, 0),
746
STRUCT_FLD(max_val, 0),
747
STRUCT_FLD(validate, NULL),
748
STRUCT_FLD(set, ib_cfg_var_set_generic),
749
STRUCT_FLD(get, ib_cfg_var_get_generic),
750
STRUCT_FLD(tank, &srv_innodb_status)},
752
{STRUCT_FLD(name, "sync_spin_loops"),
753
STRUCT_FLD(type, IB_CFG_ULONG),
754
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
755
STRUCT_FLD(min_val, 0),
756
STRUCT_FLD(max_val, ~0L),
757
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
758
STRUCT_FLD(set, ib_cfg_var_set_generic),
759
STRUCT_FLD(get, ib_cfg_var_get_generic),
760
STRUCT_FLD(tank, &srv_n_spin_wait_rounds)},
762
{STRUCT_FLD(name, "thread_concurrency"),
763
STRUCT_FLD(type, IB_CFG_ULONG),
764
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
765
STRUCT_FLD(min_val, 0),
766
STRUCT_FLD(max_val, 1000),
767
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
768
STRUCT_FLD(set, ib_cfg_var_set_generic),
769
STRUCT_FLD(get, ib_cfg_var_get_generic),
770
STRUCT_FLD(tank, &srv_thread_concurrency)},
772
{STRUCT_FLD(name, "thread_sleep_delay"),
773
STRUCT_FLD(type, IB_CFG_ULONG),
774
STRUCT_FLD(flag, IB_CFG_FLAG_NONE),
775
STRUCT_FLD(min_val, 0),
776
STRUCT_FLD(max_val, ~0L),
777
STRUCT_FLD(validate, ib_cfg_var_validate_numeric),
778
STRUCT_FLD(set, ib_cfg_var_set_generic),
779
STRUCT_FLD(get, ib_cfg_var_get_generic),
780
STRUCT_FLD(tank, &srv_thread_sleep_delay)},
782
{STRUCT_FLD(name, "version"),
783
STRUCT_FLD(type, IB_CFG_TEXT),
784
STRUCT_FLD(flag, IB_CFG_FLAG_READONLY),
785
STRUCT_FLD(min_val, 0),
786
STRUCT_FLD(max_val, 0),
787
STRUCT_FLD(validate, NULL),
788
STRUCT_FLD(set, NULL /* The ::set() function should never
789
be called because this variable is
790
flagged as IB_CFG_FLAG_READONLY */),
791
STRUCT_FLD(get, ib_cfg_var_get_version),
792
STRUCT_FLD(tank, NULL)},
795
/*************************************************************************
796
Lookup a variable name. */
801
/* out: config variable instance if
803
const char* var) /* in: variable name */
807
for (i = 0; i < UT_ARR_SIZE(cfg_vars); ++i) {
808
ib_cfg_var_t* cfg_var;
810
cfg_var = &cfg_vars[i];
812
if (strcasecmp(var, cfg_var->name) == 0) {
820
/*************************************************************************
821
Get the type of a configuration variable. Returns IB_TRUE if "type" was
822
set, IB_FALSE if no such variable. */
827
/* out: IB_TRUE if successful */
828
const char* name, /* in: variable name */
829
ib_cfg_type_t* type) /* out: variable type */
831
ib_cfg_var_t* cfg_var;
833
cfg_var = ib_cfg_lookup_var(name);
835
if (cfg_var != NULL) {
836
*type = cfg_var->type;
843
/*************************************************************************
844
Set a configuration variable. "ap" must contain one argument whose type
845
depends on the type of the variable with the given "name". */
850
/* out: IB_TRUE if set */
851
const char* name, /* in: variable name */
852
va_list ap) /* in: variable value */
854
ib_cfg_var_t* cfg_var;
856
if (!ib_cfg_are_defaults_set) {
857
ib_cfg_set_defaults();
860
cfg_var = ib_cfg_lookup_var(name);
862
if (cfg_var != NULL) {
864
/* check whether setting the variable is appropriate,
865
according to its flag */
866
switch (cfg_var->flag) {
867
case IB_CFG_FLAG_NONE:
870
case IB_CFG_FLAG_READONLY_AFTER_STARTUP:
871
if (srv_was_started) {
876
case IB_CFG_FLAG_READONLY:
880
/* get the parameter according to its type and call ::set() */
881
switch (cfg_var->type) {
885
value = va_arg(ap, int);
887
return(cfg_var->set(cfg_var, &value));
893
value = va_arg(ap, ulint);
895
return(cfg_var->set(cfg_var, &value));
901
value = va_arg(ap, ulong);
903
return(cfg_var->set(cfg_var, &value));
909
value = va_arg(ap, const char*);
911
return(cfg_var->set(cfg_var, &value));
917
value = va_arg(ap, ib_cb_t);
919
return(cfg_var->set(cfg_var, &value));
930
/*************************************************************************
931
Set a configuration variable. The second argument's type depends on the
932
type of the variable with the given "name". */
937
/* out: IB_TRUE if set */
938
const char* name, /* in: variable name */
939
...) /* in: variable value */
946
ret = ib_cfg_set_ap(name, ap);
953
/*************************************************************************
954
Get the value of a configuration variable. The type of the returned value
955
depends on the type of the configuration variable. IB_FALSE is returned if
956
no such variable exists. */
961
/* out: IB_TRUE if retrieved successfully */
962
const char* name, /* in: variable name */
963
void* value) /* out: place to store the retrieved
966
ib_cfg_var_t* cfg_var;
968
cfg_var = ib_cfg_lookup_var(name);
970
if (cfg_var != NULL) {
971
return(cfg_var->get(cfg_var, value));
977
/* Used to indicate whether the default values of the configuration
978
variables have been set or not. This is needed because we want to set
979
the defaults in ib_startup(), but we do not want to overwrite settings
980
possibly done by the user with ib_cfg_set() before he called ib_startup().
981
So if the first function invoked by the user is ib_startup() we call
982
ib_cfg_set_defaults() from there. Otherwise, if he calls ib_cfg_set()
983
first, then we call ib_cfg_set_defaults() from ib_cfg_set(). */
984
ib_bool_t ib_cfg_are_defaults_set = IB_FALSE;
986
/*************************************************************************
987
Set the default values of some variables, others get their defaults when
988
declared (in srv0srv.c). */
991
ib_cfg_set_defaults()
992
/*=================*/
994
ut_a(ib_cfg_are_defaults_set == FALSE);
996
ib_cfg_are_defaults_set = IB_TRUE;
997
#define IB_CFG_SET_DEFAULT(name, var) if (!ib_cfg_set(name, var)) ut_error
999
IB_CFG_SET_DEFAULT("additional_mem_pool_size", 4 * 1024 * 1024);
1000
IB_CFG_SET_DEFAULT("buffer_pool_size", 8 * 1024 * 1024);
1001
IB_CFG_SET_DEFAULT("data_file_path", "ibdata1:32M:autoextend");
1002
IB_CFG_SET_DEFAULT("data_home_dir", ".");
1003
IB_CFG_SET_DEFAULT("file_io_threads", 4);
1004
IB_CFG_SET_DEFAULT("file_per_table", IB_TRUE);
1005
IB_CFG_SET_DEFAULT("flush_method", "fsync");
1006
IB_CFG_SET_DEFAULT("lock_wait_timeout", 60);
1007
IB_CFG_SET_DEFAULT("log_buffer_size", 384 * 1024);
1008
IB_CFG_SET_DEFAULT("log_file_size", 16 * 1024 * 1024);
1009
IB_CFG_SET_DEFAULT("log_files_in_group", 2);
1010
IB_CFG_SET_DEFAULT("log_group_home_dir", "log");
1011
/* XXX ha_innodb.cc says mirrored_log_groups should be set to 1,
1012
why is it set to 2? */
1013
IB_CFG_SET_DEFAULT("mirrored_log_groups", 2);
1014
IB_CFG_SET_DEFAULT("rollback_on_timeout", IB_TRUE);
1015
#undef IB_CFG_SET_DEFAULT