pg_dump: Don't use enums for defining bit mask values

This usage would mean that values of the enum type are potentially not
one of the enum values.  Use macros instead, like everywhere else.

Discussion: https://www.postgresql.org/message-id/14dde730-1d34-260e-fa9d-7664df2d6313@enterprisedb.com
This commit is contained in:
Peter Eisentraut 2020-12-11 19:15:30 +01:00
parent 525e60b742
commit d2a2808eb4
3 changed files with 15 additions and 20 deletions

View File

@ -86,7 +86,7 @@ static void _selectTableAccessMethod(ArchiveHandle *AH, const char *tableam);
static void processEncodingEntry(ArchiveHandle *AH, TocEntry *te); static void processEncodingEntry(ArchiveHandle *AH, TocEntry *te);
static void processStdStringsEntry(ArchiveHandle *AH, TocEntry *te); static void processStdStringsEntry(ArchiveHandle *AH, TocEntry *te);
static void processSearchPathEntry(ArchiveHandle *AH, TocEntry *te); static void processSearchPathEntry(ArchiveHandle *AH, TocEntry *te);
static teReqs _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH); static int _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH);
static RestorePass _tocEntryRestorePass(TocEntry *te); static RestorePass _tocEntryRestorePass(TocEntry *te);
static bool _tocEntryIsACL(TocEntry *te); static bool _tocEntryIsACL(TocEntry *te);
static void _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te); static void _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te);
@ -757,7 +757,7 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te, bool is_parallel)
{ {
RestoreOptions *ropt = AH->public.ropt; RestoreOptions *ropt = AH->public.ropt;
int status = WORKER_OK; int status = WORKER_OK;
teReqs reqs; int reqs;
bool defnDumped; bool defnDumped;
AH->currentTE = te; AH->currentTE = te;
@ -1868,7 +1868,7 @@ getTocEntryByDumpId(ArchiveHandle *AH, DumpId id)
return NULL; return NULL;
} }
teReqs int
TocIDRequired(ArchiveHandle *AH, DumpId id) TocIDRequired(ArchiveHandle *AH, DumpId id)
{ {
TocEntry *te = getTocEntryByDumpId(AH, id); TocEntry *te = getTocEntryByDumpId(AH, id);
@ -2803,10 +2803,10 @@ StrictNamesCheck(RestoreOptions *ropt)
* REQ_SCHEMA and REQ_DATA bits if we want to restore schema and/or data * REQ_SCHEMA and REQ_DATA bits if we want to restore schema and/or data
* portions of this TOC entry, or REQ_SPECIAL if it's a special entry. * portions of this TOC entry, or REQ_SPECIAL if it's a special entry.
*/ */
static teReqs static int
_tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH) _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH)
{ {
teReqs res = REQ_SCHEMA | REQ_DATA; int res = REQ_SCHEMA | REQ_DATA;
RestoreOptions *ropt = AH->public.ropt; RestoreOptions *ropt = AH->public.ropt;
/* These items are treated specially */ /* These items are treated specially */

View File

@ -229,12 +229,9 @@ typedef enum
#define RESTORE_PASS_LAST RESTORE_PASS_POST_ACL #define RESTORE_PASS_LAST RESTORE_PASS_POST_ACL
} RestorePass; } RestorePass;
typedef enum #define REQ_SCHEMA 0x01 /* want schema */
{ #define REQ_DATA 0x02 /* want data */
REQ_SCHEMA = 0x01, /* want schema */ #define REQ_SPECIAL 0x04 /* for special TOC entries */
REQ_DATA = 0x02, /* want data */
REQ_SPECIAL = 0x04 /* for special TOC entries */
} teReqs;
struct _archiveHandle struct _archiveHandle
{ {
@ -386,7 +383,7 @@ struct _tocEntry
/* working state while dumping/restoring */ /* working state while dumping/restoring */
pgoff_t dataLength; /* item's data size; 0 if none or unknown */ pgoff_t dataLength; /* item's data size; 0 if none or unknown */
teReqs reqs; /* do we need schema and/or data of object */ int reqs; /* do we need schema and/or data of object (REQ_* bit mask) */
bool created; /* set for DATA member if TABLE was created */ bool created; /* set for DATA member if TABLE was created */
/* working state (needed only for parallel restore) */ /* working state (needed only for parallel restore) */
@ -436,7 +433,7 @@ extern void WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te);
extern ArchiveHandle *CloneArchive(ArchiveHandle *AH); extern ArchiveHandle *CloneArchive(ArchiveHandle *AH);
extern void DeCloneArchive(ArchiveHandle *AH); extern void DeCloneArchive(ArchiveHandle *AH);
extern teReqs TocIDRequired(ArchiveHandle *AH, DumpId id); extern int TocIDRequired(ArchiveHandle *AH, DumpId id);
TocEntry *getTocEntryByDumpId(ArchiveHandle *AH, DumpId id); TocEntry *getTocEntryByDumpId(ArchiveHandle *AH, DumpId id);
extern bool checkSeek(FILE *fp); extern bool checkSeek(FILE *fp);

View File

@ -17,13 +17,11 @@
#include "common/logging.h" #include "common/logging.h"
typedef enum /* bits returned by set_dump_section */ /* bits returned by set_dump_section */
{ #define DUMP_PRE_DATA 0x01
DUMP_PRE_DATA = 0x01, #define DUMP_DATA 0x02
DUMP_DATA = 0x02, #define DUMP_POST_DATA 0x04
DUMP_POST_DATA = 0x04, #define DUMP_UNSECTIONED 0xff
DUMP_UNSECTIONED = 0xff
} DumpSections;
typedef void (*on_exit_nicely_callback) (int code, void *arg); typedef void (*on_exit_nicely_callback) (int code, void *arg);