On Thu, Oct 9, 2008 at 9:37 AM, Jim Cox <[EMAIL PROTECTED]> wrote: > Is anyone working the "CLUSTER: Add VERBOSE option..." TODO item listed > on the PostgreSQL Wiki? If not, would it be wise for me to use > VERBOSE handling in an existing command (e.g. VACUUM) > as a guide while adding VERBOSE to CLUSTER? > > A patch s/b attached which adds a "VERBOSE" option to the CLUSTER command as mentioned in the following TODO item for CLUSTER: "Add VERBOSE option to report tables as they are processed, like VACUUM VERBOSE".
In short, all three variations of the CLUSTER command now take an optional "VERBOSE" arg, if present an INFO message is generated which displays the schema.tblname just before actual clustering is kicked off (see example below). postgres=# CLUSTER ; CLUSTER postgres=# CLUSTER VERBOSE ; INFO: clustering "public.my_b" INFO: clustering "public.my_c" INFO: clustering "public.my_a" CLUSTER postgres=# CLUSTER public.my_c ; CLUSTER postgres=# CLUSTER public.my_c VERBOSE ; INFO: clustering "public.my_c" CLUSTER
Index: src/backend/commands/cluster.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/commands/cluster.c,v retrieving revision 1.177 diff -c -r1.177 cluster.c *** src/backend/commands/cluster.c 19 Jun 2008 00:46:04 -0000 1.177 --- src/backend/commands/cluster.c 10 Oct 2008 12:47:04 -0000 *************** *** 60,66 **** } RelToCluster; ! static void cluster_rel(RelToCluster *rv, bool recheck); 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); --- 60,66 ---- } RelToCluster; ! static void cluster_rel(RelToCluster *rv, bool recheck, int elevel); 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); *************** *** 176,182 **** heap_close(rel, NoLock); /* Do the job */ ! cluster_rel(&rvtc, false); } else { --- 176,182 ---- heap_close(rel, NoLock); /* Do the job */ ! cluster_rel(&rvtc, false, stmt->verbose ? INFO : DEBUG2); } else { *************** *** 225,231 **** StartTransactionCommand(); /* functions in indexes may want a snapshot set */ PushActiveSnapshot(GetTransactionSnapshot()); ! cluster_rel(rvtc, true); PopActiveSnapshot(); CommitTransactionCommand(); } --- 225,231 ---- StartTransactionCommand(); /* functions in indexes may want a snapshot set */ PushActiveSnapshot(GetTransactionSnapshot()); ! cluster_rel(rvtc, true, stmt->verbose ? INFO : DEBUG2); PopActiveSnapshot(); CommitTransactionCommand(); } *************** *** 253,259 **** * them incrementally while we load the table. */ static void ! cluster_rel(RelToCluster *rvtc, bool recheck) { Relation OldHeap; --- 253,259 ---- * them incrementally while we load the table. */ static void ! cluster_rel(RelToCluster *rvtc, bool recheck, int elevel) { Relation OldHeap; *************** *** 343,348 **** --- 343,352 ---- check_index_is_clusterable(OldHeap, rvtc->indexOid, recheck); /* rebuild_relation does all the dirty work */ + ereport(elevel, + (errmsg("clustering \"%s.%s\"", + get_namespace_name(RelationGetNamespace(OldHeap)), + RelationGetRelationName(OldHeap)))); rebuild_relation(OldHeap, rvtc->indexOid); /* NB: rebuild_relation does heap_close() on OldHeap */ Index: src/backend/nodes/copyfuncs.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v retrieving revision 1.408 diff -c -r1.408 copyfuncs.c *** src/backend/nodes/copyfuncs.c 7 Oct 2008 19:27:04 -0000 1.408 --- src/backend/nodes/copyfuncs.c 10 Oct 2008 12:47:04 -0000 *************** *** 2259,2264 **** --- 2259,2265 ---- COPY_NODE_FIELD(relation); COPY_STRING_FIELD(indexname); + COPY_SCALAR_FIELD(verbose) ; return newnode; } Index: src/backend/nodes/equalfuncs.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v retrieving revision 1.333 diff -c -r1.333 equalfuncs.c *** src/backend/nodes/equalfuncs.c 6 Oct 2008 17:39:26 -0000 1.333 --- src/backend/nodes/equalfuncs.c 10 Oct 2008 12:47:04 -0000 *************** *** 1000,1005 **** --- 1000,1006 ---- { COMPARE_NODE_FIELD(relation); COMPARE_STRING_FIELD(indexname); + COMPARE_SCALAR_FIELD(verbose); return true; } Index: src/backend/parser/gram.y =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/parser/gram.y,v retrieving revision 2.625 diff -c -r2.625 gram.y *** src/backend/parser/gram.y 4 Oct 2008 21:56:54 -0000 2.625 --- src/backend/parser/gram.y 10 Oct 2008 12:47:05 -0000 *************** *** 5738,5770 **** /***************************************************************************** * * QUERY: ! * CLUSTER <qualified_name> [ USING <index_name> ] ! * CLUSTER ! * CLUSTER <index_name> ON <qualified_name> (for pre-8.3) * *****************************************************************************/ ClusterStmt: ! CLUSTER qualified_name cluster_index_specification { ClusterStmt *n = makeNode(ClusterStmt); n->relation = $2; n->indexname = $3; $$ = (Node*)n; } ! | CLUSTER { ClusterStmt *n = makeNode(ClusterStmt); n->relation = NULL; n->indexname = NULL; $$ = (Node*)n; } /* kept for pre-8.3 compatibility */ ! | CLUSTER index_name ON qualified_name { ClusterStmt *n = makeNode(ClusterStmt); n->relation = $4; n->indexname = $2; $$ = (Node*)n; } ; --- 5738,5773 ---- /***************************************************************************** * * QUERY: ! * CLUSTER <qualified_name> [ USING <index_name> ] [VERBOSE] ! * CLUSTER [VERBOSE] ! * CLUSTER <index_name> ON <qualified_name> [VERBOSE] (for pre-8.3) * *****************************************************************************/ ClusterStmt: ! CLUSTER qualified_name cluster_index_specification opt_verbose { ClusterStmt *n = makeNode(ClusterStmt); n->relation = $2; n->indexname = $3; + n->verbose = $4; $$ = (Node*)n; } ! | CLUSTER opt_verbose { ClusterStmt *n = makeNode(ClusterStmt); n->relation = NULL; n->indexname = NULL; + n->verbose = $2; $$ = (Node*)n; } /* kept for pre-8.3 compatibility */ ! | CLUSTER index_name ON qualified_name opt_verbose { ClusterStmt *n = makeNode(ClusterStmt); n->relation = $4; n->indexname = $2; + n->verbose = $5; $$ = (Node*)n; } ; Index: src/include/nodes/parsenodes.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/nodes/parsenodes.h,v retrieving revision 1.376 diff -c -r1.376 parsenodes.h *** src/include/nodes/parsenodes.h 4 Oct 2008 21:56:55 -0000 1.376 --- src/include/nodes/parsenodes.h 10 Oct 2008 12:47:06 -0000 *************** *** 1940,1945 **** --- 1940,1946 ---- NodeTag type; RangeVar *relation; /* relation being indexed, or NULL if all */ char *indexname; /* original index defined */ + bool verbose; /* print progress info */ } ClusterStmt; /* ----------------------
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers