-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvp_table.cc
2707 lines (2530 loc) · 82.2 KB
/
vp_table.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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Copyright (C) 2009-2020 Kentoku Shiba
Copyright (C) 2019-2020 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_base.h"
#include "sql_select.h"
#endif
#ifdef WITH_PARTITION_STORAGE_ENGINE
#include "ha_partition.h"
#endif
#include "vp_err.h"
#include "vp_param.h"
#include "vp_include.h"
#include "ha_vp.h"
#include "vp_table.h"
#ifndef VP_HAS_NEXT_THREAD_ID
ulong *vp_db_att_thread_id;
#endif
handlerton *vp_hton_ptr;
handlerton *vp_partition_hton_ptr;
#ifdef HAVE_PSI_INTERFACE
PSI_mutex_key vp_key_mutex_tbl;
#ifdef WITH_PARTITION_STORAGE_ENGINE
PSI_mutex_key vp_key_mutex_pt_share;
#endif
PSI_mutex_key vp_key_mutex_bg_sync;
PSI_mutex_key vp_key_mutex_bg;
PSI_mutex_key vp_key_mutex_share;
PSI_mutex_key vp_key_mutex_share_init;
#ifdef WITH_PARTITION_STORAGE_ENGINE
PSI_mutex_key vp_key_mutex_pt_handler;
#endif
static PSI_mutex_info all_vp_mutexes[]=
{
{ &vp_key_mutex_tbl, "tbl", PSI_FLAG_GLOBAL},
#ifdef WITH_PARTITION_STORAGE_ENGINE
{ &vp_key_mutex_pt_share, "pt_share", PSI_FLAG_GLOBAL},
#endif
#ifndef WITHOUT_VP_BG_ACCESS
{ &vp_key_mutex_bg_sync, "bg_sync", 0},
{ &vp_key_mutex_bg, "bg", 0},
#endif
{ &vp_key_mutex_share, "share", 0},
{ &vp_key_mutex_share_init, "share_init", 0},
#ifdef WITH_PARTITION_STORAGE_ENGINE
{ &vp_key_mutex_pt_handler, "pt_handler", 0},
#endif
};
#ifndef WITHOUT_VP_BG_ACCESS
PSI_cond_key vp_key_cond_bg_sync;
PSI_cond_key vp_key_cond_bg;
#endif
static PSI_cond_info all_vp_conds[] = {
#ifndef WITHOUT_VP_BG_ACCESS
{&vp_key_cond_bg_sync, "bg_sync", 0},
{&vp_key_cond_bg, "bg", 0},
#endif
};
#ifndef WITHOUT_VP_BG_ACCESS
PSI_thread_key vp_key_thd_bg;
#endif
static PSI_thread_info all_vp_threads[] = {
#ifndef WITHOUT_VP_BG_ACCESS
{&vp_key_thd_bg, "bg", 0},
#endif
};
#endif
HASH vp_open_tables;
pthread_mutex_t vp_tbl_mutex;
#ifdef WITH_PARTITION_STORAGE_ENGINE
HASH vp_open_pt_share;
pthread_mutex_t vp_pt_share_mutex;
#endif
#ifndef WITHOUT_VP_BG_ACCESS
pthread_attr_t vp_pt_attr;
#endif
// for vp_open_tables
uchar *vp_tbl_get_key(
VP_SHARE *share,
size_t *length,
my_bool not_used __attribute__ ((unused))
) {
DBUG_ENTER("vp_tbl_get_key");
*length = share->table_name_length;
DBUG_RETURN((uchar*) share->table_name);
}
#ifdef WITH_PARTITION_STORAGE_ENGINE
uchar *vp_pt_share_get_key(
VP_PARTITION_SHARE *share,
size_t *length,
my_bool not_used __attribute__ ((unused))
) {
DBUG_ENTER("vp_pt_share_get_key");
*length = share->table_name_length;
DBUG_RETURN((uchar*) share->table_name);
}
uchar *vp_pt_handler_share_get_key(
VP_PARTITION_HANDLER_SHARE *share,
size_t *length,
my_bool not_used __attribute__ ((unused))
) {
DBUG_ENTER("vp_pt_handler_share_get_key");
*length = sizeof(TABLE *);
DBUG_RETURN((uchar*) &share->table);
}
#endif
#ifdef HAVE_PSI_INTERFACE
static void init_vp_psi_keys()
{
DBUG_ENTER("init_vp_psi_keys");
if (PSI_server == NULL)
DBUG_VOID_RETURN;
PSI_server->register_mutex("vp", all_vp_mutexes,
array_elements(all_vp_mutexes));
PSI_server->register_cond("vp", all_vp_conds,
array_elements(all_vp_conds));
PSI_server->register_thread("vp", all_vp_threads,
array_elements(all_vp_threads));
DBUG_VOID_RETURN;
}
#endif
int vp_free_share_alloc(
VP_SHARE *share
) {
DBUG_ENTER("vp_free_share_alloc");
if (share->tgt_default_db_name)
vp_my_free(share->tgt_default_db_name, MYF(0));
if (share->tgt_table_name_list)
vp_my_free(share->tgt_table_name_list, MYF(0));
if (share->tgt_table_name_prefix)
vp_my_free(share->tgt_table_name_prefix, MYF(0));
if (share->tgt_table_name_suffix)
vp_my_free(share->tgt_table_name_suffix, MYF(0));
if (share->choose_ignore_table_list)
vp_my_free(share->choose_ignore_table_list, MYF(0));
if (share->choose_ignore_table_list_for_lock)
vp_my_free(share->choose_ignore_table_list_for_lock, MYF(0));
if (share->tgt_db_name)
vp_my_free(share->tgt_db_name, MYF(0));
if (share->correspond_columns_p)
vp_my_free(share->correspond_columns_p, MYF(0));
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (share->partition_share)
vp_free_pt_share(share->partition_share);
#endif
DBUG_RETURN(0);
}
/**
Initialize the parameter string parse information.
@param param_string Pointer to the parameter string being parsed.
@param error_code Error code of the error message to print when
an error is detected.
*/
inline void st_vp_param_string_parse::init(
char *param_string,
int error_code
)
{
DBUG_ENTER("st_vp_param_string_parse::init");
start_ptr = param_string;
end_ptr = start_ptr + strlen(start_ptr);
init_param_title();
init_param_value();
error_num = error_code;
DBUG_VOID_RETURN;
}
/**
Initialize the current parameter title.
*/
inline void st_vp_param_string_parse::init_param_title()
{
DBUG_ENTER("st_vp_param_string_parse::init_param_title");
start_title_ptr = end_title_ptr = NULL;
delim_title_len = 0;
delim_title = '\0';
DBUG_VOID_RETURN;
}
/**
Save pointers to the start and end positions of the current parameter
title in the parameter string. Also save the parameter title's
delimiter character.
@param start_value Pointer to the start position of the current
parameter title.
@param end_value Pointer to the end position of the current
parameter title.
*/
inline void st_vp_param_string_parse::set_param_title(
char *start_title,
char *end_title
)
{
DBUG_ENTER("st_vp_param_string_parse::set_param_title");
start_title_ptr = start_title;
end_title_ptr = end_title;
if (*start_title == '"' ||
*start_title == '\'')
{
delim_title = *start_title;
if (start_title >= start_ptr && *--start_title == '\\')
delim_title_len = 2;
else
delim_title_len = 1;
}
DBUG_VOID_RETURN;
}
/**
Initialize the current parameter value.
*/
inline void st_vp_param_string_parse::init_param_value()
{
DBUG_ENTER("st_vp_param_string_parse::init_param_value");
start_value_ptr = end_value_ptr = NULL;
delim_value_len = 0;
delim_value = '\0';
DBUG_VOID_RETURN;
}
/**
Save pointers to the start and end positions of the current parameter
value in the parameter string. Also save the parameter value's
delimiter character.
@param start_value Pointer to the start position of the current
parameter value.
@param end_value Pointer to the end position of the current
parameter value.
*/
inline void st_vp_param_string_parse::set_param_value(
char *start_value,
char *end_value
)
{
DBUG_ENTER("st_vp_param_string_parse::set_param_value");
start_value_ptr = start_value--;
end_value_ptr = end_value;
if (*start_value == '"' ||
*start_value == '\'')
{
delim_value = *start_value;
if (*--start_value == '\\')
delim_value_len = 2;
else
delim_value_len = 1;
}
DBUG_VOID_RETURN;
}
/**
Determine whether the current parameter in the parameter string has
extra parameter values.
@return 0 Current parameter value in the parameter string
does not have extra parameter values.
<> 0 Error code indicating that the current parameter
value in the parameter string has extra
parameter values.
*/
inline int st_vp_param_string_parse::has_extra_parameter_values()
{
int error_num = 0;
DBUG_ENTER("st_vp_param_string_parse::has_extra_parameter_values");
if (end_value_ptr)
{
/* There is a current parameter value */
char *end_param_ptr = end_value_ptr;
while (end_param_ptr < end_ptr &&
(*end_param_ptr == ' ' || *end_param_ptr == '\r' ||
*end_param_ptr == '\n' || *end_param_ptr == '\t'))
end_param_ptr++;
if (end_param_ptr < end_ptr && *end_param_ptr != '\0')
{
/* Extra values in parameter definition */
error_num = print_param_error();
}
}
DBUG_RETURN(error_num);
}
/**
Restore the current parameter's input delimiter characters in the
parameter string. They were NULLed during parameter parsing.
*/
inline void st_vp_param_string_parse::restore_delims()
{
char *end = end_title_ptr - 1;
DBUG_ENTER("st_vp_param_string_parse::restore_delims");
switch (delim_title_len)
{
case 2:
*end++ = '\\';
/* Fall through */
case 1:
*end = delim_title;
}
end = end_value_ptr - 1;
switch (delim_value_len)
{
case 2:
*end++ = '\\';
/* Fall through */
case 1:
*end = delim_value;
}
DBUG_VOID_RETURN;
}
/**
Print a parameter string error message.
@return Error code.
*/
int st_vp_param_string_parse::print_param_error()
{
DBUG_ENTER("st_vp_param_string_parse::print_param_error");
if (start_title_ptr)
{
/* Restore the input delimiter characters */
restore_delims();
/* Print the error message */
switch (error_num)
{
case ER_VP_INVALID_UDF_PARAM_NUM:
my_printf_error(error_num, ER_VP_INVALID_UDF_PARAM_STR,
MYF(0), start_title_ptr);
break;
case ER_VP_INVALID_TABLE_INFO_NUM:
default:
my_printf_error(error_num, ER_VP_INVALID_TABLE_INFO_STR,
MYF(0), start_title_ptr);
}
DBUG_RETURN(error_num);
}
DBUG_RETURN(0);
}
char *vp_get_string_between_quote(
char *ptr,
bool alloc,
VP_PARAM_STRING_PARSE *param_string_parse
) {
char *start_ptr, *end_ptr, *tmp_ptr, *esc_ptr;
bool find_flg = FALSE, esc_flg = FALSE;
DBUG_ENTER("vp_get_string_between_quote");
start_ptr = strchr(ptr, '\'');
end_ptr = strchr(ptr, '"');
if (start_ptr && (!end_ptr || start_ptr < end_ptr))
{
tmp_ptr = ++start_ptr;
while (!find_flg)
{
if (!(end_ptr = strchr(tmp_ptr, '\'')))
DBUG_RETURN(NULL);
esc_ptr = tmp_ptr;
while (!find_flg)
{
esc_ptr = strchr(esc_ptr, '\\');
if (!esc_ptr || esc_ptr > end_ptr)
find_flg = TRUE;
else if (esc_ptr == end_ptr - 1)
{
esc_flg = TRUE;
tmp_ptr = end_ptr + 1;
break;
} else {
esc_flg = TRUE;
esc_ptr += 2;
}
}
}
} else if (end_ptr)
{
start_ptr = end_ptr;
tmp_ptr = ++start_ptr;
while (!find_flg)
{
if (!(end_ptr = strchr(tmp_ptr, '"')))
DBUG_RETURN(NULL);
esc_ptr = tmp_ptr;
while (!find_flg)
{
esc_ptr = strchr(esc_ptr, '\\');
if (!esc_ptr || esc_ptr > end_ptr)
find_flg = TRUE;
else if (esc_ptr == end_ptr - 1)
{
esc_flg = TRUE;
tmp_ptr = end_ptr + 1;
break;
} else {
esc_flg = TRUE;
esc_ptr += 2;
}
}
}
} else
DBUG_RETURN(NULL);
*end_ptr = '\0';
if (esc_flg)
{
esc_ptr = start_ptr;
while (TRUE)
{
esc_ptr = strchr(esc_ptr, '\\');
if (!esc_ptr)
break;
switch(*(esc_ptr + 1))
{
case 'b':
*esc_ptr = '\b';
break;
case 'n':
*esc_ptr = '\n';
break;
case 'r':
*esc_ptr = '\r';
break;
case 't':
*esc_ptr = '\t';
break;
default:
*esc_ptr = *(esc_ptr + 1);
break;
}
esc_ptr++;
strcpy(esc_ptr, esc_ptr + 1);
}
}
if (param_string_parse)
param_string_parse->set_param_value(start_ptr, start_ptr + strlen(start_ptr) + 1);
if (alloc)
{
DBUG_RETURN(
vp_create_string(
start_ptr,
strlen(start_ptr))
);
} else {
DBUG_RETURN(start_ptr);
}
}
int vp_parse_table_info(
VP_SHARE *share,
TABLE *table,
uint create_table
) {
int error_num = 0;
char *comment_string = NULL;
char *sprit_ptr[2];
char *tmp_ptr, *tmp_ptr2, *start_ptr;
int roop_count;
int title_length;
VP_PARAM_STRING_PARSE param_string_parse;
#ifdef WITH_PARTITION_STORAGE_ENGINE
partition_element *part_elem;
partition_element *sub_elem;
#endif
DBUG_ENTER("vp_parse_table_info");
#if MYSQL_VERSION_ID < 50500
DBUG_PRINT("info",("vp partition_info=%s", table->s->partition_info));
#else
DBUG_PRINT("info",("vp partition_info=%s", table->s->partition_info_str));
#endif
DBUG_PRINT("info",("vp part_info=%p", table->part_info));
DBUG_PRINT("info",("vp s->db=%s", table->s->db.str));
DBUG_PRINT("info",("vp s->table_name=%s", table->s->table_name.str));
DBUG_PRINT("info",("vp s->path=%s", table->s->path.str));
DBUG_PRINT("info",
("vp s->normalized_path=%s", table->s->normalized_path.str));
#ifdef WITH_PARTITION_STORAGE_ENGINE
vp_get_partition_info(share->table_name, share->table_name_length, table->s,
table->part_info, &part_elem, &sub_elem);
#endif
share->choose_table_mode = -1;
share->choose_table_mode_for_lock = -1;
share->multi_range_mode = -1;
share->pk_correspond_mode = -1;
share->info_src_table = -1;
share->auto_increment_table = -1;
share->table_count_mode = -1;
share->support_table_cache = -1;
share->child_binlog = -1;
#ifndef WITHOUT_VP_BG_ACCESS
share->bgs_mode = -1;
share->bgi_mode = -1;
share->bgu_mode = -1;
#endif
share->zero_record_update_mode = -1;
share->allow_bulk_autoinc = -1;
share->allow_different_column_type = -1;
#ifdef WITH_PARTITION_STORAGE_ENGINE
#ifdef VP_PARTITION_HAS_CONNECTION_STRING
for (roop_count = 6; roop_count > 0; roop_count--)
#else
for (roop_count = 4; roop_count > 0; roop_count--)
#endif
#else
for (roop_count = 2; roop_count > 0; roop_count--)
#endif
{
if (comment_string)
{
vp_my_free(comment_string, MYF(0));
comment_string = NULL;
}
switch (roop_count)
{
#ifdef WITH_PARTITION_STORAGE_ENGINE
#ifdef VP_PARTITION_HAS_CONNECTION_STRING
case 6:
if (!sub_elem || sub_elem->connect_string.length == 0)
continue;
DBUG_PRINT("info",("vp create sub connect string"));
if (
!(comment_string = vp_create_string(
sub_elem->connect_string.str,
sub_elem->connect_string.length))
) {
error_num = HA_ERR_OUT_OF_MEM;
goto error_alloc_comment_string;
}
DBUG_PRINT("info",("vp connect_string=%s", comment_string));
break;
case 5:
#else
case 4:
#endif
if (!sub_elem || !sub_elem->part_comment)
continue;
DBUG_PRINT("info",("vp create sub comment string"));
if (
!(comment_string = vp_create_string(
sub_elem->part_comment,
strlen(sub_elem->part_comment)))
) {
error_num = HA_ERR_OUT_OF_MEM;
goto error_alloc_comment_string;
}
DBUG_PRINT("info",("vp sub comment string=%s", comment_string));
break;
#ifdef VP_PARTITION_HAS_CONNECTION_STRING
case 4:
if (!part_elem || part_elem->connect_string.length == 0)
continue;
DBUG_PRINT("info",("vp create part connect string"));
if (
!(comment_string = vp_create_string(
part_elem->connect_string.str,
part_elem->connect_string.length))
) {
error_num = HA_ERR_OUT_OF_MEM;
goto error_alloc_comment_string;
}
DBUG_PRINT("info",("vp connect_string=%s", comment_string));
break;
#endif
case 3:
if (!part_elem || !part_elem->part_comment)
continue;
DBUG_PRINT("info",("vp create part comment string"));
if (
!(comment_string = vp_create_string(
part_elem->part_comment,
strlen(part_elem->part_comment)))
) {
error_num = HA_ERR_OUT_OF_MEM;
goto error_alloc_comment_string;
}
DBUG_PRINT("info",("vp part comment string=%s", comment_string));
break;
#endif
case 2:
if (table->s->comment.length == 0)
continue;
DBUG_PRINT("info",("vp create comment string"));
if (
!(comment_string = vp_create_string(
table->s->comment.str,
table->s->comment.length))
) {
error_num = HA_ERR_OUT_OF_MEM;
goto error_alloc_comment_string;
}
DBUG_PRINT("info",("vp comment string=%s", comment_string));
break;
default:
if (table->s->connect_string.length == 0)
continue;
DBUG_PRINT("info",("vp create connect_string string"));
if (
!(comment_string = vp_create_string(
table->s->connect_string.str,
table->s->connect_string.length))
) {
error_num = HA_ERR_OUT_OF_MEM;
goto error_alloc_comment_string;
}
DBUG_PRINT("info",("vp comment_string=%s", comment_string));
break;
}
sprit_ptr[0] = comment_string;
param_string_parse.init(comment_string,
ER_VP_INVALID_TABLE_INFO_NUM);
while (sprit_ptr[0])
{
if ((sprit_ptr[1] = strchr(sprit_ptr[0], ',')))
{
*sprit_ptr[1] = '\0';
sprit_ptr[1]++;
}
tmp_ptr = sprit_ptr[0];
sprit_ptr[0] = sprit_ptr[1];
while (*tmp_ptr == ' ' || *tmp_ptr == '\r' ||
*tmp_ptr == '\n' || *tmp_ptr == '\t')
tmp_ptr++;
if (*tmp_ptr == '\0')
continue;
title_length = 0;
start_ptr = tmp_ptr;
while (*start_ptr != ' ' && *start_ptr != '\'' &&
*start_ptr != '"' && *start_ptr != '\0' &&
*start_ptr != '\r' && *start_ptr != '\n' &&
*start_ptr != '\t')
{
title_length++;
start_ptr++;
}
param_string_parse.set_param_title(tmp_ptr, tmp_ptr + title_length);
switch (title_length)
{
case 0:
error_num = param_string_parse.print_param_error();
if (error_num)
goto error;
continue;
case 3:
VP_PARAM_INT_WITH_MAX(share, "aba", allow_bulk_autoinc, 0, 1);
VP_PARAM_INT_WITH_MAX(share, "adc", allow_different_column_type,
0, 1);
VP_PARAM_INT(share, "ait", auto_increment_table, 1);
#ifndef WITHOUT_VP_BG_ACCESS
VP_PARAM_INT_WITH_MAX(share, "bgs", bgs_mode, 0, 1);
VP_PARAM_INT_WITH_MAX(share, "bgi", bgi_mode, 0, 1);
VP_PARAM_INT_WITH_MAX(share, "bgu", bgu_mode, 0, 1);
#endif
VP_PARAM_INT_WITH_MAX(share, "cbl", child_binlog, 0, 1);
VP_PARAM_STR(share, "cil", choose_ignore_table_list_for_lock);
VP_PARAM_STR(share, "cit", choose_ignore_table_list);
VP_PARAM_INT_WITH_MAX(share, "cml", choose_table_mode_for_lock,
0, 1);
VP_PARAM_INT_WITH_MAX(share, "ctm", choose_table_mode, 0, 1);
VP_PARAM_STR(share, "ddb", tgt_default_db_name);
VP_PARAM_INT_WITH_MAX(share, "tcm", table_count_mode, 0, 1);
VP_PARAM_INT(share, "ist", info_src_table, 0);
VP_PARAM_INT_WITH_MAX(share, "mrm", multi_range_mode, 0, 1);
VP_PARAM_INT_WITH_MAX(share, "pcm", pk_correspond_mode, 0, 1);
VP_PARAM_INT_WITH_MAX(share, "stc", support_table_cache, 0, 2);
VP_PARAM_STR(share, "tnl", tgt_table_name_list);
VP_PARAM_STR(share, "tnp", tgt_table_name_prefix);
VP_PARAM_STR(share, "tns", tgt_table_name_suffix);
VP_PARAM_INT_WITH_MAX(share, "zru", zero_record_update_mode, 0, 1);
error_num = param_string_parse.print_param_error();
goto error;
#ifndef WITHOUT_VP_BG_ACCESS
case 8:
VP_PARAM_INT_WITH_MAX(share, "bgs_mode", bgs_mode, 0, 1);
VP_PARAM_INT_WITH_MAX(share, "bgi_mode", bgi_mode, 0, 1);
VP_PARAM_INT_WITH_MAX(share, "bgu_mode", bgu_mode, 0, 1);
error_num = param_string_parse.print_param_error();
goto error;
#endif
case 12:
VP_PARAM_INT_WITH_MAX(share, "child_binlog", child_binlog, 0, 1);
error_num = param_string_parse.print_param_error();
goto error;
case 15:
VP_PARAM_STR(share, "table_name_list", tgt_table_name_list);
error_num = param_string_parse.print_param_error();
goto error;
case 16:
VP_PARAM_INT_WITH_MAX(share, "multi_range_mode", multi_range_mode,
0, 1);
VP_PARAM_STR(share, "default_database", tgt_default_db_name);
VP_PARAM_INT_WITH_MAX(share, "table_count_mode", table_count_mode,
0, 1);
error_num = param_string_parse.print_param_error();
goto error;
case 17:
VP_PARAM_INT_WITH_MAX(share, "choose_table_mode", choose_table_mode,
0, 1);
VP_PARAM_STR(share, "table_name_prefix", tgt_table_name_prefix);
VP_PARAM_STR(share, "table_name_suffix", tgt_table_name_suffix);
error_num = param_string_parse.print_param_error();
goto error;
case 18:
VP_PARAM_INT_WITH_MAX(share, "pk_correspond_mode",
pk_correspond_mode, 0, 1);
VP_PARAM_INT_WITH_MAX(share, "allow_bulk_autoinc",
allow_bulk_autoinc, 0, 1);
error_num = param_string_parse.print_param_error();
goto error;
case 19:
VP_PARAM_INT_WITH_MAX(share, "support_table_cache",
support_table_cache, 0, 2);
error_num = param_string_parse.print_param_error();
goto error;
case 20:
VP_PARAM_INT(share, "auto_increment_table", auto_increment_table, 1);
error_num = param_string_parse.print_param_error();
goto error;
case 23:
VP_PARAM_INT(share, "infomation_source_table", info_src_table, 0);
VP_PARAM_INT_WITH_MAX(share, "zero_record_update_mode",
zero_record_update_mode, 0, 1);
error_num = param_string_parse.print_param_error();
goto error;
case 24:
VP_PARAM_STR(share, "choose_ignore_table_list",
choose_ignore_table_list);
error_num = param_string_parse.print_param_error();
goto error;
case 26:
VP_PARAM_INT_WITH_MAX(share, "choose_table_mode_for_lock",
choose_table_mode_for_lock, 0, 1);
error_num = param_string_parse.print_param_error();
goto error;
case 27:
VP_PARAM_INT_WITH_MAX(share, "allow_different_column_type",
allow_different_column_type, 0, 1);
error_num = param_string_parse.print_param_error();
goto error;
case 33:
VP_PARAM_STR(share, "choose_ignore_table_list_for_lock",
choose_ignore_table_list_for_lock);
error_num = param_string_parse.print_param_error();
goto error;
default:
error_num = param_string_parse.print_param_error();
goto error;
}
/* Verify that the remainder of the parameter value is whitespace */
if ((error_num = param_string_parse.has_extra_parameter_values()))
goto error;
}
}
if ((error_num = vp_set_table_info_default(
share,
#ifdef WITH_PARTITION_STORAGE_ENGINE
part_elem,
sub_elem,
#endif
table
)))
goto error;
if (create_table)
{
DBUG_PRINT("info",
("vp tgt_default_db_name_length = %u",
share->tgt_default_db_name_length));
if (share->tgt_default_db_name_length > VP_TABLE_INFO_MAX_LEN)
{
error_num = ER_VP_INVALID_TABLE_INFO_TOO_LONG_NUM;
my_printf_error(error_num, ER_VP_INVALID_TABLE_INFO_TOO_LONG_STR,
MYF(0), share->tgt_default_db_name, "default_database");
goto error;
}
/*
DBUG_PRINT("info",
("vp tgt_table_name_list_length = %ld",
share->tgt_table_name_list_length));
if (share->tgt_table_name_list_length > VP_TABLE_INFO_MAX_LEN)
{
error_num = ER_VP_INVALID_TABLE_INFO_TOO_LONG_NUM;
my_printf_error(error_num, ER_VP_INVALID_TABLE_INFO_TOO_LONG_STR,
MYF(0), share->tgt_table_name_list, "table_name_list");
goto error;
}
*/
DBUG_PRINT("info",
("vp tgt_table_name_prefix_length = %u",
share->tgt_table_name_prefix_length));
if (share->tgt_table_name_prefix_length > VP_TABLE_INFO_MAX_LEN)
{
error_num = ER_VP_INVALID_TABLE_INFO_TOO_LONG_NUM;
my_printf_error(error_num, ER_VP_INVALID_TABLE_INFO_TOO_LONG_STR,
MYF(0), share->tgt_table_name_prefix, "table_name_prefix");
goto error;
}
DBUG_PRINT("info",
("vp tgt_table_name_suffix_length = %u",
share->tgt_table_name_suffix_length));
if (share->tgt_table_name_suffix_length > VP_TABLE_INFO_MAX_LEN)
{
error_num = ER_VP_INVALID_TABLE_INFO_TOO_LONG_NUM;
my_printf_error(error_num, ER_VP_INVALID_TABLE_INFO_TOO_LONG_STR,
MYF(0), share->tgt_table_name_suffix, "table_name_suffix");
goto error;
}
}
if (comment_string)
vp_my_free(comment_string, MYF(0));
DBUG_RETURN(0);
error:
if (comment_string)
vp_my_free(comment_string, MYF(0));
error_alloc_comment_string:
DBUG_RETURN(error_num);
}
int vp_set_table_info_default(
VP_SHARE *share,
#ifdef WITH_PARTITION_STORAGE_ENGINE
partition_element *part_elem,
partition_element *sub_elem,
#endif
TABLE *table
) {
DBUG_ENTER("vp_set_table_info_default");
if (!share->tgt_default_db_name)
{
DBUG_PRINT("info",("vp create default tgt_default_db_name"));
share->tgt_default_db_name_length = table->s->db.length;
if (
!(share->tgt_default_db_name = vp_create_string(
table->s->db.str,
share->tgt_default_db_name_length))
) {
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
}
if (!share->tgt_table_name_prefix)
{
DBUG_PRINT("info",("vp create default tgt_table_name_prefix"));
share->tgt_table_name_prefix_length = 0;
if (
!(share->tgt_table_name_prefix = vp_create_string(
"",
share->tgt_table_name_prefix_length))
) {
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
}
if (!share->tgt_table_name_suffix)
{
DBUG_PRINT("info",("vp create default tgt_table_name_suffix"));
share->tgt_table_name_suffix_length = 0;
if (
!(share->tgt_table_name_suffix = vp_create_string(
"",
share->tgt_table_name_suffix_length))
) {
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
}
if (!share->tgt_table_name_list && table)
{
DBUG_PRINT("info",("vp create default tgt_table_name_list"));
share->tgt_table_name_list_length = share->table_name_length;
if (
!(share->tgt_table_name_list = vp_create_table_name_string(
table->s->table_name.str,
#ifdef WITH_PARTITION_STORAGE_ENGINE
(part_elem ? part_elem->partition_name : NULL),
(sub_elem ? sub_elem->partition_name : NULL)
#else
NULL,
NULL
#endif
))
) {
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
}
if (!share->choose_ignore_table_list)
{
DBUG_PRINT("info",("vp create default choose_ignore_table_list"));
share->choose_ignore_table_list_length = 0;
if (
!(share->choose_ignore_table_list = vp_create_string(
"",
share->choose_ignore_table_list_length))
) {
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
}
if (!share->choose_ignore_table_list_for_lock)
{
DBUG_PRINT("info",("vp create default choose_ignore_table_list_for_lock"));
share->choose_ignore_table_list_for_lock_length = 0;
if (
!(share->choose_ignore_table_list_for_lock = vp_create_string(
"",
share->choose_ignore_table_list_for_lock_length))
) {
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
}
if (share->choose_table_mode == -1)
share->choose_table_mode = 0;
if (share->choose_table_mode_for_lock == -1)
share->choose_table_mode_for_lock = 1;
if (share->multi_range_mode == -1)
share->multi_range_mode = 1;
if (share->pk_correspond_mode == -1)
share->pk_correspond_mode = 0;
if (share->info_src_table == -1)
share->info_src_table = 0;
if (share->table_count_mode == -1)
share->table_count_mode = 0;