mirror of
https://github.com/postgres/postgres.git
synced 2025-10-16 17:07:43 +03:00
Added long-standing transaction when restoring BLOBS (uses commit every BLOB_BATCH_SIZE)
Prevent dumping of languages from template1.
This commit is contained in:
@@ -23,6 +23,10 @@
|
||||
* Modifications - 31-Jul-2000 - pjw@rhyme.com.au (1.46, 1.47)
|
||||
* Fixed version number initialization in _allocAH (pg_backup_archiver.c)
|
||||
*
|
||||
*
|
||||
* Modifications - 30-Oct-2000 - pjw@rhyme.com.au
|
||||
* Added {Start,End}RestoreBlobs to allow extended TX during BLOB restore.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@@ -590,6 +594,34 @@ int EndBlob(Archive* AHX, int oid)
|
||||
* BLOB Restoration
|
||||
**********/
|
||||
|
||||
/*
|
||||
* Called by a format handler before any blobs are restored
|
||||
*/
|
||||
void StartRestoreBlobs(ArchiveHandle* AH)
|
||||
{
|
||||
AH->blobCount = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called by a format handler after all blobs are restored
|
||||
*/
|
||||
void EndRestoreBlobs(ArchiveHandle* AH)
|
||||
{
|
||||
if (AH->txActive)
|
||||
{
|
||||
ahlog(AH, 2, "Committing BLOB transactions\n");
|
||||
CommitTransaction(AH);
|
||||
}
|
||||
|
||||
if (AH->blobTxActive)
|
||||
{
|
||||
CommitTransactionXref(AH);
|
||||
}
|
||||
|
||||
ahlog(AH, 1, "Restored %d BLOBs\n", AH->blobCount);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called by a format handler to initiate restoration of a blob
|
||||
*/
|
||||
@@ -597,6 +629,8 @@ void StartRestoreBlob(ArchiveHandle* AH, int oid)
|
||||
{
|
||||
int loOid;
|
||||
|
||||
AH->blobCount++;
|
||||
|
||||
if (!AH->createdBlobXref)
|
||||
{
|
||||
if (!AH->connection)
|
||||
@@ -606,7 +640,18 @@ void StartRestoreBlob(ArchiveHandle* AH, int oid)
|
||||
AH->createdBlobXref = 1;
|
||||
}
|
||||
|
||||
StartTransaction(AH);
|
||||
/*
|
||||
* Start long-running TXs if necessary
|
||||
*/
|
||||
if (!AH->txActive)
|
||||
{
|
||||
ahlog(AH, 2, "Starting BLOB transactions\n");
|
||||
StartTransaction(AH);
|
||||
}
|
||||
if (!AH->blobTxActive)
|
||||
{
|
||||
StartTransactionXref(AH);
|
||||
}
|
||||
|
||||
loOid = lo_creat(AH->connection, INV_READ | INV_WRITE);
|
||||
if (loOid == 0)
|
||||
@@ -628,7 +673,15 @@ void EndRestoreBlob(ArchiveHandle* AH, int oid)
|
||||
lo_close(AH->connection, AH->loFd);
|
||||
AH->writingBlob = 0;
|
||||
|
||||
CommitTransaction(AH);
|
||||
/*
|
||||
* Commit every BLOB_BATCH_SIZE blobs...
|
||||
*/
|
||||
if ( ((AH->blobCount / BLOB_BATCH_SIZE) * BLOB_BATCH_SIZE) == AH->blobCount)
|
||||
{
|
||||
ahlog(AH, 2, "Committing BLOB transactions\n");
|
||||
CommitTransaction(AH);
|
||||
CommitTransactionXref(AH);
|
||||
}
|
||||
}
|
||||
|
||||
/***********
|
||||
|
Reference in New Issue
Block a user