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

Commit772f63d

Browse files
committed
Fix nodeTidscan.c to not trigger an error if the block number portion of
a user-supplied TID is out of range for the relation. This is needed topreserve compatibility with our pre-8.3 behavior, and it is sensible anywaysince if the query were implemented by brute force rather than optimizedinto a TidScan, the behavior for a non-existent TID would be zero rows out,never an error. Per gripe from Gurjeet Singh.
1 parentca0aecf commit772f63d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

‎src/backend/executor/nodeTidscan.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/nodeTidscan.c,v 1.58 2008/01/01 19:45:49 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/nodeTidscan.c,v 1.59 2008/04/30 23:28:32 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -54,11 +54,20 @@ TidListCreate(TidScanState *tidstate)
5454
{
5555
List*evalList=tidstate->tss_tidquals;
5656
ExprContext*econtext=tidstate->ss.ps.ps_ExprContext;
57+
BlockNumbernblocks;
5758
ItemPointerData*tidList;
5859
intnumAllocTids;
5960
intnumTids;
6061
ListCell*l;
6162

63+
/*
64+
* We silently discard any TIDs that are out of range at the time of
65+
* scan start. (Since we hold at least AccessShareLock on the table,
66+
* it won't be possible for someone to truncate away the blocks we
67+
* intend to visit.)
68+
*/
69+
nblocks=RelationGetNumberOfBlocks(tidstate->ss.ss_currentRelation);
70+
6271
/*
6372
* We initialize the array with enough slots for the case that all quals
6473
* are simple OpExprs or CurrentOfExprs. If there are any
@@ -97,7 +106,9 @@ TidListCreate(TidScanState *tidstate)
97106
econtext,
98107
&isNull,
99108
NULL));
100-
if (!isNull&&ItemPointerIsValid(itemptr))
109+
if (!isNull&&
110+
ItemPointerIsValid(itemptr)&&
111+
ItemPointerGetBlockNumber(itemptr)<nblocks)
101112
{
102113
if (numTids >=numAllocTids)
103114
{
@@ -142,7 +153,8 @@ TidListCreate(TidScanState *tidstate)
142153
if (!ipnulls[i])
143154
{
144155
itemptr= (ItemPointer)DatumGetPointer(ipdatums[i]);
145-
if (ItemPointerIsValid(itemptr))
156+
if (ItemPointerIsValid(itemptr)&&
157+
ItemPointerGetBlockNumber(itemptr)<nblocks)
146158
tidList[numTids++]=*itemptr;
147159
}
148160
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp