@@ -58,8 +58,8 @@ main(int argc, char *argv[])
58
58
bool echo = false;
59
59
bool quiet = false;
60
60
bool alldb = false;
61
- char * table = NULL ;
62
61
bool verbose = false;
62
+ SimpleStringList tables = {NULL , NULL };
63
63
64
64
progname = get_progname (argv [0 ]);
65
65
set_pglocale_pgservice (argv [0 ], PG_TEXTDOMAIN ("pgscripts" ));
@@ -98,7 +98,7 @@ main(int argc, char *argv[])
98
98
alldb = true;
99
99
break ;
100
100
case 't' :
101
- table = pg_strdup ( optarg );
101
+ simple_string_list_append ( & tables , optarg );
102
102
break ;
103
103
case 'v' :
104
104
verbose = true;
@@ -140,9 +140,10 @@ main(int argc, char *argv[])
140
140
progname );
141
141
exit (1 );
142
142
}
143
- if (table )
143
+
144
+ if (tables .head != NULL )
144
145
{
145
- fprintf (stderr , _ ("%s: cannot cluster a specific table in all databases\n" ),
146
+ fprintf (stderr , _ ("%s: cannot cluster specific table(s) in all databases\n" ),
146
147
progname );
147
148
exit (1 );
148
149
}
@@ -162,9 +163,21 @@ main(int argc, char *argv[])
162
163
dbname = get_user_name (progname );
163
164
}
164
165
165
- cluster_one_database (dbname , verbose , table ,
166
- host , port , username , prompt_password ,
167
- progname , echo );
166
+ if (tables .head != NULL )
167
+ {
168
+ SimpleStringListCell * cell ;
169
+
170
+ for (cell = tables .head ; cell ; cell = cell -> next )
171
+ {
172
+ cluster_one_database (dbname , verbose , cell -> val ,
173
+ host , port , username , prompt_password ,
174
+ progname , echo );
175
+ }
176
+ }
177
+ else
178
+ cluster_one_database (dbname , verbose , NULL ,
179
+ host , port , username , prompt_password ,
180
+ progname , echo );
168
181
}
169
182
170
183
exit (0 );
@@ -253,7 +266,7 @@ help(const char *progname)
253
266
printf (_ (" -d, --dbname=DBNAME database to cluster\n" ));
254
267
printf (_ (" -e, --echo show the commands being sent to the server\n" ));
255
268
printf (_ (" -q, --quiet don't write any messages\n" ));
256
- printf (_ (" -t, --table=TABLE cluster specific table only\n" ));
269
+ printf (_ (" -t, --table=TABLE cluster specific table(s) only\n" ));
257
270
printf (_ (" -v, --verbose write a lot of output\n" ));
258
271
printf (_ (" -V, --version output version information, then exit\n" ));
259
272
printf (_ (" -?, --help show this help, then exit\n" ));
0 commit comments