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
| main |-- init_signal_handling |-- parse_args(argc, argv); |-- mysql_server_init |-- |-- mysql_init(&con->mysql) |-- safe_connect(&con->mysql, con->name, opt_host, opt_user, opt_pass, opt_db, opt_port, unix_sock) |-- ssl_client_check_post_connect_ssl_setup( &con->mysql, [](const char *err) { die("%s", err); }) |-- mysql_query_wrapper( &con->mysql, "SET optimizer_switch='hypergraph_optimizer=on';") |-- ... |-- while (!read_command(&command) && !abort_flag) { ...
if (ok_to_do) { switch (command->type) { case Q_CONNECT: do_connect(command); break; case Q_CONNECTION: select_connection(command); break; case Q_DISCONNECT: case Q_DIRTY_CLOSE: do_close_connection(command); break; case Q_ENABLE_QUERY_LOG: set_property(command, P_QUERY, false); break; case Q_DISABLE_QUERY_LOG: set_property(command, P_QUERY, true); break; case Q_ENABLE_ABORT_ON_ERROR: set_property(command, P_ABORT, true); break; case Q_DISABLE_ABORT_ON_ERROR: set_property(command, P_ABORT, false); break; case Q_ENABLE_RESULT_LOG: set_property(command, P_RESULT, false); break; case Q_DISABLE_RESULT_LOG: set_property(command, P_RESULT, true); break; case Q_ENABLE_CONNECT_LOG: set_property(command, P_CONNECT, false); break; case Q_DISABLE_CONNECT_LOG: set_property(command, P_CONNECT, true); break; case Q_ENABLE_WARNINGS: do_enable_warnings(command); break; case Q_DISABLE_WARNINGS: do_disable_warnings(command); break; case Q_ENABLE_INFO: set_property(command, P_INFO, false); break; case Q_DISABLE_INFO: set_property(command, P_INFO, true); break; case Q_ENABLE_SESSION_TRACK_INFO: set_property(command, P_SESSION_TRACK, true); break; case Q_DISABLE_SESSION_TRACK_INFO: set_property(command, P_SESSION_TRACK, false); break; case Q_ENABLE_METADATA: set_property(command, P_META, true); break; case Q_DISABLE_METADATA: set_property(command, P_META, false); break; case Q_SOURCE: do_source(command); break; case Q_SLEEP: do_sleep(command); break; case Q_WAIT_FOR_SLAVE_TO_STOP: do_wait_for_slave_to_stop(command); break; case Q_INC: do_modify_var(command, DO_INC); break; case Q_DEC: do_modify_var(command, DO_DEC); break; case Q_ECHO: do_echo(command); command_executed++; break; case Q_REMOVE_FILE: do_remove_file(command); break; case Q_REMOVE_FILES_WILDCARD: do_remove_files_wildcard(command); break; case Q_COPY_FILES_WILDCARD: do_copy_files_wildcard(command); break; case Q_MKDIR: do_mkdir(command); break; case Q_RMDIR: do_rmdir(command, false); break; case Q_FORCE_RMDIR: do_rmdir(command, true); break; case Q_FORCE_CPDIR: do_force_cpdir(command); break; case Q_LIST_FILES: do_list_files(command); break; case Q_LIST_FILES_WRITE_FILE: do_list_files_write_file_command(command, false); break; case Q_LIST_FILES_APPEND_FILE: do_list_files_write_file_command(command, true); break; case Q_FILE_EXIST: do_file_exist(command); break; case Q_WRITE_FILE: do_write_file(command); break; case Q_APPEND_FILE: do_append_file(command); break; case Q_DIFF_FILES: do_diff_files(command); break; case Q_SEND_QUIT: do_send_quit(command); break; case Q_CHANGE_USER: do_change_user(command); break; case Q_CAT_FILE: do_cat_file(command); break; case Q_COPY_FILE: do_copy_file(command); break; case Q_MOVE_FILE: do_move_file(command); break; case Q_CHMOD_FILE: do_chmod_file(command); break; case Q_PERL: do_perl(command); break; case Q_RESULT_FORMAT_VERSION: do_result_format_version(command); break; case Q_DELIMITER: do_delimiter(command); break; case Q_DISPLAY_VERTICAL_RESULTS: display_result_vertically = true; break; case Q_DISPLAY_HORIZONTAL_RESULTS: display_result_vertically = false; break; case Q_SORTED_RESULT:
display_result_sorted = true; start_sort_column = 0; break; case Q_PARTIALLY_SORTED_RESULT:
display_result_sorted = true; start_sort_column = atoi(command->first_argument); command->last_argument = command->end; break; case Q_LOWERCASE:
display_result_lower = true; break; case Q_SKIP_IF_HYPERGRAPH:
skip_if_hypergraph = true; break; case Q_LET: do_let(command); break; case Q_EXPR: do_expr(command); break; case Q_EVAL: case Q_QUERY_VERTICAL: case Q_QUERY_HORIZONTAL: if (command->query == command->query_buf) { command->query = command->first_argument; command->first_word_len = 0; } [[fallthrough]]; case Q_QUERY: case Q_REAP: { bool old_display_result_vertically = display_result_vertically; int flags = QUERY_REAP_FLAG | QUERY_SEND_FLAG;
if (q_send_flag) { flags = QUERY_SEND_FLAG; if (q_send_flag == 2) command->type = Q_SEND_EVAL; q_send_flag = 0; } else if (command->type == Q_REAP) { flags = QUERY_REAP_FLAG; }
display_result_vertically |= (command->type == Q_QUERY_VERTICAL);
if (explain_protocol_enabled) run_explain(cur_con, command, flags, false); if (json_explain_protocol_enabled) run_explain(cur_con, command, flags, true);
if (*output_file) { strmake(command->output_file, output_file, sizeof(output_file) - 1); *output_file = 0; } run_query(cur_con, command, flags); display_opt_trace(cur_con, command, flags); command_executed++; command->last_argument = command->end;
display_result_vertically = old_display_result_vertically;
break; } case Q_SEND: case Q_SEND_EVAL: if (!*command->first_argument) { if (command->type == Q_SEND) q_send_flag = 1; else if (command->type == Q_SEND_EVAL) q_send_flag = 2; break; }
if (command->query == command->query_buf) command->query = command->first_argument;
run_query(cur_con, command, QUERY_SEND_FLAG); command_executed++; command->last_argument = command->end; break; case Q_ERROR: do_error(command); break; case Q_REPLACE: do_get_replace(command); break; case Q_REPLACE_REGEX: do_get_replace_regex(command); break; case Q_REPLACE_COLUMN: do_get_replace_column(command); break; case Q_REPLACE_NUMERIC_ROUND: do_get_replace_numeric_round(command); break; case Q_SAVE_MASTER_POS: do_save_master_pos(); break; case Q_SYNC_WITH_MASTER: do_sync_with_master(command); break; case Q_SYNC_SLAVE_WITH_MASTER: { do_save_master_pos(); if (*command->first_argument) select_connection(command); else select_connection_name("slave"); do_sync_with_master2(command, 0); break; } case Q_COMMENT: { command->last_argument = command->end;
if (opt_result_format_version == 1) break;
if (disable_query_log) break;
const char *p = command->query; if (p && *p == '#' && *(p + 1) == '#') { dynstr_append_mem(&ds_res, command->query, command->query_len); dynstr_append(&ds_res, "\n"); } break; } case Q_EMPTY_LINE: if (opt_result_format_version == 1) break;
if (disable_query_log) break;
dynstr_append(&ds_res, "\n"); break; case Q_PING: handle_command_error(command, mysql_ping(&cur_con->mysql)); break; case Q_RESET_CONNECTION: do_reset_connection(); global_attrs->clear(); break; case Q_QUERY_ATTRIBUTES: do_query_attributes(command); break; case Q_SEND_SHUTDOWN: if (opt_offload_count_file) { if (secondary_engine->offload_count(&cur_con->mysql, "after")) cleanup_and_exit(1); }
handle_command_error( command, mysql_query_wrapper(&cur_con->mysql, "shutdown")); break; case Q_SHUTDOWN_SERVER: do_shutdown_server(command); break; case Q_EXEC: case Q_EXECW: do_exec(command, false); command_executed++; break; case Q_EXEC_BACKGROUND: do_exec(command, true); command_executed++; break; case Q_START_TIMER: timer_start = timer_now(); break; case Q_END_TIMER: timer_output(); break; case Q_CHARACTER_SET: do_set_charset(command); break; case Q_DISABLE_PS_PROTOCOL: set_property(command, P_PS, false); close_statements(); break; case Q_ENABLE_PS_PROTOCOL: set_property(command, P_PS, ps_protocol); break; case Q_DISABLE_RECONNECT: set_reconnect(&cur_con->mysql, 0); break; case Q_ENABLE_RECONNECT: set_reconnect(&cur_con->mysql, 1); enable_async_client = false; close_statements(); break; case Q_ENABLE_ASYNC_CLIENT: set_property(command, P_ASYNC, true); break; case Q_DISABLE_ASYNC_CLIENT: set_property(command, P_ASYNC, false); break; case Q_DISABLE_TESTCASE: if (testcase_disabled == 0) do_disable_testcase(command); else die("Test case is already disabled."); break; case Q_ENABLE_TESTCASE: if (testcase_disabled == 1) testcase_disabled = false; else die("Test case is already enabled."); break; case Q_DIE: die("%s", command->first_argument); break; case Q_EXIT: abort_flag = true; break; case Q_SKIP: { DYNAMIC_STRING ds_skip_msg; init_dynamic_string(&ds_skip_msg, nullptr, command->query_len);
do_eval(&ds_skip_msg, command->first_argument, command->end, false);
char skip_msg[FN_REFLEN]; strmake(skip_msg, ds_skip_msg.str, FN_REFLEN - 1); dynstr_free(&ds_skip_msg);
if (!no_skip) { abort_not_supported_test("%s", skip_msg); } else { const char *path = cur_file->file_name; const char *fn = get_filename_from_path(path);
if (excluded_string && strstr(excluded_string, fn)) { abort_not_supported_test("%s", skip_msg); } else { command->last_argument = command->end; skip_ignored = true; } } } break; case Q_OUTPUT: { static DYNAMIC_STRING ds_to_file; const struct command_arg output_file_args[] = { {"to_file", ARG_STRING, true, &ds_to_file, "Output filename"}}; check_command_args(command, command->first_argument, output_file_args, 1, ' '); strmake(output_file, ds_to_file.str, FN_REFLEN); dynstr_free(&ds_to_file); break; }
default: processed = 0; break; } }
if (!processed) { current_line_inc = 0; switch (command->type) { case Q_WHILE: do_block(cmd_while, command); break; case Q_IF: do_block(cmd_if, command); break; case Q_ASSERT: do_block(cmd_assert, command); break; case Q_END_BLOCK: do_done(command); break; default: current_line_inc = 1; break; } } else check_eol_junk(command->last_argument);
if (command_executed != last_command_executed || command->used_replace) {
free_all_replace();
display_result_sorted = false; display_result_lower = false; skip_if_hypergraph = false; } last_command_executed = command_executed;
parser.current_line += current_line_inc; if (opt_mark_progress) mark_progress(&progress_file, parser.current_line);
flush_ds_res(); }
|--
if (log_file.bytes_written()) { if (result_file_name) {
if (record) {
if (my_copy(log_file.file_name(), result_file_name, MYF(0)) != 0) die("Failed to copy '%s' to '%s', errno: %d", log_file.file_name(), result_file_name, errno);
} else { check_result(); } } } else { if (!result_file_name || record || compare_files(log_file.file_name(), result_file_name)) { die("The test didn't produce any output"); } else { empty_result = true; } }
if (!command_executed && result_file_name && !empty_result) die("No queries executed but non-empty result file found!");
verbose_msg("Test has succeeded!"); timer_output(); cleanup_and_exit(0); return 0; }
|