diff options
| author | Peter Eisentraut | 2022-03-31 14:09:44 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2022-03-31 14:20:27 +0000 |
| commit | d3ab618290543017402b3bec9d36dde881becb18 (patch) | |
| tree | e03d39d7579239d5078b64ccea68d8dffe53a8d5 | |
| parent | ddee016b342cddcfb97325afac0a65c502932e5f (diff) | |
psql: Add tests for \errverbose
This is another piece of functionality that happens while a user query
is being sent and which did not have any test coverage.
| -rw-r--r-- | src/bin/psql/t/001_basic.pl | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/bin/psql/t/001_basic.pl b/src/bin/psql/t/001_basic.pl index 02a84543fd5..66796f4978d 100644 --- a/src/bin/psql/t/001_basic.pl +++ b/src/bin/psql/t/001_basic.pl @@ -132,4 +132,51 @@ server closed the connection unexpectedly psql:<stdin>:2: fatal: connection to server was lost', 'server crash: error message'); +# test \errverbose +# +# (This is not in the regular regression tests because the output +# contains the source code location and we don't want to have to +# update that every time it changes.) + +psql_like( + $node, + 'SELECT 1; +\errverbose', + qr/^1\nThere is no previous error\.$/, + '\errverbose with no previous error'); + +# There are three main ways to run a query that might affect +# \errverbose: The normal way, using a cursor by setting FETCH_COUNT, +# and using \gdesc. Test them all. + +like(($node->psql('postgres', "SELECT error;\n\\errverbose", on_error_stop => 0))[2], + qr/\A^psql:<stdin>:1: ERROR: .*$ +^LINE 1: SELECT error;$ +^ *^.*$ +^psql:<stdin>:2: error: ERROR: [0-9A-Z]{5}: .*$ +^LINE 1: SELECT error;$ +^ *^.*$ +^LOCATION: .*$/m, + '\errverbose after normal query with error'); + +like(($node->psql('postgres', "\\set FETCH_COUNT 1\nSELECT error;\n\\errverbose", on_error_stop => 0))[2], + qr/\A^psql:<stdin>:2: ERROR: .*$ +^LINE 2: SELECT error;$ +^ *^.*$ +^psql:<stdin>:3: error: ERROR: [0-9A-Z]{5}: .*$ +^LINE 2: SELECT error;$ +^ *^.*$ +^LOCATION: .*$/m, + '\errverbose after FETCH_COUNT query with error'); + +like(($node->psql('postgres', "SELECT error\\gdesc\n\\errverbose", on_error_stop => 0))[2], + qr/\A^psql:<stdin>:1: ERROR: .*$ +^LINE 1: SELECT error$ +^ *^.*$ +^psql:<stdin>:2: error: ERROR: [0-9A-Z]{5}: .*$ +^LINE 1: SELECT error$ +^ *^.*$ +^LOCATION: .*$/m, + '\errverbose after \gdesc with error'); + done_testing(); |
