Skip to content

Commit 841df96

Browse files
committed
Insert CHECK_FOR_INTERRUPTS calls into loops in dbsize.c, to ensure that
the various disk-size-reporting functions will respond to query cancel reasonably promptly even in very large databases. Per report from Kevin Grittner.
1 parent a06ea6f commit 841df96

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/backend/utils/adt/dbsize.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Copyright (c) 2002-2010, PostgreSQL Global Development Group
66
*
77
* IDENTIFICATION
8-
* $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.27 2010/01/19 05:50:18 tgl Exp $
8+
* $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.28 2010/01/23 21:29:00 tgl Exp $
99
*
1010
*/
1111

@@ -46,6 +46,8 @@ db_dir_size(const char *path)
4646
{
4747
struct stat fst;
4848

49+
CHECK_FOR_INTERRUPTS();
50+
4951
if (strcmp(direntry->d_name, ".") == 0 ||
5052
strcmp(direntry->d_name, "..") == 0)
5153
continue;
@@ -104,6 +106,8 @@ calculate_database_size(Oid dbOid)
104106

105107
while ((direntry = ReadDir(dirdesc, dirpath)) != NULL)
106108
{
109+
CHECK_FOR_INTERRUPTS();
110+
107111
if (strcmp(direntry->d_name, ".") == 0 ||
108112
strcmp(direntry->d_name, "..") == 0)
109113
continue;
@@ -194,6 +198,8 @@ calculate_tablespace_size(Oid tblspcOid)
194198
{
195199
struct stat fst;
196200

201+
CHECK_FOR_INTERRUPTS();
202+
197203
if (strcmp(direntry->d_name, ".") == 0 ||
198204
strcmp(direntry->d_name, "..") == 0)
199205
continue;
@@ -262,6 +268,8 @@ calculate_relation_size(RelFileNode *rfn, ForkNumber forknum)
262268
{
263269
struct stat fst;
264270

271+
CHECK_FOR_INTERRUPTS();
272+
265273
if (segcount == 0)
266274
snprintf(pathname, MAXPGPATH, "%s",
267275
relationpath);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy