-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvp_param.cc
384 lines (353 loc) · 8.31 KB
/
vp_param.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
/* Copyright (C) 2009-2019 Kentoku Shiba
Copyright (C) 2019 MariaDB corp
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#define MYSQL_SERVER 1
#include <my_global.h>
#include "mysql_version.h"
#include "vp_environ.h"
#if MYSQL_VERSION_ID < 50500
#include "mysql_priv.h"
#include <mysql/plugin.h>
#else
#include "sql_priv.h"
#include "probes_mysql.h"
#include "sql_class.h"
#include "sql_partition.h"
#include "sql_select.h"
#endif
#include "vp_include.h"
#include "ha_vp.h"
#include "vp_table.h"
static my_bool vp_support_xa;
static MYSQL_SYSVAR_BOOL(
support_xa,
vp_support_xa,
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
"XA support",
NULL,
NULL,
TRUE
);
my_bool vp_param_support_xa()
{
DBUG_ENTER("vp_param_support_xa");
DBUG_RETURN(vp_support_xa);
}
/*
-1 :use table parameter
0 :minimum
1 :sequential
*/
static MYSQL_THDVAR_INT(
choose_table_mode, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Mode of choosing to access tables", /* comment */
NULL, /* check */
NULL, /* update */
-1, /* def */
-1, /* min */
1, /* max */
0 /* blk */
);
int vp_param_choose_table_mode(
THD *thd,
int choose_table_mode
) {
DBUG_ENTER("vp_param_choose_table_mode");
DBUG_RETURN(THDVAR(thd, choose_table_mode) < 0 ?
choose_table_mode : THDVAR(thd, choose_table_mode));
}
/*
-1 :use table parameter
0 :minimum
1 :sequential
*/
static MYSQL_THDVAR_INT(
choose_table_mode_for_lock, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Mode of choosing to access tables for lock", /* comment */
NULL, /* check */
NULL, /* update */
-1, /* def */
-1, /* min */
1, /* max */
0 /* blk */
);
int vp_param_choose_table_mode_for_lock(
THD *thd,
int choose_table_mode_for_lock
) {
DBUG_ENTER("vp_param_choose_table_mode_for_lock");
DBUG_RETURN(THDVAR(thd, choose_table_mode_for_lock) < 0 ?
choose_table_mode_for_lock : THDVAR(thd, choose_table_mode_for_lock));
}
/*
-1 :use table parameter
0 :separete range
1 :multi range
*/
static MYSQL_THDVAR_INT(
multi_range_mode, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Mode of choosing to access tables", /* comment */
NULL, /* check */
NULL, /* update */
-1, /* def */
-1, /* min */
1, /* max */
0 /* blk */
);
int vp_param_multi_range_mode(
THD *thd,
int multi_range_mode
) {
DBUG_ENTER("vp_param_multi_range_mode");
DBUG_RETURN(THDVAR(thd, multi_range_mode) < 0 ?
multi_range_mode : THDVAR(thd, multi_range_mode));
}
/*
-1 :use table parameter
0 :separete range
1 :multi range
*/
static MYSQL_THDVAR_INT(
child_binlog, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Mode of choosing to access tables", /* comment */
NULL, /* check */
NULL, /* update */
-1, /* def */
-1, /* min */
1, /* max */
0 /* blk */
);
int vp_param_child_binlog(
THD *thd,
int child_binlog
) {
DBUG_ENTER("vp_param_child_binlog");
DBUG_RETURN(THDVAR(thd, child_binlog) < 0 ?
child_binlog : THDVAR(thd, child_binlog));
}
#ifndef WITHOUT_VP_BG_ACCESS
/*
-1 :use table parameter
0 :background search is disabled
1 :background search is enabled
*/
static MYSQL_THDVAR_INT(
bgs_mode, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Mode of background search", /* comment */
NULL, /* check */
NULL, /* update */
-1, /* def */
-1, /* min */
1, /* max */
0 /* blk */
);
int vp_param_bgs_mode(
THD *thd,
int bgs_mode
) {
DBUG_ENTER("vp_param_bgs_mode");
DBUG_RETURN(THDVAR(thd, bgs_mode) < 0 ?
bgs_mode : THDVAR(thd, bgs_mode));
}
/*
-1 :use table parameter
0 :background insert is disabled
1 :background insert is enabled
*/
static MYSQL_THDVAR_INT(
bgi_mode, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Mode of background insert", /* comment */
NULL, /* check */
NULL, /* update */
-1, /* def */
-1, /* min */
1, /* max */
0 /* blk */
);
int vp_param_bgi_mode(
THD *thd,
int bgi_mode
) {
DBUG_ENTER("vp_param_bgi_mode");
DBUG_RETURN(THDVAR(thd, bgi_mode) < 0 ?
bgi_mode : THDVAR(thd, bgi_mode));
}
/*
-1 :use table parameter
0 :background update is disabled
1 :background update is enabled
*/
static MYSQL_THDVAR_INT(
bgu_mode, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Mode of background update", /* comment */
NULL, /* check */
NULL, /* update */
-1, /* def */
-1, /* min */
1, /* max */
0 /* blk */
);
int vp_param_bgu_mode(
THD *thd,
int bgu_mode
) {
DBUG_ENTER("vp_param_bgu_mode");
DBUG_RETURN(THDVAR(thd, bgu_mode) < 0 ?
bgu_mode : THDVAR(thd, bgu_mode));
}
#endif
/*
-1 :use table parameter
0 :exchange bulk inserting to single inserting for safety
1 :allow bulk inserting with auto_increment
*/
static MYSQL_THDVAR_INT(
allow_bulk_autoinc, /* name */
PLUGIN_VAR_RQCMDARG, /* opt */
"Mode of bulk inserting into table with auto_increment", /* comment */
NULL, /* check */
NULL, /* update */
-1, /* def */
-1, /* min */
1, /* max */
0 /* blk */
);
int vp_param_allow_bulk_autoinc(
THD *thd,
int allow_bulk_autoinc
) {
DBUG_ENTER("vp_param_allow_bulk_autoinc");
DBUG_RETURN(THDVAR(thd, allow_bulk_autoinc) < 0 ?
allow_bulk_autoinc : THDVAR(thd, allow_bulk_autoinc));
}
static int vp_udf_ct_bulk_insert_interval;
/*
-1 : The UDF parameter is adopted.
0 or more : Milliseconds.
*/
static MYSQL_SYSVAR_INT(
udf_ct_bulk_insert_interval,
vp_udf_ct_bulk_insert_interval,
PLUGIN_VAR_RQCMDARG,
"The interval time between bulk insert and next bulk insert at coping",
NULL,
NULL,
-1,
-1,
2147483647,
0
);
int vp_param_udf_ct_bulk_insert_interval(
int udf_ct_bulk_insert_interval
) {
DBUG_ENTER("vp_param_udf_ct_bulk_insert_interval");
DBUG_RETURN(vp_udf_ct_bulk_insert_interval < 0 ?
udf_ct_bulk_insert_interval : vp_udf_ct_bulk_insert_interval);
}
static longlong vp_udf_ct_bulk_insert_rows;
/*
-1,0 : The UDF parameter is adopted.
1 or more : Number of rows.
*/
static MYSQL_SYSVAR_LONGLONG(
udf_ct_bulk_insert_rows,
vp_udf_ct_bulk_insert_rows,
PLUGIN_VAR_RQCMDARG,
"The number of rows inserted with bulk insert of one time at coping",
NULL,
NULL,
-1,
-1,
9223372036854775807LL,
0
);
longlong vp_param_udf_ct_bulk_insert_rows(
longlong udf_ct_bulk_insert_rows
) {
DBUG_ENTER("vp_param_udf_ct_bulk_insert_rows");
DBUG_RETURN(vp_udf_ct_bulk_insert_rows <= 0 ?
udf_ct_bulk_insert_rows : vp_udf_ct_bulk_insert_rows);
}
static char *vp_version = (char *) VP_DETAIL_VERSION;
static MYSQL_SYSVAR_STR(
version,
vp_version,
PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
"The version of Vertical Partitioning",
NULL,
NULL,
VP_DETAIL_VERSION
);
struct st_mysql_storage_engine vp_storage_engine =
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
struct st_mysql_sys_var* vp_system_variables[] = {
MYSQL_SYSVAR(support_xa),
MYSQL_SYSVAR(choose_table_mode),
MYSQL_SYSVAR(choose_table_mode_for_lock),
MYSQL_SYSVAR(multi_range_mode),
MYSQL_SYSVAR(child_binlog),
#ifndef WITHOUT_VP_BG_ACCESS
MYSQL_SYSVAR(bgs_mode),
MYSQL_SYSVAR(bgi_mode),
MYSQL_SYSVAR(bgu_mode),
#endif
MYSQL_SYSVAR(allow_bulk_autoinc),
MYSQL_SYSVAR(udf_ct_bulk_insert_interval),
MYSQL_SYSVAR(udf_ct_bulk_insert_rows),
MYSQL_SYSVAR(version),
NULL
};
mysql_declare_plugin(vp)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&vp_storage_engine,
"VP",
"Kentoku Shiba",
"Vertical Partitioning Storage Engine",
PLUGIN_LICENSE_GPL,
vp_db_init,
vp_db_done,
VP_HEX_VERSION,
NULL,
vp_system_variables,
NULL,
#if MYSQL_VERSION_ID >= 50600
0,
#endif
}
mysql_declare_plugin_end;
#ifdef MARIADB_BASE_VERSION
maria_declare_plugin(vp)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&vp_storage_engine,
"VP",
"Kentoku Shiba",
"Vertical Partitioning Storage Engine",
PLUGIN_LICENSE_GPL,
vp_db_init,
vp_db_done,
VP_HEX_VERSION,
NULL,
vp_system_variables,
VP_DETAIL_VERSION,
MariaDB_PLUGIN_MATURITY_BETA
}
maria_declare_plugin_end;
#endif