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

Function execute_init_command

sql/sql_parse.cc:500–533  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

498}
499
500void execute_init_command(THD *thd, LEX_STRING *init_command,
501 mysql_rwlock_t *var_lock)
502{
503 Vio* save_vio;
504 ulong save_client_capabilities;
505
506 mysql_rwlock_rdlock(var_lock);
507 if (!init_command->length)
508 {
509 mysql_rwlock_unlock(var_lock);
510 return;
511 }
512
513 /*
514 copy the value under a lock, and release the lock.
515 init_command has to be executed without a lock held,
516 as it may try to change itself
517 */
518 size_t len= init_command->length;
519 char *buf= thd->strmake(init_command->str, len);
520 mysql_rwlock_unlock(var_lock);
521
522 save_client_capabilities= thd->client_capabilities;
523 thd->client_capabilities|= CLIENT_MULTI_QUERIES;
524 /*
525 We don't need return result of execution to client side.
526 To forbid this we should set thd->net.vio to 0.
527 */
528 save_vio= thd->net.vio;
529 thd->net.vio= 0;
530 dispatch_command(COM_QUERY, thd, buf, len);
531 thd->client_capabilities= save_client_capabilities;
532 thd->net.vio= save_vio;
533}
534
535/* This works because items are allocated with sql_alloc() */
536

Callers

nothing calls this directly

Calls 2

dispatch_commandFunction · 0.85
strmakeMethod · 0.80

Tested by

no test coverage detected