You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tpcc_check.lua
+38-4
Original file line number
Diff line number
Diff line change
@@ -24,10 +24,17 @@ require("tpcc_common")
24
24
25
25
functioncheck_tables(drv, con, warehouse_num)
26
26
27
+
straight_join_hint=","
28
+
29
+
ifdrv:name() =="mysql" then
30
+
straight_join_hint="STRAIGHT_JOIN"
31
+
end
32
+
33
+
27
34
localpass1=1
28
35
fortable_num=1, sysbench.opt.tablesdo
29
36
-- print(string.format("Checking tables: %d for warehouse: %d\n", table_num, warehouse_num))
30
-
rs=con:query("SELECT d_w_id,sum(d_ytd)-w_ytd diff FROM district"..table_num..",warehouse"..table_num.."where d_w_id=w_id AND w_id="..warehouse_num.." group by d_w_id")
37
+
rs=con:query("SELECT d_w_id,sum(d_ytd)-max(w_ytd) diff FROM district"..table_num..",warehouse"..table_num.."WHERE d_w_id=w_id AND w_id="..warehouse_num.." group by d_w_id")
31
38
32
39
fori=1, rs.nrowsdo
33
40
row=rs:fetch_row()
@@ -41,6 +48,8 @@ function check_tables(drv, con, warehouse_num)
@@ -96,7 +105,13 @@ function check_tables(drv, con, warehouse_num)
96
105
localpass4=1
97
106
fortable_num=1, sysbench.opt.tablesdo
98
107
-- print(string.format("Checking tables: %d for warehouse: %d\n", table_num, warehouse_num))
99
-
rs=con:query(string.format("SELECT count(*) FROM (SELECT o_d_id, SUM(o_ol_cnt) sm1, cn FROM orders%d,(SELECT ol_d_id, COUNT(*) cn FROM order_line%d WHERE ol_w_id=%d GROUP BY ol_d_id) ol WHERE O_w_id=%d AND ol_d_id=o_d_id GROUP BY o_d_id) t1 WHERE sm1<>cn",table_num, table_num, warehouse_num, warehouse_num))
108
+
rs=con:query(string.format([[SELECT count(*)
109
+
FROM (SELECT o_d_id, SUM(o_ol_cnt) sm1, MAX(cn) as cn
110
+
FROM orders%d,(SELECT ol_d_id, COUNT(*) cn
111
+
FROM order_line%d
112
+
WHERE ol_w_id=%d GROUP BY ol_d_id) ol
113
+
WHERE o_w_id=%d AND ol_d_id=o_d_id GROUP BY o_d_id) t1
114
+
WHERE sm1<>cn]],table_num, table_num, warehouse_num, warehouse_num))
100
115
101
116
fori=1, rs.nrowsdo
102
117
row=rs:fetch_row()
@@ -196,7 +211,22 @@ function check_tables(drv, con, warehouse_num)
196
211
localpass10=1
197
212
fortable_num=1, sysbench.opt.tablesdo
198
213
-- print(string.format("Checking tables: %d for warehouse: %d\n", table_num, warehouse_num))
199
-
rs=con:query(string.format("SELECT count(*) FROM ( SELECT c.c_id, c.c_d_id, c.c_w_id, c.c_balance c1, (SELECT sum(ol_amount) FROM orders%d STRAIGHT_JOIN order_line%d WHERE OL_W_ID=O_W_ID AND OL_D_ID = O_D_ID AND OL_O_ID = O_ID AND OL_DELIVERY_D IS NOT NULL AND O_W_ID=c.c_w_id AND O_D_ID=c.C_D_ID AND O_C_ID=c.C_ID) sm, (SELECT sum(h_amount) from history%d WHERE H_C_W_ID=c.C_W_ID AND H_C_D_ID=c.C_D_ID AND H_C_ID=c.C_ID) smh FROM customer%d c WHERE c.c_w_id=%d ) t where c1<>sm-smh",table_num, table_num, table_num, table_num, warehouse_num))
214
+
rs=con:query(string.format([[SELECT count(*)
215
+
FROM ( SELECT c.c_id, c.c_d_id, c.c_w_id, c.c_balance c1,
216
+
(SELECT sum(ol_amount) FROM orders%d ]] ..straight_join_hint..[[ order_line%d
217
+
WHERE OL_W_ID=O_W_ID
218
+
AND OL_D_ID = O_D_ID
219
+
AND OL_O_ID = O_ID
220
+
AND OL_DELIVERY_D IS NOT NULL
221
+
AND O_W_ID=c.c_w_id
222
+
AND O_D_ID=c.C_D_ID
223
+
AND O_C_ID=c.C_ID) sm, (SELECT sum(h_amount) from history%d
224
+
WHERE H_C_W_ID=c.C_W_ID
225
+
AND H_C_D_ID=c.C_D_ID
226
+
AND H_C_ID=c.C_ID) smh
227
+
FROM customer%d c
228
+
WHERE c.c_w_id=%d ) t
229
+
WHERE c1<>sm-smh]],table_num, table_num, table_num, table_num, warehouse_num))
200
230
201
231
fori=1, rs.nrowsdo
202
232
row=rs:fetch_row()
@@ -216,7 +246,11 @@ function check_tables(drv, con, warehouse_num)
216
246
localpass12=1
217
247
fortable_num=1, sysbench.opt.tablesdo
218
248
-- print(string.format("Checking tables: %d for warehouse: %d\n", table_num, warehouse_num))
219
-
rs=con:query(string.format("SELECT count(*) FROM (SELECT c.c_id, c.c_d_id, c.c_balance c1, c_ytd_payment, (SELECT sum(ol_amount) FROM orders%d STRAIGHT_JOIN order_line%d WHERE OL_W_ID=O_W_ID AND OL_D_ID = O_D_ID AND OL_O_ID = O_ID AND OL_DELIVERY_D IS NOT NULL AND O_W_ID=c.c_w_id AND O_D_ID=c.C_D_ID AND O_C_ID=c.C_ID) sm FROM customer%d c WHERE c.c_w_id=%d) t1 WHERE c1+c_ytd_payment <> sm " ,table_num, table_num, table_num, warehouse_num))
249
+
rs=con:query(string.format([[SELECT count(*) FROM (SELECT c.c_id, c.c_d_id, c.c_balance c1, c_ytd_payment,
250
+
(SELECT sum(ol_amount) FROM orders%d ]] ..straight_join_hint..[[ order_line%d
251
+
WHERE OL_W_ID=O_W_ID AND OL_D_ID = O_D_ID AND OL_O_ID = O_ID AND OL_DELIVERY_D IS NOT NULL AND
252
+
O_W_ID=c.c_w_id AND O_D_ID=c.C_D_ID AND O_C_ID=c.C_ID) sm FROM customer%d c WHERE c.c_w_id=%d) t1
253
+
WHERE c1+c_ytd_payment <> sm ]] ,table_num, table_num, table_num, warehouse_num))
0 commit comments