Skip to content

Commit 0d32cdc

Browse files
committed
Done. In backend/commands/define.c unused field is set to '-' for the
moment. A patch for CVS is attached, and I have amended my BLOB dumping version appropriately. Philip Warner
1 parent 793704d commit 0d32cdc

File tree

2 files changed

+215
-199
lines changed

2 files changed

+215
-199
lines changed

src/bin/pg_dump/pg_backup_archiver.h

+193-193
Original file line numberDiff line numberDiff line change
@@ -1,193 +1,193 @@
1-
/*-------------------------------------------------------------------------
2-
*
3-
* pg_backup_archiver.h
4-
*
5-
* Private interface to the pg_dump archiver routines.
6-
* It is NOT intended that these routines be called by any
7-
* dumper directly.
8-
*
9-
* See the headers to pg_restore for more details.
10-
*
11-
* Copyright (c) 2000, Philip Warner
12-
* Rights are granted to use this software in any way so long
13-
* as this notice is not removed.
14-
*
15-
* The author is not responsible for loss or damages that may
16-
* result from it's use.
17-
*
18-
*
19-
* IDENTIFICATION
20-
*
21-
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
22-
*
23-
* Initial version.
24-
*
25-
*-------------------------------------------------------------------------
26-
*/
27-
28-
#ifndef __PG_BACKUP_ARCHIVE__
29-
#define __PG_BACKUP_ARCHIVE__
30-
31-
#include <stdio.h>
32-
33-
#ifdef HAVE_LIBZ
34-
#include <zlib.h>
35-
#define GZCLOSE(fh) gzclose(fh)
36-
#define GZWRITE(p, s, n, fh) gzwrite(fh, p, n * s)
37-
#define GZREAD(p, s, n, fh) gzread(fh, p, n * s)
38-
#else
39-
#define GZCLOSE(fh) fclose(fh)
40-
#define GZWRITE(p, s, n, fh) fwrite(p, s, n, fh)
41-
#define GZREAD(p, s, n, fh) fread(p, s, n, fh)
42-
#define Z_DEFAULT_COMPRESSION -1
43-
44-
typedef struct _z_stream {
45-
void *next_in;
46-
void *next_out;
47-
int avail_in;
48-
int avail_out;
49-
} z_stream;
50-
typedef z_stream *z_streamp;
51-
#endif
52-
53-
#include "pg_backup.h"
54-
55-
#define K_VERS_MAJOR 1
56-
#define K_VERS_MINOR 2
57-
#define K_VERS_REV 1
58-
59-
/* Some important version numbers (checked in code) */
60-
#define K_VERS_1_0 (( (1 * 256 + 0) * 256 + 0) * 256 + 0)
61-
#define K_VERS_1_2 (( (1 * 256 + 2) * 256 + 0) * 256 + 0)
62-
#define K_VERS_MAX (( (1 * 256 + 2) * 256 + 255) * 256 + 0)
63-
64-
struct _archiveHandle;
65-
struct _tocEntry;
66-
struct _restoreList;
67-
68-
typedef void (*ClosePtr) (struct _archiveHandle* AH);
69-
typedef void (*ArchiveEntryPtr) (struct _archiveHandle* AH, struct _tocEntry* te);
70-
71-
typedef void (*StartDataPtr) (struct _archiveHandle* AH, struct _tocEntry* te);
72-
typedef int (*WriteDataPtr) (struct _archiveHandle* AH, const void* data, int dLen);
73-
typedef void (*EndDataPtr) (struct _archiveHandle* AH, struct _tocEntry* te);
74-
75-
typedef int (*WriteBytePtr) (struct _archiveHandle* AH, const int i);
76-
typedef int (*ReadBytePtr) (struct _archiveHandle* AH);
77-
typedef int (*WriteBufPtr) (struct _archiveHandle* AH, const void* c, int len);
78-
typedef int (*ReadBufPtr) (struct _archiveHandle* AH, void* buf, int len);
79-
typedef void (*SaveArchivePtr) (struct _archiveHandle* AH);
80-
typedef void (*WriteExtraTocPtr) (struct _archiveHandle* AH, struct _tocEntry* te);
81-
typedef void (*ReadExtraTocPtr) (struct _archiveHandle* AH, struct _tocEntry* te);
82-
typedef void (*PrintExtraTocPtr) (struct _archiveHandle* AH, struct _tocEntry* te);
83-
typedef void (*PrintTocDataPtr) (struct _archiveHandle* AH, struct _tocEntry* te,
84-
RestoreOptions *ropt);
85-
86-
typedef int (*TocSortCompareFn) (const void* te1, const void *te2);
87-
88-
typedef enum _archiveMode {
89-
archModeWrite,
90-
archModeRead
91-
} ArchiveMode;
92-
93-
typedef struct _outputContext {
94-
void *OF;
95-
int gzOut;
96-
} OutputContext;
97-
98-
typedef struct _archiveHandle {
99-
char vmaj; /* Version of file */
100-
char vmin;
101-
char vrev;
102-
int version; /* Conveniently formatted version */
103-
104-
int intSize; /* Size of an integer in the archive */
105-
ArchiveFormat format; /* Archive format */
106-
107-
int readHeader; /* Used if file header has been read already */
108-
109-
ArchiveEntryPtr ArchiveEntryPtr; /* Called for each metadata object */
110-
StartDataPtr StartDataPtr; /* Called when table data is about to be dumped */
111-
WriteDataPtr WriteDataPtr; /* Called to send some table data to the archive */
112-
EndDataPtr EndDataPtr; /* Called when table data dump is finished */
113-
WriteBytePtr WriteBytePtr; /* Write a byte to output */
114-
ReadBytePtr ReadBytePtr; /* */
115-
WriteBufPtr WriteBufPtr;
116-
ReadBufPtr ReadBufPtr;
117-
ClosePtr ClosePtr; /* Close the archive */
118-
WriteExtraTocPtr WriteExtraTocPtr; /* Write extra TOC entry data associated with */
119-
/* the current archive format */
120-
ReadExtraTocPtr ReadExtraTocPtr; /* Read extr info associated with archie format */
121-
PrintExtraTocPtr PrintExtraTocPtr; /* Extra TOC info for format */
122-
PrintTocDataPtr PrintTocDataPtr;
123-
124-
int lastID; /* Last internal ID for a TOC entry */
125-
char* fSpec; /* Archive File Spec */
126-
FILE *FH; /* General purpose file handle */
127-
void *OF;
128-
int gzOut; /* Output file */
129-
130-
struct _tocEntry* toc; /* List of TOC entries */
131-
int tocCount; /* Number of TOC entries */
132-
struct _tocEntry* currToc; /* Used when dumping data */
133-
char *currUser; /* Restore: current username in script */
134-
int compression; /* Compression requested on open */
135-
ArchiveMode mode; /* File mode - r or w */
136-
void* formatData; /* Header data specific to file format */
137-
138-
} ArchiveHandle;
139-
140-
typedef struct _tocEntry {
141-
struct _tocEntry* prev;
142-
struct _tocEntry* next;
143-
int id;
144-
int hadDumper; /* Archiver was passed a dumper routine (used in restore) */
145-
char* oid;
146-
int oidVal;
147-
char* name;
148-
char* desc;
149-
char* defn;
150-
char* dropStmt;
151-
char* owner;
152-
char** depOid;
153-
int printed; /* Indicates if entry defn has been dumped */
154-
DataDumperPtr dataDumper; /* Routine to dump data for object */
155-
void* dataDumperArg; /* Arg for above routine */
156-
void* formatData; /* TOC Entry data specific to file format */
157-
158-
int _moved; /* Marker used when rearranging TOC */
159-
160-
} TocEntry;
161-
162-
extern void die_horribly(const char *fmt, ...);
163-
164-
extern void WriteTOC(ArchiveHandle* AH);
165-
extern void ReadTOC(ArchiveHandle* AH);
166-
extern void WriteHead(ArchiveHandle* AH);
167-
extern void ReadHead(ArchiveHandle* AH);
168-
extern void WriteToc(ArchiveHandle* AH);
169-
extern void ReadToc(ArchiveHandle* AH);
170-
extern void WriteDataChunks(ArchiveHandle* AH);
171-
172-
extern int TocIDRequired(ArchiveHandle* AH, int id, RestoreOptions *ropt);
173-
174-
/*
175-
* Mandatory routines for each supported format
176-
*/
177-
178-
extern int WriteInt(ArchiveHandle* AH, int i);
179-
extern int ReadInt(ArchiveHandle* AH);
180-
extern char* ReadStr(ArchiveHandle* AH);
181-
extern int WriteStr(ArchiveHandle* AH, char* s);
182-
183-
extern void InitArchiveFmt_Custom(ArchiveHandle* AH);
184-
extern void InitArchiveFmt_Files(ArchiveHandle* AH);
185-
extern void InitArchiveFmt_PlainText(ArchiveHandle* AH);
186-
187-
extern OutputContext SetOutput(ArchiveHandle* AH, char *filename, int compression);
188-
extern void ResetOutput(ArchiveHandle* AH, OutputContext savedContext);
189-
190-
int ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle* AH);
191-
int ahprintf(ArchiveHandle* AH, const char *fmt, ...);
192-
193-
#endif
1+
/*-------------------------------------------------------------------------
2+
*
3+
* pg_backup_archiver.h
4+
*
5+
* Private interface to the pg_dump archiver routines.
6+
* It is NOT intended that these routines be called by any
7+
* dumper directly.
8+
*
9+
* See the headers to pg_restore for more details.
10+
*
11+
* Copyright (c) 2000, Philip Warner
12+
* Rights are granted to use this software in any way so long
13+
* as this notice is not removed.
14+
*
15+
* The author is not responsible for loss or damages that may
16+
* result from it's use.
17+
*
18+
*
19+
* IDENTIFICATION
20+
*
21+
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
22+
*
23+
* Initial version.
24+
*
25+
*-------------------------------------------------------------------------
26+
*/
27+
28+
#ifndef __PG_BACKUP_ARCHIVE__
29+
#define __PG_BACKUP_ARCHIVE__
30+
31+
#include <stdio.h>
32+
33+
#ifdef HAVE_LIBZ
34+
#include <zlib.h>
35+
#define GZCLOSE(fh) gzclose(fh)
36+
#define GZWRITE(p, s, n, fh) gzwrite(fh, p, n * s)
37+
#define GZREAD(p, s, n, fh) gzread(fh, p, n * s)
38+
#else
39+
#define GZCLOSE(fh) fclose(fh)
40+
#define GZWRITE(p, s, n, fh) fwrite(p, s, n, fh)
41+
#define GZREAD(p, s, n, fh) fread(p, s, n, fh)
42+
#define Z_DEFAULT_COMPRESSION -1
43+
44+
typedef struct _z_stream {
45+
void *next_in;
46+
void *next_out;
47+
int avail_in;
48+
int avail_out;
49+
} z_stream;
50+
typedef z_stream *z_streamp;
51+
#endif
52+
53+
#include "pg_backup.h"
54+
55+
#define K_VERS_MAJOR 1
56+
#define K_VERS_MINOR 2
57+
#define K_VERS_REV 2
58+
59+
/* Some important version numbers (checked in code) */
60+
#define K_VERS_1_0 (( (1 * 256 + 0) * 256 + 0) * 256 + 0)
61+
#define K_VERS_1_2 (( (1 * 256 + 2) * 256 + 0) * 256 + 0)
62+
#define K_VERS_MAX (( (1 * 256 + 2) * 256 + 255) * 256 + 0)
63+
64+
struct _archiveHandle;
65+
struct _tocEntry;
66+
struct _restoreList;
67+
68+
typedef void (*ClosePtr) (struct _archiveHandle* AH);
69+
typedef void (*ArchiveEntryPtr) (struct _archiveHandle* AH, struct _tocEntry* te);
70+
71+
typedef void (*StartDataPtr) (struct _archiveHandle* AH, struct _tocEntry* te);
72+
typedef int (*WriteDataPtr) (struct _archiveHandle* AH, const void* data, int dLen);
73+
typedef void (*EndDataPtr) (struct _archiveHandle* AH, struct _tocEntry* te);
74+
75+
typedef int (*WriteBytePtr) (struct _archiveHandle* AH, const int i);
76+
typedef int (*ReadBytePtr) (struct _archiveHandle* AH);
77+
typedef int (*WriteBufPtr) (struct _archiveHandle* AH, const void* c, int len);
78+
typedef int (*ReadBufPtr) (struct _archiveHandle* AH, void* buf, int len);
79+
typedef void (*SaveArchivePtr) (struct _archiveHandle* AH);
80+
typedef void (*WriteExtraTocPtr) (struct _archiveHandle* AH, struct _tocEntry* te);
81+
typedef void (*ReadExtraTocPtr) (struct _archiveHandle* AH, struct _tocEntry* te);
82+
typedef void (*PrintExtraTocPtr) (struct _archiveHandle* AH, struct _tocEntry* te);
83+
typedef void (*PrintTocDataPtr) (struct _archiveHandle* AH, struct _tocEntry* te,
84+
RestoreOptions *ropt);
85+
86+
typedef int (*TocSortCompareFn) (const void* te1, const void *te2);
87+
88+
typedef enum _archiveMode {
89+
archModeWrite,
90+
archModeRead
91+
} ArchiveMode;
92+
93+
typedef struct _outputContext {
94+
void *OF;
95+
int gzOut;
96+
} OutputContext;
97+
98+
typedef struct _archiveHandle {
99+
char vmaj; /* Version of file */
100+
char vmin;
101+
char vrev;
102+
int version; /* Conveniently formatted version */
103+
104+
int intSize; /* Size of an integer in the archive */
105+
ArchiveFormat format; /* Archive format */
106+
107+
int readHeader; /* Used if file header has been read already */
108+
109+
ArchiveEntryPtr ArchiveEntryPtr; /* Called for each metadata object */
110+
StartDataPtr StartDataPtr; /* Called when table data is about to be dumped */
111+
WriteDataPtr WriteDataPtr; /* Called to send some table data to the archive */
112+
EndDataPtr EndDataPtr; /* Called when table data dump is finished */
113+
WriteBytePtr WriteBytePtr; /* Write a byte to output */
114+
ReadBytePtr ReadBytePtr; /* */
115+
WriteBufPtr WriteBufPtr;
116+
ReadBufPtr ReadBufPtr;
117+
ClosePtr ClosePtr; /* Close the archive */
118+
WriteExtraTocPtr WriteExtraTocPtr; /* Write extra TOC entry data associated with */
119+
/* the current archive format */
120+
ReadExtraTocPtr ReadExtraTocPtr; /* Read extr info associated with archie format */
121+
PrintExtraTocPtr PrintExtraTocPtr; /* Extra TOC info for format */
122+
PrintTocDataPtr PrintTocDataPtr;
123+
124+
int lastID; /* Last internal ID for a TOC entry */
125+
char* fSpec; /* Archive File Spec */
126+
FILE *FH; /* General purpose file handle */
127+
void *OF;
128+
int gzOut; /* Output file */
129+
130+
struct _tocEntry* toc; /* List of TOC entries */
131+
int tocCount; /* Number of TOC entries */
132+
struct _tocEntry* currToc; /* Used when dumping data */
133+
char *currUser; /* Restore: current username in script */
134+
int compression; /* Compression requested on open */
135+
ArchiveMode mode; /* File mode - r or w */
136+
void* formatData; /* Header data specific to file format */
137+
138+
} ArchiveHandle;
139+
140+
typedef struct _tocEntry {
141+
struct _tocEntry* prev;
142+
struct _tocEntry* next;
143+
int id;
144+
int hadDumper; /* Archiver was passed a dumper routine (used in restore) */
145+
char* oid;
146+
int oidVal;
147+
char* name;
148+
char* desc;
149+
char* defn;
150+
char* dropStmt;
151+
char* owner;
152+
char** depOid;
153+
int printed; /* Indicates if entry defn has been dumped */
154+
DataDumperPtr dataDumper; /* Routine to dump data for object */
155+
void* dataDumperArg; /* Arg for above routine */
156+
void* formatData; /* TOC Entry data specific to file format */
157+
158+
int _moved; /* Marker used when rearranging TOC */
159+
160+
} TocEntry;
161+
162+
extern void die_horribly(const char *fmt, ...);
163+
164+
extern void WriteTOC(ArchiveHandle* AH);
165+
extern void ReadTOC(ArchiveHandle* AH);
166+
extern void WriteHead(ArchiveHandle* AH);
167+
extern void ReadHead(ArchiveHandle* AH);
168+
extern void WriteToc(ArchiveHandle* AH);
169+
extern void ReadToc(ArchiveHandle* AH);
170+
extern void WriteDataChunks(ArchiveHandle* AH);
171+
172+
extern int TocIDRequired(ArchiveHandle* AH, int id, RestoreOptions *ropt);
173+
174+
/*
175+
* Mandatory routines for each supported format
176+
*/
177+
178+
extern int WriteInt(ArchiveHandle* AH, int i);
179+
extern int ReadInt(ArchiveHandle* AH);
180+
extern char* ReadStr(ArchiveHandle* AH);
181+
extern int WriteStr(ArchiveHandle* AH, char* s);
182+
183+
extern void InitArchiveFmt_Custom(ArchiveHandle* AH);
184+
extern void InitArchiveFmt_Files(ArchiveHandle* AH);
185+
extern void InitArchiveFmt_PlainText(ArchiveHandle* AH);
186+
187+
extern OutputContext SetOutput(ArchiveHandle* AH, char *filename, int compression);
188+
extern void ResetOutput(ArchiveHandle* AH, OutputContext savedContext);
189+
190+
int ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle* AH);
191+
int ahprintf(ArchiveHandle* AH, const char *fmt, ...);
192+
193+
#endif

0 commit comments

Comments
 (0)