diff options
author | Alvaro Herrera | 2018-11-09 16:08:00 +0000 |
---|---|---|
committer | Alvaro Herrera | 2018-11-09 16:08:00 +0000 |
commit | a28e10e82e540d45e448bc404af76df8a54008f1 (patch) | |
tree | a1a25303d97605b40eb8702b559d3d9bfbb9dce6 /src/test/isolation/isolationtester.c | |
parent | 319a8101804f3b62512fdce1a3af1c839344b593 (diff) |
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/[email protected]
Diffstat (limited to 'src/test/isolation/isolationtester.c')
-rw-r--r-- | src/test/isolation/isolationtester.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/test/isolation/isolationtester.c b/src/test/isolation/isolationtester.c index 62097ab961e..e2638553f62 100644 --- a/src/test/isolation/isolationtester.c +++ b/src/test/isolation/isolationtester.c @@ -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 @@ -172,6 +174,21 @@ main(int argc, char **argv) } /* + * 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 */ +} |