psql: Fix exit status when query is canceled
authorPeter Eisentraut <peter@eisentraut.org>
Sat, 22 Oct 2022 07:41:38 +0000 (09:41 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Sat, 22 Oct 2022 07:42:52 +0000 (09:42 +0200)
Because of a small thinko in 7844c9918a43b494adde3575891d217a37062378,
psql -c would exit successfully when a query is canceled.  Fix this so
that it exits with a nonzero status, just like for all other errors.

src/bin/psql/common.c

index 4f310a8019dc41b897888f11b918706f8c5ed3ae..864f195992f52c0e7330fe9faa190f1576fceee6 100644 (file)
@@ -1114,7 +1114,7 @@ SendQuery(const char *query)
             pset.crosstab_flag || !is_select_command(query))
    {
        /* Default fetch-it-all-and-print mode */
-       OK = (ExecQueryAndProcessResults(query, &elapsed_msec, &svpt_gone, false, NULL, NULL) >= 0);
+       OK = (ExecQueryAndProcessResults(query, &elapsed_msec, &svpt_gone, false, NULL, NULL) > 0);
    }
    else
    {