File: bulk_insert.lua

package info (click to toggle)
sysbench 1.0.20%2Bds-7
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,840 kB
  • sloc: ansic: 11,830; sh: 1,752; xml: 736; makefile: 195
file content (61 lines) | stat: -rw-r--r-- 1,195 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
-- -------------------------------------------------------------------------- --
-- Bulk insert tests                                                          --
-- -------------------------------------------------------------------------- --

cursize=0

function prepare()
   local i

   db_connect()

   for i = 0,num_threads-1 do

   if (db_driver == "pgsql") then

      db_query([[
CREATE TABLE IF NOT EXISTS sbtest]] .. i .. [[ (
id INTEGER NOT NULL,
k INTEGER DEFAULT '0' NOT NULL,
PRIMARY KEY (id)
)]])

   else

      db_query([[
CREATE TABLE IF NOT EXISTS sbtest]] .. i .. [[ (
id INTEGER UNSIGNED NOT NULL,
k INTEGER UNSIGNED DEFAULT '0' NOT NULL,
PRIMARY KEY (id)
) ENGINE = InnoDB
]])

   end

   end --for
end

function event()
   local i

   if (cursize == 0) then
      db_bulk_insert_init("INSERT INTO sbtest" .. thread_id .. " VALUES")
   end

   cursize = cursize + 1

   db_bulk_insert_next("(" .. cursize .. "," .. cursize .. ")")
end

function thread_done(thread_9d)
   db_bulk_insert_done()
end

function cleanup()
   local i

   for i = 0,num_threads-1 do
      print("Dropping table 'sbtest" .. i .. "'...")
      db_query("DROP TABLE IF EXISTS sbtest".. i )
   end
end