@@ -132,4 +132,51 @@ sub psql_fails_like
132
132
psql:<stdin>:2: fatal: connection to server was lost' ,
133
133
' server crash: error message' );
134
134
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\n There 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\n SELECT 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
+
135
182
done_testing();
0 commit comments