diff options
author | Bruce Momjian <bruce@momjian.us> | 2000-04-12 17:17:23 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2000-04-12 17:17:23 +0000 |
commit | 52f77df613cea1803ce86321c37229626d9f213c (patch) | |
tree | bd9ac9f667f295cb65f4c448a5bb5a062d656b27 /src/backend/utils/init | |
parent | db4518729d85da83eafdacbcebaeb12618517595 (diff) | |
download | postgresql-52f77df613cea1803ce86321c37229626d9f213c.tar.gz postgresql-52f77df613cea1803ce86321c37229626d9f213c.zip |
Ye-old pgindent run. Same 4-space tabs.
Diffstat (limited to 'src/backend/utils/init')
-rw-r--r-- | src/backend/utils/init/globals.c | 5 | ||||
-rw-r--r-- | src/backend/utils/init/miscinit.c | 134 | ||||
-rw-r--r-- | src/backend/utils/init/postinit.c | 159 |
3 files changed, 158 insertions, 140 deletions
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c index 5170be28615..8c4642d1ee2 100644 --- a/src/backend/utils/init/globals.c +++ b/src/backend/utils/init/globals.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.41 2000/02/16 17:25:49 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.42 2000/04/12 17:16:02 momjian Exp $ * * NOTES * Globals used all over the place should be declared here and not @@ -93,7 +93,8 @@ char *IndexedCatalogNames[] = { * ps status buffer */ #ifndef linux -char Ps_status_buffer[1024]; +char Ps_status_buffer[1024]; + #endif /* ---------------- diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index 41b4020c713..a1ba1e1ff9b 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.44 2000/02/18 09:28:58 inoue Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.45 2000/04/12 17:16:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,6 +34,7 @@ #ifdef CYR_RECODE unsigned char RecodeForwTable[128]; unsigned char RecodeBackTable[128]; + #endif ProcessingMode Mode = InitProcessing; @@ -43,7 +44,7 @@ ProcessingMode Mode = InitProcessing; * ---------------------------------------------------------------- */ -static bool isIgnoringSystemIndexes = false; +static bool isIgnoringSystemIndexes = false; /* * IsIgnoringSystemIndexes @@ -74,24 +75,24 @@ IgnoreSystemIndexes(bool mode) void SetDatabasePath(const char *path) { - free(DatabasePath); + free(DatabasePath); /* use strdup since this is done before memory contexts are set up */ - if (path) - { - DatabasePath = strdup(path); - AssertState(DatabasePath); - } + if (path) + { + DatabasePath = strdup(path); + AssertState(DatabasePath); + } } void SetDatabaseName(const char *name) { - free(DatabaseName); - if (name) - { - DatabaseName = strdup(name); - AssertState(DatabaseName); - } + free(DatabaseName); + if (name) + { + DatabaseName = strdup(name); + AssertState(DatabaseName); + } } #ifndef MULTIBYTE @@ -105,13 +106,15 @@ getdatabaseencoding() return (""); } -const char *pg_encoding_to_char(int encoding) +const char * +pg_encoding_to_char(int encoding) { elog(ERROR, "MultiByte support must be enabled to use this function"); return (""); } -int pg_char_to_encoding(const char *encoding_string) +int +pg_char_to_encoding(const char *encoding_string) { elog(ERROR, "MultiByte support must be enabled to use this function"); return (0); @@ -332,7 +335,7 @@ SetUserId() HeapTuple userTup; char *userName; - AssertState(!OidIsValid(UserId));/* only once */ + AssertState(!OidIsValid(UserId)); /* only once */ /* * Don't do scans if we're bootstrapping, none of the system catalogs @@ -361,10 +364,10 @@ SetUserId() * * (1) postmaster starts. In this case pid > 0. * (2) postgres starts in standalone mode. In this case - * pid < 0 + * pid < 0 * * to gain an interlock. - * + * * SetPidFname(datadir) * Remember the the pid file name. This is neccesary * UnlinkPidFile() is called from proc_exit(). @@ -392,7 +395,8 @@ static char PidFile[MAXPGPATH]; /* * Remove the pid file. This function is called from proc_exit. */ -void UnlinkPidFile(void) +void +UnlinkPidFile(void) { unlink(PidFile); } @@ -400,7 +404,8 @@ void UnlinkPidFile(void) /* * Set path to the pid file */ -void SetPidFname(char * datadir) +void +SetPidFname(char *datadir) { snprintf(PidFile, sizeof(PidFile), "%s/%s", datadir, PIDFNAME); } @@ -408,45 +413,50 @@ void SetPidFname(char * datadir) /* * Get path to the pid file */ -char *GetPidFname(void) +char * +GetPidFname(void) { - return(PidFile); + return (PidFile); } /* * Create the pid file */ -int SetPidFile(pid_t pid) +int +SetPidFile(pid_t pid) { - int fd; - char *pidfile; - char pidstr[32]; - int len; - pid_t post_pid; - int is_postgres = 0; + int fd; + char *pidfile; + char pidstr[32]; + int len; + pid_t post_pid; + int is_postgres = 0; /* * Creating pid file */ pidfile = GetPidFname(); fd = open(pidfile, O_RDWR | O_CREAT | O_EXCL, 0600); - if (fd < 0) { + if (fd < 0) + { + /* - * Couldn't create the pid file. Probably - * it already exists. Read the file to see if the process - * actually exists + * Couldn't create the pid file. Probably it already exists. Read + * the file to see if the process actually exists */ fd = open(pidfile, O_RDONLY, 0600); - if (fd < 0) { + if (fd < 0) + { fprintf(stderr, "Can't open pid file: %s\n", pidfile); fprintf(stderr, "Please check the permission and try again.\n"); - return(-1); + return (-1); } - if ((len = read(fd, pidstr, sizeof(pidstr)-1)) < 0) { + if ((len = read(fd, pidstr, sizeof(pidstr) - 1)) < 0) + { fprintf(stderr, "Can't read pid file: %s\n", pidfile); fprintf(stderr, "Please check the permission and try again.\n"); close(fd); - return(-1); + return (-1); } close(fd); @@ -454,56 +464,62 @@ int SetPidFile(pid_t pid) * Check to see if the process actually exists */ pidstr[len] = '\0'; - post_pid = (pid_t)atoi(pidstr); + post_pid = (pid_t) atoi(pidstr); /* if pid < 0, the pid is for postgres, not postmatser */ - if (post_pid < 0) { + if (post_pid < 0) + { is_postgres++; post_pid = -post_pid; } - if (post_pid == 0 || (post_pid > 0 && kill(post_pid, 0) < 0)) { + if (post_pid == 0 || (post_pid > 0 && kill(post_pid, 0) < 0)) + { + /* - * No, the process did not exist. Unlink - * the file and try to create it + * No, the process did not exist. Unlink the file and try to + * create it */ - if (unlink(pidfile) < 0) { + if (unlink(pidfile) < 0) + { fprintf(stderr, "Can't remove pid file: %s\n", pidfile); fprintf(stderr, "The file seems accidently left, but I couldn't remove it.\n"); fprintf(stderr, "Please remove the file by hand and try again.\n"); - return(-1); + return (-1); } fd = open(pidfile, O_RDWR | O_CREAT | O_EXCL, 0600); - if (fd < 0) { + if (fd < 0) + { fprintf(stderr, "Can't create pid file: %s\n", pidfile); fprintf(stderr, "Please check the permission and try again.\n"); - return(-1); + return (-1); } - } else { + } + else + { + /* * Another postmaster is running */ fprintf(stderr, "Can't create pid file: %s\n", pidfile); - if (is_postgres) { - fprintf(stderr, "Is another postgres (pid: %d) running?\n", post_pid); - } + if (is_postgres) + fprintf(stderr, "Is another postgres (pid: %d) running?\n", post_pid); else - { - fprintf(stderr, "Is another postmaster (pid: %s) running?\n", pidstr); - } - return(-1); + fprintf(stderr, "Is another postmaster (pid: %s) running?\n", pidstr); + return (-1); } } sprintf(pidstr, "%d", pid); - if (write(fd, pidstr, strlen(pidstr)) != strlen(pidstr)) { - fprintf(stderr,"Write to pid file failed\n"); + if (write(fd, pidstr, strlen(pidstr)) != strlen(pidstr)) + { + fprintf(stderr, "Write to pid file failed\n"); fprintf(stderr, "Please check the permission and try again.\n"); close(fd); unlink(pidfile); - return(-1); + return (-1); } close(fd); - return(0); + return (0); } diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 597e6ced8b6..c4675a6b57d 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.56 2000/01/26 05:57:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.57 2000/04/12 17:16:02 momjian Exp $ * * *------------------------------------------------------------------------- @@ -77,12 +77,12 @@ ReverifyMyDatabase(const char *name) { Relation pgdbrel; HeapScanDesc pgdbscan; - ScanKeyData key; + ScanKeyData key; HeapTuple tup; /* - * Because we grab AccessShareLock here, we can be sure that - * destroydb is not running in parallel with us (any more). + * Because we grab AccessShareLock here, we can be sure that destroydb + * is not running in parallel with us (any more). */ pgdbrel = heap_openr(DatabaseRelationName, AccessShareLock); @@ -97,12 +97,12 @@ ReverifyMyDatabase(const char *name) { /* OOPS */ heap_close(pgdbrel, AccessShareLock); + /* * The only real problem I could have created is to load dirty - * buffers for the dead database into shared buffer cache; - * if I did, some other backend will eventually try to write - * them and die in mdblindwrt. Flush any such pages to forestall - * trouble. + * buffers for the dead database into shared buffer cache; if I + * did, some other backend will eventually try to write them and + * die in mdblindwrt. Flush any such pages to forestall trouble. */ DropBuffers(MyDatabaseId); /* Now I can commit hara-kiri with a clear conscience... */ @@ -112,15 +112,15 @@ ReverifyMyDatabase(const char *name) /* * OK, we're golden. Only other to-do item is to save the MULTIBYTE - * encoding info out of the pg_database tuple. Note we also set the - * "template encoding", which is the default encoding for any - * CREATE DATABASE commands executed in this backend; essentially, - * you get the same encoding of the database you connected to as - * the default. (This replaces code that unreliably grabbed - * template1's encoding out of pg_database. We could do an extra - * scan to find template1's tuple, but for 99.99% of all backend - * startups it'd be wasted cycles --- and the 'createdb' script - * connects to template1 anyway, so there's no difference.) + * encoding info out of the pg_database tuple. Note we also set the + * "template encoding", which is the default encoding for any CREATE + * DATABASE commands executed in this backend; essentially, you get + * the same encoding of the database you connected to as the default. + * (This replaces code that unreliably grabbed template1's encoding + * out of pg_database. We could do an extra scan to find template1's + * tuple, but for 99.99% of all backend startups it'd be wasted cycles + * --- and the 'createdb' script connects to template1 anyway, so + * there's no difference.) */ #ifdef MULTIBYTE SetDatabaseEncoding(((Form_pg_database) GETSTRUCT(tup))->encoding); @@ -250,7 +250,7 @@ InitPostgres(const char *dbname) on_shmem_exit(FlushBufferPool, (caddr_t) NULL); #endif - SetDatabaseName(dbname); + SetDatabaseName(dbname); /* ---------------- * initialize the database id used for system caches and lock tables * ---------------- @@ -262,56 +262,56 @@ InitPostgres(const char *dbname) } else { - char *reason; - char *fullpath, - datpath[MAXPGPATH]; - - /* Verify if DataDir is ok */ - if (access(DataDir, F_OK) == -1) - elog(FATAL, "Database system not found. Data directory '%s' does not exist.", - DataDir); - - ValidatePgVersion(DataDir, &reason); - if (reason != NULL) - elog(FATAL, reason); - - /*----------------- - * Find oid and path of the database we're about to open. Since we're - * not yet up and running we have to use the hackish GetRawDatabaseInfo. - * - * OLD COMMENTS: - * The database's oid forms half of the unique key for the system - * caches and lock tables. We therefore want it initialized before - * we open any relations, since opening relations puts things in the - * cache. To get around this problem, this code opens and scans the - * pg_database relation by hand. - */ - - GetRawDatabaseInfo(dbname, &MyDatabaseId, datpath); - - if (!OidIsValid(MyDatabaseId)) - elog(FATAL, - "Database \"%s\" does not exist in the system catalog.", - dbname); - - fullpath = ExpandDatabasePath(datpath); - if (!fullpath) - elog(FATAL, "Database path could not be resolved."); - - /* Verify the database path */ - - if (access(fullpath, F_OK) == -1) - elog(FATAL, "Database \"%s\" does not exist. The data directory '%s' is missing.", - dbname, fullpath); - - ValidatePgVersion(fullpath, &reason); - if (reason != NULL) - elog(FATAL, "%s", reason); - - if(chdir(fullpath) == -1) - elog(FATAL, "Unable to change directory to '%s': %s", fullpath, strerror(errno)); - - SetDatabasePath(fullpath); + char *reason; + char *fullpath, + datpath[MAXPGPATH]; + + /* Verify if DataDir is ok */ + if (access(DataDir, F_OK) == -1) + elog(FATAL, "Database system not found. Data directory '%s' does not exist.", + DataDir); + + ValidatePgVersion(DataDir, &reason); + if (reason != NULL) + elog(FATAL, reason); + + /*----------------- + * Find oid and path of the database we're about to open. Since we're + * not yet up and running we have to use the hackish GetRawDatabaseInfo. + * + * OLD COMMENTS: + * The database's oid forms half of the unique key for the system + * caches and lock tables. We therefore want it initialized before + * we open any relations, since opening relations puts things in the + * cache. To get around this problem, this code opens and scans the + * pg_database relation by hand. + */ + + GetRawDatabaseInfo(dbname, &MyDatabaseId, datpath); + + if (!OidIsValid(MyDatabaseId)) + elog(FATAL, + "Database \"%s\" does not exist in the system catalog.", + dbname); + + fullpath = ExpandDatabasePath(datpath); + if (!fullpath) + elog(FATAL, "Database path could not be resolved."); + + /* Verify the database path */ + + if (access(fullpath, F_OK) == -1) + elog(FATAL, "Database \"%s\" does not exist. The data directory '%s' is missing.", + dbname, fullpath); + + ValidatePgVersion(fullpath, &reason); + if (reason != NULL) + elog(FATAL, "%s", reason); + + if (chdir(fullpath) == -1) + elog(FATAL, "Unable to change directory to '%s': %s", fullpath, strerror(errno)); + + SetDatabasePath(fullpath); } /* @@ -319,8 +319,9 @@ InitPostgres(const char *dbname) */ /* - * Initialize the transaction system and the relation descriptor cache. - * Note we have to make certain the lock manager is off while we do this. + * Initialize the transaction system and the relation descriptor + * cache. Note we have to make certain the lock manager is off while + * we do this. */ AmiTransactionOverride(IsBootstrapProcessingMode()); LockDisable(true); @@ -344,10 +345,10 @@ InitPostgres(const char *dbname) InitProcess(PostgresIpcKey); /* - * Initialize my entry in the shared-invalidation manager's - * array of per-backend data. (Formerly this came before - * InitProcess, but now it must happen after, because it uses - * MyProc.) Once I have done this, I am visible to other backends! + * Initialize my entry in the shared-invalidation manager's array of + * per-backend data. (Formerly this came before InitProcess, but now + * it must happen after, because it uses MyProc.) Once I have done + * this, I am visible to other backends! * * Sets up MyBackendId, a unique backend identifier. */ @@ -361,8 +362,8 @@ InitPostgres(const char *dbname) } /* - * Initialize the access methods. - * Does not touch files (?) - thomas 1997-11-01 + * Initialize the access methods. Does not touch files (?) - thomas + * 1997-11-01 */ initam(); @@ -412,9 +413,9 @@ BaseInit(void) EnableExceptionHandling(true); /* - * Memory system initialization - we may call palloc after - * EnableMemoryContext()). Note that EnableMemoryContext() - * must happen before EnablePortalManager(). + * Memory system initialization - we may call palloc after + * EnableMemoryContext()). Note that EnableMemoryContext() must + * happen before EnablePortalManager(). */ EnableMemoryContext(true); /* initializes the "top context" */ EnablePortalManager(true); /* memory for portal/transaction stuff */ |