27main(
int argc,
char *argv[])
29 static struct option long_options[] = {
69 const char *maintenance_db = NULL;
75 int concurrentCons = 1;
76 unsigned int tbl_count = 0;
80 memset(&vacopts, 0,
sizeof(vacopts));
91 memset(&cparams, 0,
sizeof(cparams));
100 while ((
c =
getopt_long(argc, argv,
"ad:efFh:j:n:N:p:P:qt:U:vwWzZ",
101 long_options, &optindex)) != -1)
236 pg_log_error(
"too many command-line arguments (first is \"%s\")",
252 pg_fatal(
"cannot use the \"%s\" option when performing only analyze",
255 pg_fatal(
"cannot use the \"%s\" option when performing only analyze",
258 pg_fatal(
"cannot use the \"%s\" option when performing only analyze",
259 "disable-page-skipping");
261 pg_fatal(
"cannot use the \"%s\" option when performing only analyze",
264 pg_fatal(
"cannot use the \"%s\" option when performing only analyze",
265 "force-index-cleanup");
267 pg_fatal(
"cannot use the \"%s\" option when performing only analyze",
270 pg_fatal(
"cannot use the \"%s\" option when performing only analyze",
273 pg_fatal(
"cannot use the \"%s\" option when performing only analyze",
283 pg_fatal(
"cannot use the \"%s\" option when performing only analyze",
286 pg_fatal(
"cannot use the \"%s\" option when performing full vacuum",
292 pg_fatal(
"cannot use the \"%s\" option with the \"%s\" option",
293 "no-index-cleanup",
"force-index-cleanup");
300 pg_fatal(
"cannot use the \"%s\" option with the \"%s\" option",
301 "buffer-usage-limit",
"full");
309 pg_fatal(
"cannot use the \"%s\" option without \"%s\" or \"%s\"",
310 "missing-stats-only",
"analyze-only",
"analyze-in-stages");
327 pg_fatal(
"cannot vacuum all databases and a specific one at the same time");
331 pg_fatal(
"cannot vacuum all tables in schema(s) and specific table(s) at the same time");
335 pg_fatal(
"cannot vacuum specific table(s) and exclude schema(s) at the same time");
339 pg_fatal(
"cannot vacuum all tables in schema(s) and exclude schema(s) at the same time");
346 printf(
_(
"%s cleans and analyzes a PostgreSQL database.\n\n"),
progname);
350 printf(
_(
" -a, --all vacuum all databases\n"));
351 printf(
_(
" --buffer-usage-limit=SIZE size of ring buffer used for vacuum\n"));
352 printf(
_(
" -d, --dbname=DBNAME database to vacuum\n"));
353 printf(
_(
" --disable-page-skipping disable all page-skipping behavior\n"));
354 printf(
_(
" -e, --echo show the commands being sent to the server\n"));
355 printf(
_(
" -f, --full do full vacuuming\n"));
356 printf(
_(
" -F, --freeze freeze row transaction information\n"));
357 printf(
_(
" --force-index-cleanup always remove index entries that point to dead tuples\n"));
358 printf(
_(
" -j, --jobs=NUM use this many concurrent connections to vacuum\n"));
359 printf(
_(
" --min-mxid-age=MXID_AGE minimum multixact ID age of tables to vacuum\n"));
360 printf(
_(
" --min-xid-age=XID_AGE minimum transaction ID age of tables to vacuum\n"));
361 printf(
_(
" --missing-stats-only only analyze relations with missing statistics\n"));
362 printf(
_(
" --no-index-cleanup don't remove index entries that point to dead tuples\n"));
363 printf(
_(
" --no-process-main skip the main relation\n"));
364 printf(
_(
" --no-process-toast skip the TOAST table associated with the table to vacuum\n"));
365 printf(
_(
" --no-truncate don't truncate empty pages at the end of the table\n"));
366 printf(
_(
" -n, --schema=SCHEMA vacuum tables in the specified schema(s) only\n"));
367 printf(
_(
" -N, --exclude-schema=SCHEMA do not vacuum tables in the specified schema(s)\n"));
368 printf(
_(
" -P, --parallel=PARALLEL_WORKERS use this many background workers for vacuum, if available\n"));
369 printf(
_(
" -q, --quiet don't write any messages\n"));
370 printf(
_(
" --skip-locked skip relations that cannot be immediately locked\n"));
371 printf(
_(
" -t, --table='TABLE[(COLUMNS)]' vacuum specific table(s) only\n"));
372 printf(
_(
" -v, --verbose write a lot of output\n"));
373 printf(
_(
" -V, --version output version information, then exit\n"));
374 printf(
_(
" -z, --analyze update optimizer statistics\n"));
375 printf(
_(
" -Z, --analyze-only only update optimizer statistics; no vacuum\n"));
376 printf(
_(
" --analyze-in-stages only update optimizer statistics, in multiple\n"
377 " stages for faster results; no vacuum\n"));
378 printf(
_(
" -?, --help show this help, then exit\n"));
379 printf(
_(
"\nConnection options:\n"));
380 printf(
_(
" -h, --host=HOSTNAME database server host or socket directory\n"));
381 printf(
_(
" -p, --port=PORT database server port\n"));
382 printf(
_(
" -U, --username=USERNAME user name to connect as\n"));
383 printf(
_(
" -w, --no-password never prompt for password\n"));
384 printf(
_(
" -W, --password force password prompt\n"));
385 printf(
_(
" --maintenance-db=DBNAME alternate maintenance database\n"));
386 printf(
_(
"\nRead the description of the SQL command VACUUM for details.\n"));
387 printf(
_(
"\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
388 printf(
_(
"%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
#define PG_TEXTDOMAIN(domain)
void set_pglocale_pgservice(const char *argv0, const char *app)
char * pg_strdup(const char *in)
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
#define required_argument
static char * escape_quotes(const char *src)
void pg_logging_init(const char *argv0)
#define pg_log_error(...)
#define pg_log_error_hint(...)
bool option_parse_int(const char *optarg, const char *optname, int min_range, int max_range, int *result)
void handle_help_version_opts(int argc, char *argv[], const char *fixed_progname, help_handler hlp)
PGDLLIMPORT char * optarg
const char * get_progname(const char *argv0)
void simple_string_list_append(SimpleStringList *list, const char *val)
enum trivalue prompt_password
bool disable_page_skipping
char * buffer_usage_limit
int main(int argc, char *argv[])
static void help(const char *progname)
static void check_objfilter(bits32 objfilter)
int vacuuming_main(ConnParams *cparams, const char *dbname, const char *maintenance_db, vacuumingOptions *vacopts, SimpleStringList *objects, unsigned int tbl_count, int concurrentCons, const char *progname, bool echo, bool quiet)
#define OBJFILTER_ALL_DBS
#define OBJFILTER_SCHEMA_EXCLUDE
#define OBJFILTER_DATABASE