Skip to content

Commit d2a2808

Browse files
committed
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
1 parent 525e60b commit d2a2808

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static void _selectTableAccessMethod(ArchiveHandle *AH, const char *tableam);
8686
static void processEncodingEntry(ArchiveHandle *AH, TocEntry *te);
8787
static void processStdStringsEntry(ArchiveHandle *AH, TocEntry *te);
8888
static void processSearchPathEntry(ArchiveHandle *AH, TocEntry *te);
89-
static teReqs _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH);
89+
static int _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH);
9090
static RestorePass _tocEntryRestorePass(TocEntry *te);
9191
static bool _tocEntryIsACL(TocEntry *te);
9292
static void _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te);
@@ -757,7 +757,7 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te, bool is_parallel)
757757
{
758758
RestoreOptions *ropt = AH->public.ropt;
759759
int status = WORKER_OK;
760-
teReqs reqs;
760+
int reqs;
761761
bool defnDumped;
762762

763763
AH->currentTE = te;
@@ -1868,7 +1868,7 @@ getTocEntryByDumpId(ArchiveHandle *AH, DumpId id)
18681868
return NULL;
18691869
}
18701870

1871-
teReqs
1871+
int
18721872
TocIDRequired(ArchiveHandle *AH, DumpId id)
18731873
{
18741874
TocEntry *te = getTocEntryByDumpId(AH, id);
@@ -2803,10 +2803,10 @@ StrictNamesCheck(RestoreOptions *ropt)
28032803
* REQ_SCHEMA and REQ_DATA bits if we want to restore schema and/or data
28042804
* portions of this TOC entry, or REQ_SPECIAL if it's a special entry.
28052805
*/
2806-
static teReqs
2806+
static int
28072807
_tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH)
28082808
{
2809-
teReqs res = REQ_SCHEMA | REQ_DATA;
2809+
int res = REQ_SCHEMA | REQ_DATA;
28102810
RestoreOptions *ropt = AH->public.ropt;
28112811

28122812
/* These items are treated specially */

src/bin/pg_dump/pg_backup_archiver.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,9 @@ typedef enum
229229
#define RESTORE_PASS_LAST RESTORE_PASS_POST_ACL
230230
} RestorePass;
231231

232-
typedef enum
233-
{
234-
REQ_SCHEMA = 0x01, /* want schema */
235-
REQ_DATA = 0x02, /* want data */
236-
REQ_SPECIAL = 0x04 /* for special TOC entries */
237-
} teReqs;
232+
#define REQ_SCHEMA 0x01 /* want schema */
233+
#define REQ_DATA 0x02 /* want data */
234+
#define REQ_SPECIAL 0x04 /* for special TOC entries */
238235

239236
struct _archiveHandle
240237
{
@@ -386,7 +383,7 @@ struct _tocEntry
386383

387384
/* working state while dumping/restoring */
388385
pgoff_t dataLength; /* item's data size; 0 if none or unknown */
389-
teReqs reqs; /* do we need schema and/or data of object */
386+
int reqs; /* do we need schema and/or data of object (REQ_* bit mask) */
390387
bool created; /* set for DATA member if TABLE was created */
391388

392389
/* working state (needed only for parallel restore) */
@@ -436,7 +433,7 @@ extern void WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te);
436433
extern ArchiveHandle *CloneArchive(ArchiveHandle *AH);
437434
extern void DeCloneArchive(ArchiveHandle *AH);
438435

439-
extern teReqs TocIDRequired(ArchiveHandle *AH, DumpId id);
436+
extern int TocIDRequired(ArchiveHandle *AH, DumpId id);
440437
TocEntry *getTocEntryByDumpId(ArchiveHandle *AH, DumpId id);
441438
extern bool checkSeek(FILE *fp);
442439

src/bin/pg_dump/pg_backup_utils.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717

1818
#include "common/logging.h"
1919

20-
typedef enum /* bits returned by set_dump_section */
21-
{
22-
DUMP_PRE_DATA = 0x01,
23-
DUMP_DATA = 0x02,
24-
DUMP_POST_DATA = 0x04,
25-
DUMP_UNSECTIONED = 0xff
26-
} DumpSections;
20+
/* bits returned by set_dump_section */
21+
#define DUMP_PRE_DATA 0x01
22+
#define DUMP_DATA 0x02
23+
#define DUMP_POST_DATA 0x04
24+
#define DUMP_UNSECTIONED 0xff
2725

2826
typedef void (*on_exit_nicely_callback) (int code, void *arg);
2927

0 commit comments

Comments
 (0)