]> granicus.if.org Git - postgresql/commitdiff
Insert CHECK_FOR_INTERRUPTS calls into loops in dbsize.c, to ensure that
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 23 Jan 2010 21:29:00 +0000 (21:29 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 23 Jan 2010 21:29:00 +0000 (21:29 +0000)
the various disk-size-reporting functions will respond to query cancel
reasonably promptly even in very large databases.  Per report from
Kevin Grittner.

src/backend/utils/adt/dbsize.c

index 47d1df88fa814eb00b774391034665ff87429e85..d2d91975872cff61c9adbd5ee41dd6101be15784 100644 (file)
@@ -5,7 +5,7 @@
  * Copyright (c) 2002-2010, PostgreSQL Global Development Group
  *
  * 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)
        {
                struct stat fst;
 
+               CHECK_FOR_INTERRUPTS();
+
                if (strcmp(direntry->d_name, ".") == 0 ||
                        strcmp(direntry->d_name, "..") == 0)
                        continue;
@@ -104,6 +106,8 @@ calculate_database_size(Oid dbOid)
 
        while ((direntry = ReadDir(dirdesc, dirpath)) != NULL)
        {
+               CHECK_FOR_INTERRUPTS();
+
                if (strcmp(direntry->d_name, ".") == 0 ||
                        strcmp(direntry->d_name, "..") == 0)
                        continue;
@@ -194,6 +198,8 @@ calculate_tablespace_size(Oid tblspcOid)
        {
                struct stat fst;
 
+               CHECK_FOR_INTERRUPTS();
+
                if (strcmp(direntry->d_name, ".") == 0 ||
                        strcmp(direntry->d_name, "..") == 0)
                        continue;
@@ -262,6 +268,8 @@ calculate_relation_size(RelFileNode *rfn, ForkNumber forknum)
        {
                struct stat fst;
 
+               CHECK_FOR_INTERRUPTS();
+
                if (segcount == 0)
                        snprintf(pathname, MAXPGPATH, "%s",
                                         relationpath);