Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd3ab618

Browse files
committed
psql: Add tests for \errverbose
This is another piece of functionality that happens while a user queryis being sent and which did not have any test coverage.
1 parentddee016 commitd3ab618

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

‎src/bin/psql/t/001_basic.pl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,51 @@ sub psql_fails_like
132132
psql:<stdin>:2: fatal: connection to server was lost',
133133
'server crash: error message');
134134

135+
# test \errverbose
136+
#
137+
# (This is not in the regular regression tests because the output
138+
# contains the source code location and we don't want to have to
139+
# update that every time it changes.)
140+
141+
psql_like(
142+
$node,
143+
'SELECT 1;
144+
\errverbose',
145+
qr/^1\nThere is no previous error\.$/,
146+
'\errverbose with no previous error');
147+
148+
# There are three main ways to run a query that might affect
149+
# \errverbose: The normal way, using a cursor by setting FETCH_COUNT,
150+
# and using \gdesc. Test them all.
151+
152+
like(($node->psql('postgres',"SELECT error;\n\\errverbose",on_error_stop=> 0))[2],
153+
qr/\A^psql:<stdin>:1: ERROR: .*$
154+
^LINE 1: SELECT error;$
155+
^ *^.*$
156+
^psql:<stdin>:2: error: ERROR: [0-9A-Z]{5}: .*$
157+
^LINE 1: SELECT error;$
158+
^ *^.*$
159+
^LOCATION: .*$/m,
160+
'\errverbose after normal query with error');
161+
162+
like(($node->psql('postgres',"\\set FETCH_COUNT 1\nSELECT error;\n\\errverbose",on_error_stop=> 0))[2],
163+
qr/\A^psql:<stdin>:2: ERROR: .*$
164+
^LINE 2: SELECT error;$
165+
^ *^.*$
166+
^psql:<stdin>:3: error: ERROR: [0-9A-Z]{5}: .*$
167+
^LINE 2: SELECT error;$
168+
^ *^.*$
169+
^LOCATION: .*$/m,
170+
'\errverbose after FETCH_COUNT query with error');
171+
172+
like(($node->psql('postgres',"SELECT error\\gdesc\n\\errverbose",on_error_stop=> 0))[2],
173+
qr/\A^psql:<stdin>:1: ERROR: .*$
174+
^LINE 1: SELECT error$
175+
^ *^.*$
176+
^psql:<stdin>:2: error: ERROR: [0-9A-Z]{5}: .*$
177+
^LINE 1: SELECT error$
178+
^ *^.*$
179+
^LOCATION: .*$/m,
180+
'\errverbose after \gdesc with error');
181+
135182
done_testing();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp