mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
pgindent run. Make it all clean.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.54 2001/03/13 01:17:06 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.55 2001/03/22 03:59:59 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Globals used all over the place should be declared here and not
|
||||
@@ -79,7 +79,7 @@ char DateFormat[20] = "%d-%m-%Y"; /* mjl: sizes! or better
|
||||
* malloc? XXX */
|
||||
char FloatFormat[20] = "%f";
|
||||
|
||||
bool enableFsync = true;
|
||||
bool enableFsync = true;
|
||||
bool allowSystemTableMods = false;
|
||||
int SortMem = 512;
|
||||
int NBuffers = DEF_NBUFFERS;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.63 2001/03/18 18:22:08 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.64 2001/03/22 04:00:00 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -109,7 +109,7 @@ SetDatabaseName(const char *name)
|
||||
void
|
||||
SetDataDir(const char *dir)
|
||||
{
|
||||
char *new;
|
||||
char *new;
|
||||
|
||||
AssertArg(dir);
|
||||
if (DataDir)
|
||||
@@ -117,8 +117,8 @@ SetDataDir(const char *dir)
|
||||
|
||||
if (dir[0] != '/')
|
||||
{
|
||||
char *buf;
|
||||
size_t buflen;
|
||||
char *buf;
|
||||
size_t buflen;
|
||||
|
||||
buflen = MAXPGPATH;
|
||||
for (;;)
|
||||
@@ -147,13 +147,11 @@ SetDataDir(const char *dir)
|
||||
free(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
new = strdup(dir);
|
||||
}
|
||||
|
||||
if (!new)
|
||||
elog(FATAL, "out of memory");
|
||||
DataDir = new;
|
||||
DataDir = new;
|
||||
}
|
||||
|
||||
|
||||
@@ -344,7 +342,7 @@ convertstr(unsigned char *buff, int len, int dest)
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* User ID things
|
||||
* User ID things
|
||||
*
|
||||
* The session user is determined at connection start and never
|
||||
* changes. The current user may change when "setuid" functions
|
||||
@@ -415,7 +413,7 @@ SetSessionUserIdFromUserName(const char *username)
|
||||
if (!HeapTupleIsValid(userTup))
|
||||
elog(FATAL, "user \"%s\" does not exist", username);
|
||||
|
||||
SetSessionUserId( ((Form_pg_shadow) GETSTRUCT(userTup))->usesysid );
|
||||
SetSessionUserId(((Form_pg_shadow) GETSTRUCT(userTup))->usesysid);
|
||||
|
||||
ReleaseSysCache(userTup);
|
||||
}
|
||||
@@ -436,7 +434,7 @@ GetUserName(Oid userid)
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
elog(ERROR, "invalid user id %u", (unsigned) userid);
|
||||
|
||||
result = pstrdup( NameStr(((Form_pg_shadow) GETSTRUCT(tuple))->usename) );
|
||||
result = pstrdup(NameStr(((Form_pg_shadow) GETSTRUCT(tuple))->usename));
|
||||
|
||||
ReleaseSysCache(tuple);
|
||||
return result;
|
||||
@@ -502,12 +500,14 @@ CreateLockFile(const char *filename, bool amPostmaster,
|
||||
*/
|
||||
for (;;)
|
||||
{
|
||||
|
||||
/*
|
||||
* Try to create the lock file --- O_EXCL makes this atomic.
|
||||
*/
|
||||
fd = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||
if (fd >= 0)
|
||||
break; /* Success; exit the retry loop */
|
||||
|
||||
/*
|
||||
* Couldn't create the pid file. Probably it already exists.
|
||||
*/
|
||||
@@ -551,7 +551,7 @@ CreateLockFile(const char *filename, bool amPostmaster,
|
||||
#ifdef __BEOS__
|
||||
&& errno != EINVAL
|
||||
#endif
|
||||
))
|
||||
))
|
||||
{
|
||||
/* lockfile belongs to a live process */
|
||||
fprintf(stderr, "Lock file \"%s\" already exists.\n",
|
||||
@@ -571,11 +571,11 @@ CreateLockFile(const char *filename, bool amPostmaster,
|
||||
}
|
||||
|
||||
/*
|
||||
* No, the creating process did not exist. However, it could be that
|
||||
* the postmaster crashed (or more likely was kill -9'd by a clueless
|
||||
* admin) but has left orphan backends behind. Check for this by
|
||||
* looking to see if there is an associated shmem segment that is
|
||||
* still in use.
|
||||
* No, the creating process did not exist. However, it could be
|
||||
* that the postmaster crashed (or more likely was kill -9'd by a
|
||||
* clueless admin) but has left orphan backends behind. Check for
|
||||
* this by looking to see if there is an associated shmem segment
|
||||
* that is still in use.
|
||||
*/
|
||||
if (isDDLock)
|
||||
{
|
||||
@@ -585,7 +585,7 @@ CreateLockFile(const char *filename, bool amPostmaster,
|
||||
|
||||
ptr = strchr(buffer, '\n');
|
||||
if (ptr != NULL &&
|
||||
(ptr = strchr(ptr+1, '\n')) != NULL)
|
||||
(ptr = strchr(ptr + 1, '\n')) != NULL)
|
||||
{
|
||||
ptr++;
|
||||
if (sscanf(ptr, "%lu %lu", &shmKey, &shmId) == 2)
|
||||
@@ -607,8 +607,8 @@ CreateLockFile(const char *filename, bool amPostmaster,
|
||||
|
||||
/*
|
||||
* Looks like nobody's home. Unlink the file and try again to
|
||||
* create it. Need a loop because of possible race condition against
|
||||
* other would-be creators.
|
||||
* create it. Need a loop because of possible race condition
|
||||
* against other would-be creators.
|
||||
*/
|
||||
if (unlink(filename) < 0)
|
||||
elog(FATAL, "Can't remove old lock file %s: %m"
|
||||
@@ -621,11 +621,11 @@ CreateLockFile(const char *filename, bool amPostmaster,
|
||||
* Successfully created the file, now fill it.
|
||||
*/
|
||||
snprintf(buffer, sizeof(buffer), "%d\n%s\n",
|
||||
amPostmaster ? (int) my_pid : - ((int) my_pid),
|
||||
amPostmaster ? (int) my_pid : -((int) my_pid),
|
||||
DataDir);
|
||||
if (write(fd, buffer, strlen(buffer)) != strlen(buffer))
|
||||
{
|
||||
int save_errno = errno;
|
||||
int save_errno = errno;
|
||||
|
||||
close(fd);
|
||||
unlink(filename);
|
||||
@@ -645,10 +645,10 @@ CreateLockFile(const char *filename, bool amPostmaster,
|
||||
bool
|
||||
CreateDataDirLockFile(const char *datadir, bool amPostmaster)
|
||||
{
|
||||
char lockfile[MAXPGPATH];
|
||||
char lockfile[MAXPGPATH];
|
||||
|
||||
snprintf(lockfile, sizeof(lockfile), "%s/postmaster.pid", datadir);
|
||||
if (! CreateLockFile(lockfile, amPostmaster, true, datadir))
|
||||
if (!CreateLockFile(lockfile, amPostmaster, true, datadir))
|
||||
return false;
|
||||
/* Save name of lockfile for RecordSharedMemoryInLockFile */
|
||||
strcpy(directoryLockFile, lockfile);
|
||||
@@ -658,10 +658,10 @@ CreateDataDirLockFile(const char *datadir, bool amPostmaster)
|
||||
bool
|
||||
CreateSocketLockFile(const char *socketfile, bool amPostmaster)
|
||||
{
|
||||
char lockfile[MAXPGPATH];
|
||||
char lockfile[MAXPGPATH];
|
||||
|
||||
snprintf(lockfile, sizeof(lockfile), "%s.lock", socketfile);
|
||||
if (! CreateLockFile(lockfile, amPostmaster, false, socketfile))
|
||||
if (!CreateLockFile(lockfile, amPostmaster, false, socketfile))
|
||||
return false;
|
||||
/* Save name of lockfile for TouchSocketLockFile */
|
||||
strcpy(socketLockFile, lockfile);
|
||||
@@ -698,7 +698,7 @@ TouchSocketLockFile(void)
|
||||
* lock file (if we have created one).
|
||||
*
|
||||
* This may be called multiple times in the life of a postmaster, if we
|
||||
* delete and recreate shmem due to backend crash. Therefore, be prepared
|
||||
* delete and recreate shmem due to backend crash. Therefore, be prepared
|
||||
* to overwrite existing information. (As of 7.1, a postmaster only creates
|
||||
* one shm seg anyway; but for the purposes here, if we did have more than
|
||||
* one then any one of them would do anyway.)
|
||||
@@ -712,8 +712,8 @@ RecordSharedMemoryInLockFile(IpcMemoryKey shmKey, IpcMemoryId shmId)
|
||||
char buffer[BLCKSZ];
|
||||
|
||||
/*
|
||||
* Do nothing if we did not create a lockfile (probably because we
|
||||
* are running standalone).
|
||||
* Do nothing if we did not create a lockfile (probably because we are
|
||||
* running standalone).
|
||||
*/
|
||||
if (directoryLockFile[0] == '\0')
|
||||
return;
|
||||
@@ -732,27 +732,30 @@ RecordSharedMemoryInLockFile(IpcMemoryKey shmKey, IpcMemoryId shmId)
|
||||
return;
|
||||
}
|
||||
buffer[len] = '\0';
|
||||
|
||||
/*
|
||||
* Skip over first two lines (PID and path).
|
||||
*/
|
||||
ptr = strchr(buffer, '\n');
|
||||
if (ptr == NULL ||
|
||||
(ptr = strchr(ptr+1, '\n')) == NULL)
|
||||
(ptr = strchr(ptr + 1, '\n')) == NULL)
|
||||
{
|
||||
elog(DEBUG, "Bogus data in %s", directoryLockFile);
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
ptr++;
|
||||
|
||||
/*
|
||||
* Append shm key and ID. Format to try to keep it the same length
|
||||
* always (trailing junk won't hurt, but might confuse humans).
|
||||
*/
|
||||
sprintf(ptr, "%9lu %9lu\n",
|
||||
(unsigned long) shmKey, (unsigned long) shmId);
|
||||
|
||||
/*
|
||||
* And rewrite the data. Since we write in a single kernel call,
|
||||
* this update should appear atomic to onlookers.
|
||||
* And rewrite the data. Since we write in a single kernel call, this
|
||||
* update should appear atomic to onlookers.
|
||||
*/
|
||||
len = strlen(buffer);
|
||||
if (lseek(fd, (off_t) 0, SEEK_SET) != 0 ||
|
||||
@@ -781,16 +784,18 @@ void
|
||||
ValidatePgVersion(const char *path)
|
||||
{
|
||||
char full_path[MAXPGPATH];
|
||||
FILE *file;
|
||||
FILE *file;
|
||||
int ret;
|
||||
long file_major, file_minor;
|
||||
long my_major = 0, my_minor = 0;
|
||||
char *endptr;
|
||||
long file_major,
|
||||
file_minor;
|
||||
long my_major = 0,
|
||||
my_minor = 0;
|
||||
char *endptr;
|
||||
const char *version_string = PG_VERSION;
|
||||
|
||||
my_major = strtol(version_string, &endptr, 10);
|
||||
if (*endptr == '.')
|
||||
my_minor = strtol(endptr+1, NULL, 10);
|
||||
my_minor = strtol(endptr + 1, NULL, 10);
|
||||
|
||||
snprintf(full_path, MAXPGPATH, "%s/PG_VERSION", path);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.81 2001/02/16 18:50:40 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.82 2001/03/22 04:00:00 momjian Exp $
|
||||
*
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
@@ -118,7 +118,7 @@ ReverifyMyDatabase(const char *name)
|
||||
* Also check that the database is currently allowing connections.
|
||||
*/
|
||||
dbform = (Form_pg_database) GETSTRUCT(tup);
|
||||
if (! dbform->datallowconn)
|
||||
if (!dbform->datallowconn)
|
||||
elog(FATAL, "Database \"%s\" is not currently accepting connections",
|
||||
name);
|
||||
|
||||
@@ -175,6 +175,7 @@ InitCommunication(void)
|
||||
void
|
||||
BaseInit(void)
|
||||
{
|
||||
|
||||
/*
|
||||
* Attach to shared memory and semaphores, and initialize our
|
||||
* input/output/debugging file descriptors.
|
||||
@@ -230,8 +231,8 @@ InitPostgres(const char *dbname, const char *username)
|
||||
ValidatePgVersion(DataDir);
|
||||
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
GetRawDatabaseInfo(dbname, &MyDatabaseId, datpath);
|
||||
@@ -347,8 +348,8 @@ InitPostgres(const char *dbname, const char *username)
|
||||
|
||||
/*
|
||||
* Unless we are bootstrapping, double-check that InitMyDatabaseInfo()
|
||||
* got a correct result. We can't do this until all the database-access
|
||||
* infrastructure is up.
|
||||
* got a correct result. We can't do this until all the
|
||||
* database-access infrastructure is up.
|
||||
*/
|
||||
if (!bootstrap)
|
||||
ReverifyMyDatabase(dbname);
|
||||
@@ -359,14 +360,18 @@ InitPostgres(const char *dbname, const char *username)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set up process-exit callbacks to remove temp relations and then
|
||||
* do pre-shutdown cleanup. This should be last because we want
|
||||
* Set up process-exit callbacks to remove temp relations and then do
|
||||
* pre-shutdown cleanup. This should be last because we want
|
||||
* shmem_exit to call these routines before the exit callbacks that
|
||||
* are registered by buffer manager, lock manager, etc. We need
|
||||
* to run this code before we close down database access!
|
||||
* are registered by buffer manager, lock manager, etc. We need to
|
||||
* run this code before we close down database access!
|
||||
*/
|
||||
on_shmem_exit(ShutdownPostgres, 0);
|
||||
/* because callbacks are called in reverse order, this gets done first: */
|
||||
|
||||
/*
|
||||
* because callbacks are called in reverse order, this gets done
|
||||
* first:
|
||||
*/
|
||||
on_shmem_exit(remove_all_temp_relations, 0);
|
||||
|
||||
/* close the transaction we started above */
|
||||
@@ -389,21 +394,24 @@ InitPostgres(const char *dbname, const char *username)
|
||||
static void
|
||||
ShutdownPostgres(void)
|
||||
{
|
||||
|
||||
/*
|
||||
* These operations are really just a minimal subset of AbortTransaction().
|
||||
* We don't want to do any inessential cleanup, since that just raises
|
||||
* the odds of failure --- but there's some stuff we need to do.
|
||||
* These operations are really just a minimal subset of
|
||||
* AbortTransaction(). We don't want to do any inessential cleanup,
|
||||
* since that just raises the odds of failure --- but there's some
|
||||
* stuff we need to do.
|
||||
*
|
||||
* Release any spinlocks or buffer context locks we might be holding.
|
||||
* This is a kluge to improve the odds that we won't get into a self-made
|
||||
* stuck-spinlock scenario while trying to shut down.
|
||||
* This is a kluge to improve the odds that we won't get into a
|
||||
* self-made stuck-spinlock scenario while trying to shut down.
|
||||
*/
|
||||
ProcReleaseSpins(NULL);
|
||||
UnlockBuffers();
|
||||
|
||||
/*
|
||||
* In case a transaction is open, delete any files it created. This
|
||||
* In case a transaction is open, delete any files it created. This
|
||||
* has to happen before bufmgr shutdown, so having smgr register a
|
||||
* callback for it wouldn't work.
|
||||
*/
|
||||
smgrDoPendingDeletes(false); /* delete as though aborting xact */
|
||||
smgrDoPendingDeletes(false);/* delete as though aborting xact */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user