* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.9 2004/01/26 22:35:31 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/slru.c,v 1.10 2004/01/28 21:02:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
shared = (SlruShared) ptr;
#ifdef EXEC_BACKEND
-
/*
* Locks are in shared memory
*/
locks = (SlruLock) (ptr + MAXALIGN(sizeof(SlruSharedData)) +
BLCKSZ * NUM_CLOG_BUFFERS);
#else
-
/*
* Locks are in private memory
*/
Assert(locks);
#endif
-
if (!IsUnderPostmaster)
- /* Initialize locks and shared memory area */
{
+ /* Initialize locks and shared memory area */
char *bufptr;
int slotno;
else
Assert(found);
-
ctl->locks = locks;
ctl->shared = shared;
-
/* Init directory path */
snprintf(ctl->Dir, MAXPGPATH, "%s/%s", DataDir, subdir);
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.225 2004/01/07 18:56:25 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.226 2004/01/28 21:02:39 tgl Exp $
*
*
* INTERFACE ROUTINES
* We cannot allow indexing a shared relation after initdb (because
* there's no way to make the entry in other databases' pg_class).
* Unfortunately we can't distinguish initdb from a manually started
- * standalone backend. However, we can at least prevent this mistake
- * under normal multi-user operation.
+ * standalone backend (toasting of shared rels happens after the bootstrap
+ * phase, so checking IsBootstrapProcessingMode() won't work). However,
+ * we can at least prevent this mistake under normal multi-user operation.
*/
if (shared_relation && IsUnderPostmaster)
ereport(ERROR,
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.216 2004/01/26 22:35:31 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.217 2004/01/28 21:02:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
}
if (pipe)
{
- if (IsUnderPostmaster)
+ if (whereToSendOutput == Remote)
ReceiveCopyBegin(binary, length(attnumlist));
else
copy_file = stdin;
}
if (pipe)
{
- if (IsUnderPostmaster)
+ if (whereToSendOutput == Remote)
SendCopyBegin(binary, length(attnumlist));
else
copy_file = stdout;
errmsg("could not write to file \"%s\": %m",
filename)));
}
- else if (IsUnderPostmaster && !is_from)
+ else if (whereToSendOutput == Remote && !is_from)
SendCopyEnd(binary);
pfree(attribute_buf.data);
pfree(line_buf.data);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.96 2004/01/23 02:13:11 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.97 2004/01/28 21:02:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* We cannot allow toasting a shared relation after initdb (because
* there's no way to mark it toasted in other databases' pg_class).
* Unfortunately we can't distinguish initdb from a manually started
- * standalone backend. However, we can at least prevent this mistake
- * under normal multi-user operation.
+ * standalone backend (toasting happens after the bootstrap phase,
+ * so checking IsBootstrapProcessingMode() won't work). However, we can
+ * at least prevent this mistake under normal multi-user operation.
*/
shared_relation = rel->rd_rel->relisshared;
if (shared_relation && IsUnderPostmaster)
*
* Copyright (c) 2001-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.56 2004/01/26 22:59:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.57 2004/01/28 21:02:40 tgl Exp $
* ----------
*/
#include "postgres.h"
{
IsUnderPostmaster = true; /* we are a postmaster subprocess now */
+#ifdef EXEC_BACKEND
+ /* In EXEC case we will not have inherited these settings */
+ IsPostmasterEnvironment = true;
+ whereToSendOutput = None;
+#endif
+
MyProcPid = getpid(); /* reset MyProcPid */
/* Lose the postmaster's on-exit routines */
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.363 2004/01/27 00:45:26 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.364 2004/01/28 21:02:40 tgl Exp $
*
* NOTES
*
/* Do this sooner rather than later... */
IsUnderPostmaster = true; /* we are a postmaster subprocess now */
+ /* In EXEC case we will not have inherited these settings */
+ IsPostmasterEnvironment = true;
+ whereToSendOutput = None;
+
/* Setup global context */
MemoryContextInit();
InitializeGUCOptions();
IsUnderPostmaster = true; /* we are a postmaster subprocess
* now */
+#ifdef EXEC_BACKEND
+ /* In EXEC case we will not have inherited these settings */
+ IsPostmasterEnvironment = true;
+ whereToSendOutput = None;
+#endif
+
+ MyProcPid = getpid(); /* reset MyProcPid */
+
/* Lose the postmaster's on-exit routines and port connections */
on_exit_reset();
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.386 2004/01/26 22:59:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.387 2004/01/28 21:02:40 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
{
int result;
- if (IsUnderPostmaster)
+ if (whereToSendOutput == Remote)
result = SocketBackend(inBuf);
else
result = InteractiveBackend(inBuf);
/* Need not flush since ReadyForQuery will do it. */
}
- /* Welcome banner for non-frontend case */
- if (!IsUnderPostmaster)
+ /* Welcome banner for standalone case */
+ if (whereToSendOutput == Debug)
printf("\nPostgreSQL stand-alone backend %s\n", PG_VERSION);
/*
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.80 2004/01/26 22:59:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.81 2004/01/28 21:02:40 tgl Exp $
*
* NOTES
* Globals used all over the place should be declared here and not
char *DatabasePath = NULL;
Oid MyDatabaseId = InvalidOid;
-pid_t PostmasterPid = 0;
+pid_t PostmasterPid = 0;
-/* these are initialized for the bootstrap/standalone case: */
+/*
+ * IsPostmasterEnvironment is true in a postmaster process and any postmaster
+ * child process; it is false in a standalone process (bootstrap or
+ * standalone backend). IsUnderPostmaster is true in postmaster child
+ * processes. Note that "child process" includes all children, not only
+ * regular backends. These should be set correctly as early as possible
+ * in the execution of a process, so that error handling will do the right
+ * things if an error should occur during process initialization.
+ *
+ * These are initialized for the bootstrap/standalone case.
+ */
bool IsPostmasterEnvironment = false;
bool IsUnderPostmaster = false;