X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=src%2Fbackend%2Futils%2Finit%2Fpostinit.c;h=57ce319e764ed1f72dddc9ea640806de9e92d9ba;hb=bf00bbb0c4940b80b46b7e5b379cd64184f2262f;hp=226f9ba23b845af89df90c69f2347a450b1a835c;hpb=03a7cd1788734d63b013fc8ada0f07571f760cbc;p=postgresql diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 226f9ba23b..57ce319e76 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.26 1998/04/05 05:52:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.31 1998/07/24 03:31:50 scrappy Exp $ * * NOTES * InitPostgres() is the function called from PostgresMain @@ -66,7 +66,12 @@ #include "utils/inval.h" #include "catalog/catname.h" +#ifdef MB +#include "catalog/pg_database_mb.h" +#include "mb/pg_wchar.h" +#else #include "catalog/pg_database.h" +#endif #include "libpq/libpq.h" @@ -78,7 +83,11 @@ static void InitStdio(void); static void InitUserid(void); extern char *ExpandDatabasePath(char *name); +#ifdef MB +extern void GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path, int *encoding); +#else extern void GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path); +#endif static IPCKey PostgresIpcKey; @@ -119,18 +128,28 @@ InitMyDatabaseInfo(char *name) Oid owner; char *path, myPath[MAXPGPATH + 1]; +#ifdef MB + int encoding; +#endif SetDatabaseName(name); +#ifdef MB + GetRawDatabaseInfo(name, &owner, &MyDatabaseId, myPath, &encoding); +#else GetRawDatabaseInfo(name, &owner, &MyDatabaseId, myPath); +#endif if (!OidIsValid(MyDatabaseId)) elog(FATAL, "Database %s does not exist in %s", - GetDatabaseName(), + DatabaseName, DatabaseRelationName); path = ExpandDatabasePath(myPath); SetDatabasePath(path); +#ifdef MB + SetDatabaseEncoding(encoding); +#endif return; } /* InitMyDatabaseInfo() */ @@ -203,8 +222,8 @@ VerifyMyDatabase() int fd; char errormsg[1000]; - name = GetDatabaseName(); - myPath = GetDatabasePath(); + name = DatabaseName; + myPath = DatabasePath; if ((fd = open(myPath, O_RDONLY, 0)) == -1) sprintf(errormsg, @@ -295,9 +314,7 @@ InitCommunication() postid = getenv("POSTID"); if (!PointerIsValid(postid)) - { MyBackendTag = -1; - } else { MyBackendTag = atoi(postid); @@ -307,9 +324,7 @@ InitCommunication() ipc_key = getenv("IPC_KEY"); if (!PointerIsValid(ipc_key)) - { key = -1; - } else { key = atoi(ipc_key); @@ -367,9 +382,7 @@ InitCommunication() * ---------------- */ if (MyBackendTag == -1) - { MyBackendTag = 1; - } key = PrivateIPCKey; } @@ -384,8 +397,11 @@ forcesharedmemory: #endif - PostgresIpcKey = key; - AttachSharedMemoryAndSemaphores(key); + if (!IsUnderPostmaster) /* postmaster already did this */ + { + PostgresIpcKey = key; + AttachSharedMemoryAndSemaphores(key); + } } @@ -484,7 +500,7 @@ InitPostgres(char *name) /* database name */ InitLocalBuffer(); if (!TransactionFlushEnabled()) - on_exitpg(FlushBufferPool, (caddr_t) NULL); + on_shmem_exit(FlushBufferPool, (caddr_t) NULL); /* ---------------- * initialize the database id used for system caches and lock tables @@ -604,7 +620,7 @@ InitPostgres(char *name) /* database name */ * ---------------- */ PostgresIsInitialized = true; -/* on_exitpg(DestroyLocalRelList, (caddr_t) NULL); */ +/* on_shmem_exit(DestroyLocalRelList, (caddr_t) NULL); */ /* ---------------- * Done with "InitPostgres", now change to NormalProcessing unless