Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite8f69be

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 parent0143d39 commite8f69be

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.opg_backup_db.opg_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-
#ifndefPG_BACKUP__
27-
28-
#include"config.h"
29-
#include"c.h"
30-
31-
#definePG_BACKUP__
32-
33-
typedefenum_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-
typedefstruct_Archive {
46-
/* Nothing here */
47-
}Archive;
48-
49-
typedefint (*DataDumperPtr)(Archive*AH,char*oid,void*userArg);
50-
51-
typedefstruct_restoreOptions {
52-
intdataOnly;
53-
intdropSchema;
54-
char*filename;
55-
intschemaOnly;
56-
intverbose;
57-
intaclsSkip;
58-
inttocSummary;
59-
char*tocFile;
60-
intoidOrder;
61-
intorigOrder;
62-
intrearrange;
63-
intformat;
64-
char*formatName;
65-
66-
intselTypes;
67-
intselIndex;
68-
intselFunction;
69-
intselTrigger;
70-
intselTable;
71-
char*indexNames;
72-
char*functionNames;
73-
char*tableNames;
74-
char*triggerNames;
75-
76-
int*idWanted;
77-
intlimitToList;
78-
intcompression;
79-
80-
}RestoreOptions;
81-
82-
/*
83-
* Main archiver interface.
84-
*/
85-
86-
/* Called to add a TOC entry */
87-
externvoidArchiveEntry(Archive*AH,constchar*oid,constchar*name,
88-
constchar*desc,constchar* (deps[]),constchar*defn,
89-
constchar*dropStmt,constchar*owner,
90-
DataDumperPtrdumpFn,void*dumpArg);
91-
92-
/* Called to write *data* to the archive */
93-
externintWriteData(Archive*AH,constvoid*data,intdLen);
94-
95-
externvoidCloseArchive(Archive*AH);
96-
97-
externvoidRestoreArchive(Archive*AH,RestoreOptions*ropt);
98-
99-
/* Open an existing archive */
100-
externArchive*OpenArchive(constchar*FileSpec,ArchiveFormatfmt);
101-
102-
/* Create a new archive */
103-
externArchive*CreateArchive(constchar*FileSpec,ArchiveFormatfmt,intcompression);
104-
105-
/* The --list option */
106-
externvoidPrintTOCSummary(Archive*AH,RestoreOptions*ropt);
107-
108-
externRestoreOptions*NewRestoreOptions(void);
109-
110-
/* Rearrange TOC entries */
111-
externvoidMoveToStart(Archive*AH,char*oType);
112-
externvoidMoveToEnd(Archive*AH,char*oType);
113-
externvoidSortTocByOID(Archive*AH);
114-
externvoidSortTocByID(Archive*AH);
115-
externvoidSortTocFromFile(Archive*AH,RestoreOptions*ropt);
116-
117-
/* Convenience functions used only when writing DATA */
118-
externintarchputs(constchar*s,Archive*AH);
119-
externintarchputc(constcharc,Archive*AH);
120-
externintarchprintf(Archive*AH,constchar*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+
#ifndefPG_BACKUP__
27+
28+
#include"config.h"
29+
#include"c.h"
30+
31+
#definePG_BACKUP__
32+
33+
#include"postgres.h"
34+
#include"libpq-fe.h"
35+
36+
typedefenum_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+
typedefstruct_Archive {
49+
intverbose;
50+
/* The rest is private */
51+
}Archive;
52+
53+
typedefint (*DataDumperPtr)(Archive*AH,char*oid,void*userArg);
54+
55+
typedefstruct_restoreOptions {
56+
intdataOnly;
57+
intdropSchema;
58+
char*filename;
59+
intschemaOnly;
60+
intverbose;
61+
intaclsSkip;
62+
inttocSummary;
63+
char*tocFile;
64+
intoidOrder;
65+
intorigOrder;
66+
intrearrange;
67+
intformat;
68+
char*formatName;
69+
70+
intselTypes;
71+
intselIndex;
72+
intselFunction;
73+
intselTrigger;
74+
intselTable;
75+
char*indexNames;
76+
char*functionNames;
77+
char*tableNames;
78+
char*triggerNames;
79+
80+
intuseDB;
81+
char*dbname;
82+
char*pgport;
83+
char*pghost;
84+
intignoreVersion;
85+
intrequirePassword;
86+
87+
int*idWanted;
88+
intlimitToList;
89+
intcompression;
90+
91+
}RestoreOptions;
92+
93+
/*
94+
* Main archiver interface.
95+
*/
96+
97+
externvoidexit_horribly(Archive*AH,constchar*fmt, ...);
98+
99+
/* Lets the archibe know we have a DB connection to shutdown if it dies */
100+
101+
PGconn*ConnectDatabase(Archive*AH,
102+
constchar*dbname,
103+
constchar*pghost,
104+
constchar*pgport,
105+
constintreqPwd,
106+
constintignoreVersion);
107+
108+
109+
/* Called to add a TOC entry */
110+
externvoidArchiveEntry(Archive*AH,constchar*oid,constchar*name,
111+
constchar*desc,constchar* (deps[]),constchar*defn,
112+
constchar*dropStmt,constchar*copyStmt,constchar*owner,
113+
DataDumperPtrdumpFn,void*dumpArg);
114+
115+
/* Called to write *data* to the archive */
116+
externintWriteData(Archive*AH,constvoid*data,intdLen);
117+
118+
//extern int StartBlobs(Archive* AH);
119+
//extern intEndBlobs(Archive* AH);
120+
externintStartBlob(Archive*AH,intoid);
121+
externintEndBlob(Archive*AH,intoid);
122+
123+
externvoidCloseArchive(Archive*AH);
124+
125+
externvoidRestoreArchive(Archive*AH,RestoreOptions*ropt);
126+
127+
/* Open an existing archive */
128+
externArchive*OpenArchive(constchar*FileSpec,constArchiveFormatfmt);
129+
130+
/* Create a new archive */
131+
externArchive*CreateArchive(constchar*FileSpec,constArchiveFormatfmt,
132+
constintcompression);
133+
134+
/* The --list option */
135+
externvoidPrintTOCSummary(Archive*AH,RestoreOptions*ropt);
136+
137+
externRestoreOptions*NewRestoreOptions(void);
138+
139+
/* Rearrange TOC entries */
140+
externvoidMoveToStart(Archive*AH,char*oType);
141+
externvoidMoveToEnd(Archive*AH,char*oType);
142+
externvoidSortTocByOID(Archive*AH);
143+
externvoidSortTocByID(Archive*AH);
144+
externvoidSortTocFromFile(Archive*AH,RestoreOptions*ropt);
145+
146+
/* Convenience functions used only when writing DATA */
147+
externintarchputs(constchar*s,Archive*AH);
148+
externintarchputc(constcharc,Archive*AH);
149+
externintarchprintf(Archive*AH,constchar*fmt, ...);
150+
151+
#endif
152+
153+
154+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp