diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c index 62cf1f404a..81aac0988a 100644 --- a/src/bin/psql/mainloop.c +++ b/src/bin/psql/mainloop.c @@ -233,6 +233,18 @@ MainLoop(FILE *source) continue; } + /* quit (without slash) or exit -- exit psql */ + if (pset.cur_cmd_interactive && query_buf->len == 0 && + (pg_strncasecmp(line, "exit", 4) == 0 || pg_strncasecmp(line, "quit", 4) == 0) && + (line[4] == '\0' || line[4] == ';' || isspace((unsigned char) line[4]))) + { + free(line); + fflush(stdout); + + successResult = EXIT_SUCCESS; + break; + } + /* echo back if flag is set, unless interactive */ if (pset.echo == PSQL_ECHO_ALL && !pset.cur_cmd_interactive) {