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
|
/* Copyright (C) 2008-2019 Kentoku Shiba
Copyright (C) 2019-2022 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
/*
Structure used to manage Spider parameter string parsing. Types of
parameters include:
- connection strings
- UDF parameters
A parameter string consists of one or more parameter definitions using
the following syntax:
<parameter title> <parameter value>
A comma is the separator character between multiple parameter definitions.
Parameter titles must not be quoted. Parameter values must be quoted with
single or double quotes.
*/
typedef struct st_spider_param_string_parse
{
char *start_title; /* Pointer to the start of the current parameter
title */
char *end_title; /* Pointer to the end of the current
parameter value */
char *start_value; /* Pointer to the start of the current parameter
value */
char *end_value; /* Pointer to the end of the current parameter
value */
char delim_value; /* Current parameter value's delimiter
character, either a single or a double quote */
int error_num; /* Error code of the error message to print when
an error is detected */
int fail(bool restore_delim);
bool locate_param_def(char*& start_param);
} SPIDER_PARAM_STRING_PARSE;
const uchar *spider_tbl_get_key(
const void *share,
size_t *length,
my_bool
);
const uchar *spider_wide_share_get_key(
const void *share,
size_t *length,
my_bool
);
const uchar *spider_link_get_key(
const void *link_for_hash,
size_t *length,
my_bool
);
int spider_get_server(
SPIDER_SHARE *share,
int link_idx
);
int spider_free_share_alloc(
SPIDER_SHARE *share
);
void spider_free_tmp_share_alloc(
SPIDER_SHARE *share
);
int spider_create_string_list(
char ***string_list,
uint **string_length_list,
uint *list_length,
char *str,
uint length
);
int spider_create_long_list(
long **long_list,
uint *list_length,
char *str,
uint length,
long min_val,
long max_val
);
int spider_create_longlong_list(
longlong **longlong_list,
uint *list_length,
char *str,
uint length,
longlong min_val,
longlong max_val
);
int spider_increase_string_list(
char ***string_list,
uint **string_length_list,
uint *list_length,
uint *list_charlen,
uint link_count
);
int spider_increase_long_list(
long **long_list,
uint *list_length,
uint link_count
);
int spider_increase_longlong_list(
longlong **longlong_list,
uint *list_length,
uint link_count
);
int spider_parse_connect_info(
SPIDER_SHARE *share,
TABLE_SHARE *table_share,
partition_info *part_info,
uint create_table
);
int spider_set_connect_info_default(
SPIDER_SHARE *share,
partition_element *part_elem,
partition_element *sub_elem,
TABLE_SHARE *table_share
);
int spider_set_connect_info_default_db_table(
SPIDER_SHARE *share,
const char *db_name,
uint db_name_length,
const char *table_name,
uint table_name_length
);
int spider_set_connect_info_default_dbtable(
SPIDER_SHARE *share,
const char *dbtable_name,
int dbtable_name_length
);
#ifdef DBUG_TRACE
void spider_print_keys(
const char *key,
uint length
);
#endif
void spider_create_conn_key_add_one(int* counter, char** target, char* src);
int spider_create_conn_keys(
SPIDER_SHARE *share
);
SPIDER_LGTM_TBLHND_SHARE *spider_get_lgtm_tblhnd_share(
const char *table_name,
uint table_name_length,
my_hash_value_type hash_value,
bool locked,
bool need_to_create,
int *error_num
);
void spider_free_lgtm_tblhnd_share_alloc(
SPIDER_LGTM_TBLHND_SHARE *lgtm_tblhnd_share,
bool locked
);
SPIDER_SHARE *spider_create_share(
const char *table_name,
TABLE_SHARE *table_share,
partition_info *part_info,
my_hash_value_type hash_value,
int *error_num
);
SPIDER_SHARE *spider_get_share(
const char *table_name,
TABLE *table,
THD *thd,
ha_spider *spider,
int *error_num
);
void spider_free_share_resource_only(
SPIDER_SHARE *share
);
int spider_free_share(
SPIDER_SHARE *share
);
void spider_update_link_status_for_share(
const char *table_name,
uint table_name_length,
int link_idx,
long link_status
);
SPIDER_WIDE_SHARE *spider_get_wide_share(
SPIDER_SHARE *share,
TABLE_SHARE *table_share,
int *error_num
);
int spider_free_wide_share(
SPIDER_WIDE_SHARE *wide_share
);
int spider_open_all_tables(
SPIDER_TRX *trx,
bool lock
);
bool spider_flush_logs(
handlerton *hton
);
handler* spider_create_handler(
handlerton *hton,
TABLE_SHARE *table,
MEM_ROOT *mem_root
);
int spider_close_connection(
handlerton* hton,
THD* thd
);
void spider_drop_database(
handlerton *hton,
char* path
);
bool spider_show_status(
handlerton *hton,
THD *thd,
stat_print_fn *stat_print,
enum ha_stat_type stat_type
);
int spider_db_done(
void *p
);
int spider_panic(
handlerton *hton,
ha_panic_function type
);
int spider_db_init(
void *p
);
char *spider_create_table_name_string(
const char *table_name,
const char *part_name,
const char *sub_name
);
void spider_get_partition_info(
const char *table_name,
uint table_name_length,
const TABLE_SHARE *table_share,
partition_info *part_info,
partition_element **part_elem,
partition_element **sub_elem
);
int spider_get_sts(
SPIDER_SHARE *share,
int link_idx,
time_t tmp_time,
ha_spider *spider,
double sts_interval,
int sts_mode,
int sts_sync,
int sts_sync_level,
uint flag
);
int spider_get_crd(
SPIDER_SHARE *share,
int link_idx,
time_t tmp_time,
ha_spider *spider,
TABLE *table,
double crd_interval,
int crd_mode,
int crd_sync,
int crd_sync_level
);
void spider_set_result_list_param(
ha_spider *spider
);
SPIDER_INIT_ERROR_TABLE *spider_get_init_error_table(
SPIDER_TRX *trx,
SPIDER_SHARE *share,
bool create
);
void spider_delete_init_error_table(
const char *name
);
bool spider_check_pk_update(
TABLE *table
);
void spider_set_tmp_share_pointer(
SPIDER_SHARE *tmp_share,
char **tmp_connect_info,
uint *tmp_connect_info_length,
long *tmp_long,
longlong *tmp_longlong
);
int spider_create_tmp_dbton_share(
SPIDER_SHARE *tmp_share
);
void spider_free_tmp_dbton_share(
SPIDER_SHARE *tmp_share
);
int spider_create_tmp_dbton_handler(
ha_spider *tmp_spider
);
void spider_free_tmp_dbton_handler(
ha_spider *tmp_spider
);
TABLE_LIST *spider_get_parent_table_list(
ha_spider *spider
);
List<Index_hint> *spider_get_index_hints(
ha_spider *spider
);
st_select_lex *spider_get_select_lex(
ha_spider *spider
);
void spider_get_select_limit_from_select_lex(
st_select_lex *select_lex,
longlong *select_limit,
longlong *offset_limit
);
void spider_get_select_limit(
ha_spider *spider,
st_select_lex **select_lex,
longlong *select_limit,
longlong *offset_limit
);
longlong spider_split_read_param(
ha_spider *spider
);
longlong spider_bg_split_read_param(
ha_spider *spider
);
void spider_first_split_read_param(
ha_spider *spider
);
void spider_next_split_read_param(
ha_spider *spider
);
bool spider_check_direct_order_limit(
ha_spider *spider
);
bool spider_all_part_in_order(
ORDER *order,
TABLE *table
);
Field *spider_field_exchange(
handler *handler,
Field *field
);
int spider_set_direct_limit_offset(
ha_spider *spider
);
bool spider_check_index_merge(
TABLE *table,
st_select_lex *select_lex
);
int spider_compare_for_sort(
const void *a,
const void *b
);
ulong spider_calc_for_sort(
uint count,
...
);
double spider_rand(
uint32 rand_source
);
int spider_discover_table_structure_internal(
SPIDER_TRX *trx,
SPIDER_SHARE *spider_share,
spider_string *str
);
int spider_discover_table_structure(
handlerton *hton,
THD* thd,
TABLE_SHARE *share,
HA_CREATE_INFO *info
);
int spider_create_spider_object_for_share(
SPIDER_TRX *trx,
SPIDER_SHARE *share,
ha_spider **spider
);
void spider_free_spider_object_for_share(
ha_spider **spider
);
int spider_create_sts_crd_threads(
SPIDER_THREAD *spider_thread,
bool is_sts
);
void spider_free_sts_crd_threads(
SPIDER_THREAD *spider_thread
);
void *spider_table_bg_sts_action(
void *arg
);
void *spider_table_bg_crd_action(
void *arg
);
void spider_table_add_share_to_sts_thread(
SPIDER_SHARE *share
);
void spider_table_add_share_to_crd_thread(
SPIDER_SHARE *share
);
void spider_table_remove_share_from_sts_thread(
SPIDER_SHARE *share
);
void spider_table_remove_share_from_crd_thread(
SPIDER_SHARE *share
);
uchar *spider_duplicate_char(
uchar *dst,
uchar esc,
uchar *src,
uint src_lgt
);
|