diff options
author | Tom Lane | 2021-06-23 15:12:31 +0000 |
---|---|---|
committer | Tom Lane | 2021-06-23 15:13:00 +0000 |
commit | 4a054069a36032a59afceb07f3b837f09ab1a2e9 (patch) | |
tree | bd1b3af2b44313e68c8f1d4f59edc87ad8bd6c3e /src/test/isolation/isolationtester.c | |
parent | 24043c27b46f873211177e3460ab09dc011802a5 (diff) |
Improve display of query results in isolation tests.
Previously, isolationtester displayed SQL query results using some
ad-hoc code that clearly hadn't had much effort expended on it.
Field values longer than 14 characters weren't separated from
the next field, and usually caused misalignment of the columns
too. Also there was no visual separation of a query's result
from subsequent isolationtester output. This made test result
files confusing and hard to read.
To improve matters, let's use libpq's PQprint() function. Although
that's long since unused by psql, it's still plenty good enough
for the purpose here.
Like 741d7f104, back-patch to all supported branches, so that this
isn't a stumbling block for back-patching isolation test changes.
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/test/isolation/isolationtester.c')
-rw-r--r-- | src/test/isolation/isolationtester.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/test/isolation/isolationtester.c b/src/test/isolation/isolationtester.c index 71546bf9238..01a420bcd3a 100644 --- a/src/test/isolation/isolationtester.c +++ b/src/test/isolation/isolationtester.c @@ -1089,23 +1089,13 @@ step_has_blocker(PermutationStep *pstep) static void printResultSet(PGresult *res) { - int nFields; - int i, - j; - - /* first, print out the attribute names */ - nFields = PQnfields(res); - for (i = 0; i < nFields; i++) - printf("%-15s", PQfname(res, i)); - printf("\n\n"); + PQprintOpt popt; - /* next, print out the rows */ - for (i = 0; i < PQntuples(res); i++) - { - for (j = 0; j < nFields; j++) - printf("%-15s", PQgetvalue(res, i, j)); - printf("\n"); - } + memset(&popt, 0, sizeof(popt)); + popt.header = true; + popt.align = true; + popt.fieldSep = "|"; + PQprint(stdout, res, &popt); } /* notice processor for regular user sessions */ |