1 /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 // vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
3 /* -*- mode: C; c-basic-offset: 4 -*- */
4 #ident "$Id$"
5 /*======
6 This file is part of TokuDB
7
8
9 Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
10
11 TokuDBis is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License, version 2,
13 as published by the Free Software Foundation.
14
15 TokuDB is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with TokuDB. If not, see <http://www.gnu.org/licenses/>.
22
23 ======= */
24
25 #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved."
26
27 #include "hatoku_hton.h"
28 #include "sql_acl.h"
29 #include "tokudb_dir_cmd.h"
30 #include "sql_parse.h"
31
32 namespace tokudb {
33 namespace sysvars {
34
35 //******************************************************************************
36 // global variables
37 //******************************************************************************
38 #ifdef TOKUDB_VERSION
39 #define tokudb_stringify_2(x) #x
40 #define tokudb_stringify(x) tokudb_stringify_2(x)
41 #define TOKUDB_VERSION_STR tokudb_stringify(TOKUDB_VERSION)
42 #else
43 #define TOKUDB_VERSION_STR NULL
44 #endif
45
46
47 ulonglong cache_size = 0;
48 uint cachetable_pool_threads = 0;
49 int cardinality_scale_percent = 0;
50 my_bool checkpoint_on_flush_logs = FALSE;
51 uint checkpoint_pool_threads = 0;
52 uint checkpointing_period = 0;
53 ulong cleaner_iterations = 0;
54 ulong cleaner_period = 0;
55 uint client_pool_threads = 0;
56 my_bool compress_buffers_before_eviction = TRUE;
57 char* data_dir = NULL;
58 ulong debug = 0;
59 #if defined(TOKUDB_DEBUG) && TOKUDB_DEBUG
60 // used to control background job manager
61 my_bool debug_pause_background_job_manager = FALSE;
62 #endif // defined(TOKUDB_DEBUG) && TOKUDB_DEBUG
63 my_bool directio = FALSE;
64 my_bool enable_partial_eviction = TRUE;
65 int fs_reserve_percent = 0;
66 uint fsync_log_period = 0;
67 char* log_dir = NULL;
68 ulonglong max_lock_memory = 0;
69 uint read_status_frequency = 0;
70 my_bool strip_frm_data = FALSE;
71 char* tmp_dir = NULL;
72 uint write_status_frequency = 0;
73 my_bool dir_per_db = FALSE;
74 char* version = (char*) TOKUDB_VERSION_STR;
75
76 // file system reserve as a percentage of total disk space
77 #if defined(TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL) && \
78 TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL
79 char* gdb_path = NULL;
80 my_bool gdb_on_fatal = FALSE;
81 #endif // defined(TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL) &&
82 // TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL
83
84 my_bool check_jemalloc = TRUE;
85
86 static MYSQL_SYSVAR_ULONGLONG(
87 cache_size,
88 cache_size,
89 PLUGIN_VAR_READONLY,
90 "cache table size",
91 NULL,
92 NULL,
93 0,
94 0,
95 ~0ULL,
96 0);
97
98 static MYSQL_SYSVAR_UINT(
99 cachetable_pool_threads,
100 cachetable_pool_threads,
101 PLUGIN_VAR_READONLY,
102 "cachetable ops thread pool size",
103 NULL,
104 NULL,
105 0,
106 0,
107 1024,
108 0);
109
110 static MYSQL_SYSVAR_INT(
111 cardinality_scale_percent,
112 cardinality_scale_percent,
113 0,
114 "index cardinality scale percentage",
115 NULL,
116 NULL,
117 50,
118 0,
119 100,
120 0);
121
122 static MYSQL_SYSVAR_BOOL(
123 checkpoint_on_flush_logs,
124 checkpoint_on_flush_logs,
125 0,
126 "checkpoint on flush logs",
127 NULL,
128 NULL,
129 FALSE);
130
131 static MYSQL_SYSVAR_UINT(
132 checkpoint_pool_threads,
133 checkpoint_pool_threads,
134 PLUGIN_VAR_READONLY,
135 "checkpoint ops thread pool size",
136 NULL,
137 NULL,
138 0,
139 0,
140 1024,
141 0);
142
checkpointing_period_update(TOKUDB_UNUSED (THD * thd),TOKUDB_UNUSED (st_mysql_sys_var * sys_var),void * var,const void * save)143 static void checkpointing_period_update(
144 TOKUDB_UNUSED(THD* thd),
145 TOKUDB_UNUSED(st_mysql_sys_var* sys_var),
146 void* var,
147 const void* save) {
148 uint* cp = (uint*)var;
149 *cp = *(const uint*)save;
150 int r = db_env->checkpointing_set_period(db_env, *cp);
151 assert(r == 0);
152 }
153
154 static MYSQL_SYSVAR_UINT(
155 checkpointing_period,
156 checkpointing_period,
157 0,
158 "checkpointing period",
159 NULL,
160 checkpointing_period_update,
161 60,
162 0,
163 ~0U,
164 0);
165
cleaner_iterations_update(TOKUDB_UNUSED (THD * thd),TOKUDB_UNUSED (st_mysql_sys_var * sys_var),void * var,const void * save)166 static void cleaner_iterations_update(TOKUDB_UNUSED(THD* thd),
167 TOKUDB_UNUSED(st_mysql_sys_var* sys_var),
168 void* var,
169 const void* save) {
170 ulong* ci = (ulong*)var;
171 *ci = *(const ulong*)save;
172 int r = db_env->cleaner_set_iterations(db_env, *ci);
173 assert(r == 0);
174 }
175
176 static MYSQL_SYSVAR_ULONG(
177 cleaner_iterations,
178 cleaner_iterations,
179 0,
180 "cleaner_iterations",
181 NULL,
182 cleaner_iterations_update,
183 DEFAULT_TOKUDB_CLEANER_ITERATIONS,
184 0,
185 ~0UL,
186 0);
187
cleaner_period_update(TOKUDB_UNUSED (THD * thd),TOKUDB_UNUSED (st_mysql_sys_var * sys_var),void * var,const void * save)188 static void cleaner_period_update(TOKUDB_UNUSED(THD* thd),
189 TOKUDB_UNUSED(st_mysql_sys_var* sys_var),
190 void* var,
191 const void* save) {
192 ulong* cp = (ulong*)var;
193 *cp = *(const ulong*)save;
194 int r = db_env->cleaner_set_period(db_env, *cp);
195 assert(r == 0);
196 }
197
198 static MYSQL_SYSVAR_ULONG(
199 cleaner_period,
200 cleaner_period,
201 0,
202 "cleaner_period",
203 NULL,
204 cleaner_period_update,
205 DEFAULT_TOKUDB_CLEANER_PERIOD,
206 0,
207 ~0UL,
208 0);
209
210 static MYSQL_SYSVAR_UINT(
211 client_pool_threads,
212 client_pool_threads,
213 PLUGIN_VAR_READONLY,
214 "client ops thread pool size",
215 NULL,
216 NULL,
217 0,
218 0,
219 1024,
220 0);
221
222 static MYSQL_SYSVAR_BOOL(
223 compress_buffers_before_eviction,
224 compress_buffers_before_eviction,
225 PLUGIN_VAR_READONLY,
226 "enable in-memory buffer compression before partial eviction",
227 NULL,
228 NULL,
229 TRUE);
230
231 static MYSQL_SYSVAR_STR(
232 data_dir,
233 data_dir,
234 PLUGIN_VAR_READONLY,
235 "data directory",
236 NULL,
237 NULL,
238 NULL);
239
240 static MYSQL_SYSVAR_ULONG(
241 debug,
242 debug,
243 0,
244 "plugin debug mask",
245 NULL,
246 NULL,
247 0,
248 0,
249 ~0UL,
250 0);
251
252 #if defined(TOKUDB_DEBUG) && TOKUDB_DEBUG
253 static MYSQL_SYSVAR_BOOL(
254 debug_pause_background_job_manager,
255 debug_pause_background_job_manager,
256 0,
257 "debug : pause the background job manager",
258 NULL,
259 NULL,
260 FALSE);
261 #endif // defined(TOKUDB_DEBUG) && TOKUDB_DEBUG
262
263 static MYSQL_SYSVAR_BOOL(
264 directio,
265 directio,
266 PLUGIN_VAR_READONLY, "enable direct i/o ",
267 NULL,
268 NULL,
269 FALSE);
270
enable_partial_eviction_update(TOKUDB_UNUSED (THD * thd),TOKUDB_UNUSED (st_mysql_sys_var * sys_var),void * var,const void * save)271 static void enable_partial_eviction_update(
272 TOKUDB_UNUSED(THD* thd),
273 TOKUDB_UNUSED(st_mysql_sys_var* sys_var),
274 void* var,
275 const void* save) {
276 my_bool* epe = (my_bool*)var;
277 *epe = *(const my_bool*)save;
278 int r = db_env->evictor_set_enable_partial_eviction(db_env, *epe);
279 assert(r == 0);
280 }
281
282 static MYSQL_SYSVAR_BOOL(
283 enable_partial_eviction,
284 enable_partial_eviction,
285 0,
286 "enable partial node eviction",
287 NULL,
288 enable_partial_eviction_update,
289 TRUE);
290
291 static MYSQL_SYSVAR_INT(
292 fs_reserve_percent,
293 fs_reserve_percent,
294 PLUGIN_VAR_READONLY,
295 "file system space reserve (percent free required)",
296 NULL,
297 NULL,
298 5,
299 0,
300 100,
301 0);
302
fsync_log_period_update(TOKUDB_UNUSED (THD * thd),TOKUDB_UNUSED (st_mysql_sys_var * sys_var),void * var,const void * save)303 static void fsync_log_period_update(TOKUDB_UNUSED(THD* thd),
304 TOKUDB_UNUSED(st_mysql_sys_var* sys_var),
305 void* var,
306 const void* save) {
307 uint* flp = (uint*)var;
308 *flp = *(const uint*)save;
309 db_env->change_fsync_log_period(db_env, *flp);
310 }
311
312 static MYSQL_SYSVAR_UINT(
313 fsync_log_period,
314 fsync_log_period,
315 0,
316 "fsync log period",
317 NULL,
318 fsync_log_period_update,
319 0,
320 0,
321 ~0U,
322 0);
323
324 static MYSQL_SYSVAR_STR(
325 log_dir,
326 log_dir,
327 PLUGIN_VAR_READONLY,
328 "log directory",
329 NULL,
330 NULL,
331 NULL);
332
333 static MYSQL_SYSVAR_ULONGLONG(
334 max_lock_memory,
335 max_lock_memory,
336 PLUGIN_VAR_READONLY,
337 "max memory for locks",
338 NULL,
339 NULL,
340 0,
341 0,
342 ~0ULL,
343 0);
344
345 static MYSQL_SYSVAR_UINT(
346 read_status_frequency,
347 read_status_frequency,
348 0,
349 "frequency that show processlist updates status of reads",
350 NULL,
351 NULL,
352 10000,
353 0,
354 ~0U,
355 0);
356
357 static MYSQL_SYSVAR_BOOL(
358 strip_frm_data,
359 strip_frm_data,
360 PLUGIN_VAR_READONLY,
361 "strip .frm data from metadata file(s)",
362 NULL,
363 NULL,
364 FALSE);
365
366 static MYSQL_SYSVAR_STR(
367 tmp_dir,
368 tmp_dir,
369 PLUGIN_VAR_READONLY,
370 "directory to use for temporary files",
371 NULL,
372 NULL,
373 NULL);
374
375 static MYSQL_SYSVAR_STR(
376 version,
377 version,
378 PLUGIN_VAR_READONLY,
379 "plugin version",
380 NULL,
381 NULL,
382 NULL);
383
384 static MYSQL_SYSVAR_UINT(
385 write_status_frequency,
386 write_status_frequency,
387 0,
388 "frequency that show processlist updates status of writes",
389 NULL,
390 NULL,
391 1000,
392 0,
393 ~0U,
394 0);
395
tokudb_dir_per_db_update(TOKUDB_UNUSED (THD * thd),TOKUDB_UNUSED (struct st_mysql_sys_var * sys_var),void * var,const void * save)396 static void tokudb_dir_per_db_update(
397 TOKUDB_UNUSED(THD* thd),
398 TOKUDB_UNUSED(struct st_mysql_sys_var* sys_var),
399 void* var,
400 const void* save) {
401 my_bool *value = (my_bool *) var;
402 *value = *(const my_bool *) save;
403 db_env->set_dir_per_db(db_env, *value);
404 }
405
406 static MYSQL_SYSVAR_BOOL(dir_per_db, dir_per_db,
407 0, "TokuDB store ft files in db directories",
408 NULL, tokudb_dir_per_db_update, FALSE);
409
410 #if defined(TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL) && \
411 TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL
412 static MYSQL_SYSVAR_STR(
413 gdb_path,
414 gdb_path,
415 PLUGIN_VAR_READONLY|PLUGIN_VAR_RQCMDARG,
416 "path to gdb for extra debug info on fatal signal",
417 NULL,
418 NULL,
419 "/usr/bin/gdb");
420
421 static MYSQL_SYSVAR_BOOL(
422 gdb_on_fatal,
423 gdb_on_fatal,
424 0,
425 "enable gdb debug info on fatal signal",
426 NULL,
427 NULL,
428 true);
429 #endif // defined(TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL) &&
430 // TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL
431
432 static MYSQL_SYSVAR_BOOL(
433 check_jemalloc,
434 check_jemalloc,
435 PLUGIN_VAR_READONLY|PLUGIN_VAR_RQCMDARG,
436 "check if jemalloc is linked and transparent huge pages are disabled",
437 NULL,
438 NULL,
439 TRUE);
440
441
442 //******************************************************************************
443 // session variables
444 //******************************************************************************
445 static MYSQL_THDVAR_BOOL(
446 alter_print_error,
447 0,
448 "print errors for alter table operations",
449 NULL,
450 NULL,
451 false);
452
453 static MYSQL_THDVAR_DOUBLE(
454 analyze_delete_fraction,
455 0,
456 "fraction of rows allowed to be deleted",
457 NULL,
458 NULL,
459 1.0,
460 0,
461 1.0,
462 1);
463
464 static MYSQL_THDVAR_BOOL(
465 analyze_in_background,
466 0,
467 "dispatch ANALYZE TABLE to background job.",
468 NULL,
469 NULL,
470 false);
471
472 const char* srv_analyze_mode_names[] = {
473 "TOKUDB_ANALYZE_STANDARD",
474 "TOKUDB_ANALYZE_RECOUNT_ROWS",
475 "TOKUDB_ANALYZE_CANCEL",
476 NullS
477 };
478
479 static TYPELIB tokudb_analyze_mode_typelib = {
480 array_elements(srv_analyze_mode_names) - 1,
481 "tokudb_analyze_mode_typelib",
482 srv_analyze_mode_names,
483 NULL
484 };
485
486 static MYSQL_THDVAR_ENUM(analyze_mode,
487 PLUGIN_VAR_RQCMDARG,
488 "Controls the function of ANALYZE TABLE. Possible values are: "
489 "TOKUDB_ANALYZE_STANDARD perform standard table analysis (default); "
490 "TOKUDB_ANALYZE_RECOUNT_ROWS perform logical recount of table rows;"
491 "TOKUDB_ANALYZE_CANCEL terminate and cancel all scheduled background jobs "
492 "for a table",
493 NULL,
494 NULL,
495 TOKUDB_ANALYZE_STANDARD,
496 &tokudb_analyze_mode_typelib);
497
498 static MYSQL_THDVAR_ULONGLONG(
499 analyze_throttle,
500 0,
501 "analyze throttle (keys)",
502 NULL,
503 NULL,
504 0,
505 0,
506 ~0U,
507 1);
508
509 static MYSQL_THDVAR_UINT(
510 analyze_time,
511 0,
512 "analyze time (seconds)",
513 NULL,
514 NULL,
515 5,
516 0,
517 ~0U,
518 1);
519
520 static MYSQL_THDVAR_ULONGLONG(
521 auto_analyze,
522 0,
523 "auto analyze threshold (percent)",
524 NULL,
525 NULL,
526 0,
527 0,
528 ~0U,
529 1);
530
531 static MYSQL_THDVAR_UINT(
532 block_size,
533 0,
534 "fractal tree block size",
535 NULL,
536 NULL,
537 4<<20,
538 4096,
539 ~0U,
540 1);
541
542 static MYSQL_THDVAR_BOOL(
543 bulk_fetch,
544 PLUGIN_VAR_THDLOCAL,
545 "enable bulk fetch",
546 NULL,
547 NULL,
548 true);
549
checkpoint_lock_update(TOKUDB_UNUSED (THD * thd),TOKUDB_UNUSED (st_mysql_sys_var * var),void * var_ptr,const void * save)550 static void checkpoint_lock_update(TOKUDB_UNUSED(THD* thd),
551 TOKUDB_UNUSED(st_mysql_sys_var* var),
552 void* var_ptr,
553 const void* save) {
554 my_bool* val = (my_bool*)var_ptr;
555 *val= *(my_bool*)save ? true : false;
556 if (*val) {
557 tokudb_checkpoint_lock(thd);
558 } else {
559 tokudb_checkpoint_unlock(thd);
560 }
561 }
562
563 static MYSQL_THDVAR_BOOL(
564 checkpoint_lock,
565 0,
566 "checkpoint lock",
567 NULL,
568 checkpoint_lock_update,
569 false);
570
571 static MYSQL_THDVAR_BOOL(
572 commit_sync,
573 PLUGIN_VAR_THDLOCAL,
574 "sync on txn commit",
575 NULL,
576 NULL,
577 true);
578
579 static MYSQL_THDVAR_BOOL(
580 create_index_online,
581 0,
582 "if on, create index done online",
583 NULL,
584 NULL,
585 true);
586
587 static MYSQL_THDVAR_BOOL(
588 disable_hot_alter,
589 0,
590 "if on, hot alter table is disabled",
591 NULL,
592 NULL,
593 false);
594
595 static MYSQL_THDVAR_BOOL(
596 disable_prefetching,
597 0,
598 "if on, prefetching disabled",
599 NULL,
600 NULL,
601 false);
602
603 static MYSQL_THDVAR_BOOL(
604 disable_slow_alter,
605 0,
606 "if on, alter tables that require copy are disabled",
607 NULL,
608 NULL,
609 false);
610
611 static const char *tokudb_empty_scan_names[] = {
612 "disabled",
613 "lr",
614 "rl",
615 NullS
616 };
617
618 static TYPELIB tokudb_empty_scan_typelib = {
619 array_elements(tokudb_empty_scan_names) - 1,
620 "tokudb_empty_scan_typelib",
621 tokudb_empty_scan_names,
622 NULL
623 };
624
625 static MYSQL_THDVAR_ENUM(
626 empty_scan,
627 PLUGIN_VAR_OPCMDARG,
628 "algorithm to check if the table is empty when opened",
629 NULL,
630 NULL,
631 TOKUDB_EMPTY_SCAN_RL,
632 &tokudb_empty_scan_typelib);
633
634 static MYSQL_THDVAR_UINT(
635 fanout,
636 0,
637 "fractal tree fanout",
638 NULL,
639 NULL,
640 16,
641 2,
642 16*1024,
643 1);
644
645 static MYSQL_THDVAR_BOOL(
646 hide_default_row_format,
647 0,
648 "hide the default row format",
649 NULL,
650 NULL,
651 true);
652
653 static MYSQL_THDVAR_ULONGLONG(
654 killed_time,
655 0,
656 "killed time",
657 NULL,
658 NULL,
659 DEFAULT_TOKUDB_KILLED_TIME,
660 0,
661 ~0ULL,
662 1);
663
664 static MYSQL_THDVAR_STR(last_lock_timeout,
665 PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_NOCMDOPT |
666 PLUGIN_VAR_READONLY,
667 "last lock timeout",
668 NULL,
669 NULL,
670 NULL);
671
672 static MYSQL_THDVAR_BOOL(
673 load_save_space,
674 0,
675 "compress intermediate bulk loader files to save space",
676 NULL,
677 NULL,
678 true);
679
680 static MYSQL_THDVAR_ULONGLONG(
681 loader_memory_size,
682 0,
683 "loader memory size",
684 NULL,
685 NULL,
686 100*1000*1000,
687 0,
688 ~0ULL,
689 1);
690
691 static MYSQL_THDVAR_ULONGLONG(
692 lock_timeout,
693 0,
694 "lock timeout",
695 NULL,
696 NULL,
697 DEFAULT_TOKUDB_LOCK_TIMEOUT,
698 0,
699 ~0ULL,
700 1);
701
702 static MYSQL_THDVAR_UINT(
703 lock_timeout_debug,
704 0,
705 "lock timeout debug",
706 NULL,
707 NULL,
708 1,
709 0,
710 ~0U,
711 1);
712
713 static MYSQL_THDVAR_DOUBLE(
714 optimize_index_fraction,
715 0,
716 "optimize index fraction (default 1.0 all)",
717 NULL,
718 NULL,
719 1.0,
720 0,
721 1.0,
722 1);
723
724 static MYSQL_THDVAR_STR(
725 optimize_index_name,
726 PLUGIN_VAR_THDLOCAL + PLUGIN_VAR_MEMALLOC,
727 "optimize index name (default all indexes)",
728 NULL,
729 NULL,
730 NULL);
731
732 static MYSQL_THDVAR_ULONGLONG(
733 optimize_throttle,
734 0,
735 "optimize throttle (default no throttle)",
736 NULL,
737 NULL,
738 0,
739 0,
740 ~0ULL,
741 1);
742
743 static const char* deprecated_tokudb_pk_insert_mode =
744 "Using tokudb_pk_insert_mode is deprecated and the "
745 "parameter may be removed in future releases.";
746 static const char* deprecated_tokudb_pk_insert_mode_zero =
747 "Using tokudb_pk_insert_mode=0 is deprecated and the "
748 "parameter may be removed in future releases. "
749 "Only tokudb_pk_insert_mode=1|2 is allowed."
750 "Resettig the value to 1.";
751
pk_insert_mode_update(THD * thd,st_mysql_sys_var * var,void * var_ptr,const void * save)752 static void pk_insert_mode_update(
753 THD* thd,
754 st_mysql_sys_var* var,
755 void* var_ptr,
756 const void* save) {
757 const uint* new_pk_insert_mode = static_cast<const uint*>(save);
758 uint* pk_insert_mode = static_cast<uint*>(var_ptr);
759 if (*new_pk_insert_mode == 0) {
760 push_warning(
761 thd,
762 Sql_condition::WARN_LEVEL_WARN,
763 HA_ERR_WRONG_COMMAND,
764 deprecated_tokudb_pk_insert_mode_zero);
765 *pk_insert_mode = 1;
766 } else {
767 push_warning(
768 thd,
769 Sql_condition::WARN_LEVEL_WARN,
770 HA_ERR_WRONG_COMMAND,
771 deprecated_tokudb_pk_insert_mode);
772 *pk_insert_mode = *new_pk_insert_mode;
773 }
774 }
775
776 static MYSQL_THDVAR_UINT(
777 pk_insert_mode,
778 0,
779 "set the primary key insert mode",
780 NULL,
781 pk_insert_mode_update,
782 1,
783 0,
784 2,
785 1);
786
787 static MYSQL_THDVAR_BOOL(
788 prelock_empty,
789 0,
790 "prelock empty table",
791 NULL,
792 NULL,
793 true);
794
795 static MYSQL_THDVAR_UINT(
796 read_block_size,
797 0,
798 "fractal tree read block size",
799 NULL,
800 NULL,
801 64*1024,
802 4096,
803 ~0U,
804 1);
805
806 static MYSQL_THDVAR_UINT(
807 read_buf_size,
808 0,
809 "range query read buffer size",
810 NULL,
811 NULL,
812 128*1024,
813 0,
814 1*1024*1024,
815 1);
816
817 static const char *tokudb_row_format_names[] = {
818 "tokudb_uncompressed",
819 "tokudb_zlib",
820 "tokudb_snappy",
821 "tokudb_quicklz",
822 "tokudb_lzma",
823 "tokudb_fast",
824 "tokudb_small",
825 "tokudb_default",
826 NullS
827 };
828
829 static TYPELIB tokudb_row_format_typelib = {
830 array_elements(tokudb_row_format_names) - 1,
831 "tokudb_row_format_typelib",
832 tokudb_row_format_names,
833 NULL
834 };
835
836 static MYSQL_THDVAR_ENUM(
837 row_format,
838 PLUGIN_VAR_OPCMDARG,
839 "Specifies the compression method for a table created during this session. "
840 "Possible values are TOKUDB_UNCOMPRESSED, TOKUDB_ZLIB, TOKUDB_SNAPPY, "
841 "TOKUDB_QUICKLZ, TOKUDB_LZMA, TOKUDB_FAST, TOKUDB_SMALL and TOKUDB_DEFAULT",
842 NULL,
843 NULL,
844 SRV_ROW_FORMAT_ZLIB,
845 &tokudb_row_format_typelib);
846
847 #if defined(TOKU_INCLUDE_RFR) && TOKU_INCLUDE_RFR
848 static MYSQL_THDVAR_BOOL(
849 rpl_check_readonly,
850 PLUGIN_VAR_THDLOCAL,
851 "check if the slave is read only",
852 NULL,
853 NULL,
854 true);
855
856 static MYSQL_THDVAR_BOOL(
857 rpl_lookup_rows,
858 PLUGIN_VAR_THDLOCAL,
859 "lookup a row on rpl slave",
860 NULL,
861 NULL,
862 true);
863
864 static MYSQL_THDVAR_ULONGLONG(
865 rpl_lookup_rows_delay,
866 PLUGIN_VAR_THDLOCAL,
867 "time in milliseconds to add to lookups on replication slave",
868 NULL,
869 NULL,
870 0,
871 0,
872 ~0ULL,
873 1);
874
875 static MYSQL_THDVAR_BOOL(
876 rpl_unique_checks,
877 PLUGIN_VAR_THDLOCAL,
878 "enable unique checks on replication slave",
879 NULL,
880 NULL,
881 true);
882
883 static MYSQL_THDVAR_ULONGLONG(
884 rpl_unique_checks_delay,
885 PLUGIN_VAR_THDLOCAL,
886 "time in milliseconds to add to unique checks test on replication slave",
887 NULL,
888 NULL,
889 0,
890 0,
891 ~0ULL,
892 1);
893 #endif // defined(TOKU_INCLUDE_RFR) && TOKU_INCLUDE_RFR
894
895 #if defined(TOKU_INCLUDE_UPSERT)
896 static MYSQL_THDVAR_BOOL(
897 enable_fast_update,
898 PLUGIN_VAR_THDLOCAL,
899 "disable slow update",
900 NULL,
901 NULL,
902 false);
903
904 static MYSQL_THDVAR_BOOL(
905 enable_fast_upsert,
906 PLUGIN_VAR_THDLOCAL,
907 "disable slow upsert",
908 NULL,
909 NULL,
910 false);
911 #endif
912
913 #if TOKU_INCLUDE_XA
914 static MYSQL_THDVAR_BOOL(
915 support_xa,
916 PLUGIN_VAR_OPCMDARG,
917 "Enable TokuDB support for the XA two-phase commit",
918 NULL,
919 NULL,
920 true);
921 #endif
922
923 //******************************************************************************
924 // all system variables
925 //******************************************************************************
926 st_mysql_sys_var* system_variables[] = {
927 // global vars
928 MYSQL_SYSVAR(cache_size),
929 MYSQL_SYSVAR(checkpoint_on_flush_logs),
930 MYSQL_SYSVAR(cachetable_pool_threads),
931 MYSQL_SYSVAR(cardinality_scale_percent),
932 MYSQL_SYSVAR(checkpoint_pool_threads),
933 MYSQL_SYSVAR(checkpointing_period),
934 MYSQL_SYSVAR(cleaner_iterations),
935 MYSQL_SYSVAR(cleaner_period),
936 MYSQL_SYSVAR(client_pool_threads),
937 MYSQL_SYSVAR(compress_buffers_before_eviction),
938 MYSQL_SYSVAR(data_dir),
939 MYSQL_SYSVAR(debug),
940 MYSQL_SYSVAR(directio),
941 MYSQL_SYSVAR(enable_partial_eviction),
942 MYSQL_SYSVAR(fs_reserve_percent),
943 MYSQL_SYSVAR(fsync_log_period),
944 MYSQL_SYSVAR(log_dir),
945 MYSQL_SYSVAR(max_lock_memory),
946 MYSQL_SYSVAR(read_status_frequency),
947 MYSQL_SYSVAR(strip_frm_data),
948 MYSQL_SYSVAR(tmp_dir),
949 MYSQL_SYSVAR(version),
950 MYSQL_SYSVAR(write_status_frequency),
951 MYSQL_SYSVAR(dir_per_db),
952 #if defined(TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL) && \
953 TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL
954 MYSQL_SYSVAR(gdb_path),
955 MYSQL_SYSVAR(gdb_on_fatal),
956 #endif // defined(TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL) &&
957 // TOKU_INCLUDE_HANDLERTON_HANDLE_FATAL_SIGNAL
958
959 MYSQL_SYSVAR(check_jemalloc),
960
961 // session vars
962 MYSQL_SYSVAR(alter_print_error),
963 MYSQL_SYSVAR(analyze_delete_fraction),
964 MYSQL_SYSVAR(analyze_in_background),
965 MYSQL_SYSVAR(analyze_mode),
966 MYSQL_SYSVAR(analyze_throttle),
967 MYSQL_SYSVAR(analyze_time),
968 MYSQL_SYSVAR(auto_analyze),
969 MYSQL_SYSVAR(block_size),
970 MYSQL_SYSVAR(bulk_fetch),
971 MYSQL_SYSVAR(checkpoint_lock),
972 MYSQL_SYSVAR(commit_sync),
973 MYSQL_SYSVAR(create_index_online),
974 MYSQL_SYSVAR(disable_hot_alter),
975 MYSQL_SYSVAR(disable_prefetching),
976 MYSQL_SYSVAR(disable_slow_alter),
977 MYSQL_SYSVAR(empty_scan),
978 MYSQL_SYSVAR(fanout),
979 MYSQL_SYSVAR(hide_default_row_format),
980 MYSQL_SYSVAR(killed_time),
981 MYSQL_SYSVAR(last_lock_timeout),
982 MYSQL_SYSVAR(load_save_space),
983 MYSQL_SYSVAR(loader_memory_size),
984 MYSQL_SYSVAR(lock_timeout),
985 MYSQL_SYSVAR(lock_timeout_debug),
986 MYSQL_SYSVAR(optimize_index_fraction),
987 MYSQL_SYSVAR(optimize_index_name),
988 MYSQL_SYSVAR(optimize_throttle),
989 MYSQL_SYSVAR(pk_insert_mode),
990 MYSQL_SYSVAR(prelock_empty),
991 MYSQL_SYSVAR(read_block_size),
992 MYSQL_SYSVAR(read_buf_size),
993 MYSQL_SYSVAR(row_format),
994 #if defined(TOKU_INCLUDE_RFR) && TOKU_INCLUDE_RFR
995 MYSQL_SYSVAR(rpl_check_readonly),
996 MYSQL_SYSVAR(rpl_lookup_rows),
997 MYSQL_SYSVAR(rpl_lookup_rows_delay),
998 MYSQL_SYSVAR(rpl_unique_checks),
999 MYSQL_SYSVAR(rpl_unique_checks_delay),
1000 #endif // defined(TOKU_INCLUDE_RFR) && TOKU_INCLUDE_RFR
1001 #if defined(TOKU_INCLUDE_UPSERT)
1002 MYSQL_SYSVAR(enable_fast_update),
1003 MYSQL_SYSVAR(enable_fast_upsert),
1004 #endif
1005 #if TOKU_INCLUDE_XA
1006 MYSQL_SYSVAR(support_xa),
1007 #endif
1008
1009 #if defined(TOKUDB_DEBUG) && TOKUDB_DEBUG
1010 MYSQL_SYSVAR(debug_pause_background_job_manager),
1011 #endif // TOKUDB_DEBUG
1012
1013 NULL
1014 };
1015
alter_print_error(THD * thd)1016 my_bool alter_print_error(THD* thd) {
1017 return (THDVAR(thd, alter_print_error) != 0);
1018 }
analyze_delete_fraction(THD * thd)1019 double analyze_delete_fraction(THD* thd) {
1020 return THDVAR(thd, analyze_delete_fraction);
1021 }
analyze_in_background(THD * thd)1022 my_bool analyze_in_background(THD* thd) {
1023 return (THDVAR(thd, analyze_in_background) != 0);
1024 }
analyze_mode(THD * thd)1025 analyze_mode_t analyze_mode(THD* thd) {
1026 return (analyze_mode_t ) THDVAR(thd, analyze_mode);
1027 }
analyze_throttle(THD * thd)1028 ulonglong analyze_throttle(THD* thd) {
1029 return THDVAR(thd, analyze_throttle);
1030 }
analyze_time(THD * thd)1031 ulonglong analyze_time(THD* thd) {
1032 return THDVAR(thd, analyze_time);
1033 }
auto_analyze(THD * thd)1034 ulonglong auto_analyze(THD* thd) {
1035 return THDVAR(thd, auto_analyze);
1036 }
bulk_fetch(THD * thd)1037 my_bool bulk_fetch(THD* thd) {
1038 return (THDVAR(thd, bulk_fetch) != 0);
1039 }
block_size(THD * thd)1040 uint block_size(THD* thd) {
1041 return THDVAR(thd, block_size);
1042 }
commit_sync(THD * thd)1043 my_bool commit_sync(THD* thd) {
1044 return (THDVAR(thd, commit_sync) != 0);
1045 }
create_index_online(THD * thd)1046 my_bool create_index_online(THD* thd) {
1047 return (THDVAR(thd, create_index_online) != 0);
1048 }
disable_hot_alter(THD * thd)1049 my_bool disable_hot_alter(THD* thd) {
1050 return (THDVAR(thd, disable_hot_alter) != 0);
1051 }
disable_prefetching(THD * thd)1052 my_bool disable_prefetching(THD* thd) {
1053 return (THDVAR(thd, disable_prefetching) != 0);
1054 }
disable_slow_alter(THD * thd)1055 my_bool disable_slow_alter(THD* thd) {
1056 return (THDVAR(thd, disable_slow_alter) != 0);
1057 }
1058 #if defined(TOKU_INCLUDE_UPSERT) && TOKU_INCLUDE_UPSERT
enable_fast_update(THD * thd)1059 my_bool enable_fast_update(THD* thd) {
1060 return (THDVAR(thd, enable_fast_update) != 0);
1061 }
enable_fast_upsert(THD * thd)1062 my_bool enable_fast_upsert(THD* thd) {
1063 return (THDVAR(thd, enable_fast_upsert) != 0);
1064 }
1065 #endif // defined(TOKU_INCLUDE_UPSERT) && TOKU_INCLUDE_UPSERT
empty_scan(THD * thd)1066 empty_scan_mode_t empty_scan(THD* thd) {
1067 return (empty_scan_mode_t)THDVAR(thd, empty_scan);
1068 }
fanout(THD * thd)1069 uint fanout(THD* thd) {
1070 return THDVAR(thd, fanout);
1071 }
hide_default_row_format(THD * thd)1072 my_bool hide_default_row_format(THD* thd) {
1073 return (THDVAR(thd, hide_default_row_format) != 0);
1074 }
killed_time(THD * thd)1075 ulonglong killed_time(THD* thd) {
1076 return THDVAR(thd, killed_time);
1077 }
last_lock_timeout(THD * thd)1078 char* last_lock_timeout(THD* thd) {
1079 return THDVAR(thd, last_lock_timeout);
1080 }
set_last_lock_timeout(THD * thd,char * last)1081 void set_last_lock_timeout(THD* thd, char* last) {
1082 THDVAR(thd, last_lock_timeout) = last;
1083 }
load_save_space(THD * thd)1084 my_bool load_save_space(THD* thd) {
1085 return (THDVAR(thd, load_save_space) != 0);
1086 }
loader_memory_size(THD * thd)1087 ulonglong loader_memory_size(THD* thd) {
1088 return THDVAR(thd, loader_memory_size);
1089 }
lock_timeout(THD * thd)1090 ulonglong lock_timeout(THD* thd) {
1091 return THDVAR(thd, lock_timeout);
1092 }
lock_timeout_debug(THD * thd)1093 uint lock_timeout_debug(THD* thd) {
1094 return THDVAR(thd, lock_timeout_debug);
1095 }
optimize_index_fraction(THD * thd)1096 double optimize_index_fraction(THD* thd) {
1097 return THDVAR(thd, optimize_index_fraction);
1098 }
optimize_index_name(THD * thd)1099 const char* optimize_index_name(THD* thd) {
1100 return THDVAR(thd, optimize_index_name);
1101 }
optimize_throttle(THD * thd)1102 ulonglong optimize_throttle(THD* thd) {
1103 return THDVAR(thd, optimize_throttle);
1104 }
pk_insert_mode(THD * thd)1105 uint pk_insert_mode(THD* thd) {
1106 return THDVAR(thd, pk_insert_mode);
1107 }
set_pk_insert_mode(THD * thd,uint mode)1108 void set_pk_insert_mode(THD* thd, uint mode) {
1109 THDVAR(thd, pk_insert_mode) = mode;
1110 }
prelock_empty(THD * thd)1111 my_bool prelock_empty(THD* thd) {
1112 return (THDVAR(thd, prelock_empty) != 0);
1113 }
read_block_size(THD * thd)1114 uint read_block_size(THD* thd) {
1115 return THDVAR(thd, read_block_size);
1116 }
read_buf_size(THD * thd)1117 uint read_buf_size(THD* thd) {
1118 return THDVAR(thd, read_buf_size);
1119 }
row_format(THD * thd)1120 row_format_t row_format(THD *thd) {
1121 return (row_format_t) THDVAR(thd, row_format);
1122 }
1123 #if defined(TOKU_INCLUDE_RFR) && TOKU_INCLUDE_RFR
rpl_check_readonly(THD * thd)1124 my_bool rpl_check_readonly(THD* thd) {
1125 return (THDVAR(thd, rpl_check_readonly) != 0);
1126 }
rpl_lookup_rows(THD * thd)1127 my_bool rpl_lookup_rows(THD* thd) {
1128 return (THDVAR(thd, rpl_lookup_rows) != 0);
1129 }
rpl_lookup_rows_delay(THD * thd)1130 ulonglong rpl_lookup_rows_delay(THD* thd) {
1131 return THDVAR(thd, rpl_lookup_rows_delay);
1132 }
rpl_unique_checks(THD * thd)1133 my_bool rpl_unique_checks(THD* thd) {
1134 return (THDVAR(thd, rpl_unique_checks) != 0);
1135 }
rpl_unique_checks_delay(THD * thd)1136 ulonglong rpl_unique_checks_delay(THD* thd) {
1137 return THDVAR(thd, rpl_unique_checks_delay);
1138 }
1139 #endif // defined(TOKU_INCLUDE_RFR) && TOKU_INCLUDE_RFR
support_xa(THD * thd)1140 my_bool support_xa(THD* thd) {
1141 return (THDVAR(thd, support_xa) != 0);
1142 }
1143
1144 #if defined(TOKU_INCLUDE_OPTION_STRUCTS) && TOKU_INCLUDE_OPTION_STRUCTS
1145 ha_create_table_option tokudb_table_options[] = {
1146 HA_TOPTION_SYSVAR("compression", row_format, row_format),
1147 HA_TOPTION_END
1148 };
1149
1150 ha_create_table_option tokudb_index_options[] = {
1151 HA_IOPTION_BOOL("clustering", clustering, 0),
1152 HA_IOPTION_END
1153 };
1154 #endif // defined(TOKU_INCLUDE_OPTION_STRUCTS) && TOKU_INCLUDE_OPTION_STRUCTS
1155
1156 } // namespace sysvars
1157 } // namespace tokudb
1158