aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-05-28 05:13:32 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-05-28 05:13:32 +0000
commit1a321f26d88e5c64bccba9d36920aede1e201729 (patch)
tree43940a3ed5cc754bff68748502550731b0ad19a0 /src/include
parent37da0ba0e0f2d92857dc62789820d21e177dc00f (diff)
downloadpostgresql-1a321f26d88e5c64bccba9d36920aede1e201729.tar.gz
postgresql-1a321f26d88e5c64bccba9d36920aede1e201729.zip
Code review for EXEC_BACKEND changes. Reduce the number of #ifdefs by
about a third, make it work on non-Windows platforms again. (But perhaps I broke the WIN32 code, since I have no way to test that.) Fold all the paths that fork postmaster child processes to go through the single routine SubPostmasterMain, which takes care of resurrecting the state that would normally be inherited from the postmaster (including GUC variables). Clean up some places where there's no particularly good reason for the EXEC and non-EXEC cases to work differently. Take care of one or two FIXMEs that remained in the code.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/slru.h35
-rw-r--r--src/include/bootstrap/bootstrap.h4
-rw-r--r--src/include/miscadmin.h12
-rw-r--r--src/include/pgstat.h33
-rw-r--r--src/include/storage/lock.h9
-rw-r--r--src/include/utils/guc.h6
6 files changed, 44 insertions, 55 deletions
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 851dfd865d3..fec968e7a20 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/slru.h,v 1.4 2003/11/29 22:40:55 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/access/slru.h,v 1.5 2004/05/28 05:13:17 tgl Exp $
*/
#ifndef SLRU_H
#define SLRU_H
@@ -16,35 +16,38 @@
/* exported because lwlock.c needs it */
#define NUM_CLOG_BUFFERS 8
+/*
+ * Note: the separation between SlruLockData and SlruSharedData is purely
+ * historical; the structs could be combined.
+ */
typedef struct SlruLockData
{
LWLockId ControlLock;
-/*
- * BufferLocks is set during CLOGShmemInit and does not change thereafter.
- * The value is automatically inherited by backends via fork, and
- * doesn't need to be in shared memory.
- */
LWLockId BufferLocks[NUM_CLOG_BUFFERS]; /* Per-buffer I/O locks */
} SlruLockData;
typedef SlruLockData *SlruLock;
+/*
+ * SlruCtlData is an unshared structure that points to the active information
+ * in shared memory.
+ */
typedef struct SlruCtlData
{
void *shared; /* pointer to SlruSharedData */
SlruLock locks;
-/*
- * Dir is set during SimpleLruShmemInit and does not change thereafter.
- * The value is automatically inherited by backends via fork, and
- * doesn't need to be in shared memory.
- */
+ /*
+ * Dir is set during SimpleLruShmemInit and does not change thereafter.
+ * The value is automatically inherited by backends via fork, and
+ * doesn't need to be in shared memory.
+ */
char Dir[MAXPGPATH];
-/*
- * Decide which of two page numbers is "older" for truncation purposes.
- * We need to use comparison of TransactionIds here in order to do the right
- * thing with wraparound XID arithmetic.
- */
+ /*
+ * Decide which of two page numbers is "older" for truncation purposes.
+ * We need to use comparison of TransactionIds here in order to do the
+ * right thing with wraparound XID arithmetic.
+ */
bool (*PagePrecedes) (int, int);
} SlruCtlData;
diff --git a/src/include/bootstrap/bootstrap.h b/src/include/bootstrap/bootstrap.h
index 719fb5a3b73..7dd9c808fde 100644
--- a/src/include/bootstrap/bootstrap.h
+++ b/src/include/bootstrap/bootstrap.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/bootstrap/bootstrap.h,v 1.33 2003/11/29 22:40:56 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/bootstrap/bootstrap.h,v 1.34 2004/05/28 05:13:21 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -34,7 +34,7 @@ typedef struct hashnode
extern Relation boot_reldesc;
extern Form_pg_attribute attrtypes[MAXATTR];
extern int numattr;
-extern int BootstrapMain(int ac, char *av[]);
+extern int BootstrapMain(int argc, char *argv[]);
extern void index_register(Oid heap, Oid ind, IndexInfo *indexInfo);
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index 03491f2ee56..e8e35fd6b58 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -13,7 +13,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.160 2004/05/18 03:36:44 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.161 2004/05/28 05:13:24 tgl Exp $
*
* NOTES
* some of the information in this file should be moved to
@@ -116,13 +116,13 @@ do { \
* from postmaster/postmaster.c
*/
extern bool ClientAuthInProgress;
-extern const bool ExecBackend;
extern int PostmasterMain(int argc, char *argv[]);
+extern void ClosePostmasterPorts(bool pgstat_too);
#ifdef EXEC_BACKEND
-extern void SubPostmasterMain(int argc, char* argv[]);
+extern pid_t postmaster_forkexec(int argc, char *argv[]);
+extern int SubPostmasterMain(int argc, char *argv[]);
#endif
-extern void ClosePostmasterPorts(bool pgstat_too);
#define PG_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
@@ -143,8 +143,10 @@ extern long MyCancelKey;
extern char OutputFileName[];
extern char my_exec_path[];
-extern char postgres_exec_path[];
extern char pkglib_path[];
+#ifdef EXEC_BACKEND
+extern char postgres_exec_path[];
+#endif
/*
* done in storage/backendid.h for now.
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index 7380a883cfa..8f7c4dc4515 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -5,7 +5,7 @@
*
* Copyright (c) 2001-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/include/pgstat.h,v 1.21 2004/03/09 05:11:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/pgstat.h,v 1.22 2004/05/28 05:13:25 tgl Exp $
* ----------
*/
#ifndef PGSTAT_H
@@ -325,18 +325,6 @@ typedef union PgStat_Msg
} PgStat_Msg;
-#ifdef EXEC_BACKEND
-typedef enum STATS_PROCESS_TYPE
-{
- STAT_PROC_BUFFER,
- STAT_PROC_COLLECTOR
-} STATS_PROCESS_TYPE;
-#define PGSTAT_FORK_ARGS int argc, char *argv[]
-#else
-#define PGSTAT_FORK_ARGS void
-#endif
-
-
/* ----------
* GUC parameters
* ----------
@@ -355,28 +343,21 @@ extern bool pgstat_is_running;
/* ----------
- * Functions called from main
- * ----------
- */
-#ifdef EXEC_BACKEND
-extern void pgstat_main(PGSTAT_FORK_ARGS);
-extern void pgstat_mainChild(PGSTAT_FORK_ARGS);
-#endif
-
-
-/* ----------
* Functions called from postmaster
* ----------
*/
-#ifdef EXEC_BACKEND
-extern void pgstat_init_forkexec_backend(void);
-#endif
extern void pgstat_init(void);
extern void pgstat_start(void);
extern bool pgstat_ispgstat(int pid);
extern void pgstat_close_sockets(void);
extern void pgstat_beterm(int pid);
+#ifdef EXEC_BACKEND
+extern void PgstatBufferMain(int argc, char *argv[]);
+extern void PgstatCollectorMain(int argc, char *argv[]);
+#endif
+
+
/* ----------
* Functions called from backends
* ----------
diff --git a/src/include/storage/lock.h b/src/include/storage/lock.h
index 2d13e9df114..8c7159c0cb0 100644
--- a/src/include/storage/lock.h
+++ b/src/include/storage/lock.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/storage/lock.h,v 1.76 2003/12/20 17:31:21 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/storage/lock.h,v 1.77 2004/05/28 05:13:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -223,13 +223,16 @@ typedef struct
LOCK *locks;
} LockData;
+extern int NumLockMethods;
+
/*
* function prototypes
*/
extern void InitLocks(void);
extern LockMethod GetLocksMethodTable(LOCK *lock);
-extern LOCKMETHODID LockMethodTableInit(char *tabName, LOCKMASK *conflictsP,
- int numModes, int maxBackends);
+extern LOCKMETHODID LockMethodTableInit(const char *tabName,
+ const LOCKMASK *conflictsP,
+ int numModes, int maxBackends);
extern LOCKMETHODID LockMethodTableRename(LOCKMETHODID lockmethodid);
extern bool LockAcquire(LOCKMETHODID lockmethodid, LOCKTAG *locktag,
TransactionId xid, LOCKMODE lockmode, bool dontWait);
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h
index 707dca33910..b91682af88f 100644
--- a/src/include/utils/guc.h
+++ b/src/include/utils/guc.h
@@ -7,7 +7,7 @@
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
- * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.46 2004/05/26 15:07:41 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.47 2004/05/28 05:13:32 tgl Exp $
*--------------------------------------------------------------------
*/
#ifndef GUC_H
@@ -206,8 +206,8 @@ extern ArrayType *GUCArrayAdd(ArrayType *array, const char *name, const char *va
extern ArrayType *GUCArrayDelete(ArrayType *array, const char *name);
#ifdef EXEC_BACKEND
-void write_nondefault_variables(GucContext context);
-void read_nondefault_variables(void);
+extern void write_nondefault_variables(GucContext context);
+extern void read_nondefault_variables(void);
#endif
/*