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

Commit d602a35

Browse files
committed
Brought in extensions to pg_dump
Submitted by: david bennett <dave@bensoft.com> marc g. fournier <scrappy@ki.net>
1 parent e72ca17 commit d602a35

File tree

6 files changed

+310
-136
lines changed

6 files changed

+310
-136
lines changed

src/bin/pg_dump/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.1.1.1 1996/07/09 06:22:14 scrappy Exp $
10+
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.2 1996/07/12 05:39:30 scrappy Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

src/bin/pg_dump/README.dhb

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
This is a modified version of the pg_dump.c program that is distributed with
3+
pg95 1.01. Modifications include:
4+
5+
* Applied 'insert string' patch from "Marc G. Fournier" <scrappy@ki.net>
6+
7+
(see insert.patch & README.scrappy for info on this patch)
8+
9+
* Added '-t table' option
10+
11+
By specifying '-t table' on the command line you can output only the
12+
schema (table & index defs) and data for one table of a database.
13+
14+
Example:
15+
16+
pg_dump -t descriptions software
17+
18+
* Added '-a' option
19+
20+
This is the opposite of the -S option. By specifying -a you can output
21+
only the database data and not the schema.
22+
23+
Example:
24+
25+
pg_dump -a zipcodes
26+
27+
* Added '-da' option
28+
29+
Marc's '-d' option adds the ability to output insert strings, By using
30+
the 'a' sub-parameter you can also place the attribute names in the
31+
insert strings. Basically, this is useful because ALTER TABLE is
32+
broken in pg95 1.01.
33+
34+
NOTE: This will create some long hairy output files! Be sure to pipe
35+
through compress or gzip before outputing to disk.
36+
37+
Example:
38+
39+
pg_dump -da -t oldfile mydatabase | gzip > oldfile.data.gz
40+
41+
Comments:
42+
43+
-----------------------------------------------------
44+
David Bennett, Bennett Software Solutions
45+
2608 NW Fawn Drive Blue Springs, MO 64015
46+
Phone: 816-228-8788, Fax: 816-228-3204
47+
dave@bensoft.com, http://bensoft.com
48+
PGP key at ftp://bensoft.com/pub/pgp/daveskey.txt

src/bin/pg_dump/README.scrappy

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Here is what Marc had to say about insert.patch included in this archive....
2+
3+
In preparation of finally moving all my 1.0 databases over to a 1.01
4+
database server, I looked at pg_dump and found that, unless I missed
5+
something, it didn't *easily* do what I wanted, which was to dump a database
6+
to a file, and then reload it again on another server (short-term)...but,
7+
also, there doesn't seem to be any mechanism for dumping the database to a
8+
file that can be backed up and quickly reloaded again.
9+
10+
So, I spent the past several hours modifying pg_dump so that it has an extra
11+
switch for dumping the data in valid 'insert' strings, so that you can
12+
quickly and easily reload a database.
13+
14+
So, now the output looks like:
15+
16+
CREATE TABLE scrap (integer int4, real float4, text text) archive = none;
17+
insert into scrap values (1, 1, 'text');
18+
19+
Now, the hard part was figuring out what types are available, so that the
20+
insert string works properly for char vs numberic data fields. As such, the
21+
switch statement I'm using in dumpClasses() for this may be missing values
22+
for numeric fields (I'm using PQftype() to figure out numeric vs non-numeric
23+
fields)

src/bin/pg_dump/common.c

+31-20
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.1.1.1 1996/07/09 06:22:14 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.2 1996/07/12 05:39:33 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -199,7 +199,7 @@ strInArray(char* pattern, char** arr, int arr_size)
199199
*/
200200

201201
TableInfo *
202-
dumpSchema(FILE *fout, int *numTablesPtr)
202+
dumpSchema(FILE *fout, int *numTablesPtr, char *tablename)
203203
{
204204
int numTypes;
205205
int numFuncs;
@@ -252,31 +252,42 @@ if (g_verbose) fprintf(stderr,"%s reading indices information %s\n",
252252
g_comment_start, g_comment_end);
253253
indinfo = getIndices(&numIndices);
254254

255-
if (g_verbose) fprintf(stderr,"%s dumping out user-defined types %s\n",
256-
g_comment_start, g_comment_end);
257-
dumpTypes(fout, finfo, numFuncs, tinfo, numTypes);
255+
if (!tablename && fout) {
256+
if (g_verbose) fprintf(stderr,"%s dumping out user-defined types %s\n",
257+
g_comment_start, g_comment_end);
258+
dumpTypes(fout, finfo, numFuncs, tinfo, numTypes);
259+
}
258260

259-
if (g_verbose) fprintf(stderr,"%s dumping out tables %s\n",
261+
if (fout) {
262+
if (g_verbose) fprintf(stderr,"%s dumping out tables %s\n",
260263
g_comment_start, g_comment_end);
261264
dumpTables(fout, tblinfo, numTables, inhinfo, numInherits,
262-
tinfo, numTypes);
265+
tinfo, numTypes, tablename);
266+
}
263267

264-
if (g_verbose) fprintf(stderr,"%s dumping out user-defined functions %s\n",
265-
g_comment_start, g_comment_end);
266-
dumpFuncs(fout, finfo, numFuncs, tinfo, numTypes);
268+
if (!tablename && fout) {
269+
if (g_verbose) fprintf(stderr,"%s dumping out user-defined functions %s\n",
270+
g_comment_start, g_comment_end);
271+
dumpFuncs(fout, finfo, numFuncs, tinfo, numTypes);
272+
}
267273

268-
if (g_verbose) fprintf(stderr,"%s dumping out user-defined functions %s\n",
269-
g_comment_start, g_comment_end);
270-
dumpAggs(fout, agginfo, numAggregates, tinfo, numTypes);
274+
if (!tablename && fout) {
275+
if (g_verbose) fprintf(stderr,"%s dumping out user-defined functions %s\n",
276+
g_comment_start, g_comment_end);
277+
dumpAggs(fout, agginfo, numAggregates, tinfo, numTypes);
278+
}
271279

272-
if (g_verbose) fprintf(stderr,"%s dumping out user-defined operators %s\n",
273-
g_comment_start, g_comment_end);
274-
dumpOprs(fout, oprinfo, numOperators, tinfo, numTypes);
275-
276-
if (g_verbose) fprintf(stderr,"%s dumping out indices %s\n",
277-
g_comment_start, g_comment_end);
278-
dumpIndices(fout, indinfo, numIndices, tblinfo, numTables);
280+
if (!tablename && fout) {
281+
if (g_verbose) fprintf(stderr,"%s dumping out user-defined operators %s\n",
282+
g_comment_start, g_comment_end);
283+
dumpOprs(fout, oprinfo, numOperators, tinfo, numTypes);
284+
}
279285

286+
if (fout) {
287+
if (g_verbose) fprintf(stderr,"%s dumping out indices %s\n",
288+
g_comment_start, g_comment_end);
289+
dumpIndices(fout, indinfo, numIndices, tblinfo, numTables, tablename);
290+
}
280291
*numTablesPtr = numTables;
281292
return tblinfo;
282293
}

0 commit comments

Comments
 (0)