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

Function exec_command_include

src/bin/psql/command.c:1598–1628  ·  view source on GitHub ↗

* \i and \ir -- include a file */

Source from the content-addressed store, hash-verified

1596 * \i and \ir -- include a file
1597 */
1598static backslashResult
1599exec_command_include(PsqlScanState scan_state, bool active_branch, const char *cmd)
1600{
1601 bool success = true;
1602
1603 if (active_branch)
1604 {
1605 char *fname = psql_scan_slash_option(scan_state,
1606 OT_NORMAL, NULL, true);
1607
1608 if (!fname)
1609 {
1610 pg_log_error("\\%s: missing required argument", cmd);
1611 success = false;
1612 }
1613 else
1614 {
1615 bool include_relative;
1616
1617 include_relative = (strcmp(cmd, "ir") == 0
1618 || strcmp(cmd, "include_relative") == 0);
1619 expand_tilde(&fname);
1620 success = (process_file(fname, include_relative) == EXIT_SUCCESS);
1621 free(fname);
1622 }
1623 }
1624 else
1625 ignore_slash_options(scan_state);
1626
1627 return success ? PSQL_CMD_SKIP_LINE : PSQL_CMD_ERROR;
1628}
1629
1630/*
1631 * \if <expr> -- beginning of an \if..\endif block

Callers 1

exec_commandFunction · 0.85

Calls 3

expand_tildeFunction · 0.85
ignore_slash_optionsFunction · 0.85
process_fileFunction · 0.70

Tested by

no test coverage detected