File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -2544,6 +2544,20 @@ main(int argc, char **argv)
25442544 }
25452545 }
25462546
2547+ /*
2548+ * Define a :client_id variable that is unique per connection. But don't
2549+ * override an explicit -D switch.
2550+ */
2551+ if (getVariable (& state [0 ], "client_id" ) == NULL )
2552+ {
2553+ for (i = 0 ; i < nclients ; i ++ )
2554+ {
2555+ snprintf (val , sizeof (val ), "%d" , i );
2556+ if (!putVariable (& state [i ], "startup" , "client_id" , val ))
2557+ exit (1 );
2558+ }
2559+ }
2560+
25472561 if (!is_no_vacuum )
25482562 {
25492563 fprintf (stderr , "starting vacuum..." );
Original file line number Diff line number Diff line change @@ -600,13 +600,39 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
600600 Variables can be set by the command-line <option>-D</> option,
601601 explained above, or by the meta commands explained below.
602602 In addition to any variables preset by <option>-D</> command-line options,
603- the variable <literal>scale</> is preset to the current scale factor.
603+ there are a few variables that are preset automatically, listed in
604+ <xref linkend="pgbench-automatic-variables">. A value specified for these
605+ variables using <option>-D</> takes precedence over the automatic presets.
604606 Once set, a variable's
605607 value can be inserted into a SQL command by writing
606608 <literal>:</><replaceable>variablename</>. When running more than
607609 one client session, each session has its own set of variables.
608610 </para>
609611
612+ <table id="pgbench-automatic-variables">
613+ <title>Automatic variables</title>
614+ <tgroup cols="2">
615+ <thead>
616+ <row>
617+ <entry>Variable</entry>
618+ <entry>Description</entry>
619+ </row>
620+ </thead>
621+
622+ <tbody>
623+ <row>
624+ <entry> <literal>scale</literal> </entry>
625+ <entry>current scale factor</entry>
626+ </row>
627+
628+ <row>
629+ <entry> <literal>client_id</literal> </entry>
630+ <entry>unique number identifying the client session (starts from zero)</entry>
631+ </row>
632+ </tbody>
633+ </tgroup>
634+ </table>
635+
610636 <para>
611637 Script file meta commands begin with a backslash (<literal>\</>).
612638 Arguments to a meta command are separated by white space.
You can’t perform that action at this time.
0 commit comments