diff options
author | Fujii Masao | 2015-05-15 11:09:57 +0000 |
---|---|---|
committer | Fujii Masao | 2015-05-15 11:09:57 +0000 |
commit | ecd222e770d352121590363ffdf981147a43e976 (patch) | |
tree | 9fa6f9d3ad7002f5d8ced9948d49b72206bad713 /src/backend/commands | |
parent | 4b8f797f672bef07b4e87b4650b4035731b61d84 (diff) |
Support VERBOSE option in REINDEX command.
When this option is specified, a progress report is printed as each index
is reindexed.
Per discussion, we agreed on the following syntax for the extensibility of
the options.
REINDEX (flexible options) { INDEX | ... } name
Sawada Masahiko.
Reviewed by Robert Haas, FabrÃzio Mello, Alvaro Herrera, Kyotaro Horiguchi,
Jim Nasby and me.
Discussion: CAD21AoA0pK3YcOZAFzMae+2fcc3oGp5zoRggDyMNg5zoaWDhdQ@mail.gmail.com
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/cluster.c | 2 | ||||
-rw-r--r-- | src/backend/commands/indexcmds.c | 25 | ||||
-rw-r--r-- | src/backend/commands/tablecmds.c | 2 |
3 files changed, 17 insertions, 12 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 3febdd5cf44..7ab4874c4bd 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -1532,7 +1532,7 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap, else if (newrelpersistence == RELPERSISTENCE_PERMANENT) reindex_flags |= REINDEX_REL_FORCE_INDEXES_PERMANENT; - reindex_relation(OIDOldHeap, reindex_flags); + reindex_relation(OIDOldHeap, reindex_flags, 0); /* * If the relation being rebuild is pg_class, swap_relation_files() diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 351d48ece62..7340a1fc2bb 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -1681,7 +1681,7 @@ ChooseIndexColumnNames(List *indexElems) * Recreate a specific index. */ Oid -ReindexIndex(RangeVar *indexRelation) +ReindexIndex(RangeVar *indexRelation, int options) { Oid indOid; Oid heapOid = InvalidOid; @@ -1706,7 +1706,7 @@ ReindexIndex(RangeVar *indexRelation) persistence = irel->rd_rel->relpersistence; index_close(irel, NoLock); - reindex_index(indOid, false, persistence); + reindex_index(indOid, false, persistence, options); return indOid; } @@ -1775,7 +1775,7 @@ RangeVarCallbackForReindexIndex(const RangeVar *relation, * Recreate all indexes of a table (and of its toast table, if any) */ Oid -ReindexTable(RangeVar *relation) +ReindexTable(RangeVar *relation, int options) { Oid heapOid; @@ -1785,7 +1785,8 @@ ReindexTable(RangeVar *relation) if (!reindex_relation(heapOid, REINDEX_REL_PROCESS_TOAST | - REINDEX_REL_CHECK_CONSTRAINTS)) + REINDEX_REL_CHECK_CONSTRAINTS, + options)) ereport(NOTICE, (errmsg("table \"%s\" has no indexes", relation->relname))); @@ -1802,7 +1803,8 @@ ReindexTable(RangeVar *relation) * That means this must not be called within a user transaction block! */ void -ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind) +ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind, + int options) { Oid objectOid; Relation relationRelation; @@ -1938,11 +1940,14 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind) PushActiveSnapshot(GetTransactionSnapshot()); if (reindex_relation(relid, REINDEX_REL_PROCESS_TOAST | - REINDEX_REL_CHECK_CONSTRAINTS)) - ereport(DEBUG1, - (errmsg("table \"%s.%s\" was reindexed", - get_namespace_name(get_rel_namespace(relid)), - get_rel_name(relid)))); + REINDEX_REL_CHECK_CONSTRAINTS, + options)) + + if (options & REINDEXOPT_VERBOSE) + ereport(INFO, + (errmsg("table \"%s.%s\" was reindexed", + get_namespace_name(get_rel_namespace(relid)), + get_rel_name(relid)))); PopActiveSnapshot(); CommitTransactionCommand(); } diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 0a6b0690657..33ea387d62f 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -1234,7 +1234,7 @@ ExecuteTruncate(TruncateStmt *stmt) /* * Reconstruct the indexes to match, and we're done. */ - reindex_relation(heap_relid, REINDEX_REL_PROCESS_TOAST); + reindex_relation(heap_relid, REINDEX_REL_PROCESS_TOAST, 0); } pgstat_count_truncate(rel); |