提交 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 @@
*
*
* 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
*
......@@ -34,6 +34,8 @@
#include "postgres_fe.h"
#include "pg_dump.h"
#include "pg_backup_archiver.h"
#include "postgres.h"
#include "catalog/pg_class.h"
#include <ctype.h>
......@@ -234,6 +236,7 @@ parseNumericArray(const char *str, char **array, int arraysize)
temp[j++] = s;
}
}
while (argNum < arraysize)
array[argNum++] = strdup("0");
}
......@@ -344,8 +347,8 @@ dumpSchema(Archive *fout,
if (g_verbose)
write_msg(NULL, "dumping out tables\n");
dumpTables(fout, tblinfo, numTables, indinfo, numIndexes, inhinfo, numInherits,
tinfo, numTypes, tablename, aclsSkip, oids, schemaOnly, dataOnly);
dumpTables(fout, tblinfo, numTables, tablename,
aclsSkip, schemaOnly, dataOnly);
if (fout && !dataOnly)
{
......@@ -425,9 +428,8 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
*/
for (i = numTables - 1; i >= 0; i--)
{
/* Sequences can never have parents, and attr info is undefined */
if (tblinfo[i].sequence)
if (tblinfo[i].relkind == RELKIND_SEQUENCE)
continue;
/* Get all the parents and their indexes. */
......
......@@ -22,7 +22,7 @@
*
*
* 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,
if (tblinfo[i].viewdef != NULL)
continue;
if (tblinfo[i].sequence) /* already dumped */
if (tblinfo[i].relkind == RELKIND_SEQUENCE) /* already dumped */
continue;
if (!onlytable || (strcmp(classname, onlytable) == 0) || (strlen(onlytable) == 0))
......@@ -1672,7 +1672,7 @@ clearTableInfo(TableInfo *tblinfo, int numTables)
if (tblinfo[i].relname)
free(tblinfo[i].relname);
if (tblinfo[i].sequence)
if (tblinfo[i].relkind == RELKIND_SEQUENCE)
continue;
/* Process Attributes */
......@@ -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].relacl = strdup(PQgetvalue(res, i, i_relacl));
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].hasoids = (strcmp(PQgetvalue(res, i, i_relhasoids), "t") == 0);
tblinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
......@@ -2858,7 +2857,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
for (i = 0; i < numTables; i++)
{
if (tblinfo[i].sequence)
if (tblinfo[i].relkind == RELKIND_SEQUENCE)
continue;
/* find all the user attributes and their types */
......@@ -4242,7 +4241,7 @@ dumpACL(Archive *fout, TableInfo tbinfo)
}
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;
int precision;
......@@ -4303,10 +4302,7 @@ _dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q)
void
dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
IndInfo *indinfo, int numIndexes,
InhInfo *inhinfo, int numInherits,
TypeInfo *tinfo, int numTypes, const char *tablename,
const bool aclsSkip, const bool oids,
const char *tablename, const bool aclsSkip,
const bool schemaOnly, const bool dataOnly)
{
int i,
......@@ -4336,7 +4332,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
}
for (i = 0; i < numTables; i++)
{
if (!(tblinfo[i].sequence))
if (tblinfo[i].relkind != RELKIND_SEQUENCE)
continue;
if (!tablename || (!strcmp(tblinfo[i].relname, tablename))
|| (serialSeq && !strcmp(tblinfo[i].relname, serialSeq)))
......@@ -4352,7 +4348,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
for (i = 0; i < numTables; i++)
{
if (tblinfo[i].sequence) /* already dumped */
if (tblinfo[i].relkind == RELKIND_SEQUENCE) /* already dumped */
continue;
if (!tablename || (!strcmp(tblinfo[i].relname, tablename)) || (strlen(tablename) == 0))
......@@ -4415,7 +4411,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
if (g_fout->remoteVersion >= 70100)
appendPQExpBuffer(q, "%s", tblinfo[i].atttypedefns[j]);
else
_dumpTableAttr70(fout, tblinfo, i, j, q);
_dumpTableAttr70(tblinfo, i, j, q);
/* Default value */
if (tblinfo[i].adef_expr[j] != NULL && tblinfo[i].inhAttrDef[j] == 0)
......
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* 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
*
......@@ -99,7 +99,6 @@ typedef struct _tableInfo
* rule may ref things created after the
* base table was created. */
char relkind;
bool sequence; /* this is redundant with relkind... */
bool hasindex; /* does it have any indexes? */
bool hasoids; /* does it have OIDs? */
int numatts; /* number of attributes */
......@@ -275,10 +274,7 @@ extern void dumpAggs(Archive *fout, AggInfo *agginfo, int numAggregates,
extern void dumpOprs(Archive *fout, OprInfo *agginfo, int numOperators,
TypeInfo *tinfo, int numTypes);
extern void dumpTables(Archive *fout, TableInfo *tbinfo, int numTables,
IndInfo *indinfo, int numIndexes,
InhInfo *inhinfo, int numInherits,
TypeInfo *tinfo, int numTypes, const char *tablename,
const bool acls, const bool oids,
const char *tablename, const bool acls,
const bool schemaOnly, const bool dataOnly);
extern void dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes,
TableInfo *tbinfo, int numTables, const char *tablename);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册