← Back to team overview

sysbench-developers team mailing list archive

[Merge] lp:~vadim-tk/sysbench/sysbench-db-scripts into lp:sysbench

 

Vadim Tkachenko has proposed merging lp:~vadim-tk/sysbench/sysbench-db-scripts into lp:sysbench with lp:~vadim-tk/sysbench/sysbench-stat-fix as a prerequisite.

Requested reviews:
  Alexey Kopytov (akopytov)

For more details, see:
https://code.launchpad.net/~vadim-tk/sysbench/sysbench-db-scripts/+merge/59320

Changed tests/db script 
1) to use db_query instead of db_execute
2) moved common part for all scripts into common.lua
-- 
https://code.launchpad.net/~vadim-tk/sysbench/sysbench-db-scripts/+merge/59320
Your team sysbench-developers is subscribed to branch lp:sysbench.
=== added file 'sysbench/tests/db/common.lua'
--- sysbench/tests/db/common.lua	1970-01-01 00:00:00 +0000
+++ sysbench/tests/db/common.lua	2011-04-28 05:45:45 +0000
@@ -0,0 +1,136 @@
+-- Input parameters
+-- oltp-tables-count - number of tables to create
+-- oltp-secondary - use secondary key instead PRIMARY key for id column
+--
+--
+
+function create_insert(table_id)
+
+   local index_name
+   local i
+   local j
+   local query
+
+   if (oltp_secondary) then
+     index_name = "KEY xid"
+   else
+     index_name = "PRIMARY KEY"
+   end
+
+   i = table_id
+
+   print("Creating table 'sbtest" .. i .. "'...")
+	if (db_driver == "mysql") then
+   	query = [[
+   CREATE TABLE sbtest]] .. i .. [[ (
+		   id INTEGER UNSIGNED NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
+		   k INTEGER UNSIGNED DEFAULT '0' NOT NULL,
+		   c CHAR(120) DEFAULT '' NOT NULL,
+		   pad CHAR(60) DEFAULT '' NOT NULL,
+		   ]] .. index_name .. [[ (id)
+		   ) /*! ENGINE = ]] .. mysql_table_engine .. " MAX_ROWS = " .. myisam_max_rows .. " */"
+
+   elseif (db_driver == "drizzle") then
+   query = [[
+   CREATE TABLE sbtest (
+		   id INTEGER NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
+		   k INTEGER DEFAULT '0' NOT NULL,
+		   c CHAR(120) DEFAULT '' NOT NULL,
+		   pad CHAR(60) DEFAULT '' NOT NULL,
+		   ]] .. index_name .. [[ (id)
+		   ) ]]
+   else
+   print("Unknown database driver: " .. db_driver)
+   return 1
+   end
+
+   db_query(query)
+
+
+   db_query("CREATE INDEX k on sbtest" .. i .. "(k)")
+
+   print("Inserting " .. oltp_table_size .. " records into 'sbtest" .. i .. "'")
+   
+   if (oltp_auto_inc) then
+      db_bulk_insert_init("INSERT INTO sbtest" .. i .. "(k, c, pad) VALUES")
+   else
+      db_bulk_insert_init("INSERT INTO sbtest" .. i .. "(id, k, c, pad) VALUES")
+   end
+
+   local c_val
+   local pad_val
+
+
+   for j = 1,oltp_table_size do
+
+   c_val = sb_rand_str([[
+###########-###########-###########-###########-###########-###########-###########-###########-###########-###########]])
+   pad_val = sb_rand_str([[
+###########-###########-###########-###########-###########]])
+
+      if (oltp_auto_inc) then
+	 db_bulk_insert_next("(" .. sb_rand(1, oltp_table_size) .. ", '".. c_val .."', '" .. pad_val .. "')")
+      else
+	 db_bulk_insert_next("("..j.."," .. sb_rand(1, oltp_table_size) .. ",'".. c_val .."', '" .. pad_val .. "'  )")
+      end
+   end
+
+   db_bulk_insert_done()
+
+
+end
+
+
+function prepare()
+   local query
+   local i
+   local j
+
+   set_vars()
+
+   db_connect()
+
+
+   for i = 1,oltp_tables_count do
+     create_insert(i)
+   end
+
+   return 0
+end
+
+function cleanup()
+   local i
+
+   set_vars()
+
+   for i = 1,oltp_tables_count do
+   print("Dropping table 'sbtest" .. i .. "'...")
+   db_query("DROP TABLE sbtest".. i )
+   end
+end
+
+function set_vars()
+   oltp_table_size = oltp_table_size or 10000
+   oltp_range_size = oltp_range_size or 100
+   oltp_tables_count = oltp_tables_count or 1
+   oltp_point_selects = oltp_point_selects or 10
+   oltp_simple_ranges = oltp_simple_ranges or 1
+   oltp_sum_ranges = oltp_sum_ranges or 1
+   oltp_order_ranges = oltp_order_ranges or 1
+   oltp_distinct_ranges = oltp_distinct_ranges or 1
+   oltp_index_updates = oltp_index_updates or 1
+   oltp_non_index_updates = oltp_non_index_updates or 1
+   
+   if (oltp_auto_inc == 'off') then
+      oltp_auto_inc = false
+   else
+      oltp_auto_inc = true
+   end
+
+   if (oltp_read_only == 'on') then
+      oltp_read_only = true
+   else
+      oltp_read_only = false
+   end
+
+end

=== modified file 'sysbench/tests/db/delete.lua'
--- sysbench/tests/db/delete.lua	2009-06-10 23:43:32 +0000
+++ sysbench/tests/db/delete.lua	2011-04-28 05:45:45 +0000
@@ -1,119 +1,13 @@
-function prepare()
-   local query
-   local i
-
-   set_vars()
-
-   db_connect()
-
-   print("Creating table 'sbtest'...")
-
-   if (db_driver == "mysql") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER UNSIGNED NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
-	      k INTEGER UNSIGNED DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-              pad CHAR(60) DEFAULT '' NOT NULL,
-              PRIMARY KEY (id)
-	    ) /*! ENGINE = ]] .. mysql_table_engine .. " MAX_ROWS = " .. myisam_max_rows .. " */"
-
-   elseif (db_driver == "oracle") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER NOT NULL,
-	      k INTEGER,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-	      pad CHAR(60 DEFAULT '' NOT NULL,
-	      PRIMARY KEY (id)
-	   ) ]]
-	
-
-   elseif (db_driver == "pgsql") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id ]] .. (sb.oltp_auto_inc and "SERIAL") or "" .. [[,
-	      k INTEGER DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-	      pad CHAR(60) DEFAULT '' NOT NULL, 
-	      PRIMARY KEY (id)
-	    ) ]]
-
-   elseif (db_driver == "drizzle") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
-	      k INTEGER DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-              pad CHAR(60) DEFAULT '' NOT NULL,
-              PRIMARY KEY (id)
-	    ) ]]
-
-   else
-      print("Unknown database driver: " .. db_driver)
-      return 1
-   end
-
-   db_query(query)
-
-   if (db_driver == "oracle") then
-      db_query("CREATE SEQUENCE sbtest_seq")
-      db_query([[CREATE TRIGGER sbtest_trig BEFORE INSERT ON sbtest 
-		     FOR EACH ROW BEGIN SELECT sbtest_seq.nextval INTO :new.id FROM DUAL; END;]])
-   end
-
-   db_query("CREATE INDEX k on sbtest(k)")
-
-   print("Inserting " .. oltp_table_size .. " records into 'sbtest'")
-   
-   if (oltp_auto_inc) then
-      db_bulk_insert_init("INSERT INTO sbtest(k, c, pad) VALUES")
-   else
-      db_bulk_insert_init("INSERT INTO sbtest(id, k, c, pad) VALUES")
-   end
-
-   for i = 1,oltp_table_size do
-      if (oltp_auto_inc) then
-	 db_bulk_insert_next("(0, ' ', 'qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
-      else
-	 db_bulk_insert_next("("..i..",0,' ','qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
-      end
-   end
-
-   db_bulk_insert_done()
-
-   return 0
-end
-
-function cleanup()
-   print("Dropping table 'sbtest'...")
-   db_query("DROP TABLE sbtest")
-end
+pathtest = string.match(test, "(.*/)") or ""
+
+dofile(pathtest .. "common.lua")
 
 function thread_init(thread_id)
-   local query
-
    set_vars()
-   
-   stmt = db_prepare([[
-			   DELETE FROM sbtest WHERE id = ?
-		     ]])
-   params = {0}
-   db_bind_param(stmt, params)
 end
 
 function event(thread_id)
-   local rs
-   params[1] = sb_rand(1, oltp_table_size)
-   rs = db_execute(stmt)
+   local table_name
+   table_name = "sbtest".. sb_rand_uniform(1, oltp_tables_count)
+   rs = db_query("DELETE FROM " .. table_name .. " WHERE id=" .. sb_rand(1, oltp_table_size))
 end
-
-function set_vars()
-   oltp_table_size = oltp_table_size or 10000
-
-   if (oltp_auto_inc == 'off') then
-      oltp_auto_inc = false
-   else
-      oltp_auto_inc = true
-   end
-end
\ No newline at end of file

=== modified file 'sysbench/tests/db/insert.lua'
--- sysbench/tests/db/insert.lua	2009-06-10 23:43:32 +0000
+++ sysbench/tests/db/insert.lua	2011-04-28 05:45:45 +0000
@@ -1,111 +1,30 @@
-function prepare()
-   local query
-   local i
-
-   set_vars()
-
-   db_connect()
-
-   print("Creating table 'sbtest'...")
-
-   if (db_driver == "mysql") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER UNSIGNED NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
-	      k INTEGER UNSIGNED DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-              pad CHAR(60) DEFAULT '' NOT NULL,
-              PRIMARY KEY (id)
-	    ) /*! ENGINE = ]] .. mysql_table_engine .. " MAX_ROWS = " .. myisam_max_rows .. " */"
-
-   elseif (db_driver == "oracle") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER NOT NULL,
-	      k INTEGER,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-	      pad CHAR(60 DEFAULT '' NOT NULL,
-	      PRIMARY KEY (id)
-	   ) ]]
-	
-
-   elseif (db_driver == "pgsql") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id ]] .. (sb.oltp_auto_inc and "SERIAL") or "" .. [[,
-	      k INTEGER DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-	      pad CHAR(60) DEFAULT '' NOT NULL, 
-	      PRIMARY KEY (id)
-	    ) ]]
-
-   elseif (db_driver == "drizzle") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
-	      k INTEGER DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-              pad CHAR(60) DEFAULT '' NOT NULL,
-              PRIMARY KEY (id)
-	    ) ]]
-
-   else
-      print("Unknown database driver: " .. db_driver)
-      return 1
-   end
-
-   db_query(query)
-
-   if (db_driver == "oracle") then
-      db_query("CREATE SEQUENCE sbtest_seq")
-      db_query([[CREATE TRIGGER sbtest_trig BEFORE INSERT ON sbtest 
-		     FOR EACH ROW BEGIN SELECT sbtest_seq.nextval INTO :new.id FROM DUAL; END;]])
-   end
-
-   db_query("CREATE INDEX k on sbtest(k)")
-
-   return 0
-end
-
-function cleanup()
-   print("Dropping table 'sbtest'...")
-   db_query("DROP TABLE sbtest")
-end
+pathtest = string.match(test, "(.*/)") or ""
+
+dofile(pathtest .. "common.lua")
 
 function thread_init(thread_id)
-   local query
-
    set_vars()
-   
-   stmt = db_prepare([[
-			   INSERT INTO sbtest VALUES (?,?,?,?)
-		     ]])
-   params = {0, 0, "", ""}
-   db_bind_param(stmt, params)
-
 end
 
 function event(thread_id)
-   local rs
+   local table_name
+   local i
+   local c_val
+   local k_val
+   local pad_val
+
+   table_name = "sbtest".. sb_rand_uniform(1, oltp_tables_count)
+
    if (oltp_auto_inc) then
-      params[1] = nil
+      i = 0
    else
-      params[1] = sb_rand_uniq(1, oltp_table_size)
+      i = sb_rand_uniq(1, oltp_table_size)
    end
-   params[2]= sb_rand(1, oltp_table_size)
-   params[3] = sb_rand_str([[
+   k_val = sb_rand(1, oltp_table_size)
+   c_val = sb_rand_str([[
 ###########-###########-###########-###########-###########-###########-###########-###########-###########-###########]])
-   params[4] = sb_rand_str([[
+   pad_val = sb_rand_str([[
 ###########-###########-###########-###########-###########]])
-   rs = db_execute(stmt)
+   
+   rs = db_query("INSERT INTO " .. table_name ..  " (id, k, c, pad) VALUES " .. string.format("(%d, %d, '%s', '%s')",i, k_val, c_val, pad_val))
 end
-
-function set_vars()
-   oltp_table_size = oltp_table_size or 10000
-
-   if (oltp_auto_inc == 'off') then
-      oltp_auto_inc = false
-   else
-      oltp_auto_inc = true
-   end
-end
\ No newline at end of file

=== added file 'sysbench/tests/db/oltp.lua'
--- sysbench/tests/db/oltp.lua	1970-01-01 00:00:00 +0000
+++ sysbench/tests/db/oltp.lua	2011-04-28 05:45:45 +0000
@@ -0,0 +1,85 @@
+pathtest = string.match(test, "(.*/)") or ""
+
+dofile(pathtest .. "common.lua")
+
+function thread_init(thread_id)
+   set_vars()
+
+   if (db_driver == "mysql" and mysql_table_engine == "myisam") then
+      begin_query = "LOCK TABLES sbtest WRITE"
+      commit_query = "UNLOCK TABLES"
+   else
+      begin_query = "BEGIN"
+      commit_query = "COMMIT"
+   end
+
+end
+
+function event(thread_id)
+   local rs
+   local i
+   local table_name
+   local range_start
+   local c_val
+   local pad_val
+   local query
+
+   table_name = "sbtest".. sb_rand_uniform(1, oltp_tables_count)
+   db_query(begin_query)
+
+   for i=1, oltp_point_selects do
+      rs = db_query("SELECT c FROM ".. table_name .." WHERE id=" .. sb_rand(1, oltp_table_size))
+   end
+
+   for i=1, oltp_simple_ranges do
+      range_start = sb_rand(1, oltp_table_size)
+      rs = db_query("SELECT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1)
+   end
+  
+   for i=1, oltp_sum_ranges do
+      range_start = sb_rand(1, oltp_table_size)
+      rs = db_query("SELECT SUM(K) FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1)
+   end
+   
+   for i=1, oltp_order_ranges do
+      range_start = sb_rand(1, oltp_table_size)
+      rs = db_query("SELECT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1 .. " ORDER BY c")
+   end
+
+   for i=1, oltp_distinct_ranges do
+      range_start = sb_rand(1, oltp_table_size)
+      rs = db_query("SELECT DISTINCT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1 .. " ORDER BY c")
+   end
+
+   if not oltp_read_only then
+
+   for i=1, oltp_index_updates do
+      rs = db_query("UPDATE " .. table_name .. " SET k=k+1 WHERE id=" .. sb_rand(1, oltp_table_size))
+   end
+
+   for i=1, oltp_non_index_updates do
+      c_val = sb_rand_str("###########-###########-###########-###########-###########-###########-###########-###########-###########-###########")
+      query = "UPDATE " .. table_name .. " SET c='" .. c_val .. "' WHERE id=" .. sb_rand(1, oltp_table_size)
+      rs = db_query(query)
+      if rs then
+        print(query)
+      end
+   end
+
+   i = sb_rand(1, oltp_table_size)
+
+   rs = db_query("DELETE FROM " .. table_name .. " WHERE id=" .. i)
+   
+   c_val = sb_rand_str([[
+###########-###########-###########-###########-###########-###########-###########-###########-###########-###########]])
+   pad_val = sb_rand_str([[
+###########-###########-###########-###########-###########]])
+
+   rs = db_query("INSERT INTO " .. table_name ..  " (id, k, c, pad) VALUES " .. string.format("(%d, %d, '%s', '%s')",i, sb_rand(1, oltp_table_size) , c_val, pad_val))
+
+   end -- oltp_read_only
+
+   db_query(commit_query)
+
+end
+

=== removed file 'sysbench/tests/db/oltp_complex_ro.lua'
--- sysbench/tests/db/oltp_complex_ro.lua	2009-06-10 23:43:32 +0000
+++ sysbench/tests/db/oltp_complex_ro.lua	1970-01-01 00:00:00 +0000
@@ -1,176 +0,0 @@
-function prepare()
-   local query
-   local i
-
-   set_vars()
-
-   db_connect()
-
-   print("Creating table 'sbtest'...")
-
-   if (db_driver == "mysql") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER UNSIGNED NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
-	      k INTEGER UNSIGNED DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-              pad CHAR(60) DEFAULT '' NOT NULL,
-              PRIMARY KEY (id)
-	    ) /*! ENGINE = ]] .. mysql_table_engine .. " MAX_ROWS = " .. myisam_max_rows .. " */"
-
-   elseif (db_driver == "oracle") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER NOT NULL,
-	      k INTEGER,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-	      pad CHAR(60 DEFAULT '' NOT NULL,
-	      PRIMARY KEY (id)
-	   ) ]]
-	
-
-   elseif (db_driver == "pgsql") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id ]] .. (sb.oltp_auto_inc and "SERIAL") or "" .. [[,
-	      k INTEGER DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-	      pad CHAR(60) DEFAULT '' NOT NULL, 
-	      PRIMARY KEY (id)
-	    ) ]]
-
-   elseif (db_driver == "drizzle") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
-	      k INTEGER DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-              pad CHAR(60) DEFAULT '' NOT NULL,
-              PRIMARY KEY (id)
-	    ) ]]
-
-   else
-      print("Unknown database driver: " .. db_driver)
-      return 1
-   end
-
-   db_query(query)
-
-   if (db_driver == "oracle") then
-      db_query("CREATE SEQUENCE sbtest_seq")
-      db_query([[CREATE TRIGGER sbtest_trig BEFORE INSERT ON sbtest 
-		     FOR EACH ROW BEGIN SELECT sbtest_seq.nextval INTO :new.id FROM DUAL; END;]])
-   end
-
-   db_query("CREATE INDEX k on sbtest(k)")
-
-   print("Inserting " .. oltp_table_size .. " records into 'sbtest'")
-   
-   if (oltp_auto_inc) then
-      db_bulk_insert_init("INSERT INTO sbtest(k, c, pad) VALUES")
-   else
-      db_bulk_insert_init("INSERT INTO sbtest(id, k, c, pad) VALUES")
-   end
-
-   for i = 1,oltp_table_size do
-      if (oltp_auto_inc) then
-	 db_bulk_insert_next("(0, ' ', 'qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
-      else
-	 db_bulk_insert_next("("..i..",0,' ','qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
-      end
-   end
-
-   db_bulk_insert_done()
-
-   return 0
-end
-
-function cleanup()
-   print("Dropping table 'sbtest'...")
-   db_query("DROP TABLE sbtest")
-end
-
-function thread_init(thread_id)
-   set_vars()
-
-   if (db_driver == "mysql" and mysql_table_engine == "myisam") then
-      begin_stmt = db_prepare("LOCK TABLES sbtest READ")
-      commit_stmt = db_prepare("UNLOCK TABLES")
-   else
-      begin_stmt = db_prepare("BEGIN")
-      commit_stmt = db_prepare("COMMIT")
-   end
-
-   point_stmt = db_prepare("SELECT c FROM sbtest WHERE id=?")
-   point_params = {0}
-   db_bind_param(point_stmt, point_params)
-
-   range_stmt = db_prepare("SELECT c FROM sbtest WHERE id BETWEEN ? AND ?")
-   range_params = {0,0}
-   db_bind_param(range_stmt, range_params)
-   
-   sum_stmt = db_prepare("SELECT SUM(K) FROM sbtest WHERE id BETWEEN ? AND ?")
-   sum_params = {0,0}
-   db_bind_param(sum_stmt, sum_params)
-
-   order_stmt= db_prepare("SELECT c FROM sbtest WHERE id BETWEEN ? AND ? ORDER BY c")
-   order_params = {0,0}
-   db_bind_param(order_stmt, order_params)
-
-   distinct_stmt = db_prepare("SELECT DISTINCT c FROM sbtest WHERE id BETWEEN ? AND ? ORDER BY c")
-   distinct_params = {0,0}
-   db_bind_param(distinct_stmt, distinct_params)
-
-end
-
-function event(thread_id)
-   local rs
-   local i
-
-   db_execute(begin_stmt)
-
-   for i=1,10 do
-      point_params[1] = sb_rand(1, oltp_table_size)
-      rs = db_execute(point_stmt)
-      db_store_results(rs)
-      db_free_results(rs)
-   end
-   
-   range_params[1] = sb_rand(1, oltp_table_size)
-   range_params[2] = range_params[1] + oltp_range_size - 1
-   rs = db_execute(range_stmt)
-   db_store_results(rs)
-   db_free_results(rs)
-   
-   sum_params[1] = sb_rand(1, oltp_table_size)
-   sum_params[2] = sum_params[1] + oltp_range_size - 1
-   rs = db_execute(sum_stmt)
-   db_store_results(rs)
-   db_free_results(rs)
-   
-   order_params[1] = sb_rand(1, oltp_table_size)
-   order_params[2] = order_params[1] + oltp_range_size - 1
-   rs = db_execute(order_stmt)
-   db_store_results(rs)
-   db_free_results(rs)
-   
-   distinct_params[1] = sb_rand(1, oltp_table_size)
-   distinct_params[2] = distinct_params[1] + oltp_range_size - 1
-   rs = db_execute(distinct_stmt)
-   db_store_results(rs)
-   db_free_results(rs)
-
-   db_execute(commit_stmt)
-   
-end
-
-function set_vars()
-   oltp_table_size = oltp_table_size or 10000
-   oltp_range_size = oltp_range_size or 100
-   
-   if (oltp_auto_inc == 'off') then
-      oltp_auto_inc = false
-   else
-      oltp_auto_inc = true
-   end
-end

=== removed file 'sysbench/tests/db/oltp_complex_rw.lua'
--- sysbench/tests/db/oltp_complex_rw.lua	2009-06-10 23:43:32 +0000
+++ sysbench/tests/db/oltp_complex_rw.lua	1970-01-01 00:00:00 +0000
@@ -1,210 +0,0 @@
-function prepare()
-   local query
-   local i
-
-   set_vars()
-
-   db_connect()
-
-   print("Creating table 'sbtest'...")
-
-   if (db_driver == "mysql") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER UNSIGNED NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
-	      k INTEGER UNSIGNED DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-              pad CHAR(60) DEFAULT '' NOT NULL,
-              PRIMARY KEY (id)
-	    ) /*! ENGINE = ]] .. mysql_table_engine .. " MAX_ROWS = " .. myisam_max_rows .. " */"
-
-   elseif (db_driver == "oracle") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER NOT NULL,
-	      k INTEGER,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-	      pad CHAR(60) DEFAULT '' NOT NULL,
-	      PRIMARY KEY (id)
-	   ) ]]
-	
-
-   elseif (db_driver == "pgsql") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id ]] .. (sb.oltp_auto_inc and "SERIAL") or "" .. [[,
-	      k INTEGER DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-	      pad CHAR(60) DEFAULT '' NOT NULL, 
-	      PRIMARY KEY (id)
-	    ) ]]
-
-   elseif (db_driver == "drizzle") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
-	      k INTEGER DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-              pad CHAR(60) DEFAULT '' NOT NULL,
-              PRIMARY KEY (id)
-	    ) ]]
-   else
-      print("Unknown database driver: " .. db_driver)
-      return 1
-   end
-
-   db_query(query)
-
-   if (db_driver == "oracle") then
-      db_query("CREATE SEQUENCE sbtest_seq")
-      db_query([[CREATE TRIGGER sbtest_trig BEFORE INSERT ON sbtest 
-		     FOR EACH ROW BEGIN SELECT sbtest_seq.nextval INTO :new.id FROM DUAL; END;]])
-   end
-
-   db_query("CREATE INDEX k on sbtest(k)")
-
-   print("Inserting " .. oltp_table_size .. " records into 'sbtest'")
-   
-   if (oltp_auto_inc) then
-      db_bulk_insert_init("INSERT INTO sbtest(k, c, pad) VALUES")
-   else
-      db_bulk_insert_init("INSERT INTO sbtest(id, k, c, pad) VALUES")
-   end
-
-   for i = 1,oltp_table_size do
-      if (oltp_auto_inc) then
-	 db_bulk_insert_next("(0, ' ', 'qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
-      else
-	 db_bulk_insert_next("("..i..",0,' ','qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
-      end
-   end
-
-   db_bulk_insert_done()
-
-   return 0
-end
-
-function cleanup()
-   print("Dropping table 'sbtest'...")
-   db_query("DROP TABLE sbtest")
-end
-
-function thread_init(thread_id)
-   set_vars()
-
-   if (db_driver == "mysql" and mysql_table_engine == "myisam") then
-      begin_stmt = db_prepare("LOCK TABLES sbtest WRITE")
-      commit_stmt = db_prepare("UNLOCK TABLES")
-   else
-      begin_stmt = db_prepare("BEGIN")
-      commit_stmt = db_prepare("COMMIT")
-   end
-
-   point_stmt = db_prepare("SELECT c FROM sbtest WHERE id=?")
-   point_params = {0}
-   db_bind_param(point_stmt, point_params)
-
-   range_stmt = db_prepare("SELECT c FROM sbtest WHERE id BETWEEN ? AND ?")
-   range_params = {0,0}
-   db_bind_param(range_stmt, range_params)
-   
-   sum_stmt = db_prepare("SELECT SUM(K) FROM sbtest WHERE id BETWEEN ? AND ?")
-   sum_params = {0,0}
-   db_bind_param(sum_stmt, sum_params)
-
-   order_stmt= db_prepare("SELECT c FROM sbtest WHERE id BETWEEN ? AND ? ORDER BY c")
-   order_params = {0,0}
-   db_bind_param(order_stmt, order_params)
-
-   distinct_stmt = db_prepare("SELECT DISTINCT c FROM sbtest WHERE id BETWEEN ? AND ? ORDER BY c")
-   distinct_params = {0,0}
-   db_bind_param(distinct_stmt, distinct_params)
-
-   update_idx_stmt = db_prepare("UPDATE sbtest SET k=k+1 WHERE id=?")
-   update_idx_params = {0}
-   db_bind_param(update_idx_stmt, update_idx_params)
-
-   update_nonidx_stmt = db_prepare("UPDATE sbtest SET c=? WHERE id=?")
-   update_nonidx_params = {"", 0}
-   db_bind_param(update_nonidx_stmt, update_nonidx_params)
-
-   delete_stmt = db_prepare("DELETE FROM sbtest WHERE id=?")
-   delete_params = {0}
-   db_bind_param(delete_stmt, delete_params)
-
-   insert_stmt = db_prepare([[
-		 INSERT INTO sbtest VALUES(?,0,' ',
-		 'aaaaaaaaaaffffffffffrrrrrrrrrreeeeeeeeeeyyyyyyyyyy')
-	   ]])
-   insert_params={0}
-   db_bind_param(insert_stmt, insert_params)
-end
-
-function event(thread_id)
-   local rs
-   local i
-
-   db_execute(begin_stmt)
-
-   for i=1,10 do
-      point_params[1] = sb_rand(1, oltp_table_size)
-      rs = db_execute(point_stmt)
-      db_store_results(rs)
-      db_free_results(rs)
-   end
-   
-   range_params[1] = sb_rand(1, oltp_table_size)
-   range_params[2] = range_params[1] + oltp_range_size - 1
-   rs = db_execute(range_stmt)
-   db_store_results(rs)
-   db_free_results(rs)
-   
-   sum_params[1] = sb_rand(1, oltp_table_size)
-   sum_params[2] = sum_params[1] + oltp_range_size - 1
-   rs = db_execute(sum_stmt)
-   db_store_results(rs)
-   db_free_results(rs)
-   
-   order_params[1] = sb_rand(1, oltp_table_size)
-   order_params[2] = order_params[1] + oltp_range_size - 1
-   rs = db_execute(order_stmt)
-   db_store_results(rs)
-   db_free_results(rs)
-   
-   distinct_params[1] = sb_rand(1, oltp_table_size)
-   distinct_params[2] = distinct_params[1] + oltp_range_size - 1
-   rs = db_execute(distinct_stmt)
-   db_store_results(rs)
-   db_free_results(rs)
-   
-   update_idx_params[1] = sb_rand(1, oltp_table_size)
-   rs = db_execute(update_idx_stmt)
-   
-   update_nonidx_params[1] = sb_rand_str([[
-###########-###########-###########-###########-###########-###########-###########-###########-###########-###########]])
-   update_nonidx_params[2] = sb_rand(1, oltp_table_size)
-   rs = db_execute(update_nonidx_stmt)
-   
-   -- DELETE and INSERT on the same id
-   local id = sb_rand(1, oltp_table_size)
-   
-   delete_params[1] = id
-   db_execute(delete_stmt)
-
-   insert_params[1] = id
-   db_execute(insert_stmt)
-
-   db_execute(commit_stmt)
-
-end
-
-function set_vars()
-   oltp_table_size = oltp_table_size or 10000
-   oltp_range_size = oltp_range_size or 100
-   
-   if (oltp_auto_inc == 'off') then
-      oltp_auto_inc = false
-   else
-      oltp_auto_inc = true
-   end
-end

=== modified file 'sysbench/tests/db/oltp_simple.lua'
--- sysbench/tests/db/oltp_simple.lua	2009-06-10 23:43:32 +0000
+++ sysbench/tests/db/oltp_simple.lua	2011-04-28 05:45:45 +0000
@@ -1,120 +1,15 @@
-function prepare()
-   local query
-   local i
-
-   set_vars()
-
-   db_connect()
-
-   print("Creating table 'sbtest'...")
-
-   if (db_driver == "mysql") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER UNSIGNED NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
-	      k INTEGER UNSIGNED DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-              pad CHAR(60) DEFAULT '' NOT NULL,
-              PRIMARY KEY (id)
-	    ) /*! ENGINE = ]] .. mysql_table_engine .. " MAX_ROWS = " .. myisam_max_rows .. " */"
-
-   elseif (db_driver == "oracle") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER NOT NULL,
-	      k INTEGER,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-	      pad CHAR(60 DEFAULT '' NOT NULL,
-	      PRIMARY KEY (id)
-	   ) ]]
-	
-
-   elseif (db_driver == "pgsql") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id ]] .. (sb.oltp_auto_inc and "SERIAL") or "" .. [[,
-	      k INTEGER DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-	      pad CHAR(60) DEFAULT '' NOT NULL, 
-	      PRIMARY KEY (id)
-	    ) ]]
-
-   elseif (db_driver == "drizzle") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
-	      k INTEGER DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-              pad CHAR(60) DEFAULT '' NOT NULL,
-              PRIMARY KEY (id)
-	    ) ]]
-
-   else
-      print("Unknown database driver: " .. db_driver)
-      return 1
-   end
-
-   db_query(query)
-
-   if (db_driver == "oracle") then
-      db_query("CREATE SEQUENCE sbtest_seq")
-      db_query([[CREATE TRIGGER sbtest_trig BEFORE INSERT ON sbtest 
-		     FOR EACH ROW BEGIN SELECT sbtest_seq.nextval INTO :new.id FROM DUAL; END;]])
-   end
-
-   db_query("CREATE INDEX k on sbtest(k)")
-
-   print("Inserting " .. oltp_table_size .. " records into 'sbtest'")
-   
-   if (oltp_auto_inc) then
-      db_bulk_insert_init("INSERT INTO sbtest(k, c, pad) VALUES")
-   else
-      db_bulk_insert_init("INSERT INTO sbtest(id, k, c, pad) VALUES")
-   end
-
-   for i = 1,oltp_table_size do
-      if (oltp_auto_inc) then
-	 db_bulk_insert_next("(0, ' ', 'qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
-      else
-	 db_bulk_insert_next("("..i..",0,' ','qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
-      end
-   end
-
-   db_bulk_insert_done()
-
-   return 0
-end
-
-function cleanup()
-   print("Dropping table 'sbtest'...")
-   db_query("DROP TABLE sbtest")
-end
+pathtest = string.match(test, "(.*/)") or ""
+
+dofile(pathtest .. "common.lua")
 
 function thread_init(thread_id)
    set_vars()
 
-   stmt = db_prepare([[
-	    SELECT c FROM sbtest WHERE id=?
-      ]])
-   params = {1}
-   db_bind_param(stmt, params)
-
 end
 
 function event(thread_id)
-   local rs
-   params[1] = sb_rand(1, oltp_table_size)
-   rs = db_execute(stmt)
-   db_store_results(rs)
-   db_free_results(rs)
-end
+   local table_name
+   table_name = "sbtest".. sb_rand_uniform(1, oltp_tables_count)
 
-function set_vars()
-   oltp_table_size = oltp_table_size or 10000
-   
-   if (oltp_auto_inc == 'off') then
-      oltp_auto_inc = false
-   else
-      oltp_auto_inc = true
-   end
+   rs = db_query("SELECT c FROM ".. table_name .." WHERE id=" .. sb_rand(1, oltp_table_size))
 end

=== added file 'sysbench/tests/db/parallel_prepare.lua'
--- sysbench/tests/db/parallel_prepare.lua	1970-01-01 00:00:00 +0000
+++ sysbench/tests/db/parallel_prepare.lua	2011-04-28 05:45:45 +0000
@@ -0,0 +1,26 @@
+pathtest = string.match(test, "(.*/)") or ""
+
+dofile(pathtest .. "common.lua")
+
+function thread_init(thread_id)
+   local index_name
+   local i
+   set_vars()
+   
+   print("thread prepare"..thread_id)
+
+   if (oltp_secondary) then
+     index_name = "KEY xid"
+   else
+     index_name = "PRIMARY KEY"
+   end
+
+   for i=thread_id+1, oltp_tables_count, num_threads  do
+   create_insert(i)
+   end
+
+end
+
+function event(thread_id)
+
+end

=== modified file 'sysbench/tests/db/select.lua'
--- sysbench/tests/db/select.lua	2009-06-10 23:43:32 +0000
+++ sysbench/tests/db/select.lua	2011-04-28 05:45:45 +0000
@@ -1,121 +1,14 @@
-function prepare()
-   local query
-   local i
-
-   set_vars()
-
-   db_connect()
-
-   print("Creating table 'sbtest'...")
-
-   if (db_driver == "mysql") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER UNSIGNED NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
-	      k INTEGER UNSIGNED DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-              pad CHAR(60) DEFAULT '' NOT NULL,
-              PRIMARY KEY (id)
-	    ) /*! ENGINE = ]] .. mysql_table_engine .. " MAX_ROWS = " .. myisam_max_rows .. " */"
-
-   elseif (db_driver == "oracle") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER NOT NULL,
-	      k INTEGER,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-	      pad CHAR(60 DEFAULT '' NOT NULL,
-	      PRIMARY KEY (id)
-	   ) ]]
-	
-
-   elseif (db_driver == "pgsql") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id ]] .. (sb.oltp_auto_inc and "SERIAL") or "" .. [[,
-	      k INTEGER DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-	      pad CHAR(60) DEFAULT '' NOT NULL, 
-	      PRIMARY KEY (id)
-	    ) ]]
-
-   elseif (db_driver == "drizzle") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
-	      k INTEGER DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-              pad CHAR(60) DEFAULT '' NOT NULL,
-              PRIMARY KEY (id)
-	    ) ]]
-
-   else
-      print("Unknown database driver: " .. db_driver)
-      return 1
-   end
-
-   db_query(query)
-
-   if (db_driver == "oracle") then
-      db_query("CREATE SEQUENCE sbtest_seq")
-      db_query([[CREATE TRIGGER sbtest_trig BEFORE INSERT ON sbtest 
-		     FOR EACH ROW BEGIN SELECT sbtest_seq.nextval INTO :new.id FROM DUAL; END;]])
-   end
-
-   db_query("CREATE INDEX k on sbtest(k)")
-
-   print("Inserting " .. oltp_table_size .. " records into 'sbtest'")
-   
-   if (oltp_auto_inc) then
-      db_bulk_insert_init("INSERT INTO sbtest(k, c, pad) VALUES")
-   else
-      db_bulk_insert_init("INSERT INTO sbtest(id, k, c, pad) VALUES")
-   end
-
-   for i = 1,oltp_table_size do
-      if (oltp_auto_inc) then
-	 db_bulk_insert_next("(0, ' ', 'qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
-      else
-	 db_bulk_insert_next("("..i..",0,' ','qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
-      end
-   end
-
-   db_bulk_insert_done()
-
-   return 0
-end
-
-function cleanup()
-   print("Dropping table 'sbtest'...")
-   db_query("DROP TABLE sbtest")
-end
+pathtest = string.match(test, "(.*/)") or ""
+
+dofile(pathtest .. "common.lua")
 
 function thread_init(thread_id)
-   local query
-
    set_vars()
-   
-   stmt = db_prepare([[
-			   SELECT pad FROM sbtest WHERE id = ?
-		     ]])
-   params = {0}
-   db_bind_param(stmt, params)
 end
 
 function event(thread_id)
-   local rs
-   params[1] = sb_rand(1, oltp_table_size)
-   rs = db_execute(stmt)
-   db_store_results(rs)
-   db_free_results(rs)
+   local table_name
+   table_name = "sbtest".. sb_rand_uniform(1, oltp_tables_count)
+   rs = db_query("SELECT pad FROM ".. table_name .." WHERE id=" .. sb_rand(1, oltp_table_size))
 end
 
-function set_vars()
-   oltp_table_size = oltp_table_size or 10000
-
-   if (oltp_auto_inc == 'off') then
-      oltp_auto_inc = false
-   else
-      oltp_auto_inc = true
-   end
-end
\ No newline at end of file

=== modified file 'sysbench/tests/db/update_index.lua'
--- sysbench/tests/db/update_index.lua	2009-06-10 23:43:32 +0000
+++ sysbench/tests/db/update_index.lua	2011-04-28 05:45:45 +0000
@@ -1,119 +1,13 @@
-function prepare()
-   local query
-   local i
-
-   set_vars()
-
-   db_connect()
-
-   print("Creating table 'sbtest'...")
-
-   if (db_driver == "mysql") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER UNSIGNED NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
-	      k INTEGER UNSIGNED DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-              pad CHAR(60) DEFAULT '' NOT NULL,
-              PRIMARY KEY (id)
-	    ) /*! ENGINE = ]] .. mysql_table_engine .. " MAX_ROWS = " .. myisam_max_rows .. " */"
-
-   elseif (db_driver == "oracle") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER NOT NULL,
-	      k INTEGER,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-	      pad CHAR(60 DEFAULT '' NOT NULL,
-	      PRIMARY KEY (id)
-	   ) ]]
-	
-
-   elseif (db_driver == "pgsql") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id ]] .. (sb.oltp_auto_inc and "SERIAL") or "" .. [[,
-	      k INTEGER DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-	      pad CHAR(60) DEFAULT '' NOT NULL, 
-	      PRIMARY KEY (id)
-	    ) ]]
-
-   elseif (db_driver == "drizzle") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
-	      k INTEGER DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-              pad CHAR(60) DEFAULT '' NOT NULL,
-              PRIMARY KEY (id)
-	    ) ]]
-
-   else
-      print("Unknown database driver: " .. db_driver)
-      return 1
-   end
-
-   db_query(query)
-
-   if (db_driver == "oracle") then
-      db_query("CREATE SEQUENCE sbtest_seq")
-      db_query([[CREATE TRIGGER sbtest_trig BEFORE INSERT ON sbtest 
-		     FOR EACH ROW BEGIN SELECT sbtest_seq.nextval INTO :new.id FROM DUAL; END;]])
-   end
-
-   db_query("CREATE INDEX k on sbtest(k)")
-
-   print("Inserting " .. oltp_table_size .. " records into 'sbtest'")
-   
-   if (oltp_auto_inc) then
-      db_bulk_insert_init("INSERT INTO sbtest(k, c, pad) VALUES")
-   else
-      db_bulk_insert_init("INSERT INTO sbtest(id, k, c, pad) VALUES")
-   end
-
-   for i = 1,oltp_table_size do
-      if (oltp_auto_inc) then
-	 db_bulk_insert_next("(0, ' ', 'qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
-      else
-	 db_bulk_insert_next("("..i..",0,' ','qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
-      end
-   end
-
-   db_bulk_insert_done()
-
-   return 0
-end
-
-function cleanup()
-   print("Dropping table 'sbtest'...")
-   db_query("DROP TABLE sbtest")
-end
+pathtest = string.match(test, "(.*/)") or ""
+
+dofile(pathtest .. "common.lua")
 
 function thread_init(thread_id)
-   local query
-
    set_vars()
-   
-   stmt = db_prepare([[
-			   UPDATE sbtest SET k=k+1 WHERE id = ?
-		     ]])
-   params = {0}
-   db_bind_param(stmt, params)
 end
 
 function event(thread_id)
-   local rs
-   params[1] = sb_rand(1, oltp_table_size)
-   rs = db_execute(stmt)
+   local table_name
+   table_name = "sbtest".. sb_rand_uniform(1, oltp_tables_count)
+   rs = db_query("UPDATE ".. table_name .." SET k=k+1 WHERE id=" .. sb_rand(1, oltp_table_size))
 end
-
-function set_vars()
-   oltp_table_size = oltp_table_size or 10000
-
-   if (oltp_auto_inc == 'off') then
-      oltp_auto_inc = false
-   else
-      oltp_auto_inc = true
-   end
-end
\ No newline at end of file

=== modified file 'sysbench/tests/db/update_non_index.lua'
--- sysbench/tests/db/update_non_index.lua	2009-06-10 23:43:32 +0000
+++ sysbench/tests/db/update_non_index.lua	2011-04-28 05:45:45 +0000
@@ -1,121 +1,17 @@
-function prepare()
-   local query
-   local i
-
-   set_vars()
-
-   db_connect()
-
-   print("Creating table 'sbtest'...")
-
-   if (db_driver == "mysql") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER UNSIGNED NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
-	      k INTEGER UNSIGNED DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-              pad CHAR(60) DEFAULT '' NOT NULL,
-              PRIMARY KEY (id)
-	    ) /*! ENGINE = ]] .. mysql_table_engine .. " MAX_ROWS = " .. myisam_max_rows .. " */"
-
-   elseif (db_driver == "oracle") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER NOT NULL,
-	      k INTEGER,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-	      pad CHAR(60 DEFAULT '' NOT NULL,
-	      PRIMARY KEY (id)
-	   ) ]]
-	
-
-   elseif (db_driver == "pgsql") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id ]] .. (sb.oltp_auto_inc and "SERIAL") or "" .. [[,
-	      k INTEGER DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-	      pad CHAR(60) DEFAULT '' NOT NULL, 
-	      PRIMARY KEY (id)
-	    ) ]]
-
-   elseif (db_driver == "drizzle") then
-      query = [[
-	    CREATE TABLE sbtest (
-	      id INTEGER NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
-	      k INTEGER DEFAULT '0' NOT NULL,
-	      c CHAR(120) DEFAULT '' NOT NULL,
-              pad CHAR(60) DEFAULT '' NOT NULL,
-              PRIMARY KEY (id)
-	    ) ]]
-
-   else
-      print("Unknown database driver: " .. db_driver)
-      return 1
-   end
-
-   db_query(query)
-
-   if (db_driver == "oracle") then
-      db_query("CREATE SEQUENCE sbtest_seq")
-      db_query([[CREATE TRIGGER sbtest_trig BEFORE INSERT ON sbtest 
-		     FOR EACH ROW BEGIN SELECT sbtest_seq.nextval INTO :new.id FROM DUAL; END;]])
-   end
-
-   db_query("CREATE INDEX k on sbtest(k)")
-
-   print("Inserting " .. oltp_table_size .. " records into 'sbtest'")
-   
-   if (oltp_auto_inc) then
-      db_bulk_insert_init("INSERT INTO sbtest(k, c, pad) VALUES")
-   else
-      db_bulk_insert_init("INSERT INTO sbtest(id, k, c, pad) VALUES")
-   end
-
-   for i = 1,oltp_table_size do
-      if (oltp_auto_inc) then
-	 db_bulk_insert_next("(0, ' ', 'qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
-      else
-	 db_bulk_insert_next("("..i..",0,' ','qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
-      end
-   end
-
-   db_bulk_insert_done()
-
-   return 0
-end
-
-function cleanup()
-   print("Dropping table 'sbtest'...")
-   db_query("DROP TABLE sbtest")
-end
+pathtest = string.match(test, "(.*/)") or ""
+
+dofile(pathtest .. "common.lua")
 
 function thread_init(thread_id)
-   local query
-
    set_vars()
-   
-   stmt = db_prepare([[
-			   UPDATE sbtest set c=? where id=?
-		     ]])
-   params = {"", 0}
-   db_bind_param(stmt, params)
 end
 
 function event(thread_id)
-   local rs
-   params[1] = sb_rand_str([[
-###########-###########-###########-###########-###########-###########-###########-###########-###########-###########]])
-   params[2] = sb_rand(1, oltp_table_size)
-   rs = db_execute(stmt)
+   local table_name
+   local c_val
+   local query
+   table_name = "sbtest".. sb_rand_uniform(1, oltp_tables_count)
+   c_val = sb_rand_str("###########-###########-###########-###########-###########-###########-###########-###########-###########-###########")
+   query = "UPDATE " .. table_name .. " SET c='" .. c_val .. "' WHERE id=" .. sb_rand(1, oltp_table_size)
+   rs = db_query(query)
 end
-
-function set_vars()
-   oltp_table_size = oltp_table_size or 10000
-
-   if (oltp_auto_inc == 'off') then
-      oltp_auto_inc = false
-   else
-      oltp_auto_inc = true
-   end
-end
\ No newline at end of file


Follow ups