@@ -575,10 +575,9 @@ static void setNullValue(PgBenchValue *pv);
575
575
static void setBoolValue (PgBenchValue * pv , bool bval );
576
576
static void setIntValue (PgBenchValue * pv , int64 ival );
577
577
static void setDoubleValue (PgBenchValue * pv , double dval );
578
- static bool evaluateExpr (TState * thread , CState * st , PgBenchExpr * expr ,
578
+ static bool evaluateExpr (CState * st , PgBenchExpr * expr ,
579
579
PgBenchValue * retval );
580
- static ConnectionStateEnum executeMetaCommand (TState * thread , CState * st ,
581
- instr_time * now );
580
+ static ConnectionStateEnum executeMetaCommand (CState * st , instr_time * now );
582
581
static void doLog (TState * thread , CState * st ,
583
582
StatsData * agg , bool skipped , double latency , double lag );
584
583
static void processXactStats (TState * thread , CState * st , instr_time * now ,
@@ -1744,7 +1743,7 @@ isLazyFunc(PgBenchFunction func)
1744
1743
1745
1744
/* lazy evaluation of some functions */
1746
1745
static bool
1747
- evalLazyFunc (TState * thread , CState * st ,
1746
+ evalLazyFunc (CState * st ,
1748
1747
PgBenchFunction func , PgBenchExprLink * args , PgBenchValue * retval )
1749
1748
{
1750
1749
PgBenchValue a1 ,
@@ -1755,7 +1754,7 @@ evalLazyFunc(TState *thread, CState *st,
1755
1754
Assert (isLazyFunc (func ) && args != NULL && args -> next != NULL );
1756
1755
1757
1756
/* args points to first condition */
1758
- if (!evaluateExpr (thread , st , args -> expr , & a1 ))
1757
+ if (!evaluateExpr (st , args -> expr , & a1 ))
1759
1758
return false;
1760
1759
1761
1760
/* second condition for AND/OR and corresponding branch for CASE */
@@ -1779,7 +1778,7 @@ evalLazyFunc(TState *thread, CState *st,
1779
1778
return true;
1780
1779
}
1781
1780
1782
- if (!evaluateExpr (thread , st , args -> expr , & a2 ))
1781
+ if (!evaluateExpr (st , args -> expr , & a2 ))
1783
1782
return false;
1784
1783
1785
1784
if (a2 .type == PGBT_NULL )
@@ -1814,7 +1813,7 @@ evalLazyFunc(TState *thread, CState *st,
1814
1813
return true;
1815
1814
}
1816
1815
1817
- if (!evaluateExpr (thread , st , args -> expr , & a2 ))
1816
+ if (!evaluateExpr (st , args -> expr , & a2 ))
1818
1817
return false;
1819
1818
1820
1819
if (a2 .type == PGBT_NULL )
@@ -1833,17 +1832,17 @@ evalLazyFunc(TState *thread, CState *st,
1833
1832
case PGBENCH_CASE :
1834
1833
/* when true, execute branch */
1835
1834
if (valueTruth (& a1 ))
1836
- return evaluateExpr (thread , st , args -> expr , retval );
1835
+ return evaluateExpr (st , args -> expr , retval );
1837
1836
1838
1837
/* now args contains next condition or final else expression */
1839
1838
args = args -> next ;
1840
1839
1841
1840
/* final else case? */
1842
1841
if (args -> next == NULL )
1843
- return evaluateExpr (thread , st , args -> expr , retval );
1842
+ return evaluateExpr (st , args -> expr , retval );
1844
1843
1845
1844
/* no, another when, proceed */
1846
- return evalLazyFunc (thread , st , PGBENCH_CASE , args , retval );
1845
+ return evalLazyFunc (st , PGBENCH_CASE , args , retval );
1847
1846
1848
1847
default :
1849
1848
/* internal error, cannot get here */
@@ -1861,7 +1860,7 @@ evalLazyFunc(TState *thread, CState *st,
1861
1860
* which do not require lazy evaluation.
1862
1861
*/
1863
1862
static bool
1864
- evalStandardFunc (TState * thread , CState * st ,
1863
+ evalStandardFunc (CState * st ,
1865
1864
PgBenchFunction func , PgBenchExprLink * args ,
1866
1865
PgBenchValue * retval )
1867
1866
{
@@ -1873,7 +1872,7 @@ evalStandardFunc(TState *thread, CState *st,
1873
1872
1874
1873
for (nargs = 0 ; nargs < MAX_FARGS && l != NULL ; nargs ++ , l = l -> next )
1875
1874
{
1876
- if (!evaluateExpr (thread , st , l -> expr , & vargs [nargs ]))
1875
+ if (!evaluateExpr (st , l -> expr , & vargs [nargs ]))
1877
1876
return false;
1878
1877
has_null |= vargs [nargs ].type == PGBT_NULL ;
1879
1878
}
@@ -2408,13 +2407,13 @@ evalStandardFunc(TState *thread, CState *st,
2408
2407
2409
2408
/* evaluate some function */
2410
2409
static bool
2411
- evalFunc (TState * thread , CState * st ,
2410
+ evalFunc (CState * st ,
2412
2411
PgBenchFunction func , PgBenchExprLink * args , PgBenchValue * retval )
2413
2412
{
2414
2413
if (isLazyFunc (func ))
2415
- return evalLazyFunc (thread , st , func , args , retval );
2414
+ return evalLazyFunc (st , func , args , retval );
2416
2415
else
2417
- return evalStandardFunc (thread , st , func , args , retval );
2416
+ return evalStandardFunc (st , func , args , retval );
2418
2417
}
2419
2418
2420
2419
/*
@@ -2424,7 +2423,7 @@ evalFunc(TState *thread, CState *st,
2424
2423
* the value itself is returned through the retval pointer.
2425
2424
*/
2426
2425
static bool
2427
- evaluateExpr (TState * thread , CState * st , PgBenchExpr * expr , PgBenchValue * retval )
2426
+ evaluateExpr (CState * st , PgBenchExpr * expr , PgBenchValue * retval )
2428
2427
{
2429
2428
switch (expr -> etype )
2430
2429
{
@@ -2453,7 +2452,7 @@ evaluateExpr(TState *thread, CState *st, PgBenchExpr *expr, PgBenchValue *retval
2453
2452
}
2454
2453
2455
2454
case ENODE_FUNCTION :
2456
- return evalFunc (thread , st ,
2455
+ return evalFunc (st ,
2457
2456
expr -> u .function .function ,
2458
2457
expr -> u .function .args ,
2459
2458
retval );
@@ -3072,7 +3071,7 @@ advanceConnectionState(TState *thread, CState *st, StatsData *agg)
3072
3071
* - on sleep CSTATE_SLEEP
3073
3072
* - else CSTATE_END_COMMAND
3074
3073
*/
3075
- st -> state = executeMetaCommand (thread , st , & now );
3074
+ st -> state = executeMetaCommand (st , & now );
3076
3075
}
3077
3076
3078
3077
/*
@@ -3304,7 +3303,7 @@ advanceConnectionState(TState *thread, CState *st, StatsData *agg)
3304
3303
* take no time to execute.
3305
3304
*/
3306
3305
static ConnectionStateEnum
3307
- executeMetaCommand (TState * thread , CState * st , instr_time * now )
3306
+ executeMetaCommand (CState * st , instr_time * now )
3308
3307
{
3309
3308
Command * command = sql_script [st -> use_file ].commands [st -> command ];
3310
3309
int argc ;
@@ -3348,7 +3347,7 @@ executeMetaCommand(TState *thread, CState *st, instr_time *now)
3348
3347
PgBenchExpr * expr = command -> expr ;
3349
3348
PgBenchValue result ;
3350
3349
3351
- if (!evaluateExpr (thread , st , expr , & result ))
3350
+ if (!evaluateExpr (st , expr , & result ))
3352
3351
{
3353
3352
commandFailed (st , argv [0 ], "evaluation of meta-command failed" );
3354
3353
return CSTATE_ABORTED ;
@@ -3367,7 +3366,7 @@ executeMetaCommand(TState *thread, CState *st, instr_time *now)
3367
3366
PgBenchValue result ;
3368
3367
bool cond ;
3369
3368
3370
- if (!evaluateExpr (thread , st , expr , & result ))
3369
+ if (!evaluateExpr (st , expr , & result ))
3371
3370
{
3372
3371
commandFailed (st , argv [0 ], "evaluation of meta-command failed" );
3373
3372
return CSTATE_ABORTED ;
@@ -3390,7 +3389,7 @@ executeMetaCommand(TState *thread, CState *st, instr_time *now)
3390
3389
return CSTATE_END_COMMAND ;
3391
3390
}
3392
3391
3393
- if (!evaluateExpr (thread , st , expr , & result ))
3392
+ if (!evaluateExpr (st , expr , & result ))
3394
3393
{
3395
3394
commandFailed (st , argv [0 ], "evaluation of meta-command failed" );
3396
3395
return CSTATE_ABORTED ;
@@ -4773,7 +4772,7 @@ addScript(ParsedScript script)
4773
4772
* progress report. On exit, they are updated with the new stats.
4774
4773
*/
4775
4774
static void
4776
- printProgressReport (TState * thread , int64 test_start , int64 now ,
4775
+ printProgressReport (TState * threads , int64 test_start , int64 now ,
4777
4776
StatsData * last , int64 * last_report )
4778
4777
{
4779
4778
/* generate and show report */
@@ -4801,10 +4800,10 @@ printProgressReport(TState *thread, int64 test_start, int64 now,
4801
4800
initStats (& cur , 0 );
4802
4801
for (int i = 0 ; i < nthreads ; i ++ )
4803
4802
{
4804
- mergeSimpleStats (& cur .latency , & thread [i ].stats .latency );
4805
- mergeSimpleStats (& cur .lag , & thread [i ].stats .lag );
4806
- cur .cnt += thread [i ].stats .cnt ;
4807
- cur .skipped += thread [i ].stats .skipped ;
4803
+ mergeSimpleStats (& cur .latency , & threads [i ].stats .latency );
4804
+ mergeSimpleStats (& cur .lag , & threads [i ].stats .lag );
4805
+ cur .cnt += threads [i ].stats .cnt ;
4806
+ cur .skipped += threads [i ].stats .skipped ;
4808
4807
}
4809
4808
4810
4809
/* we count only actually executed transactions */
@@ -4874,7 +4873,7 @@ printSimpleStats(const char *prefix, SimpleStats *ss)
4874
4873
4875
4874
/* print out results */
4876
4875
static void
4877
- printResults (TState * threads , StatsData * total , instr_time total_time ,
4876
+ printResults (StatsData * total , instr_time total_time ,
4878
4877
instr_time conn_total_time , int64 latency_late )
4879
4878
{
4880
4879
double time_include ,
@@ -5887,7 +5886,7 @@ main(int argc, char **argv)
5887
5886
*/
5888
5887
INSTR_TIME_SET_CURRENT (total_time );
5889
5888
INSTR_TIME_SUBTRACT (total_time , start_time );
5890
- printResults (threads , & stats , total_time , conn_total_time , latency_late );
5889
+ printResults (& stats , total_time , conn_total_time , latency_late );
5891
5890
5892
5891
if (exit_code != 0 )
5893
5892
fprintf (stderr , "Run was aborted; the above results are incomplete.\n" );
@@ -6146,7 +6145,14 @@ threadRun(void *arg)
6146
6145
now = INSTR_TIME_GET_MICROSEC (now_time );
6147
6146
if (now >= next_report )
6148
6147
{
6149
- printProgressReport (thread , thread_start , now , & last , & last_report );
6148
+ /*
6149
+ * Horrible hack: this relies on the thread pointer we are
6150
+ * passed to be equivalent to threads[0], that is the first
6151
+ * entry of the threads array. That is why this MUST be done
6152
+ * by thread 0 and not any other.
6153
+ */
6154
+ printProgressReport (thread , thread_start , now ,
6155
+ & last , & last_report );
6150
6156
6151
6157
/*
6152
6158
* Ensure that the next report is in the future, in case
0 commit comments