1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-04 20:11:56 +03:00

Indicate session name in isolationtester notices

When a session under isolationtester produces printable notices (NOTICE,
WARNING) we were just printing them unadorned, which can be confusing
when debugging.  Prefix them with the session name, which makes things
clearer.

Author: Álvaro Herrera
Reviewed-by: Hari Babu Kommi
Discussion: https://postgr.es/m/20181024213451.75nh3f3dctmcdbfq@alvherre.pgsql
This commit is contained in:
Alvaro Herrera
2018-11-09 13:08:00 -03:00
parent 319a810180
commit a28e10e82e
4 changed files with 50 additions and 19 deletions

View File

@@ -48,6 +48,8 @@ static int step_qsort_cmp(const void *a, const void *b);
static int step_bsearch_cmp(const void *a, const void *b);
static void printResultSet(PGresult *res);
static void isotesterNoticeProcessor(void *arg, const char *message);
static void blackholeNoticeProcessor(void *arg, const char *message);
/* close all connections and exit */
static void
@@ -171,6 +173,21 @@ main(int argc, char **argv)
exit_nicely();
}
/*
* Set up notice processors for the user-defined connections, so that
* messages can get printed prefixed with the session names. The
* control connection gets a "blackhole" processor instead (hides all
* messages).
*/
if (i != 0)
PQsetNoticeProcessor(conns[i],
isotesterNoticeProcessor,
(void *) (testspec->sessions[i - 1]->name));
else
PQsetNoticeProcessor(conns[i],
blackholeNoticeProcessor,
NULL);
/*
* Suppress NOTIFY messages, which otherwise pop into results at odd
* places.
@@ -881,3 +898,17 @@ printResultSet(PGresult *res)
printf("\n");
}
}
/* notice processor, prefixes each message with the session name */
static void
isotesterNoticeProcessor(void *arg, const char *message)
{
fprintf(stderr, "%s: %s", (char *) arg, message);
}
/* notice processor, hides the message */
static void
blackholeNoticeProcessor(void *arg, const char *message)
{
/* do nothing */
}