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

Commit1ea9414

Browse files
committed
Check block number against the correct fork in get_raw_page().
get_raw_page tried to validate the supplied block number againstRelationGetNumberOfBlocks(), which of course is only right whenaccessing the main fork. In most cases, the main fork is longerthan the others, so that the check was too weak (allowing alower-level error to be reported, but no real harm to be done).However, very small tables could have an FSM larger than their heap,in which case the mistake prevented access to some FSM pages.Per report from Torsten Foertsch.In passing, make the bad-block-number error into an ereport not elog(since it's certainly not an internal error); and fix sloppilymaintained comment for RelationGetNumberOfBlocksInFork.This has been wrong since we invented relation forks, so back-patchto all supported branches.
1 parenta61f63d commit1ea9414

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

‎contrib/pageinspect/rawpage.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,11 @@ get_raw_page_internal(text *relname, ForkNumber forknum, BlockNumber blkno)
131131
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
132132
errmsg("cannot access temporary tables of other sessions")));
133133

134-
if (blkno >=RelationGetNumberOfBlocks(rel))
135-
elog(ERROR,"block number %u is out of range for relation \"%s\"",
136-
blkno,RelationGetRelationName(rel));
134+
if (blkno >=RelationGetNumberOfBlocksInFork(rel,forknum))
135+
ereport(ERROR,
136+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
137+
errmsg("block number %u is out of range for relation \"%s\"",
138+
blkno,RelationGetRelationName(rel))));
137139

138140
/* Initialize buffer to copy to */
139141
raw_page= (bytea*)palloc(BLCKSZ+VARHDRSZ);

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,8 +2032,8 @@ FlushBuffer(volatile BufferDesc *buf, SMgrRelation reln)
20322032
}
20332033

20342034
/*
2035-
*RelationGetNumberOfBlocks
2036-
*Determines the current number of pages in the relation.
2035+
*RelationGetNumberOfBlocksInFork
2036+
*Determines the current number of pages in thespecifiedrelation fork.
20372037
*/
20382038
BlockNumber
20392039
RelationGetNumberOfBlocksInFork(Relationrelation,ForkNumberforkNum)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp