55 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
66 * Portions Copyright (c) 1994, Regents of the University of California
77 *
8- * $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.22 2009/01/01 17:23 :55 momjian Exp $
8+ * $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.23 2009/02/18 12:11 :55 momjian Exp $
99 *
1010 *-------------------------------------------------------------------------
1111 */
1515
1616
1717static void vacuum_one_database (const char * dbname ,bool full ,bool verbose ,bool analyze ,
18- const char * table ,
18+ bool freeze , const char * table ,
1919const char * host ,const char * port ,
2020const char * username ,bool password ,
2121const char * progname ,bool echo );
22- static void vacuum_all_databases (bool full ,bool verbose ,bool analyze ,
22+ static void vacuum_all_databases (bool full ,bool verbose ,bool analyze ,bool freeze ,
2323const char * host ,const char * port ,
2424const char * username ,bool password ,
2525const char * progname ,bool echo ,bool quiet );
@@ -39,6 +39,7 @@ main(int argc, char *argv[])
3939{"quiet" ,no_argument ,NULL ,'q' },
4040{"dbname" ,required_argument ,NULL ,'d' },
4141{"analyze" ,no_argument ,NULL ,'z' },
42+ {"freeze" ,no_argument ,NULL ,'F' },
4243{"all" ,no_argument ,NULL ,'a' },
4344{"table" ,required_argument ,NULL ,'t' },
4445{"full" ,no_argument ,NULL ,'f' },
@@ -58,6 +59,7 @@ main(int argc, char *argv[])
5859bool echo = false;
5960bool quiet = false;
6061bool analyze = false;
62+ bool freeze = false;
6163bool alldb = false;
6264char * table = NULL ;
6365bool full = false;
@@ -68,7 +70,7 @@ main(int argc, char *argv[])
6870
6971handle_help_version_opts (argc ,argv ,"vacuumdb" ,help );
7072
71- while ((c = getopt_long (argc ,argv ,"h:p:U:Weqd:zat :fv" ,long_options ,& optindex ))!= -1 )
73+ while ((c = getopt_long (argc ,argv ,"h:p:U:Weqd:zaFt :fv" ,long_options ,& optindex ))!= -1 )
7274{
7375switch (c )
7476{
@@ -96,6 +98,9 @@ main(int argc, char *argv[])
9698case 'z' :
9799analyze = true;
98100break ;
101+ case 'F' :
102+ freeze = true;
103+ break ;
99104case 'a' :
100105alldb = true;
101106break ;
@@ -145,7 +150,7 @@ main(int argc, char *argv[])
145150exit (1 );
146151}
147152
148- vacuum_all_databases (full ,verbose ,analyze ,
153+ vacuum_all_databases (full ,verbose ,analyze ,freeze ,
149154host ,port ,username ,password ,
150155progname ,echo ,quiet );
151156}
@@ -161,7 +166,7 @@ main(int argc, char *argv[])
161166dbname = get_user_name (progname );
162167}
163168
164- vacuum_one_database (dbname ,full ,verbose ,analyze ,table ,
169+ vacuum_one_database (dbname ,full ,verbose ,analyze ,freeze , table ,
165170host ,port ,username ,password ,
166171progname ,echo );
167172}
@@ -172,7 +177,7 @@ main(int argc, char *argv[])
172177
173178static void
174179vacuum_one_database (const char * dbname ,bool full ,bool verbose ,bool analyze ,
175- const char * table ,
180+ bool freeze , const char * table ,
176181const char * host ,const char * port ,
177182const char * username ,bool password ,
178183const char * progname ,bool echo )
@@ -190,6 +195,8 @@ vacuum_one_database(const char *dbname, bool full, bool verbose, bool analyze,
190195appendPQExpBuffer (& sql ," VERBOSE" );
191196if (analyze )
192197appendPQExpBuffer (& sql ," ANALYZE" );
198+ if (freeze )
199+ appendPQExpBuffer (& sql ," FREEZE" );
193200if (table )
194201appendPQExpBuffer (& sql ," %s" ,table );
195202appendPQExpBuffer (& sql ,";\n" );
@@ -212,7 +219,7 @@ vacuum_one_database(const char *dbname, bool full, bool verbose, bool analyze,
212219
213220
214221static void
215- vacuum_all_databases (bool full ,bool verbose ,bool analyze ,
222+ vacuum_all_databases (bool full ,bool verbose ,bool analyze ,bool freeze ,
216223const char * host ,const char * port ,
217224const char * username ,bool password ,
218225const char * progname ,bool echo ,bool quiet )
@@ -235,7 +242,7 @@ vacuum_all_databases(bool full, bool verbose, bool analyze,
235242fflush (stdout );
236243}
237244
238- vacuum_one_database (dbname ,full ,verbose ,analyze ,NULL ,
245+ vacuum_one_database (dbname ,full ,verbose ,analyze ,freeze , NULL ,
239246host ,port ,username ,password ,
240247progname ,echo );
241248}
@@ -256,6 +263,7 @@ help(const char *progname)
256263printf (_ (" -t, --table='TABLE[(COLUMNS)]' vacuum specific table only\n" ));
257264printf (_ (" -f, --full do full vacuuming\n" ));
258265printf (_ (" -z, --analyze update optimizer hints\n" ));
266+ printf (_ (" -F, --freeze freeze row transaction information\n" ));
259267printf (_ (" -e, --echo show the commands being sent to the server\n" ));
260268printf (_ (" -q, --quiet don't write any messages\n" ));
261269printf (_ (" -v, --verbose write a lot of output\n" ));