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

Function exec_command

src/bin/psql/command.c:282–427  ·  view source on GitHub ↗

* Subroutine to actually try to execute a backslash command. * * The typical "success" result code is PSQL_CMD_SKIP_LINE, although some * commands return something else. Failure results are PSQL_CMD_ERROR, * unless PSQL_CMD_UNKNOWN is more appropriate. */

Source from the content-addressed store, hash-verified

280 * unless PSQL_CMD_UNKNOWN is more appropriate.
281 */
282static backslashResult
283exec_command(const char *cmd,
284 PsqlScanState scan_state,
285 ConditionalStack cstack,
286 PQExpBuffer query_buf,
287 PQExpBuffer previous_buf)
288{
289 backslashResult status;
290 bool active_branch = conditional_active(cstack);
291
292 /*
293 * In interactive mode, warn when we're ignoring a command within a false
294 * \if-branch. But we continue on, so as to parse and discard the right
295 * amount of parameter text. Each individual backslash command subroutine
296 * is responsible for doing nothing after discarding appropriate
297 * arguments, if !active_branch.
298 */
299 if (pset.cur_cmd_interactive && !active_branch &&
300 !is_branching_command(cmd))
301 {
302 pg_log_warning("\\%s command ignored; use \\endif or Ctrl-C to exit current \\if block",
303 cmd);
304 }
305
306 if (strcmp(cmd, "a") == 0)
307 status = exec_command_a(scan_state, active_branch);
308 else if (strcmp(cmd, "C") == 0)
309 status = exec_command_C(scan_state, active_branch);
310 else if (strcmp(cmd, "c") == 0 || strcmp(cmd, "connect") == 0)
311 status = exec_command_connect(scan_state, active_branch);
312 else if (strcmp(cmd, "cd") == 0)
313 status = exec_command_cd(scan_state, active_branch, cmd);
314 else if (strcmp(cmd, "conninfo") == 0)
315 status = exec_command_conninfo(scan_state, active_branch);
316 else if (pg_strcasecmp(cmd, "copy") == 0)
317 status = exec_command_copy(scan_state, active_branch);
318 else if (strcmp(cmd, "copyright") == 0)
319 status = exec_command_copyright(scan_state, active_branch);
320 else if (strcmp(cmd, "crosstabview") == 0)
321 status = exec_command_crosstabview(scan_state, active_branch);
322 else if (cmd[0] == 'd')
323 status = exec_command_d(scan_state, active_branch, cmd);
324 else if (strcmp(cmd, "e") == 0 || strcmp(cmd, "edit") == 0)
325 status = exec_command_edit(scan_state, active_branch,
326 query_buf, previous_buf);
327 else if (strcmp(cmd, "ef") == 0)
328 status = exec_command_ef_ev(scan_state, active_branch, query_buf, true);
329 else if (strcmp(cmd, "ev") == 0)
330 status = exec_command_ef_ev(scan_state, active_branch, query_buf, false);
331 else if (strcmp(cmd, "echo") == 0 || strcmp(cmd, "qecho") == 0 ||
332 strcmp(cmd, "warn") == 0)
333 status = exec_command_echo(scan_state, active_branch, cmd);
334 else if (strcmp(cmd, "elif") == 0)
335 status = exec_command_elif(scan_state, cstack, query_buf);
336 else if (strcmp(cmd, "else") == 0)
337 status = exec_command_else(scan_state, cstack, query_buf);
338 else if (strcmp(cmd, "endif") == 0)
339 status = exec_command_endif(scan_state, cstack, query_buf);

Callers 1

HandleSlashCmdsFunction · 0.85

Calls 15

conditional_activeFunction · 0.85
is_branching_commandFunction · 0.85
exec_command_aFunction · 0.85
exec_command_CFunction · 0.85
exec_command_connectFunction · 0.85
exec_command_cdFunction · 0.85
exec_command_conninfoFunction · 0.85
pg_strcasecmpFunction · 0.85
exec_command_copyFunction · 0.85
exec_command_copyrightFunction · 0.85
exec_command_dFunction · 0.85

Tested by

no test coverage detected