44 *
55 * Portions Copyright (c) 2002-2008, PostgreSQL Global Development Group
66 *
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 $
88 *
99 *-------------------------------------------------------------------------
1010 */
1414#include "dumputils.h"
1515
1616
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 ,
1818const char * host ,const char * port ,
1919const char * username ,bool password ,
2020const 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 ,
2222const char * username ,bool password ,
2323const char * progname ,bool echo ,bool quiet );
2424
@@ -38,6 +38,7 @@ main(int argc, char *argv[])
3838{"dbname" ,required_argument ,NULL ,'d' },
3939{"all" ,no_argument ,NULL ,'a' },
4040{"table" ,required_argument ,NULL ,'t' },
41+ {"verbose" ,no_argument ,NULL ,'v' },
4142{NULL ,0 ,NULL ,0 }
4243};
4344
@@ -54,13 +55,14 @@ main(int argc, char *argv[])
5455bool quiet = false;
5556bool alldb = false;
5657char * table = NULL ;
58+ bool verbose = false;
5759
5860progname = get_progname (argv [0 ]);
5961set_pglocale_pgservice (argv [0 ],"pgscripts" );
6062
6163handle_help_version_opts (argc ,argv ,"clusterdb" ,help );
6264
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 )
6466{
6567switch (c )
6668{
@@ -91,6 +93,9 @@ main(int argc, char *argv[])
9193case 't' :
9294table = optarg ;
9395break ;
96+ case 'v' :
97+ verbose = true;
98+ break ;
9499default :
95100fprintf (stderr ,_ ("Try \"%s --help\" for more information.\n" ),progname );
96101exit (1 );
@@ -128,7 +133,7 @@ main(int argc, char *argv[])
128133exit (1 );
129134}
130135
131- cluster_all_databases (host ,port ,username ,password ,
136+ cluster_all_databases (verbose , host ,port ,username ,password ,
132137progname ,echo ,quiet );
133138}
134139else
@@ -143,7 +148,7 @@ main(int argc, char *argv[])
143148dbname = get_user_name (progname );
144149}
145150
146- cluster_one_database (dbname ,table ,
151+ cluster_one_database (dbname ,verbose , table ,
147152host ,port ,username ,password ,
148153progname ,echo );
149154}
@@ -153,7 +158,7 @@ main(int argc, char *argv[])
153158
154159
155160static void
156- cluster_one_database (const char * dbname ,const char * table ,
161+ cluster_one_database (const char * dbname ,bool verbose , const char * table ,
157162const char * host ,const char * port ,
158163const char * username ,bool password ,
159164const char * progname ,bool echo )
@@ -165,6 +170,8 @@ cluster_one_database(const char *dbname, const char *table,
165170initPQExpBuffer (& sql );
166171
167172appendPQExpBuffer (& sql ,"CLUSTER" );
173+ if (verbose )
174+ appendPQExpBuffer (& sql ," VERBOSE" );
168175if (table )
169176appendPQExpBuffer (& sql ," %s" ,fmtId (table ));
170177appendPQExpBuffer (& sql ,";\n" );
@@ -187,7 +194,7 @@ cluster_one_database(const char *dbname, const char *table,
187194
188195
189196static void
190- cluster_all_databases (const char * host ,const char * port ,
197+ cluster_all_databases (bool verbose , const char * host ,const char * port ,
191198const char * username ,bool password ,
192199const char * progname ,bool echo ,bool quiet )
193200{
@@ -209,7 +216,7 @@ cluster_all_databases(const char *host, const char *port,
209216fflush (stdout );
210217}
211218
212- cluster_one_database (dbname ,NULL ,
219+ cluster_one_database (dbname ,verbose , NULL ,
213220host ,port ,username ,password ,
214221progname ,echo );
215222}
@@ -230,6 +237,7 @@ help(const char *progname)
230237printf (_ (" -t, --table=TABLE cluster specific table only\n" ));
231238printf (_ (" -e, --echo show the commands being sent to the server\n" ));
232239printf (_ (" -q, --quiet don't write any messages\n" ));
240+ printf (_ (" -v, --verbose write a lot of output\n" ));
233241printf (_ (" --help show this help, then exit\n" ));
234242printf (_ (" --version output version information, then exit\n" ));
235243printf (_ ("\nConnection options:\n" ));