Skip to content

Commit e8f69be

Browse files
committed
- Support for BLOB output from pg_dump and input via pg_restore
- Support for direct DB connection in pg_restore - Fixes in support for --insert flag - pg_dump now outputs in modified OID order - various other bug fixes
1 parent 0143d39 commit e8f69be

File tree

9 files changed

+2924
-1774
lines changed

9 files changed

+2924
-1774
lines changed

src/bin/pg_dump/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.19 2000/07/04 19:52:00 petere Exp $
7+
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.20 2000/07/21 11:40:08 pjw Exp $
88
#
99
#-------------------------------------------------------------------------
1010

1111
subdir = src/bin/pg_dump
1212
top_builddir = ../../..
1313
include ../../Makefile.global
1414

15-
OBJS= pg_backup_archiver.o pg_backup_custom.o pg_backup_files.o \
16-
pg_backup_plain_text.o $(STRDUP)
15+
OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o pg_backup_files.o \
16+
pg_backup_null.o pg_backup_tar.o $(STRDUP)
1717

1818
CFLAGS+= -I$(LIBPQDIR)
1919
LIBS+= -lz

src/bin/pg_dump/README

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
Notes on pg_dump
22
================
33

4-
pg_dump, by default, still outputs text files.
4+
1. pg_dump, by default, still outputs text files.
55

6-
pg_dumpall forces all pg_dump output to be text, since it also outputs text into the same output stream.
6+
2. pg_dumpall forces all pg_dump output to be text, since it also outputs text into the same output stream.
77

8-
The plain text output format can not be used as input into pg_restore.
8+
3. The plain text output format can not be used as input into pg_restore.
9+
10+
4. pg_dump now dumps the items in a modified OID order to try to improve relaibility of default restores.
911

1012

1113
To dump a database into the next custom format, type:
1214

1315
pg_dump <db-name> -Fc > <backup-file>
1416

17+
or, in TAR format
18+
19+
pg_dump <db-name> -Ft > <backup-file>
20+
1521
To restore, try
1622

1723
To list contents:
@@ -53,7 +59,37 @@ or, simply:
5359
pg_restore backup.bck --use=toc.lis | psql newdbname
5460

5561

56-
Philip Warner, 3-Jul-2000
62+
BLOBs
63+
=====
64+
65+
To dump blobs you must use the custom archive format (-Fc) or TAR format (-Ft), and specify the
66+
--blobs qualifier to the pg_dump command.
67+
68+
To restore blobs you must use a direct database connection (--db=db-to-restore-to).
69+
70+
eg.
71+
72+
pg_dump --blob -Fc db-to-backup -f backup.bck
73+
74+
pg_restore backup.bck --db=db-to-restore-into
75+
76+
77+
TAR
78+
===
79+
80+
The TAR archive that pg_dump creates currently has a blank username & group for the files,
81+
but should be otherwise valid. It also includes a 'restore.sql' script which is there for
82+
the benefit of humans. It is never used by pg_restore.
83+
84+
Note: the TAR format archive can only be used as input into pg_restore if it is in TAR form.
85+
(ie. you should not extract the files then expect pg_restore to work).
86+
87+
You can extract, edit, and tar the files again, and it should work, but the 'toc'
88+
file should go at the start, the data files be in the order they are used, and
89+
the BLOB files at the end.
90+
91+
92+
Philip Warner, 16-Jul-2000
5793
pjw@rhyme.com.au
5894

5995

src/bin/pg_dump/pg_backup.h

Lines changed: 154 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,154 @@
1-
/*-------------------------------------------------------------------------
2-
*
3-
* pg_backup.h
4-
*
5-
* Public interface to the pg_dump archiver routines.
6-
*
7-
* See the headers to pg_restore for more details.
8-
*
9-
* Copyright (c) 2000, Philip Warner
10-
* Rights are granted to use this software in any way so long
11-
* as this notice is not removed.
12-
*
13-
* The author is not responsible for loss or damages that may
14-
* result from it's use.
15-
*
16-
*
17-
* IDENTIFICATION
18-
*
19-
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
20-
*
21-
* Initial version.
22-
*
23-
*-------------------------------------------------------------------------
24-
*/
25-
26-
#ifndef PG_BACKUP__
27-
28-
#include "config.h"
29-
#include "c.h"
30-
31-
#define PG_BACKUP__
32-
33-
typedef enum _archiveFormat {
34-
archUnknown = 0,
35-
archCustom = 1,
36-
archFiles = 2,
37-
archTar = 3,
38-
archPlainText = 4
39-
} ArchiveFormat;
40-
41-
/*
42-
* We may want to have so user-readbale data, but in the mean
43-
* time this gives us some abstraction and type checking.
44-
*/
45-
typedef struct _Archive {
46-
/* Nothing here */
47-
} Archive;
48-
49-
typedef int (*DataDumperPtr)(Archive* AH, char* oid, void* userArg);
50-
51-
typedef struct _restoreOptions {
52-
int dataOnly;
53-
int dropSchema;
54-
char *filename;
55-
int schemaOnly;
56-
int verbose;
57-
int aclsSkip;
58-
int tocSummary;
59-
char *tocFile;
60-
int oidOrder;
61-
int origOrder;
62-
int rearrange;
63-
int format;
64-
char *formatName;
65-
66-
int selTypes;
67-
int selIndex;
68-
int selFunction;
69-
int selTrigger;
70-
int selTable;
71-
char *indexNames;
72-
char *functionNames;
73-
char *tableNames;
74-
char *triggerNames;
75-
76-
int *idWanted;
77-
int limitToList;
78-
int compression;
79-
80-
} RestoreOptions;
81-
82-
/*
83-
* Main archiver interface.
84-
*/
85-
86-
/* Called to add a TOC entry */
87-
extern void ArchiveEntry(Archive* AH, const char* oid, const char* name,
88-
const char* desc, const char* (deps[]), const char* defn,
89-
const char* dropStmt, const char* owner,
90-
DataDumperPtr dumpFn, void* dumpArg);
91-
92-
/* Called to write *data* to the archive */
93-
extern int WriteData(Archive* AH, const void* data, int dLen);
94-
95-
extern void CloseArchive(Archive* AH);
96-
97-
extern void RestoreArchive(Archive* AH, RestoreOptions *ropt);
98-
99-
/* Open an existing archive */
100-
extern Archive* OpenArchive(const char* FileSpec, ArchiveFormat fmt);
101-
102-
/* Create a new archive */
103-
extern Archive* CreateArchive(const char* FileSpec, ArchiveFormat fmt, int compression);
104-
105-
/* The --list option */
106-
extern void PrintTOCSummary(Archive* AH, RestoreOptions *ropt);
107-
108-
extern RestoreOptions* NewRestoreOptions(void);
109-
110-
/* Rearrange TOC entries */
111-
extern void MoveToStart(Archive* AH, char *oType);
112-
extern void MoveToEnd(Archive* AH, char *oType);
113-
extern void SortTocByOID(Archive* AH);
114-
extern void SortTocByID(Archive* AH);
115-
extern void SortTocFromFile(Archive* AH, RestoreOptions *ropt);
116-
117-
/* Convenience functions used only when writing DATA */
118-
extern int archputs(const char *s, Archive* AH);
119-
extern int archputc(const char c, Archive* AH);
120-
extern int archprintf(Archive* AH, const char *fmt, ...);
121-
122-
#endif
123-
124-
125-
1+
/*-------------------------------------------------------------------------
2+
*
3+
* pg_backup.h
4+
*
5+
* Public interface to the pg_dump archiver routines.
6+
*
7+
* See the headers to pg_restore for more details.
8+
*
9+
* Copyright (c) 2000, Philip Warner
10+
* Rights are granted to use this software in any way so long
11+
* as this notice is not removed.
12+
*
13+
* The author is not responsible for loss or damages that may
14+
* result from it's use.
15+
*
16+
*
17+
* IDENTIFICATION
18+
*
19+
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
20+
*
21+
* Initial version.
22+
*
23+
*-------------------------------------------------------------------------
24+
*/
25+
26+
#ifndef PG_BACKUP__
27+
28+
#include "config.h"
29+
#include "c.h"
30+
31+
#define PG_BACKUP__
32+
33+
#include "postgres.h"
34+
#include "libpq-fe.h"
35+
36+
typedef enum _archiveFormat {
37+
archUnknown = 0,
38+
archCustom = 1,
39+
archFiles = 2,
40+
archTar = 3,
41+
archNull = 4
42+
} ArchiveFormat;
43+
44+
/*
45+
* We may want to have so user-readbale data, but in the mean
46+
* time this gives us some abstraction and type checking.
47+
*/
48+
typedef struct _Archive {
49+
int verbose;
50+
/* The rest is private */
51+
} Archive;
52+
53+
typedef int (*DataDumperPtr)(Archive* AH, char* oid, void* userArg);
54+
55+
typedef struct _restoreOptions {
56+
int dataOnly;
57+
int dropSchema;
58+
char *filename;
59+
int schemaOnly;
60+
int verbose;
61+
int aclsSkip;
62+
int tocSummary;
63+
char *tocFile;
64+
int oidOrder;
65+
int origOrder;
66+
int rearrange;
67+
int format;
68+
char *formatName;
69+
70+
int selTypes;
71+
int selIndex;
72+
int selFunction;
73+
int selTrigger;
74+
int selTable;
75+
char *indexNames;
76+
char *functionNames;
77+
char *tableNames;
78+
char *triggerNames;
79+
80+
int useDB;
81+
char *dbname;
82+
char *pgport;
83+
char *pghost;
84+
int ignoreVersion;
85+
int requirePassword;
86+
87+
int *idWanted;
88+
int limitToList;
89+
int compression;
90+
91+
} RestoreOptions;
92+
93+
/*
94+
* Main archiver interface.
95+
*/
96+
97+
extern void exit_horribly(Archive *AH, const char *fmt, ...);
98+
99+
/* Lets the archibe know we have a DB connection to shutdown if it dies */
100+
101+
PGconn* ConnectDatabase(Archive *AH,
102+
const char* dbname,
103+
const char* pghost,
104+
const char* pgport,
105+
const int reqPwd,
106+
const int ignoreVersion);
107+
108+
109+
/* Called to add a TOC entry */
110+
extern void ArchiveEntry(Archive* AH, const char* oid, const char* name,
111+
const char* desc, const char* (deps[]), const char* defn,
112+
const char* dropStmt, const char* copyStmt, const char* owner,
113+
DataDumperPtr dumpFn, void* dumpArg);
114+
115+
/* Called to write *data* to the archive */
116+
extern int WriteData(Archive* AH, const void* data, int dLen);
117+
118+
//extern int StartBlobs(Archive* AH);
119+
//extern int EndBlobs(Archive* AH);
120+
extern int StartBlob(Archive* AH, int oid);
121+
extern int EndBlob(Archive* AH, int oid);
122+
123+
extern void CloseArchive(Archive* AH);
124+
125+
extern void RestoreArchive(Archive* AH, RestoreOptions *ropt);
126+
127+
/* Open an existing archive */
128+
extern Archive* OpenArchive(const char* FileSpec, const ArchiveFormat fmt);
129+
130+
/* Create a new archive */
131+
extern Archive* CreateArchive(const char* FileSpec, const ArchiveFormat fmt,
132+
const int compression);
133+
134+
/* The --list option */
135+
extern void PrintTOCSummary(Archive* AH, RestoreOptions *ropt);
136+
137+
extern RestoreOptions* NewRestoreOptions(void);
138+
139+
/* Rearrange TOC entries */
140+
extern void MoveToStart(Archive* AH, char *oType);
141+
extern void MoveToEnd(Archive* AH, char *oType);
142+
extern void SortTocByOID(Archive* AH);
143+
extern void SortTocByID(Archive* AH);
144+
extern void SortTocFromFile(Archive* AH, RestoreOptions *ropt);
145+
146+
/* Convenience functions used only when writing DATA */
147+
extern int archputs(const char *s, Archive* AH);
148+
extern int archputc(const char c, Archive* AH);
149+
extern int archprintf(Archive* AH, const char *fmt, ...);
150+
151+
#endif
152+
153+
154+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy