|
|
@ -3712,6 +3712,7 @@ RelationCopyStorageUsingBuffer(RelFileLocator srclocator, |
|
|
|
bool use_wal; |
|
|
|
bool use_wal; |
|
|
|
BlockNumber nblocks; |
|
|
|
BlockNumber nblocks; |
|
|
|
BlockNumber blkno; |
|
|
|
BlockNumber blkno; |
|
|
|
|
|
|
|
PGAlignedBlock buf; |
|
|
|
BufferAccessStrategy bstrategy_src; |
|
|
|
BufferAccessStrategy bstrategy_src; |
|
|
|
BufferAccessStrategy bstrategy_dst; |
|
|
|
BufferAccessStrategy bstrategy_dst; |
|
|
|
|
|
|
|
|
|
|
@ -3730,6 +3731,14 @@ RelationCopyStorageUsingBuffer(RelFileLocator srclocator, |
|
|
|
if (nblocks == 0) |
|
|
|
if (nblocks == 0) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Bulk extend the destination relation of the same size as the source |
|
|
|
|
|
|
|
* relation before starting to copy block by block. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
memset(buf.data, 0, BLCKSZ); |
|
|
|
|
|
|
|
smgrextend(smgropen(dstlocator, InvalidBackendId), forkNum, nblocks - 1, |
|
|
|
|
|
|
|
buf.data, true); |
|
|
|
|
|
|
|
|
|
|
|
/* This is a bulk operation, so use buffer access strategies. */ |
|
|
|
/* This is a bulk operation, so use buffer access strategies. */ |
|
|
|
bstrategy_src = GetAccessStrategy(BAS_BULKREAD); |
|
|
|
bstrategy_src = GetAccessStrategy(BAS_BULKREAD); |
|
|
|
bstrategy_dst = GetAccessStrategy(BAS_BULKWRITE); |
|
|
|
bstrategy_dst = GetAccessStrategy(BAS_BULKWRITE); |
|
|
@ -3747,7 +3756,7 @@ RelationCopyStorageUsingBuffer(RelFileLocator srclocator, |
|
|
|
srcPage = BufferGetPage(srcBuf); |
|
|
|
srcPage = BufferGetPage(srcBuf); |
|
|
|
|
|
|
|
|
|
|
|
/* Use P_NEW to extend the destination relation. */ |
|
|
|
/* Use P_NEW to extend the destination relation. */ |
|
|
|
dstBuf = ReadBufferWithoutRelcache(dstlocator, forkNum, P_NEW, |
|
|
|
dstBuf = ReadBufferWithoutRelcache(dstlocator, forkNum, blkno, |
|
|
|
RBM_NORMAL, bstrategy_dst, |
|
|
|
RBM_NORMAL, bstrategy_dst, |
|
|
|
permanent); |
|
|
|
permanent); |
|
|
|
LockBuffer(dstBuf, BUFFER_LOCK_EXCLUSIVE); |
|
|
|
LockBuffer(dstBuf, BUFFER_LOCK_EXCLUSIVE); |
|
|
|