*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.178 2008/10/14 17:19:50 alvherre Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.179 2008/11/24 08:46:03 petere Exp $
*
*-------------------------------------------------------------------------
*/
} RelToCluster;
-static void cluster_rel(RelToCluster *rv, bool recheck);
+static void cluster_rel(RelToCluster *rv, bool recheck, bool verbose);
static void rebuild_relation(Relation OldHeap, Oid indexOid);
static TransactionId copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex);
static List *get_tables_to_cluster(MemoryContext cluster_context);
heap_close(rel, NoLock);
/* Do the job */
- cluster_rel(&rvtc, false);
+ cluster_rel(&rvtc, false, stmt->verbose);
}
else
{
StartTransactionCommand();
/* functions in indexes may want a snapshot set */
PushActiveSnapshot(GetTransactionSnapshot());
- cluster_rel(rvtc, true);
+ cluster_rel(rvtc, true, stmt->verbose);
PopActiveSnapshot();
CommitTransactionCommand();
}
* them incrementally while we load the table.
*/
static void
-cluster_rel(RelToCluster *rvtc, bool recheck)
+cluster_rel(RelToCluster *rvtc, bool recheck, bool verbose)
{
Relation OldHeap;
check_index_is_clusterable(OldHeap, rvtc->indexOid, recheck);
/* rebuild_relation does all the dirty work */
+ ereport(verbose ? INFO : DEBUG2,
+ (errmsg("clustering \"%s.%s\"",
+ get_namespace_name(RelationGetNamespace(OldHeap)),
+ RelationGetRelationName(OldHeap))));
rebuild_relation(OldHeap, rvtc->indexOid);
/* NB: rebuild_relation does heap_close() on OldHeap */
*
* Portions Copyright (c) 2002-2008, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.20 2008/01/01 19:45:56 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.21 2008/11/24 08:46:04 petere Exp $
*
*-------------------------------------------------------------------------
*/
#include "dumputils.h"
-static void cluster_one_database(const char *dbname, const char *table,
+static void cluster_one_database(const char *dbname, bool verbose, const char *table,
const char *host, const char *port,
const char *username, bool password,
const char *progname, bool echo);
-static void cluster_all_databases(const char *host, const char *port,
+static void cluster_all_databases(bool verbose, const char *host, const char *port,
const char *username, bool password,
const char *progname, bool echo, bool quiet);
{"dbname", required_argument, NULL, 'd'},
{"all", no_argument, NULL, 'a'},
{"table", required_argument, NULL, 't'},
+ {"verbose", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0}
};
bool quiet = false;
bool alldb = false;
char *table = NULL;
+ bool verbose = false;
progname = get_progname(argv[0]);
set_pglocale_pgservice(argv[0], "pgscripts");
handle_help_version_opts(argc, argv, "clusterdb", help);
- while ((c = getopt_long(argc, argv, "h:p:U:Weqd:at:", long_options, &optindex)) != -1)
+ while ((c = getopt_long(argc, argv, "h:p:U:Weqd:at:v", long_options, &optindex)) != -1)
{
switch (c)
{
case 't':
table = optarg;
break;
+ case 'v':
+ verbose = true;
+ break;
default:
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
exit(1);
}
- cluster_all_databases(host, port, username, password,
+ cluster_all_databases(verbose, host, port, username, password,
progname, echo, quiet);
}
else
dbname = get_user_name(progname);
}
- cluster_one_database(dbname, table,
+ cluster_one_database(dbname, verbose, table,
host, port, username, password,
progname, echo);
}
static void
-cluster_one_database(const char *dbname, const char *table,
+cluster_one_database(const char *dbname, bool verbose, const char *table,
const char *host, const char *port,
const char *username, bool password,
const char *progname, bool echo)
initPQExpBuffer(&sql);
appendPQExpBuffer(&sql, "CLUSTER");
+ if (verbose)
+ appendPQExpBuffer(&sql, " VERBOSE");
if (table)
appendPQExpBuffer(&sql, " %s", fmtId(table));
appendPQExpBuffer(&sql, ";\n");
static void
-cluster_all_databases(const char *host, const char *port,
+cluster_all_databases(bool verbose, const char *host, const char *port,
const char *username, bool password,
const char *progname, bool echo, bool quiet)
{
fflush(stdout);
}
- cluster_one_database(dbname, NULL,
+ cluster_one_database(dbname, verbose, NULL,
host, port, username, password,
progname, echo);
}
printf(_(" -t, --table=TABLE cluster specific table only\n"));
printf(_(" -e, --echo show the commands being sent to the server\n"));
printf(_(" -q, --quiet don't write any messages\n"));
+ printf(_(" -v, --verbose write a lot of output\n"));
printf(_(" --help show this help, then exit\n"));
printf(_(" --version output version information, then exit\n"));
printf(_("\nConnection options:\n"));