]> granicus.if.org Git - postgresql/blobdiff - src/backend/utils/init/postinit.c
I really hope that I haven't missed anything in this one...
[postgresql] / src / backend / utils / init / postinit.c
index baac25cfbeef402d148029ef0a4a8b20609d70d0..57ce319e764ed1f72dddc9ea640806de9e92d9ba 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.25 1998/02/26 04:38:12 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
 #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() */
@@ -195,16 +214,16 @@ VerifySystemDatabase()
 static void
 VerifyMyDatabase()
 {
-       char       *name;
-       char       *myPath;
+       const char         *name;
+       const char         *myPath;
 
        /* Failure reason returned by some function.  NULL if no failure */
        char       *reason;
        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