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

Commit9d0826c

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 parent6647f59 commit9d0826c

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
@@ -274,7 +274,6 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
274274
BlockNumbertupblock;
275275
Bufferbuffer;
276276
pgstattuple_typestat= {0};
277-
BufferAccessStrategybstrategy;
278277
SnapshotDataSnapshotDirty;
279278

280279
/* Disable syncscan because we assume we scan from block zero upwards */
@@ -283,10 +282,6 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
283282

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

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

323-
buffer=ReadBufferExtended(rel,MAIN_FORKNUM,block,RBM_NORMAL,bstrategy);
318+
buffer=ReadBufferExtended(rel,MAIN_FORKNUM,block,
319+
RBM_NORMAL,scan->rs_strategy);
324320
LockBuffer(buffer,BUFFER_LOCK_SHARE);
325321
stat.free_space+=PageGetHeapFreeSpace((Page)BufferGetPage(buffer));
326322
UnlockReleaseBuffer(buffer);
327323
block++;
328324
}
329325
}
330-
heap_endscan(scan);
331326

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

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

339+
heap_endscan(scan);
343340
relation_close(rel,AccessShareLock);
344341

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp