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

Function exec_command_endif

src/bin/psql/command.c:1826–1861  ·  view source on GitHub ↗

* \endif -- ends an \if...\endif block */

Source from the content-addressed store, hash-verified

1824 * \endif -- ends an \if...\endif block
1825 */
1826static backslashResult
1827exec_command_endif(PsqlScanState scan_state, ConditionalStack cstack,
1828 PQExpBuffer query_buf)
1829{
1830 bool success = true;
1831
1832 switch (conditional_stack_peek(cstack))
1833 {
1834 case IFSTATE_TRUE:
1835 case IFSTATE_ELSE_TRUE:
1836 /* Close the \if block, keeping the query text */
1837 success = conditional_stack_pop(cstack);
1838 Assert(success);
1839 break;
1840 case IFSTATE_FALSE:
1841 case IFSTATE_IGNORED:
1842 case IFSTATE_ELSE_FALSE:
1843
1844 /*
1845 * Discard any query text added by the just-skipped branch.
1846 */
1847 discard_query_text(scan_state, cstack, query_buf);
1848
1849 /* Close the \if block */
1850 success = conditional_stack_pop(cstack);
1851 Assert(success);
1852 break;
1853 case IFSTATE_NONE:
1854 /* no \if to end */
1855 pg_log_error("\\endif: no matching \\if");
1856 success = false;
1857 break;
1858 }
1859
1860 return success ? PSQL_CMD_SKIP_LINE : PSQL_CMD_ERROR;
1861}
1862
1863/*
1864 * \l -- list databases

Callers 1

exec_commandFunction · 0.85

Calls 3

conditional_stack_peekFunction · 0.85
conditional_stack_popFunction · 0.85
discard_query_textFunction · 0.85

Tested by

no test coverage detected