summaryrefslogtreecommitdiff
path: root/src/backend/storage/smgr/smgr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/storage/smgr/smgr.c')
-rw-r--r--src/backend/storage/smgr/smgr.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c
index 9e6500ff981..6676e0cae5c 100644
--- a/src/backend/storage/smgr/smgr.c
+++ b/src/backend/storage/smgr/smgr.c
@@ -586,6 +586,26 @@ smgrnblocks_cached(SMgrRelation reln, ForkNumber forknum)
* smgrtruncate() -- Truncate the given forks of supplied relation to
* each specified numbers of blocks
*
+ * Backward-compatible version of smgrtruncate2() for the benefit of external
+ * callers. This version isn't used in PostgreSQL core code, and can't be
+ * used in a critical section.
+ */
+void
+smgrtruncate(SMgrRelation reln, ForkNumber *forknum, int nforks,
+ BlockNumber *nblocks)
+{
+ BlockNumber old_nblocks[MAX_FORKNUM + 1];
+
+ for (int i = 0; i < nforks; ++i)
+ old_nblocks[i] = smgrnblocks(reln, forknum[i]);
+
+ return smgrtruncate2(reln, forknum, nforks, old_nblocks, nblocks);
+}
+
+/*
+ * smgrtruncate2() -- Truncate the given forks of supplied relation to
+ * each specified numbers of blocks
+ *
* The truncation is done immediately, so this can't be rolled back.
*
* The caller must hold AccessExclusiveLock on the relation, to ensure that
@@ -597,8 +617,8 @@ smgrnblocks_cached(SMgrRelation reln, ForkNumber forknum)
* to this relation should be called in between.
*/
void
-smgrtruncate(SMgrRelation reln, ForkNumber *forknum, int nforks,
- BlockNumber *old_nblocks, BlockNumber *nblocks)
+smgrtruncate2(SMgrRelation reln, ForkNumber *forknum, int nforks,
+ BlockNumber *old_nblocks, BlockNumber *nblocks)
{
int i;