Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit66aaabe

Browse files
committed
Restore smgrtruncate() prototype in back-branches.
It's possible that external code is calling smgrtruncate(). Anyexternal callers might like to consider the recent changes toRelationTruncate(), but commit38c579b should not have changed thefunction prototype in the back-branches, per ABI stability policy.Restore smgrtruncate()'s traditional argument list in the back-branches,but make it a wrapper for a new function smgrtruncate2(). The threecallers in core can use smgrtruncate2() directly. In master (18-to-be),smgrtruncate2() is effectively renamed to smgrtruncate(), so this wartis cleaned up.Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/CA%2BhUKG%2BThae6x6%2BjmQiuALQBT2Ae1ChjMh1%3DkMvJ8y_SBJZrvA%40mail.gmail.com
1 parente43537c commit66aaabe

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

‎contrib/pg_visibility/pg_visibility.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ pg_truncate_visibility_map(PG_FUNCTION_ARGS)
421421
}
422422

423423
if (BlockNumberIsValid(block))
424-
smgrtruncate(RelationGetSmgr(rel),&fork,1,&old_block,&block);
424+
smgrtruncate2(RelationGetSmgr(rel),&fork,1,&old_block,&block);
425425

426426
END_CRIT_SECTION();
427427
MyProc->delayChkptFlags &= ~(DELAY_CHKPT_START |DELAY_CHKPT_COMPLETE);

‎src/backend/catalog/storage.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ RelationTruncate(Relation rel, BlockNumber nblocks)
418418
* longer exist after truncation is complete, and then truncate the
419419
* corresponding files on disk.
420420
*/
421-
smgrtruncate(RelationGetSmgr(rel),forks,nforks,old_blocks,blocks);
421+
smgrtruncate2(RelationGetSmgr(rel),forks,nforks,old_blocks,blocks);
422422

423423
END_CRIT_SECTION();
424424

@@ -1059,7 +1059,7 @@ smgr_redo(XLogReaderState *record)
10591059
if (nforks>0)
10601060
{
10611061
START_CRIT_SECTION();
1062-
smgrtruncate(reln,forks,nforks,old_blocks,blocks);
1062+
smgrtruncate2(reln,forks,nforks,old_blocks,blocks);
10631063
END_CRIT_SECTION();
10641064
}
10651065

‎src/backend/storage/smgr/smgr.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,26 @@ smgrnblocks_cached(SMgrRelation reln, ForkNumber forknum)
693693
* smgrtruncate() -- Truncate the given forks of supplied relation to
694694
* each specified numbers of blocks
695695
*
696+
* Backward-compatible version of smgrtruncate2() for the benefit of external
697+
* callers. This version isn't used in PostgreSQL core code, and can't be
698+
* used in a critical section.
699+
*/
700+
void
701+
smgrtruncate(SMgrRelationreln,ForkNumber*forknum,intnforks,
702+
BlockNumber*nblocks)
703+
{
704+
BlockNumberold_nblocks[MAX_FORKNUM+1];
705+
706+
for (inti=0;i<nforks;++i)
707+
old_nblocks[i]=smgrnblocks(reln,forknum[i]);
708+
709+
returnsmgrtruncate2(reln,forknum,nforks,old_nblocks,nblocks);
710+
}
711+
712+
/*
713+
* smgrtruncate2() -- Truncate the given forks of supplied relation to
714+
* each specified numbers of blocks
715+
*
696716
* The truncation is done immediately, so this can't be rolled back.
697717
*
698718
* The caller must hold AccessExclusiveLock on the relation, to ensure that
@@ -704,8 +724,8 @@ smgrnblocks_cached(SMgrRelation reln, ForkNumber forknum)
704724
* to this relation should be called in between.
705725
*/
706726
void
707-
smgrtruncate(SMgrRelationreln,ForkNumber*forknum,intnforks,
708-
BlockNumber*old_nblocks,BlockNumber*nblocks)
727+
smgrtruncate2(SMgrRelationreln,ForkNumber*forknum,intnforks,
728+
BlockNumber*old_nblocks,BlockNumber*nblocks)
709729
{
710730
inti;
711731

‎src/include/storage/smgr.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ extern void smgrwriteback(SMgrRelation reln, ForkNumber forknum,
104104
externBlockNumbersmgrnblocks(SMgrRelationreln,ForkNumberforknum);
105105
externBlockNumbersmgrnblocks_cached(SMgrRelationreln,ForkNumberforknum);
106106
externvoidsmgrtruncate(SMgrRelationreln,ForkNumber*forknum,intnforks,
107-
BlockNumber*old_nblocks,
108107
BlockNumber*nblocks);
108+
externvoidsmgrtruncate2(SMgrRelationreln,ForkNumber*forknum,intnforks,
109+
BlockNumber*old_nblocks,
110+
BlockNumber*nblocks);
109111
externvoidsmgrimmedsync(SMgrRelationreln,ForkNumberforknum);
110112
externvoidsmgrregistersync(SMgrRelationreln,ForkNumberforknum);
111113
externvoidAtEOXact_SMgr(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp