Repository navigation
Conversation
pgcli -c "select nope" exited 0, so a script calling pgcli could not tell a failed statement from a good one. psql uses the status of the last -c or -f that ran: a failed -c exits 1, a script exits 0 even with errors in it, and with ON_ERROR_STOP the first failure stops everything after it and a failed script exits 3. on_error = STOP (the default) now plays ON_ERROR_STOP and RESUME plays psql's default. The same loop had two more departures from psql: under RESUME a failed -c kept the next -c from running, and under STOP it did not stop the -f files. Both follow psql now. Nine cases, each measured with psql 18 against a live server, plus two tests through a real connection; ten of the eleven fail without the change (the remaining case already matched). The two behave scenarios that ran an invalid query expected a successful exit; they now expect an error, and fail without the change.
DiegoDAF
added a commit
to DiegoDAF/pgcli.daf
that referenced
this pull request
Oct 16, 2026
Contributor
Author
|
The red builds are |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
pgcli -c "select nope"exits 0, so a shell script or a CI job that calls pgcli cannot tell a failed statement from a good one. This makes-cand-fexit the way psql does.psql's rule, measured with psql 18 against a live server: the exit status is that of the last
-cor-fthat ran. A failed-cexits 1. A script exits 0 even with errors in it, unlessON_ERROR_STOPis set; then the first failure stops everything after it, and a failed script exits 3. pgcli'son_error = STOP(the default) plays the part ofON_ERROR_STOP, andRESUMEplays psql's default:-c "select nope"-c "select 1" -c "select nope", RESUME-cruns-c "select 1" -c "select nope" -c "select 2", RESUMEselect 2skipped-f err.sql, STOP /ON_ERROR_STOP-f err.sql -f ok.sql, RESUMEok.sqlskipped-c "select nope" -f err.sql, STOP /ON_ERROR_STOPThe last rows are the same loop's other departures from psql: under
RESUMEa failure kept the next-cor-ffrom running, and underSTOPa failed-cdid not stop the files.One difference remains and is left alone here: pgcli runs every
-cbefore every-f, while psql follows the order on the command line.Tests: nine parametrized cases mirroring the measured psql runs, plus two through a real connection (a failed
-cexits 1, a failed script exits 3). Ten of the eleven fail on main; the remaining case already matched psql. The two behave scenarios that run an invalid query assertedpgcli exits successfully, which wrote the bug down as expected behaviour (that assertion came with the original-c/-fPRs, mine); they now assert an error exit, and fail without this change.Checklist
changelog.rst.AUTHORSfile (or it is already there).pip install pre-commit && pre-commit install).On the third box:
.pre-commit-config.yamlpins an olderruff-pre-committhan the onetox -e styleinstalls, and the two disagree on formatting, so I ranruff checkandruff formatmatching the CI instead, both clean.