diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 1e5f40162a9..afc64657f17 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -20,7 +20,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.25 1997/03/01 15:24:51 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.26 1997/04/02 04:17:21 vadim Exp $ * * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb * @@ -61,6 +61,8 @@ #include "pg_dump.h" +static void dumpSequence (FILE* fout, TableInfo tbinfo); + extern char *optarg; extern int optind, opterr; @@ -71,6 +73,8 @@ FILE *g_fout; /* the script file */ PGconn *g_conn; /* the database connection */ int dumpData; /* dump data using proper insert strings */ int attrNames; /* put attr names into insert strings */ +int schemaOnly; +int dataOnly; char g_opaque_type[10]; /* name for the opaque type */ @@ -346,7 +350,23 @@ dumpClasses(const TableInfo tblinfo[], const int numTables, FILE *fout, if (isViewRule(tblinfo[i].relname)) continue; - if (!onlytable || (!strcmp(classname,onlytable))) { + if (!onlytable || (!strcmp(classname,onlytable))) + { + if ( tblinfo[i].sequence ) + { + if ( dataOnly ) /* i.e. SCHEMA didn't dumped */ + { + if ( g_verbose ) + fprintf (stderr, "%s dumping out schema of sequence %s %s\n", + g_comment_start, classname, g_comment_end); + dumpSequence (fout, tblinfo[i]); + } + else if ( g_verbose ) + fprintf (stderr, "%s contents of sequence '%s' dumped in schema %s\n", + g_comment_start, classname, g_comment_end); + continue; + } + if (g_verbose) fprintf(stderr, "%s dumping out the contents of Table %s %s\n", g_comment_start, classname, g_comment_end); @@ -372,8 +392,6 @@ main(int argc, char** argv) const char* progname; const char* filename; const char* dbname; - int schemaOnly; - int dataOnly; const char *pghost = NULL; const char *pgport = NULL; const char *tablename; @@ -905,6 +923,7 @@ getTables(int *numTables) int i_oid; int i_relname; int i_relarch; + int i_relkind; /* find all the user-defined tables (no indices and no catalogs), ordering by oid is important so that we always process the parent @@ -921,8 +940,8 @@ getTables(int *numTables) PQclear(res); sprintf(query, - "SELECT oid, relname, relarch from pg_class " - "where relkind = 'r' and relname !~ '^pg_' " + "SELECT oid, relname, relarch, relkind from pg_class " + "where (relkind = 'r' or relkind = 'S') and relname !~ '^pg_' " "and relname !~ '^Xinv' order by oid;"); res = PQexec(g_conn, query); @@ -941,11 +960,13 @@ getTables(int *numTables) i_oid = PQfnumber(res,"oid"); i_relname = PQfnumber(res,"relname"); i_relarch = PQfnumber(res,"relarch"); + i_relkind = PQfnumber(res,"relkind"); for (i=0;i