diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-02-10 03:42:45 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-02-10 03:42:45 +0000 |
commit | 58f337a3435cd6ac46dfca4ce1a44b837080745e (patch) | |
tree | 03e4a309f7ada6914474c02fd9b53df7ab1da975 /src/include | |
parent | 87bd95638552b8fc1f5f787ce5b862bb6fc2eb80 (diff) | |
download | postgresql-58f337a3435cd6ac46dfca4ce1a44b837080745e.tar.gz |
Centralize implementation of delay code by creating a pg_usleep()
subroutine in src/port/pgsleep.c. Remove platform dependencies from
miscadmin.h and put them in port.h where they belong. Extend recent
vacuum cost-based-delay patch to apply to VACUUM FULL, ANALYZE, and
non-btree index vacuuming.
By the way, where is the documentation for the cost-based-delay patch?
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/commands/vacuum.h | 3 | ||||
-rw-r--r-- | src/include/miscadmin.h | 39 | ||||
-rw-r--r-- | src/include/port.h | 7 |
3 files changed, 13 insertions, 36 deletions
diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h index e93942fd25..61985b0d39 100644 --- a/src/include/commands/vacuum.h +++ b/src/include/commands/vacuum.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.47 2003/11/29 22:40:59 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.48 2004/02/10 03:42:45 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,7 @@ extern void vacuum_set_xid_limits(VacuumStmt *vacstmt, bool sharedRel, extern bool vac_is_partial_index(Relation indrel); extern void vac_init_rusage(VacRUsage *ru0); extern const char *vac_show_rusage(VacRUsage *ru0); +extern void vacuum_delay_point(void); /* in commands/vacuumlazy.c */ extern void lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt); diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index 7e9a209331..b43d481c52 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.152 2004/02/08 22:28:57 neilc Exp $ + * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.153 2004/02/10 03:42:45 tgl Exp $ * * NOTES * some of the information in this file should be moved to @@ -24,7 +24,6 @@ #define MISCADMIN_H - /***************************************************************************** * System interrupt and critical section handling * @@ -83,10 +82,10 @@ do { \ #else #define CHECK_FOR_INTERRUPTS() \ do { \ - WaitForSingleObjectEx(GetCurrentThread(),0,TRUE); \ + WaitForSingleObjectEx(GetCurrentThread(),0,TRUE); \ if (InterruptPending) \ ProcessInterrupts(); \ -} while (0) +} while(0) #endif @@ -106,34 +105,6 @@ do { \ CritSectionCount--; \ } while(0) -#ifndef WIN32 -#define PG_USLEEP(_usec) \ -do { \ - /* This will overflow on systems with 32-bit ints for > ~2000 secs */ \ - struct timeval delay; \ - \ - delay.tv_sec = (_usec) / 1000000; \ - delay.tv_usec = ((_usec) % 1000000); \ - (void) select(0, NULL, NULL, NULL, &delay); \ -} while(0) -#define PG_MSLEEP(_msec) \ -do { \ - struct timeval _delay; \ - _delay.tv_sec = (_msec) / 1000; \ - _delay.tv_usec = ((_msec) % 1000) * 1000; \ - (void) select (0, NULL, NULL, NULL, &_delay); \ -} while(0) -#else -#define PG_USLEEP(_usec) \ -do { \ - SleepEx(((_usec) < 500 ? 1 : ((_usec) + 500) / 1000), TRUE); \ -} while(0) -#define PG_MSLEEP(_msec) PG_USLEEP((_msec) * 1000) -#endif - -#ifdef WIN32 -#define ftruncate(a,b) chsize(a,b) -#endif /***************************************************************************** * globals.h -- * @@ -227,14 +198,14 @@ extern bool enableFsync; extern bool allowSystemTableMods; extern DLLIMPORT int work_mem; extern DLLIMPORT int maintenance_work_mem; -extern int VacuumMem; extern int VacuumCostPageHit; extern int VacuumCostPageMiss; extern int VacuumCostPageDirty; extern int VacuumCostLimit; -extern int VacuumCostBalance; extern int VacuumCostNaptime; + +extern int VacuumCostBalance; extern bool VacuumCostActive; /* diff --git a/src/include/port.h b/src/include/port.h index a885e91424..40ccc8a6d2 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/port.h,v 1.18 2004/02/02 22:20:33 momjian Exp $ + * $PostgreSQL: pgsql/src/include/port.h,v 1.19 2004/02/10 03:42:45 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -23,6 +23,10 @@ extern char *first_path_separator(const char *filename); extern char *last_path_separator(const char *filename); extern char *get_progname(char *argv0); +/* Portable delay handling */ +extern void pg_usleep(long microsec); + +/* Portable prompt handling */ extern char *simple_prompt(const char *prompt, int maxlen, bool echo); #if defined(bsdi) || defined(netbsd) @@ -138,6 +142,7 @@ extern int pqGethostbyname(const char *name, #ifdef WIN32 #define fsync(a) _commit(a) #define sync() _flushall() +#define ftruncate(a,b) chsize(a,b) #define WEXITSTATUS(w) (((w) >> 8) & 0xff) #define WIFEXITED(w) (((w) & 0xff) == 0) #define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f)) |