1/* Copyright (C) 2008-2017 Kentoku Shiba
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
6
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
15
16#define MYSQL_SERVER 1
17#include <my_global.h>
18#include "mysql_version.h"
19#include "spd_environ.h"
20#if MYSQL_VERSION_ID < 50500
21#include "mysql_priv.h"
22#include <mysql/plugin.h>
23#else
24#include "sql_priv.h"
25#include "probes_mysql.h"
26#include "sql_class.h"
27#include "sql_partition.h"
28#endif
29#include <my_getopt.h>
30#include "spd_err.h"
31#include "spd_db_include.h"
32#include "spd_include.h"
33#include "ha_spider.h"
34#include "spd_table.h"
35#include "spd_trx.h"
36
37extern struct st_mysql_plugin spider_i_s_alloc_mem;
38#ifdef MARIADB_BASE_VERSION
39extern struct st_maria_plugin spider_i_s_alloc_mem_maria;
40#endif
41
42extern volatile ulonglong spider_mon_table_cache_version;
43extern volatile ulonglong spider_mon_table_cache_version_req;
44
45#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
46static int spider_direct_update(THD *thd, SHOW_VAR *var, char *buff)
47{
48 int error_num = 0;
49 SPIDER_TRX *trx;
50 DBUG_ENTER("spider_direct_update");
51 var->type = SHOW_LONGLONG;
52 if ((trx = spider_get_trx(thd, TRUE, &error_num)))
53 var->value = (char *) &trx->direct_update_count;
54 DBUG_RETURN(error_num);
55}
56
57static int spider_direct_delete(THD *thd, SHOW_VAR *var, char *buff)
58{
59 int error_num = 0;
60 SPIDER_TRX *trx;
61 DBUG_ENTER("spider_direct_delete");
62 var->type = SHOW_LONGLONG;
63 if ((trx = spider_get_trx(thd, TRUE, &error_num)))
64 var->value = (char *) &trx->direct_delete_count;
65 DBUG_RETURN(error_num);
66}
67#endif
68
69static int spider_direct_order_limit(THD *thd, SHOW_VAR *var, char *buff)
70{
71 int error_num = 0;
72 SPIDER_TRX *trx;
73 DBUG_ENTER("spider_direct_order_limit");
74 var->type = SHOW_LONGLONG;
75 if ((trx = spider_get_trx(thd, TRUE, &error_num)))
76 var->value = (char *) &trx->direct_order_limit_count;
77 DBUG_RETURN(error_num);
78}
79
80static int spider_direct_aggregate(THD *thd, SHOW_VAR *var, char *buff)
81{
82 int error_num = 0;
83 SPIDER_TRX *trx;
84 DBUG_ENTER("spider_direct_aggregate");
85 var->type = SHOW_LONGLONG;
86 if ((trx = spider_get_trx(thd, TRUE, &error_num)))
87 var->value = (char *) &trx->direct_aggregate_count;
88 DBUG_RETURN(error_num);
89}
90
91static int spider_parallel_search(THD *thd, SHOW_VAR *var, char *buff)
92{
93 int error_num = 0;
94 SPIDER_TRX *trx;
95 DBUG_ENTER("spider_parallel_search");
96 var->type = SHOW_LONGLONG;
97 if ((trx = spider_get_trx(thd, TRUE, &error_num)))
98 var->value = (char *) &trx->parallel_search_count;
99 DBUG_RETURN(error_num);
100}
101
102#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
103static int spider_hs_result_free(THD *thd, SHOW_VAR *var, char *buff)
104{
105 int error_num = 0;
106 SPIDER_TRX *trx;
107 DBUG_ENTER("spider_hs_result_free");
108 var->type = SHOW_LONGLONG;
109 if ((trx = spider_get_trx(thd, TRUE, &error_num)))
110 var->value = (char *) &trx->hs_result_free_count;
111 DBUG_RETURN(error_num);
112}
113#endif
114
115struct st_mysql_show_var spider_status_variables[] =
116{
117 {"Spider_mon_table_cache_version",
118 (char *) &spider_mon_table_cache_version, SHOW_LONGLONG},
119 {"Spider_mon_table_cache_version_req",
120 (char *) &spider_mon_table_cache_version_req, SHOW_LONGLONG},
121#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
122#ifdef SPIDER_HAS_SHOW_SIMPLE_FUNC
123 {"Spider_direct_update", (char *) &spider_direct_update, SHOW_SIMPLE_FUNC},
124 {"Spider_direct_delete", (char *) &spider_direct_delete, SHOW_SIMPLE_FUNC},
125#else
126 {"Spider_direct_update", (char *) &spider_direct_update, SHOW_FUNC},
127 {"Spider_direct_delete", (char *) &spider_direct_delete, SHOW_FUNC},
128#endif
129#endif
130#ifdef SPIDER_HAS_SHOW_SIMPLE_FUNC
131 {"Spider_direct_order_limit",
132 (char *) &spider_direct_order_limit, SHOW_SIMPLE_FUNC},
133 {"Spider_direct_aggregate",
134 (char *) &spider_direct_aggregate, SHOW_SIMPLE_FUNC},
135 {"Spider_parallel_search",
136 (char *) &spider_parallel_search, SHOW_SIMPLE_FUNC},
137#else
138 {"Spider_direct_order_limit",
139 (char *) &spider_direct_order_limit, SHOW_FUNC},
140 {"Spider_direct_aggregate",
141 (char *) &spider_direct_aggregate, SHOW_FUNC},
142 {"Spider_parallel_search",
143 (char *) &spider_parallel_search, SHOW_FUNC},
144#endif
145#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
146#ifdef SPIDER_HAS_SHOW_SIMPLE_FUNC
147 {"Spider_hs_result_free", (char *) &spider_hs_result_free, SHOW_SIMPLE_FUNC},
148#else
149 {"Spider_hs_result_free", (char *) &spider_hs_result_free, SHOW_FUNC},
150#endif
151#endif
152 {NullS, NullS, SHOW_LONG}
153};
154
155typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_int_t, int);
156#if MYSQL_VERSION_ID < 50500
157extern bool throw_bounds_warning(THD *thd, bool fixed, bool unsignd,
158 const char *name, long long val);
159#else
160extern bool throw_bounds_warning(THD *thd, const char *name, bool fixed,
161 bool is_unsignd, longlong v);
162#endif
163
164static my_bool spider_support_xa;
165static MYSQL_SYSVAR_BOOL(
166 support_xa,
167 spider_support_xa,
168 PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
169 "XA support",
170 NULL,
171 NULL,
172 TRUE
173);
174
175my_bool spider_param_support_xa()
176{
177 DBUG_ENTER("spider_param_support_xa");
178 DBUG_RETURN(spider_support_xa);
179}
180
181static my_bool spider_connect_mutex;
182static MYSQL_SYSVAR_BOOL(
183 connect_mutex,
184 spider_connect_mutex,
185 PLUGIN_VAR_OPCMDARG,
186 "Use mutex at connecting",
187 NULL,
188 NULL,
189 FALSE
190);
191
192my_bool spider_param_connect_mutex()
193{
194 DBUG_ENTER("spider_param_connect_mutex");
195 DBUG_RETURN(spider_connect_mutex);
196}
197
198static uint spider_connect_error_interval;
199/*
200 0-: interval
201 */
202static MYSQL_SYSVAR_UINT(
203 connect_error_interval,
204 spider_connect_error_interval,
205 PLUGIN_VAR_RQCMDARG,
206 "Return same error code until interval passes if connection is failed",
207 NULL,
208 NULL,
209 1,
210 0,
211 4294967295U,
212 0
213);
214
215uint spider_param_connect_error_interval()
216{
217 DBUG_ENTER("spider_param_connect_error_interval");
218 DBUG_RETURN(spider_connect_error_interval);
219}
220
221static uint spider_table_init_error_interval;
222/*
223 0-: interval
224 */
225static MYSQL_SYSVAR_UINT(
226 table_init_error_interval,
227 spider_table_init_error_interval,
228 PLUGIN_VAR_RQCMDARG,
229 "Return same error code until interval passes if table init is failed",
230 NULL,
231 NULL,
232 1,
233 0,
234 4294967295U,
235 0
236);
237
238uint spider_param_table_init_error_interval()
239{
240 DBUG_ENTER("spider_param_table_init_error_interval");
241 DBUG_RETURN(spider_table_init_error_interval);
242}
243
244static int spider_use_table_charset;
245/*
246 -1 :use table parameter
247 0 :use utf8
248 1 :use table charset
249 */
250static MYSQL_SYSVAR_INT(
251 use_table_charset,
252 spider_use_table_charset,
253 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
254 "Use table charset for remote access",
255 NULL,
256 NULL,
257 -1,
258 -1,
259 1,
260 0
261);
262
263int spider_param_use_table_charset(
264 int use_table_charset
265) {
266 DBUG_ENTER("spider_param_use_table_charset");
267 DBUG_RETURN(spider_use_table_charset == -1 ?
268 use_table_charset : spider_use_table_charset);
269}
270
271/*
272 0: no recycle
273 1: recycle in instance
274 2: recycle in thread
275 */
276static MYSQL_THDVAR_UINT(
277 conn_recycle_mode, /* name */
278 PLUGIN_VAR_RQCMDARG, /* opt */
279 "Connection recycle mode", /* comment */
280 NULL, /* check */
281 NULL, /* update */
282 0, /* def */
283 0, /* min */
284 2, /* max */
285 0 /* blk */
286);
287
288uint spider_param_conn_recycle_mode(
289 THD *thd
290) {
291 DBUG_ENTER("spider_param_conn_recycle_mode");
292 DBUG_RETURN(THDVAR(thd, conn_recycle_mode));
293}
294
295/*
296 0: weak
297 1: strict
298 */
299static MYSQL_THDVAR_UINT(
300 conn_recycle_strict, /* name */
301 PLUGIN_VAR_RQCMDARG, /* opt */
302 "Strict connection recycle", /* comment */
303 NULL, /* check */
304 NULL, /* update */
305 0, /* def */
306 0, /* min */
307 1, /* max */
308 0 /* blk */
309);
310
311uint spider_param_conn_recycle_strict(
312 THD *thd
313) {
314 DBUG_ENTER("spider_param_conn_recycle_strict");
315 DBUG_RETURN(THDVAR(thd, conn_recycle_strict));
316}
317
318/*
319 FALSE: no sync
320 TRUE: sync
321 */
322static MYSQL_THDVAR_BOOL(
323 sync_trx_isolation, /* name */
324 PLUGIN_VAR_OPCMDARG, /* opt */
325 "Sync transaction isolation level", /* comment */
326 NULL, /* check */
327 NULL, /* update */
328 TRUE /* def */
329);
330
331bool spider_param_sync_trx_isolation(
332 THD *thd
333) {
334 DBUG_ENTER("spider_param_sync_trx_isolation");
335 DBUG_RETURN(THDVAR(thd, sync_trx_isolation));
336}
337
338/*
339 FALSE: no use
340 TRUE: use
341 */
342static MYSQL_THDVAR_BOOL(
343 use_consistent_snapshot, /* name */
344 PLUGIN_VAR_OPCMDARG, /* opt */
345 "Use start transaction with consistent snapshot", /* comment */
346 NULL, /* check */
347 NULL, /* update */
348 FALSE /* def */
349);
350
351bool spider_param_use_consistent_snapshot(
352 THD *thd
353) {
354 DBUG_ENTER("spider_param_use_consistent_snapshot");
355 DBUG_RETURN(THDVAR(thd, use_consistent_snapshot));
356}
357
358/*
359 FALSE: off
360 TRUE: on
361 */
362static MYSQL_THDVAR_BOOL(
363 internal_xa, /* name */
364 PLUGIN_VAR_OPCMDARG, /* opt */
365 "Use inner xa transaction", /* comment */
366 NULL, /* check */
367 NULL, /* update */
368 FALSE /* def */
369);
370
371bool spider_param_internal_xa(
372 THD *thd
373) {
374 DBUG_ENTER("spider_param_internal_xa");
375 DBUG_RETURN(THDVAR(thd, internal_xa));
376}
377
378/*
379 0 :err when use a spider table
380 1 :err when start trx
381 2 :start trx with snapshot on remote server(not use xa)
382 3 :start xa on remote server(not use trx with snapshot)
383 */
384static MYSQL_THDVAR_UINT(
385 internal_xa_snapshot, /* name */
386 PLUGIN_VAR_RQCMDARG, /* opt */
387 "Action of inner xa and snapshot both using", /* comment */
388 NULL, /* check */
389 NULL, /* update */
390 0, /* def */
391 0, /* min */
392 3, /* max */
393 0 /* blk */
394);
395
396uint spider_param_internal_xa_snapshot(
397 THD *thd
398) {
399 DBUG_ENTER("spider_param_internal_xa_snapshot");
400 DBUG_RETURN(THDVAR(thd, internal_xa_snapshot));
401}
402
403/*
404 0 :off
405 1 :continue prepare, commit, rollback if xid not found return
406 2 :continue prepare, commit, rollback if all error return
407 */
408static MYSQL_THDVAR_UINT(
409 force_commit, /* name */
410 PLUGIN_VAR_RQCMDARG, /* opt */
411 "Force prepare, commit, rollback mode", /* comment */
412 NULL, /* check */
413 NULL, /* update */
414 1, /* def */
415 0, /* min */
416 2, /* max */
417 0 /* blk */
418);
419
420uint spider_param_force_commit(
421 THD *thd
422) {
423 DBUG_ENTER("spider_param_force_commit");
424 DBUG_RETURN(THDVAR(thd, force_commit));
425}
426
427/*
428 0: register all XA transaction
429 1: register only write XA transaction
430 */
431static MYSQL_THDVAR_UINT(
432 xa_register_mode, /* name */
433 PLUGIN_VAR_RQCMDARG, /* opt */
434 "Mode of XA transaction register into system table", /* comment */
435 NULL, /* check */
436 NULL, /* update */
437 1, /* def */
438 0, /* min */
439 1, /* max */
440 0 /* blk */
441);
442
443uint spider_param_xa_register_mode(
444 THD *thd
445) {
446 DBUG_ENTER("spider_param_xa_register_mode");
447 DBUG_RETURN(THDVAR(thd, xa_register_mode));
448}
449
450/*
451 -1 :use table parameter
452 0-:offset
453 */
454static MYSQL_THDVAR_LONGLONG(
455 internal_offset, /* name */
456 PLUGIN_VAR_RQCMDARG, /* opt */
457 "Internal offset", /* comment */
458 NULL, /* check */
459 NULL, /* update */
460 -1, /* def */
461 -1, /* min */
462 9223372036854775807LL, /* max */
463 0 /* blk */
464);
465
466longlong spider_param_internal_offset(
467 THD *thd,
468 longlong internal_offset
469) {
470 DBUG_ENTER("spider_param_internal_offset");
471 DBUG_RETURN(THDVAR(thd, internal_offset) < 0 ?
472 internal_offset : THDVAR(thd, internal_offset));
473}
474
475/*
476 -1 :use table parameter
477 0-:limit
478 */
479static MYSQL_THDVAR_LONGLONG(
480 internal_limit, /* name */
481 PLUGIN_VAR_RQCMDARG, /* opt */
482 "Internal limit", /* comment */
483 NULL, /* check */
484 NULL, /* update */
485 -1, /* def */
486 -1, /* min */
487 9223372036854775807LL, /* max */
488 0 /* blk */
489);
490
491longlong spider_param_internal_limit(
492 THD *thd,
493 longlong internal_limit
494) {
495 DBUG_ENTER("spider_param_internal_limit");
496 DBUG_RETURN(THDVAR(thd, internal_limit) < 0 ?
497 internal_limit : THDVAR(thd, internal_limit));
498}
499
500/*
501 -1 :use table parameter
502 0-:number of rows at a select
503 */
504static MYSQL_THDVAR_LONGLONG(
505 split_read, /* name */
506 PLUGIN_VAR_RQCMDARG, /* opt */
507 "Number of rows at a select", /* comment */
508 NULL, /* check */
509 NULL, /* update */
510 -1, /* def */
511 -1, /* min */
512 9223372036854775807LL, /* max */
513 0 /* blk */
514);
515
516longlong spider_param_split_read(
517 THD *thd,
518 longlong split_read
519) {
520 DBUG_ENTER("spider_param_split_read");
521 DBUG_RETURN(THDVAR(thd, split_read) < 0 ?
522 split_read : THDVAR(thd, split_read));
523}
524
525/*
526 -1 :use table parameter
527 0 :doesn't use "offset" and "limit" for "split_read"
528 1-:magnification
529 */
530static MYSQL_THDVAR_INT(
531 semi_split_read, /* name */
532 PLUGIN_VAR_RQCMDARG, /* opt */
533 "Use offset and limit parameter in SQL for split_read parameter.", /* comment */
534 NULL, /* check */
535 NULL, /* update */
536 -1, /* def */
537 -1, /* min */
538 2147483647, /* max */
539 0 /* blk */
540);
541
542double spider_param_semi_split_read(
543 THD *thd,
544 double semi_split_read
545) {
546 DBUG_ENTER("spider_param_semi_split_read");
547 DBUG_RETURN(THDVAR(thd, semi_split_read) < 0 ?
548 semi_split_read : THDVAR(thd, semi_split_read));
549}
550
551/*
552 -1 :use table parameter
553 0-:the limit value
554 */
555static MYSQL_THDVAR_LONGLONG(
556 semi_split_read_limit, /* name */
557 PLUGIN_VAR_RQCMDARG, /* opt */
558 "The limit value for semi_split_read", /* comment */
559 NULL, /* check */
560 NULL, /* update */
561 -1, /* def */
562 -1, /* min */
563 9223372036854775807LL, /* max */
564 0 /* blk */
565);
566
567longlong spider_param_semi_split_read_limit(
568 THD *thd,
569 longlong semi_split_read_limit
570) {
571 DBUG_ENTER("spider_param_semi_split_read_limit");
572 DBUG_RETURN(THDVAR(thd, semi_split_read_limit) < 0 ?
573 semi_split_read_limit : THDVAR(thd, semi_split_read_limit));
574}
575
576/*
577 -1 :use table parameter
578 0 :no alloc
579 1-:alloc size
580 */
581static MYSQL_THDVAR_INT(
582 init_sql_alloc_size, /* name */
583 PLUGIN_VAR_RQCMDARG, /* opt */
584 "Initial sql string alloc size", /* comment */
585 NULL, /* check */
586 NULL, /* update */
587 -1, /* def */
588 -1, /* min */
589 2147483647, /* max */
590 0 /* blk */
591);
592
593int spider_param_init_sql_alloc_size(
594 THD *thd,
595 int init_sql_alloc_size
596) {
597 DBUG_ENTER("spider_param_init_sql_alloc_size");
598 DBUG_RETURN(THDVAR(thd, init_sql_alloc_size) < 0 ?
599 init_sql_alloc_size : THDVAR(thd, init_sql_alloc_size));
600}
601
602/*
603 -1 :use table parameter
604 0 :off
605 1 :on
606 */
607static MYSQL_THDVAR_INT(
608 reset_sql_alloc, /* name */
609 PLUGIN_VAR_RQCMDARG, /* opt */
610 "Reset sql string alloc after execute", /* comment */
611 NULL, /* check */
612 NULL, /* update */
613 -1, /* def */
614 -1, /* min */
615 1, /* max */
616 0 /* blk */
617);
618
619int spider_param_reset_sql_alloc(
620 THD *thd,
621 int reset_sql_alloc
622) {
623 DBUG_ENTER("spider_param_reset_sql_alloc");
624 DBUG_RETURN(THDVAR(thd, reset_sql_alloc) < 0 ?
625 reset_sql_alloc : THDVAR(thd, reset_sql_alloc));
626}
627
628#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
629/*
630 -1 :use table parameter
631 0-:result free size for handlersocket
632 */
633static MYSQL_THDVAR_LONGLONG(
634 hs_result_free_size, /* name */
635 PLUGIN_VAR_RQCMDARG, /* opt */
636 "Result free size for handlersocket", /* comment */
637 NULL, /* check */
638 NULL, /* update */
639 -1, /* def */
640 -1, /* min */
641 9223372036854775807LL, /* max */
642 0 /* blk */
643);
644
645longlong spider_param_hs_result_free_size(
646 THD *thd,
647 longlong hs_result_free_size
648) {
649 DBUG_ENTER("spider_param_hs_result_free_size");
650 DBUG_RETURN(THDVAR(thd, hs_result_free_size) < 0 ?
651 hs_result_free_size : THDVAR(thd, hs_result_free_size));
652}
653#endif
654
655/*
656 -1 :use table parameter
657 0 :off
658 1 :on
659 */
660static MYSQL_THDVAR_INT(
661 multi_split_read, /* name */
662 PLUGIN_VAR_RQCMDARG, /* opt */
663 "Sprit read mode for multi range", /* comment */
664 NULL, /* check */
665 NULL, /* update */
666 -1, /* def */
667 -1, /* min */
668 2147483647, /* max */
669 0 /* blk */
670);
671
672int spider_param_multi_split_read(
673 THD *thd,
674 int multi_split_read
675) {
676 DBUG_ENTER("spider_param_multi_split_read");
677 DBUG_RETURN(THDVAR(thd, multi_split_read) < 0 ?
678 multi_split_read : THDVAR(thd, multi_split_read));
679}
680
681/*
682 -1 :use table parameter
683 0-:max order columns
684 */
685static MYSQL_THDVAR_INT(
686 max_order, /* name */
687 PLUGIN_VAR_RQCMDARG, /* opt */
688 "Max columns for order by", /* comment */
689 NULL, /* check */
690 NULL, /* update */
691 -1, /* def */
692 -1, /* min */
693 32767, /* max */
694 0 /* blk */
695);
696
697int spider_param_max_order(
698 THD *thd,
699 int max_order
700) {
701 DBUG_ENTER("spider_param_max_order");
702 DBUG_RETURN(THDVAR(thd, max_order) < 0 ?
703 max_order : THDVAR(thd, max_order));
704}
705
706/*
707 -1 :off
708 0 :read uncommitted
709 1 :read committed
710 2 :repeatable read
711 3 :serializable
712 */
713static MYSQL_THDVAR_INT(
714 semi_trx_isolation, /* name */
715 PLUGIN_VAR_RQCMDARG, /* opt */
716 "Transaction isolation level during execute a sql", /* comment */
717 NULL, /* check */
718 NULL, /* update */
719 -1, /* def */
720 -1, /* min */
721 3, /* max */
722 0 /* blk */
723);
724
725int spider_param_semi_trx_isolation(
726 THD *thd
727) {
728 DBUG_ENTER("spider_param_semi_trx_isolation");
729 DBUG_RETURN(THDVAR(thd, semi_trx_isolation));
730}
731
732static int spider_param_semi_table_lock_check(
733 MYSQL_THD thd,
734 struct st_mysql_sys_var *var,
735 void *save,
736 struct st_mysql_value *value
737) {
738 int error_num;
739 SPIDER_TRX *trx;
740 my_bool fixed;
741 long long tmp;
742 struct my_option options;
743 DBUG_ENTER("spider_param_semi_table_lock_check");
744 if (!(trx = spider_get_trx((THD *) thd, TRUE, &error_num)))
745 DBUG_RETURN(error_num);
746 if (trx->locked_connections)
747 {
748 my_message(ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM,
749 ER_SPIDER_ALTER_BEFORE_UNLOCK_STR, MYF(0));
750 DBUG_RETURN(ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM);
751 }
752 value->val_int(value, &tmp);
753 options.sub_size = 0;
754 options.var_type = GET_INT;
755 options.def_value = ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->def_val;
756 options.min_value = ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->min_val;
757 options.max_value = ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->max_val;
758 options.block_size =
759 (long) ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->blk_sz;
760 options.arg_type = REQUIRED_ARG;
761 *((int *) save) = (int) getopt_ll_limit_value(tmp, &options, &fixed);
762#if MYSQL_VERSION_ID < 50500
763 DBUG_RETURN(throw_bounds_warning(thd, fixed, FALSE,
764 ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->name, (long long) tmp));
765#else
766 DBUG_RETURN(throw_bounds_warning(thd,
767 ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->name, fixed, FALSE,
768 (longlong) tmp));
769#endif
770}
771
772/*
773 0 :off
774 1 :on
775 */
776static MYSQL_THDVAR_INT(
777 semi_table_lock, /* name */
778 PLUGIN_VAR_RQCMDARG, /* opt */
779 "Table lock during execute a sql", /* comment */
780 &spider_param_semi_table_lock_check, /* check */
781 NULL, /* update */
782 1, /* def */
783 0, /* min */
784 1, /* max */
785 0 /* blk */
786);
787
788int spider_param_semi_table_lock(
789 THD *thd,
790 int semi_table_lock
791) {
792 DBUG_ENTER("spider_param_semi_table_lock");
793 DBUG_RETURN((semi_table_lock & THDVAR(thd, semi_table_lock)));
794}
795
796static int spider_param_semi_table_lock_connection_check(
797 MYSQL_THD thd,
798 struct st_mysql_sys_var *var,
799 void *save,
800 struct st_mysql_value *value
801) {
802 int error_num;
803 SPIDER_TRX *trx;
804 my_bool fixed;
805 long long tmp;
806 struct my_option options;
807 DBUG_ENTER("spider_param_semi_table_lock_connection_check");
808 if (!(trx = spider_get_trx((THD *) thd, TRUE, &error_num)))
809 DBUG_RETURN(error_num);
810 if (trx->locked_connections)
811 {
812 my_message(ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM,
813 ER_SPIDER_ALTER_BEFORE_UNLOCK_STR, MYF(0));
814 DBUG_RETURN(ER_SPIDER_ALTER_BEFORE_UNLOCK_NUM);
815 }
816 value->val_int(value, &tmp);
817 options.sub_size = 0;
818 options.var_type = GET_INT;
819 options.def_value = ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->def_val;
820 options.min_value = ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->min_val;
821 options.max_value = ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->max_val;
822 options.block_size =
823 (long) ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->blk_sz;
824 options.arg_type = REQUIRED_ARG;
825 *((int *) save) = (int) getopt_ll_limit_value(tmp, &options, &fixed);
826#if MYSQL_VERSION_ID < 50500
827 DBUG_RETURN(throw_bounds_warning(thd, fixed, FALSE,
828 ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->name, (long long) tmp));
829#else
830 DBUG_RETURN(throw_bounds_warning(thd,
831 ((MYSQL_SYSVAR_NAME(thdvar_int_t) *) var)->name, fixed, FALSE,
832 (longlong) tmp));
833#endif
834}
835
836/*
837 -1 :off
838 0 :use same connection
839 1 :use different connection
840 */
841static MYSQL_THDVAR_INT(
842 semi_table_lock_connection, /* name */
843 PLUGIN_VAR_RQCMDARG, /* opt */
844 "Use different connection if semi_table_lock is enabled", /* comment */
845 &spider_param_semi_table_lock_connection_check, /* check */
846 NULL, /* update */
847 -1, /* def */
848 -1, /* min */
849 1, /* max */
850 0 /* blk */
851);
852
853int spider_param_semi_table_lock_connection(
854 THD *thd,
855 int semi_table_lock_connection
856) {
857 DBUG_ENTER("spider_param_semi_table_lock_connection");
858 DBUG_RETURN(THDVAR(thd, semi_table_lock_connection) == -1 ?
859 semi_table_lock_connection : THDVAR(thd, semi_table_lock_connection));
860}
861
862/*
863 0-:block_size
864 */
865static MYSQL_THDVAR_UINT(
866 block_size, /* name */
867 PLUGIN_VAR_RQCMDARG, /* opt */
868 "Index block size", /* comment */
869 NULL, /* check */
870 NULL, /* update */
871 16384, /* def */
872 0, /* min */
873 4294967295U, /* max */
874 0 /* blk */
875);
876
877uint spider_param_block_size(
878 THD *thd
879) {
880 DBUG_ENTER("spider_param_block_size");
881 DBUG_RETURN(THDVAR(thd, block_size));
882}
883
884/*
885 -1 :use table parameter
886 0 :off
887 1 :lock in share mode
888 2 :for update
889 */
890static MYSQL_THDVAR_INT(
891 selupd_lock_mode, /* name */
892 PLUGIN_VAR_RQCMDARG, /* opt */
893 "Lock for select with update", /* comment */
894 NULL, /* check */
895 NULL, /* update */
896 -1, /* def */
897 -1, /* min */
898 2, /* max */
899 0 /* blk */
900);
901
902int spider_param_selupd_lock_mode(
903 THD *thd,
904 int selupd_lock_mode
905) {
906 DBUG_ENTER("spider_param_selupd_lock_mode");
907 DBUG_RETURN(THDVAR(thd, selupd_lock_mode) == -1 ?
908 selupd_lock_mode : THDVAR(thd, selupd_lock_mode));
909}
910
911/*
912 FALSE: no sync
913 TRUE: sync
914 */
915static MYSQL_THDVAR_BOOL(
916 sync_autocommit, /* name */
917 PLUGIN_VAR_OPCMDARG, /* opt */
918 "Sync autocommit", /* comment */
919 NULL, /* check */
920 NULL, /* update */
921 TRUE /* def */
922);
923
924bool spider_param_sync_autocommit(
925 THD *thd
926) {
927 DBUG_ENTER("spider_param_sync_autocommit");
928 DBUG_RETURN(THDVAR(thd, sync_autocommit));
929}
930
931/*
932 FALSE: no sync
933 TRUE: sync
934 */
935static MYSQL_THDVAR_BOOL(
936 sync_time_zone, /* name */
937 PLUGIN_VAR_OPCMDARG, /* opt */
938 "Sync time_zone", /* comment */
939 NULL, /* check */
940 NULL, /* update */
941 FALSE /* def */
942);
943
944bool spider_param_sync_time_zone(
945 THD *thd
946) {
947 DBUG_ENTER("spider_param_sync_time_zone");
948 DBUG_RETURN(THDVAR(thd, sync_time_zone));
949}
950
951/*
952 FALSE: not use
953 TRUE: use
954 */
955static MYSQL_THDVAR_BOOL(
956 use_default_database, /* name */
957 PLUGIN_VAR_OPCMDARG, /* opt */
958 "Use default database", /* comment */
959 NULL, /* check */
960 NULL, /* update */
961 TRUE /* def */
962);
963
964bool spider_param_use_default_database(
965 THD *thd
966) {
967 DBUG_ENTER("spider_param_use_default_database");
968 DBUG_RETURN(THDVAR(thd, use_default_database));
969}
970
971/*
972-1 :don't know or does not matter; don't send 'SET SQL_LOG_OFF' statement
973 0 :do send 'SET SQL_LOG_OFF 0' statement to data nodes
974 1 :do send 'SET SQL_LOG_OFF 1' statement to data nodes
975*/
976static MYSQL_THDVAR_INT(
977 internal_sql_log_off, /* name */
978 PLUGIN_VAR_RQCMDARG, /* opt */
979 "Manage SQL_LOG_OFF mode statement to the data nodes", /* comment */
980 NULL, /* check */
981 NULL, /* update */
982 -1, /* default */
983 -1, /* min */
984 1, /* max */
985 0 /* blk */
986);
987
988int spider_param_internal_sql_log_off(
989 THD *thd
990) {
991 DBUG_ENTER("spider_param_internal_sql_log_off");
992 DBUG_RETURN(THDVAR(thd, internal_sql_log_off));
993}
994
995/*
996 -1 :use table parameter
997 0-:bulk insert size
998 */
999static MYSQL_THDVAR_INT(
1000 bulk_size, /* name */
1001 PLUGIN_VAR_RQCMDARG, /* opt */
1002 "Bulk insert size", /* comment */
1003 NULL, /* check */
1004 NULL, /* update */
1005 -1, /* def */
1006 -1, /* min */
1007 2147483647, /* max */
1008 0 /* blk */
1009);
1010
1011int spider_param_bulk_size(
1012 THD *thd,
1013 int bulk_size
1014) {
1015 DBUG_ENTER("spider_param_bulk_size");
1016 DBUG_RETURN(THDVAR(thd, bulk_size) < 0 ?
1017 bulk_size : THDVAR(thd, bulk_size));
1018}
1019
1020/*
1021 -1 :use table parameter
1022 0 : Send "update" and "delete" statements one by one.
1023 1 : Send collected multiple "update" and "delete" statements.
1024 (Collected statements are sent one by one)
1025 2 : Send collected multiple "update" and "delete" statements.
1026 (Collected statements are sent together)
1027 */
1028static MYSQL_THDVAR_INT(
1029 bulk_update_mode, /* name */
1030 PLUGIN_VAR_RQCMDARG, /* opt */
1031 "The mode of bulk updating and deleting", /* comment */
1032 NULL, /* check */
1033 NULL, /* update */
1034 -1, /* def */
1035 -1, /* min */
1036 2, /* max */
1037 0 /* blk */
1038);
1039
1040int spider_param_bulk_update_mode(
1041 THD *thd,
1042 int bulk_update_mode
1043) {
1044 DBUG_ENTER("spider_param_bulk_update_mode");
1045 DBUG_RETURN(THDVAR(thd, bulk_update_mode) == -1 ?
1046 bulk_update_mode : THDVAR(thd, bulk_update_mode));
1047}
1048
1049/*
1050 -1 :use table parameter
1051 0-:bulk update size
1052 */
1053static MYSQL_THDVAR_INT(
1054 bulk_update_size, /* name */
1055 PLUGIN_VAR_RQCMDARG, /* opt */
1056 "Bulk update size", /* comment */
1057 NULL, /* check */
1058 NULL, /* update */
1059 -1, /* def */
1060 -1, /* min */
1061 2147483647, /* max */
1062 0 /* blk */
1063);
1064
1065int spider_param_bulk_update_size(
1066 THD *thd,
1067 int bulk_update_size
1068) {
1069 DBUG_ENTER("spider_param_bulk_update_size");
1070 DBUG_RETURN(THDVAR(thd, bulk_update_size) == -1 ?
1071 bulk_update_size : THDVAR(thd, bulk_update_size));
1072}
1073
1074/*
1075 -1 :use table parameter
1076 0 :off
1077 1 :on
1078 */
1079static MYSQL_THDVAR_INT(
1080 internal_optimize, /* name */
1081 PLUGIN_VAR_RQCMDARG, /* opt */
1082 "Execute optimize to remote server", /* comment */
1083 NULL, /* check */
1084 NULL, /* update */
1085 -1, /* def */
1086 -1, /* min */
1087 1, /* max */
1088 0 /* blk */
1089);
1090
1091int spider_param_internal_optimize(
1092 THD *thd,
1093 int internal_optimize
1094) {
1095 DBUG_ENTER("spider_param_internal_optimize");
1096 DBUG_RETURN(THDVAR(thd, internal_optimize) == -1 ?
1097 internal_optimize : THDVAR(thd, internal_optimize));
1098}
1099
1100/*
1101 -1 :use table parameter
1102 0 :off
1103 1 :on
1104 */
1105static MYSQL_THDVAR_INT(
1106 internal_optimize_local, /* name */
1107 PLUGIN_VAR_RQCMDARG, /* opt */
1108 "Execute optimize to remote server with local", /* comment */
1109 NULL, /* check */
1110 NULL, /* update */
1111 -1, /* def */
1112 -1, /* min */
1113 1, /* max */
1114 0 /* blk */
1115);
1116
1117int spider_param_internal_optimize_local(
1118 THD *thd,
1119 int internal_optimize_local
1120) {
1121 DBUG_ENTER("spider_param_internal_optimize_local");
1122 DBUG_RETURN(THDVAR(thd, internal_optimize_local) == -1 ?
1123 internal_optimize_local : THDVAR(thd, internal_optimize_local));
1124}
1125
1126/*
1127 FALSE: off
1128 TRUE: on
1129 */
1130static MYSQL_THDVAR_BOOL(
1131 use_flash_logs, /* name */
1132 PLUGIN_VAR_OPCMDARG, /* opt */
1133 "Execute flush logs to remote server", /* comment */
1134 NULL, /* check */
1135 NULL, /* update */
1136 FALSE /* def */
1137);
1138
1139bool spider_param_use_flash_logs(
1140 THD *thd
1141) {
1142 DBUG_ENTER("spider_param_use_flash_logs");
1143 DBUG_RETURN(THDVAR(thd, use_flash_logs));
1144}
1145
1146/*
1147 0 :off
1148 1 :flush tables with read lock
1149 2 :flush tables another connection
1150 */
1151static MYSQL_THDVAR_INT(
1152 use_snapshot_with_flush_tables, /* name */
1153 PLUGIN_VAR_RQCMDARG, /* opt */
1154 "Execute optimize to remote server with local", /* comment */
1155 NULL, /* check */
1156 NULL, /* update */
1157 0, /* def */
1158 0, /* min */
1159 2, /* max */
1160 0 /* blk */
1161);
1162
1163int spider_param_use_snapshot_with_flush_tables(
1164 THD *thd
1165) {
1166 DBUG_ENTER("spider_param_use_snapshot_with_flush_tables");
1167 DBUG_RETURN(THDVAR(thd, use_snapshot_with_flush_tables));
1168}
1169
1170/*
1171 FALSE: off
1172 TRUE: on
1173 */
1174static MYSQL_THDVAR_BOOL(
1175 use_all_conns_snapshot, /* name */
1176 PLUGIN_VAR_OPCMDARG, /* opt */
1177 "When start trx with snapshot, it send to all connections", /* comment */
1178 NULL, /* check */
1179 NULL, /* update */
1180 FALSE /* def */
1181);
1182
1183bool spider_param_use_all_conns_snapshot(
1184 THD *thd
1185) {
1186 DBUG_ENTER("spider_param_use_all_conns_snapshot");
1187 DBUG_RETURN(THDVAR(thd, use_all_conns_snapshot));
1188}
1189
1190/*
1191 FALSE: off
1192 TRUE: on
1193 */
1194static MYSQL_THDVAR_BOOL(
1195 lock_exchange, /* name */
1196 PLUGIN_VAR_OPCMDARG, /* opt */
1197 "Exchange select lock to lock tables", /* comment */
1198 NULL, /* check */
1199 NULL, /* update */
1200 FALSE /* def */
1201);
1202
1203bool spider_param_lock_exchange(
1204 THD *thd
1205) {
1206 DBUG_ENTER("spider_param_lock_exchange");
1207 DBUG_RETURN(THDVAR(thd, lock_exchange));
1208}
1209
1210/*
1211 FALSE: off
1212 TRUE: on
1213 */
1214static MYSQL_THDVAR_BOOL(
1215 internal_unlock, /* name */
1216 PLUGIN_VAR_OPCMDARG, /* opt */
1217 "Unlock tables for using connections in sql", /* comment */
1218 NULL, /* check */
1219 NULL, /* update */
1220 FALSE /* def */
1221);
1222
1223bool spider_param_internal_unlock(
1224 THD *thd
1225) {
1226 DBUG_ENTER("spider_param_internal_unlock");
1227 DBUG_RETURN(THDVAR(thd, internal_unlock));
1228}
1229
1230/*
1231 FALSE: off
1232 TRUE: on
1233 */
1234static MYSQL_THDVAR_BOOL(
1235 semi_trx, /* name */
1236 PLUGIN_VAR_OPCMDARG, /* opt */
1237 "Take a transaction during execute a sql", /* comment */
1238 NULL, /* check */
1239 NULL, /* update */
1240 TRUE /* def */
1241);
1242
1243bool spider_param_semi_trx(
1244 THD *thd
1245) {
1246 DBUG_ENTER("spider_param_semi_trx");
1247 DBUG_RETURN(THDVAR(thd, semi_trx));
1248}
1249
1250/*
1251 -1 :use table parameter
1252 0-:seconds of timeout
1253 */
1254static MYSQL_THDVAR_INT(
1255 connect_timeout, /* name */
1256 PLUGIN_VAR_RQCMDARG, /* opt */
1257 "Wait timeout of connecting to remote server", /* comment */
1258 NULL, /* check */
1259 NULL, /* update */
1260 -1, /* def */
1261 -1, /* min */
1262 2147483647, /* max */
1263 0 /* blk */
1264);
1265
1266int spider_param_connect_timeout(
1267 THD *thd,
1268 int connect_timeout
1269) {
1270 DBUG_ENTER("spider_param_connect_timeout");
1271 if (thd)
1272 DBUG_RETURN(THDVAR(thd, connect_timeout) == -1 ?
1273 connect_timeout : THDVAR(thd, connect_timeout));
1274 DBUG_RETURN(connect_timeout);
1275}
1276
1277/*
1278 -1 :use table parameter
1279 0-:seconds of timeout
1280 */
1281static MYSQL_THDVAR_INT(
1282 net_read_timeout, /* name */
1283 PLUGIN_VAR_RQCMDARG, /* opt */
1284 "Wait timeout of receiving data from remote server", /* comment */
1285 NULL, /* check */
1286 NULL, /* update */
1287 -1, /* def */
1288 -1, /* min */
1289 2147483647, /* max */
1290 0 /* blk */
1291);
1292
1293int spider_param_net_read_timeout(
1294 THD *thd,
1295 int net_read_timeout
1296) {
1297 DBUG_ENTER("spider_param_net_read_timeout");
1298 if (thd)
1299 DBUG_RETURN(THDVAR(thd, net_read_timeout) == -1 ?
1300 net_read_timeout : THDVAR(thd, net_read_timeout));
1301 DBUG_RETURN(net_read_timeout);
1302}
1303
1304/*
1305 -1 :use table parameter
1306 0-:seconds of timeout
1307 */
1308static MYSQL_THDVAR_INT(
1309 net_write_timeout, /* name */
1310 PLUGIN_VAR_RQCMDARG, /* opt */
1311 "Wait timeout of sending data to remote server", /* comment */
1312 NULL, /* check */
1313 NULL, /* update */
1314 -1, /* def */
1315 -1, /* min */
1316 2147483647, /* max */
1317 0 /* blk */
1318);
1319
1320int spider_param_net_write_timeout(
1321 THD *thd,
1322 int net_write_timeout
1323) {
1324 DBUG_ENTER("spider_param_net_write_timeout");
1325 if (thd)
1326 DBUG_RETURN(THDVAR(thd, net_write_timeout) == -1 ?
1327 net_write_timeout : THDVAR(thd, net_write_timeout));
1328 DBUG_RETURN(net_write_timeout);
1329}
1330
1331/*
1332 -1 :use table parameter
1333 0 :It acquires it collectively.
1334 1 :Acquisition one by one.If it discontinues once, and it will need
1335 it later, it retrieves it again when there is interrupt on the way.
1336 2 :Acquisition one by one.Interrupt is waited for until end of getting
1337 result when there is interrupt on the way.
1338 */
1339static MYSQL_THDVAR_INT(
1340 quick_mode, /* name */
1341 PLUGIN_VAR_RQCMDARG, /* opt */
1342 "The retrieval result from a remote server is acquired by acquisition one by one", /* comment */
1343 NULL, /* check */
1344 NULL, /* update */
1345 -1, /* def */
1346 -1, /* min */
1347 3, /* max */
1348 0 /* blk */
1349);
1350
1351int spider_param_quick_mode(
1352 THD *thd,
1353 int quick_mode
1354) {
1355 DBUG_ENTER("spider_param_quick_mode");
1356 DBUG_RETURN(THDVAR(thd, quick_mode) < 0 ?
1357 quick_mode : THDVAR(thd, quick_mode));
1358}
1359
1360/*
1361 -1 :use table parameter
1362 0-:number of records
1363 */
1364static MYSQL_THDVAR_LONGLONG(
1365 quick_page_size, /* name */
1366 PLUGIN_VAR_RQCMDARG, /* opt */
1367 "Number of records in a page when acquisition one by one", /* comment */
1368 NULL, /* check */
1369 NULL, /* update */
1370 -1, /* def */
1371 -1, /* min */
1372 9223372036854775807LL, /* max */
1373 0 /* blk */
1374);
1375
1376longlong spider_param_quick_page_size(
1377 THD *thd,
1378 longlong quick_page_size
1379) {
1380 DBUG_ENTER("spider_param_quick_page_size");
1381 DBUG_RETURN(THDVAR(thd, quick_page_size) < 0 ?
1382 quick_page_size : THDVAR(thd, quick_page_size));
1383}
1384
1385/*
1386 -1 :use table parameter
1387 0 :It doesn't use low memory mode.
1388 1 :It uses low memory mode.
1389 */
1390static MYSQL_THDVAR_INT(
1391 low_mem_read, /* name */
1392 PLUGIN_VAR_RQCMDARG, /* opt */
1393 "Use low memory mode when SQL(SELECT) internally issued to a remote server is executed and get a result list", /* comment */
1394 NULL, /* check */
1395 NULL, /* update */
1396 -1, /* def */
1397 -1, /* min */
1398 1, /* max */
1399 0 /* blk */
1400);
1401
1402int spider_param_low_mem_read(
1403 THD *thd,
1404 int low_mem_read
1405) {
1406 DBUG_ENTER("spider_param_low_mem_read");
1407 DBUG_RETURN(THDVAR(thd, low_mem_read) < 0 ?
1408 low_mem_read : THDVAR(thd, low_mem_read));
1409}
1410
1411/*
1412 -1 :use table parameter
1413 0 :Use index columns if select statement can solve by using index,
1414 otherwise use all columns.
1415 1 :Use columns that are judged necessary.
1416 */
1417static MYSQL_THDVAR_INT(
1418 select_column_mode, /* name */
1419 PLUGIN_VAR_RQCMDARG, /* opt */
1420 "The mode of using columns at select clause", /* comment */
1421 NULL, /* check */
1422 NULL, /* update */
1423 -1, /* def */
1424 -1, /* min */
1425 1, /* max */
1426 0 /* blk */
1427);
1428
1429int spider_param_select_column_mode(
1430 THD *thd,
1431 int select_column_mode
1432) {
1433 DBUG_ENTER("spider_param_select_column_mode");
1434 DBUG_RETURN(THDVAR(thd, select_column_mode) == -1 ?
1435 select_column_mode : THDVAR(thd, select_column_mode));
1436}
1437
1438#ifndef WITHOUT_SPIDER_BG_SEARCH
1439/*
1440 -1 :use table parameter
1441 0 :background search is disabled
1442 1 :background search is used if search with no lock
1443 2 :background search is used if search with no lock or shared lock
1444 3 :background search is used regardless of the lock
1445 */
1446static MYSQL_THDVAR_INT(
1447 bgs_mode, /* name */
1448 PLUGIN_VAR_RQCMDARG, /* opt */
1449 "Mode of background search", /* comment */
1450 NULL, /* check */
1451 NULL, /* update */
1452 -1, /* def */
1453 -1, /* min */
1454 3, /* max */
1455 0 /* blk */
1456);
1457
1458int spider_param_bgs_mode(
1459 THD *thd,
1460 int bgs_mode
1461) {
1462 DBUG_ENTER("spider_param_bgs_mode");
1463 DBUG_RETURN(THDVAR(thd, bgs_mode) < 0 ?
1464 bgs_mode : THDVAR(thd, bgs_mode));
1465}
1466
1467/*
1468 -1 :use table parameter
1469 0 :records is gotten usually
1470 1-:number of records
1471 */
1472static MYSQL_THDVAR_LONGLONG(
1473 bgs_first_read, /* name */
1474 PLUGIN_VAR_RQCMDARG, /* opt */
1475 "Number of first read records when background search is used", /* comment */
1476 NULL, /* check */
1477 NULL, /* update */
1478 -1, /* def */
1479 -1, /* min */
1480 9223372036854775807LL, /* max */
1481 0 /* blk */
1482);
1483
1484longlong spider_param_bgs_first_read(
1485 THD *thd,
1486 longlong bgs_first_read
1487) {
1488 DBUG_ENTER("spider_param_bgs_first_read");
1489 DBUG_RETURN(THDVAR(thd, bgs_first_read) < 0 ?
1490 bgs_first_read : THDVAR(thd, bgs_first_read));
1491}
1492
1493/*
1494 -1 :use table parameter
1495 0 :records is gotten usually
1496 1-:number of records
1497 */
1498static MYSQL_THDVAR_LONGLONG(
1499 bgs_second_read, /* name */
1500 PLUGIN_VAR_RQCMDARG, /* opt */
1501 "Number of second read records when background search is used", /* comment */
1502 NULL, /* check */
1503 NULL, /* update */
1504 -1, /* def */
1505 -1, /* min */
1506 9223372036854775807LL, /* max */
1507 0 /* blk */
1508);
1509
1510longlong spider_param_bgs_second_read(
1511 THD *thd,
1512 longlong bgs_second_read
1513) {
1514 DBUG_ENTER("spider_param_bgs_second_read");
1515 DBUG_RETURN(THDVAR(thd, bgs_second_read) < 0 ?
1516 bgs_second_read : THDVAR(thd, bgs_second_read));
1517}
1518#endif
1519
1520/*
1521 -1 :use table parameter
1522 0 :records is gotten usually
1523 1-:number of records
1524 */
1525static MYSQL_THDVAR_LONGLONG(
1526 first_read, /* name */
1527 PLUGIN_VAR_RQCMDARG, /* opt */
1528 "Number of first read records", /* comment */
1529 NULL, /* check */
1530 NULL, /* update */
1531 -1, /* def */
1532 -1, /* min */
1533 9223372036854775807LL, /* max */
1534 0 /* blk */
1535);
1536
1537longlong spider_param_first_read(
1538 THD *thd,
1539 longlong first_read
1540) {
1541 DBUG_ENTER("spider_param_first_read");
1542 DBUG_RETURN(THDVAR(thd, first_read) < 0 ?
1543 first_read : THDVAR(thd, first_read));
1544}
1545
1546/*
1547 -1 :use table parameter
1548 0 :records is gotten usually
1549 1-:number of records
1550 */
1551static MYSQL_THDVAR_LONGLONG(
1552 second_read, /* name */
1553 PLUGIN_VAR_RQCMDARG, /* opt */
1554 "Number of second read records", /* comment */
1555 NULL, /* check */
1556 NULL, /* update */
1557 -1, /* def */
1558 -1, /* min */
1559 9223372036854775807LL, /* max */
1560 0 /* blk */
1561);
1562
1563longlong spider_param_second_read(
1564 THD *thd,
1565 longlong second_read
1566) {
1567 DBUG_ENTER("spider_param_second_read");
1568 DBUG_RETURN(THDVAR(thd, second_read) < 0 ?
1569 second_read : THDVAR(thd, second_read));
1570}
1571
1572/*
1573 -1 :use table parameter
1574 0 :always get the newest information
1575 1-:interval
1576 */
1577static MYSQL_THDVAR_INT(
1578 crd_interval, /* name */
1579 PLUGIN_VAR_RQCMDARG, /* opt */
1580 "Interval of cardinality confirmation.(second)", /* comment */
1581 NULL, /* check */
1582 NULL, /* update */
1583 -1, /* def */
1584 -1, /* min */
1585 2147483647, /* max */
1586 0 /* blk */
1587);
1588
1589double spider_param_crd_interval(
1590 THD *thd,
1591 double crd_interval
1592) {
1593 DBUG_ENTER("spider_param_crd_interval");
1594 DBUG_RETURN(THDVAR(thd, crd_interval) == -1 ?
1595 crd_interval : THDVAR(thd, crd_interval));
1596}
1597
1598/*
1599 -1 :use table parameter
1600 0 :use table parameter
1601 1 :use show command
1602 2 :use information schema
1603 3 :use explain
1604 */
1605static MYSQL_THDVAR_INT(
1606 crd_mode, /* name */
1607 PLUGIN_VAR_RQCMDARG, /* opt */
1608 "Mode of cardinality confirmation.", /* comment */
1609 NULL, /* check */
1610 NULL, /* update */
1611 -1, /* def */
1612 -1, /* min */
1613 3, /* max */
1614 0 /* blk */
1615);
1616
1617int spider_param_crd_mode(
1618 THD *thd,
1619 int crd_mode
1620) {
1621 DBUG_ENTER("spider_param_crd_mode");
1622 DBUG_RETURN(THDVAR(thd, crd_mode) <= 0 ?
1623 crd_mode : THDVAR(thd, crd_mode));
1624}
1625
1626#ifdef WITH_PARTITION_STORAGE_ENGINE
1627/*
1628 -1 :use table parameter
1629 0 :No synchronization.
1630 1 :Cardinality is synchronized when opening a table.
1631 Then no synchronization.
1632 2 :Synchronization.
1633 */
1634static MYSQL_THDVAR_INT(
1635 crd_sync, /* name */
1636 PLUGIN_VAR_RQCMDARG, /* opt */
1637 "Cardinality synchronization in partitioned table.", /* comment */
1638 NULL, /* check */
1639 NULL, /* update */
1640 -1, /* def */
1641 -1, /* min */
1642 2, /* max */
1643 0 /* blk */
1644);
1645
1646int spider_param_crd_sync(
1647 THD *thd,
1648 int crd_sync
1649) {
1650 DBUG_ENTER("spider_param_crd_sync");
1651 DBUG_RETURN(THDVAR(thd, crd_sync) == -1 ?
1652 crd_sync : THDVAR(thd, crd_sync));
1653}
1654#endif
1655
1656/*
1657 -1 :use table parameter
1658 0 :The crd_weight is used as a fixed value.
1659 1 :The crd_weight is used as an addition value.
1660 2 :The crd_weight is used as a multiplication value.
1661 */
1662static MYSQL_THDVAR_INT(
1663 crd_type, /* name */
1664 PLUGIN_VAR_RQCMDARG, /* opt */
1665 "Type of cardinality calculation.", /* comment */
1666 NULL, /* check */
1667 NULL, /* update */
1668 -1, /* def */
1669 -1, /* min */
1670 2, /* max */
1671 0 /* blk */
1672);
1673
1674int spider_param_crd_type(
1675 THD *thd,
1676 int crd_type
1677) {
1678 DBUG_ENTER("spider_param_crd_type");
1679 DBUG_RETURN(THDVAR(thd, crd_type) == -1 ?
1680 crd_type : THDVAR(thd, crd_type));
1681}
1682
1683/*
1684 -1 :use table parameter
1685 0-:weight
1686 */
1687static MYSQL_THDVAR_INT(
1688 crd_weight, /* name */
1689 PLUGIN_VAR_RQCMDARG, /* opt */
1690 "Weight coefficient to calculate effectiveness of index from cardinality of column.", /* comment */
1691 NULL, /* check */
1692 NULL, /* update */
1693 -1, /* def */
1694 -1, /* min */
1695 2147483647, /* max */
1696 0 /* blk */
1697);
1698
1699double spider_param_crd_weight(
1700 THD *thd,
1701 double crd_weight
1702) {
1703 DBUG_ENTER("spider_param_crd_weight");
1704 DBUG_RETURN(THDVAR(thd, crd_weight) == -1 ?
1705 crd_weight : THDVAR(thd, crd_weight));
1706}
1707
1708#ifndef WITHOUT_SPIDER_BG_SEARCH
1709/*
1710 -1 :use table parameter
1711 0 :Background confirmation is disabled
1712 1 :Background confirmation is enabled (create thread per table/partition)
1713 2 :Background confirmation is enabled (use static threads)
1714 */
1715static MYSQL_THDVAR_INT(
1716 crd_bg_mode, /* name */
1717 PLUGIN_VAR_RQCMDARG, /* opt */
1718 "Mode of cardinality confirmation at background.", /* comment */
1719 NULL, /* check */
1720 NULL, /* update */
1721 -1, /* def */
1722 -1, /* min */
1723 2, /* max */
1724 0 /* blk */
1725);
1726
1727int spider_param_crd_bg_mode(
1728 THD *thd,
1729 int crd_bg_mode
1730) {
1731 DBUG_ENTER("spider_param_crd_bg_mode");
1732 DBUG_RETURN(THDVAR(thd, crd_bg_mode) == -1 ?
1733 crd_bg_mode : THDVAR(thd, crd_bg_mode));
1734}
1735#endif
1736
1737/*
1738 -1 :use table parameter
1739 0 :always get the newest information
1740 1-:interval
1741 */
1742static MYSQL_THDVAR_INT(
1743 sts_interval, /* name */
1744 PLUGIN_VAR_RQCMDARG, /* opt */
1745 "Interval of table state confirmation.(second)", /* comment */
1746 NULL, /* check */
1747 NULL, /* update */
1748 -1, /* def */
1749 -1, /* min */
1750 2147483647, /* max */
1751 0 /* blk */
1752);
1753
1754double spider_param_sts_interval(
1755 THD *thd,
1756 double sts_interval
1757) {
1758 DBUG_ENTER("spider_param_sts_interval");
1759 DBUG_RETURN(THDVAR(thd, sts_interval) == -1 ?
1760 sts_interval : THDVAR(thd, sts_interval));
1761}
1762
1763/*
1764 -1 :use table parameter
1765 0 :use table parameter
1766 1 :use show command
1767 2 :use information schema
1768 */
1769static MYSQL_THDVAR_INT(
1770 sts_mode, /* name */
1771 PLUGIN_VAR_RQCMDARG, /* opt */
1772 "Mode of table state confirmation.", /* comment */
1773 NULL, /* check */
1774 NULL, /* update */
1775 -1, /* def */
1776 -1, /* min */
1777 2, /* max */
1778 0 /* blk */
1779);
1780
1781int spider_param_sts_mode(
1782 THD *thd,
1783 int sts_mode
1784) {
1785 DBUG_ENTER("spider_param_sts_mode");
1786 DBUG_RETURN(THDVAR(thd, sts_mode) <= 0 ?
1787 sts_mode : THDVAR(thd, sts_mode));
1788}
1789
1790#ifdef WITH_PARTITION_STORAGE_ENGINE
1791/*
1792 -1 :use table parameter
1793 0 :No synchronization.
1794 1 :Table state is synchronized when opening a table.
1795 Then no synchronization.
1796 2 :Synchronization.
1797 */
1798static MYSQL_THDVAR_INT(
1799 sts_sync, /* name */
1800 PLUGIN_VAR_RQCMDARG, /* opt */
1801 "Table state synchronization in partitioned table.", /* comment */
1802 NULL, /* check */
1803 NULL, /* update */
1804 -1, /* def */
1805 -1, /* min */
1806 2, /* max */
1807 0 /* blk */
1808);
1809
1810int spider_param_sts_sync(
1811 THD *thd,
1812 int sts_sync
1813) {
1814 DBUG_ENTER("spider_param_sts_sync");
1815 DBUG_RETURN(THDVAR(thd, sts_sync) == -1 ?
1816 sts_sync : THDVAR(thd, sts_sync));
1817}
1818#endif
1819
1820#ifndef WITHOUT_SPIDER_BG_SEARCH
1821/*
1822 -1 :use table parameter
1823 0 :Background confirmation is disabled
1824 1 :Background confirmation is enabled (create thread per table/partition)
1825 2 :Background confirmation is enabled (use static threads)
1826 */
1827static MYSQL_THDVAR_INT(
1828 sts_bg_mode, /* name */
1829 PLUGIN_VAR_RQCMDARG, /* opt */
1830 "Mode of table state confirmation at background.", /* comment */
1831 NULL, /* check */
1832 NULL, /* update */
1833 -1, /* def */
1834 -1, /* min */
1835 2, /* max */
1836 0 /* blk */
1837);
1838
1839int spider_param_sts_bg_mode(
1840 THD *thd,
1841 int sts_bg_mode
1842) {
1843 DBUG_ENTER("spider_param_sts_bg_mode");
1844 DBUG_RETURN(THDVAR(thd, sts_bg_mode) == -1 ?
1845 sts_bg_mode : THDVAR(thd, sts_bg_mode));
1846}
1847#endif
1848
1849/*
1850 0 :always ping
1851 1-:interval
1852 */
1853static MYSQL_THDVAR_INT(
1854 ping_interval_at_trx_start, /* name */
1855 PLUGIN_VAR_RQCMDARG, /* opt */
1856 "Ping interval at transaction start", /* comment */
1857 NULL, /* check */
1858 NULL, /* update */
1859 3600, /* def */
1860 0, /* min */
1861 2147483647, /* max */
1862 0 /* blk */
1863);
1864
1865double spider_param_ping_interval_at_trx_start(
1866 THD *thd
1867) {
1868 DBUG_ENTER("spider_param_ping_interval_at_trx_start");
1869 DBUG_RETURN(THDVAR(thd, ping_interval_at_trx_start));
1870}
1871
1872#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
1873/*
1874 0 :always ping
1875 1-:interval
1876 */
1877static MYSQL_THDVAR_INT(
1878 hs_ping_interval, /* name */
1879 PLUGIN_VAR_RQCMDARG, /* opt */
1880 "Ping interval for handlersocket", /* comment */
1881 NULL, /* check */
1882 NULL, /* update */
1883 30, /* def */
1884 0, /* min */
1885 2147483647, /* max */
1886 0 /* blk */
1887);
1888
1889double spider_param_hs_ping_interval(
1890 THD *thd
1891) {
1892 DBUG_ENTER("spider_param_hs_ping_interval");
1893 DBUG_RETURN(THDVAR(thd, hs_ping_interval));
1894}
1895#endif
1896
1897/*
1898 -1 :use table parameter
1899 0 :normal mode
1900 1 :quick mode
1901 2 :set 0 value
1902 */
1903static MYSQL_THDVAR_INT(
1904 auto_increment_mode, /* name */
1905 PLUGIN_VAR_RQCMDARG, /* opt */
1906 "Mode of auto increment.", /* comment */
1907 NULL, /* check */
1908 NULL, /* update */
1909 -1, /* def */
1910 -1, /* min */
1911 3, /* max */
1912 0 /* blk */
1913);
1914
1915int spider_param_auto_increment_mode(
1916 THD *thd,
1917 int auto_increment_mode
1918) {
1919 DBUG_ENTER("spider_param_auto_increment_mode");
1920 DBUG_RETURN(THDVAR(thd, auto_increment_mode) == -1 ?
1921 auto_increment_mode : THDVAR(thd, auto_increment_mode));
1922}
1923
1924/*
1925 FALSE: off
1926 TRUE: on
1927 */
1928static MYSQL_THDVAR_BOOL(
1929 same_server_link, /* name */
1930 PLUGIN_VAR_OPCMDARG, /* opt */
1931 "Permit one to link same server's table", /* comment */
1932 NULL, /* check */
1933 NULL, /* update */
1934 FALSE /* def */
1935);
1936
1937bool spider_param_same_server_link(
1938 THD *thd
1939) {
1940 DBUG_ENTER("spider_param_same_server_link");
1941 DBUG_RETURN(THDVAR(thd, same_server_link));
1942}
1943
1944/*
1945 FALSE: transmits
1946 TRUE: don't transmit
1947 */
1948static MYSQL_THDVAR_BOOL(
1949 local_lock_table, /* name */
1950 PLUGIN_VAR_OPCMDARG, /* opt */
1951 "Remote server transmission when lock tables is executed at local",
1952 /* comment */
1953 NULL, /* check */
1954 NULL, /* update */
1955 FALSE /* def */
1956);
1957
1958bool spider_param_local_lock_table(
1959 THD *thd
1960) {
1961 DBUG_ENTER("spider_param_local_lock_table");
1962 DBUG_RETURN(THDVAR(thd, local_lock_table));
1963}
1964
1965/*
1966 -1 :use table parameter
1967 0 :don't transmit
1968 1 :transmits
1969 */
1970static MYSQL_THDVAR_INT(
1971 use_pushdown_udf, /* name */
1972 PLUGIN_VAR_RQCMDARG, /* opt */
1973 "Remote server transmission existence when UDF is used at condition and \"engine_condition_pushdown=1\"", /* comment */
1974 NULL, /* check */
1975 NULL, /* update */
1976 -1, /* def */
1977 -1, /* min */
1978 1, /* max */
1979 0 /* blk */
1980);
1981
1982int spider_param_use_pushdown_udf(
1983 THD *thd,
1984 int use_pushdown_udf
1985) {
1986 DBUG_ENTER("spider_param_use_pushdown_udf");
1987 DBUG_RETURN(THDVAR(thd, use_pushdown_udf) == -1 ?
1988 use_pushdown_udf : THDVAR(thd, use_pushdown_udf));
1989}
1990
1991/*
1992 -1 :use table parameter
1993 0 :duplicate check on local server
1994 1 :avoid duplicate check on local server
1995 */
1996static MYSQL_THDVAR_INT(
1997 direct_dup_insert, /* name */
1998 PLUGIN_VAR_RQCMDARG, /* opt */
1999 "Execute \"REPLACE\" and \"INSERT IGNORE\" on remote server and avoid duplicate check on local server", /* comment */
2000 NULL, /* check */
2001 NULL, /* update */
2002 -1, /* def */
2003 -1, /* min */
2004 1, /* max */
2005 0 /* blk */
2006);
2007
2008int spider_param_direct_dup_insert(
2009 THD *thd,
2010 int direct_dup_insert
2011) {
2012 DBUG_ENTER("spider_param_direct_dup_insert");
2013 DBUG_RETURN(THDVAR(thd, direct_dup_insert) < 0 ?
2014 direct_dup_insert : THDVAR(thd, direct_dup_insert));
2015}
2016
2017static uint spider_udf_table_lock_mutex_count;
2018/*
2019 1-: mutex count
2020 */
2021static MYSQL_SYSVAR_UINT(
2022 udf_table_lock_mutex_count,
2023 spider_udf_table_lock_mutex_count,
2024 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
2025 "Mutex count of table lock for Spider UDFs",
2026 NULL,
2027 NULL,
2028 20,
2029 1,
2030 4294967295U,
2031 0
2032);
2033
2034uint spider_param_udf_table_lock_mutex_count()
2035{
2036 DBUG_ENTER("spider_param_udf_table_lock_mutex_count");
2037 DBUG_RETURN(spider_udf_table_lock_mutex_count);
2038}
2039
2040static uint spider_udf_table_mon_mutex_count;
2041/*
2042 1-: mutex count
2043 */
2044static MYSQL_SYSVAR_UINT(
2045 udf_table_mon_mutex_count,
2046 spider_udf_table_mon_mutex_count,
2047 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
2048 "Mutex count of table mon for Spider UDFs",
2049 NULL,
2050 NULL,
2051 20,
2052 1,
2053 4294967295U,
2054 0
2055);
2056
2057uint spider_param_udf_table_mon_mutex_count()
2058{
2059 DBUG_ENTER("spider_param_udf_table_mon_mutex_count");
2060 DBUG_RETURN(spider_udf_table_mon_mutex_count);
2061}
2062
2063/*
2064 1-:number of rows
2065 */
2066static MYSQL_THDVAR_LONGLONG(
2067 udf_ds_bulk_insert_rows, /* name */
2068 PLUGIN_VAR_RQCMDARG, /* opt */
2069 "Number of rows for bulk inserting", /* comment */
2070 NULL, /* check */
2071 NULL, /* update */
2072 -1, /* def */
2073 -1, /* min */
2074 9223372036854775807LL, /* max */
2075 0 /* blk */
2076);
2077
2078longlong spider_param_udf_ds_bulk_insert_rows(
2079 THD *thd,
2080 longlong udf_ds_bulk_insert_rows
2081) {
2082 DBUG_ENTER("spider_param_udf_ds_bulk_insert_rows");
2083 DBUG_RETURN(THDVAR(thd, udf_ds_bulk_insert_rows) <= 0 ?
2084 udf_ds_bulk_insert_rows : THDVAR(thd, udf_ds_bulk_insert_rows));
2085}
2086
2087/*
2088 -1 :use table parameter
2089 0 :drop records
2090 1 :insert last table
2091 2 :insert first table and loop again
2092 */
2093static MYSQL_THDVAR_INT(
2094 udf_ds_table_loop_mode, /* name */
2095 PLUGIN_VAR_RQCMDARG, /* opt */
2096 "Table loop mode if the number of tables in table list are less than the number of result sets", /* comment */
2097 NULL, /* check */
2098 NULL, /* update */
2099 -1, /* def */
2100 -1, /* min */
2101 2, /* max */
2102 0 /* blk */
2103);
2104
2105int spider_param_udf_ds_table_loop_mode(
2106 THD *thd,
2107 int udf_ds_table_loop_mode
2108) {
2109 DBUG_ENTER("spider_param_udf_ds_table_loop_mode");
2110 DBUG_RETURN(THDVAR(thd, udf_ds_table_loop_mode) == -1 ?
2111 udf_ds_table_loop_mode : THDVAR(thd, udf_ds_table_loop_mode));
2112}
2113
2114static char *spider_remote_access_charset;
2115/*
2116 */
2117#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
2118static MYSQL_SYSVAR_STR(
2119 remote_access_charset,
2120 spider_remote_access_charset,
2121 PLUGIN_VAR_MEMALLOC |
2122 PLUGIN_VAR_RQCMDARG,
2123 "Set remote access charset at connecting for improvement performance of connection if you know",
2124 NULL,
2125 NULL,
2126 NULL
2127);
2128#else
2129#ifdef PLUGIN_VAR_CAN_MEMALLOC
2130static MYSQL_SYSVAR_STR(
2131 remote_access_charset,
2132 spider_remote_access_charset,
2133 PLUGIN_VAR_MEMALLOC |
2134 PLUGIN_VAR_RQCMDARG,
2135 "Set remote access charset at connecting for improvement performance of connection if you know",
2136 NULL,
2137 NULL,
2138 NULL
2139);
2140#else
2141static MYSQL_SYSVAR_STR(
2142 remote_access_charset,
2143 spider_remote_access_charset,
2144 PLUGIN_VAR_RQCMDARG,
2145 "Set remote access charset at connecting for improvement performance of connection if you know",
2146 NULL,
2147 NULL,
2148 NULL
2149);
2150#endif
2151#endif
2152
2153char *spider_param_remote_access_charset()
2154{
2155 DBUG_ENTER("spider_param_remote_access_charset");
2156 DBUG_RETURN(spider_remote_access_charset);
2157}
2158
2159static int spider_remote_autocommit;
2160/*
2161 -1 :don't set
2162 0 :autocommit = 0
2163 1 :autocommit = 1
2164 */
2165static MYSQL_SYSVAR_INT(
2166 remote_autocommit,
2167 spider_remote_autocommit,
2168 PLUGIN_VAR_RQCMDARG,
2169 "Set autocommit mode at connecting for improvement performance of connection if you know",
2170 NULL,
2171 NULL,
2172 -1,
2173 -1,
2174 1,
2175 0
2176);
2177
2178int spider_param_remote_autocommit()
2179{
2180 DBUG_ENTER("spider_param_remote_autocommit");
2181 DBUG_RETURN(spider_remote_autocommit);
2182}
2183
2184static char *spider_remote_time_zone;
2185/*
2186 */
2187#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
2188static MYSQL_SYSVAR_STR(
2189 remote_time_zone,
2190 spider_remote_time_zone,
2191 PLUGIN_VAR_MEMALLOC |
2192 PLUGIN_VAR_RQCMDARG,
2193 "Set remote time_zone at connecting for improvement performance of connection if you know",
2194 NULL,
2195 NULL,
2196 NULL
2197);
2198#else
2199#ifdef PLUGIN_VAR_CAN_MEMALLOC
2200static MYSQL_SYSVAR_STR(
2201 remote_time_zone,
2202 spider_remote_time_zone,
2203 PLUGIN_VAR_MEMALLOC |
2204 PLUGIN_VAR_RQCMDARG,
2205 "Set remote time_zone at connecting for improvement performance of connection if you know",
2206 NULL,
2207 NULL,
2208 NULL
2209);
2210#else
2211static MYSQL_SYSVAR_STR(
2212 remote_time_zone,
2213 spider_remote_time_zone,
2214 PLUGIN_VAR_RQCMDARG,
2215 "Set remote time_zone at connecting for improvement performance of connection if you know",
2216 NULL,
2217 NULL,
2218 NULL
2219);
2220#endif
2221#endif
2222
2223char *spider_param_remote_time_zone()
2224{
2225 DBUG_ENTER("spider_param_remote_time_zone");
2226 DBUG_RETURN(spider_remote_time_zone);
2227}
2228
2229static int spider_remote_sql_log_off;
2230/*
2231 -1 :don't know the value on all data nodes, or does not matter
2232 0 :sql_log_off = 0 on all data nodes
2233 1 :sql_log_off = 1 on all data nodes
2234 */
2235static MYSQL_SYSVAR_INT(
2236 remote_sql_log_off,
2237 spider_remote_sql_log_off,
2238 PLUGIN_VAR_RQCMDARG,
2239 "Set SQL_LOG_OFF mode on connecting for improved performance of connection, if you know",
2240 NULL,
2241 NULL,
2242 -1,
2243 -1,
2244 1,
2245 0
2246);
2247
2248int spider_param_remote_sql_log_off()
2249{
2250 DBUG_ENTER("spider_param_remote_sql_log_off");
2251 DBUG_RETURN(spider_remote_sql_log_off);
2252}
2253
2254static int spider_remote_trx_isolation;
2255/*
2256 -1 :don't set
2257 0 :READ UNCOMMITTED
2258 1 :READ COMMITTED
2259 2 :REPEATABLE READ
2260 3 :SERIALIZABLE
2261 */
2262static MYSQL_SYSVAR_INT(
2263 remote_trx_isolation,
2264 spider_remote_trx_isolation,
2265 PLUGIN_VAR_RQCMDARG,
2266 "Set transaction isolation level at connecting for improvement performance of connection if you know",
2267 NULL,
2268 NULL,
2269 -1,
2270 -1,
2271 3,
2272 0
2273);
2274
2275int spider_param_remote_trx_isolation()
2276{
2277 DBUG_ENTER("spider_param_remote_trx_isolation");
2278 DBUG_RETURN(spider_remote_trx_isolation);
2279}
2280
2281static char *spider_remote_default_database;
2282/*
2283 */
2284#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
2285static MYSQL_SYSVAR_STR(
2286 remote_default_database,
2287 spider_remote_default_database,
2288 PLUGIN_VAR_MEMALLOC |
2289 PLUGIN_VAR_RQCMDARG,
2290 "Set remote database at connecting for improvement performance of connection if you know",
2291 NULL,
2292 NULL,
2293 NULL
2294);
2295#else
2296#ifdef PLUGIN_VAR_CAN_MEMALLOC
2297static MYSQL_SYSVAR_STR(
2298 remote_default_database,
2299 spider_remote_default_database,
2300 PLUGIN_VAR_MEMALLOC |
2301 PLUGIN_VAR_RQCMDARG,
2302 "Set remote database at connecting for improvement performance of connection if you know",
2303 NULL,
2304 NULL,
2305 NULL
2306);
2307#else
2308static MYSQL_SYSVAR_STR(
2309 remote_default_database,
2310 spider_remote_default_database,
2311 PLUGIN_VAR_RQCMDARG,
2312 "Set remote database at connecting for improvement performance of connection if you know",
2313 NULL,
2314 NULL,
2315 NULL
2316);
2317#endif
2318#endif
2319
2320char *spider_param_remote_default_database()
2321{
2322 DBUG_ENTER("spider_param_remote_default_database");
2323 DBUG_RETURN(spider_remote_default_database);
2324}
2325
2326/*
2327 0-:connect retry interval (micro second)
2328 */
2329static MYSQL_THDVAR_LONGLONG(
2330 connect_retry_interval, /* name */
2331 PLUGIN_VAR_RQCMDARG, /* opt */
2332 "Connect retry interval", /* comment */
2333 NULL, /* check */
2334 NULL, /* update */
2335 1000, /* def */
2336 0, /* min */
2337 9223372036854775807LL, /* max */
2338 0 /* blk */
2339);
2340
2341longlong spider_param_connect_retry_interval(
2342 THD *thd
2343) {
2344 DBUG_ENTER("spider_param_connect_retry_interval");
2345 if (thd)
2346 DBUG_RETURN(THDVAR(thd, connect_retry_interval));
2347 DBUG_RETURN(0);
2348}
2349
2350/*
2351 0-:connect retry count
2352 */
2353static MYSQL_THDVAR_INT(
2354 connect_retry_count, /* name */
2355 PLUGIN_VAR_RQCMDARG, /* opt */
2356 "Connect retry count", /* comment */
2357 NULL, /* check */
2358 NULL, /* update */
2359 1000, /* def */
2360 0, /* min */
2361 2147483647, /* max */
2362 0 /* blk */
2363);
2364
2365int spider_param_connect_retry_count(
2366 THD *thd
2367) {
2368 DBUG_ENTER("spider_param_connect_retry_count");
2369 if (thd)
2370 DBUG_RETURN(THDVAR(thd, connect_retry_count));
2371 DBUG_RETURN(0);
2372}
2373
2374/*
2375 */
2376#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
2377static MYSQL_THDVAR_STR(
2378 bka_engine, /* name */
2379 PLUGIN_VAR_MEMALLOC |
2380 PLUGIN_VAR_RQCMDARG,
2381 "Temporary table's engine for BKA", /* comment */
2382 NULL, /* check */
2383 NULL, /* update */
2384 NULL /* def */
2385);
2386#else
2387#ifdef PLUGIN_VAR_CAN_MEMALLOC
2388static MYSQL_THDVAR_STR(
2389 bka_engine, /* name */
2390 PLUGIN_VAR_MEMALLOC |
2391 PLUGIN_VAR_RQCMDARG,
2392 "Temporary table's engine for BKA", /* comment */
2393 NULL, /* check */
2394 NULL, /* update */
2395 NULL /* def */
2396);
2397#else
2398static MYSQL_THDVAR_STR(
2399 bka_engine, /* name */
2400 PLUGIN_VAR_RQCMDARG,
2401 "Temporary table's engine for BKA", /* comment */
2402 NULL, /* check */
2403 NULL, /* update */
2404 NULL /* def */
2405);
2406#endif
2407#endif
2408
2409char *spider_param_bka_engine(
2410 THD *thd,
2411 char *bka_engine
2412) {
2413 DBUG_ENTER("spider_param_bka_engine");
2414 DBUG_RETURN(THDVAR(thd, bka_engine) ?
2415 THDVAR(thd, bka_engine) : bka_engine);
2416}
2417
2418/*
2419 -1 :use table parameter
2420 0 :use union all
2421 1 :use temporary table
2422 */
2423static MYSQL_THDVAR_INT(
2424 bka_mode, /* name */
2425 PLUGIN_VAR_RQCMDARG, /* opt */
2426 "Mode of BKA for Spider", /* comment */
2427 NULL, /* check */
2428 NULL, /* update */
2429 -1, /* def */
2430 -1, /* min */
2431 2, /* max */
2432 0 /* blk */
2433);
2434
2435int spider_param_bka_mode(
2436 THD *thd,
2437 int bka_mode
2438) {
2439 DBUG_ENTER("spider_param_bka_mode");
2440 DBUG_RETURN(THDVAR(thd, bka_mode) == -1 ?
2441 bka_mode : THDVAR(thd, bka_mode));
2442}
2443
2444static int spider_udf_ct_bulk_insert_interval;
2445/*
2446 -1 : The UDF parameter is adopted.
2447 0 or more : Milliseconds.
2448 */
2449static MYSQL_SYSVAR_INT(
2450 udf_ct_bulk_insert_interval,
2451 spider_udf_ct_bulk_insert_interval,
2452 PLUGIN_VAR_RQCMDARG,
2453 "The interval time between bulk insert and next bulk insert at coping",
2454 NULL,
2455 NULL,
2456 -1,
2457 -1,
2458 2147483647,
2459 0
2460);
2461
2462int spider_param_udf_ct_bulk_insert_interval(
2463 int udf_ct_bulk_insert_interval
2464) {
2465 DBUG_ENTER("spider_param_udf_ct_bulk_insert_interval");
2466 DBUG_RETURN(spider_udf_ct_bulk_insert_interval < 0 ?
2467 udf_ct_bulk_insert_interval : spider_udf_ct_bulk_insert_interval);
2468}
2469
2470static longlong spider_udf_ct_bulk_insert_rows;
2471/*
2472 -1,0 : The UDF parameter is adopted.
2473 1 or more : Number of rows.
2474 */
2475static MYSQL_SYSVAR_LONGLONG(
2476 udf_ct_bulk_insert_rows,
2477 spider_udf_ct_bulk_insert_rows,
2478 PLUGIN_VAR_RQCMDARG,
2479 "The number of rows inserted with bulk insert of one time at coping",
2480 NULL,
2481 NULL,
2482 -1,
2483 -1,
2484 9223372036854775807LL,
2485 0
2486);
2487
2488longlong spider_param_udf_ct_bulk_insert_rows(
2489 longlong udf_ct_bulk_insert_rows
2490) {
2491 DBUG_ENTER("spider_param_udf_ct_bulk_insert_rows");
2492 DBUG_RETURN(spider_udf_ct_bulk_insert_rows <= 0 ?
2493 udf_ct_bulk_insert_rows : spider_udf_ct_bulk_insert_rows);
2494}
2495
2496#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
2497/*
2498 0: no recycle
2499 1: recycle in instance
2500 2: recycle in thread
2501 */
2502static MYSQL_THDVAR_UINT(
2503 hs_r_conn_recycle_mode, /* name */
2504 PLUGIN_VAR_RQCMDARG, /* opt */
2505 "Handlersocket connection recycle mode", /* comment */
2506 NULL, /* check */
2507 NULL, /* update */
2508 2, /* def */
2509 0, /* min */
2510 2, /* max */
2511 0 /* blk */
2512);
2513
2514uint spider_param_hs_r_conn_recycle_mode(
2515 THD *thd
2516) {
2517 DBUG_ENTER("spider_param_hs_r_conn_recycle_mode");
2518 DBUG_RETURN(THDVAR(thd, hs_r_conn_recycle_mode));
2519}
2520
2521/*
2522 0: weak
2523 1: strict
2524 */
2525static MYSQL_THDVAR_UINT(
2526 hs_r_conn_recycle_strict, /* name */
2527 PLUGIN_VAR_RQCMDARG, /* opt */
2528 "Strict handlersocket connection recycle", /* comment */
2529 NULL, /* check */
2530 NULL, /* update */
2531 0, /* def */
2532 0, /* min */
2533 1, /* max */
2534 0 /* blk */
2535);
2536
2537uint spider_param_hs_r_conn_recycle_strict(
2538 THD *thd
2539) {
2540 DBUG_ENTER("spider_param_hs_r_conn_recycle_strict");
2541 DBUG_RETURN(THDVAR(thd, hs_r_conn_recycle_strict));
2542}
2543
2544/*
2545 0: no recycle
2546 1: recycle in instance
2547 2: recycle in thread
2548 */
2549static MYSQL_THDVAR_UINT(
2550 hs_w_conn_recycle_mode, /* name */
2551 PLUGIN_VAR_RQCMDARG, /* opt */
2552 "Handlersocket connection recycle mode", /* comment */
2553 NULL, /* check */
2554 NULL, /* update */
2555 2, /* def */
2556 0, /* min */
2557 2, /* max */
2558 0 /* blk */
2559);
2560
2561uint spider_param_hs_w_conn_recycle_mode(
2562 THD *thd
2563) {
2564 DBUG_ENTER("spider_param_hs_w_conn_recycle_mode");
2565 DBUG_RETURN(THDVAR(thd, hs_w_conn_recycle_mode));
2566}
2567
2568/*
2569 0: weak
2570 1: strict
2571 */
2572static MYSQL_THDVAR_UINT(
2573 hs_w_conn_recycle_strict, /* name */
2574 PLUGIN_VAR_RQCMDARG, /* opt */
2575 "Strict handlersocket connection recycle", /* comment */
2576 NULL, /* check */
2577 NULL, /* update */
2578 0, /* def */
2579 0, /* min */
2580 1, /* max */
2581 0 /* blk */
2582);
2583
2584uint spider_param_hs_w_conn_recycle_strict(
2585 THD *thd
2586) {
2587 DBUG_ENTER("spider_param_hs_w_conn_recycle_strict");
2588 DBUG_RETURN(THDVAR(thd, hs_w_conn_recycle_strict));
2589}
2590
2591/*
2592 -1 :use table parameter
2593 0 :not use
2594 1 :use handlersocket
2595 */
2596static MYSQL_THDVAR_INT(
2597 use_hs_read, /* name */
2598 PLUGIN_VAR_RQCMDARG, /* opt */
2599 "Use handlersocket for reading", /* comment */
2600 NULL, /* check */
2601 NULL, /* update */
2602 -1, /* def */
2603 -1, /* min */
2604 1, /* max */
2605 0 /* blk */
2606);
2607
2608int spider_param_use_hs_read(
2609 THD *thd,
2610 int use_hs_read
2611) {
2612 DBUG_ENTER("spider_param_use_hs_read");
2613 DBUG_RETURN(THDVAR(thd, use_hs_read) == -1 ?
2614 use_hs_read : THDVAR(thd, use_hs_read));
2615}
2616
2617/*
2618 -1 :use table parameter
2619 0 :not use
2620 1 :use handlersocket
2621 */
2622static MYSQL_THDVAR_INT(
2623 use_hs_write, /* name */
2624 PLUGIN_VAR_RQCMDARG, /* opt */
2625 "Use handlersocket for writing", /* comment */
2626 NULL, /* check */
2627 NULL, /* update */
2628 -1, /* def */
2629 -1, /* min */
2630 1, /* max */
2631 0 /* blk */
2632);
2633
2634int spider_param_use_hs_write(
2635 THD *thd,
2636 int use_hs_write
2637) {
2638 DBUG_ENTER("spider_param_use_hs_write");
2639 DBUG_RETURN(THDVAR(thd, use_hs_write) == -1 ?
2640 use_hs_write : THDVAR(thd, use_hs_write));
2641}
2642#endif
2643
2644/*
2645 -1 :use table parameter
2646 0 :not use
2647 1 :use handler
2648 */
2649static MYSQL_THDVAR_INT(
2650 use_handler, /* name */
2651 PLUGIN_VAR_RQCMDARG, /* opt */
2652 "Use handler for reading", /* comment */
2653 NULL, /* check */
2654 NULL, /* update */
2655 -1, /* def */
2656 -1, /* min */
2657 3, /* max */
2658 0 /* blk */
2659);
2660
2661int spider_param_use_handler(
2662 THD *thd,
2663 int use_handler
2664) {
2665 DBUG_ENTER("spider_param_use_handler");
2666 DBUG_RETURN(THDVAR(thd, use_handler) == -1 ?
2667 use_handler : THDVAR(thd, use_handler));
2668}
2669
2670/*
2671 -1 :use table parameter
2672 0 :return error if error
2673 1 :return 0 record if error
2674 */
2675static MYSQL_THDVAR_INT(
2676 error_read_mode, /* name */
2677 PLUGIN_VAR_RQCMDARG, /* opt */
2678 "Read error mode if error", /* comment */
2679 NULL, /* check */
2680 NULL, /* update */
2681 -1, /* def */
2682 -1, /* min */
2683 1, /* max */
2684 0 /* blk */
2685);
2686
2687int spider_param_error_read_mode(
2688 THD *thd,
2689 int error_read_mode
2690) {
2691 DBUG_ENTER("spider_param_error_read_mode");
2692 DBUG_RETURN(THDVAR(thd, error_read_mode) == -1 ?
2693 error_read_mode : THDVAR(thd, error_read_mode));
2694}
2695
2696/*
2697 -1 :use table parameter
2698 0 :return error if error
2699 1 :return 0 record if error
2700 */
2701static MYSQL_THDVAR_INT(
2702 error_write_mode, /* name */
2703 PLUGIN_VAR_RQCMDARG, /* opt */
2704 "Write error mode if error", /* comment */
2705 NULL, /* check */
2706 NULL, /* update */
2707 -1, /* def */
2708 -1, /* min */
2709 1, /* max */
2710 0 /* blk */
2711);
2712
2713int spider_param_error_write_mode(
2714 THD *thd,
2715 int error_write_mode
2716) {
2717 DBUG_ENTER("spider_param_error_write_mode");
2718 DBUG_RETURN(THDVAR(thd, error_write_mode) == -1 ?
2719 error_write_mode : THDVAR(thd, error_write_mode));
2720}
2721
2722/*
2723 -1 :use table parameter
2724 0 :not skip
2725 1 :skip
2726 */
2727static MYSQL_THDVAR_INT(
2728 skip_default_condition, /* name */
2729 PLUGIN_VAR_RQCMDARG, /* opt */
2730 "Skip generating internal default condition", /* comment */
2731 NULL, /* check */
2732 NULL, /* update */
2733 -1, /* def */
2734 -1, /* min */
2735 1, /* max */
2736 0 /* blk */
2737);
2738
2739int spider_param_skip_default_condition(
2740 THD *thd,
2741 int skip_default_condition
2742) {
2743 DBUG_ENTER("spider_param_skip_default_condition");
2744 DBUG_RETURN(THDVAR(thd, skip_default_condition) == -1 ?
2745 skip_default_condition : THDVAR(thd, skip_default_condition));
2746}
2747
2748/*
2749 -1 :use table parameter
2750 0 :not skip
2751 1 :skip parallel search if query is not SELECT statement
2752 2 :skip parallel search if query has SQL_NO_CACHE
2753 3 :1+2
2754 */
2755static MYSQL_THDVAR_INT(
2756 skip_parallel_search, /* name */
2757 PLUGIN_VAR_RQCMDARG, /* opt */
2758 "Skip parallel search by specific conditions", /* comment */
2759 NULL, /* check */
2760 NULL, /* update */
2761 -1, /* def */
2762 -1, /* min */
2763 3, /* max */
2764 0 /* blk */
2765);
2766
2767int spider_param_skip_parallel_search(
2768 THD *thd,
2769 int skip_parallel_search
2770) {
2771 DBUG_ENTER("spider_param_skip_parallel_search");
2772 DBUG_RETURN(THDVAR(thd, skip_parallel_search) == -1 ?
2773 skip_parallel_search : THDVAR(thd, skip_parallel_search));
2774}
2775
2776/*
2777 -1 :use table parameter
2778 0 :not send directly
2779 1-:send directly
2780 */
2781static MYSQL_THDVAR_LONGLONG(
2782 direct_order_limit, /* name */
2783 PLUGIN_VAR_RQCMDARG, /* opt */
2784 "Send 'ORDER BY' and 'LIMIT' to remote server directly", /* comment */
2785 NULL, /* check */
2786 NULL, /* update */
2787 -1, /* def */
2788 -1, /* min */
2789 9223372036854775807LL, /* max */
2790 0 /* blk */
2791);
2792
2793longlong spider_param_direct_order_limit(
2794 THD *thd,
2795 longlong direct_order_limit
2796) {
2797 DBUG_ENTER("spider_param_direct_order_limit");
2798 DBUG_RETURN(THDVAR(thd, direct_order_limit) == -1 ?
2799 direct_order_limit : THDVAR(thd, direct_order_limit));
2800}
2801
2802/*
2803 -1 :use table parameter
2804 0 :writable
2805 1 :read only
2806 */
2807static MYSQL_THDVAR_INT(
2808 read_only_mode, /* name */
2809 PLUGIN_VAR_RQCMDARG, /* opt */
2810 "Read only", /* comment */
2811 NULL, /* check */
2812 NULL, /* update */
2813 -1, /* def */
2814 -1, /* min */
2815 1, /* max */
2816 0 /* blk */
2817);
2818
2819int spider_param_read_only_mode(
2820 THD *thd,
2821 int read_only_mode
2822) {
2823 DBUG_ENTER("spider_param_read_only_mode");
2824 DBUG_RETURN(THDVAR(thd, read_only_mode) == -1 ?
2825 read_only_mode : THDVAR(thd, read_only_mode));
2826}
2827
2828#ifdef HA_CAN_BULK_ACCESS
2829static int spider_bulk_access_free;
2830/*
2831 -1 :use table parameter
2832 0 :in reset
2833 1 :in close
2834 */
2835static MYSQL_SYSVAR_INT(
2836 bulk_access_free,
2837 spider_bulk_access_free,
2838 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
2839 "Free mode of bulk access resources",
2840 NULL,
2841 NULL,
2842 -1,
2843 -1,
2844 1,
2845 0
2846);
2847
2848int spider_param_bulk_access_free(
2849 int bulk_access_free
2850) {
2851 DBUG_ENTER("spider_param_bulk_access_free");
2852 DBUG_RETURN(spider_bulk_access_free == -1 ?
2853 bulk_access_free : spider_bulk_access_free);
2854}
2855#endif
2856
2857#if MYSQL_VERSION_ID < 50500
2858#else
2859/*
2860 -1 :use UDF parameter
2861 0 :can not use
2862 1 :can use
2863 */
2864static MYSQL_THDVAR_INT(
2865 udf_ds_use_real_table, /* name */
2866 PLUGIN_VAR_RQCMDARG, /* opt */
2867 "Use real table for temporary table list", /* comment */
2868 NULL, /* check */
2869 NULL, /* update */
2870 -1, /* def */
2871 -1, /* min */
2872 1, /* max */
2873 0 /* blk */
2874);
2875
2876int spider_param_udf_ds_use_real_table(
2877 THD *thd,
2878 int udf_ds_use_real_table
2879) {
2880 DBUG_ENTER("spider_param_udf_ds_use_real_table");
2881 DBUG_RETURN(THDVAR(thd, udf_ds_use_real_table) == -1 ?
2882 udf_ds_use_real_table : THDVAR(thd, udf_ds_use_real_table));
2883}
2884#endif
2885
2886static my_bool spider_general_log;
2887static MYSQL_SYSVAR_BOOL(
2888 general_log,
2889 spider_general_log,
2890 PLUGIN_VAR_OPCMDARG,
2891 "Log query to remote server in general log",
2892 NULL,
2893 NULL,
2894 FALSE
2895);
2896
2897my_bool spider_param_general_log()
2898{
2899 DBUG_ENTER("spider_param_general_log");
2900 DBUG_RETURN(spider_general_log);
2901}
2902
2903/*
2904 FALSE: no pushdown hints
2905 TRUE: pushdown hints
2906 */
2907static MYSQL_THDVAR_BOOL(
2908 index_hint_pushdown, /* name */
2909 PLUGIN_VAR_OPCMDARG, /* opt */
2910 "switch to control if push down index hint, like force_index", /* comment */
2911 NULL, /* check */
2912 NULL, /* update */
2913 FALSE /* def */
2914);
2915
2916my_bool spider_param_index_hint_pushdown(
2917 THD *thd
2918) {
2919 DBUG_ENTER("spider_param_index_hint_pushdown");
2920 DBUG_RETURN(THDVAR(thd, index_hint_pushdown));
2921}
2922
2923static uint spider_max_connections;
2924static MYSQL_SYSVAR_UINT(
2925 max_connections,
2926 spider_max_connections,
2927 PLUGIN_VAR_RQCMDARG,
2928 "the values, as the max conncetion from spider to remote mysql. Default 0, mean unlimit the connections",
2929 NULL,
2930 NULL,
2931 0, /* def */
2932 0, /* min */
2933 99999, /* max */
2934 0 /* blk */
2935);
2936
2937uint spider_param_max_connections()
2938{
2939 DBUG_ENTER("spider_param_max_connections");
2940 DBUG_RETURN(spider_max_connections);
2941}
2942
2943static uint spider_conn_wait_timeout;
2944static MYSQL_SYSVAR_UINT(
2945 conn_wait_timeout,
2946 spider_conn_wait_timeout,
2947 PLUGIN_VAR_RQCMDARG,
2948 "the values, as the max waiting time when spider get a remote conn",
2949 NULL,
2950 NULL,
2951 10, /* def */
2952 0, /* min */
2953 1000, /* max */
2954 0 /* blk */
2955);
2956
2957uint spider_param_conn_wait_timeout()
2958{
2959 DBUG_ENTER("spider_param_conn_wait_timeout");
2960 DBUG_RETURN(spider_conn_wait_timeout);
2961}
2962
2963static uint spider_log_result_errors;
2964/*
2965 0: no log
2966 1: log error
2967 2: log warning summary
2968 3: log warning
2969 4: log info
2970 */
2971static MYSQL_SYSVAR_UINT(
2972 log_result_errors,
2973 spider_log_result_errors,
2974 PLUGIN_VAR_RQCMDARG,
2975 "Log error from remote server in error log",
2976 NULL,
2977 NULL,
2978 0,
2979 0,
2980 4,
2981 0
2982);
2983
2984uint spider_param_log_result_errors()
2985{
2986 DBUG_ENTER("spider_param_log_result_errors");
2987 DBUG_RETURN(spider_log_result_errors);
2988}
2989
2990static uint spider_log_result_error_with_sql;
2991/*
2992 0: no log
2993 1: log spider sql at logging result errors
2994 2: log user sql at logging result errors
2995 3: log both sql at logging result errors
2996 */
2997static MYSQL_SYSVAR_UINT(
2998 log_result_error_with_sql,
2999 spider_log_result_error_with_sql,
3000 PLUGIN_VAR_RQCMDARG,
3001 "Log sql at logging result errors",
3002 NULL,
3003 NULL,
3004 0,
3005 0,
3006 3,
3007 0
3008);
3009
3010uint spider_param_log_result_error_with_sql()
3011{
3012 DBUG_ENTER("spider_param_log_result_error_with_sql");
3013 DBUG_RETURN(spider_log_result_error_with_sql);
3014}
3015
3016static char *spider_version = (char *) SPIDER_DETAIL_VERSION;
3017static MYSQL_SYSVAR_STR(
3018 version,
3019 spider_version,
3020 PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
3021 "The version of Spider",
3022 NULL,
3023 NULL,
3024 SPIDER_DETAIL_VERSION
3025);
3026
3027/*
3028 0: server_id + thread_id
3029 1: server_id + thread_id + query_id
3030 */
3031static MYSQL_THDVAR_UINT(
3032 internal_xa_id_type, /* name */
3033 PLUGIN_VAR_RQCMDARG, /* opt */
3034 "The type of internal_xa id", /* comment */
3035 NULL, /* check */
3036 NULL, /* update */
3037 0, /* def */
3038 0, /* min */
3039 1, /* max */
3040 0 /* blk */
3041);
3042
3043uint spider_param_internal_xa_id_type(
3044 THD *thd
3045) {
3046 DBUG_ENTER("spider_param_internal_xa_id_type");
3047 DBUG_RETURN(THDVAR(thd, internal_xa_id_type));
3048}
3049
3050/*
3051 -1 :use table parameter
3052 0 :OFF
3053 1 :automatic channel
3054 2-63 :use custom channel
3055 */
3056static MYSQL_THDVAR_INT(
3057 casual_read, /* name */
3058 PLUGIN_VAR_RQCMDARG, /* opt */
3059 "Read casually if it is possible", /* comment */
3060 NULL, /* check */
3061 NULL, /* update */
3062 -1, /* def */
3063 -1, /* min */
3064 63, /* max */
3065 0 /* blk */
3066);
3067
3068int spider_param_casual_read(
3069 THD *thd,
3070 int casual_read
3071) {
3072 DBUG_ENTER("spider_param_casual_read");
3073 DBUG_RETURN(THDVAR(thd, casual_read) == -1 ?
3074 casual_read : THDVAR(thd, casual_read));
3075}
3076
3077static my_bool spider_dry_access;
3078static MYSQL_SYSVAR_BOOL(
3079 dry_access,
3080 spider_dry_access,
3081 PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
3082 "dry access",
3083 NULL,
3084 NULL,
3085 FALSE
3086);
3087
3088my_bool spider_param_dry_access()
3089{
3090 DBUG_ENTER("spider_param_dry_access");
3091 DBUG_RETURN(spider_dry_access);
3092}
3093
3094/*
3095 -1 :use table parameter
3096 0 :fast
3097 1 :correct delete row number
3098 */
3099static MYSQL_THDVAR_INT(
3100 delete_all_rows_type, /* name */
3101 PLUGIN_VAR_RQCMDARG, /* opt */
3102 "The type of delete_all_rows", /* comment */
3103 NULL, /* check */
3104 NULL, /* update */
3105 -1, /* def */
3106 -1, /* min */
3107 1, /* max */
3108 0 /* blk */
3109);
3110
3111int spider_param_delete_all_rows_type(
3112 THD *thd,
3113 int delete_all_rows_type
3114) {
3115 DBUG_ENTER("spider_param_delete_all_rows_type");
3116 DBUG_RETURN(THDVAR(thd, delete_all_rows_type) == -1 ?
3117 delete_all_rows_type : THDVAR(thd, delete_all_rows_type));
3118}
3119
3120/*
3121 -1 :use table parameter
3122 0 :compact
3123 1 :add original table name
3124 */
3125static MYSQL_THDVAR_INT(
3126 bka_table_name_type, /* name */
3127 PLUGIN_VAR_RQCMDARG, /* opt */
3128 "The type of temporary table name for bka", /* comment */
3129 NULL, /* check */
3130 NULL, /* update */
3131 -1, /* def */
3132 -1, /* min */
3133 1, /* max */
3134 0 /* blk */
3135);
3136
3137int spider_param_bka_table_name_type(
3138 THD *thd,
3139 int bka_table_name_type
3140) {
3141 DBUG_ENTER("spider_param_bka_table_name_type");
3142 DBUG_RETURN(THDVAR(thd, bka_table_name_type) == -1 ?
3143 bka_table_name_type : THDVAR(thd, bka_table_name_type));
3144}
3145
3146static int spider_store_last_sts;
3147/*
3148 -1 : use table parameter
3149 0 : do not store
3150 1 : do store
3151 */
3152static MYSQL_SYSVAR_INT(
3153 store_last_sts,
3154 spider_store_last_sts,
3155 PLUGIN_VAR_RQCMDARG,
3156 "Store last sts result into system table",
3157 NULL,
3158 NULL,
3159 -1,
3160 -1,
3161 1,
3162 0
3163);
3164
3165int spider_param_store_last_sts(
3166 int store_last_sts
3167) {
3168 DBUG_ENTER("spider_param_store_last_sts");
3169 DBUG_RETURN(spider_store_last_sts == -1 ?
3170 store_last_sts : spider_store_last_sts);
3171}
3172
3173static int spider_store_last_crd;
3174/*
3175 -1 : use table parameter
3176 0 : do not store
3177 1 : do store
3178 */
3179static MYSQL_SYSVAR_INT(
3180 store_last_crd,
3181 spider_store_last_crd,
3182 PLUGIN_VAR_RQCMDARG,
3183 "Store last crd result into system table",
3184 NULL,
3185 NULL,
3186 -1,
3187 -1,
3188 1,
3189 0
3190);
3191
3192int spider_param_store_last_crd(
3193 int store_last_crd
3194) {
3195 DBUG_ENTER("spider_param_store_last_crd");
3196 DBUG_RETURN(spider_store_last_crd == -1 ?
3197 store_last_crd : spider_store_last_crd);
3198}
3199
3200static int spider_load_sts_at_startup;
3201/*
3202 -1 : use table parameter
3203 0 : do not load
3204 1 : do load
3205 */
3206static MYSQL_SYSVAR_INT(
3207 load_sts_at_startup,
3208 spider_load_sts_at_startup,
3209 PLUGIN_VAR_RQCMDARG,
3210 "Load sts from system table at startup",
3211 NULL,
3212 NULL,
3213 -1,
3214 -1,
3215 1,
3216 0
3217);
3218
3219int spider_param_load_sts_at_startup(
3220 int load_sts_at_startup
3221) {
3222 DBUG_ENTER("spider_param_load_sts_at_startup");
3223 DBUG_RETURN(spider_load_sts_at_startup == -1 ?
3224 load_sts_at_startup : spider_load_sts_at_startup);
3225}
3226
3227static int spider_load_crd_at_startup;
3228/*
3229 -1 : use table parameter
3230 0 : do not load
3231 1 : do load
3232 */
3233static MYSQL_SYSVAR_INT(
3234 load_crd_at_startup,
3235 spider_load_crd_at_startup,
3236 PLUGIN_VAR_RQCMDARG,
3237 "Load crd from system table at startup",
3238 NULL,
3239 NULL,
3240 -1,
3241 -1,
3242 1,
3243 0
3244);
3245
3246int spider_param_load_crd_at_startup(
3247 int load_crd_at_startup
3248) {
3249 DBUG_ENTER("spider_param_load_crd_at_startup");
3250 DBUG_RETURN(spider_load_crd_at_startup == -1 ?
3251 load_crd_at_startup : spider_load_crd_at_startup);
3252}
3253
3254#ifndef WITHOUT_SPIDER_BG_SEARCH
3255static uint spider_table_sts_thread_count;
3256/*
3257 1-: thread count
3258 */
3259static MYSQL_SYSVAR_UINT(
3260 table_sts_thread_count,
3261 spider_table_sts_thread_count,
3262 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3263 "Static thread count of table sts",
3264 NULL,
3265 NULL,
3266 10,
3267 1,
3268 4294967295U,
3269 0
3270);
3271
3272uint spider_param_table_sts_thread_count()
3273{
3274 DBUG_ENTER("spider_param_table_sts_thread_count");
3275 DBUG_RETURN(spider_table_sts_thread_count);
3276}
3277
3278static uint spider_table_crd_thread_count;
3279/*
3280 1-: thread count
3281 */
3282static MYSQL_SYSVAR_UINT(
3283 table_crd_thread_count,
3284 spider_table_crd_thread_count,
3285 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
3286 "Static thread count of table crd",
3287 NULL,
3288 NULL,
3289 10,
3290 1,
3291 4294967295U,
3292 0
3293);
3294
3295uint spider_param_table_crd_thread_count()
3296{
3297 DBUG_ENTER("spider_param_table_crd_thread_count");
3298 DBUG_RETURN(spider_table_crd_thread_count);
3299}
3300#endif
3301
3302static struct st_mysql_storage_engine spider_storage_engine =
3303{ MYSQL_HANDLERTON_INTERFACE_VERSION };
3304
3305static struct st_mysql_sys_var* spider_system_variables[] = {
3306 MYSQL_SYSVAR(support_xa),
3307 MYSQL_SYSVAR(table_init_error_interval),
3308 MYSQL_SYSVAR(use_table_charset),
3309 MYSQL_SYSVAR(conn_recycle_mode),
3310 MYSQL_SYSVAR(conn_recycle_strict),
3311 MYSQL_SYSVAR(sync_trx_isolation),
3312 MYSQL_SYSVAR(use_consistent_snapshot),
3313 MYSQL_SYSVAR(internal_xa),
3314 MYSQL_SYSVAR(internal_xa_snapshot),
3315 MYSQL_SYSVAR(force_commit),
3316 MYSQL_SYSVAR(xa_register_mode),
3317 MYSQL_SYSVAR(internal_offset),
3318 MYSQL_SYSVAR(internal_limit),
3319 MYSQL_SYSVAR(split_read),
3320 MYSQL_SYSVAR(semi_split_read),
3321 MYSQL_SYSVAR(semi_split_read_limit),
3322 MYSQL_SYSVAR(init_sql_alloc_size),
3323 MYSQL_SYSVAR(reset_sql_alloc),
3324#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
3325 MYSQL_SYSVAR(hs_result_free_size),
3326#endif
3327 MYSQL_SYSVAR(multi_split_read),
3328 MYSQL_SYSVAR(max_order),
3329 MYSQL_SYSVAR(semi_trx_isolation),
3330 MYSQL_SYSVAR(semi_table_lock),
3331 MYSQL_SYSVAR(semi_table_lock_connection),
3332 MYSQL_SYSVAR(block_size),
3333 MYSQL_SYSVAR(selupd_lock_mode),
3334 MYSQL_SYSVAR(sync_autocommit),
3335 MYSQL_SYSVAR(sync_time_zone),
3336 MYSQL_SYSVAR(use_default_database),
3337 MYSQL_SYSVAR(internal_sql_log_off),
3338 MYSQL_SYSVAR(bulk_size),
3339 MYSQL_SYSVAR(bulk_update_mode),
3340 MYSQL_SYSVAR(bulk_update_size),
3341 MYSQL_SYSVAR(internal_optimize),
3342 MYSQL_SYSVAR(internal_optimize_local),
3343 MYSQL_SYSVAR(use_flash_logs),
3344 MYSQL_SYSVAR(use_snapshot_with_flush_tables),
3345 MYSQL_SYSVAR(use_all_conns_snapshot),
3346 MYSQL_SYSVAR(lock_exchange),
3347 MYSQL_SYSVAR(internal_unlock),
3348 MYSQL_SYSVAR(semi_trx),
3349 MYSQL_SYSVAR(connect_timeout),
3350 MYSQL_SYSVAR(net_read_timeout),
3351 MYSQL_SYSVAR(net_write_timeout),
3352 MYSQL_SYSVAR(quick_mode),
3353 MYSQL_SYSVAR(quick_page_size),
3354 MYSQL_SYSVAR(low_mem_read),
3355 MYSQL_SYSVAR(select_column_mode),
3356#ifndef WITHOUT_SPIDER_BG_SEARCH
3357 MYSQL_SYSVAR(bgs_mode),
3358 MYSQL_SYSVAR(bgs_first_read),
3359 MYSQL_SYSVAR(bgs_second_read),
3360#endif
3361 MYSQL_SYSVAR(first_read),
3362 MYSQL_SYSVAR(second_read),
3363 MYSQL_SYSVAR(crd_interval),
3364 MYSQL_SYSVAR(crd_mode),
3365#ifdef WITH_PARTITION_STORAGE_ENGINE
3366 MYSQL_SYSVAR(crd_sync),
3367#endif
3368 MYSQL_SYSVAR(store_last_crd),
3369 MYSQL_SYSVAR(load_crd_at_startup),
3370 MYSQL_SYSVAR(crd_type),
3371 MYSQL_SYSVAR(crd_weight),
3372#ifndef WITHOUT_SPIDER_BG_SEARCH
3373 MYSQL_SYSVAR(crd_bg_mode),
3374#endif
3375 MYSQL_SYSVAR(sts_interval),
3376 MYSQL_SYSVAR(sts_mode),
3377#ifdef WITH_PARTITION_STORAGE_ENGINE
3378 MYSQL_SYSVAR(sts_sync),
3379#endif
3380 MYSQL_SYSVAR(store_last_sts),
3381 MYSQL_SYSVAR(load_sts_at_startup),
3382#ifndef WITHOUT_SPIDER_BG_SEARCH
3383 MYSQL_SYSVAR(sts_bg_mode),
3384#endif
3385 MYSQL_SYSVAR(ping_interval_at_trx_start),
3386#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
3387 MYSQL_SYSVAR(hs_ping_interval),
3388#endif
3389 MYSQL_SYSVAR(auto_increment_mode),
3390 MYSQL_SYSVAR(same_server_link),
3391 MYSQL_SYSVAR(local_lock_table),
3392 MYSQL_SYSVAR(use_pushdown_udf),
3393 MYSQL_SYSVAR(direct_dup_insert),
3394 MYSQL_SYSVAR(udf_table_lock_mutex_count),
3395 MYSQL_SYSVAR(udf_table_mon_mutex_count),
3396 MYSQL_SYSVAR(udf_ds_bulk_insert_rows),
3397 MYSQL_SYSVAR(udf_ds_table_loop_mode),
3398 MYSQL_SYSVAR(remote_access_charset),
3399 MYSQL_SYSVAR(remote_autocommit),
3400 MYSQL_SYSVAR(remote_time_zone),
3401 MYSQL_SYSVAR(remote_sql_log_off),
3402 MYSQL_SYSVAR(remote_trx_isolation),
3403 MYSQL_SYSVAR(remote_default_database),
3404 MYSQL_SYSVAR(connect_retry_interval),
3405 MYSQL_SYSVAR(connect_retry_count),
3406 MYSQL_SYSVAR(connect_mutex),
3407 MYSQL_SYSVAR(bka_engine),
3408 MYSQL_SYSVAR(bka_mode),
3409 MYSQL_SYSVAR(udf_ct_bulk_insert_interval),
3410 MYSQL_SYSVAR(udf_ct_bulk_insert_rows),
3411#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
3412 MYSQL_SYSVAR(hs_r_conn_recycle_mode),
3413 MYSQL_SYSVAR(hs_r_conn_recycle_strict),
3414 MYSQL_SYSVAR(hs_w_conn_recycle_mode),
3415 MYSQL_SYSVAR(hs_w_conn_recycle_strict),
3416 MYSQL_SYSVAR(use_hs_read),
3417 MYSQL_SYSVAR(use_hs_write),
3418#endif
3419 MYSQL_SYSVAR(use_handler),
3420 MYSQL_SYSVAR(error_read_mode),
3421 MYSQL_SYSVAR(error_write_mode),
3422 MYSQL_SYSVAR(skip_default_condition),
3423 MYSQL_SYSVAR(skip_parallel_search),
3424 MYSQL_SYSVAR(direct_order_limit),
3425 MYSQL_SYSVAR(read_only_mode),
3426#ifdef HA_CAN_BULK_ACCESS
3427 MYSQL_SYSVAR(bulk_access_free),
3428#endif
3429#if MYSQL_VERSION_ID < 50500
3430#else
3431 MYSQL_SYSVAR(udf_ds_use_real_table),
3432#endif
3433 MYSQL_SYSVAR(general_log),
3434 MYSQL_SYSVAR(index_hint_pushdown),
3435 MYSQL_SYSVAR(max_connections),
3436 MYSQL_SYSVAR(conn_wait_timeout),
3437 MYSQL_SYSVAR(log_result_errors),
3438 MYSQL_SYSVAR(log_result_error_with_sql),
3439 MYSQL_SYSVAR(version),
3440 MYSQL_SYSVAR(internal_xa_id_type),
3441 MYSQL_SYSVAR(casual_read),
3442 MYSQL_SYSVAR(dry_access),
3443 MYSQL_SYSVAR(delete_all_rows_type),
3444 MYSQL_SYSVAR(bka_table_name_type),
3445 MYSQL_SYSVAR(connect_error_interval),
3446#ifndef WITHOUT_SPIDER_BG_SEARCH
3447 MYSQL_SYSVAR(table_sts_thread_count),
3448 MYSQL_SYSVAR(table_crd_thread_count),
3449#endif
3450 NULL
3451};
3452
3453mysql_declare_plugin(spider)
3454{
3455 MYSQL_STORAGE_ENGINE_PLUGIN,
3456 &spider_storage_engine,
3457 "SPIDER",
3458 "Kentoku Shiba",
3459 "Spider storage engine",
3460 PLUGIN_LICENSE_GPL,
3461 spider_db_init,
3462 spider_db_done,
3463 SPIDER_HEX_VERSION,
3464 spider_status_variables,
3465 spider_system_variables,
3466 NULL,
3467#if MYSQL_VERSION_ID >= 50600
3468 0,
3469#endif
3470},
3471spider_i_s_alloc_mem
3472mysql_declare_plugin_end;
3473
3474#ifdef MARIADB_BASE_VERSION
3475maria_declare_plugin(spider)
3476{
3477 MYSQL_STORAGE_ENGINE_PLUGIN,
3478 &spider_storage_engine,
3479 "SPIDER",
3480 "Kentoku Shiba",
3481 "Spider storage engine",
3482 PLUGIN_LICENSE_GPL,
3483 spider_db_init,
3484 spider_db_done,
3485 SPIDER_HEX_VERSION,
3486 spider_status_variables,
3487 spider_system_variables,
3488 SPIDER_DETAIL_VERSION,
3489 MariaDB_PLUGIN_MATURITY_GAMMA
3490},
3491spider_i_s_alloc_mem_maria
3492maria_declare_plugin_end;
3493#endif
3494