From c7f01df8d6c6baa42b69f14c2a50187667cf27d7 Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
Date: Fri, 4 Dec 2020 15:02:59 -0600
Subject: [PATCH v34 8/8] Avoid enums for bitmasks..

..since the utility enums is nullified
---
 contrib/bloom/blutils.c                       |  2 +-
 src/backend/access/common/reloptions.c        | 12 ++---
 src/backend/commands/explain.c                |  2 +-
 src/backend/utils/sort/tuplesort.c            |  5 +-
 src/include/access/reloptions.h               | 43 ++++++++---------
 src/include/access/relscan.h                  |  4 +-
 src/include/access/tableam.h                  | 47 +++++++++----------
 src/include/catalog/index.h                   |  4 ++
 src/include/catalog/namespace.h               |  9 ++--
 src/include/commands/cluster.h                |  7 +--
 src/include/commands/vacuum.h                 | 21 ++++-----
 src/include/executor/execdesc.h               |  2 +-
 src/include/executor/instrument.h             | 13 ++---
 src/include/nodes/execnodes.h                 |  4 +-
 src/include/nodes/parsenodes.h                | 24 +++++-----
 src/include/utils/tuplesort.h                 | 20 ++++----
 .../modules/dummy_index_am/dummy_index_am.c   |  2 +-
 src/tools/pgindent/typedefs.list              |  2 -
 18 files changed, 103 insertions(+), 120 deletions(-)

diff --git a/contrib/bloom/blutils.c b/contrib/bloom/blutils.c
index 26b9927c3a..d8c575e5a8 100644
--- a/contrib/bloom/blutils.c
+++ b/contrib/bloom/blutils.c
@@ -35,7 +35,7 @@
 PG_FUNCTION_INFO_V1(blhandler);
 
 /* Kind of relation options for bloom index */
-static relopt_kind bl_relopt_kind;
+static int bl_relopt_kind;
 
 /* parse table for fillRelOptions */
 static relopt_parse_elt bl_relopt_tab[INDEX_MAX_KEYS + 1];
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index 8ccc228a8c..c5dc7f5f52 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -652,10 +652,10 @@ initialize_reloptions(void)
 
 /*
  * add_reloption_kind
- *		Create a new relopt_kind value, to be used in custom reloptions by
+ *		Return a value for a new kind of reloption, to be used in custom reloptions by
  *		user-defined AMs.
  */
-relopt_kind
+int
 add_reloption_kind(void)
 {
 	/* don't hand out the last bit so that the enum's behavior is portable */
@@ -664,7 +664,7 @@ add_reloption_kind(void)
 				(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
 				 errmsg("user-defined relation parameter types limit exceeded")));
 	last_assigned_kind <<= 1;
-	return (relopt_kind) last_assigned_kind;
+	return last_assigned_kind;
 }
 
 /*
@@ -1475,7 +1475,7 @@ parseRelOptionsInternal(Datum options, bool validate,
  * be freed by the caller.
  */
 static relopt_value *
-parseRelOptions(Datum options, bool validate, relopt_kind kind,
+parseRelOptions(Datum options, bool validate, int kind,
 				int *numrelopts)
 {
 	relopt_value *reloptions = NULL;
@@ -1814,7 +1814,7 @@ fillRelOptions(void *rdopts, Size basesize,
  * Option parser for anything that uses StdRdOptions.
  */
 bytea *
-default_reloptions(Datum reloptions, bool validate, relopt_kind kind)
+default_reloptions(Datum reloptions, bool validate, int kind)
 {
 	static const relopt_parse_elt tab[] = {
 		{"fillfactor", RELOPT_TYPE_INT, offsetof(StdRdOptions, fillfactor)},
@@ -1885,7 +1885,7 @@ default_reloptions(Datum reloptions, bool validate, relopt_kind kind)
  */
 void *
 build_reloptions(Datum reloptions, bool validate,
-				 relopt_kind kind,
+				 int kind,
 				 Size relopt_struct_size,
 				 const relopt_parse_elt *relopt_elems,
 				 int num_relopt_elems)
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 43f9b01e83..5c6e9c98fd 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -2750,7 +2750,7 @@ show_incremental_sort_group_info(IncrementalSortGroupInfo *groupInfo,
 	/* Generate a list of sort methods used across all groups. */
 	for (int bit = 0; bit < NUM_TUPLESORTMETHODS; bit++)
 	{
-		TuplesortMethod sortMethod = (1 << bit);
+		int sortMethod = (1 << bit);
 
 		if (groupInfo->sortMethods & sortMethod)
 		{
diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c
index d0cc04a878..285c94d34a 100644
--- a/src/backend/utils/sort/tuplesort.c
+++ b/src/backend/utils/sort/tuplesort.c
@@ -3397,10 +3397,11 @@ tuplesort_get_stats(Tuplesortstate *state,
 }
 
 /*
- * Convert TuplesortMethod to a string.
+ * Convert sortMethod bitmask to a string.
+ * XXX: multiple bits can be defined
  */
 const char *
-tuplesort_method_name(TuplesortMethod m)
+tuplesort_method_name(int m)
 {
 	switch (m)
 	{
diff --git a/src/include/access/reloptions.h b/src/include/access/reloptions.h
index 5964438cb0..d7df48ef53 100644
--- a/src/include/access/reloptions.h
+++ b/src/include/access/reloptions.h
@@ -36,26 +36,23 @@ typedef enum relopt_type
 } relopt_type;
 
 /* kinds supported by reloptions */
-typedef enum relopt_kind
-{
-	RELOPT_KIND_LOCAL = 0,
-	RELOPT_KIND_HEAP = (1 << 0),
-	RELOPT_KIND_TOAST = (1 << 1),
-	RELOPT_KIND_BTREE = (1 << 2),
-	RELOPT_KIND_HASH = (1 << 3),
-	RELOPT_KIND_GIN = (1 << 4),
-	RELOPT_KIND_GIST = (1 << 5),
-	RELOPT_KIND_ATTRIBUTE = (1 << 6),
-	RELOPT_KIND_TABLESPACE = (1 << 7),
-	RELOPT_KIND_SPGIST = (1 << 8),
-	RELOPT_KIND_VIEW = (1 << 9),
-	RELOPT_KIND_BRIN = (1 << 10),
-	RELOPT_KIND_PARTITIONED = (1 << 11),
-	/* if you add a new kind, make sure you update "last_default" too */
-	RELOPT_KIND_LAST_DEFAULT = RELOPT_KIND_PARTITIONED,
-	/* some compilers treat enums as signed ints, so we can't use 1 << 31 */
-	RELOPT_KIND_MAX = (1 << 30)
-} relopt_kind;
+#define RELOPT_KIND_LOCAL		0
+#define RELOPT_KIND_HEAP		(1 << 0)
+#define RELOPT_KIND_TOAST		(1 << 1)
+#define RELOPT_KIND_BTREE		(1 << 2)
+#define RELOPT_KIND_HASH		(1 << 3)
+#define RELOPT_KIND_GIN			(1 << 4)
+#define RELOPT_KIND_GIST		(1 << 5)
+#define RELOPT_KIND_ATTRIBUTE	(1 << 6)
+#define RELOPT_KIND_TABLESPACE	(1 << 7)
+#define RELOPT_KIND_SPGIST		(1 << 8)
+#define RELOPT_KIND_VIEW		(1 << 9)
+#define RELOPT_KIND_BRIN		(1 << 10)
+#define RELOPT_KIND_PARTITIONED	(1 << 11)
+/* if you add a new kind, make sure you update "last_default" too */
+#define RELOPT_KIND_LAST_DEFAULT		RELOPT_KIND_PARTITIONED
+/* some compilers treat enums as signed ints, so we can't use 1 << 31 */
+#define RELOPT_KIND_MAX		(1 << 30)
 
 /* reloption namespaces allowed for heaps -- currently only TOAST */
 #define HEAP_RELOPT_NAMESPACES { "toast", NULL }
@@ -179,7 +176,7 @@ typedef struct local_relopts
 	((optstruct)->member == 0 ? NULL : \
 	 (char *)(optstruct) + (optstruct)->member)
 
-extern relopt_kind add_reloption_kind(void);
+extern int add_reloption_kind(void);
 extern void add_bool_reloption(bits32 kinds, const char *name, const char *desc,
 							   bool default_val, LOCKMODE lockmode);
 extern void add_int_reloption(bits32 kinds, const char *name, const char *desc,
@@ -226,7 +223,7 @@ extern List *untransformRelOptions(Datum options);
 extern bytea *extractRelOptions(HeapTuple tuple, TupleDesc tupdesc,
 								amoptions_function amoptions);
 extern void *build_reloptions(Datum reloptions, bool validate,
-							  relopt_kind kind,
+							  int kind,
 							  Size relopt_struct_size,
 							  const relopt_parse_elt *relopt_elems,
 							  int num_relopt_elems);
@@ -234,7 +231,7 @@ extern void *build_local_reloptions(local_relopts *relopts, Datum options,
 									bool validate);
 
 extern bytea *default_reloptions(Datum reloptions, bool validate,
-								 relopt_kind kind);
+								 int kind);
 extern bytea *heap_reloptions(char relkind, Datum reloptions, bool validate);
 extern bytea *view_reloptions(Datum reloptions, bool validate);
 extern bytea *partitioned_table_reloptions(Datum reloptions, bool validate);
diff --git a/src/include/access/relscan.h b/src/include/access/relscan.h
index 5645976951..9a278e408f 100644
--- a/src/include/access/relscan.h
+++ b/src/include/access/relscan.h
@@ -37,8 +37,8 @@ typedef struct TableScanDescData
 	struct ScanKeyData *rs_key; /* array of scan key descriptors */
 
 	/*
-	 * Information about type and behaviour of the scan, a bitmask of members
-	 * of the ScanOptions enum (see tableam.h).
+	 * Information about type and behaviour of the scan, a bitmask of
+	 * flags to scan_begin (see tableam.h).
 	 */
 	uint32		rs_flags;
 
diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h
index 387eb34a61..eda47241eb 100644
--- a/src/include/access/tableam.h
+++ b/src/include/access/tableam.h
@@ -42,26 +42,25 @@ struct ValidateIndexState;
 /*
  * Bitmask values for the flags argument to the scan_begin callback.
  */
-typedef enum ScanOptions
-{
-	/* one of SO_TYPE_* may be specified */
-	SO_TYPE_SEQSCAN = 1 << 0,
-	SO_TYPE_BITMAPSCAN = 1 << 1,
-	SO_TYPE_SAMPLESCAN = 1 << 2,
-	SO_TYPE_TIDSCAN = 1 << 3,
-	SO_TYPE_ANALYZE = 1 << 4,
-
-	/* several of SO_ALLOW_* may be specified */
-	/* allow or disallow use of access strategy */
-	SO_ALLOW_STRAT = 1 << 5,
-	/* report location to syncscan logic? */
-	SO_ALLOW_SYNC = 1 << 6,
-	/* verify visibility page-at-a-time? */
-	SO_ALLOW_PAGEMODE = 1 << 7,
-
-	/* unregister snapshot at scan end? */
-	SO_TEMP_SNAPSHOT = 1 << 8
-} ScanOptions;
+
+/* one of SO_TYPE_* may be specified */
+#define SO_TYPE_SEQSCAN		(1 << 0)
+#define SO_TYPE_BITMAPSCAN	(1 << 1)
+#define SO_TYPE_SAMPLESCAN	(1 << 2)
+#define SO_TYPE_TIDSCAN		(1 << 3)
+#define SO_TYPE_ANALYZE		(1 << 4)
+
+/*
+ * several of SO_ALLOW_* may be specified
+ */
+/* allow or disallow use of access strategy */
+#define SO_ALLOW_STRAT		(1 << 5)
+/* report location to syncscan logic? */
+#define SO_ALLOW_SYNC		(1 << 6)
+/* verify visibility page-at-a-time? */
+#define SO_ALLOW_PAGEMODE	(1 << 7)
+/* unregister snapshot at scan end? */
+#define SO_TEMP_SNAPSHOT	(1 << 8)
 
 /*
  * Result codes for table_{update,delete,lock_tuple}, and for visibility
@@ -192,11 +191,11 @@ typedef struct TableAmRoutine
 	 * parallelscan_initialize(), and has to be for the same relation. Will
 	 * only be set coming from table_beginscan_parallel().
 	 *
-	 * `flags` is a bitmask indicating the type of scan (ScanOptions's
-	 * SO_TYPE_*, currently only one may be specified), options controlling
-	 * the scan's behaviour (ScanOptions's SO_ALLOW_*, several may be
+	 * `flags` is a bitmask indicating the type of scan
+	 * (SO_TYPE_*, currently only one may be specified), options controlling
+	 * the scan's behaviour (SO_ALLOW_*, several may be
 	 * specified, an AM may ignore unsupported ones) and whether the snapshot
-	 * needs to be deallocated at scan_end (ScanOptions's SO_TEMP_SNAPSHOT).
+	 * needs to be deallocated at scan_end (SO_TEMP_SNAPSHOT).
 	 */
 	TableScanDesc (*scan_begin) (Relation rel,
 								 Snapshot snapshot,
diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index 9543ca9c61..cd75249192 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -38,6 +38,10 @@ typedef struct ReindexOptions
 	bool REINDEXOPT_CONCURRENTLY;		/* concurrent mode */
 	Oid  tablespaceOid;					/* tablespace to rebuild index */
 } ReindexOptions;
+// #define REINDEXOPT_VERBOSE			(1 << 0)	/* print progress info */
+// #define REINDEXOPT_REPORT_PROGRESS	(1 << 1)	/* report pgstat progress */
+// #define REINDEXOPT_MISSING_OK		(1 << 2)	/* skip missing relations */
+// #define REINDEXOPT_CONCURRENTLY		(1 << 3)	/* concurrent mode */
 
 /* state info for validate_index bulkdelete callback */
 typedef struct ValidateIndexState
diff --git a/src/include/catalog/namespace.h b/src/include/catalog/namespace.h
index 2456c08bf7..485293d77a 100644
--- a/src/include/catalog/namespace.h
+++ b/src/include/catalog/namespace.h
@@ -65,12 +65,9 @@ typedef struct OverrideSearchPath
 /*
  * Option flag bits for RangeVarGetRelidExtended().
  */
-typedef enum RVROption
-{
-	RVR_MISSING_OK = 1 << 0,	/* don't error if relation doesn't exist */
-	RVR_NOWAIT = 1 << 1,		/* error if relation cannot be locked */
-	RVR_SKIP_LOCKED = 1 << 2	/* skip if relation cannot be locked */
-} RVROption;
+#define RVR_MISSING_OK		(1 << 0)	/* don't error if relation doesn't exist */
+#define RVR_NOWAIT			(1 << 1)	/* error if relation cannot be locked */
+#define RVR_SKIP_LOCKED		(1 << 2)	/* skip if relation cannot be locked */
 
 typedef void (*RangeVarGetRelidCallback) (const RangeVar *relation, Oid relId,
 										  Oid oldRelId, void *callback_arg);
diff --git a/src/include/commands/cluster.h b/src/include/commands/cluster.h
index ab15689019..8f59af5863 100644
--- a/src/include/commands/cluster.h
+++ b/src/include/commands/cluster.h
@@ -20,11 +20,8 @@
 
 
 /* options for CLUSTER */
-typedef enum ClusterOption
-{
-	CLUOPT_RECHECK = 1 << 0,	/* recheck relation state */
-	CLUOPT_VERBOSE = 1 << 1		/* print progress info */
-} ClusterOption;
+#define CLUOPT_RECHECK		(1 << 0)	/* recheck relation state */
+#define CLUOPT_VERBOSE		(1 << 1)	/* print progress info */
 
 extern void cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel);
 extern void cluster_rel(Oid tableOid, Oid indexOid, int options,
diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h
index 488d7540c7..0f9d4e2438 100644
--- a/src/include/commands/vacuum.h
+++ b/src/include/commands/vacuum.h
@@ -174,17 +174,14 @@ typedef struct VacAttrStats
 	int			rowstride;
 } VacAttrStats;
 
-typedef enum 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 */
-} VacuumOption;
+#define VACOPT_VACUUM				(1 << 0)	/* do VACUUM */
+#define VACOPT_ANALYZE				(1 << 1)	/* do ANALYZE */
+#define VACOPT_VERBOSE				(1 << 2)	/* print progress info */
+#define VACOPT_FREEZE				(1 << 3)	/* FREEZE option */
+#define VACOPT_FULL					(1 << 4)	/* FULL (non-concurrent) vacuum */
+#define VACOPT_SKIP_LOCKED			(1 << 5)	/* skip if cannot get lock */
+#define VACOPT_SKIPTOAST			(1 << 6)	/* don't process the TOAST table, if any */
+#define VACOPT_DISABLE_PAGE_SKIPPING (1 << 7)	/* don't skip any pages */
 
 /*
  * A ternary value used by vacuum parameters.
@@ -207,7 +204,7 @@ typedef enum VacOptTernaryValue
  */
 typedef struct VacuumParams
 {
-	int			options;		/* bitmask of VacuumOption */
+	int			options;		/* bitmask of VACOPT_* options */
 	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
diff --git a/src/include/executor/execdesc.h b/src/include/executor/execdesc.h
index b5cead3502..0087d192ca 100644
--- a/src/include/executor/execdesc.h
+++ b/src/include/executor/execdesc.h
@@ -41,7 +41,7 @@ typedef struct QueryDesc
 	DestReceiver *dest;			/* the destination for tuple output */
 	ParamListInfo params;		/* param values being passed in */
 	QueryEnvironment *queryEnv; /* query environment passed in */
-	int			instrument_options; /* OR of InstrumentOption flags */
+	int			instrument_options; /* OR of flags to instrumentoption */
 
 	/* These fields are set by ExecutorStart */
 	TupleDesc	tupDesc;		/* descriptor for result tuples */
diff --git a/src/include/executor/instrument.h b/src/include/executor/instrument.h
index 9dc3ecb07d..3148d88fea 100644
--- a/src/include/executor/instrument.h
+++ b/src/include/executor/instrument.h
@@ -40,14 +40,11 @@ typedef struct WalUsage
 } WalUsage;
 
 /* Flag bits included in InstrAlloc's instrument_options bitmask */
-typedef enum InstrumentOption
-{
-	INSTRUMENT_TIMER = 1 << 0,	/* needs timer (and row counts) */
-	INSTRUMENT_BUFFERS = 1 << 1,	/* needs buffer usage */
-	INSTRUMENT_ROWS = 1 << 2,	/* needs row count */
-	INSTRUMENT_WAL = 1 << 3,	/* needs WAL usage */
-	INSTRUMENT_ALL = PG_INT32_MAX
-} InstrumentOption;
+#define INSTRUMENT_TIMER	(1 << 0)	/* needs timer (and row counts) */
+#define INSTRUMENT_BUFFERS	(1 << 1)	/* needs buffer usage */
+#define INSTRUMENT_ROWS		(1 << 2)	/* needs row count */
+#define INSTRUMENT_WAL		(1 << 3)	/* needs WAL usage */
+#define INSTRUMENT_ALL		PG_INT32_MAX
 
 typedef struct Instrumentation
 {
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 61ba4c3666..d065cdefd0 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -563,7 +563,7 @@ typedef struct EState
 	uint64		es_processed;	/* # of tuples processed */
 
 	int			es_top_eflags;	/* eflags passed to ExecutorStart */
-	int			es_instrument;	/* OR of InstrumentOption flags */
+	int			es_instrument;	/* OR of flags to instrument_options */
 	bool		es_finished;	/* true when ExecutorFinish is done */
 
 	List	   *es_exprcontexts;	/* List of ExprContexts within EState */
@@ -2022,7 +2022,7 @@ typedef struct IncrementalSortGroupInfo
 	int64		totalDiskSpaceUsed;
 	int64		maxMemorySpaceUsed;
 	int64		totalMemorySpaceUsed;
-	bits32		sortMethods;	/* bitmask of TuplesortMethod */
+	bits32		sortMethods;	/* bitmask of sortMethod flags */
 } IncrementalSortGroupInfo;
 
 typedef struct IncrementalSortInfo
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 48a79a7657..f223df8a0c 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -671,22 +671,20 @@ typedef struct TableLikeClause
 {
 	NodeTag		type;
 	RangeVar   *relation;
-	bits32		options;		/* OR of TableLikeOption flags */
+	bits32		options;		/* OR of flags */
 	Oid			relationOid;	/* If table has been looked up, its OID */
 } TableLikeClause;
 
-typedef enum TableLikeOption
-{
-	CREATE_TABLE_LIKE_COMMENTS = 1 << 0,
-	CREATE_TABLE_LIKE_CONSTRAINTS = 1 << 1,
-	CREATE_TABLE_LIKE_DEFAULTS = 1 << 2,
-	CREATE_TABLE_LIKE_GENERATED = 1 << 3,
-	CREATE_TABLE_LIKE_IDENTITY = 1 << 4,
-	CREATE_TABLE_LIKE_INDEXES = 1 << 5,
-	CREATE_TABLE_LIKE_STATISTICS = 1 << 6,
-	CREATE_TABLE_LIKE_STORAGE = 1 << 7,
-	CREATE_TABLE_LIKE_ALL = PG_INT32_MAX
-} TableLikeOption;
+/* bitmask of flags to TableLikeClause */
+#define CREATE_TABLE_LIKE_COMMENTS		(1 << 0)
+#define CREATE_TABLE_LIKE_CONSTRAINTS	(1 << 1)
+#define CREATE_TABLE_LIKE_DEFAULTS		(1 << 2)
+#define CREATE_TABLE_LIKE_GENERATED		(1 << 3)
+#define CREATE_TABLE_LIKE_IDENTITY		(1 << 4)
+#define CREATE_TABLE_LIKE_INDEXES		(1 << 5)
+#define CREATE_TABLE_LIKE_STATISTICS	(1 << 6)
+#define CREATE_TABLE_LIKE_STORAGE		(1 << 7)
+#define CREATE_TABLE_LIKE_ALL			PG_INT32_MAX
 
 /*
  * IndexElem - index parameters (used in CREATE INDEX, and in ON CONFLICT)
diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h
index c69b36e209..5da79fc0b6 100644
--- a/src/include/utils/tuplesort.h
+++ b/src/include/utils/tuplesort.h
@@ -62,21 +62,19 @@ typedef struct SortCoordinateData *SortCoordinate;
  * TuplesortInstrumentation can't contain any pointers because we
  * sometimes put it in shared memory.
  *
- * The parallel-sort infrastructure relies on having a zero TuplesortMethod
+ * The parallel-sort infrastructure relies on having a zero sortMethod
  * to indicate that a worker never did anything, so we assign zero to
  * SORT_TYPE_STILL_IN_PROGRESS.  The other values of this enum can be
  * OR'ed together to represent a situation where different workers used
  * different methods, so we need a separate bit for each one.  Keep the
  * NUM_TUPLESORTMETHODS constant in sync with the number of bits!
  */
-typedef enum
-{
-	SORT_TYPE_STILL_IN_PROGRESS = 0,
-	SORT_TYPE_TOP_N_HEAPSORT = 1 << 0,
-	SORT_TYPE_QUICKSORT = 1 << 1,
-	SORT_TYPE_EXTERNAL_SORT = 1 << 2,
-	SORT_TYPE_EXTERNAL_MERGE = 1 << 3
-} TuplesortMethod;
+/* sortMethod flags */
+#define SORT_TYPE_STILL_IN_PROGRESS	0
+#define SORT_TYPE_TOP_N_HEAPSORT	(1 << 0)
+#define SORT_TYPE_QUICKSORT		(1 << 1)
+#define SORT_TYPE_EXTERNAL_SORT		(1 << 2)
+#define SORT_TYPE_EXTERNAL_MERGE	(1 << 3)
 
 #define NUM_TUPLESORTMETHODS 4
 
@@ -88,7 +86,7 @@ typedef enum
 
 typedef struct TuplesortInstrumentation
 {
-	TuplesortMethod sortMethod; /* sort algorithm used */
+	int sortMethod; /* sort algorithm used */
 	TuplesortSpaceType spaceType;	/* type of space spaceUsed represents */
 	int64		spaceUsed;		/* space consumption, in kB */
 } TuplesortInstrumentation;
@@ -257,7 +255,7 @@ extern void tuplesort_reset(Tuplesortstate *state);
 
 extern void tuplesort_get_stats(Tuplesortstate *state,
 								TuplesortInstrumentation *stats);
-extern const char *tuplesort_method_name(TuplesortMethod m);
+extern const char *tuplesort_method_name(int m);
 extern const char *tuplesort_space_type_name(TuplesortSpaceType t);
 
 extern int	tuplesort_merge_order(int64 allowedMem);
diff --git a/src/test/modules/dummy_index_am/dummy_index_am.c b/src/test/modules/dummy_index_am/dummy_index_am.c
index 8f4cdab1b3..3351639382 100644
--- a/src/test/modules/dummy_index_am/dummy_index_am.c
+++ b/src/test/modules/dummy_index_am/dummy_index_am.c
@@ -29,7 +29,7 @@ void		_PG_init(void);
 relopt_parse_elt di_relopt_tab[6];
 
 /* Kind of relation options for dummy index */
-relopt_kind di_relopt_kind;
+int di_relopt_kind;
 
 typedef enum DummyAmEnum
 {
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index a9dca717a6..229fa80675 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -2583,7 +2583,6 @@ TupleQueueReader
 TupleTableSlot
 TupleTableSlotOps
 TuplesortInstrumentation
-TuplesortMethod
 TuplesortSpaceType
 Tuplesortstate
 Tuplestorestate
@@ -3309,7 +3308,6 @@ relopt_enum
 relopt_enum_elt_def
 relopt_gen
 relopt_int
-relopt_kind
 relopt_parse_elt
 relopt_real
 relopt_string
-- 
2.17.0

