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

Commitf14e408

Browse files
committed
Don't prematurely free the BufferAccessStrategy in pgstat_heap().
This function continued to use it after heap_endscan() freed it. Inpassing, don't explicit create a strategy here. Instead, use the onecreated by heap_beginscan_strat(), if any. Back-patch to 9.2, where useof a BufferAccessStrategy here was introduced.
1 parent9a28c37 commitf14e408

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

‎contrib/pgstattuple/pgstattuple.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,12 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
277277
BlockNumbertupblock;
278278
Bufferbuffer;
279279
pgstattuple_typestat= {0};
280-
BufferAccessStrategybstrategy;
281280

282281
/* Disable syncscan because we assume we scan from block zero upwards */
283282
scan=heap_beginscan_strat(rel,SnapshotAny,0,NULL, true, false);
284283

285284
nblocks=scan->rs_nblocks;/* # blocks to be scanned */
286285

287-
/* prepare access strategy for this table */
288-
bstrategy=GetAccessStrategy(BAS_BULKREAD);
289-
scan->rs_strategy=bstrategy;
290-
291286
/* scan the relation */
292287
while ((tuple=heap_getnext(scan,ForwardScanDirection))!=NULL)
293288
{
@@ -321,26 +316,28 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
321316
{
322317
CHECK_FOR_INTERRUPTS();
323318

324-
buffer=ReadBufferExtended(rel,MAIN_FORKNUM,block,RBM_NORMAL,bstrategy);
319+
buffer=ReadBufferExtended(rel,MAIN_FORKNUM,block,
320+
RBM_NORMAL,scan->rs_strategy);
325321
LockBuffer(buffer,BUFFER_LOCK_SHARE);
326322
stat.free_space+=PageGetHeapFreeSpace((Page)BufferGetPage(buffer));
327323
UnlockReleaseBuffer(buffer);
328324
block++;
329325
}
330326
}
331-
heap_endscan(scan);
332327

333328
while (block<nblocks)
334329
{
335330
CHECK_FOR_INTERRUPTS();
336331

337-
buffer=ReadBufferExtended(rel,MAIN_FORKNUM,block,RBM_NORMAL,bstrategy);
332+
buffer=ReadBufferExtended(rel,MAIN_FORKNUM,block,
333+
RBM_NORMAL,scan->rs_strategy);
338334
LockBuffer(buffer,BUFFER_LOCK_SHARE);
339335
stat.free_space+=PageGetHeapFreeSpace((Page)BufferGetPage(buffer));
340336
UnlockReleaseBuffer(buffer);
341337
block++;
342338
}
343339

340+
heap_endscan(scan);
344341
relation_close(rel,AccessShareLock);
345342

346343
stat.table_len= (uint64)nblocks*BLCKSZ;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp