]> granicus.if.org Git - postgresql/blobdiff - src/bin/psql/startup.c
Support \if ... \elif ... \else ... \endif in psql scripting.
[postgresql] / src / bin / psql / startup.c
index 694f0ef257fe1b431d81fbd1333e3a125b557f7c..8068a28b4e2142c22c69370f1517eef8b6e6b623 100644 (file)
@@ -331,6 +331,7 @@ main(int argc, char *argv[])
                        else if (cell->action == ACT_SINGLE_SLASH)
                        {
                                PsqlScanState scan_state;
+                               ConditionalStack cond_stack;
 
                                if (pset.echo == PSQL_ECHO_ALL)
                                        puts(cell->val);
@@ -339,11 +340,17 @@ main(int argc, char *argv[])
                                psql_scan_setup(scan_state,
                                                                cell->val, strlen(cell->val),
                                                                pset.encoding, standard_strings());
+                               cond_stack = conditional_stack_create();
+                               psql_scan_set_passthrough(scan_state, (void *) cond_stack);
 
-                               successResult = HandleSlashCmds(scan_state, NULL) != PSQL_CMD_ERROR
+                               successResult = HandleSlashCmds(scan_state,
+                                                                                               cond_stack,
+                                                                                               NULL,
+                                                                                               NULL) != PSQL_CMD_ERROR
                                        ? EXIT_SUCCESS : EXIT_FAILURE;
 
                                psql_scan_destroy(scan_state);
+                               conditional_stack_destroy(cond_stack);
                        }
                        else if (cell->action == ACT_FILE)
                        {