MCPcopy Create free account
hub / github.com/apache/cloudberry / executeMetaCommand

Function executeMetaCommand

src/bin/pgbench/pgbench.c:3626–3815  ·  view source on GitHub ↗

* Subroutine for advanceConnectionState -- initiate or execute the current * meta command, and return the next state to set. * * *now is updated to the current time, unless the command is expected to * take no time to execute. */

Source from the content-addressed store, hash-verified

3624 * take no time to execute.
3625 */
3626static ConnectionStateEnum
3627executeMetaCommand(CState *st, pg_time_usec_t *now)
3628{
3629 Command *command = sql_script[st->use_file].commands[st->command];
3630 int argc;
3631 char **argv;
3632
3633 Assert(command != NULL && command->type == META_COMMAND);
3634
3635 argc = command->argc;
3636 argv = command->argv;
3637
3638 if (unlikely(__pg_log_level <= PG_LOG_DEBUG))
3639 {
3640 PQExpBufferData buf;
3641
3642 initPQExpBuffer(&buf);
3643
3644 printfPQExpBuffer(&buf, "client %d executing \\%s", st->id, argv[0]);
3645 for (int i = 1; i < argc; i++)
3646 appendPQExpBuffer(&buf, " %s", argv[i]);
3647
3648 pg_log_debug("%s", buf.data);
3649
3650 termPQExpBuffer(&buf);
3651 }
3652
3653 if (command->meta == META_SLEEP)
3654 {
3655 int usec;
3656
3657 /*
3658 * A \sleep doesn't execute anything, we just get the delay from the
3659 * argument, and enter the CSTATE_SLEEP state. (The per-command
3660 * latency will be recorded in CSTATE_SLEEP state, not here, after the
3661 * delay has elapsed.)
3662 */
3663 if (!evaluateSleep(st, argc, argv, &usec))
3664 {
3665 commandFailed(st, "sleep", "execution of meta-command failed");
3666 return CSTATE_ABORTED;
3667 }
3668
3669 pg_time_now_lazy(now);
3670 st->sleep_until = (*now) + usec;
3671 return CSTATE_SLEEP;
3672 }
3673 else if (command->meta == META_SET)
3674 {
3675 PgBenchExpr *expr = command->expr;
3676 PgBenchValue result;
3677
3678 if (!evaluateExpr(st, expr, &result))
3679 {
3680 commandFailed(st, argv[0], "evaluation of meta-command failed");
3681 return CSTATE_ABORTED;
3682 }
3683

Callers 1

advanceConnectionStateFunction · 0.85

Calls 15

initPQExpBufferFunction · 0.85
printfPQExpBufferFunction · 0.85
appendPQExpBufferFunction · 0.85
termPQExpBufferFunction · 0.85
evaluateSleepFunction · 0.85
commandFailedFunction · 0.85
pg_time_now_lazyFunction · 0.85
evaluateExprFunction · 0.85
putVariableValueFunction · 0.85
valueTruthFunction · 0.85
conditional_stack_pushFunction · 0.85
conditional_stack_peekFunction · 0.85

Tested by

no test coverage detected