Commit d602a35d authored by Marc G. Fournier's avatar Marc G. Fournier

Brought in extensions to pg_dump

Submitted by: david bennett <dave@bensoft.com>
	      marc g. fournier <scrappy@ki.net>
parent e72ca17f
......@@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.1.1.1 1996/07/09 06:22:14 scrappy Exp $
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Makefile,v 1.2 1996/07/12 05:39:30 scrappy Exp $
#
#-------------------------------------------------------------------------
......
This is a modified version of the pg_dump.c program that is distributed with
pg95 1.01. Modifications include:
* Applied 'insert string' patch from "Marc G. Fournier" <scrappy@ki.net>
(see insert.patch & README.scrappy for info on this patch)
* Added '-t table' option
By specifying '-t table' on the command line you can output only the
schema (table & index defs) and data for one table of a database.
Example:
pg_dump -t descriptions software
* Added '-a' option
This is the opposite of the -S option. By specifying -a you can output
only the database data and not the schema.
Example:
pg_dump -a zipcodes
* Added '-da' option
Marc's '-d' option adds the ability to output insert strings, By using
the 'a' sub-parameter you can also place the attribute names in the
insert strings. Basically, this is useful because ALTER TABLE is
broken in pg95 1.01.
NOTE: This will create some long hairy output files! Be sure to pipe
through compress or gzip before outputing to disk.
Example:
pg_dump -da -t oldfile mydatabase | gzip > oldfile.data.gz
Comments:
-----------------------------------------------------
David Bennett, Bennett Software Solutions
2608 NW Fawn Drive Blue Springs, MO 64015
Phone: 816-228-8788, Fax: 816-228-3204
dave@bensoft.com, http://bensoft.com
PGP key at ftp://bensoft.com/pub/pgp/daveskey.txt
Here is what Marc had to say about insert.patch included in this archive....
In preparation of finally moving all my 1.0 databases over to a 1.01
database server, I looked at pg_dump and found that, unless I missed
something, it didn't *easily* do what I wanted, which was to dump a database
to a file, and then reload it again on another server (short-term)...but,
also, there doesn't seem to be any mechanism for dumping the database to a
file that can be backed up and quickly reloaded again.
So, I spent the past several hours modifying pg_dump so that it has an extra
switch for dumping the data in valid 'insert' strings, so that you can
quickly and easily reload a database.
So, now the output looks like:
CREATE TABLE scrap (integer int4, real float4, text text) archive = none;
insert into scrap values (1, 1, 'text');
Now, the hard part was figuring out what types are available, so that the
insert string works properly for char vs numberic data fields. As such, the
switch statement I'm using in dumpClasses() for this may be missing values
for numeric fields (I'm using PQftype() to figure out numeric vs non-numeric
fields)
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.1.1.1 1996/07/09 06:22:14 scrappy Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.2 1996/07/12 05:39:33 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -199,7 +199,7 @@ strInArray(char* pattern, char** arr, int arr_size)
*/
TableInfo *
dumpSchema(FILE *fout, int *numTablesPtr)
dumpSchema(FILE *fout, int *numTablesPtr, char *tablename)
{
int numTypes;
int numFuncs;
......@@ -252,31 +252,42 @@ if (g_verbose) fprintf(stderr,"%s reading indices information %s\n",
g_comment_start, g_comment_end);
indinfo = getIndices(&numIndices);
if (g_verbose) fprintf(stderr,"%s dumping out user-defined types %s\n",
g_comment_start, g_comment_end);
dumpTypes(fout, finfo, numFuncs, tinfo, numTypes);
if (!tablename && fout) {
if (g_verbose) fprintf(stderr,"%s dumping out user-defined types %s\n",
g_comment_start, g_comment_end);
dumpTypes(fout, finfo, numFuncs, tinfo, numTypes);
}
if (g_verbose) fprintf(stderr,"%s dumping out tables %s\n",
if (fout) {
if (g_verbose) fprintf(stderr,"%s dumping out tables %s\n",
g_comment_start, g_comment_end);
dumpTables(fout, tblinfo, numTables, inhinfo, numInherits,
tinfo, numTypes);
tinfo, numTypes, tablename);
}
if (g_verbose) fprintf(stderr,"%s dumping out user-defined functions %s\n",
g_comment_start, g_comment_end);
dumpFuncs(fout, finfo, numFuncs, tinfo, numTypes);
if (!tablename && fout) {
if (g_verbose) fprintf(stderr,"%s dumping out user-defined functions %s\n",
g_comment_start, g_comment_end);
dumpFuncs(fout, finfo, numFuncs, tinfo, numTypes);
}
if (g_verbose) fprintf(stderr,"%s dumping out user-defined functions %s\n",
g_comment_start, g_comment_end);
dumpAggs(fout, agginfo, numAggregates, tinfo, numTypes);
if (!tablename && fout) {
if (g_verbose) fprintf(stderr,"%s dumping out user-defined functions %s\n",
g_comment_start, g_comment_end);
dumpAggs(fout, agginfo, numAggregates, tinfo, numTypes);
}
if (g_verbose) fprintf(stderr,"%s dumping out user-defined operators %s\n",
g_comment_start, g_comment_end);
dumpOprs(fout, oprinfo, numOperators, tinfo, numTypes);
if (g_verbose) fprintf(stderr,"%s dumping out indices %s\n",
g_comment_start, g_comment_end);
dumpIndices(fout, indinfo, numIndices, tblinfo, numTables);
if (!tablename && fout) {
if (g_verbose) fprintf(stderr,"%s dumping out user-defined operators %s\n",
g_comment_start, g_comment_end);
dumpOprs(fout, oprinfo, numOperators, tinfo, numTypes);
}
if (fout) {
if (g_verbose) fprintf(stderr,"%s dumping out indices %s\n",
g_comment_start, g_comment_end);
dumpIndices(fout, indinfo, numIndices, tblinfo, numTables, tablename);
}
*numTablesPtr = numTables;
return tblinfo;
}
......
This diff is collapsed.
......@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_dump.h,v 1.1.1.1 1996/07/09 06:22:14 scrappy Exp $
* $Id: pg_dump.h,v 1.2 1996/07/12 05:39:39 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -135,7 +135,7 @@ extern char g_opaque_type[10]; /* name for the opaque type */
* common utility functions
*/
extern TableInfo* dumpSchema(FILE* fout, int *numTablesPtr);
extern TableInfo* dumpSchema(FILE* fout, int *numTablesPtr, char *tablename);
extern char* findTypeByOid(TypeInfo* tinfo, int numTypes, char* oid);
extern char* findOprByOid(OprInfo *oprinfo, int numOprs, char *oid);
......@@ -178,11 +178,11 @@ extern void dumpOneFunc(FILE* fout, FuncInfo* finfo, int i,
TypeInfo *tinfo, int numTypes);
extern void dumpTables(FILE* fout, TableInfo* tbinfo, int numTables,
InhInfo *inhinfo, int numInherits,
TypeInfo *tinfo, int numTypes);
TypeInfo *tinfo, int numTypes, char *tablename);
extern void dumpIndices(FILE* fout, IndInfo* indinfo, int numIndices,
TableInfo* tbinfo, int numTables);
TableInfo* tbinfo, int numTables, char *tablename);
extern void dumpClasses(TableInfo *tbinfo, int numTables, FILE *fout);
extern void dumpClasses(TableInfo *tbinfo, int numTables, FILE *fout, char *tablename);
extern void dumpTuples(PGresult *res, FILE *fout, int *attrmap);
extern char* checkForQuote(char* s);
extern int findLastBuiltinOid();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment