On Sat, Dec 12, 2020 at 01:45:26PM -0600, Justin Pryzby wrote: > On Sat, Dec 12, 2020 at 09:20:35AM +0100, Peter Eisentraut wrote: > > On 2020-12-11 21:27, Alvaro Herrera wrote: > > > By the way-- What did you think of the idea of explictly marking the > > > types used for bitmasks using types bits32 and friends, instead of plain > > > int, which is harder to spot? > > > > If we want to make it clearer, why not turn the thing into a struct, as in > > the attached patch, and avoid the bit fiddling altogether. > > I like this. > It's a lot like what I wrote as [PATCH v31 1/5] ExecReindex and ReindexParams > In my v31 patch, I moved ReindexOptions to a private structure in indexcmds.c, > with an "int options" bitmask which is passed to reindex_index() et al. Your > patch keeps/puts ReindexOptions index.h, so it also applies to reindex_index, > which I think is good. > > So I've rebased this branch on your patch. > > Some thoughts: > > - what about removing the REINDEXOPT_* prefix ? > - You created local vars with initialization like "={}". But I thought it's > needed to include at least one struct member like "={false}", or else > they're not guaranteed to be zerod ? > - You passed the structure across function calls. The usual convention is to > pass a pointer.
I think maybe Michael missed this message (?) I had applied some changes on top of Peter's patch. I squished those commits now, and also handled ClusterOption and VacuumOption in the same style. Some more thoughts: - should the structures be named in plural ? "ReindexOptions" etc. Since they define *all* the options, not just a single bit. - For vacuum, do we even need a separate structure, or should the members be directly within VacuumParams ? It's a bit odd to write params.options.verbose. Especially since there's also ternary options which are directly within params. - Then, for cluster, I think it should be called ClusterParams, and eventually include the tablespaceOid, like what we're doing for Reindex. I am awaiting feedback on these before going further since I've done too much rebasing with these ideas going back and forth and back. -- Justin
>From 34bf8abaca50d39cb9fd00b21752f931b05a62f3 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <pe...@eisentraut.org> Date: Sat, 12 Dec 2020 09:17:55 +0100 Subject: [PATCH 1/4] Convert reindex options to struct --- src/backend/catalog/index.c | 24 ++++---- src/backend/commands/cluster.c | 3 +- src/backend/commands/indexcmds.c | 96 ++++++++++++++++---------------- src/backend/commands/tablecmds.c | 4 +- src/backend/tcop/utility.c | 10 ++-- src/include/catalog/index.h | 16 +++--- src/include/commands/defrem.h | 9 +-- 7 files changed, 83 insertions(+), 79 deletions(-) diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 731610c701..da2f45b796 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -3594,7 +3594,7 @@ IndexGetRelation(Oid indexId, bool missing_ok) */ void reindex_index(Oid indexId, bool skip_constraint_checks, char persistence, - int options) + ReindexOptions *options) { Relation iRel, heapRelation; @@ -3602,7 +3602,6 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence, IndexInfo *indexInfo; volatile bool skipped_constraint = false; PGRUsage ru0; - bool progress = (options & REINDEXOPT_REPORT_PROGRESS) != 0; pg_rusage_init(&ru0); @@ -3611,12 +3610,12 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence, * we only need to be sure no schema or data changes are going on. */ heapId = IndexGetRelation(indexId, - (options & REINDEXOPT_MISSING_OK) != 0); + options->REINDEXOPT_MISSING_OK); /* if relation is missing, leave */ if (!OidIsValid(heapId)) return; - if ((options & REINDEXOPT_MISSING_OK) != 0) + if (options->REINDEXOPT_MISSING_OK) heapRelation = try_table_open(heapId, ShareLock); else heapRelation = table_open(heapId, ShareLock); @@ -3625,7 +3624,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence, if (!heapRelation) return; - if (progress) + if (options->REINDEXOPT_REPORT_PROGRESS) { pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX, heapId); @@ -3641,7 +3640,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence, */ iRel = index_open(indexId, AccessExclusiveLock); - if (progress) + if (options->REINDEXOPT_REPORT_PROGRESS) pgstat_progress_update_param(PROGRESS_CREATEIDX_ACCESS_METHOD_OID, iRel->rd_rel->relam); @@ -3792,14 +3791,14 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence, } /* Log what we did */ - if (options & REINDEXOPT_VERBOSE) + if (options->REINDEXOPT_VERBOSE) ereport(INFO, (errmsg("index \"%s\" was reindexed", get_rel_name(indexId)), errdetail_internal("%s", pg_rusage_show(&ru0)))); - if (progress) + if (options->REINDEXOPT_REPORT_PROGRESS) pgstat_progress_end_command(); /* Close rels, but keep locks */ @@ -3846,7 +3845,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence, * index rebuild. */ bool -reindex_relation(Oid relid, int flags, int options) +reindex_relation(Oid relid, int flags, ReindexOptions *options) { Relation rel; Oid toast_relid; @@ -3861,7 +3860,7 @@ reindex_relation(Oid relid, int flags, int options) * to prevent schema and data changes in it. The lock level used here * should match ReindexTable(). */ - if ((options & REINDEXOPT_MISSING_OK) != 0) + if (options->REINDEXOPT_MISSING_OK) rel = try_table_open(relid, ShareLock); else rel = table_open(relid, ShareLock); @@ -3965,8 +3964,9 @@ reindex_relation(Oid relid, int flags, int options) * Note that this should fail if the toast relation is missing, so * reset REINDEXOPT_MISSING_OK. */ - result |= reindex_relation(toast_relid, flags, - options & ~(REINDEXOPT_MISSING_OK)); + ReindexOptions newoptions = *options; + newoptions.REINDEXOPT_MISSING_OK = false; + result |= reindex_relation(toast_relid, flags, &newoptions); } return result; diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index fd5a6eec86..272723e050 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -1353,6 +1353,7 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap, char newrelpersistence) { ObjectAddress object; + ReindexOptions reindexopts = {false}; Oid mapped_tables[4]; int reindex_flags; int i; @@ -1412,7 +1413,7 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap, pgstat_progress_update_param(PROGRESS_CLUSTER_PHASE, PROGRESS_CLUSTER_PHASE_REBUILD_INDEX); - reindex_relation(OIDOldHeap, reindex_flags, 0); + reindex_relation(OIDOldHeap, reindex_flags, &reindexopts); /* Report that we are now doing clean up */ pgstat_progress_update_param(PROGRESS_CLUSTER_PHASE, diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 14d24b3cc4..80fa39112a 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -89,9 +89,9 @@ static List *ChooseIndexColumnNames(List *indexElems); static void RangeVarCallbackForReindexIndex(const RangeVar *relation, Oid relId, Oid oldRelId, void *arg); static void reindex_error_callback(void *args); -static void ReindexPartitions(Oid relid, int options, bool isTopLevel); -static void ReindexMultipleInternal(List *relids, int options); -static bool ReindexRelationConcurrently(Oid relationOid, int options); +static void ReindexPartitions(Oid relid, ReindexOptions *options, bool isTopLevel); +static void ReindexMultipleInternal(List *relids, ReindexOptions *options); +static bool ReindexRelationConcurrently(Oid relationOid, ReindexOptions *options); static void update_relispartition(Oid relationId, bool newval); static inline void set_indexsafe_procflags(void); @@ -100,7 +100,7 @@ static inline void set_indexsafe_procflags(void); */ struct ReindexIndexCallbackState { - int options; /* options from statement */ + ReindexOptions options; /* options from statement */ Oid locked_table_oid; /* tracks previously locked table */ }; @@ -2455,13 +2455,11 @@ ChooseIndexColumnNames(List *indexElems) * ReindexParseOptions * Parse list of REINDEX options, returning a bitmask of ReindexOption. */ -int +ReindexOptions ReindexParseOptions(ParseState *pstate, ReindexStmt *stmt) { ListCell *lc; - int options = 0; - bool concurrently = false; - bool verbose = false; + ReindexOptions options = {false}; /* Parse option list */ foreach(lc, stmt->params) @@ -2469,9 +2467,9 @@ ReindexParseOptions(ParseState *pstate, ReindexStmt *stmt) DefElem *opt = (DefElem *) lfirst(lc); if (strcmp(opt->defname, "verbose") == 0) - verbose = defGetBoolean(opt); + options.REINDEXOPT_VERBOSE = defGetBoolean(opt); else if (strcmp(opt->defname, "concurrently") == 0) - concurrently = defGetBoolean(opt); + options.REINDEXOPT_CONCURRENTLY = defGetBoolean(opt); else ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -2480,10 +2478,6 @@ ReindexParseOptions(ParseState *pstate, ReindexStmt *stmt) parser_errposition(pstate, opt->location))); } - options = - (verbose ? REINDEXOPT_VERBOSE : 0) | - (concurrently ? REINDEXOPT_CONCURRENTLY : 0); - return options; } @@ -2492,7 +2486,7 @@ ReindexParseOptions(ParseState *pstate, ReindexStmt *stmt) * Recreate a specific index. */ void -ReindexIndex(RangeVar *indexRelation, int options, bool isTopLevel) +ReindexIndex(RangeVar *indexRelation, ReindexOptions *options, bool isTopLevel) { struct ReindexIndexCallbackState state; Oid indOid; @@ -2509,10 +2503,10 @@ ReindexIndex(RangeVar *indexRelation, int options, bool isTopLevel) * upgrade the lock, but that's OK, because other sessions can't hold * locks on our temporary table. */ - state.options = options; + state.options = *options; state.locked_table_oid = InvalidOid; indOid = RangeVarGetRelidExtended(indexRelation, - (options & REINDEXOPT_CONCURRENTLY) != 0 ? + options->REINDEXOPT_CONCURRENTLY ? ShareUpdateExclusiveLock : AccessExclusiveLock, 0, RangeVarCallbackForReindexIndex, @@ -2527,12 +2521,15 @@ ReindexIndex(RangeVar *indexRelation, int options, bool isTopLevel) if (relkind == RELKIND_PARTITIONED_INDEX) ReindexPartitions(indOid, options, isTopLevel); - else if ((options & REINDEXOPT_CONCURRENTLY) != 0 && + else if (options->REINDEXOPT_CONCURRENTLY && persistence != RELPERSISTENCE_TEMP) ReindexRelationConcurrently(indOid, options); else - reindex_index(indOid, false, persistence, - options | REINDEXOPT_REPORT_PROGRESS); + { + ReindexOptions newoptions = *options; + newoptions.REINDEXOPT_REPORT_PROGRESS = true; + reindex_index(indOid, false, persistence, &newoptions); + } } /* @@ -2553,7 +2550,7 @@ RangeVarCallbackForReindexIndex(const RangeVar *relation, * non-concurrent case and table locks used by index_concurrently_*() for * concurrent case. */ - table_lockmode = ((state->options & REINDEXOPT_CONCURRENTLY) != 0) ? + table_lockmode = state->options.REINDEXOPT_CONCURRENTLY ? ShareUpdateExclusiveLock : ShareLock; /* @@ -2611,7 +2608,7 @@ RangeVarCallbackForReindexIndex(const RangeVar *relation, * Recreate all indexes of a table (and of its toast table, if any) */ Oid -ReindexTable(RangeVar *relation, int options, bool isTopLevel) +ReindexTable(RangeVar *relation, ReindexOptions *options, bool isTopLevel) { Oid heapOid; bool result; @@ -2625,14 +2622,14 @@ ReindexTable(RangeVar *relation, int options, bool isTopLevel) * locks on our temporary table. */ heapOid = RangeVarGetRelidExtended(relation, - (options & REINDEXOPT_CONCURRENTLY) != 0 ? + options->REINDEXOPT_CONCURRENTLY ? ShareUpdateExclusiveLock : ShareLock, 0, RangeVarCallbackOwnsTable, NULL); if (get_rel_relkind(heapOid) == RELKIND_PARTITIONED_TABLE) ReindexPartitions(heapOid, options, isTopLevel); - else if ((options & REINDEXOPT_CONCURRENTLY) != 0 && + else if (options->REINDEXOPT_CONCURRENTLY && get_rel_persistence(heapOid) != RELPERSISTENCE_TEMP) { result = ReindexRelationConcurrently(heapOid, options); @@ -2644,10 +2641,12 @@ ReindexTable(RangeVar *relation, int options, bool isTopLevel) } else { + ReindexOptions newoptions = *options; + newoptions.REINDEXOPT_REPORT_PROGRESS = true; result = reindex_relation(heapOid, REINDEX_REL_PROCESS_TOAST | REINDEX_REL_CHECK_CONSTRAINTS, - options | REINDEXOPT_REPORT_PROGRESS); + &newoptions); if (!result) ereport(NOTICE, (errmsg("table \"%s\" has no indexes to reindex", @@ -2667,7 +2666,7 @@ ReindexTable(RangeVar *relation, int options, bool isTopLevel) */ void ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind, - int options) + ReindexOptions *options) { Oid objectOid; Relation relationRelation; @@ -2686,7 +2685,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind, objectKind == REINDEX_OBJECT_DATABASE); if (objectKind == REINDEX_OBJECT_SYSTEM && - (options & REINDEXOPT_CONCURRENTLY) != 0) + options->REINDEXOPT_CONCURRENTLY) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot reindex system catalogs concurrently"))); @@ -2794,7 +2793,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind, * Skip system tables, since index_create() would reject indexing them * concurrently (and it would likely fail if we tried). */ - if ((options & REINDEXOPT_CONCURRENTLY) != 0 && + if (options->REINDEXOPT_CONCURRENTLY && IsCatalogRelationOid(relid)) { if (!concurrent_warning) @@ -2860,7 +2859,7 @@ reindex_error_callback(void *arg) * by the caller. */ static void -ReindexPartitions(Oid relid, int options, bool isTopLevel) +ReindexPartitions(Oid relid, ReindexOptions *options, bool isTopLevel) { List *partitions = NIL; char relkind = get_rel_relkind(relid); @@ -2955,7 +2954,7 @@ ReindexPartitions(Oid relid, int options, bool isTopLevel) * and starts a new transaction when finished. */ static void -ReindexMultipleInternal(List *relids, int options) +ReindexMultipleInternal(List *relids, ReindexOptions *options) { ListCell *l; @@ -2991,35 +2990,36 @@ ReindexMultipleInternal(List *relids, int options) Assert(relkind != RELKIND_PARTITIONED_INDEX && relkind != RELKIND_PARTITIONED_TABLE); - if ((options & REINDEXOPT_CONCURRENTLY) != 0 && + if (options->REINDEXOPT_CONCURRENTLY && relpersistence != RELPERSISTENCE_TEMP) { - (void) ReindexRelationConcurrently(relid, - options | - REINDEXOPT_MISSING_OK); + ReindexOptions newoptions = *options; + newoptions.REINDEXOPT_MISSING_OK = true; + (void) ReindexRelationConcurrently(relid, &newoptions); /* ReindexRelationConcurrently() does the verbose output */ } else if (relkind == RELKIND_INDEX) { - reindex_index(relid, false, relpersistence, - options | - REINDEXOPT_REPORT_PROGRESS | - REINDEXOPT_MISSING_OK); + ReindexOptions newoptions = *options; + newoptions.REINDEXOPT_REPORT_PROGRESS = true; + newoptions.REINDEXOPT_MISSING_OK = true; + reindex_index(relid, false, relpersistence, &newoptions); PopActiveSnapshot(); /* reindex_index() does the verbose output */ } else { bool result; + ReindexOptions newoptions = *options; + newoptions.REINDEXOPT_REPORT_PROGRESS = true; + newoptions.REINDEXOPT_MISSING_OK = true; result = reindex_relation(relid, REINDEX_REL_PROCESS_TOAST | REINDEX_REL_CHECK_CONSTRAINTS, - options | - REINDEXOPT_REPORT_PROGRESS | - REINDEXOPT_MISSING_OK); + &newoptions); - if (result && (options & REINDEXOPT_VERBOSE)) + if (result && options->REINDEXOPT_VERBOSE) ereport(INFO, (errmsg("table \"%s.%s\" was reindexed", get_namespace_name(get_rel_namespace(relid)), @@ -3059,7 +3059,7 @@ ReindexMultipleInternal(List *relids, int options) * anyway, and a non-concurrent reindex is more efficient. */ static bool -ReindexRelationConcurrently(Oid relationOid, int options) +ReindexRelationConcurrently(Oid relationOid, ReindexOptions *options) { List *heapRelationIds = NIL; List *indexIds = NIL; @@ -3092,7 +3092,7 @@ ReindexRelationConcurrently(Oid relationOid, int options) "ReindexConcurrent", ALLOCSET_SMALL_SIZES); - if (options & REINDEXOPT_VERBOSE) + if (options->REINDEXOPT_VERBOSE) { /* Save data needed by REINDEX VERBOSE in private context */ oldcontext = MemoryContextSwitchTo(private_context); @@ -3137,7 +3137,7 @@ ReindexRelationConcurrently(Oid relationOid, int options) errmsg("cannot reindex system catalogs concurrently"))); /* Open relation to get its indexes */ - if ((options & REINDEXOPT_MISSING_OK) != 0) + if (options->REINDEXOPT_MISSING_OK) { heapRelation = try_table_open(relationOid, ShareUpdateExclusiveLock); @@ -3233,7 +3233,7 @@ ReindexRelationConcurrently(Oid relationOid, int options) case RELKIND_INDEX: { Oid heapId = IndexGetRelation(relationOid, - (options & REINDEXOPT_MISSING_OK) != 0); + options->REINDEXOPT_MISSING_OK); Relation heapRelation; /* if relation is missing, leave */ @@ -3262,7 +3262,7 @@ ReindexRelationConcurrently(Oid relationOid, int options) * to rebuild is not complete yet, and REINDEXOPT_MISSING_OK * should not be used once all the session locks are taken. */ - if ((options & REINDEXOPT_MISSING_OK) != 0) + if (options->REINDEXOPT_MISSING_OK) { heapRelation = try_table_open(heapId, ShareUpdateExclusiveLock); @@ -3754,7 +3754,7 @@ ReindexRelationConcurrently(Oid relationOid, int options) StartTransactionCommand(); /* Log what we did */ - if (options & REINDEXOPT_VERBOSE) + if (options->REINDEXOPT_VERBOSE) { if (relkind == RELKIND_INDEX) ereport(INFO, diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 1fa9f19f08..e0f62d3c77 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -1854,6 +1854,7 @@ ExecuteTruncateGuts(List *explicit_rels, List *relids, List *relids_logged, { Oid heap_relid; Oid toast_relid; + ReindexOptions reindexopts = {false}; /* Default options are all false */ /* * This effectively deletes all rows in the table, and may be done @@ -1891,7 +1892,8 @@ ExecuteTruncateGuts(List *explicit_rels, List *relids, List *relids_logged, /* * Reconstruct the indexes to match, and we're done. */ - reindex_relation(heap_relid, REINDEX_REL_PROCESS_TOAST, 0); + reindex_relation(heap_relid, REINDEX_REL_PROCESS_TOAST, + &reindexopts); } pgstat_count_truncate(rel); diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index a42ead7d69..23612b7a90 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -919,20 +919,20 @@ standard_ProcessUtility(PlannedStmt *pstmt, case T_ReindexStmt: { ReindexStmt *stmt = (ReindexStmt *) parsetree; - int options; + ReindexOptions options; options = ReindexParseOptions(pstate, stmt); - if ((options & REINDEXOPT_CONCURRENTLY) != 0) + if (options.REINDEXOPT_CONCURRENTLY) PreventInTransactionBlock(isTopLevel, "REINDEX CONCURRENTLY"); switch (stmt->kind) { case REINDEX_OBJECT_INDEX: - ReindexIndex(stmt->relation, options, isTopLevel); + ReindexIndex(stmt->relation, &options, isTopLevel); break; case REINDEX_OBJECT_TABLE: - ReindexTable(stmt->relation, options, isTopLevel); + ReindexTable(stmt->relation, &options, isTopLevel); break; case REINDEX_OBJECT_SCHEMA: case REINDEX_OBJECT_SYSTEM: @@ -948,7 +948,7 @@ standard_ProcessUtility(PlannedStmt *pstmt, (stmt->kind == REINDEX_OBJECT_SCHEMA) ? "REINDEX SCHEMA" : (stmt->kind == REINDEX_OBJECT_SYSTEM) ? "REINDEX SYSTEM" : "REINDEX DATABASE"); - ReindexMultipleTables(stmt->name, stmt->kind, options); + ReindexMultipleTables(stmt->name, stmt->kind, &options); break; default: elog(ERROR, "unrecognized object type: %d", diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h index c041628049..3a8671f558 100644 --- a/src/include/catalog/index.h +++ b/src/include/catalog/index.h @@ -30,13 +30,13 @@ typedef enum } IndexStateFlagsAction; /* options for REINDEX */ -typedef enum ReindexOption +typedef struct ReindexOptions { - REINDEXOPT_VERBOSE = 1 << 0, /* print progress info */ - REINDEXOPT_REPORT_PROGRESS = 1 << 1, /* report pgstat progress */ - REINDEXOPT_MISSING_OK = 1 << 2, /* skip missing relations */ - REINDEXOPT_CONCURRENTLY = 1 << 3 /* concurrent mode */ -} ReindexOption; + bool REINDEXOPT_VERBOSE; /* print progress info */ + bool REINDEXOPT_REPORT_PROGRESS; /* report pgstat progress */ + bool REINDEXOPT_MISSING_OK; /* skip missing relations */ + bool REINDEXOPT_CONCURRENTLY; /* concurrent mode */ +} ReindexOptions; /* state info for validate_index bulkdelete callback */ typedef struct ValidateIndexState @@ -146,7 +146,7 @@ extern void index_set_state_flags(Oid indexId, IndexStateFlagsAction action); extern Oid IndexGetRelation(Oid indexId, bool missing_ok); extern void reindex_index(Oid indexId, bool skip_constraint_checks, - char relpersistence, int options); + char relpersistence, ReindexOptions *options); /* Flag bits for reindex_relation(): */ #define REINDEX_REL_PROCESS_TOAST 0x01 @@ -155,7 +155,7 @@ extern void reindex_index(Oid indexId, bool skip_constraint_checks, #define REINDEX_REL_FORCE_INDEXES_UNLOGGED 0x08 #define REINDEX_REL_FORCE_INDEXES_PERMANENT 0x10 -extern bool reindex_relation(Oid relid, int flags, int options); +extern bool reindex_relation(Oid relid, int flags, ReindexOptions *options); extern bool ReindexIsProcessingHeap(Oid heapOid); extern bool ReindexIsProcessingIndex(Oid indexOid); diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h index 1133ae1143..33df5d5780 100644 --- a/src/include/commands/defrem.h +++ b/src/include/commands/defrem.h @@ -14,6 +14,7 @@ #ifndef DEFREM_H #define DEFREM_H +#include "catalog/index.h" #include "catalog/objectaddress.h" #include "nodes/params.h" #include "parser/parse_node.h" @@ -34,11 +35,11 @@ extern ObjectAddress DefineIndex(Oid relationId, bool check_not_in_use, bool skip_build, bool quiet); -extern int ReindexParseOptions(ParseState *pstate, ReindexStmt *stmt); -extern void ReindexIndex(RangeVar *indexRelation, int options, bool isTopLevel); -extern Oid ReindexTable(RangeVar *relation, int options, bool isTopLevel); +extern ReindexOptions ReindexParseOptions(ParseState *pstate, ReindexStmt *stmt); +extern void ReindexIndex(RangeVar *indexRelation, ReindexOptions *options, bool isTopLevel); +extern Oid ReindexTable(RangeVar *relation, ReindexOptions *options, bool isTopLevel); extern void ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind, - int options); + ReindexOptions *options); extern char *makeObjectName(const char *name1, const char *name2, const char *label); extern char *ChooseRelationName(const char *name1, const char *name2, -- 2.17.0
>From a67881969747cbbe95cbd50bd3daad831b8b417a Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Mon, 14 Dec 2020 00:26:44 -0600 Subject: [PATCH 2/4] Also do ClusterOpt and VacuumOpt --- src/backend/access/heap/vacuumlazy.c | 8 +- src/backend/commands/analyze.c | 15 ++-- src/backend/commands/cluster.c | 26 +++--- src/backend/commands/vacuum.c | 128 +++++++++++++-------------- src/backend/postmaster/autovacuum.c | 14 +-- src/include/commands/cluster.h | 8 +- src/include/commands/vacuum.h | 25 +++--- 7 files changed, 110 insertions(+), 114 deletions(-) diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index 25f2d5df1b..3c8b22fd63 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -456,7 +456,7 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params, starttime = GetCurrentTimestamp(); } - if (params->options & VACOPT_VERBOSE) + if (params->options.VACOPT_VERBOSE) elevel = INFO; else elevel = DEBUG2; @@ -484,7 +484,7 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params, xidFullScanLimit); aggressive |= MultiXactIdPrecedesOrEquals(onerel->rd_rel->relminmxid, mxactFullScanLimit); - if (params->options & VACOPT_DISABLE_PAGE_SKIPPING) + if (params->options.VACOPT_DISABLE_PAGE_SKIPPING) aggressive = true; vacrelstats = (LVRelStats *) palloc0(sizeof(LVRelStats)); @@ -902,7 +902,7 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, * be replayed on any hot standby, where it can be disruptive. */ next_unskippable_block = 0; - if ((params->options & VACOPT_DISABLE_PAGE_SKIPPING) == 0) + if (!params->options.VACOPT_DISABLE_PAGE_SKIPPING) { while (next_unskippable_block < nblocks) { @@ -960,7 +960,7 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, { /* Time to advance next_unskippable_block */ next_unskippable_block++; - if ((params->options & VACOPT_DISABLE_PAGE_SKIPPING) == 0) + if (!params->options.VACOPT_DISABLE_PAGE_SKIPPING) { while (next_unskippable_block < nblocks) { diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 8af12b5c6b..2e266391fb 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -124,9 +124,10 @@ analyze_rel(Oid relid, RangeVar *relation, int elevel; AcquireSampleRowsFunc acquirefunc = NULL; BlockNumber relpages = 0; + VacuumOption newoptions; /* Select logging level */ - if (params->options & VACOPT_VERBOSE) + if (params->options.VACOPT_VERBOSE) elevel = INFO; else elevel = DEBUG2; @@ -148,7 +149,9 @@ analyze_rel(Oid relid, RangeVar *relation, * * Make sure to generate only logs for ANALYZE in this case. */ - onerel = vacuum_open_relation(relid, relation, params->options & ~(VACOPT_VACUUM), + newoptions = params->options; + newoptions.VACOPT_VACUUM = false; + onerel = vacuum_open_relation(relid, relation, &newoptions, params->log_min_duration >= 0, ShareUpdateExclusiveLock); @@ -166,7 +169,7 @@ analyze_rel(Oid relid, RangeVar *relation, */ if (!vacuum_is_relation_owner(RelationGetRelid(onerel), onerel->rd_rel, - params->options & VACOPT_ANALYZE)) + &newoptions)) { relation_close(onerel, ShareUpdateExclusiveLock); return; @@ -238,7 +241,7 @@ analyze_rel(Oid relid, RangeVar *relation, else { /* No need for a WARNING if we already complained during VACUUM */ - if (!(params->options & VACOPT_VACUUM)) + if (!params->options.VACOPT_VACUUM) ereport(WARNING, (errmsg("skipping \"%s\" --- cannot analyze non-tables or special system tables", RelationGetRelationName(onerel)))); @@ -624,7 +627,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params, * VACUUM ANALYZE, don't overwrite the accurate count already inserted by * VACUUM. */ - if (!inh && !(params->options & VACOPT_VACUUM)) + if (!inh && !params->options.VACOPT_VACUUM) { for (ind = 0; ind < nindexes; ind++) { @@ -655,7 +658,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params, (va_cols == NIL)); /* If this isn't part of VACUUM ANALYZE, let index AMs do cleanup */ - if (!(params->options & VACOPT_VACUUM)) + if (!params->options.VACOPT_VACUUM) { for (ind = 0; ind < nindexes; ind++) { diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 272723e050..591878207d 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -103,8 +103,7 @@ void cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel) { ListCell *lc; - int options = 0; - bool verbose = false; + ClusterOption options = {false}; /* Parse option list */ foreach(lc, stmt->params) @@ -112,7 +111,7 @@ cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel) DefElem *opt = (DefElem *) lfirst(lc); if (strcmp(opt->defname, "verbose") == 0) - verbose = defGetBoolean(opt); + options.CLUOPT_VERBOSE = defGetBoolean(opt); else ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -121,8 +120,6 @@ cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel) parser_errposition(pstate, opt->location))); } - options = (verbose ? CLUOPT_VERBOSE : 0); - if (stmt->relation != NULL) { /* This is the single-relation case. */ @@ -192,7 +189,7 @@ cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel) table_close(rel, NoLock); /* Do the job. */ - cluster_rel(tableOid, indexOid, options); + cluster_rel(tableOid, indexOid, &options); } else { @@ -234,14 +231,15 @@ cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel) foreach(rv, rvs) { RelToCluster *rvtc = (RelToCluster *) lfirst(rv); + ClusterOption newoptions = options; + newoptions.CLUOPT_RECHECK = true; /* Start a new transaction for each relation. */ StartTransactionCommand(); /* functions in indexes may want a snapshot set */ PushActiveSnapshot(GetTransactionSnapshot()); /* Do the job. */ - cluster_rel(rvtc->tableOid, rvtc->indexOid, - options | CLUOPT_RECHECK); + cluster_rel(rvtc->tableOid, rvtc->indexOid, &newoptions); PopActiveSnapshot(); CommitTransactionCommand(); } @@ -272,11 +270,9 @@ cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel) * and error messages should refer to the operation as VACUUM not CLUSTER. */ void -cluster_rel(Oid tableOid, Oid indexOid, int options) +cluster_rel(Oid tableOid, Oid indexOid, ClusterOption *options) { Relation OldHeap; - bool verbose = ((options & CLUOPT_VERBOSE) != 0); - bool recheck = ((options & CLUOPT_RECHECK) != 0); /* Check for user-requested abort. */ CHECK_FOR_INTERRUPTS(); @@ -312,7 +308,7 @@ cluster_rel(Oid tableOid, Oid indexOid, int options) * *must* skip the one on indisclustered since it would reject an attempt * to cluster a not-previously-clustered index. */ - if (recheck) + if (options->CLUOPT_RECHECK) { /* Check that the user still owns the relation */ if (!pg_class_ownercheck(tableOid, GetUserId())) @@ -396,7 +392,9 @@ cluster_rel(Oid tableOid, Oid indexOid, int options) /* Check heap and index are valid to cluster on */ if (OidIsValid(indexOid)) - check_index_is_clusterable(OldHeap, indexOid, recheck, AccessExclusiveLock); + check_index_is_clusterable(OldHeap, indexOid, options->CLUOPT_RECHECK, + AccessExclusiveLock); + /* * Quietly ignore the request if this is a materialized view which has not @@ -422,7 +420,7 @@ cluster_rel(Oid tableOid, Oid indexOid, int options) TransferPredicateLocksToHeapRelation(OldHeap); /* rebuild_relation does all the dirty work */ - rebuild_relation(OldHeap, indexOid, verbose); + rebuild_relation(OldHeap, indexOid, options->CLUOPT_VERBOSE); /* NB: rebuild_relation does table_close() on OldHeap */ diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 98270a1049..3774a18ff8 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -78,8 +78,8 @@ pg_atomic_uint32 *VacuumActiveNWorkers = NULL; int VacuumCostBalanceLocal = 0; /* non-export function prototypes */ -static List *expand_vacuum_rel(VacuumRelation *vrel, int options); -static List *get_all_vacuum_rels(int options); +static List *expand_vacuum_rel(VacuumRelation *vrel, VacuumOption *options); +static List *get_all_vacuum_rels(VacuumOption *options); static void vac_truncate_clog(TransactionId frozenXID, MultiXactId minMulti, TransactionId lastSaneFrozenXid, @@ -97,13 +97,7 @@ static VacOptTernaryValue get_vacopt_ternary_value(DefElem *def); void ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel) { - VacuumParams params; - bool verbose = false; - bool skip_locked = false; - bool analyze = false; - bool freeze = false; - bool full = false; - bool disable_page_skipping = false; + VacuumParams params = {.options={false} }; ListCell *lc; /* Set default value */ @@ -120,9 +114,9 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel) /* Parse common options for VACUUM and ANALYZE */ if (strcmp(opt->defname, "verbose") == 0) - verbose = defGetBoolean(opt); + params.options.VACOPT_VERBOSE = defGetBoolean(opt); else if (strcmp(opt->defname, "skip_locked") == 0) - skip_locked = defGetBoolean(opt); + params.options.VACOPT_SKIP_LOCKED = defGetBoolean(opt); else if (!vacstmt->is_vacuumcmd) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -131,16 +125,18 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel) /* Parse options available on VACUUM */ else if (strcmp(opt->defname, "analyze") == 0) - analyze = defGetBoolean(opt); + params.options.VACOPT_ANALYZE = defGetBoolean(opt); else if (strcmp(opt->defname, "freeze") == 0) - freeze = defGetBoolean(opt); + params.options.VACOPT_FREEZE = defGetBoolean(opt); else if (strcmp(opt->defname, "full") == 0) - full = defGetBoolean(opt); + params.options.VACOPT_FULL = defGetBoolean(opt); else if (strcmp(opt->defname, "disable_page_skipping") == 0) - disable_page_skipping = defGetBoolean(opt); + params.options.VACOPT_DISABLE_PAGE_SKIPPING = defGetBoolean(opt); else if (strcmp(opt->defname, "index_cleanup") == 0) +// XXX params.index_cleanup = get_vacopt_ternary_value(opt); else if (strcmp(opt->defname, "truncate") == 0) +// XXX params.truncate = get_vacopt_ternary_value(opt); else if (strcmp(opt->defname, "parallel") == 0) { @@ -181,23 +177,18 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel) parser_errposition(pstate, opt->location))); } - /* Set vacuum options */ - params.options = - (vacstmt->is_vacuumcmd ? VACOPT_VACUUM : VACOPT_ANALYZE) | - (verbose ? VACOPT_VERBOSE : 0) | - (skip_locked ? VACOPT_SKIP_LOCKED : 0) | - (analyze ? VACOPT_ANALYZE : 0) | - (freeze ? VACOPT_FREEZE : 0) | - (full ? VACOPT_FULL : 0) | - (disable_page_skipping ? VACOPT_DISABLE_PAGE_SKIPPING : 0); + if (vacstmt->is_vacuumcmd) + params.options.VACOPT_VACUUM = true; + else + params.options.VACOPT_ANALYZE = true; /* sanity checks on options */ - Assert(params.options & (VACOPT_VACUUM | VACOPT_ANALYZE)); - Assert((params.options & VACOPT_VACUUM) || - !(params.options & (VACOPT_FULL | VACOPT_FREEZE))); - Assert(!(params.options & VACOPT_SKIPTOAST)); + Assert(params.options.VACOPT_VACUUM || params.options.VACOPT_ANALYZE); + Assert(params.options.VACOPT_VACUUM || + !(params.options.VACOPT_FULL || params.options.VACOPT_FREEZE)); + Assert(!params.options.VACOPT_SKIPTOAST); - if ((params.options & VACOPT_FULL) && params.nworkers > 0) + if (params.options.VACOPT_FULL && params.nworkers > 0) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("VACUUM FULL cannot be performed in parallel"))); @@ -205,7 +196,7 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel) /* * Make sure VACOPT_ANALYZE is specified if any column lists are present. */ - if (!(params.options & VACOPT_ANALYZE)) + if (!params.options.VACOPT_ANALYZE) { ListCell *lc; @@ -224,7 +215,7 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel) * All freeze ages are zero if the FREEZE option is given; otherwise pass * them as -1 which means to use the default values. */ - if (params.options & VACOPT_FREEZE) + if (params.options.VACOPT_FREEZE) { params.freeze_min_age = 0; params.freeze_table_age = 0; @@ -280,7 +271,7 @@ vacuum(List *relations, VacuumParams *params, Assert(params != NULL); - stmttype = (params->options & VACOPT_VACUUM) ? "VACUUM" : "ANALYZE"; + stmttype = params->options.VACOPT_VACUUM ? "VACUUM" : "ANALYZE"; /* * We cannot run VACUUM inside a user transaction block; if we were inside @@ -290,7 +281,7 @@ vacuum(List *relations, VacuumParams *params, * * ANALYZE (without VACUUM) can run either way. */ - if (params->options & VACOPT_VACUUM) + if (params->options.VACOPT_VACUUM) { PreventInTransactionBlock(isTopLevel, stmttype); in_outer_xact = false; @@ -312,8 +303,8 @@ vacuum(List *relations, VacuumParams *params, /* * Sanity check DISABLE_PAGE_SKIPPING option. */ - if ((params->options & VACOPT_FULL) != 0 && - (params->options & VACOPT_DISABLE_PAGE_SKIPPING) != 0) + if (params->options.VACOPT_FULL && + params->options.VACOPT_DISABLE_PAGE_SKIPPING) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("VACUUM option DISABLE_PAGE_SKIPPING cannot be used with FULL"))); @@ -322,7 +313,7 @@ vacuum(List *relations, VacuumParams *params, * Send info about dead objects to the statistics collector, unless we are * in autovacuum --- autovacuum.c does this for itself. */ - if ((params->options & VACOPT_VACUUM) && !IsAutoVacuumWorkerProcess()) + if (params->options.VACOPT_VACUUM && !IsAutoVacuumWorkerProcess()) pgstat_vacuum_stat(); /* @@ -363,7 +354,7 @@ vacuum(List *relations, VacuumParams *params, List *sublist; MemoryContext old_context; - sublist = expand_vacuum_rel(vrel, params->options); + sublist = expand_vacuum_rel(vrel, ¶ms->options); old_context = MemoryContextSwitchTo(vac_context); newrels = list_concat(newrels, sublist); MemoryContextSwitchTo(old_context); @@ -371,7 +362,7 @@ vacuum(List *relations, VacuumParams *params, relations = newrels; } else - relations = get_all_vacuum_rels(params->options); + relations = get_all_vacuum_rels(¶ms->options); /* * Decide whether we need to start/commit our own transactions. @@ -387,11 +378,11 @@ vacuum(List *relations, VacuumParams *params, * transaction block, and also in an autovacuum worker, use own * transactions so we can release locks sooner. */ - if (params->options & VACOPT_VACUUM) + if (params->options.VACOPT_VACUUM) use_own_xacts = true; else { - Assert(params->options & VACOPT_ANALYZE); + Assert(params->options.VACOPT_ANALYZE); if (IsAutoVacuumWorkerProcess()) use_own_xacts = true; else if (in_outer_xact) @@ -444,13 +435,13 @@ vacuum(List *relations, VacuumParams *params, { VacuumRelation *vrel = lfirst_node(VacuumRelation, cur); - if (params->options & VACOPT_VACUUM) + if (params->options.VACOPT_VACUUM) { if (!vacuum_rel(vrel->oid, vrel->relation, params)) continue; } - if (params->options & VACOPT_ANALYZE) + if (params->options.VACOPT_ANALYZE) { /* * If using separate xacts, start one for analyze. Otherwise, @@ -504,7 +495,7 @@ vacuum(List *relations, VacuumParams *params, StartTransactionCommand(); } - if ((params->options & VACOPT_VACUUM) && !IsAutoVacuumWorkerProcess()) + if (params->options.VACOPT_VACUUM && !IsAutoVacuumWorkerProcess()) { /* * Update pg_database.datfrozenxid, and truncate pg_xact if possible. @@ -530,11 +521,11 @@ vacuum(List *relations, VacuumParams *params, * ANALYZE. */ bool -vacuum_is_relation_owner(Oid relid, Form_pg_class reltuple, int options) +vacuum_is_relation_owner(Oid relid, Form_pg_class reltuple, VacuumOption *options) { char *relname; - Assert((options & (VACOPT_VACUUM | VACOPT_ANALYZE)) != 0); + Assert(options->VACOPT_VACUUM || options->VACOPT_ANALYZE); /* * Check permissions. @@ -553,7 +544,7 @@ vacuum_is_relation_owner(Oid relid, Form_pg_class reltuple, int options) relname = NameStr(reltuple->relname); - if ((options & VACOPT_VACUUM) != 0) + if (options->VACOPT_VACUUM) { if (reltuple->relisshared) ereport(WARNING, @@ -576,7 +567,7 @@ vacuum_is_relation_owner(Oid relid, Form_pg_class reltuple, int options) return false; } - if ((options & VACOPT_ANALYZE) != 0) + if (options->VACOPT_ANALYZE) { if (reltuple->relisshared) ereport(WARNING, @@ -604,14 +595,14 @@ vacuum_is_relation_owner(Oid relid, Form_pg_class reltuple, int options) * or locked, a log is emitted if possible. */ Relation -vacuum_open_relation(Oid relid, RangeVar *relation, int options, +vacuum_open_relation(Oid relid, RangeVar *relation, VacuumOption *options, bool verbose, LOCKMODE lmode) { Relation onerel; bool rel_lock = true; int elevel; - Assert((options & (VACOPT_VACUUM | VACOPT_ANALYZE)) != 0); + Assert(options->VACOPT_VACUUM || options->VACOPT_ANALYZE); /* * Open the relation and get the appropriate lock on it. @@ -622,7 +613,7 @@ vacuum_open_relation(Oid relid, RangeVar *relation, int options, * If we've been asked not to wait for the relation lock, acquire it first * in non-blocking mode, before calling try_relation_open(). */ - if (!(options & VACOPT_SKIP_LOCKED)) + if (!options->VACOPT_SKIP_LOCKED) onerel = try_relation_open(relid, lmode); else if (ConditionalLockRelationOid(relid, lmode)) onerel = try_relation_open(relid, NoLock); @@ -662,7 +653,7 @@ vacuum_open_relation(Oid relid, RangeVar *relation, int options, else return NULL; - if ((options & VACOPT_VACUUM) != 0) + if (options->VACOPT_VACUUM) { if (!rel_lock) ereport(elevel, @@ -683,7 +674,7 @@ vacuum_open_relation(Oid relid, RangeVar *relation, int options, return NULL; } - if ((options & VACOPT_ANALYZE) != 0) + if (options->VACOPT_ANALYZE) { if (!rel_lock) ereport(elevel, @@ -716,7 +707,7 @@ vacuum_open_relation(Oid relid, RangeVar *relation, int options, * are made in vac_context. */ static List * -expand_vacuum_rel(VacuumRelation *vrel, int options) +expand_vacuum_rel(VacuumRelation *vrel, VacuumOption *options) { List *vacrels = NIL; MemoryContext oldcontext; @@ -748,7 +739,7 @@ expand_vacuum_rel(VacuumRelation *vrel, int options) * below, as well as find_all_inheritors's expectation that the caller * holds some lock on the starting relation. */ - rvr_opts = (options & VACOPT_SKIP_LOCKED) ? RVR_SKIP_LOCKED : 0; + rvr_opts = (options->VACOPT_SKIP_LOCKED) ? RVR_SKIP_LOCKED : 0; relid = RangeVarGetRelidExtended(vrel->relation, AccessShareLock, rvr_opts, @@ -760,7 +751,7 @@ expand_vacuum_rel(VacuumRelation *vrel, int options) */ if (!OidIsValid(relid)) { - if (options & VACOPT_VACUUM) + if (options->VACOPT_VACUUM) ereport(WARNING, (errcode(ERRCODE_LOCK_NOT_AVAILABLE), errmsg("skipping vacuum of \"%s\" --- lock not available", @@ -855,7 +846,7 @@ expand_vacuum_rel(VacuumRelation *vrel, int options) * the current database. The list is built in vac_context. */ static List * -get_all_vacuum_rels(int options) +get_all_vacuum_rels(VacuumOption *options) { List *vacrels = NIL; Relation pgclass; @@ -1722,13 +1713,14 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params) Oid save_userid; int save_sec_context; int save_nestlevel; + VacuumOption newoptions; Assert(params != NULL); /* Begin a transaction for vacuuming this relation */ StartTransactionCommand(); - if (!(params->options & VACOPT_FULL)) + if (!params->options.VACOPT_FULL) { /* * In lazy vacuum, we can set the PROC_IN_VACUUM flag, which lets @@ -1778,11 +1770,11 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params) * vacuum, but just ShareUpdateExclusiveLock for concurrent vacuum. Either * way, we can be sure that no other backend is vacuuming the same table. */ - lmode = (params->options & VACOPT_FULL) ? + lmode = (params->options.VACOPT_FULL) ? AccessExclusiveLock : ShareUpdateExclusiveLock; /* open the relation and get the appropriate lock on it */ - onerel = vacuum_open_relation(relid, relation, params->options, + onerel = vacuum_open_relation(relid, relation, ¶ms->options, params->log_min_duration >= 0, lmode); /* leave if relation could not be opened or locked */ @@ -1801,9 +1793,11 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params) * changed in-between. Make sure to only generate logs for VACUUM in this * case. */ + newoptions = params->options; + newoptions.VACOPT_ANALYZE = false; if (!vacuum_is_relation_owner(RelationGetRelid(onerel), onerel->rd_rel, - params->options & VACOPT_VACUUM)) + &newoptions)) { relation_close(onerel, lmode); PopActiveSnapshot(); @@ -1895,7 +1889,7 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params) * us to process it. In VACUUM FULL, though, the toast table is * automatically rebuilt by cluster_rel so we shouldn't recurse to it. */ - if (!(params->options & VACOPT_SKIPTOAST) && !(params->options & VACOPT_FULL)) + if (!params->options.VACOPT_SKIPTOAST && !params->options.VACOPT_FULL) toast_relid = onerel->rd_rel->reltoastrelid; else toast_relid = InvalidOid; @@ -1914,19 +1908,19 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params) /* * Do the actual work --- either FULL or "lazy" vacuum */ - if (params->options & VACOPT_FULL) + if (params->options.VACOPT_FULL) { - int cluster_options = 0; + ClusterOption cluster_options = { + .CLUOPT_VERBOSE = params->options.VACOPT_VERBOSE, + /* Other members initialized to false/0/NULL */ + }; /* close relation before vacuuming, but hold lock until commit */ relation_close(onerel, NoLock); onerel = NULL; - if ((params->options & VACOPT_VERBOSE) != 0) - cluster_options |= CLUOPT_VERBOSE; - /* VACUUM FULL is now a variant of CLUSTER; see cluster.c */ - cluster_rel(relid, InvalidOid, cluster_options); + cluster_rel(relid, InvalidOid, &cluster_options); } else table_relation_vacuum(onerel, params, vac_strategy); diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 7e28944d2f..a1599ccb77 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -2505,7 +2505,7 @@ do_autovacuum(void) * next table in our list. */ HOLD_INTERRUPTS(); - if (tab->at_params.options & VACOPT_VACUUM) + if (tab->at_params.options.VACOPT_VACUUM) errcontext("automatic vacuum of table \"%s.%s.%s\"", tab->at_datname, tab->at_nspname, tab->at_relname); else @@ -2919,10 +2919,10 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map, tab = palloc(sizeof(autovac_table)); tab->at_relid = relid; tab->at_sharedrel = classForm->relisshared; - tab->at_params.options = VACOPT_SKIPTOAST | - (dovacuum ? VACOPT_VACUUM : 0) | - (doanalyze ? VACOPT_ANALYZE : 0) | - (!wraparound ? VACOPT_SKIP_LOCKED : 0); + tab->at_params.options.VACOPT_SKIPTOAST = true; + tab->at_params.options.VACOPT_VACUUM = dovacuum; + tab->at_params.options.VACOPT_ANALYZE = doanalyze; + tab->at_params.options.VACOPT_SKIP_LOCKED = !wraparound; tab->at_params.index_cleanup = VACOPT_TERNARY_DEFAULT; tab->at_params.truncate = VACOPT_TERNARY_DEFAULT; /* As of now, we don't support parallel vacuum for autovacuum */ @@ -3250,10 +3250,10 @@ autovac_report_activity(autovac_table *tab) int len; /* Report the command and possible options */ - if (tab->at_params.options & VACOPT_VACUUM) + if (tab->at_params.options.VACOPT_VACUUM) snprintf(activity, MAX_AUTOVAC_ACTIV_LEN, "autovacuum: VACUUM%s", - tab->at_params.options & VACOPT_ANALYZE ? " ANALYZE" : ""); + tab->at_params.options.VACOPT_ANALYZE ? " ANALYZE" : ""); else snprintf(activity, MAX_AUTOVAC_ACTIV_LEN, "autovacuum: ANALYZE"); diff --git a/src/include/commands/cluster.h b/src/include/commands/cluster.h index 7cfb37c9b2..5111941a41 100644 --- a/src/include/commands/cluster.h +++ b/src/include/commands/cluster.h @@ -20,14 +20,14 @@ /* options for CLUSTER */ -typedef enum ClusterOption +typedef struct ClusterOption { - CLUOPT_RECHECK = 1 << 0, /* recheck relation state */ - CLUOPT_VERBOSE = 1 << 1 /* print progress info */ + bool CLUOPT_RECHECK; /* recheck relation state */ + bool CLUOPT_VERBOSE; /* print progress info */ } ClusterOption; extern void cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel); -extern void cluster_rel(Oid tableOid, Oid indexOid, int options); +extern void cluster_rel(Oid tableOid, Oid indexOid, ClusterOption *options); extern void check_index_is_clusterable(Relation OldHeap, Oid indexOid, bool recheck, LOCKMODE lockmode); extern void mark_index_clustered(Relation rel, Oid indexOid, bool is_internal); diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h index a4cd721400..15327643ba 100644 --- a/src/include/commands/vacuum.h +++ b/src/include/commands/vacuum.h @@ -174,16 +174,16 @@ typedef struct VacAttrStats int rowstride; } VacAttrStats; -typedef enum VacuumOption +typedef struct VacuumOption { - VACOPT_VACUUM = 1 << 0, /* do VACUUM */ - VACOPT_ANALYZE = 1 << 1, /* do ANALYZE */ - VACOPT_VERBOSE = 1 << 2, /* print progress info */ - VACOPT_FREEZE = 1 << 3, /* FREEZE option */ - VACOPT_FULL = 1 << 4, /* FULL (non-concurrent) vacuum */ - VACOPT_SKIP_LOCKED = 1 << 5, /* skip if cannot get lock */ - VACOPT_SKIPTOAST = 1 << 6, /* don't process the TOAST table, if any */ - VACOPT_DISABLE_PAGE_SKIPPING = 1 << 7 /* don't skip any pages */ + bool VACOPT_VACUUM; /* do VACUUM */ + bool VACOPT_ANALYZE; /* do ANALYZE */ + bool VACOPT_VERBOSE; /* print progress info */ + bool VACOPT_FREEZE; /* FREEZE option */ + bool VACOPT_FULL; /* FULL (non-concurrent) vacuum */ + bool VACOPT_SKIP_LOCKED; /* skip if cannot get lock */ + bool VACOPT_SKIPTOAST; /* don't process the TOAST table, if any */ + bool VACOPT_DISABLE_PAGE_SKIPPING; /* don't skip any pages */ } VacuumOption; /* @@ -207,7 +207,7 @@ typedef enum VacOptTernaryValue */ typedef struct VacuumParams { - int options; /* bitmask of VacuumOption */ + VacuumOption options; /* bitmask of VacuumOption */ int freeze_min_age; /* min freeze age, -1 to use default */ int freeze_table_age; /* age at which to scan whole table */ int multixact_freeze_min_age; /* min multixact freeze age, -1 to @@ -275,9 +275,10 @@ extern void vacuum_set_xid_limits(Relation rel, extern void vac_update_datfrozenxid(void); extern void vacuum_delay_point(void); extern bool vacuum_is_relation_owner(Oid relid, Form_pg_class reltuple, - int options); + VacuumOption *options); extern Relation vacuum_open_relation(Oid relid, RangeVar *relation, - int options, bool verbose, LOCKMODE lmode); + VacuumOption *options, bool verbose, + LOCKMODE lmode); /* in commands/analyze.c */ extern void analyze_rel(Oid relid, RangeVar *relation, -- 2.17.0
>From 2b2b2846b99fc176900ec44e01f3bcc97b6a3cf8 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Mon, 14 Dec 2020 16:37:16 -0600 Subject: [PATCH 3/4] structure member variables: remove prefixes and lowercase --- src/backend/access/heap/vacuumlazy.c | 8 +-- src/backend/catalog/index.c | 18 +++--- src/backend/commands/analyze.c | 10 ++-- src/backend/commands/cluster.c | 10 ++-- src/backend/commands/indexcmds.c | 50 ++++++++--------- src/backend/commands/vacuum.c | 82 ++++++++++++++-------------- src/backend/postmaster/autovacuum.c | 14 ++--- src/backend/tcop/utility.c | 2 +- src/include/catalog/index.h | 8 +-- src/include/commands/cluster.h | 4 +- src/include/commands/vacuum.h | 16 +++--- 11 files changed, 111 insertions(+), 111 deletions(-) diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index 3c8b22fd63..6bfed2b2da 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -456,7 +456,7 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params, starttime = GetCurrentTimestamp(); } - if (params->options.VACOPT_VERBOSE) + if (params->options.verbose) elevel = INFO; else elevel = DEBUG2; @@ -484,7 +484,7 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params, xidFullScanLimit); aggressive |= MultiXactIdPrecedesOrEquals(onerel->rd_rel->relminmxid, mxactFullScanLimit); - if (params->options.VACOPT_DISABLE_PAGE_SKIPPING) + if (params->options.disable_page_skipping) aggressive = true; vacrelstats = (LVRelStats *) palloc0(sizeof(LVRelStats)); @@ -902,7 +902,7 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, * be replayed on any hot standby, where it can be disruptive. */ next_unskippable_block = 0; - if (!params->options.VACOPT_DISABLE_PAGE_SKIPPING) + if (!params->options.disable_page_skipping) { while (next_unskippable_block < nblocks) { @@ -960,7 +960,7 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, { /* Time to advance next_unskippable_block */ next_unskippable_block++; - if (!params->options.VACOPT_DISABLE_PAGE_SKIPPING) + if (!params->options.disable_page_skipping) { while (next_unskippable_block < nblocks) { diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index da2f45b796..ecd66ff3df 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -3610,12 +3610,12 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence, * we only need to be sure no schema or data changes are going on. */ heapId = IndexGetRelation(indexId, - options->REINDEXOPT_MISSING_OK); + options->missing_ok); /* if relation is missing, leave */ if (!OidIsValid(heapId)) return; - if (options->REINDEXOPT_MISSING_OK) + if (options->missing_ok) heapRelation = try_table_open(heapId, ShareLock); else heapRelation = table_open(heapId, ShareLock); @@ -3624,7 +3624,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence, if (!heapRelation) return; - if (options->REINDEXOPT_REPORT_PROGRESS) + if (options->report_progress) { pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX, heapId); @@ -3640,7 +3640,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence, */ iRel = index_open(indexId, AccessExclusiveLock); - if (options->REINDEXOPT_REPORT_PROGRESS) + if (options->report_progress) pgstat_progress_update_param(PROGRESS_CREATEIDX_ACCESS_METHOD_OID, iRel->rd_rel->relam); @@ -3791,14 +3791,14 @@ reindex_index(Oid indexId, bool skip_constraint_checks, char persistence, } /* Log what we did */ - if (options->REINDEXOPT_VERBOSE) + if (options->verbose) ereport(INFO, (errmsg("index \"%s\" was reindexed", get_rel_name(indexId)), errdetail_internal("%s", pg_rusage_show(&ru0)))); - if (options->REINDEXOPT_REPORT_PROGRESS) + if (options->report_progress) pgstat_progress_end_command(); /* Close rels, but keep locks */ @@ -3860,7 +3860,7 @@ reindex_relation(Oid relid, int flags, ReindexOptions *options) * to prevent schema and data changes in it. The lock level used here * should match ReindexTable(). */ - if (options->REINDEXOPT_MISSING_OK) + if (options->missing_ok) rel = try_table_open(relid, ShareLock); else rel = table_open(relid, ShareLock); @@ -3962,10 +3962,10 @@ reindex_relation(Oid relid, int flags, ReindexOptions *options) { /* * Note that this should fail if the toast relation is missing, so - * reset REINDEXOPT_MISSING_OK. + * reset missing_ok. */ ReindexOptions newoptions = *options; - newoptions.REINDEXOPT_MISSING_OK = false; + newoptions.missing_ok = false; result |= reindex_relation(toast_relid, flags, &newoptions); } diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 2e266391fb..01c034407c 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -127,7 +127,7 @@ analyze_rel(Oid relid, RangeVar *relation, VacuumOption newoptions; /* Select logging level */ - if (params->options.VACOPT_VERBOSE) + if (params->options.verbose) elevel = INFO; else elevel = DEBUG2; @@ -150,7 +150,7 @@ analyze_rel(Oid relid, RangeVar *relation, * Make sure to generate only logs for ANALYZE in this case. */ newoptions = params->options; - newoptions.VACOPT_VACUUM = false; + newoptions.vacuum = false; onerel = vacuum_open_relation(relid, relation, &newoptions, params->log_min_duration >= 0, ShareUpdateExclusiveLock); @@ -241,7 +241,7 @@ analyze_rel(Oid relid, RangeVar *relation, else { /* No need for a WARNING if we already complained during VACUUM */ - if (!params->options.VACOPT_VACUUM) + if (!params->options.vacuum) ereport(WARNING, (errmsg("skipping \"%s\" --- cannot analyze non-tables or special system tables", RelationGetRelationName(onerel)))); @@ -627,7 +627,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params, * VACUUM ANALYZE, don't overwrite the accurate count already inserted by * VACUUM. */ - if (!inh && !params->options.VACOPT_VACUUM) + if (!inh && !params->options.vacuum) { for (ind = 0; ind < nindexes; ind++) { @@ -658,7 +658,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params, (va_cols == NIL)); /* If this isn't part of VACUUM ANALYZE, let index AMs do cleanup */ - if (!params->options.VACOPT_VACUUM) + if (!params->options.vacuum) { for (ind = 0; ind < nindexes; ind++) { diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 591878207d..04bf056caa 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -111,7 +111,7 @@ cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel) DefElem *opt = (DefElem *) lfirst(lc); if (strcmp(opt->defname, "verbose") == 0) - options.CLUOPT_VERBOSE = defGetBoolean(opt); + options.verbose = defGetBoolean(opt); else ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -232,7 +232,7 @@ cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel) { RelToCluster *rvtc = (RelToCluster *) lfirst(rv); ClusterOption newoptions = options; - newoptions.CLUOPT_RECHECK = true; + newoptions.recheck = true; /* Start a new transaction for each relation. */ StartTransactionCommand(); @@ -308,7 +308,7 @@ cluster_rel(Oid tableOid, Oid indexOid, ClusterOption *options) * *must* skip the one on indisclustered since it would reject an attempt * to cluster a not-previously-clustered index. */ - if (options->CLUOPT_RECHECK) + if (options->recheck) { /* Check that the user still owns the relation */ if (!pg_class_ownercheck(tableOid, GetUserId())) @@ -392,7 +392,7 @@ cluster_rel(Oid tableOid, Oid indexOid, ClusterOption *options) /* Check heap and index are valid to cluster on */ if (OidIsValid(indexOid)) - check_index_is_clusterable(OldHeap, indexOid, options->CLUOPT_RECHECK, + check_index_is_clusterable(OldHeap, indexOid, options->recheck, AccessExclusiveLock); @@ -420,7 +420,7 @@ cluster_rel(Oid tableOid, Oid indexOid, ClusterOption *options) TransferPredicateLocksToHeapRelation(OldHeap); /* rebuild_relation does all the dirty work */ - rebuild_relation(OldHeap, indexOid, options->CLUOPT_VERBOSE); + rebuild_relation(OldHeap, indexOid, options->verbose); /* NB: rebuild_relation does table_close() on OldHeap */ diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 80fa39112a..13e463da90 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -2467,9 +2467,9 @@ ReindexParseOptions(ParseState *pstate, ReindexStmt *stmt) DefElem *opt = (DefElem *) lfirst(lc); if (strcmp(opt->defname, "verbose") == 0) - options.REINDEXOPT_VERBOSE = defGetBoolean(opt); + options.verbose = defGetBoolean(opt); else if (strcmp(opt->defname, "concurrently") == 0) - options.REINDEXOPT_CONCURRENTLY = defGetBoolean(opt); + options.concurrently = defGetBoolean(opt); else ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -2506,7 +2506,7 @@ ReindexIndex(RangeVar *indexRelation, ReindexOptions *options, bool isTopLevel) state.options = *options; state.locked_table_oid = InvalidOid; indOid = RangeVarGetRelidExtended(indexRelation, - options->REINDEXOPT_CONCURRENTLY ? + options->concurrently ? ShareUpdateExclusiveLock : AccessExclusiveLock, 0, RangeVarCallbackForReindexIndex, @@ -2521,13 +2521,13 @@ ReindexIndex(RangeVar *indexRelation, ReindexOptions *options, bool isTopLevel) if (relkind == RELKIND_PARTITIONED_INDEX) ReindexPartitions(indOid, options, isTopLevel); - else if (options->REINDEXOPT_CONCURRENTLY && + else if (options->concurrently && persistence != RELPERSISTENCE_TEMP) ReindexRelationConcurrently(indOid, options); else { ReindexOptions newoptions = *options; - newoptions.REINDEXOPT_REPORT_PROGRESS = true; + newoptions.report_progress = true; reindex_index(indOid, false, persistence, &newoptions); } } @@ -2550,7 +2550,7 @@ RangeVarCallbackForReindexIndex(const RangeVar *relation, * non-concurrent case and table locks used by index_concurrently_*() for * concurrent case. */ - table_lockmode = state->options.REINDEXOPT_CONCURRENTLY ? + table_lockmode = state->options.concurrently ? ShareUpdateExclusiveLock : ShareLock; /* @@ -2622,14 +2622,14 @@ ReindexTable(RangeVar *relation, ReindexOptions *options, bool isTopLevel) * locks on our temporary table. */ heapOid = RangeVarGetRelidExtended(relation, - options->REINDEXOPT_CONCURRENTLY ? + options->concurrently ? ShareUpdateExclusiveLock : ShareLock, 0, RangeVarCallbackOwnsTable, NULL); if (get_rel_relkind(heapOid) == RELKIND_PARTITIONED_TABLE) ReindexPartitions(heapOid, options, isTopLevel); - else if (options->REINDEXOPT_CONCURRENTLY && + else if (options->concurrently && get_rel_persistence(heapOid) != RELPERSISTENCE_TEMP) { result = ReindexRelationConcurrently(heapOid, options); @@ -2642,7 +2642,7 @@ ReindexTable(RangeVar *relation, ReindexOptions *options, bool isTopLevel) else { ReindexOptions newoptions = *options; - newoptions.REINDEXOPT_REPORT_PROGRESS = true; + newoptions.report_progress = true; result = reindex_relation(heapOid, REINDEX_REL_PROCESS_TOAST | REINDEX_REL_CHECK_CONSTRAINTS, @@ -2685,7 +2685,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind, objectKind == REINDEX_OBJECT_DATABASE); if (objectKind == REINDEX_OBJECT_SYSTEM && - options->REINDEXOPT_CONCURRENTLY) + options->concurrently) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot reindex system catalogs concurrently"))); @@ -2793,7 +2793,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind, * Skip system tables, since index_create() would reject indexing them * concurrently (and it would likely fail if we tried). */ - if (options->REINDEXOPT_CONCURRENTLY && + if (options->concurrently && IsCatalogRelationOid(relid)) { if (!concurrent_warning) @@ -2990,19 +2990,19 @@ ReindexMultipleInternal(List *relids, ReindexOptions *options) Assert(relkind != RELKIND_PARTITIONED_INDEX && relkind != RELKIND_PARTITIONED_TABLE); - if (options->REINDEXOPT_CONCURRENTLY && + if (options->concurrently && relpersistence != RELPERSISTENCE_TEMP) { ReindexOptions newoptions = *options; - newoptions.REINDEXOPT_MISSING_OK = true; + newoptions.missing_ok = true; (void) ReindexRelationConcurrently(relid, &newoptions); /* ReindexRelationConcurrently() does the verbose output */ } else if (relkind == RELKIND_INDEX) { ReindexOptions newoptions = *options; - newoptions.REINDEXOPT_REPORT_PROGRESS = true; - newoptions.REINDEXOPT_MISSING_OK = true; + newoptions.report_progress = true; + newoptions.missing_ok = true; reindex_index(relid, false, relpersistence, &newoptions); PopActiveSnapshot(); /* reindex_index() does the verbose output */ @@ -3011,15 +3011,15 @@ ReindexMultipleInternal(List *relids, ReindexOptions *options) { bool result; ReindexOptions newoptions = *options; - newoptions.REINDEXOPT_REPORT_PROGRESS = true; - newoptions.REINDEXOPT_MISSING_OK = true; + newoptions.report_progress = true; + newoptions.missing_ok = true; result = reindex_relation(relid, REINDEX_REL_PROCESS_TOAST | REINDEX_REL_CHECK_CONSTRAINTS, &newoptions); - if (result && options->REINDEXOPT_VERBOSE) + if (result && options->verbose) ereport(INFO, (errmsg("table \"%s.%s\" was reindexed", get_namespace_name(get_rel_namespace(relid)), @@ -3092,7 +3092,7 @@ ReindexRelationConcurrently(Oid relationOid, ReindexOptions *options) "ReindexConcurrent", ALLOCSET_SMALL_SIZES); - if (options->REINDEXOPT_VERBOSE) + if (options->verbose) { /* Save data needed by REINDEX VERBOSE in private context */ oldcontext = MemoryContextSwitchTo(private_context); @@ -3137,7 +3137,7 @@ ReindexRelationConcurrently(Oid relationOid, ReindexOptions *options) errmsg("cannot reindex system catalogs concurrently"))); /* Open relation to get its indexes */ - if (options->REINDEXOPT_MISSING_OK) + if (options->missing_ok) { heapRelation = try_table_open(relationOid, ShareUpdateExclusiveLock); @@ -3233,7 +3233,7 @@ ReindexRelationConcurrently(Oid relationOid, ReindexOptions *options) case RELKIND_INDEX: { Oid heapId = IndexGetRelation(relationOid, - options->REINDEXOPT_MISSING_OK); + options->missing_ok); Relation heapRelation; /* if relation is missing, leave */ @@ -3259,10 +3259,10 @@ ReindexRelationConcurrently(Oid relationOid, ReindexOptions *options) /* * Check if parent relation can be locked and if it exists, * this needs to be done at this stage as the list of indexes - * to rebuild is not complete yet, and REINDEXOPT_MISSING_OK + * to rebuild is not complete yet, and missing_ok * should not be used once all the session locks are taken. */ - if (options->REINDEXOPT_MISSING_OK) + if (options->missing_ok) { heapRelation = try_table_open(heapId, ShareUpdateExclusiveLock); @@ -3303,7 +3303,7 @@ ReindexRelationConcurrently(Oid relationOid, ReindexOptions *options) /* * Definitely no indexes, so leave. Any checks based on - * REINDEXOPT_MISSING_OK should be done only while the list of indexes to + * missing_ok should be done only while the list of indexes to * work on is built as the session locks taken before this transaction * commits will make sure that they cannot be dropped by a concurrent * session until this operation completes. @@ -3754,7 +3754,7 @@ ReindexRelationConcurrently(Oid relationOid, ReindexOptions *options) StartTransactionCommand(); /* Log what we did */ - if (options->REINDEXOPT_VERBOSE) + if (options->verbose) { if (relkind == RELKIND_INDEX) ereport(INFO, diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 3774a18ff8..167ca0a1de 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -114,9 +114,9 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel) /* Parse common options for VACUUM and ANALYZE */ if (strcmp(opt->defname, "verbose") == 0) - params.options.VACOPT_VERBOSE = defGetBoolean(opt); + params.options.verbose = defGetBoolean(opt); else if (strcmp(opt->defname, "skip_locked") == 0) - params.options.VACOPT_SKIP_LOCKED = defGetBoolean(opt); + params.options.skip_locked = defGetBoolean(opt); else if (!vacstmt->is_vacuumcmd) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), @@ -125,13 +125,13 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel) /* Parse options available on VACUUM */ else if (strcmp(opt->defname, "analyze") == 0) - params.options.VACOPT_ANALYZE = defGetBoolean(opt); + params.options.analyze = defGetBoolean(opt); else if (strcmp(opt->defname, "freeze") == 0) - params.options.VACOPT_FREEZE = defGetBoolean(opt); + params.options.freeze = defGetBoolean(opt); else if (strcmp(opt->defname, "full") == 0) - params.options.VACOPT_FULL = defGetBoolean(opt); + params.options.full = defGetBoolean(opt); else if (strcmp(opt->defname, "disable_page_skipping") == 0) - params.options.VACOPT_DISABLE_PAGE_SKIPPING = defGetBoolean(opt); + params.options.disable_page_skipping = defGetBoolean(opt); else if (strcmp(opt->defname, "index_cleanup") == 0) // XXX params.index_cleanup = get_vacopt_ternary_value(opt); @@ -178,25 +178,25 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel) } if (vacstmt->is_vacuumcmd) - params.options.VACOPT_VACUUM = true; + params.options.vacuum = true; else - params.options.VACOPT_ANALYZE = true; + params.options.analyze = true; /* sanity checks on options */ - Assert(params.options.VACOPT_VACUUM || params.options.VACOPT_ANALYZE); - Assert(params.options.VACOPT_VACUUM || - !(params.options.VACOPT_FULL || params.options.VACOPT_FREEZE)); - Assert(!params.options.VACOPT_SKIPTOAST); + Assert(params.options.vacuum || params.options.analyze); + Assert(params.options.vacuum || + !(params.options.full || params.options.freeze)); + Assert(!params.options.skiptoast); - if (params.options.VACOPT_FULL && params.nworkers > 0) + if (params.options.full && params.nworkers > 0) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("VACUUM FULL cannot be performed in parallel"))); /* - * Make sure VACOPT_ANALYZE is specified if any column lists are present. + * Make sure analyze is specified if any column lists are present. */ - if (!params.options.VACOPT_ANALYZE) + if (!params.options.analyze) { ListCell *lc; @@ -215,7 +215,7 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel) * All freeze ages are zero if the FREEZE option is given; otherwise pass * them as -1 which means to use the default values. */ - if (params.options.VACOPT_FREEZE) + if (params.options.freeze) { params.freeze_min_age = 0; params.freeze_table_age = 0; @@ -271,7 +271,7 @@ vacuum(List *relations, VacuumParams *params, Assert(params != NULL); - stmttype = params->options.VACOPT_VACUUM ? "VACUUM" : "ANALYZE"; + stmttype = params->options.vacuum ? "VACUUM" : "ANALYZE"; /* * We cannot run VACUUM inside a user transaction block; if we were inside @@ -281,7 +281,7 @@ vacuum(List *relations, VacuumParams *params, * * ANALYZE (without VACUUM) can run either way. */ - if (params->options.VACOPT_VACUUM) + if (params->options.vacuum) { PreventInTransactionBlock(isTopLevel, stmttype); in_outer_xact = false; @@ -303,8 +303,8 @@ vacuum(List *relations, VacuumParams *params, /* * Sanity check DISABLE_PAGE_SKIPPING option. */ - if (params->options.VACOPT_FULL && - params->options.VACOPT_DISABLE_PAGE_SKIPPING) + if (params->options.full && + params->options.disable_page_skipping) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("VACUUM option DISABLE_PAGE_SKIPPING cannot be used with FULL"))); @@ -313,7 +313,7 @@ vacuum(List *relations, VacuumParams *params, * Send info about dead objects to the statistics collector, unless we are * in autovacuum --- autovacuum.c does this for itself. */ - if (params->options.VACOPT_VACUUM && !IsAutoVacuumWorkerProcess()) + if (params->options.vacuum && !IsAutoVacuumWorkerProcess()) pgstat_vacuum_stat(); /* @@ -378,11 +378,11 @@ vacuum(List *relations, VacuumParams *params, * transaction block, and also in an autovacuum worker, use own * transactions so we can release locks sooner. */ - if (params->options.VACOPT_VACUUM) + if (params->options.vacuum) use_own_xacts = true; else { - Assert(params->options.VACOPT_ANALYZE); + Assert(params->options.analyze); if (IsAutoVacuumWorkerProcess()) use_own_xacts = true; else if (in_outer_xact) @@ -435,13 +435,13 @@ vacuum(List *relations, VacuumParams *params, { VacuumRelation *vrel = lfirst_node(VacuumRelation, cur); - if (params->options.VACOPT_VACUUM) + if (params->options.vacuum) { if (!vacuum_rel(vrel->oid, vrel->relation, params)) continue; } - if (params->options.VACOPT_ANALYZE) + if (params->options.analyze) { /* * If using separate xacts, start one for analyze. Otherwise, @@ -495,7 +495,7 @@ vacuum(List *relations, VacuumParams *params, StartTransactionCommand(); } - if (params->options.VACOPT_VACUUM && !IsAutoVacuumWorkerProcess()) + if (params->options.vacuum && !IsAutoVacuumWorkerProcess()) { /* * Update pg_database.datfrozenxid, and truncate pg_xact if possible. @@ -525,7 +525,7 @@ vacuum_is_relation_owner(Oid relid, Form_pg_class reltuple, VacuumOption *option { char *relname; - Assert(options->VACOPT_VACUUM || options->VACOPT_ANALYZE); + Assert(options->vacuum || options->analyze); /* * Check permissions. @@ -544,7 +544,7 @@ vacuum_is_relation_owner(Oid relid, Form_pg_class reltuple, VacuumOption *option relname = NameStr(reltuple->relname); - if (options->VACOPT_VACUUM) + if (options->vacuum) { if (reltuple->relisshared) ereport(WARNING, @@ -567,7 +567,7 @@ vacuum_is_relation_owner(Oid relid, Form_pg_class reltuple, VacuumOption *option return false; } - if (options->VACOPT_ANALYZE) + if (options->analyze) { if (reltuple->relisshared) ereport(WARNING, @@ -602,7 +602,7 @@ vacuum_open_relation(Oid relid, RangeVar *relation, VacuumOption *options, bool rel_lock = true; int elevel; - Assert(options->VACOPT_VACUUM || options->VACOPT_ANALYZE); + Assert(options->vacuum || options->analyze); /* * Open the relation and get the appropriate lock on it. @@ -613,7 +613,7 @@ vacuum_open_relation(Oid relid, RangeVar *relation, VacuumOption *options, * If we've been asked not to wait for the relation lock, acquire it first * in non-blocking mode, before calling try_relation_open(). */ - if (!options->VACOPT_SKIP_LOCKED) + if (!options->skip_locked) onerel = try_relation_open(relid, lmode); else if (ConditionalLockRelationOid(relid, lmode)) onerel = try_relation_open(relid, NoLock); @@ -653,7 +653,7 @@ vacuum_open_relation(Oid relid, RangeVar *relation, VacuumOption *options, else return NULL; - if (options->VACOPT_VACUUM) + if (options->vacuum) { if (!rel_lock) ereport(elevel, @@ -674,7 +674,7 @@ vacuum_open_relation(Oid relid, RangeVar *relation, VacuumOption *options, return NULL; } - if (options->VACOPT_ANALYZE) + if (options->analyze) { if (!rel_lock) ereport(elevel, @@ -739,7 +739,7 @@ expand_vacuum_rel(VacuumRelation *vrel, VacuumOption *options) * below, as well as find_all_inheritors's expectation that the caller * holds some lock on the starting relation. */ - rvr_opts = (options->VACOPT_SKIP_LOCKED) ? RVR_SKIP_LOCKED : 0; + rvr_opts = (options->skip_locked) ? RVR_SKIP_LOCKED : 0; relid = RangeVarGetRelidExtended(vrel->relation, AccessShareLock, rvr_opts, @@ -751,7 +751,7 @@ expand_vacuum_rel(VacuumRelation *vrel, VacuumOption *options) */ if (!OidIsValid(relid)) { - if (options->VACOPT_VACUUM) + if (options->vacuum) ereport(WARNING, (errcode(ERRCODE_LOCK_NOT_AVAILABLE), errmsg("skipping vacuum of \"%s\" --- lock not available", @@ -1720,7 +1720,7 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params) /* Begin a transaction for vacuuming this relation */ StartTransactionCommand(); - if (!params->options.VACOPT_FULL) + if (!params->options.full) { /* * In lazy vacuum, we can set the PROC_IN_VACUUM flag, which lets @@ -1770,7 +1770,7 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params) * vacuum, but just ShareUpdateExclusiveLock for concurrent vacuum. Either * way, we can be sure that no other backend is vacuuming the same table. */ - lmode = (params->options.VACOPT_FULL) ? + lmode = (params->options.full) ? AccessExclusiveLock : ShareUpdateExclusiveLock; /* open the relation and get the appropriate lock on it */ @@ -1794,7 +1794,7 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params) * case. */ newoptions = params->options; - newoptions.VACOPT_ANALYZE = false; + newoptions.analyze = false; if (!vacuum_is_relation_owner(RelationGetRelid(onerel), onerel->rd_rel, &newoptions)) @@ -1889,7 +1889,7 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params) * us to process it. In VACUUM FULL, though, the toast table is * automatically rebuilt by cluster_rel so we shouldn't recurse to it. */ - if (!params->options.VACOPT_SKIPTOAST && !params->options.VACOPT_FULL) + if (!params->options.skiptoast && !params->options.full) toast_relid = onerel->rd_rel->reltoastrelid; else toast_relid = InvalidOid; @@ -1908,10 +1908,10 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params) /* * Do the actual work --- either FULL or "lazy" vacuum */ - if (params->options.VACOPT_FULL) + if (params->options.full) { ClusterOption cluster_options = { - .CLUOPT_VERBOSE = params->options.VACOPT_VERBOSE, + .verbose = params->options.verbose, /* Other members initialized to false/0/NULL */ }; diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index a1599ccb77..ba742e4c6e 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -2505,7 +2505,7 @@ do_autovacuum(void) * next table in our list. */ HOLD_INTERRUPTS(); - if (tab->at_params.options.VACOPT_VACUUM) + if (tab->at_params.options.vacuum) errcontext("automatic vacuum of table \"%s.%s.%s\"", tab->at_datname, tab->at_nspname, tab->at_relname); else @@ -2919,10 +2919,10 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map, tab = palloc(sizeof(autovac_table)); tab->at_relid = relid; tab->at_sharedrel = classForm->relisshared; - tab->at_params.options.VACOPT_SKIPTOAST = true; - tab->at_params.options.VACOPT_VACUUM = dovacuum; - tab->at_params.options.VACOPT_ANALYZE = doanalyze; - tab->at_params.options.VACOPT_SKIP_LOCKED = !wraparound; + tab->at_params.options.skiptoast = true; + tab->at_params.options.vacuum = dovacuum; + tab->at_params.options.analyze = doanalyze; + tab->at_params.options.skip_locked = !wraparound; tab->at_params.index_cleanup = VACOPT_TERNARY_DEFAULT; tab->at_params.truncate = VACOPT_TERNARY_DEFAULT; /* As of now, we don't support parallel vacuum for autovacuum */ @@ -3250,10 +3250,10 @@ autovac_report_activity(autovac_table *tab) int len; /* Report the command and possible options */ - if (tab->at_params.options.VACOPT_VACUUM) + if (tab->at_params.options.vacuum) snprintf(activity, MAX_AUTOVAC_ACTIV_LEN, "autovacuum: VACUUM%s", - tab->at_params.options.VACOPT_ANALYZE ? " ANALYZE" : ""); + tab->at_params.options.analyze ? " ANALYZE" : ""); else snprintf(activity, MAX_AUTOVAC_ACTIV_LEN, "autovacuum: ANALYZE"); diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 23612b7a90..a6c42ee599 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -922,7 +922,7 @@ standard_ProcessUtility(PlannedStmt *pstmt, ReindexOptions options; options = ReindexParseOptions(pstate, stmt); - if (options.REINDEXOPT_CONCURRENTLY) + if (options.concurrently) PreventInTransactionBlock(isTopLevel, "REINDEX CONCURRENTLY"); diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h index 3a8671f558..d7e7e0dd24 100644 --- a/src/include/catalog/index.h +++ b/src/include/catalog/index.h @@ -32,10 +32,10 @@ typedef enum /* options for REINDEX */ typedef struct ReindexOptions { - bool REINDEXOPT_VERBOSE; /* print progress info */ - bool REINDEXOPT_REPORT_PROGRESS; /* report pgstat progress */ - bool REINDEXOPT_MISSING_OK; /* skip missing relations */ - bool REINDEXOPT_CONCURRENTLY; /* concurrent mode */ + bool verbose; /* print progress info */ + bool report_progress; /* report pgstat progress */ + bool missing_ok; /* skip missing relations */ + bool concurrently; /* concurrent mode */ } ReindexOptions; /* state info for validate_index bulkdelete callback */ diff --git a/src/include/commands/cluster.h b/src/include/commands/cluster.h index 5111941a41..2c20c76734 100644 --- a/src/include/commands/cluster.h +++ b/src/include/commands/cluster.h @@ -22,8 +22,8 @@ /* options for CLUSTER */ typedef struct ClusterOption { - bool CLUOPT_RECHECK; /* recheck relation state */ - bool CLUOPT_VERBOSE; /* print progress info */ + bool recheck; /* recheck relation state */ + bool verbose; /* print progress info */ } ClusterOption; extern void cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel); diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h index 15327643ba..bfbbc932ab 100644 --- a/src/include/commands/vacuum.h +++ b/src/include/commands/vacuum.h @@ -176,14 +176,14 @@ typedef struct VacAttrStats typedef struct VacuumOption { - bool VACOPT_VACUUM; /* do VACUUM */ - bool VACOPT_ANALYZE; /* do ANALYZE */ - bool VACOPT_VERBOSE; /* print progress info */ - bool VACOPT_FREEZE; /* FREEZE option */ - bool VACOPT_FULL; /* FULL (non-concurrent) vacuum */ - bool VACOPT_SKIP_LOCKED; /* skip if cannot get lock */ - bool VACOPT_SKIPTOAST; /* don't process the TOAST table, if any */ - bool VACOPT_DISABLE_PAGE_SKIPPING; /* don't skip any pages */ + bool vacuum; /* do VACUUM */ + bool analyze; /* do ANALYZE */ + bool verbose; /* print progress info */ + bool freeze; /* FREEZE option */ + bool full; /* FULL (non-concurrent) vacuum */ + bool skip_locked; /* skip if cannot get lock */ + bool skiptoast; /* don't process the TOAST table, if any */ + bool disable_page_skipping; /* don't skip any pages */ } VacuumOption; /* -- 2.17.0
>From 699959b0bacf6b7037cdf689c93fc90f1bde5848 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Sat, 12 Dec 2020 11:42:14 -0600 Subject: [PATCH 4/4] ExecReindex and ReindexParams --- src/backend/commands/indexcmds.c | 56 +++++++++++++++++++++++++++----- src/backend/tcop/utility.c | 40 +---------------------- src/include/commands/defrem.h | 6 +--- 3 files changed, 50 insertions(+), 52 deletions(-) diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index 13e463da90..8b688a5a65 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -86,6 +86,11 @@ static char *ChooseIndexName(const char *tabname, Oid namespaceId, bool primary, bool isconstraint); static char *ChooseIndexNameAddition(List *colnames); static List *ChooseIndexColumnNames(List *indexElems); +static void ReindexIndex(RangeVar *indexRelation, ReindexOptions *options, + bool isTopLevel); +static Oid ReindexTable(RangeVar *relation, ReindexOptions *options, bool isTopLevel); +static void ReindexMultipleTables(const char *objectName, + ReindexObjectType objectKind, ReindexOptions *options); static void RangeVarCallbackForReindexIndex(const RangeVar *relation, Oid relId, Oid oldRelId, void *arg); static void reindex_error_callback(void *args); @@ -2452,11 +2457,14 @@ ChooseIndexColumnNames(List *indexElems) } /* - * ReindexParseOptions - * Parse list of REINDEX options, returning a bitmask of ReindexOption. + * Reindex accordinging to stmt. + * This calls the intermediate routines: ReindexIndex, ReindexTable, ReindexMultipleTables, + * which ultimately call reindex_index, reindex_relation, ReindexRelationConcurrently. + * Note that partitioned relations are handled by ReindexPartitions, except that + * ReindexRelationConcurrently handles concurrently reindexing a table. */ -ReindexOptions -ReindexParseOptions(ParseState *pstate, ReindexStmt *stmt) +void +ExecReindex(ParseState *pstate, ReindexStmt *stmt, bool isTopLevel) { ListCell *lc; ReindexOptions options = {false}; @@ -2478,14 +2486,46 @@ ReindexParseOptions(ParseState *pstate, ReindexStmt *stmt) parser_errposition(pstate, opt->location))); } - return options; + if (options.concurrently) + PreventInTransactionBlock(isTopLevel, + "REINDEX CONCURRENTLY"); + + switch (stmt->kind) + { + case REINDEX_OBJECT_INDEX: + ReindexIndex(stmt->relation, &options, isTopLevel); + break; + case REINDEX_OBJECT_TABLE: + ReindexTable(stmt->relation, &options, isTopLevel); + break; + case REINDEX_OBJECT_SCHEMA: + case REINDEX_OBJECT_SYSTEM: + case REINDEX_OBJECT_DATABASE: + + /* + * This cannot run inside a user transaction block; if + * we were inside a transaction, then its commit- and + * start-transaction-command calls would not have the + * intended effect! + */ + PreventInTransactionBlock(isTopLevel, + (stmt->kind == REINDEX_OBJECT_SCHEMA) ? "REINDEX SCHEMA" : + (stmt->kind == REINDEX_OBJECT_SYSTEM) ? "REINDEX SYSTEM" : + "REINDEX DATABASE"); + ReindexMultipleTables(stmt->name, stmt->kind, &options); + break; + default: + elog(ERROR, "unrecognized object type: %d", + (int) stmt->kind); + break; + } } /* * ReindexIndex * Recreate a specific index. */ -void +static void ReindexIndex(RangeVar *indexRelation, ReindexOptions *options, bool isTopLevel) { struct ReindexIndexCallbackState state; @@ -2607,7 +2647,7 @@ RangeVarCallbackForReindexIndex(const RangeVar *relation, * ReindexTable * Recreate all indexes of a table (and of its toast table, if any) */ -Oid +static Oid ReindexTable(RangeVar *relation, ReindexOptions *options, bool isTopLevel) { Oid heapOid; @@ -2664,7 +2704,7 @@ ReindexTable(RangeVar *relation, ReindexOptions *options, bool isTopLevel) * separate transaction, so we can release the lock on it right away. * That means this must not be called within a user transaction block! */ -void +static void ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind, ReindexOptions *options) { diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index a6c42ee599..3991a834b4 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -917,45 +917,7 @@ standard_ProcessUtility(PlannedStmt *pstmt, break; case T_ReindexStmt: - { - ReindexStmt *stmt = (ReindexStmt *) parsetree; - ReindexOptions options; - - options = ReindexParseOptions(pstate, stmt); - if (options.concurrently) - PreventInTransactionBlock(isTopLevel, - "REINDEX CONCURRENTLY"); - - switch (stmt->kind) - { - case REINDEX_OBJECT_INDEX: - ReindexIndex(stmt->relation, &options, isTopLevel); - break; - case REINDEX_OBJECT_TABLE: - ReindexTable(stmt->relation, &options, isTopLevel); - break; - case REINDEX_OBJECT_SCHEMA: - case REINDEX_OBJECT_SYSTEM: - case REINDEX_OBJECT_DATABASE: - - /* - * This cannot run inside a user transaction block; if - * we were inside a transaction, then its commit- and - * start-transaction-command calls would not have the - * intended effect! - */ - PreventInTransactionBlock(isTopLevel, - (stmt->kind == REINDEX_OBJECT_SCHEMA) ? "REINDEX SCHEMA" : - (stmt->kind == REINDEX_OBJECT_SYSTEM) ? "REINDEX SYSTEM" : - "REINDEX DATABASE"); - ReindexMultipleTables(stmt->name, stmt->kind, &options); - break; - default: - elog(ERROR, "unrecognized object type: %d", - (int) stmt->kind); - break; - } - } + ExecReindex(pstate, (ReindexStmt *)parsetree, isTopLevel); break; /* diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h index 33df5d5780..d4ea57e757 100644 --- a/src/include/commands/defrem.h +++ b/src/include/commands/defrem.h @@ -35,11 +35,7 @@ extern ObjectAddress DefineIndex(Oid relationId, bool check_not_in_use, bool skip_build, bool quiet); -extern ReindexOptions ReindexParseOptions(ParseState *pstate, ReindexStmt *stmt); -extern void ReindexIndex(RangeVar *indexRelation, ReindexOptions *options, bool isTopLevel); -extern Oid ReindexTable(RangeVar *relation, ReindexOptions *options, bool isTopLevel); -extern void ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind, - ReindexOptions *options); +extern void ExecReindex(ParseState *pstate, ReindexStmt *stmt, bool isTopLevel); extern char *makeObjectName(const char *name1, const char *name2, const char *label); extern char *ChooseRelationName(const char *name1, const char *name2, -- 2.17.0