Percona-Lab / sysbench-tpcc

Sysbench scripts to generate a tpcc-like workload for MySQL and PostgreSQL
Apache License 2.0
292 stars 104 forks source link

tpcc_run.lua:325: attempt to index global 'row' (a nil value) #33

Closed oraclecorp closed 4 years ago

oraclecorp commented 4 years ago

In following code,when namecnt is 1, (namecnt / 2 ) + 1 =2,which result error.

    local namecnt = con:query_row(([[SELECT count(c_id) namecnt
                                       FROM customer%d
                                      WHERE c_w_id = %d
                                        AND c_d_id= %d
                                        AND c_last='%s']]):format(table_num, c_w_id, c_d_id, c_last ))

    if namecnt % 2 == 1 then
            namecnt = namecnt + 1
    end
    ..........
    ..........

 for i = 1,  (namecnt / 2 ) + 1 do
        .............

fix: line 313/461 if namecnt % 2 == 1 then to if namecnt >1 and namecnt % 2 == 1 then

vadimtk commented 4 years ago

fixed

oraclecorp commented 4 years ago

sorry,it should be if namecnt/1 >1 and namecnt % 2 == 1 then

vadimtk commented 4 years ago

you mean if namecnt/2 >1 and namecnt % 2 == 1 then ?

oraclecorp commented 4 years ago

you mean if namecnt/2 >1 and namecnt % 2 == 1 then ?

Because namecnt is a string,namecnt >1 will throw a error. namecnt/1 or tonumber(namecnt) can convert it to a number.