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