@@ -30,7 +30,9 @@ MYSQL_STMT ***stmt;
30
30
char connect_string [DB_STRING_MAX ];
31
31
32
32
char db_string [DB_STRING_MAX ];
33
+ char db_schemaid [DB_STRING_MAX ];
33
34
char db_host [DB_STRING_MAX ];
35
+ char db_socket [DB_STRING_MAX ] = "" ;
34
36
char db_user [DB_STRING_MAX ];
35
37
char db_password [DB_STRING_MAX ];
36
38
char report_file [DB_STRING_MAX ]= "" ;
@@ -49,6 +51,7 @@ char node_string[NUM_NODE_MAX][DB_STRING_MAX];
49
51
50
52
int time_count ;
51
53
int PRINT_INTERVAL = 10 ;
54
+ int multi_schema = 0 ;
52
55
53
56
int success [5 ];
54
57
int late [5 ];
@@ -141,7 +144,7 @@ int main( int argc, char *argv[] )
141
144
142
145
/* Parse args */
143
146
144
- while ( (c = getopt (argc , argv , "h:P:d:u:p:w:c:r:l:i:f:t:" )) != -1 ) {
147
+ while ( (c = getopt (argc , argv , "h:P:d:u:p:w:c:r:l:i:f:t:m:S: " )) != -1 ) {
145
148
switch (c ) {
146
149
case 'h' :
147
150
printf ("option h with value '%s'\n" , optarg );
@@ -183,6 +186,10 @@ int main( int argc, char *argv[] )
183
186
printf ("option l with value '%s'\n" , optarg );
184
187
measure_time = atoi (optarg );
185
188
break ;
189
+ case 'm' :
190
+ printf ("option m (multiple schemas) with value '%s'\n" , optarg );
191
+ multi_schema = atoi (optarg );
192
+ break ;
186
193
case 'i' :
187
194
printf ("option i with value '%s'\n" , optarg );
188
195
PRINT_INTERVAL = atoi (optarg );
@@ -191,6 +198,10 @@ int main( int argc, char *argv[] )
191
198
printf ("option P with value '%s'\n" , optarg );
192
199
port = atoi (optarg );
193
200
break ;
201
+ case 'S' :
202
+ printf ("option S (socket) with value '%s'\n" , optarg );
203
+ strncpy (db_socket , optarg , DB_STRING_MAX );
204
+ break ;
194
205
case '?' :
195
206
printf ("Usage: tpcc_start -h server_host -P port -d database_name -u mysql_user -p mysql_password -w warehouses -c connections -r warmup_time -l running_time -i report_interval -f report_file -t trx_file\n" );
196
207
exit (0 );
@@ -657,6 +668,7 @@ int thread_main (thread_arg* arg)
657
668
int r ,i ;
658
669
659
670
char * db_string_ptr ;
671
+ char db_string_full [DB_STRING_MAX * 2 ];
660
672
MYSQL * resp ;
661
673
662
674
db_string_ptr = db_string ;
@@ -667,12 +679,18 @@ int thread_main (thread_arg* arg)
667
679
db_string_ptr = node_string [((num_node * t_num )/num_conn )];
668
680
}
669
681
682
+ if (multi_schema ) {
683
+ sprintf (db_string_full ,"%s_%d" ,db_string , t_num % multi_schema );
684
+ }else {
685
+ sprintf (db_string_full ,"%s" ,db_string );
686
+ }
687
+
670
688
if (is_local == 1 ){
671
689
/* exec sql connect :connect_string; */
672
- resp = mysql_real_connect (ctx [t_num ], "localhost" , db_user , db_password , db_string , port , NULL , 0 );
690
+ resp = mysql_real_connect (ctx [t_num ], "localhost" , db_user , db_password , db_string_full , port , db_socket , 0 );
673
691
}else {
674
692
/* exec sql connect :connect_string USING :db_string; */
675
- resp = mysql_real_connect (ctx [t_num ], connect_string , db_user , db_password , db_string , port , NULL , 0 );
693
+ resp = mysql_real_connect (ctx [t_num ], connect_string , db_user , db_password , db_string_full , port , db_socket , 0 );
676
694
}
677
695
678
696
if (resp ) {
0 commit comments