Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4be613f

Browse files
committed
pg_dump: Rename some typedefs to avoid name conflicts
In struct _archiveHandle, some of the fields have the same name as a typedef. This is kind of confusing, so rename the types so they have names distinct from the struct fields. In C++, the previous coding changes the meaning of the typedef in the scope of the struct, causing warnings and possibly other problems. Reviewed-by: Andres Freund <andres@anarazel.de>
1 parent 20c95f2 commit 4be613f

File tree

3 files changed

+55
-55
lines changed

3 files changed

+55
-55
lines changed

src/bin/pg_dump/pg_backup.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ typedef int DumpId;
230230

231231
typedef int (*DataDumperPtr) (Archive *AH, void *userArg);
232232

233-
typedef void (*SetupWorkerPtr) (Archive *AH);
233+
typedef void (*SetupWorkerPtrType) (Archive *AH);
234234

235235
/*
236236
* Main archiver interface.
@@ -277,7 +277,7 @@ extern Archive *OpenArchive(const char *FileSpec, const ArchiveFormat fmt);
277277
/* Create a new archive */
278278
extern Archive *CreateArchive(const char *FileSpec, const ArchiveFormat fmt,
279279
const int compression, bool dosync, ArchiveMode mode,
280-
SetupWorkerPtr setupDumpWorker);
280+
SetupWorkerPtrType setupDumpWorker);
281281

282282
/* The --list option */
283283
extern void PrintTOCSummary(Archive *AH);

src/bin/pg_dump/pg_backup_archiver.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static const char *modulename = gettext_noop("archiver");
5555

5656
static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
5757
const int compression, bool dosync, ArchiveMode mode,
58-
SetupWorkerPtr setupWorkerPtr);
58+
SetupWorkerPtrType setupWorkerPtr);
5959
static void _getObjectDescription(PQExpBuffer buf, TocEntry *te,
6060
ArchiveHandle *AH);
6161
static void _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData, bool acl_pass);
@@ -204,7 +204,7 @@ setupRestoreWorker(Archive *AHX)
204204
Archive *
205205
CreateArchive(const char *FileSpec, const ArchiveFormat fmt,
206206
const int compression, bool dosync, ArchiveMode mode,
207-
SetupWorkerPtr setupDumpWorker)
207+
SetupWorkerPtrType setupDumpWorker)
208208

209209
{
210210
ArchiveHandle *AH = _allocAH(FileSpec, fmt, compression, dosync,
@@ -2273,7 +2273,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
22732273
static ArchiveHandle *
22742274
_allocAH(const char *FileSpec, const ArchiveFormat fmt,
22752275
const int compression, bool dosync, ArchiveMode mode,
2276-
SetupWorkerPtr setupWorkerPtr)
2276+
SetupWorkerPtrType setupWorkerPtr)
22772277
{
22782278
ArchiveHandle *AH;
22792279

@@ -2446,8 +2446,8 @@ mark_dump_job_done(ArchiveHandle *AH,
24462446
void
24472447
WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te)
24482448
{
2449-
StartDataPtr startPtr;
2450-
EndDataPtr endPtr;
2449+
StartDataPtrType startPtr;
2450+
EndDataPtrType endPtr;
24512451

24522452
AH->currToc = te;
24532453

src/bin/pg_dump/pg_backup_archiver.h

+48-48
Original file line numberDiff line numberDiff line change
@@ -143,36 +143,36 @@ typedef enum T_Action
143143
ACT_RESTORE
144144
} T_Action;
145145

146-
typedef void (*ClosePtr) (ArchiveHandle *AH);
147-
typedef void (*ReopenPtr) (ArchiveHandle *AH);
148-
typedef void (*ArchiveEntryPtr) (ArchiveHandle *AH, TocEntry *te);
146+
typedef void (*ClosePtrType) (ArchiveHandle *AH);
147+
typedef void (*ReopenPtrType) (ArchiveHandle *AH);
148+
typedef void (*ArchiveEntryPtrType) (ArchiveHandle *AH, TocEntry *te);
149149

150-
typedef void (*StartDataPtr) (ArchiveHandle *AH, TocEntry *te);
151-
typedef void (*WriteDataPtr) (ArchiveHandle *AH, const void *data, size_t dLen);
152-
typedef void (*EndDataPtr) (ArchiveHandle *AH, TocEntry *te);
150+
typedef void (*StartDataPtrType) (ArchiveHandle *AH, TocEntry *te);
151+
typedef void (*WriteDataPtrType) (ArchiveHandle *AH, const void *data, size_t dLen);
152+
typedef void (*EndDataPtrType) (ArchiveHandle *AH, TocEntry *te);
153153

154-
typedef void (*StartBlobsPtr) (ArchiveHandle *AH, TocEntry *te);
155-
typedef void (*StartBlobPtr) (ArchiveHandle *AH, TocEntry *te, Oid oid);
156-
typedef void (*EndBlobPtr) (ArchiveHandle *AH, TocEntry *te, Oid oid);
157-
typedef void (*EndBlobsPtr) (ArchiveHandle *AH, TocEntry *te);
154+
typedef void (*StartBlobsPtrType) (ArchiveHandle *AH, TocEntry *te);
155+
typedef void (*StartBlobPtrType) (ArchiveHandle *AH, TocEntry *te, Oid oid);
156+
typedef void (*EndBlobPtrType) (ArchiveHandle *AH, TocEntry *te, Oid oid);
157+
typedef void (*EndBlobsPtrType) (ArchiveHandle *AH, TocEntry *te);
158158

159-
typedef int (*WriteBytePtr) (ArchiveHandle *AH, const int i);
160-
typedef int (*ReadBytePtr) (ArchiveHandle *AH);
161-
typedef void (*WriteBufPtr) (ArchiveHandle *AH, const void *c, size_t len);
162-
typedef void (*ReadBufPtr) (ArchiveHandle *AH, void *buf, size_t len);
163-
typedef void (*SaveArchivePtr) (ArchiveHandle *AH);
164-
typedef void (*WriteExtraTocPtr) (ArchiveHandle *AH, TocEntry *te);
165-
typedef void (*ReadExtraTocPtr) (ArchiveHandle *AH, TocEntry *te);
166-
typedef void (*PrintExtraTocPtr) (ArchiveHandle *AH, TocEntry *te);
167-
typedef void (*PrintTocDataPtr) (ArchiveHandle *AH, TocEntry *te);
159+
typedef int (*WriteBytePtrType) (ArchiveHandle *AH, const int i);
160+
typedef int (*ReadBytePtrType) (ArchiveHandle *AH);
161+
typedef void (*WriteBufPtrType) (ArchiveHandle *AH, const void *c, size_t len);
162+
typedef void (*ReadBufPtrType) (ArchiveHandle *AH, void *buf, size_t len);
163+
typedef void (*SaveArchivePtrType) (ArchiveHandle *AH);
164+
typedef void (*WriteExtraTocPtrType) (ArchiveHandle *AH, TocEntry *te);
165+
typedef void (*ReadExtraTocPtrType) (ArchiveHandle *AH, TocEntry *te);
166+
typedef void (*PrintExtraTocPtrType) (ArchiveHandle *AH, TocEntry *te);
167+
typedef void (*PrintTocDataPtrType) (ArchiveHandle *AH, TocEntry *te);
168168

169-
typedef void (*ClonePtr) (ArchiveHandle *AH);
170-
typedef void (*DeClonePtr) (ArchiveHandle *AH);
169+
typedef void (*ClonePtrType) (ArchiveHandle *AH);
170+
typedef void (*DeClonePtrType) (ArchiveHandle *AH);
171171

172-
typedef int (*WorkerJobDumpPtr) (ArchiveHandle *AH, TocEntry *te);
173-
typedef int (*WorkerJobRestorePtr) (ArchiveHandle *AH, TocEntry *te);
172+
typedef int (*WorkerJobDumpPtrType) (ArchiveHandle *AH, TocEntry *te);
173+
typedef int (*WorkerJobRestorePtrType) (ArchiveHandle *AH, TocEntry *te);
174174

175-
typedef size_t (*CustomOutPtr) (ArchiveHandle *AH, const void *buf, size_t len);
175+
typedef size_t (*CustomOutPtrType) (ArchiveHandle *AH, const void *buf, size_t len);
176176

177177
typedef enum
178178
{
@@ -242,39 +242,39 @@ struct _archiveHandle
242242
size_t lookaheadLen; /* Length of data in lookahead */
243243
pgoff_t lookaheadPos; /* Current read position in lookahead buffer */
244244

245-
ArchiveEntryPtr ArchiveEntryPtr; /* Called for each metadata object */
246-
StartDataPtr StartDataPtr; /* Called when table data is about to be
245+
ArchiveEntryPtrType ArchiveEntryPtr; /* Called for each metadata object */
246+
StartDataPtrType StartDataPtr; /* Called when table data is about to be
247247
* dumped */
248-
WriteDataPtr WriteDataPtr; /* Called to send some table data to the
248+
WriteDataPtrType WriteDataPtr; /* Called to send some table data to the
249249
* archive */
250-
EndDataPtr EndDataPtr; /* Called when table data dump is finished */
251-
WriteBytePtr WriteBytePtr; /* Write a byte to output */
252-
ReadBytePtr ReadBytePtr; /* Read a byte from an archive */
253-
WriteBufPtr WriteBufPtr; /* Write a buffer of output to the archive */
254-
ReadBufPtr ReadBufPtr; /* Read a buffer of input from the archive */
255-
ClosePtr ClosePtr; /* Close the archive */
256-
ReopenPtr ReopenPtr; /* Reopen the archive */
257-
WriteExtraTocPtr WriteExtraTocPtr; /* Write extra TOC entry data
250+
EndDataPtrType EndDataPtr; /* Called when table data dump is finished */
251+
WriteBytePtrType WriteBytePtr; /* Write a byte to output */
252+
ReadBytePtrType ReadBytePtr; /* Read a byte from an archive */
253+
WriteBufPtrType WriteBufPtr; /* Write a buffer of output to the archive */
254+
ReadBufPtrType ReadBufPtr; /* Read a buffer of input from the archive */
255+
ClosePtrType ClosePtr; /* Close the archive */
256+
ReopenPtrType ReopenPtr; /* Reopen the archive */
257+
WriteExtraTocPtrType WriteExtraTocPtr; /* Write extra TOC entry data
258258
* associated with the current archive
259259
* format */
260-
ReadExtraTocPtr ReadExtraTocPtr; /* Read extr info associated with
260+
ReadExtraTocPtrType ReadExtraTocPtr; /* Read extr info associated with
261261
* archie format */
262-
PrintExtraTocPtr PrintExtraTocPtr; /* Extra TOC info for format */
263-
PrintTocDataPtr PrintTocDataPtr;
262+
PrintExtraTocPtrType PrintExtraTocPtr; /* Extra TOC info for format */
263+
PrintTocDataPtrType PrintTocDataPtr;
264264

265-
StartBlobsPtr StartBlobsPtr;
266-
EndBlobsPtr EndBlobsPtr;
267-
StartBlobPtr StartBlobPtr;
268-
EndBlobPtr EndBlobPtr;
265+
StartBlobsPtrType StartBlobsPtr;
266+
EndBlobsPtrType EndBlobsPtr;
267+
StartBlobPtrType StartBlobPtr;
268+
EndBlobPtrType EndBlobPtr;
269269

270-
SetupWorkerPtr SetupWorkerPtr;
271-
WorkerJobDumpPtr WorkerJobDumpPtr;
272-
WorkerJobRestorePtr WorkerJobRestorePtr;
270+
SetupWorkerPtrType SetupWorkerPtr;
271+
WorkerJobDumpPtrType WorkerJobDumpPtr;
272+
WorkerJobRestorePtrType WorkerJobRestorePtr;
273273

274-
ClonePtr ClonePtr; /* Clone format-specific fields */
275-
DeClonePtr DeClonePtr; /* Clean up cloned fields */
274+
ClonePtrType ClonePtr; /* Clone format-specific fields */
275+
DeClonePtrType DeClonePtr; /* Clean up cloned fields */
276276

277-
CustomOutPtr CustomOutPtr; /* Alternative script output routine */
277+
CustomOutPtrType CustomOutPtr; /* Alternative script output routine */
278278

279279
/* Stuff for direct DB connection */
280280
char *archdbname; /* DB name *read* from archive */

0 commit comments

Comments
 (0)