1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-16 06:01:02 +03:00

Suppress length of Notice/Error msgs in PQtrace regress mode

A (relatively minor) annoyance of ErrorResponse/NoticeResponse messages
as printed by PQtrace() is that their length might vary when we move
error messages from one source file to another, one function to another,
or even when their location line numbers change number of digits.

To avoid having to adjust expected files for some tests, make the
regress mode of PQtrace() suppress the length word of NoticeResponse and
ErrorResponse messages.

Discussion: https://postgr.es/m/20210402023010.GA13563@alvherre.pgsql
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
This commit is contained in:
Alvaro Herrera
2021-04-09 17:13:18 -04:00
parent 846d35b2dc
commit e7e341409a
3 changed files with 17 additions and 8 deletions

View File

@ -549,7 +549,16 @@ pqTraceOutputMessage(PGconn *conn, const char *message, bool toServer)
length = (int) pg_ntoh32(length);
logCursor += 4;
fprintf(conn->Pfdebug, "%s\t%d\t", prefix, length);
/*
* In regress mode, suppress the length of ErrorResponse and
* NoticeResponse. The F (file name), L (line number) and R (routine
* name) fields can change as server code is modified, and if their
* lengths differ from the originals, that would break tests.
*/
if (regress && !toServer && (id == 'E' || id == 'N'))
fprintf(conn->Pfdebug, "%s\tNN\t", prefix);
else
fprintf(conn->Pfdebug, "%s\t%d\t", prefix, length);
switch (id)
{