88#include <unistd.h>
99
1010extern bool get_ddl_only ;
11+ extern bool simple_wo_part ;
12+ extern bool first_col_as_dist_key ;
13+ extern int buffer_size ;
1114
1215static int load_table_list_file (const char * filename , char * * * p_tables , char * * * p_queries );
1316
@@ -22,6 +25,7 @@ main(int argc, char **argv)
2225 char * sport = NULL ;
2326 //char *tabname = NULL;
2427 int res_getopt = 0 ;
28+ char * target_schema = NULL ;
2529 char * table_list_file = NULL ;
2630 char * * tables = NULL , * * queries = NULL ;
2731
@@ -53,7 +57,7 @@ main(int argc, char **argv)
5357
5458 src .port = atoi (sport );
5559
56- while ((res_getopt = getopt (argc , argv , ":l:j:d " )) != -1 )
60+ while ((res_getopt = getopt (argc , argv , ":l:j:dnfhs:b: " )) != -1 )
5761 {
5862 switch (res_getopt )
5963 {
@@ -63,17 +67,34 @@ main(int argc, char **argv)
6367 case 'j' :
6468 num_thread = atoi (optarg );
6569 break ;
70+ case 'b' :
71+ buffer_size = 1024 * atoi (optarg );
72+ break ;
73+ case 's' :
74+ target_schema = optarg ;
75+ break ;
6676 case ':' :
67- fprintf (stderr , "No value specified for -%c" , optopt );
77+ fprintf (stderr , "No value specified for -%c\n " , optopt );
6878 break ;
6979 case 'd' :
7080 get_ddl_only = true;
7181 break ;
82+ case 'n' :
83+ simple_wo_part = true;
84+ break ;
85+ case 'f' :
86+ first_col_as_dist_key = true;
87+ break ;
88+ case 'h' :
89+ fprintf (stderr , "Usage: -l <table list file> -j <thread number> -d -n -f -s -b -h\n" );
90+ fprintf (stderr , " -l specifies a file with table listed;\n -j specifies number of threads to do the job;\n -d means get DDL only without fetching data;\n -n means no partion info in DDLs;\n -f means taking first column as distribution key;\n -s specifies the target schema;\n -b specifies the buffer size in KB used to sending copy data to target db, the default is 0" );
91+ return 0 ;
7292 case '?' :
7393 fprintf (stderr , "Unsupported option: %c" , optopt );
7494 break ;
7595 default :
7696 fprintf (stderr , "Parameter parsing error: %c" , res_getopt );
97+ return -1 ;
7798
7899 }
79100 }
@@ -94,7 +115,7 @@ main(int argc, char **argv)
94115 if (get_ddl_only )
95116 num_thread = 1 ;
96117
97- return mysql2pgsql_sync_main (desc , num_thread , & src );
118+ return mysql2pgsql_sync_main (desc , num_thread , & src , target_schema );
98119}
99120
100121
@@ -212,7 +233,7 @@ int load_table_list_file(const char *filename, char*** p_tables, char*** p_queri
212233 table_array [cur_table ] = table_begin ;
213234 query_array [cur_table ] = query_begin ;
214235 cur_table ++ ;
215- fprintf (stderr , "Adding table: %s\n" , table_begin );
236+ fprintf (stderr , "-- Adding table: %s\n" , table_begin );
216237 }
217238
218239 table_begin = p + 1 ;
0 commit comments