Commit bcef3229 authored by yiwenshao's avatar yiwenshao

use limited pipe

parent 1a2a3ddd
name="all.sql" name="all.sql"
if [ $# = 1 ];then if [ $# = 1 ];then
name=$1 name=$1
fi fi
mysqldump -uroot -pletmein -h127.0.0.1 -P3306 --no-create-info --compact tpcc1000 > $name mysqldump -uroot -h127.0.0.1 -P3306 --no-create-info --compact tpcc1000 > $name
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
function mysql_command(){ function mysql_command(){
cmd=\'$1\' cmd=\'$1\'
#single quoted ${cmd} is not recognised #single quoted ${cmd} is not recognised
final="mysql -uroot -pletmein -h127.0.0.1 -e ${cmd}" final="mysql -uroot -h127.0.0.1 -e ${cmd}"
#eval can not be ommited here, can not just use $final only for this command #eval can not be ommited here, can not just use $final only for this command
res=`eval $final` res=`eval $final`
echo $res echo $res
...@@ -10,8 +10,9 @@ function mysql_command(){ ...@@ -10,8 +10,9 @@ function mysql_command(){
function show_table_counts(){ function show_table_counts(){
db=$1 db=$1
raw=`mysql -uroot -pletmein -h127.0.0.1 -e "use $db;show tables;"| awk '{print $1}'` raw=`mysql -uroot -h127.0.0.1 -e "use $db;show tables;"| awk '{print $1}'`
arr=($raw) arr=($raw)
echo $arr
len=${#arr[@]} len=${#arr[@]}
for((i=1;i<$len;i++)) for((i=1;i<$len;i++))
do do
......
drop table if exists warehouse;
SET sql_mode = '';
create table warehouse (
w_id smallint unsigned,
w_name varchar(10),
w_street_1 varchar(20),
w_street_2 varchar(20),
w_city varchar(20),
w_state char(2),
w_zip char(9),
w_tax integer unsigned,
w_ytd integer unsigned
) Engine=InnoDB;
drop table if exists district;
create table district (
d_id tinyint unsigned,
d_w_id smallint unsigned,
d_name varchar(10),
d_street_1 varchar(20),
d_street_2 varchar(20),
d_city varchar(20),
d_state char(2),
d_zip char(9),
d_tax integer unsigned,
d_ytd integer unsigned,
d_next_o_id int unsigned
) Engine=InnoDB;
drop table if exists customer;
create table customer (
c_id int unsigned,
c_d_id tinyint unsigned,
c_w_id smallint unsigned,
c_first varchar(16),
c_middle char(2),
c_last varchar(16),
c_street_1 varchar(20),
c_street_2 varchar(20),
c_city varchar(20),
c_state char(2),
c_zip char(9),
c_phone char(16),
c_since varchar(20),
c_credit char(2),
c_credit_lim bigint unsigned,
c_discount bigint unsigned,
c_balance bigint unsigned,
c_ytd_payment bigint unsigned,
c_payment_cnt smallint,
c_delivery_cnt smallint,
c_data VARCHAR(1000)) Engine=InnoDB;
drop table if exists history;
create table history (
h_c_id int,
h_c_d_id tinyint,
h_c_w_id smallint,
h_d_id tinyint,
h_w_id smallint,
h_date varchar(20),
h_amount integer unsigned,
h_data varchar(24) ) Engine=InnoDB;
drop table if exists new_orders;
create table new_orders (
no_o_id int not null,
no_d_id tinyint not null,
no_w_id smallint not null) Engine=InnoDB;
drop table if exists orders;
create table orders (
o_id int not null,
o_d_id tinyint not null,
o_w_id smallint not null,
o_c_id int,
o_entry_d varchar(20),
o_carrier_id tinyint,
o_ol_cnt tinyint,
o_all_local tinyint) Engine=InnoDB ;
drop table if exists order_line;
create table order_line (
ol_o_id int not null,
ol_d_id tinyint not null,
ol_w_id smallint not null,
ol_number tinyint not null,
ol_i_id int,
ol_supply_w_id smallint,
ol_delivery_d varchar(20),
ol_quantity tinyint,
ol_amount integer unsigned,
ol_dist_info char(24)) Engine=InnoDB ;
drop table if exists item;
create table item (
i_id int not null,
i_im_id int,
i_name varchar(24),
i_price integer unsigned,
i_data varchar(50)
) Engine=InnoDB;
drop table if exists stock;
create table stock (
s_i_id int not null,
s_w_id smallint not null,
s_quantity smallint,
s_dist_01 char(24),
s_dist_02 char(24),
s_dist_03 char(24),
s_dist_04 char(24),
s_dist_05 char(24),
s_dist_06 char(24),
s_dist_07 char(24),
s_dist_08 char(24),
s_dist_09 char(24),
s_dist_10 char(24),
s_ytd integer unsigned,
s_order_cnt smallint,
s_remote_cnt smallint,
s_data varchar(50)) Engine=InnoDB;
#backup data with limited pipecount
current_dir=`pwd`
db=tpcc1000
pipe=100
tables=`mysql -uroot -h127.0.0.1 -P3306 $db -e "show tables" | awk '{print $1}'`
table_array=($tables)
len=${#table_array[@]}
back_dir=pipe_$pipe
rm -rf $back_dir
mkdir $back_dir
cd ../tls/mysql_wrapper/
for((i=1;i<$len;i++))
do
cmd="./main 100 $db ${table_array[$i]}"
eval $cmd > $current_dir/$back_dir/${table_array[$i]}.sql
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment