Commit 8f0ee46d authored by Tom Lane's avatar Tom Lane

Fix pg_dump so that comments on views are dumped in the proper sequence.

Dump the alignment and storage information for user-defined types (how'd
that manage to slip through the cracks?), and don't dump 'shell' types
that don't have typisdefined set.  Fix badly broken logic for dependencies
of type definitions (did not work for more than one user-defined type...).
Avoid memory leakage within pg_dump by being more careful to release
storage used by PQExpBuffer objects.
parent 42fbb6db
......@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver.
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.21 2001/07/03 20:21:48 petere Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.22 2001/08/03 19:43:05 tgl Exp $
*
* NOTES
*
......@@ -207,6 +207,8 @@ UserIsSuperuser(ArchiveHandle *AH, char *user)
}
PQclear(res);
destroyPQExpBuffer(qry);
return isSuper;
}
......@@ -678,7 +680,7 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen)
void
FixupBlobRefs(ArchiveHandle *AH, char *tablename)
{
PQExpBuffer tblQry = createPQExpBuffer();
PQExpBuffer tblQry;
PGresult *res,
*uRes;
int i,
......@@ -688,6 +690,8 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename)
if (strcmp(tablename, BLOB_XREF_TABLE) == 0)
return;
tblQry = createPQExpBuffer();
appendPQExpBuffer(tblQry, "SELECT a.attname FROM pg_class c, pg_attribute a, pg_type t "
" WHERE a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid "
" AND t.typname = 'oid' AND c.relname = '%s';", tablename);
......@@ -699,10 +703,8 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename)
if ((n = PQntuples(res)) == 0)
{
/* We're done */
/* nothing to do */
ahlog(AH, 1, "no OID type columns in table %s\n", tablename);
PQclear(res);
return;
}
for (i = 0; i < n; i++)
......@@ -741,7 +743,7 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename)
}
PQclear(res);
destroyPQExpBuffer(tblQry);
}
/**********
......@@ -766,6 +768,8 @@ CreateBlobXrefTable(ArchiveHandle *AH)
appendPQExpBuffer(qry, "Create Unique Index %s_ix on %s(oldOid)", BLOB_XREF_TABLE, BLOB_XREF_TABLE);
ExecuteSqlCommand(AH, qry, "could not create index on BLOB cross reference table", true);
destroyPQExpBuffer(qry);
}
void
......@@ -776,6 +780,8 @@ InsertBlobXref(ArchiveHandle *AH, int old, int new)
appendPQExpBuffer(qry, "Insert Into %s(oldOid, newOid) Values (%d, %d);", BLOB_XREF_TABLE, old, new);
ExecuteSqlCommand(AH, qry, "could not create BLOB cross reference entry", true);
destroyPQExpBuffer(qry);
}
void
......@@ -787,6 +793,8 @@ StartTransaction(ArchiveHandle *AH)
ExecuteSqlCommand(AH, qry, "could not start database transaction", false);
AH->txActive = true;
destroyPQExpBuffer(qry);
}
void
......@@ -799,6 +807,8 @@ StartTransactionXref(ArchiveHandle *AH)
ExecuteSqlCommand(AH, qry,
"could not start transaction for BLOB cross references", true);
AH->blobTxActive = true;
destroyPQExpBuffer(qry);
}
void
......@@ -810,6 +820,8 @@ CommitTransaction(ArchiveHandle *AH)
ExecuteSqlCommand(AH, qry, "could not commit database transaction", false);
AH->txActive = false;
destroyPQExpBuffer(qry);
}
void
......@@ -821,4 +833,6 @@ CommitTransactionXref(ArchiveHandle *AH)
ExecuteSqlCommand(AH, qry, "could not commit transaction for BLOB cross references", true);
AH->blobTxActive = false;
destroyPQExpBuffer(qry);
}
This diff is collapsed.
......@@ -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.67 2001/07/17 00:30:35 tgl Exp $
* $Id: pg_dump.h,v 1.68 2001/08/03 19:43:05 tgl Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
......@@ -49,10 +49,13 @@ typedef struct _typeInfo
char *typdelim;
char *typdefault;
char *typrelid;
char *typalign;
char *typstorage;
char *usename;
char *typedefn;
int passedbyvalue;
int isArray;
int isDefined;
} TypeInfo;
typedef struct _funcInfo
......
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