1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-24 00:23:06 +03:00

pgindent run before PG 9.1 beta 1.

This commit is contained in:
Bruce Momjian
2011-04-10 11:42:00 -04:00
parent 9a8b73147c
commit bf50caf105
446 changed files with 5737 additions and 5258 deletions

View File

@@ -89,7 +89,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
snprintf(buf, sizeof(buf), "_%s", name);
name = buf;
}
#endif /* !__ELF__ */
#endif /* !__ELF__ */
if ((vp = dlsym(handle, (char *) name)) == NULL)
snprintf(error_message, sizeof(error_message),
"dlsym (%s) failed", name);

View File

@@ -89,7 +89,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
snprintf(buf, sizeof(buf), "_%s", name);
name = buf;
}
#endif /* !__ELF__ */
#endif /* !__ELF__ */
if ((vp = dlsym(handle, (char *) name)) == NULL)
snprintf(error_message, sizeof(error_message),
"dlsym (%s) failed", name);

View File

@@ -89,7 +89,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
snprintf(buf, sizeof(buf), "_%s", name);
name = buf;
}
#endif /* !__ELF__ */
#endif /* !__ELF__ */
if ((vp = dlsym(handle, (char *) name)) == NULL)
snprintf(error_message, sizeof(error_message),
"dlsym (%s) failed", name);

View File

@@ -37,7 +37,7 @@ pgpipe(int handles[2])
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(0);
serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
if (bind(s, (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR)
if (bind(s, (SOCKADDR *) &serv_addr, len) == SOCKET_ERROR)
{
ereport(LOG, (errmsg_internal("pgpipe failed to bind: %ui", WSAGetLastError())));
closesocket(s);
@@ -49,7 +49,7 @@ pgpipe(int handles[2])
closesocket(s);
return -1;
}
if (getsockname(s, (SOCKADDR *) & serv_addr, &len) == SOCKET_ERROR)
if (getsockname(s, (SOCKADDR *) &serv_addr, &len) == SOCKET_ERROR)
{
ereport(LOG, (errmsg_internal("pgpipe failed to getsockname: %ui", WSAGetLastError())));
closesocket(s);
@@ -62,13 +62,13 @@ pgpipe(int handles[2])
return -1;
}
if (connect(handles[1], (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR)
if (connect(handles[1], (SOCKADDR *) &serv_addr, len) == SOCKET_ERROR)
{
ereport(LOG, (errmsg_internal("pgpipe failed to connect socket: %ui", WSAGetLastError())));
closesocket(s);
return -1;
}
if ((handles[0] = accept(s, (SOCKADDR *) & serv_addr, &len)) == INVALID_SOCKET)
if ((handles[0] = accept(s, (SOCKADDR *) &serv_addr, &len)) == INVALID_SOCKET)
{
ereport(LOG, (errmsg_internal("pgpipe failed to accept socket: %ui", WSAGetLastError())));
closesocket(handles[1]);

View File

@@ -153,7 +153,7 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size)
"segment exceeded your kernel's SHMMAX parameter. You can either "
"reduce the request size or reconfigure the kernel with larger SHMMAX. "
"To reduce the request size (currently %lu bytes), reduce "
"PostgreSQL's shared memory usage, perhaps by reducing shared_buffers "
"PostgreSQL's shared memory usage, perhaps by reducing shared_buffers "
"or max_connections.\n"
"If the request size is already small, it's possible that it is less than "
"your kernel's SHMMIN parameter, in which case raising the request size or "
@@ -164,10 +164,10 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size)
(errno == ENOMEM) ?
errhint("This error usually means that PostgreSQL's request for a shared "
"memory segment exceeded available memory or swap space, "
"or exceeded your kernel's SHMALL parameter. You can either "
"or exceeded your kernel's SHMALL parameter. You can either "
"reduce the request size or reconfigure the kernel with larger SHMALL. "
"To reduce the request size (currently %lu bytes), reduce "
"PostgreSQL's shared memory usage, perhaps by reducing shared_buffers "
"PostgreSQL's shared memory usage, perhaps by reducing shared_buffers "
"or max_connections.\n"
"The PostgreSQL documentation contains more information about shared "
"memory configuration.",
@@ -203,7 +203,7 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size)
* hurt, but might confuse humans).
*/
{
char line[64];
char line[64];
sprintf(line, "%9lu %9lu",
(unsigned long) memKey, (unsigned long) shmid);

View File

@@ -37,11 +37,11 @@
*
* for (;;)
* {
* ResetLatch();
* if (work to do)
* Do Stuff();
* ResetLatch();
* if (work to do)
* Do Stuff();
*
* WaitLatch();
* WaitLatch();
* }
*
* It's important to reset the latch *before* checking if there's work to
@@ -100,8 +100,8 @@
static volatile sig_atomic_t waiting = false;
/* Read and write end of the self-pipe */
static int selfpipe_readfd = -1;
static int selfpipe_writefd = -1;
static int selfpipe_readfd = -1;
static int selfpipe_writefd = -1;
/* private function prototypes */
static void initSelfPipe(void);
@@ -205,7 +205,8 @@ int
WaitLatchOrSocket(volatile Latch *latch, pgsocket sock, bool forRead,
bool forWrite, long timeout)
{
struct timeval tv, *tvp = NULL;
struct timeval tv,
*tvp = NULL;
fd_set input_mask;
fd_set output_mask;
int rc;
@@ -225,13 +226,13 @@ WaitLatchOrSocket(volatile Latch *latch, pgsocket sock, bool forRead,
waiting = true;
for (;;)
{
int hifd;
int hifd;
/*
* Clear the pipe, and check if the latch is set already. If someone
* sets the latch between this and the select() below, the setter
* will write a byte to the pipe (or signal us and the signal handler
* will do that), and the select() will return immediately.
* sets the latch between this and the select() below, the setter will
* write a byte to the pipe (or signal us and the signal handler will
* do that), and the select() will return immediately.
*/
drainSelfPipe();
if (latch->is_set)
@@ -278,7 +279,7 @@ WaitLatchOrSocket(volatile Latch *latch, pgsocket sock, bool forRead,
(forWrite && FD_ISSET(sock, &output_mask))))
{
result = 2;
break; /* data available in socket */
break; /* data available in socket */
}
}
waiting = false;
@@ -293,7 +294,7 @@ WaitLatchOrSocket(volatile Latch *latch, pgsocket sock, bool forRead,
void
SetLatch(volatile Latch *latch)
{
pid_t owner_pid;
pid_t owner_pid;
/* Quick exit if already set */
if (latch->is_set)
@@ -302,17 +303,17 @@ SetLatch(volatile Latch *latch)
latch->is_set = true;
/*
* See if anyone's waiting for the latch. It can be the current process
* if we're in a signal handler. We use the self-pipe to wake up the
* select() in that case. If it's another process, send a signal.
* See if anyone's waiting for the latch. It can be the current process if
* we're in a signal handler. We use the self-pipe to wake up the select()
* in that case. If it's another process, send a signal.
*
* Fetch owner_pid only once, in case the owner simultaneously disowns
* the latch and clears owner_pid. XXX: This assumes that pid_t is
* atomic, which isn't guaranteed to be true! In practice, the effective
* range of pid_t fits in a 32 bit integer, and so should be atomic. In
* the worst case, we might end up signaling wrong process if the right
* one disowns the latch just as we fetch owner_pid. Even then, you're
* very unlucky if a process with that bogus pid exists.
* Fetch owner_pid only once, in case the owner simultaneously disowns the
* latch and clears owner_pid. XXX: This assumes that pid_t is atomic,
* which isn't guaranteed to be true! In practice, the effective range of
* pid_t fits in a 32 bit integer, and so should be atomic. In the worst
* case, we might end up signaling wrong process if the right one disowns
* the latch just as we fetch owner_pid. Even then, you're very unlucky if
* a process with that bogus pid exists.
*/
owner_pid = latch->owner_pid;
if (owner_pid == 0)
@@ -351,15 +352,14 @@ latch_sigusr1_handler(void)
static void
initSelfPipe(void)
{
int pipefd[2];
int pipefd[2];
/*
* Set up the self-pipe that allows a signal handler to wake up the
* select() in WaitLatch. Make the write-end non-blocking, so that
* SetLatch won't block if the event has already been set many times
* filling the kernel buffer. Make the read-end non-blocking too, so
* that we can easily clear the pipe by reading until EAGAIN or
* EWOULDBLOCK.
* filling the kernel buffer. Make the read-end non-blocking too, so that
* we can easily clear the pipe by reading until EAGAIN or EWOULDBLOCK.
*/
if (pipe(pipefd) < 0)
elog(FATAL, "pipe() failed: %m");
@@ -376,8 +376,8 @@ initSelfPipe(void)
static void
sendSelfPipeByte(void)
{
int rc;
char dummy = 0;
int rc;
char dummy = 0;
retry:
rc = write(selfpipe_writefd, &dummy, 1);
@@ -388,16 +388,16 @@ retry:
goto retry;
/*
* If the pipe is full, we don't need to retry, the data that's
* there already is enough to wake up WaitLatch.
* If the pipe is full, we don't need to retry, the data that's there
* already is enough to wake up WaitLatch.
*/
if (errno == EAGAIN || errno == EWOULDBLOCK)
return;
/*
* Oops, the write() failed for some other reason. We might be in
* a signal handler, so it's not safe to elog(). We have no choice
* but silently ignore the error.
* Oops, the write() failed for some other reason. We might be in a
* signal handler, so it's not safe to elog(). We have no choice but
* silently ignore the error.
*/
return;
}
@@ -408,11 +408,11 @@ static void
drainSelfPipe(void)
{
/*
* There shouldn't normally be more than one byte in the pipe, or maybe
* a few more if multiple processes run SetLatch at the same instant.
* There shouldn't normally be more than one byte in the pipe, or maybe a
* few more if multiple processes run SetLatch at the same instant.
*/
char buf[16];
int rc;
char buf[16];
int rc;
for (;;)
{
@@ -420,9 +420,9 @@ drainSelfPipe(void)
if (rc < 0)
{
if (errno == EAGAIN || errno == EWOULDBLOCK)
break; /* the pipe is empty */
break; /* the pipe is empty */
else if (errno == EINTR)
continue; /* retry */
continue; /* retry */
else
elog(ERROR, "read() on self-pipe failed: %m");
}

View File

@@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------
*
* win32_crashdump.c
* Automatic crash dump creation for PostgreSQL on Windows
* Automatic crash dump creation for PostgreSQL on Windows
*
* The crashdump feature traps unhandled win32 exceptions produced by the
* backend, and tries to produce a Windows MiniDump crash
@@ -57,11 +57,11 @@
* http://www.debuginfo.com/articles/effminidumps.html
*/
typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType,
CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam
);
typedef BOOL (WINAPI * MINIDUMPWRITEDUMP) (HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType,
CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam
);
/*
@@ -76,24 +76,25 @@ typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hF
* any PostgreSQL functions.
*/
static LONG WINAPI
crashDumpHandler(struct _EXCEPTION_POINTERS *pExceptionInfo)
crashDumpHandler(struct _EXCEPTION_POINTERS * pExceptionInfo)
{
/*
* We only write crash dumps if the "crashdumps" directory within
* the postgres data directory exists.
* We only write crash dumps if the "crashdumps" directory within the
* postgres data directory exists.
*/
DWORD attribs = GetFileAttributesA("crashdumps");
if (attribs != INVALID_FILE_ATTRIBUTES && (attribs & FILE_ATTRIBUTE_DIRECTORY) )
DWORD attribs = GetFileAttributesA("crashdumps");
if (attribs != INVALID_FILE_ATTRIBUTES && (attribs & FILE_ATTRIBUTE_DIRECTORY))
{
/* 'crashdumps' exists and is a directory. Try to write a dump' */
HMODULE hDll = NULL;
HMODULE hDll = NULL;
MINIDUMPWRITEDUMP pDump = NULL;
MINIDUMP_TYPE dumpType;
char dumpPath[_MAX_PATH];
HANDLE selfProcHandle = GetCurrentProcess();
DWORD selfPid = GetProcessId(selfProcHandle);
HANDLE dumpFile;
DWORD systemTicks;
char dumpPath[_MAX_PATH];
HANDLE selfProcHandle = GetCurrentProcess();
DWORD selfPid = GetProcessId(selfProcHandle);
HANDLE dumpFile;
DWORD systemTicks;
struct _MINIDUMP_EXCEPTION_INFORMATION ExInfo;
ExInfo.ThreadId = GetCurrentThreadId();
@@ -108,19 +109,18 @@ crashDumpHandler(struct _EXCEPTION_POINTERS *pExceptionInfo)
return EXCEPTION_CONTINUE_SEARCH;
}
pDump = (MINIDUMPWRITEDUMP)GetProcAddress(hDll, "MiniDumpWriteDump");
pDump = (MINIDUMPWRITEDUMP) GetProcAddress(hDll, "MiniDumpWriteDump");
if (pDump==NULL)
if (pDump == NULL)
{
write_stderr("could not load required functions in dbghelp.dll, cannot write crashdump\n");
return EXCEPTION_CONTINUE_SEARCH;
}
/*
* Dump as much as we can, except shared memory, code segments,
* and memory mapped files.
* Exactly what we can dump depends on the version of dbghelp.dll,
* see:
* Dump as much as we can, except shared memory, code segments, and
* memory mapped files. Exactly what we can dump depends on the
* version of dbghelp.dll, see:
* http://msdn.microsoft.com/en-us/library/ms680519(v=VS.85).aspx
*/
dumpType = MiniDumpNormal | MiniDumpWithHandleData |
@@ -135,25 +135,25 @@ crashDumpHandler(struct _EXCEPTION_POINTERS *pExceptionInfo)
systemTicks = GetTickCount();
snprintf(dumpPath, _MAX_PATH,
"crashdumps\\postgres-pid%0i-%0i.mdmp", selfPid, systemTicks);
dumpPath[_MAX_PATH-1] = '\0';
"crashdumps\\postgres-pid%0i-%0i.mdmp", selfPid, systemTicks);
dumpPath[_MAX_PATH - 1] = '\0';
dumpFile = CreateFile(dumpPath, GENERIC_WRITE, FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
NULL);
if (dumpFile==INVALID_HANDLE_VALUE)
if (dumpFile == INVALID_HANDLE_VALUE)
{
write_stderr("could not open crash dump file %s for writing: error code %d\n",
dumpPath, GetLastError());
dumpPath, GetLastError());
return EXCEPTION_CONTINUE_SEARCH;
}
if ((*pDump)(selfProcHandle, selfPid, dumpFile, dumpType, &ExInfo,
NULL, NULL))
if ((*pDump) (selfProcHandle, selfPid, dumpFile, dumpType, &ExInfo,
NULL, NULL))
write_stderr("wrote crash dump to %s\n", dumpPath);
else
write_stderr("could not write crash dump to %s: error code %08x\n",
dumpPath, GetLastError());
dumpPath, GetLastError());
CloseHandle(dumpFile);
}

View File

@@ -27,7 +27,7 @@ typedef struct timerCA
struct itimerval value;
HANDLE event;
CRITICAL_SECTION crit_sec;
} timerCA;
} timerCA;
static timerCA timerCommArea;
static HANDLE timerThreadHandle = INVALID_HANDLE_VALUE;

View File

@@ -50,8 +50,7 @@ InitSharedLatch(volatile Latch *latch)
latch->is_shared = true;
/*
* Set up security attributes to specify that the events are
* inherited.
* Set up security attributes to specify that the events are inherited.
*/
ZeroMemory(&sa, sizeof(sa));
sa.nLength = sizeof(sa);
@@ -106,7 +105,7 @@ WaitLatchOrSocket(volatile Latch *latch, SOCKET sock, bool forRead,
numevents = 2;
if (sock != PGINVALID_SOCKET && (forRead || forWrite))
{
int flags = 0;
int flags = 0;
if (forRead)
flags |= FD_READ;
@@ -135,7 +134,7 @@ WaitLatchOrSocket(volatile Latch *latch, SOCKET sock, bool forRead,
}
rc = WaitForMultipleObjects(numevents, events, FALSE,
(timeout >= 0) ? (timeout / 1000) : INFINITE);
(timeout >= 0) ? (timeout / 1000) : INFINITE);
if (rc == WAIT_FAILED)
elog(ERROR, "WaitForMultipleObjects() failed: error code %d", (int) GetLastError());
else if (rc == WAIT_TIMEOUT)
@@ -178,7 +177,7 @@ WaitLatchOrSocket(volatile Latch *latch, SOCKET sock, bool forRead,
void
SetLatch(volatile Latch *latch)
{
HANDLE handle;
HANDLE handle;
/* Quick exit if already set */
if (latch->is_set)
@@ -187,21 +186,22 @@ SetLatch(volatile Latch *latch)
latch->is_set = true;
/*
* See if anyone's waiting for the latch. It can be the current process
* if we're in a signal handler. Use a local variable here in case the
* latch is just disowned between the test and the SetEvent call, and
* event field set to NULL.
* See if anyone's waiting for the latch. It can be the current process if
* we're in a signal handler. Use a local variable here in case the latch
* is just disowned between the test and the SetEvent call, and event
* field set to NULL.
*
* Fetch handle field only once, in case the owner simultaneously
* disowns the latch and clears handle. This assumes that HANDLE is
* atomic, which isn't guaranteed to be true! In practice, it should be,
* and in the worst case we end up calling SetEvent with a bogus handle,
* and SetEvent will return an error with no harm done.
* Fetch handle field only once, in case the owner simultaneously disowns
* the latch and clears handle. This assumes that HANDLE is atomic, which
* isn't guaranteed to be true! In practice, it should be, and in the
* worst case we end up calling SetEvent with a bogus handle, and SetEvent
* will return an error with no harm done.
*/
handle = latch->event;
if (handle)
{
SetEvent(handle);
/*
* Note that we silently ignore any errors. We might be in a signal
* handler or other critical path where it's not safe to call elog().