1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-08 06:02:22 +03:00

Ensure that contrib/pgstattuple functions respond to cancel interrupts

reasonably promptly, by adding CHECK_FOR_INTERRUPTS in the per-page loops.

Tatsuhito Kasahara
This commit is contained in:
Tom Lane
2010-04-02 16:17:24 +00:00
parent d07f594705
commit 9d76c53537

View File

@@ -1,5 +1,5 @@
/* /*
* $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.17.4.1 2009/03/31 22:56:18 tgl Exp $ * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.17.4.2 2010/04/02 16:17:24 tgl Exp $
* *
* Copyright (c) 2001,2002 Tatsuo Ishii * Copyright (c) 2001,2002 Tatsuo Ishii
* *
@@ -29,6 +29,7 @@
#include "access/heapam.h" #include "access/heapam.h"
#include "access/transam.h" #include "access/transam.h"
#include "catalog/namespace.h" #include "catalog/namespace.h"
#include "miscadmin.h"
#include "utils/builtins.h" #include "utils/builtins.h"
@@ -144,6 +145,8 @@ pgstattuple_real(Relation rel)
/* scan the relation */ /* scan the relation */
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{ {
CHECK_FOR_INTERRUPTS();
/* must hold a buffer lock to call HeapTupleSatisfiesNow */ /* must hold a buffer lock to call HeapTupleSatisfiesNow */
LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE); LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE);
@@ -170,6 +173,8 @@ pgstattuple_real(Relation rel)
while (block <= tupblock) while (block <= tupblock)
{ {
CHECK_FOR_INTERRUPTS();
buffer = ReadBuffer(rel, block); buffer = ReadBuffer(rel, block);
LockBuffer(buffer, BUFFER_LOCK_SHARE); LockBuffer(buffer, BUFFER_LOCK_SHARE);
free_space += PageGetFreeSpace((Page) BufferGetPage(buffer)); free_space += PageGetFreeSpace((Page) BufferGetPage(buffer));
@@ -182,6 +187,8 @@ pgstattuple_real(Relation rel)
while (block < nblocks) while (block < nblocks)
{ {
CHECK_FOR_INTERRUPTS();
buffer = ReadBuffer(rel, block); buffer = ReadBuffer(rel, block);
free_space += PageGetFreeSpace((Page) BufferGetPage(buffer)); free_space += PageGetFreeSpace((Page) BufferGetPage(buffer));
ReleaseBuffer(buffer); ReleaseBuffer(buffer);