提交 5b0fb008 编写于 作者: B Bruce Momjian

The attached patch cleans up some code in pg_dump. It cuts some

unused function arguments, and makes the TableInfo struct slightly
smaller by removing an unnecessary member.

Neil Conway <neilconway@rogers.com>
上级 24469374
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.62 2002/02/11 00:18:20 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.63 2002/04/24 02:44:19 momjian Exp $
* *
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
* *
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include "postgres_fe.h" #include "postgres_fe.h"
#include "pg_dump.h" #include "pg_dump.h"
#include "pg_backup_archiver.h" #include "pg_backup_archiver.h"
#include "postgres.h"
#include "catalog/pg_class.h"
#include <ctype.h> #include <ctype.h>
...@@ -234,6 +236,7 @@ parseNumericArray(const char *str, char **array, int arraysize) ...@@ -234,6 +236,7 @@ parseNumericArray(const char *str, char **array, int arraysize)
temp[j++] = s; temp[j++] = s;
} }
} }
while (argNum < arraysize) while (argNum < arraysize)
array[argNum++] = strdup("0"); array[argNum++] = strdup("0");
} }
...@@ -344,8 +347,8 @@ dumpSchema(Archive *fout, ...@@ -344,8 +347,8 @@ dumpSchema(Archive *fout,
if (g_verbose) if (g_verbose)
write_msg(NULL, "dumping out tables\n"); write_msg(NULL, "dumping out tables\n");
dumpTables(fout, tblinfo, numTables, indinfo, numIndexes, inhinfo, numInherits, dumpTables(fout, tblinfo, numTables, tablename,
tinfo, numTypes, tablename, aclsSkip, oids, schemaOnly, dataOnly); aclsSkip, schemaOnly, dataOnly);
if (fout && !dataOnly) if (fout && !dataOnly)
{ {
...@@ -425,9 +428,8 @@ flagInhAttrs(TableInfo *tblinfo, int numTables, ...@@ -425,9 +428,8 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
*/ */
for (i = numTables - 1; i >= 0; i--) for (i = numTables - 1; i >= 0; i--)
{ {
/* Sequences can never have parents, and attr info is undefined */ /* Sequences can never have parents, and attr info is undefined */
if (tblinfo[i].sequence) if (tblinfo[i].relkind == RELKIND_SEQUENCE)
continue; continue;
/* Get all the parents and their indexes. */ /* Get all the parents and their indexes. */
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.253 2002/04/24 02:42:27 momjian Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.254 2002/04/24 02:44:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -574,7 +574,7 @@ dumpClasses(const TableInfo *tblinfo, const int numTables, Archive *fout, ...@@ -574,7 +574,7 @@ dumpClasses(const TableInfo *tblinfo, const int numTables, Archive *fout,
if (tblinfo[i].viewdef != NULL) if (tblinfo[i].viewdef != NULL)
continue; continue;
if (tblinfo[i].sequence) /* already dumped */ if (tblinfo[i].relkind == RELKIND_SEQUENCE) /* already dumped */
continue; continue;
if (!onlytable || (strcmp(classname, onlytable) == 0) || (strlen(onlytable) == 0)) if (!onlytable || (strcmp(classname, onlytable) == 0) || (strlen(onlytable) == 0))
...@@ -1672,7 +1672,7 @@ clearTableInfo(TableInfo *tblinfo, int numTables) ...@@ -1672,7 +1672,7 @@ clearTableInfo(TableInfo *tblinfo, int numTables)
if (tblinfo[i].relname) if (tblinfo[i].relname)
free(tblinfo[i].relname); free(tblinfo[i].relname);
if (tblinfo[i].sequence) if (tblinfo[i].relkind == RELKIND_SEQUENCE)
continue; continue;
/* Process Attributes */ /* Process Attributes */
...@@ -2212,7 +2212,6 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char *tablename) ...@@ -2212,7 +2212,6 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char *tablename)
tblinfo[i].relname = strdup(PQgetvalue(res, i, i_relname)); tblinfo[i].relname = strdup(PQgetvalue(res, i, i_relname));
tblinfo[i].relacl = strdup(PQgetvalue(res, i, i_relacl)); tblinfo[i].relacl = strdup(PQgetvalue(res, i, i_relacl));
tblinfo[i].relkind = *(PQgetvalue(res, i, i_relkind)); tblinfo[i].relkind = *(PQgetvalue(res, i, i_relkind));
tblinfo[i].sequence = (tblinfo[i].relkind == RELKIND_SEQUENCE);
tblinfo[i].hasindex = (strcmp(PQgetvalue(res, i, i_relhasindex), "t") == 0); tblinfo[i].hasindex = (strcmp(PQgetvalue(res, i, i_relhasindex), "t") == 0);
tblinfo[i].hasoids = (strcmp(PQgetvalue(res, i, i_relhasoids), "t") == 0); tblinfo[i].hasoids = (strcmp(PQgetvalue(res, i, i_relhasoids), "t") == 0);
tblinfo[i].usename = strdup(PQgetvalue(res, i, i_usename)); tblinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
...@@ -2858,7 +2857,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -2858,7 +2857,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
for (i = 0; i < numTables; i++) for (i = 0; i < numTables; i++)
{ {
if (tblinfo[i].sequence) if (tblinfo[i].relkind == RELKIND_SEQUENCE)
continue; continue;
/* find all the user attributes and their types */ /* find all the user attributes and their types */
...@@ -4242,7 +4241,7 @@ dumpACL(Archive *fout, TableInfo tbinfo) ...@@ -4242,7 +4241,7 @@ dumpACL(Archive *fout, TableInfo tbinfo)
} }
static void static void
_dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q) _dumpTableAttr70(TableInfo *tblinfo, int i, int j, PQExpBuffer q)
{ {
int32 tmp_typmod; int32 tmp_typmod;
int precision; int precision;
...@@ -4303,10 +4302,7 @@ _dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q) ...@@ -4303,10 +4302,7 @@ _dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q)
void void
dumpTables(Archive *fout, TableInfo *tblinfo, int numTables, dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
IndInfo *indinfo, int numIndexes, const char *tablename, const bool aclsSkip,
InhInfo *inhinfo, int numInherits,
TypeInfo *tinfo, int numTypes, const char *tablename,
const bool aclsSkip, const bool oids,
const bool schemaOnly, const bool dataOnly) const bool schemaOnly, const bool dataOnly)
{ {
int i, int i,
...@@ -4336,7 +4332,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables, ...@@ -4336,7 +4332,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
} }
for (i = 0; i < numTables; i++) for (i = 0; i < numTables; i++)
{ {
if (!(tblinfo[i].sequence)) if (tblinfo[i].relkind != RELKIND_SEQUENCE)
continue; continue;
if (!tablename || (!strcmp(tblinfo[i].relname, tablename)) if (!tablename || (!strcmp(tblinfo[i].relname, tablename))
|| (serialSeq && !strcmp(tblinfo[i].relname, serialSeq))) || (serialSeq && !strcmp(tblinfo[i].relname, serialSeq)))
...@@ -4352,7 +4348,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables, ...@@ -4352,7 +4348,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
for (i = 0; i < numTables; i++) for (i = 0; i < numTables; i++)
{ {
if (tblinfo[i].sequence) /* already dumped */ if (tblinfo[i].relkind == RELKIND_SEQUENCE) /* already dumped */
continue; continue;
if (!tablename || (!strcmp(tblinfo[i].relname, tablename)) || (strlen(tablename) == 0)) if (!tablename || (!strcmp(tblinfo[i].relname, tablename)) || (strlen(tablename) == 0))
...@@ -4415,7 +4411,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables, ...@@ -4415,7 +4411,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
if (g_fout->remoteVersion >= 70100) if (g_fout->remoteVersion >= 70100)
appendPQExpBuffer(q, "%s", tblinfo[i].atttypedefns[j]); appendPQExpBuffer(q, "%s", tblinfo[i].atttypedefns[j]);
else else
_dumpTableAttr70(fout, tblinfo, i, j, q); _dumpTableAttr70(tblinfo, i, j, q);
/* Default value */ /* Default value */
if (tblinfo[i].adef_expr[j] != NULL && tblinfo[i].inhAttrDef[j] == 0) if (tblinfo[i].adef_expr[j] != NULL && tblinfo[i].inhAttrDef[j] == 0)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_dump.h,v 1.82 2002/04/21 05:21:18 petere Exp $ * $Id: pg_dump.h,v 1.83 2002/04/24 02:44:19 momjian Exp $
* *
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
* *
...@@ -99,7 +99,6 @@ typedef struct _tableInfo ...@@ -99,7 +99,6 @@ typedef struct _tableInfo
* rule may ref things created after the * rule may ref things created after the
* base table was created. */ * base table was created. */
char relkind; char relkind;
bool sequence; /* this is redundant with relkind... */
bool hasindex; /* does it have any indexes? */ bool hasindex; /* does it have any indexes? */
bool hasoids; /* does it have OIDs? */ bool hasoids; /* does it have OIDs? */
int numatts; /* number of attributes */ int numatts; /* number of attributes */
...@@ -275,10 +274,7 @@ extern void dumpAggs(Archive *fout, AggInfo *agginfo, int numAggregates, ...@@ -275,10 +274,7 @@ extern void dumpAggs(Archive *fout, AggInfo *agginfo, int numAggregates,
extern void dumpOprs(Archive *fout, OprInfo *agginfo, int numOperators, extern void dumpOprs(Archive *fout, OprInfo *agginfo, int numOperators,
TypeInfo *tinfo, int numTypes); TypeInfo *tinfo, int numTypes);
extern void dumpTables(Archive *fout, TableInfo *tbinfo, int numTables, extern void dumpTables(Archive *fout, TableInfo *tbinfo, int numTables,
IndInfo *indinfo, int numIndexes, const char *tablename, const bool acls,
InhInfo *inhinfo, int numInherits,
TypeInfo *tinfo, int numTypes, const char *tablename,
const bool acls, const bool oids,
const bool schemaOnly, const bool dataOnly); const bool schemaOnly, const bool dataOnly);
extern void dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes, extern void dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes,
TableInfo *tbinfo, int numTables, const char *tablename); TableInfo *tbinfo, int numTables, const char *tablename);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册