Skip to content

Commit 5b0fb00

Browse files
committed
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>
1 parent 2446937 commit 5b0fb00

File tree

3 files changed

+18
-24
lines changed

3 files changed

+18
-24
lines changed

src/bin/pg_dump/common.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.62 2002/02/11 00:18:20 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.63 2002/04/24 02:44:19 momjian Exp $
1212
*
1313
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
1414
*
@@ -34,6 +34,8 @@
3434
#include "postgres_fe.h"
3535
#include "pg_dump.h"
3636
#include "pg_backup_archiver.h"
37+
#include "postgres.h"
38+
#include "catalog/pg_class.h"
3739

3840
#include <ctype.h>
3941

@@ -234,6 +236,7 @@ parseNumericArray(const char *str, char **array, int arraysize)
234236
temp[j++] = s;
235237
}
236238
}
239+
237240
while (argNum < arraysize)
238241
array[argNum++] = strdup("0");
239242
}
@@ -344,8 +347,8 @@ dumpSchema(Archive *fout,
344347
if (g_verbose)
345348
write_msg(NULL, "dumping out tables\n");
346349

347-
dumpTables(fout, tblinfo, numTables, indinfo, numIndexes, inhinfo, numInherits,
348-
tinfo, numTypes, tablename, aclsSkip, oids, schemaOnly, dataOnly);
350+
dumpTables(fout, tblinfo, numTables, tablename,
351+
aclsSkip, schemaOnly, dataOnly);
349352

350353
if (fout && !dataOnly)
351354
{
@@ -425,9 +428,8 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
425428
*/
426429
for (i = numTables - 1; i >= 0; i--)
427430
{
428-
429431
/* Sequences can never have parents, and attr info is undefined */
430-
if (tblinfo[i].sequence)
432+
if (tblinfo[i].relkind == RELKIND_SEQUENCE)
431433
continue;
432434

433435
/* Get all the parents and their indexes. */

src/bin/pg_dump/pg_dump.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
*
2424
* IDENTIFICATION
25-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.253 2002/04/24 02:42:27 momjian Exp $
25+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.254 2002/04/24 02:44:19 momjian Exp $
2626
*
2727
*-------------------------------------------------------------------------
2828
*/
@@ -574,7 +574,7 @@ dumpClasses(const TableInfo *tblinfo, const int numTables, Archive *fout,
574574
if (tblinfo[i].viewdef != NULL)
575575
continue;
576576

577-
if (tblinfo[i].sequence) /* already dumped */
577+
if (tblinfo[i].relkind == RELKIND_SEQUENCE) /* already dumped */
578578
continue;
579579

580580
if (!onlytable || (strcmp(classname, onlytable) == 0) || (strlen(onlytable) == 0))
@@ -1672,7 +1672,7 @@ clearTableInfo(TableInfo *tblinfo, int numTables)
16721672
if (tblinfo[i].relname)
16731673
free(tblinfo[i].relname);
16741674

1675-
if (tblinfo[i].sequence)
1675+
if (tblinfo[i].relkind == RELKIND_SEQUENCE)
16761676
continue;
16771677

16781678
/* Process Attributes */
@@ -2212,7 +2212,6 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs, const char *tablename)
22122212
tblinfo[i].relname = strdup(PQgetvalue(res, i, i_relname));
22132213
tblinfo[i].relacl = strdup(PQgetvalue(res, i, i_relacl));
22142214
tblinfo[i].relkind = *(PQgetvalue(res, i, i_relkind));
2215-
tblinfo[i].sequence = (tblinfo[i].relkind == RELKIND_SEQUENCE);
22162215
tblinfo[i].hasindex = (strcmp(PQgetvalue(res, i, i_relhasindex), "t") == 0);
22172216
tblinfo[i].hasoids = (strcmp(PQgetvalue(res, i, i_relhasoids), "t") == 0);
22182217
tblinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
@@ -2858,7 +2857,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
28582857

28592858
for (i = 0; i < numTables; i++)
28602859
{
2861-
if (tblinfo[i].sequence)
2860+
if (tblinfo[i].relkind == RELKIND_SEQUENCE)
28622861
continue;
28632862

28642863
/* find all the user attributes and their types */
@@ -4242,7 +4241,7 @@ dumpACL(Archive *fout, TableInfo tbinfo)
42424241
}
42434242

42444243
static void
4245-
_dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q)
4244+
_dumpTableAttr70(TableInfo *tblinfo, int i, int j, PQExpBuffer q)
42464245
{
42474246
int32 tmp_typmod;
42484247
int precision;
@@ -4303,10 +4302,7 @@ _dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q)
43034302

43044303
void
43054304
dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
4306-
IndInfo *indinfo, int numIndexes,
4307-
InhInfo *inhinfo, int numInherits,
4308-
TypeInfo *tinfo, int numTypes, const char *tablename,
4309-
const bool aclsSkip, const bool oids,
4305+
const char *tablename, const bool aclsSkip,
43104306
const bool schemaOnly, const bool dataOnly)
43114307
{
43124308
int i,
@@ -4336,7 +4332,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
43364332
}
43374333
for (i = 0; i < numTables; i++)
43384334
{
4339-
if (!(tblinfo[i].sequence))
4335+
if (tblinfo[i].relkind != RELKIND_SEQUENCE)
43404336
continue;
43414337
if (!tablename || (!strcmp(tblinfo[i].relname, tablename))
43424338
|| (serialSeq && !strcmp(tblinfo[i].relname, serialSeq)))
@@ -4352,7 +4348,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
43524348

43534349
for (i = 0; i < numTables; i++)
43544350
{
4355-
if (tblinfo[i].sequence) /* already dumped */
4351+
if (tblinfo[i].relkind == RELKIND_SEQUENCE) /* already dumped */
43564352
continue;
43574353

43584354
if (!tablename || (!strcmp(tblinfo[i].relname, tablename)) || (strlen(tablename) == 0))
@@ -4415,7 +4411,7 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
44154411
if (g_fout->remoteVersion >= 70100)
44164412
appendPQExpBuffer(q, "%s", tblinfo[i].atttypedefns[j]);
44174413
else
4418-
_dumpTableAttr70(fout, tblinfo, i, j, q);
4414+
_dumpTableAttr70(tblinfo, i, j, q);
44194415

44204416
/* Default value */
44214417
if (tblinfo[i].adef_expr[j] != NULL && tblinfo[i].inhAttrDef[j] == 0)

src/bin/pg_dump/pg_dump.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pg_dump.h,v 1.82 2002/04/21 05:21:18 petere Exp $
9+
* $Id: pg_dump.h,v 1.83 2002/04/24 02:44:19 momjian Exp $
1010
*
1111
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
1212
*
@@ -99,7 +99,6 @@ typedef struct _tableInfo
9999
* rule may ref things created after the
100100
* base table was created. */
101101
char relkind;
102-
bool sequence; /* this is redundant with relkind... */
103102
bool hasindex; /* does it have any indexes? */
104103
bool hasoids; /* does it have OIDs? */
105104
int numatts; /* number of attributes */
@@ -275,10 +274,7 @@ extern void dumpAggs(Archive *fout, AggInfo *agginfo, int numAggregates,
275274
extern void dumpOprs(Archive *fout, OprInfo *agginfo, int numOperators,
276275
TypeInfo *tinfo, int numTypes);
277276
extern void dumpTables(Archive *fout, TableInfo *tbinfo, int numTables,
278-
IndInfo *indinfo, int numIndexes,
279-
InhInfo *inhinfo, int numInherits,
280-
TypeInfo *tinfo, int numTypes, const char *tablename,
281-
const bool acls, const bool oids,
277+
const char *tablename, const bool acls,
282278
const bool schemaOnly, const bool dataOnly);
283279
extern void dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes,
284280
TableInfo *tbinfo, int numTables, const char *tablename);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy