1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-29 23:43:17 +03:00

CLUSTER VERBOSE and corresponding clusterdb --verbose option

Jim Cox and Peter Eisentraut
This commit is contained in:
Peter Eisentraut
2008-11-24 08:46:04 +00:00
parent 6f6a6d8b14
commit a378555501
8 changed files with 71 additions and 32 deletions

View File

@@ -11,7 +11,7 @@
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
@@ -61,7 +61,7 @@ typedef struct
} 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);
@@ -177,7 +177,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
heap_close(rel, NoLock);
/* Do the job */
cluster_rel(&rvtc, false);
cluster_rel(&rvtc, false, stmt->verbose);
}
else
{
@@ -226,7 +226,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
StartTransactionCommand();
/* functions in indexes may want a snapshot set */
PushActiveSnapshot(GetTransactionSnapshot());
cluster_rel(rvtc, true);
cluster_rel(rvtc, true, stmt->verbose);
PopActiveSnapshot();
CommitTransactionCommand();
}
@@ -254,7 +254,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
* 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;
@@ -344,6 +344,10 @@ cluster_rel(RelToCluster *rvtc, bool recheck)
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 */

View File

@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.412 2008/11/15 19:43:46 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.413 2008/11/24 08:46:03 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2293,6 +2293,7 @@ _copyClusterStmt(ClusterStmt *from)
COPY_NODE_FIELD(relation);
COPY_STRING_FIELD(indexname);
COPY_SCALAR_FIELD(verbose) ;
return newnode;
}

View File

@@ -22,7 +22,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.337 2008/11/15 19:43:46 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.338 2008/11/24 08:46:03 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1032,6 +1032,7 @@ _equalClusterStmt(ClusterStmt *a, ClusterStmt *b)
{
COMPARE_NODE_FIELD(relation);
COMPARE_STRING_FIELD(indexname);
COMPARE_SCALAR_FIELD(verbose);
return true;
}

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.639 2008/11/21 11:47:55 petere Exp $
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.640 2008/11/24 08:46:03 petere Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -5781,33 +5781,36 @@ CreateConversionStmt:
/*****************************************************************************
*
* QUERY:
* CLUSTER <qualified_name> [ USING <index_name> ]
* CLUSTER
* CLUSTER <index_name> ON <qualified_name> (for pre-8.3)
* CLUSTER [VERBOSE] <qualified_name> [ USING <index_name> ]
* CLUSTER [VERBOSE]
* CLUSTER [VERBOSE] <index_name> ON <qualified_name> (for pre-8.3)
*
*****************************************************************************/
ClusterStmt:
CLUSTER qualified_name cluster_index_specification
CLUSTER opt_verbose qualified_name cluster_index_specification
{
ClusterStmt *n = makeNode(ClusterStmt);
n->relation = $2;
n->indexname = $3;
n->relation = $3;
n->indexname = $4;
n->verbose = $2;
$$ = (Node*)n;
}
| CLUSTER
| 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
| CLUSTER opt_verbose index_name ON qualified_name
{
ClusterStmt *n = makeNode(ClusterStmt);
n->relation = $4;
n->indexname = $2;
n->relation = $5;
n->indexname = $3;
n->verbose = $2;
$$ = (Node*)n;
}
;