--- src/bin/psql/mainloop.c +++ src/bin/psql/mainloop.c @@ -33,7 +33,7 @@ PQExpBuffer history_buf; /* earlier lines of a multi-line command, not * yet saved to readline history */ char *line; /* current line of input */ - int added_nl_pos; + int added_nl_pos, j; bool success; bool line_saved_in_history; volatile int successResult = EXIT_SUCCESS; @@ -72,7 +72,7 @@ } /* main loop to get queries and execute them */ - while (successResult == EXIT_SUCCESS) + for (j = 0; successResult == EXIT_SUCCESS; j++) { /* * Clean up after a previous Control-C @@ -138,6 +138,12 @@ successResult = EXIT_FAILURE; } + if (!j && line && line[0] == '#' && line[1] == '!') + { + free(line); + continue; + } + /* * query_buf holds query already accumulated. line is the malloc'd * new line of input (note it must be freed before looping around!)