5
5
* Implements the basic DB functions used by the archiver.
6
6
*
7
7
* 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 $
9
9
*
10
10
* NOTES
11
11
*
@@ -207,6 +207,8 @@ UserIsSuperuser(ArchiveHandle *AH, char *user)
207
207
}
208
208
PQclear (res );
209
209
210
+ destroyPQExpBuffer (qry );
211
+
210
212
return isSuper ;
211
213
}
212
214
@@ -678,7 +680,7 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen)
678
680
void
679
681
FixupBlobRefs (ArchiveHandle * AH , char * tablename )
680
682
{
681
- PQExpBuffer tblQry = createPQExpBuffer () ;
683
+ PQExpBuffer tblQry ;
682
684
PGresult * res ,
683
685
* uRes ;
684
686
int i ,
@@ -688,6 +690,8 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename)
688
690
if (strcmp (tablename , BLOB_XREF_TABLE ) == 0 )
689
691
return ;
690
692
693
+ tblQry = createPQExpBuffer ();
694
+
691
695
appendPQExpBuffer (tblQry , "SELECT a.attname FROM pg_class c, pg_attribute a, pg_type t "
692
696
" WHERE a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid "
693
697
" AND t.typname = 'oid' AND c.relname = '%s';" , tablename );
@@ -699,10 +703,8 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename)
699
703
700
704
if ((n = PQntuples (res )) == 0 )
701
705
{
702
- /* We're done */
706
+ /* nothing to do */
703
707
ahlog (AH , 1 , "no OID type columns in table %s\n" , tablename );
704
- PQclear (res );
705
- return ;
706
708
}
707
709
708
710
for (i = 0 ; i < n ; i ++ )
@@ -741,7 +743,7 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename)
741
743
}
742
744
743
745
PQclear (res );
744
-
746
+ destroyPQExpBuffer ( tblQry );
745
747
}
746
748
747
749
/**********
@@ -766,6 +768,8 @@ CreateBlobXrefTable(ArchiveHandle *AH)
766
768
767
769
appendPQExpBuffer (qry , "Create Unique Index %s_ix on %s(oldOid)" , BLOB_XREF_TABLE , BLOB_XREF_TABLE );
768
770
ExecuteSqlCommand (AH , qry , "could not create index on BLOB cross reference table" , true);
771
+
772
+ destroyPQExpBuffer (qry );
769
773
}
770
774
771
775
void
@@ -776,6 +780,8 @@ InsertBlobXref(ArchiveHandle *AH, int old, int new)
776
780
appendPQExpBuffer (qry , "Insert Into %s(oldOid, newOid) Values (%d, %d);" , BLOB_XREF_TABLE , old , new );
777
781
778
782
ExecuteSqlCommand (AH , qry , "could not create BLOB cross reference entry" , true);
783
+
784
+ destroyPQExpBuffer (qry );
779
785
}
780
786
781
787
void
@@ -787,6 +793,8 @@ StartTransaction(ArchiveHandle *AH)
787
793
788
794
ExecuteSqlCommand (AH , qry , "could not start database transaction" , false);
789
795
AH -> txActive = true;
796
+
797
+ destroyPQExpBuffer (qry );
790
798
}
791
799
792
800
void
@@ -799,6 +807,8 @@ StartTransactionXref(ArchiveHandle *AH)
799
807
ExecuteSqlCommand (AH , qry ,
800
808
"could not start transaction for BLOB cross references" , true);
801
809
AH -> blobTxActive = true;
810
+
811
+ destroyPQExpBuffer (qry );
802
812
}
803
813
804
814
void
@@ -810,6 +820,8 @@ CommitTransaction(ArchiveHandle *AH)
810
820
811
821
ExecuteSqlCommand (AH , qry , "could not commit database transaction" , false);
812
822
AH -> txActive = false;
823
+
824
+ destroyPQExpBuffer (qry );
813
825
}
814
826
815
827
void
@@ -821,4 +833,6 @@ CommitTransactionXref(ArchiveHandle *AH)
821
833
822
834
ExecuteSqlCommand (AH , qry , "could not commit transaction for BLOB cross references" , true);
823
835
AH -> blobTxActive = false;
836
+
837
+ destroyPQExpBuffer (qry );
824
838
}
0 commit comments