forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit618c167
committed
Rearrange libpq's error reporting to avoid duplicated error text.
Since commitffa2e46, libpq accumulates text in conn->errorMessageacross a whole query cycle. In some situations, we may report morethan one error event within a cycle: the easiest case to reach iswhere we report a FATAL error message from the server, and then abit later we detect loss of connection. Since, historically, eacherror PGresult bears the entire content of conn->errorMessage,this results in duplication of the FATAL message in any output thatconcatenates the contents of the PGresults.Accumulation in errorMessage still seems like a good idea, especiallyin view of the number of places that did ad-hoc error concatenationbeforeffa2e46. So to fix this, let's track how much ofconn->errorMessage has been read out into error PGresults, and onlyinclude new text in later PGresults. The tricky part of that isto be sure that we never discard an error PGresult once made (elsewe'd risk dropping some text, a problem much worse than duplication).While libpq formerly did that in some code paths, a little bit ofrearrangement lets us postpone making an error PGresult at all untilwe are about to return it.A side benefit of that postponement is that it now becomes practicalto return a dummy static PGresult in cases where we hit out-of-memorywhile trying to manufacture an error PGresult. This eliminates theadmittedly-very-rare case where we'd return NULL from PQgetResult,indicating successful query completion, even though what actuallyhappened was an OOM failure.Discussion:https://postgr.es/m/ab4288f8-be5c-57fb-2400-e3e857f53e46@enterprisedb.com1 parent6c417bb commit618c167
File tree
7 files changed
+224
-65
lines changed- contrib/test_decoding/expected
- src/interfaces/libpq
7 files changed
+224
-65
lines changedLines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
98 | 98 |
| |
99 | 99 |
| |
100 | 100 |
| |
101 |
| - | |
102 | 101 |
| |
103 | 102 |
| |
104 | 103 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1237 | 1237 |
| |
1238 | 1238 |
| |
1239 | 1239 |
| |
1240 |
| - | |
| 1240 | + | |
1241 | 1241 |
| |
1242 | 1242 |
| |
1243 | 1243 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3685 | 3685 |
| |
3686 | 3686 |
| |
3687 | 3687 |
| |
3688 |
| - | |
| 3688 | + | |
3689 | 3689 |
| |
3690 | 3690 |
| |
3691 | 3691 |
| |
| |||
4231 | 4231 |
| |
4232 | 4232 |
| |
4233 | 4233 |
| |
4234 |
| - | |
| 4234 | + | |
4235 | 4235 |
| |
4236 | 4236 |
| |
4237 | 4237 |
| |
| |||
4241 | 4241 |
| |
4242 | 4242 |
| |
4243 | 4243 |
| |
4244 |
| - | |
| 4244 | + | |
4245 | 4245 |
| |
4246 | 4246 |
| |
4247 | 4247 |
| |
| |||
5236 | 5236 |
| |
5237 | 5237 |
| |
5238 | 5238 |
| |
5239 |
| - | |
| 5239 | + | |
5240 | 5240 |
| |
5241 | 5241 |
| |
5242 | 5242 |
| |
|
0 commit comments
Comments
(0)