4
4
*
5
5
* Portions Copyright (c) 2002-2008, PostgreSQL Global Development Group
6
6
*
7
- * $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.20 2008/01/01 19:45:56 momjian Exp $
7
+ * $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.21 2008/11/24 08:46:04 petere Exp $
8
8
*
9
9
*-------------------------------------------------------------------------
10
10
*/
14
14
#include "dumputils.h"
15
15
16
16
17
- static void cluster_one_database (const char * dbname ,const char * table ,
17
+ static void cluster_one_database (const char * dbname ,bool verbose , const char * table ,
18
18
const char * host ,const char * port ,
19
19
const char * username ,bool password ,
20
20
const char * progname ,bool echo );
21
- static void cluster_all_databases (const char * host ,const char * port ,
21
+ static void cluster_all_databases (bool verbose , const char * host ,const char * port ,
22
22
const char * username ,bool password ,
23
23
const char * progname ,bool echo ,bool quiet );
24
24
@@ -38,6 +38,7 @@ main(int argc, char *argv[])
38
38
{"dbname" ,required_argument ,NULL ,'d' },
39
39
{"all" ,no_argument ,NULL ,'a' },
40
40
{"table" ,required_argument ,NULL ,'t' },
41
+ {"verbose" ,no_argument ,NULL ,'v' },
41
42
{NULL ,0 ,NULL ,0 }
42
43
};
43
44
@@ -54,13 +55,14 @@ main(int argc, char *argv[])
54
55
bool quiet = false;
55
56
bool alldb = false;
56
57
char * table = NULL ;
58
+ bool verbose = false;
57
59
58
60
progname = get_progname (argv [0 ]);
59
61
set_pglocale_pgservice (argv [0 ],"pgscripts" );
60
62
61
63
handle_help_version_opts (argc ,argv ,"clusterdb" ,help );
62
64
63
- while ((c = getopt_long (argc ,argv ,"h:p:U:Weqd:at:" ,long_options ,& optindex ))!= -1 )
65
+ while ((c = getopt_long (argc ,argv ,"h:p:U:Weqd:at:v " ,long_options ,& optindex ))!= -1 )
64
66
{
65
67
switch (c )
66
68
{
@@ -91,6 +93,9 @@ main(int argc, char *argv[])
91
93
case 't' :
92
94
table = optarg ;
93
95
break ;
96
+ case 'v' :
97
+ verbose = true;
98
+ break ;
94
99
default :
95
100
fprintf (stderr ,_ ("Try \"%s --help\" for more information.\n" ),progname );
96
101
exit (1 );
@@ -128,7 +133,7 @@ main(int argc, char *argv[])
128
133
exit (1 );
129
134
}
130
135
131
- cluster_all_databases (host ,port ,username ,password ,
136
+ cluster_all_databases (verbose , host ,port ,username ,password ,
132
137
progname ,echo ,quiet );
133
138
}
134
139
else
@@ -143,7 +148,7 @@ main(int argc, char *argv[])
143
148
dbname = get_user_name (progname );
144
149
}
145
150
146
- cluster_one_database (dbname ,table ,
151
+ cluster_one_database (dbname ,verbose , table ,
147
152
host ,port ,username ,password ,
148
153
progname ,echo );
149
154
}
@@ -153,7 +158,7 @@ main(int argc, char *argv[])
153
158
154
159
155
160
static void
156
- cluster_one_database (const char * dbname ,const char * table ,
161
+ cluster_one_database (const char * dbname ,bool verbose , const char * table ,
157
162
const char * host ,const char * port ,
158
163
const char * username ,bool password ,
159
164
const char * progname ,bool echo )
@@ -165,6 +170,8 @@ cluster_one_database(const char *dbname, const char *table,
165
170
initPQExpBuffer (& sql );
166
171
167
172
appendPQExpBuffer (& sql ,"CLUSTER" );
173
+ if (verbose )
174
+ appendPQExpBuffer (& sql ," VERBOSE" );
168
175
if (table )
169
176
appendPQExpBuffer (& sql ," %s" ,fmtId (table ));
170
177
appendPQExpBuffer (& sql ,";\n" );
@@ -187,7 +194,7 @@ cluster_one_database(const char *dbname, const char *table,
187
194
188
195
189
196
static void
190
- cluster_all_databases (const char * host ,const char * port ,
197
+ cluster_all_databases (bool verbose , const char * host ,const char * port ,
191
198
const char * username ,bool password ,
192
199
const char * progname ,bool echo ,bool quiet )
193
200
{
@@ -209,7 +216,7 @@ cluster_all_databases(const char *host, const char *port,
209
216
fflush (stdout );
210
217
}
211
218
212
- cluster_one_database (dbname ,NULL ,
219
+ cluster_one_database (dbname ,verbose , NULL ,
213
220
host ,port ,username ,password ,
214
221
progname ,echo );
215
222
}
@@ -230,6 +237,7 @@ help(const char *progname)
230
237
printf (_ (" -t, --table=TABLE cluster specific table only\n" ));
231
238
printf (_ (" -e, --echo show the commands being sent to the server\n" ));
232
239
printf (_ (" -q, --quiet don't write any messages\n" ));
240
+ printf (_ (" -v, --verbose write a lot of output\n" ));
233
241
printf (_ (" --help show this help, then exit\n" ));
234
242
printf (_ (" --version output version information, then exit\n" ));
235
243
printf (_ ("\nConnection options:\n" ));