Commit 841df96f authored by Tom Lane's avatar Tom Lane

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.
parent a06ea6f5
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Copyright (c) 2002-2010, PostgreSQL Global Development Group * Copyright (c) 2002-2010, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.27 2010/01/19 05:50:18 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.28 2010/01/23 21:29:00 tgl Exp $
* *
*/ */
...@@ -46,6 +46,8 @@ db_dir_size(const char *path) ...@@ -46,6 +46,8 @@ db_dir_size(const char *path)
{ {
struct stat fst; struct stat fst;
CHECK_FOR_INTERRUPTS();
if (strcmp(direntry->d_name, ".") == 0 || if (strcmp(direntry->d_name, ".") == 0 ||
strcmp(direntry->d_name, "..") == 0) strcmp(direntry->d_name, "..") == 0)
continue; continue;
...@@ -104,6 +106,8 @@ calculate_database_size(Oid dbOid) ...@@ -104,6 +106,8 @@ calculate_database_size(Oid dbOid)
while ((direntry = ReadDir(dirdesc, dirpath)) != NULL) while ((direntry = ReadDir(dirdesc, dirpath)) != NULL)
{ {
CHECK_FOR_INTERRUPTS();
if (strcmp(direntry->d_name, ".") == 0 || if (strcmp(direntry->d_name, ".") == 0 ||
strcmp(direntry->d_name, "..") == 0) strcmp(direntry->d_name, "..") == 0)
continue; continue;
...@@ -194,6 +198,8 @@ calculate_tablespace_size(Oid tblspcOid) ...@@ -194,6 +198,8 @@ calculate_tablespace_size(Oid tblspcOid)
{ {
struct stat fst; struct stat fst;
CHECK_FOR_INTERRUPTS();
if (strcmp(direntry->d_name, ".") == 0 || if (strcmp(direntry->d_name, ".") == 0 ||
strcmp(direntry->d_name, "..") == 0) strcmp(direntry->d_name, "..") == 0)
continue; continue;
...@@ -262,6 +268,8 @@ calculate_relation_size(RelFileNode *rfn, ForkNumber forknum) ...@@ -262,6 +268,8 @@ calculate_relation_size(RelFileNode *rfn, ForkNumber forknum)
{ {
struct stat fst; struct stat fst;
CHECK_FOR_INTERRUPTS();
if (segcount == 0) if (segcount == 0)
snprintf(pathname, MAXPGPATH, "%s", snprintf(pathname, MAXPGPATH, "%s",
relationpath); relationpath);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment