pgbench_postconnectcommand.v1.patch
text/x-patch
Filename: pgbench_postconnectcommand.v1.patch
Type: text/x-patch
Part: 0
Message:
pgbench post-connection command
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
Series: patch v1
| File | + | − |
|---|---|---|
| contrib/pgbench/pgbench.c | 10 | 1 |
diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c
index 9081f09..1a975d8 100644
--- a/contrib/pgbench/pgbench.c
+++ b/contrib/pgbench/pgbench.c
@@ -150,6 +150,7 @@ char *pgoptions = NULL;
char *pgtty = NULL;
char *login = NULL;
char *dbName;
+char *postConnectCommand = NULL;
volatile bool timer_exceeded = false; /* flag from signal handler */
@@ -367,6 +368,7 @@ usage(const char *progname)
" -t NUM number of transactions each client runs (default: 10)\n"
" -T NUM duration of benchmark test in seconds\n"
" -v vacuum all four standard tables before tests\n"
+ " -x SQLCMD execute SQLCMD once after connection of each db session\n"
"\nCommon options:\n"
" -d print debugging output\n"
" -h HOSTNAME database server host or socket directory\n"
@@ -454,6 +456,9 @@ doConnect(void)
return NULL;
}
+ if (postConnectCommand)
+ executeStatement(conn, postConnectCommand);
+
return conn;
}
@@ -1769,6 +1774,7 @@ printResults(int ttype, int normal_xacts, int nclients,
s = "Custom query";
printf("transaction type: %s\n", s);
+ printf("post connect command: [%s]\n", (postConnectCommand ? postConnectCommand : "not set"));
printf("scaling factor: %d\n", scale);
printf("query mode: %s\n", QUERYMODE[querymode]);
printf("number of clients: %d\n", nclients);
@@ -1910,7 +1916,7 @@ main(int argc, char **argv)
state = (CState *) xmalloc(sizeof(CState));
memset(state, 0, sizeof(CState));
- while ((c = getopt_long(argc, argv, "ih:nvp:dSNc:j:Crs:t:T:U:lf:D:F:M:", long_options, &optindex)) != -1)
+ while ((c = getopt_long(argc, argv, "ih:nvp:dSNc:j:Crs:t:T:U:lf:D:F:M:x:", long_options, &optindex)) != -1)
{
switch (c)
{
@@ -2062,6 +2068,9 @@ main(int argc, char **argv)
exit(1);
}
break;
+ case 'x':
+ postConnectCommand = optarg;
+ break;
case 0:
/* This covers long options which take no argument. */
break;