Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8f0ee46

Browse files
committed
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.
1 parent 42fbb6d commit 8f0ee46

File tree

3 files changed

+180
-71
lines changed

3 files changed

+180
-71
lines changed

src/bin/pg_dump/pg_backup_db.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Implements the basic DB functions used by the archiver.
66
*
77
* IDENTIFICATION
8-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.21 2001/07/03 20:21:48 petere Exp $
8+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.22 2001/08/03 19:43:05 tgl Exp $
99
*
1010
* NOTES
1111
*
@@ -207,6 +207,8 @@ UserIsSuperuser(ArchiveHandle *AH, char *user)
207207
}
208208
PQclear(res);
209209

210+
destroyPQExpBuffer(qry);
211+
210212
return isSuper;
211213
}
212214

@@ -678,7 +680,7 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen)
678680
void
679681
FixupBlobRefs(ArchiveHandle *AH, char *tablename)
680682
{
681-
PQExpBuffer tblQry = createPQExpBuffer();
683+
PQExpBuffer tblQry;
682684
PGresult *res,
683685
*uRes;
684686
int i,
@@ -688,6 +690,8 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename)
688690
if (strcmp(tablename, BLOB_XREF_TABLE) == 0)
689691
return;
690692

693+
tblQry = createPQExpBuffer();
694+
691695
appendPQExpBuffer(tblQry, "SELECT a.attname FROM pg_class c, pg_attribute a, pg_type t "
692696
" WHERE a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid "
693697
" AND t.typname = 'oid' AND c.relname = '%s';", tablename);
@@ -699,10 +703,8 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename)
699703

700704
if ((n = PQntuples(res)) == 0)
701705
{
702-
/* We're done */
706+
/* nothing to do */
703707
ahlog(AH, 1, "no OID type columns in table %s\n", tablename);
704-
PQclear(res);
705-
return;
706708
}
707709

708710
for (i = 0; i < n; i++)
@@ -741,7 +743,7 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename)
741743
}
742744

743745
PQclear(res);
744-
746+
destroyPQExpBuffer(tblQry);
745747
}
746748

747749
/**********
@@ -766,6 +768,8 @@ CreateBlobXrefTable(ArchiveHandle *AH)
766768

767769
appendPQExpBuffer(qry, "Create Unique Index %s_ix on %s(oldOid)", BLOB_XREF_TABLE, BLOB_XREF_TABLE);
768770
ExecuteSqlCommand(AH, qry, "could not create index on BLOB cross reference table", true);
771+
772+
destroyPQExpBuffer(qry);
769773
}
770774

771775
void
@@ -776,6 +780,8 @@ InsertBlobXref(ArchiveHandle *AH, int old, int new)
776780
appendPQExpBuffer(qry, "Insert Into %s(oldOid, newOid) Values (%d, %d);", BLOB_XREF_TABLE, old, new);
777781

778782
ExecuteSqlCommand(AH, qry, "could not create BLOB cross reference entry", true);
783+
784+
destroyPQExpBuffer(qry);
779785
}
780786

781787
void
@@ -787,6 +793,8 @@ StartTransaction(ArchiveHandle *AH)
787793

788794
ExecuteSqlCommand(AH, qry, "could not start database transaction", false);
789795
AH->txActive = true;
796+
797+
destroyPQExpBuffer(qry);
790798
}
791799

792800
void
@@ -799,6 +807,8 @@ StartTransactionXref(ArchiveHandle *AH)
799807
ExecuteSqlCommand(AH, qry,
800808
"could not start transaction for BLOB cross references", true);
801809
AH->blobTxActive = true;
810+
811+
destroyPQExpBuffer(qry);
802812
}
803813

804814
void
@@ -810,6 +820,8 @@ CommitTransaction(ArchiveHandle *AH)
810820

811821
ExecuteSqlCommand(AH, qry, "could not commit database transaction", false);
812822
AH->txActive = false;
823+
824+
destroyPQExpBuffer(qry);
813825
}
814826

815827
void
@@ -821,4 +833,6 @@ CommitTransactionXref(ArchiveHandle *AH)
821833

822834
ExecuteSqlCommand(AH, qry, "could not commit transaction for BLOB cross references", true);
823835
AH->blobTxActive = false;
836+
837+
destroyPQExpBuffer(qry);
824838
}

0 commit comments

Comments
 (0)