|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.2 2003/06/21 21:51:34 tgl Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.3 2003/06/21 23:25:38 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -1183,15 +1183,30 @@ pqEndcopy2(PGconn *conn)
|
1183 | 1183 | }
|
1184 | 1184 |
|
1185 | 1185 | /*
|
1186 |
| - * Trouble. The worst case is that we've lost sync with the backend |
1187 |
| - * entirely due to application screwup of the copy in/out protocol. To |
1188 |
| - * recover, reset the connection (talk about using a sledgehammer...) |
| 1186 | + * Trouble. For backwards-compatibility reasons, we issue the error |
| 1187 | + * message as if it were a notice (would be nice to get rid of this |
| 1188 | + * silliness, but too many apps probably don't handle errors from |
| 1189 | + * PQendcopy reasonably). Note that the app can still obtain the |
| 1190 | + * error status from the PGconn object. |
1189 | 1191 | */
|
1190 |
| - PQclear(result); |
1191 |
| - |
1192 | 1192 | if (conn->errorMessage.len > 0)
|
| 1193 | + { |
| 1194 | + /* We have to strip the trailing newline ... pain in neck... */ |
| 1195 | + char svLast = conn->errorMessage.data[conn->errorMessage.len-1]; |
| 1196 | + |
| 1197 | + if (svLast == '\n') |
| 1198 | + conn->errorMessage.data[conn->errorMessage.len-1] = '\0'; |
1193 | 1199 | PGDONOTICE(conn, conn->errorMessage.data);
|
| 1200 | + conn->errorMessage.data[conn->errorMessage.len-1] = svLast; |
| 1201 | + } |
1194 | 1202 |
|
| 1203 | + PQclear(result); |
| 1204 | + |
| 1205 | + /* |
| 1206 | + * The worst case is that we've lost sync with the backend |
| 1207 | + * entirely due to application screwup of the copy in/out protocol. To |
| 1208 | + * recover, reset the connection (talk about using a sledgehammer...) |
| 1209 | + */ |
1195 | 1210 | PGDONOTICE(conn, libpq_gettext("lost synchronization with server, resetting connection"));
|
1196 | 1211 |
|
1197 | 1212 | /*
|
|
0 commit comments