diff options
| author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2013-06-14 23:31:44 +0300 |
|---|---|---|
| committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2013-06-14 23:31:44 +0300 |
| commit | b23160889c963dfe23d8cf1f9be64fb3c535a2d6 (patch) | |
| tree | fc942b60c7d6a7797771e79dd83440704a2ebb02 /contrib/pgbench/pgbench.c | |
| parent | 46e1434f3db21cdc05dea42b4e060d2078ff5b87 (diff) | |
| download | postgresql-b23160889c963dfe23d8cf1f9be64fb3c535a2d6.tar.gz | |
Add :client_id automatic variable for custom pgbench scripts.
This makes it easier to write custom scripts that have different logic for
each client.
Gurjeet Singh, with some changes by me.
Diffstat (limited to 'contrib/pgbench/pgbench.c')
| -rw-r--r-- | contrib/pgbench/pgbench.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c index 8c202bf870..1303217086 100644 --- a/contrib/pgbench/pgbench.c +++ b/contrib/pgbench/pgbench.c @@ -2544,6 +2544,20 @@ main(int argc, char **argv) } } + /* + * Define a :client_id variable that is unique per connection. But don't + * override an explicit -D switch. + */ + if (getVariable(&state[0], "client_id") == NULL) + { + for (i = 0; i < nclients; i++) + { + snprintf(val, sizeof(val), "%d", i); + if (!putVariable(&state[i], "startup", "client_id", val)) + exit(1); + } + } + if (!is_no_vacuum) { fprintf(stderr, "starting vacuum..."); |
