* Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.32 1998/01/07 21:02:30 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.33 1998/01/25 05:12:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* -------------------
*/
- MasterPid = getpid();
+ MyProcPid = getpid();
/* ----------------
* process command arguments
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.26 1997/12/17 04:44:49 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.27 1998/01/25 05:12:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include <postgres.h>
+#include <miscadmin.h>
#include <utils/syscache.h>
#include <access/relscan.h>
#include <access/xact.h>
TupleDesc tdesc;
ScanKeyData key;
Datum d;
- int ourpid;
bool isnull;
Buffer b;
extern TransactionState CurrentTransactionState;
RelationSetLockForWrite(lRel);
sRel = heap_beginscan(lRel, 0, false, 1, &key);
tdesc = RelationGetTupleDescriptor(lRel);
- ourpid = getpid();
while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0, &b)))
{
d = heap_getattr(lTuple, b, Anum_pg_listener_pid,
tdesc, &isnull);
- if (ourpid == DatumGetInt32(d))
+ if (MyProcPid == DatumGetInt32(d))
{
#ifdef ASYNC_DEBUG
elog(DEBUG, "Notifying self, setting notifyFronEndPending to 1");
int i;
bool isnull;
int alreadyListener = 0;
- int ourPid = getpid();
char *relnamei;
TupleDesc tupDesc;
{
d = heap_getattr(htup, b, Anum_pg_listener_pid, tdesc, &isnull);
pid = DatumGetInt32(d);
- if (pid == ourPid)
+ if (pid == MyProcPid)
{
alreadyListener = 1;
}
Async_UnlistenOnExit(int code, /* from exitpg */
char *relname)
{
- Async_Unlisten((char *) relname, getpid());
+ Async_Unlisten((char *) relname, MyProcPid);
}
/*
char repl[3],
nulls[3];
Buffer b;
- int ourpid;
bool isnull;
notifyFrontEndPending = 0;
#endif
StartTransactionCommand();
- ourpid = getpid();
ScanKeyEntryInitialize(&key[0], 0,
Anum_pg_listener_notify,
Integer32EqualRegProcedure,
ScanKeyEntryInitialize(&key[1], 0,
Anum_pg_listener_pid,
Integer32EqualRegProcedure,
- Int32GetDatum(ourpid));
+ Int32GetDatum(MyProcPid));
lRel = heap_openr(ListenerRelationName);
RelationSetLockForWrite(lRel);
tdesc = RelationGetTupleDescriptor(lRel);
if (whereToSendOutput == Remote)
{
pq_putnchar("A", 1);
- pq_putint(ourpid, sizeof(ourpid));
+ pq_putint((int32)MyProcPid, sizeof(int32));
pq_putstr(DatumGetName(d)->data);
pq_flush();
}
*/
filename = crypt_getpwdfilename();
tempname = (char*)malloc(strlen(filename) + 12);
- sprintf(tempname, "%s.%d", filename, getpid());
+ sprintf(tempname, "%s.%d", filename, MyProcPid);
/* Copy the contents of pg_user to the pg_pwd ASCII file using a the SEPCHAR
* character as the delimiter between fields. Then rename the file to its
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.16 1998/01/13 04:03:53 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.17 1998/01/25 05:13:03 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include <unistd.h>
#include "postgres.h"
-
+#include "miscadmin.h"
#include "executor/execdebug.h"
#include "executor/executor.h"
#include "executor/nodeHash.h"
static void
mk_hj_temp(char *tempname)
{
- sprintf(tempname, "HJ%d.%d", (int) getpid(), hjtmpcnt);
+ sprintf(tempname, "HJ%d.%d", (int) MyProcPid, hjtmpcnt);
hjtmpcnt = (hjtmpcnt + 1) % 1000;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.33 1998/01/07 21:03:21 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.34 1998/01/25 05:13:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include <postgres.h>
+#include <miscadmin.h>
#include <libpq/pqsignal.h>
#include <libpq/auth.h>
#include <libpq/libpq.h> /* where the declarations go */
int fd = fileno(Pfout);
#if defined(hpux)
- ioctl(fd, FIOSSAIOOWN, getpid());
+ ioctl(fd, FIOSSAIOOWN, MyProcPid);
#elif defined(sco)
- ioctl(fd, SIOCSPGRP, getpid());
+ ioctl(fd, SIOCSPGRP, MyProcPid);
#else
- fcntl(fd, F_SETOWN, getpid());
+ fcntl(fd, F_SETOWN, MyProcPid);
#endif /* hpux */
pqsignal(SIGURG, fptr);
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.68 1997/12/19 02:06:37 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.69 1998/01/25 05:13:35 momjian Exp $
*
* NOTES
*
if (DebugLvl > 1)
{
fprintf(stderr, "%s child[%ld]: execv(",
- progname, (long) getpid());
+ progname, (long) MyProcPid);
for (i = 0; i < ac; ++i)
fprintf(stderr, "%s, ", av[i]);
fprintf(stderr, ")\n");
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.31 1998/01/07 21:04:49 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.32 1998/01/25 05:13:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
_bm_trace(Oid dbId, Oid relId, int blkNo, int bufNo, int allocType)
{
- static int mypid = 0;
long start,
cur;
bmtrace *tb;
- if (mypid == 0)
- mypid = getpid();
-
start = *CurTraceBuf;
if (start > 0)
okay:
tb = &TraceBuf[start];
- tb->bmt_pid = mypid;
+ tb->bmt_pid = MyProcPid;
tb->bmt_buf = bufNo;
tb->bmt_dbid = dbId;
tb->bmt_relid = relId;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.20 1998/01/23 22:16:46 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.21 1998/01/25 05:14:02 momjian Exp $
*
* NOTES
* Outside modules can create a lock table and acquire/release
#include <unistd.h>
#include "postgres.h"
+#include "miscadmin.h"
#include "storage/shmem.h"
#include "storage/spin.h"
#include "storage/proc.h"
if ((lockDebug >= 1) && (tag->relId >= lock_debug_oid_min)) \
elog(DEBUG, \
"%s: pid (%d) rel (%d) dbid (%d) tid (%d,%d) type (%s)",where, \
- getpid(),\
+ MyProcPid,\
tag->relId, tag->dbId, \
((tag->tupleId.ip_blkid.bi_hi<<16)+\
tag->tupleId.ip_blkid.bi_lo),\
elog(DEBUG, \
"%s: pid (%d) rel (%d) dbid (%d) tid (%d,%d) nHolding (%d) "\
"holders (%d,%d,%d,%d,%d) type (%s)",where, \
- getpid(),\
+ MyProcPid,\
lock->tag.relId, lock->tag.dbId, \
((lock->tag.tupleId.ip_blkid.bi_hi<<16)+\
lock->tag.tupleId.ip_blkid.bi_lo),\
"%s: pid (%d) xid (%d) pid (%d) lock (%x) nHolding (%d) "\
"holders (%d,%d,%d,%d,%d)",\
where,\
- getpid(),\
+ MyProcPid,\
xidentP->tag.xid,\
xidentP->tag.pid,\
xidentP->tag.lock,\
#ifdef USER_LOCKS
if (is_user_lock)
{
- item.tag.pid = getpid();
+ item.tag.pid = MyProcPid;
item.tag.xid = myXid = 0;
#ifdef USER_LOCKS_DEBUG
elog(NOTICE, "LockAcquire: user lock xid [%d,%d,%d]",
#ifdef USER_LOCKS
if (is_user_lock)
{
- item.tag.pid = getpid();
+ item.tag.pid = MyProcPid;
item.tag.xid = 0;
#ifdef USER_LOCKS_DEBUG
elog(NOTICE, "LockRelease: user lock xid [%d,%d,%d]",
#ifdef USER_LOCKS
int is_user_lock_table,
- my_pid,
count,
nskip;
is_user_lock_table = (tableId == 0);
- my_pid = getpid();
#ifdef USER_LOCKS_DEBUG
- elog(NOTICE, "LockReleaseAll: tableId=%d, pid=%d", tableId, my_pid);
+ elog(NOTICE, "LockReleaseAll: tableId=%d, pid=%d", tableId, MyProcPid);
#endif
if (is_user_lock_table)
{
nskip++;
goto next_item;
}
- if (xidLook->tag.pid != my_pid)
+ if (xidLook->tag.pid != MyProcPid)
{
/* This should never happen */
#ifdef USER_LOCKS_DEBUG
SPINLOCK masterLock;
int nLockTypes;
LOCK *lock;
- int pid,
count;
int tableId = 1;
LOCKTAB *ltable;
- pid = getpid();
- ShmemPIDLookup(pid, &location);
+ ShmemPIDLookup(MyProcPid, &location);
if (location == INVALID_OFFSET)
return;
proc = (PROC *) MAKE_PTR(location);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.27 1998/01/23 22:16:48 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.28 1998/01/25 05:14:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* This is so that we can support more backends. (system-wide semaphore
* sets run out pretty fast.) -ay 4/95
*
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.27 1998/01/23 22:16:48 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.28 1998/01/25 05:14:09 momjian Exp $
*/
#include <sys/time.h>
#include <unistd.h>
{
int i;
- ProcGlobal->numProcs = 0;
ProcGlobal->freeProcs = INVALID_OFFSET;
ProcGlobal->currKey = IPCGetProcessSemaphoreInitKey(key);
for (i = 0; i < MAX_PROC_SEMS / PROC_NSEMS_PER_SET; i++)
InitProcess(IPCKey key)
{
bool found = false;
- int pid;
int semstat;
unsigned long location,
myOffset;
/* this cannot be initialized until after the buffer pool */
SHMQueueInit(&(MyProc->lockQueue));
- MyProc->procId = ProcGlobal->numProcs;
- ProcGlobal->numProcs++;
}
/*
*/
SpinRelease(ProcStructLock);
- MyProc->pid = 0;
+ MyProc->pid = MyProcPid;
MyProc->xid = InvalidTransactionId;
-#if 0
- MyProc->pid = MyPid;
-#endif
/* ----------------
* Start keeping spin lock stats from here on. Any botch before
* exit.
* -------------------------
*/
- pid = getpid();
location = MAKE_OFFSET(MyProc);
- if ((!ShmemPIDLookup(pid, &location)) || (location != MAKE_OFFSET(MyProc)))
+ if ((!ShmemPIDLookup(MyProcPid, &location)) || (location != MAKE_OFFSET(MyProc)))
{
elog(FATAL, "InitProc: ShmemPID table broken");
}
MyProc->errType = NO_ERROR;
SHMQueueElemInit(&(MyProc->links));
- on_exitpg(ProcKill, (caddr_t) pid);
+ on_exitpg(ProcKill, (caddr_t) MyProcPid);
ProcInitialized = TRUE;
}
if (exitStatus != 0)
return;
- if (!pid)
- {
- pid = getpid();
- }
-
- ShmemPIDLookup(pid, &location);
+ ShmemPIDLookup(MyProcPid, &location);
if (location == INVALID_OFFSET)
return;
if (proc != MyProc)
{
- Assert(pid != getpid());
+ Assert(pid != MyProcPid);
}
else
MyProc = NULL;
MyProc->prio = prio;
MyProc->token = token;
MyProc->waitLock = lock;
-
+
/* -------------------
* currently, we only need this for the ProcWakeup routines
* -------------------
return retProc;
}
-
-/*
- * ProcGetId --
- */
-#ifdef NOT_USED
-int
-ProcGetId()
-{
- return (MyProc->procId);
-}
-
-#endif
-
/*
* ProcLockWakeup -- routine for waking up processes when a lock is
* released.
static void
HandleDeadLock(int sig)
{
- LOCK *lock;
- int size;
+ LOCK *mywaitlock;
LockLockTable();
return;
}
- lock = MyProc->waitLock;
- size = lock->waitProcs.size;/* so we can look at this in the core */
+ mywaitlock = MyProc->waitLock;
#ifdef DEADLOCK_DEBUG
DumpLocks();
* Get this process off the lock's wait queue
* ------------------------
*/
- Assert(lock->waitProcs.size > 0);
- --lock->waitProcs.size;
+ Assert(mywaitlock->waitProcs.size > 0);
+ --mywaitlock->waitProcs.size;
SHMQueueDelete(&(MyProc->links));
SHMQueueElemInit(&(MyProc->links));
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.61 1998/01/13 04:04:36 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.62 1998/01/25 05:14:18 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
* -------------------
*/
- MasterPid = getpid();
+ MyProcPid = getpid();
/* ----------------
* parse command line arguments
if (IsUnderPostmaster == false)
{
puts("\nPOSTGRES backend interactive interface");
- puts("$Revision: 1.61 $ $Date: 1998/01/13 04:04:36 $");
+ puts("$Revision: 1.62 $ $Date: 1998/01/25 05:14:18 $");
}
/* ----------------
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.36 1998/01/05 18:43:09 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.37 1998/01/25 05:14:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
commandTag = "LISTEN";
CHECK_IF_ABORTED();
- Async_Listen(stmt->relname, MasterPid);
+ Async_Listen(stmt->relname, MyProcPid);
}
break;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.24 1998/01/07 21:06:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.25 1998/01/25 05:14:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
ProcReleaseSpins(NULL); /* get rid of spinlocks we hold */
if (!InError)
{
- kill(getpid(), 1); /* abort to traffic cop */
+ kill(MyProcPid, 1); /* abort to traffic cop */
pause();
}
if (fcntl(fd, F_GETFD, 0) < 0)
{
sprintf(OutputFileName, "%s/pg.errors.%d",
- DataDir, (int) getpid());
+ DataDir, (int) MyProcPid);
fd = open(OutputFileName, O_CREAT | O_APPEND | O_WRONLY, 0666);
}
if (fd < 0)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.17 1997/11/24 05:09:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.18 1998/01/25 05:14:42 momjian Exp $
*
* NOTES
* Globals used all over the place should be declared here and not
int Noversion = 0;
int Quiet = 1;
-int MasterPid;
+int MyProcPid;
+
char *DataDir;
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.32 1998/01/15 19:46:10 pgsql Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.33 1998/01/25 05:14:49 momjian Exp $
*
* NOTES
* Sorts the first relation into the second relation.
tp = (struct tapelst *) palloc((unsigned) sizeof(struct tapelst));
- sprintf(uniqueName, "%spg_psort.%d.%d", TEMPDIR, (int) getpid(), uniqueFileId);
+ sprintf(uniqueName, "%spg_psort.%d.%d", TEMPDIR, (int) MyProcPid, uniqueFileId);
uniqueFileId++;
tapeinit = 1;
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: miscadmin.h,v 1.18 1997/12/04 23:58:01 thomas Exp $
+ * $Id: miscadmin.h,v 1.19 1998/01/25 05:15:01 momjian Exp $
*
* NOTES
* some of the information in this file will be moved to
*/
extern int Portfd;
extern int Noversion;
-extern int MasterPid;
extern int Quiet;
extern char *DataDir;
+extern int MyProcPid;
+
extern char OutputFileName[];
/*
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: proc.h,v 1.9 1998/01/23 06:01:25 momjian Exp $
+ * $Id: proc.h,v 1.10 1998/01/25 05:15:15 momjian Exp $
*
*-------------------------------------------------------------------------
*/
SEMA sem; /* ONE semaphore to sleep on */
int errType; /* error code tells why we woke up */
- int procId; /* unique number for this structure NOT
- * unique per backend, these things are
- * reused after the backend dies. */
-
int critSects; /* If critSects > 0, we are in sensitive
* routines that cannot be recovered when
* the process fails. */
typedef struct procglobal
{
SHMEM_OFFSET freeProcs;
- int numProcs;
IPCKey currKey;
int32 freeSemMap[MAX_PROC_SEMS / PROC_NSEMS_PER_SET];
} PROC_HDR;