File tree 2 files changed +41
-1
lines changed
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)
2544
2544
}
2545
2545
}
2546
2546
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
+
2547
2561
if (!is_no_vacuum )
2548
2562
{
2549
2563
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</>
600
600
Variables can be set by the command-line <option>-D</> option,
601
601
explained above, or by the meta commands explained below.
602
602
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.
604
606
Once set, a variable's
605
607
value can be inserted into a SQL command by writing
606
608
<literal>:</><replaceable>variablename</>. When running more than
607
609
one client session, each session has its own set of variables.
608
610
</para>
609
611
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
+
610
636
<para>
611
637
Script file meta commands begin with a backslash (<literal>\</>).
612
638
Arguments to a meta command are separated by white space.
You can’t perform that action at this time.
0 commit comments