MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / dispatch_command

Function dispatch_command

sql/sql_parse.cc:570–759  ·  view source on GitHub ↗

Perform one connection-level (COM_XXXX) command. @param command type of command to perform @param thd connection handle @param packet data for the command, packet is always null-terminated @param packet_length length of packet + 1 (to show that data is null-terminated) except for COM_SLEEP, where it can be ze

Source from the content-addressed store, hash-verified

568 COM_QUIT/COM_SHUTDOWN
569*/
570bool dispatch_command(enum enum_server_command command, THD *thd,
571 char* packet, uint packet_length)
572{
573 bool error= 0;
574 DBUG_ENTER("dispatch_command");
575 DBUG_PRINT("info",("packet: '%*.s'; command: %d", packet_length, packet, command));
576
577 DBUG_EXECUTE_IF("crash_dispatch_command_before",
578 { DBUG_PRINT("crash_dispatch_command_before", ("now"));
579 DBUG_ABORT(); });
580
581 /* DTRACE instrumentation, begin */
582 MYSQL_COMMAND_START(thd->thread_id, command,
583 &thd->security_ctx->priv_user[0],
584 (char *) thd->security_ctx->host_or_ip);
585
586 thd->set_command(command);
587
588 thd->clear_slow_extended();
589 thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */
590 thd->set_time();
591 if (!thd->is_valid_time())
592 {
593 /*
594 If the time has got past 2038 we need to shut this server down
595 We do this by making sure every command is a shutdown and we
596 have enough privileges to shut the server down
597
598 TODO: remove this when we have full 64 bit my_time_t support
599 */
600 thd->security_ctx->master_access|= SHUTDOWN_ACL;
601 command= COM_SHUTDOWN;
602 }
603
604 /**
605 Clear the set of flags that are expected to be cleared at the
606 beginning of each command.
607 */
608 thd->server_status&= ~SERVER_STATUS_CLEAR_SET;
609
610 /**
611 Enforce password expiration for all RPC commands, except the
612 following:
613
614 COM_QUERY does a more fine-grained check later.
615 COM_STMT_CLOSE and COM_STMT_SEND_LONG_DATA don't return anything.
616 COM_PING only discloses information that the server is running,
617 and that's available through other means.
618 COM_QUIT should work even for expired statements.
619 */
620 if (unlikely(thd->security_ctx->password_expired &&
621 command != COM_QUERY &&
622 command != COM_STMT_CLOSE &&
623 command != COM_STMT_SEND_LONG_DATA &&
624 command != COM_PING &&
625 command != COM_QUIT))
626 {
627 my_error(ER_MUST_CHANGE_PASSWORD, MYF(0));

Callers 2

sql_parserFunction · 0.85
execute_init_commandFunction · 0.85

Calls 15

my_errorFunction · 0.85
my_messageFunction · 0.85
alloc_queryFunction · 0.85
mysql_parseFunction · 0.85
set_commandMethod · 0.80
clear_slow_extendedMethod · 0.80
is_valid_timeMethod · 0.80
update_server_statusMethod · 0.80
get_stmt_daMethod · 0.80
set_query_and_idMethod · 0.80
reset_queryMethod · 0.80
set_timeMethod · 0.45

Tested by

no test coverage detected