Skip to content

Commit

Permalink
Add trailing commas to enum definitions
Browse files Browse the repository at this point in the history
Since C99, there can be a trailing comma after the last value in an
enum definition.  A lot of new code has been introducing this style on
the fly.  Some new patches are now taking an inconsistent approach to
this.  Some add the last comma on the fly if they add a new last
value, some are trying to preserve the existing style in each place,
some are even dropping the last comma if there was one.  We could
nudge this all in a consistent direction if we just add the trailing
commas everywhere once.

I omitted a few places where there was a fixed "last" value that will
always stay last.  I also skipped the header files of libpq and ecpg,
in case people want to use those with older compilers.  There were
also a small number of cases where the enum type wasn't used anywhere
(but the enum values were), which ended up confusing pgindent a bit,
so I left those alone.

Discussion: https://www.postgresql.org/message-id/flat/386f8c45-c8ac-4681-8add-e3b0852c1620%40eisentraut.org
  • Loading branch information
petere committed Oct 26, 2023
1 parent f0efa5a commit 611806c
Show file tree
Hide file tree
Showing 212 changed files with 390 additions and 390 deletions.
6 changes: 3 additions & 3 deletions contrib/amcheck/verify_heapam.c
Expand Up @@ -43,22 +43,22 @@ typedef enum XidBoundsViolation
XID_IN_FUTURE,
XID_PRECEDES_CLUSTERMIN,
XID_PRECEDES_RELMIN,
XID_BOUNDS_OK
XID_BOUNDS_OK,
} XidBoundsViolation;

typedef enum XidCommitStatus
{
XID_COMMITTED,
XID_IS_CURRENT_XID,
XID_IN_PROGRESS,
XID_ABORTED
XID_ABORTED,
} XidCommitStatus;

typedef enum SkipPages
{
SKIP_PAGES_ALL_FROZEN,
SKIP_PAGES_ALL_VISIBLE,
SKIP_PAGES_NONE
SKIP_PAGES_NONE,
} SkipPages;

/*
Expand Down
2 changes: 1 addition & 1 deletion contrib/btree_gist/btree_gist.h
Expand Up @@ -35,7 +35,7 @@ enum gbtree_type
gbt_t_bool,
gbt_t_inet,
gbt_t_uuid,
gbt_t_enum
gbt_t_enum,
};

#endif
2 changes: 1 addition & 1 deletion contrib/pg_prewarm/pg_prewarm.c
Expand Up @@ -33,7 +33,7 @@ typedef enum
{
PREWARM_PREFETCH,
PREWARM_READ,
PREWARM_BUFFER
PREWARM_BUFFER,
} PrewarmType;

static PGIOAlignedBlock blockbuffer;
Expand Down
4 changes: 2 additions & 2 deletions contrib/pg_stat_statements/pg_stat_statements.c
Expand Up @@ -118,7 +118,7 @@ typedef enum pgssVersion
PGSS_V1_8,
PGSS_V1_9,
PGSS_V1_10,
PGSS_V1_11
PGSS_V1_11,
} pgssVersion;

typedef enum pgssStoreKind
Expand Down Expand Up @@ -282,7 +282,7 @@ typedef enum
{
PGSS_TRACK_NONE, /* track no statements */
PGSS_TRACK_TOP, /* only top level statements */
PGSS_TRACK_ALL /* all statements, including nested ones */
PGSS_TRACK_ALL, /* all statements, including nested ones */
} PGSSTrackLevel;

static const struct config_enum_entry track_options[] =
Expand Down
2 changes: 1 addition & 1 deletion contrib/pg_surgery/heap_surgery.c
Expand Up @@ -29,7 +29,7 @@ PG_MODULE_MAGIC;
typedef enum HeapTupleForceOption
{
HEAP_FORCE_KILL,
HEAP_FORCE_FREEZE
HEAP_FORCE_FREEZE,
} HeapTupleForceOption;

PG_FUNCTION_INFO_V1(heap_force_kill);
Expand Down
12 changes: 6 additions & 6 deletions contrib/pgcrypto/pgp.h
Expand Up @@ -38,7 +38,7 @@ enum PGP_S2K_TYPE
{
PGP_S2K_SIMPLE = 0,
PGP_S2K_SALTED = 1,
PGP_S2K_ISALTED = 3
PGP_S2K_ISALTED = 3,
};

enum PGP_PKT_TYPE
Expand All @@ -60,7 +60,7 @@ enum PGP_PKT_TYPE
PGP_PKT_USER_ATTR = 17,
PGP_PKT_SYMENCRYPTED_DATA_MDC = 18,
PGP_PKT_MDC = 19,
PGP_PKT_PRIV_61 = 61 /* occurs in gpg secring */
PGP_PKT_PRIV_61 = 61, /* occurs in gpg secring */
};

enum PGP_PUB_ALGO_TYPE
Expand All @@ -69,7 +69,7 @@ enum PGP_PUB_ALGO_TYPE
PGP_PUB_RSA_ENCRYPT = 2,
PGP_PUB_RSA_SIGN = 3,
PGP_PUB_ELG_ENCRYPT = 16,
PGP_PUB_DSA_SIGN = 17
PGP_PUB_DSA_SIGN = 17,
};

enum PGP_SYMENC_TYPE
Expand All @@ -84,15 +84,15 @@ enum PGP_SYMENC_TYPE
PGP_SYM_AES_128 = 7, /* should */
PGP_SYM_AES_192 = 8,
PGP_SYM_AES_256 = 9,
PGP_SYM_TWOFISH = 10
PGP_SYM_TWOFISH = 10,
};

enum PGP_COMPR_TYPE
{
PGP_COMPR_NONE = 0, /* must */
PGP_COMPR_ZIP = 1, /* should */
PGP_COMPR_ZLIB = 2,
PGP_COMPR_BZIP2 = 3
PGP_COMPR_BZIP2 = 3,
};

enum PGP_DIGEST_TYPE
Expand All @@ -106,7 +106,7 @@ enum PGP_DIGEST_TYPE
PGP_DIGEST_HAVAL5_160 = 7, /* obsolete */
PGP_DIGEST_SHA256 = 8,
PGP_DIGEST_SHA384 = 9,
PGP_DIGEST_SHA512 = 10
PGP_DIGEST_SHA512 = 10,
};

#define PGP_MAX_KEY (256/8)
Expand Down
2 changes: 1 addition & 1 deletion contrib/postgres_fdw/deparse.c
Expand Up @@ -83,7 +83,7 @@ typedef enum
* it has default collation that is not
* traceable to a foreign Var */
FDW_COLLATE_SAFE, /* collation derives from a foreign Var */
FDW_COLLATE_UNSAFE /* collation is non-default and derives from
FDW_COLLATE_UNSAFE, /* collation is non-default and derives from
* something other than a foreign Var */
} FDWCollateState;

Expand Down
8 changes: 4 additions & 4 deletions contrib/postgres_fdw/postgres_fdw.c
Expand Up @@ -82,7 +82,7 @@ enum FdwScanPrivateIndex
* String describing join i.e. names of relations being joined and types
* of join, added when the scan is join
*/
FdwScanPrivateRelations
FdwScanPrivateRelations,
};

/*
Expand All @@ -108,7 +108,7 @@ enum FdwModifyPrivateIndex
/* has-returning flag (as a Boolean node) */
FdwModifyPrivateHasReturning,
/* Integer list of attribute numbers retrieved by RETURNING */
FdwModifyPrivateRetrievedAttrs
FdwModifyPrivateRetrievedAttrs,
};

/*
Expand All @@ -129,7 +129,7 @@ enum FdwDirectModifyPrivateIndex
/* Integer list of attribute numbers retrieved by RETURNING */
FdwDirectModifyPrivateRetrievedAttrs,
/* set-processed flag (as a Boolean node) */
FdwDirectModifyPrivateSetProcessed
FdwDirectModifyPrivateSetProcessed,
};

/*
Expand Down Expand Up @@ -285,7 +285,7 @@ enum FdwPathPrivateIndex
/* has-final-sort flag (as a Boolean node) */
FdwPathPrivateHasFinalSort,
/* has-limit flag (as a Boolean node) */
FdwPathPrivateHasLimit
FdwPathPrivateHasLimit,
};

/* Struct for extra information passed to estimate_path_cost_size() */
Expand Down
2 changes: 1 addition & 1 deletion contrib/postgres_fdw/postgres_fdw.h
Expand Up @@ -143,7 +143,7 @@ typedef enum PgFdwSamplingMethod
ANALYZE_SAMPLE_AUTO, /* choose by server version */
ANALYZE_SAMPLE_RANDOM, /* remote random() */
ANALYZE_SAMPLE_SYSTEM, /* TABLESAMPLE system */
ANALYZE_SAMPLE_BERNOULLI /* TABLESAMPLE bernoulli */
ANALYZE_SAMPLE_BERNOULLI, /* TABLESAMPLE bernoulli */
} PgFdwSamplingMethod;

/* in postgres_fdw.c */
Expand Down
2 changes: 1 addition & 1 deletion contrib/vacuumlo/vacuumlo.c
Expand Up @@ -35,7 +35,7 @@ enum trivalue
{
TRI_DEFAULT,
TRI_NO,
TRI_YES
TRI_YES,
};

struct _param
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/gist/gistbuild.c
Expand Up @@ -75,7 +75,7 @@ typedef enum
GIST_BUFFERING_STATS, /* gathering statistics of index tuple size
* before switching to the buffering build
* mode */
GIST_BUFFERING_ACTIVE /* in buffering build mode */
GIST_BUFFERING_ACTIVE, /* in buffering build mode */
} GistBuildMode;

/* Working state for gistbuild and its callback */
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/heap/vacuumlazy.c
Expand Up @@ -135,7 +135,7 @@ typedef enum
VACUUM_ERRCB_PHASE_VACUUM_INDEX,
VACUUM_ERRCB_PHASE_VACUUM_HEAP,
VACUUM_ERRCB_PHASE_INDEX_CLEANUP,
VACUUM_ERRCB_PHASE_TRUNCATE
VACUUM_ERRCB_PHASE_TRUNCATE,
} VacErrPhase;

typedef struct LVRelState
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/nbtree/nbtree.c
Expand Up @@ -56,7 +56,7 @@ typedef enum
BTPARALLEL_NOT_INITIALIZED,
BTPARALLEL_ADVANCING,
BTPARALLEL_IDLE,
BTPARALLEL_DONE
BTPARALLEL_DONE,
} BTPS_State;

/*
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/nbtree/nbtsplitloc.c
Expand Up @@ -22,7 +22,7 @@ typedef enum
/* strategy for searching through materialized list of split points */
SPLIT_DEFAULT, /* give some weight to truncation */
SPLIT_MANY_DUPLICATES, /* find minimally distinguishing point */
SPLIT_SINGLE_VALUE /* leave left page almost full */
SPLIT_SINGLE_VALUE, /* leave left page almost full */
} FindSplitStrat;

typedef struct
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/spgist/spgscan.c
Expand Up @@ -756,7 +756,7 @@ enum SpGistSpecialOffsetNumbers
{
SpGistBreakOffsetNumber = InvalidOffsetNumber,
SpGistRedirectOffsetNumber = MaxOffsetNumber + 1,
SpGistErrorOffsetNumber = MaxOffsetNumber + 2
SpGistErrorOffsetNumber = MaxOffsetNumber + 2,
};

static OffsetNumber
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/transam/slru.c
Expand Up @@ -128,7 +128,7 @@ typedef enum
SLRU_READ_FAILED,
SLRU_WRITE_FAILED,
SLRU_FSYNC_FAILED,
SLRU_CLOSE_FAILED
SLRU_CLOSE_FAILED,
} SlruErrorCause;

static SlruErrorCause slru_errcause;
Expand Down
4 changes: 2 additions & 2 deletions src/backend/access/transam/xact.c
Expand Up @@ -145,7 +145,7 @@ typedef enum TransState
TRANS_INPROGRESS, /* inside a valid transaction */
TRANS_COMMIT, /* commit in progress */
TRANS_ABORT, /* abort in progress */
TRANS_PREPARE /* prepare in progress */
TRANS_PREPARE, /* prepare in progress */
} TransState;

/*
Expand Down Expand Up @@ -180,7 +180,7 @@ typedef enum TBlockState
TBLOCK_SUBABORT_END, /* failed subxact, ROLLBACK received */
TBLOCK_SUBABORT_PENDING, /* live subxact, ROLLBACK received */
TBLOCK_SUBRESTART, /* live subxact, ROLLBACK TO received */
TBLOCK_SUBABORT_RESTART /* failed subxact, ROLLBACK TO received */
TBLOCK_SUBABORT_RESTART, /* failed subxact, ROLLBACK TO received */
} TBlockState;

/*
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/transam/xlogprefetcher.c
Expand Up @@ -88,7 +88,7 @@ typedef enum
{
LRQ_NEXT_NO_IO,
LRQ_NEXT_IO,
LRQ_NEXT_AGAIN
LRQ_NEXT_AGAIN,
} LsnReadQueueNextStatus;

/*
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/transam/xlogrecovery.c
Expand Up @@ -211,7 +211,7 @@ typedef enum
XLOG_FROM_ANY = 0, /* request to read WAL from any source */
XLOG_FROM_ARCHIVE, /* restored using restore_command */
XLOG_FROM_PG_WAL, /* existing file in pg_wal */
XLOG_FROM_STREAM /* streamed from primary */
XLOG_FROM_STREAM, /* streamed from primary */
} XLogSource;

/* human-readable names for XLogSources, for debugging output */
Expand Down
2 changes: 1 addition & 1 deletion src/backend/catalog/pg_shdepend.c
Expand Up @@ -73,7 +73,7 @@ typedef enum
{
LOCAL_OBJECT,
SHARED_OBJECT,
REMOTE_OBJECT
REMOTE_OBJECT,
} SharedDependencyObjectType;

typedef struct
Expand Down
2 changes: 1 addition & 1 deletion src/backend/commands/async.c
Expand Up @@ -351,7 +351,7 @@ typedef enum
{
LISTEN_LISTEN,
LISTEN_UNLISTEN,
LISTEN_UNLISTEN_ALL
LISTEN_UNLISTEN_ALL,
} ListenActionKind;

typedef struct
Expand Down
2 changes: 1 addition & 1 deletion src/backend/commands/copyto.c
Expand Up @@ -51,7 +51,7 @@ typedef enum CopyDest
{
COPY_FILE, /* to file (or a piped program) */
COPY_FRONTEND, /* to frontend */
COPY_CALLBACK /* to callback function */
COPY_CALLBACK, /* to callback function */
} CopyDest;

/*
Expand Down
2 changes: 1 addition & 1 deletion src/backend/commands/dbcommands.c
Expand Up @@ -83,7 +83,7 @@
typedef enum CreateDBStrategy
{
CREATEDB_WAL_LOG,
CREATEDB_FILE_COPY
CREATEDB_FILE_COPY,
} CreateDBStrategy;

typedef struct
Expand Down
2 changes: 1 addition & 1 deletion src/backend/commands/user.c
Expand Up @@ -64,7 +64,7 @@ typedef enum
RRG_REMOVE_ADMIN_OPTION,
RRG_REMOVE_INHERIT_OPTION,
RRG_REMOVE_SET_OPTION,
RRG_DELETE_GRANT
RRG_DELETE_GRANT,
} RevokeRoleGrantAction;

/* Potentially set by pg_upgrade_support functions */
Expand Down
2 changes: 1 addition & 1 deletion src/backend/commands/vacuumparallel.c
Expand Up @@ -118,7 +118,7 @@ typedef enum PVIndVacStatus
PARALLEL_INDVAC_STATUS_INITIAL = 0,
PARALLEL_INDVAC_STATUS_NEED_BULKDELETE,
PARALLEL_INDVAC_STATUS_NEED_CLEANUP,
PARALLEL_INDVAC_STATUS_COMPLETED
PARALLEL_INDVAC_STATUS_COMPLETED,
} PVIndVacStatus;

/*
Expand Down
2 changes: 1 addition & 1 deletion src/backend/executor/execIndexing.c
Expand Up @@ -121,7 +121,7 @@ typedef enum
{
CEOUC_WAIT,
CEOUC_NOWAIT,
CEOUC_LIVELOCK_PREVENTING_WAIT
CEOUC_LIVELOCK_PREVENTING_WAIT,
} CEOUC_WAIT_MODE;

static bool check_exclusion_or_unique_constraint(Relation heap, Relation index,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/executor/functions.c
Expand Up @@ -59,7 +59,7 @@ typedef struct
*/
typedef enum
{
F_EXEC_START, F_EXEC_RUN, F_EXEC_DONE
F_EXEC_START, F_EXEC_RUN, F_EXEC_DONE,
} ExecStatus;

typedef struct execution_state
Expand Down
2 changes: 1 addition & 1 deletion src/backend/executor/nodeMergejoin.c
Expand Up @@ -145,7 +145,7 @@ typedef enum
{
MJEVAL_MATCHABLE, /* normal, potentially matchable tuple */
MJEVAL_NONMATCHABLE, /* tuple cannot join because it has a null */
MJEVAL_ENDOFJOIN /* end of input (physical or effective) */
MJEVAL_ENDOFJOIN, /* end of input (physical or effective) */
} MJEvalResult;


Expand Down
2 changes: 1 addition & 1 deletion src/backend/executor/nodeTidrangescan.c
Expand Up @@ -39,7 +39,7 @@
typedef enum
{
TIDEXPR_UPPER_BOUND,
TIDEXPR_LOWER_BOUND
TIDEXPR_LOWER_BOUND,
} TidExprType;

/* Upper or lower range bound for scan */
Expand Down
2 changes: 1 addition & 1 deletion src/backend/libpq/auth-scram.c
Expand Up @@ -129,7 +129,7 @@ typedef enum
{
SCRAM_AUTH_INIT,
SCRAM_AUTH_SALT_SENT,
SCRAM_AUTH_FINISHED
SCRAM_AUTH_FINISHED,
} scram_state_enum;

typedef struct
Expand Down
4 changes: 2 additions & 2 deletions src/backend/nodes/tidbitmap.c
Expand Up @@ -129,7 +129,7 @@ typedef enum
{
TBM_EMPTY, /* no hashtable, nentries == 0 */
TBM_ONE_PAGE, /* entry1 contains the single entry */
TBM_HASH /* pagetable is valid, entry1 is not */
TBM_HASH, /* pagetable is valid, entry1 is not */
} TBMStatus;

/*
Expand All @@ -139,7 +139,7 @@ typedef enum
{
TBM_NOT_ITERATING, /* not yet converted to page and chunk array */
TBM_ITERATING_PRIVATE, /* converted to local page and chunk array */
TBM_ITERATING_SHARED /* converted to shared page and chunk array */
TBM_ITERATING_SHARED, /* converted to shared page and chunk array */
} TBMIteratingState;

/*
Expand Down

0 comments on commit 611806c

Please sign in to comment.