23
23
* Modifications - 31-Jul-2000 - pjw@rhyme.com.au (1.46, 1.47)
24
24
* Fixed version number initialization in _allocAH (pg_backup_archiver.c)
25
25
*
26
+ *
27
+ * Modifications - 30-Oct-2000 - pjw@rhyme.com.au
28
+ * Added {Start,End}RestoreBlobs to allow extended TX during BLOB restore.
29
+ *
26
30
*-------------------------------------------------------------------------
27
31
*/
28
32
@@ -590,13 +594,43 @@ int EndBlob(Archive* AHX, int oid)
590
594
* BLOB Restoration
591
595
**********/
592
596
597
+ /*
598
+ * Called by a format handler before any blobs are restored
599
+ */
600
+ void StartRestoreBlobs (ArchiveHandle * AH )
601
+ {
602
+ AH -> blobCount = 0 ;
603
+ }
604
+
605
+ /*
606
+ * Called by a format handler after all blobs are restored
607
+ */
608
+ void EndRestoreBlobs (ArchiveHandle * AH )
609
+ {
610
+ if (AH -> txActive )
611
+ {
612
+ ahlog (AH , 2 , "Committing BLOB transactions\n" );
613
+ CommitTransaction (AH );
614
+ }
615
+
616
+ if (AH -> blobTxActive )
617
+ {
618
+ CommitTransactionXref (AH );
619
+ }
620
+
621
+ ahlog (AH , 1 , "Restored %d BLOBs\n" , AH -> blobCount );
622
+ }
623
+
624
+
593
625
/*
594
626
* Called by a format handler to initiate restoration of a blob
595
627
*/
596
628
void StartRestoreBlob (ArchiveHandle * AH , int oid )
597
629
{
598
630
int loOid ;
599
631
632
+ AH -> blobCount ++ ;
633
+
600
634
if (!AH -> createdBlobXref )
601
635
{
602
636
if (!AH -> connection )
@@ -606,7 +640,18 @@ void StartRestoreBlob(ArchiveHandle* AH, int oid)
606
640
AH -> createdBlobXref = 1 ;
607
641
}
608
642
609
- StartTransaction (AH );
643
+ /*
644
+ * Start long-running TXs if necessary
645
+ */
646
+ if (!AH -> txActive )
647
+ {
648
+ ahlog (AH , 2 , "Starting BLOB transactions\n" );
649
+ StartTransaction (AH );
650
+ }
651
+ if (!AH -> blobTxActive )
652
+ {
653
+ StartTransactionXref (AH );
654
+ }
610
655
611
656
loOid = lo_creat (AH -> connection , INV_READ | INV_WRITE );
612
657
if (loOid == 0 )
@@ -628,7 +673,15 @@ void EndRestoreBlob(ArchiveHandle* AH, int oid)
628
673
lo_close (AH -> connection , AH -> loFd );
629
674
AH -> writingBlob = 0 ;
630
675
631
- CommitTransaction (AH );
676
+ /*
677
+ * Commit every BLOB_BATCH_SIZE blobs...
678
+ */
679
+ if ( ((AH -> blobCount / BLOB_BATCH_SIZE ) * BLOB_BATCH_SIZE ) == AH -> blobCount )
680
+ {
681
+ ahlog (AH , 2 , "Committing BLOB transactions\n" );
682
+ CommitTransaction (AH );
683
+ CommitTransactionXref (AH );
684
+ }
632
685
}
633
686
634
687
/***********
0 commit comments