Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit84bee96

Browse files
committed
Improve version reporting in pgbench.
Commit547f04e caused pgbench to start printing its version number,which seems like a fine idea, but it needs a bit more work:* Print the server version number too, when different.* Print the PG_VERSION string, not some reconstructed approximation.This patch copies psql's well-tested code for the same purpose.Discussion:https://postgr.es/m/1226654.1624036821@sss.pgh.pa.us
1 parent7c337b6 commit84bee96

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include"common/username.h"
6464
#include"fe_utils/cancel.h"
6565
#include"fe_utils/conditional.h"
66+
#include"fe_utils/string_utils.h"
6667
#include"getopt_long.h"
6768
#include"libpq-fe.h"
6869
#include"pgbench.h"
@@ -5493,6 +5494,37 @@ printSimpleStats(const char *prefix, SimpleStats *ss)
54935494
}
54945495
}
54955496

5497+
/* print version banner */
5498+
staticvoid
5499+
printVersion(PGconn*con)
5500+
{
5501+
intserver_ver=PQserverVersion(con);
5502+
intclient_ver=PG_VERSION_NUM;
5503+
5504+
if (server_ver!=client_ver)
5505+
{
5506+
constchar*server_version;
5507+
charsverbuf[32];
5508+
5509+
/* Try to get full text form, might include "devel" etc */
5510+
server_version=PQparameterStatus(con,"server_version");
5511+
/* Otherwise fall back on server_ver */
5512+
if (!server_version)
5513+
{
5514+
formatPGVersionNumber(server_ver, true,
5515+
sverbuf,sizeof(sverbuf));
5516+
server_version=sverbuf;
5517+
}
5518+
5519+
printf(_("%s (%s, server %s)\n"),
5520+
"pgbench",PG_VERSION,server_version);
5521+
}
5522+
/* For version match, only print pgbench version */
5523+
else
5524+
printf("%s (%s)\n","pgbench",PG_VERSION);
5525+
fflush(stdout);
5526+
}
5527+
54965528
/* print out results */
54975529
staticvoid
54985530
printResults(StatsData*total,
@@ -5506,7 +5538,6 @@ printResults(StatsData *total,
55065538
doublebench_duration=PG_TIME_GET_DOUBLE(total_duration);
55075539
doubletps=ntx /bench_duration;
55085540

5509-
printf("pgbench (PostgreSQL) %d.%d\n",PG_VERSION_NUM /10000,PG_VERSION_NUM %100);
55105541
/* Report test parameters. */
55115542
printf("transaction type: %s\n",
55125543
num_scripts==1 ?sql_script[0].desc :"multiple scripts");
@@ -6334,6 +6365,9 @@ main(int argc, char **argv)
63346365
if (con==NULL)
63356366
exit(1);
63366367

6368+
/* report pgbench and server versions */
6369+
printVersion(con);
6370+
63376371
pg_log_debug("pghost: %s pgport: %s nclients: %d %s: %d dbName: %s",
63386372
PQhost(con),PQport(con),nclients,
63396373
duration <=0 ?"nxacts" :"duration",

‎src/bin/pgbench/t/001_pgbench_with_server.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ sub pgbench
100100
'no such database');
101101

102102
pgbench(
103-
'-S -t 1', 1, [qr{^$}],
103+
'-S -t 1', 1, [],
104104
[qr{Perhaps you need to do initialization}],
105105
'run without init');
106106

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp