mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
elog mop-up: bring some straggling fprintf(stderr)'s into the elog world.
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.162 2003/07/22 23:30:37 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.163 2003/07/27 21:49:53 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -359,7 +359,7 @@ BootstrapMain(int argc, char *argv[])
|
|||||||
gettext("%s does not know where to find the database system data.\n"
|
gettext("%s does not know where to find the database system data.\n"
|
||||||
"You must specify the directory that contains the database system\n"
|
"You must specify the directory that contains the database system\n"
|
||||||
"either by specifying the -D invocation option or by setting the\n"
|
"either by specifying the -D invocation option or by setting the\n"
|
||||||
"PGDATA environment variable.\n\n"),
|
"PGDATA environment variable.\n"),
|
||||||
argv[0]);
|
argv[0]);
|
||||||
proc_exit(1);
|
proc_exit(1);
|
||||||
}
|
}
|
||||||
@ -414,8 +414,7 @@ BootstrapMain(int argc, char *argv[])
|
|||||||
/*
|
/*
|
||||||
* Create lockfile for data directory.
|
* Create lockfile for data directory.
|
||||||
*/
|
*/
|
||||||
if (!CreateDataDirLockFile(DataDir, false))
|
CreateDataDirLockFile(DataDir, false);
|
||||||
proc_exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetProcessingMode(BootstrapProcessing);
|
SetProcessingMode(BootstrapProcessing);
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.36 2003/07/22 19:00:10 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.37 2003/07/27 21:49:53 tgl Exp $
|
||||||
*
|
*
|
||||||
* Since the server static private key ($DataDir/server.key)
|
* Since the server static private key ($DataDir/server.key)
|
||||||
* will normally be stored unencrypted so that the database
|
* will normally be stored unencrypted so that the database
|
||||||
@ -81,10 +81,6 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "libpq/libpq.h"
|
|
||||||
#include "miscadmin.h"
|
|
||||||
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
@ -94,17 +90,13 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_STRDUP
|
|
||||||
#include "strdup.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_SSL
|
#ifdef USE_SSL
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#include <openssl/dh.h>
|
#include <openssl/dh.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void ExitPostmaster(int);
|
#include "libpq/libpq.h"
|
||||||
extern void postmaster_error(const char *fmt,...);
|
#include "miscadmin.h"
|
||||||
|
|
||||||
#ifdef USE_SSL
|
#ifdef USE_SSL
|
||||||
static DH *load_dh_file(int keylength);
|
static DH *load_dh_file(int keylength);
|
||||||
@ -126,6 +118,7 @@ static const char *SSLerrmessage(void);
|
|||||||
*/
|
*/
|
||||||
#define RENEGOTIATION_LIMIT (512 * 1024 * 1024)
|
#define RENEGOTIATION_LIMIT (512 * 1024 * 1024)
|
||||||
#define CA_PATH NULL
|
#define CA_PATH NULL
|
||||||
|
|
||||||
static SSL_CTX *SSL_context = NULL;
|
static SSL_CTX *SSL_context = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -607,7 +600,7 @@ info_cb(const SSL *ssl, int type, int args)
|
|||||||
static int
|
static int
|
||||||
initialize_SSL(void)
|
initialize_SSL(void)
|
||||||
{
|
{
|
||||||
char fnbuf[2048];
|
char fnbuf[MAXPGPATH];
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
|
||||||
if (!SSL_context)
|
if (!SSL_context)
|
||||||
@ -616,50 +609,43 @@ initialize_SSL(void)
|
|||||||
SSL_load_error_strings();
|
SSL_load_error_strings();
|
||||||
SSL_context = SSL_CTX_new(SSLv23_method());
|
SSL_context = SSL_CTX_new(SSLv23_method());
|
||||||
if (!SSL_context)
|
if (!SSL_context)
|
||||||
{
|
ereport(FATAL,
|
||||||
postmaster_error("failed to create SSL context: %s",
|
(errmsg("could not create SSL context: %s",
|
||||||
SSLerrmessage());
|
SSLerrmessage())));
|
||||||
ExitPostmaster(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Load and verify certificate and private key
|
* Load and verify certificate and private key
|
||||||
*/
|
*/
|
||||||
snprintf(fnbuf, sizeof(fnbuf), "%s/server.crt", DataDir);
|
snprintf(fnbuf, sizeof(fnbuf), "%s/server.crt", DataDir);
|
||||||
if (!SSL_CTX_use_certificate_file(SSL_context, fnbuf, SSL_FILETYPE_PEM))
|
if (!SSL_CTX_use_certificate_file(SSL_context, fnbuf, SSL_FILETYPE_PEM))
|
||||||
{
|
ereport(FATAL,
|
||||||
postmaster_error("failed to load server certificate (%s): %s",
|
(errcode(ERRCODE_CONFIG_FILE_ERROR),
|
||||||
fnbuf, SSLerrmessage());
|
errmsg("could not load server certificate file \"%s\": %s",
|
||||||
ExitPostmaster(1);
|
fnbuf, SSLerrmessage())));
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(fnbuf, sizeof(fnbuf), "%s/server.key", DataDir);
|
snprintf(fnbuf, sizeof(fnbuf), "%s/server.key", DataDir);
|
||||||
if (lstat(fnbuf, &buf) == -1)
|
if (stat(fnbuf, &buf) == -1)
|
||||||
{
|
ereport(FATAL,
|
||||||
postmaster_error("failed to stat private key file (%s): %s",
|
(errcode_for_file_access(),
|
||||||
fnbuf, strerror(errno));
|
errmsg("could not access private key file \"%s\": %m",
|
||||||
ExitPostmaster(1);
|
fnbuf)));
|
||||||
}
|
if (!S_ISREG(buf.st_mode) || (buf.st_mode & (S_IRWXG | S_IRWXO)) ||
|
||||||
if (!S_ISREG(buf.st_mode) || (buf.st_mode & 0077) ||
|
|
||||||
buf.st_uid != getuid())
|
buf.st_uid != getuid())
|
||||||
{
|
ereport(FATAL,
|
||||||
postmaster_error("bad permissions on private key file (%s)\n"
|
(errcode(ERRCODE_CONFIG_FILE_ERROR),
|
||||||
"File must be owned by the proper user and must have no permissions for\n"
|
errmsg("unsafe permissions on private key file \"%s\"",
|
||||||
"\"group\" or \"other\".", fnbuf);
|
fnbuf),
|
||||||
ExitPostmaster(1);
|
errdetail("File must be owned by the database user and must have no permissions for \"group\" or \"other\".")));
|
||||||
}
|
|
||||||
if (!SSL_CTX_use_PrivateKey_file(SSL_context, fnbuf, SSL_FILETYPE_PEM))
|
if (!SSL_CTX_use_PrivateKey_file(SSL_context, fnbuf, SSL_FILETYPE_PEM))
|
||||||
{
|
ereport(FATAL,
|
||||||
postmaster_error("failed to load private key file (%s): %s",
|
(errmsg("could not load private key file \"%s\": %s",
|
||||||
fnbuf, SSLerrmessage());
|
fnbuf, SSLerrmessage())));
|
||||||
ExitPostmaster(1);
|
|
||||||
}
|
|
||||||
if (!SSL_CTX_check_private_key(SSL_context))
|
if (!SSL_CTX_check_private_key(SSL_context))
|
||||||
{
|
ereport(FATAL,
|
||||||
postmaster_error("check of private key failed: %s",
|
(errmsg("check of private key failed: %s",
|
||||||
SSLerrmessage());
|
SSLerrmessage())));
|
||||||
ExitPostmaster(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set up empheral DH keys */
|
/* set up empheral DH keys */
|
||||||
@ -668,25 +654,22 @@ initialize_SSL(void)
|
|||||||
|
|
||||||
/* setup the allowed cipher list */
|
/* setup the allowed cipher list */
|
||||||
if (SSL_CTX_set_cipher_list(SSL_context, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH") != 1)
|
if (SSL_CTX_set_cipher_list(SSL_context, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH") != 1)
|
||||||
{
|
elog(FATAL, "could not set the cipher list (no valid ciphers available)");
|
||||||
postmaster_error("unable to set the cipher list (no valid ciphers available)");
|
|
||||||
ExitPostmaster(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* accept client certificates, but don't require them. */
|
/* accept client certificates, but don't require them. */
|
||||||
snprintf(fnbuf, sizeof fnbuf, "%s/root.crt", DataDir);
|
snprintf(fnbuf, sizeof(fnbuf), "%s/root.crt", DataDir);
|
||||||
if (!SSL_CTX_load_verify_locations(SSL_context, fnbuf, CA_PATH))
|
if (!SSL_CTX_load_verify_locations(SSL_context, fnbuf, CA_PATH))
|
||||||
{
|
{
|
||||||
|
/* Not fatal - we do not require client certificates */
|
||||||
|
ereport(LOG,
|
||||||
|
(errmsg("could not load root cert file \"%s\": %s",
|
||||||
|
fnbuf, SSLerrmessage()),
|
||||||
|
errdetail("Will not verify client certificates.")));
|
||||||
return 0;
|
return 0;
|
||||||
#ifdef NOT_USED
|
|
||||||
/* CLIENT CERTIFICATES NOT REQUIRED bjm 2002-09-26 */
|
|
||||||
postmaster_error("could not read root cert file (%s): %s",
|
|
||||||
fnbuf, SSLerrmessage());
|
|
||||||
ExitPostmaster(1);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
SSL_CTX_set_verify(SSL_context,
|
SSL_CTX_set_verify(SSL_context,
|
||||||
SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, verify_cb);
|
SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE,
|
||||||
|
verify_cb);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -716,7 +699,7 @@ open_server_SSL(Port *port)
|
|||||||
{
|
{
|
||||||
ereport(COMMERROR,
|
ereport(COMMERROR,
|
||||||
(errcode(ERRCODE_PROTOCOL_VIOLATION),
|
(errcode(ERRCODE_PROTOCOL_VIOLATION),
|
||||||
errmsg("failed to initialize SSL connection: %s",
|
errmsg("could not initialize SSL connection: %s",
|
||||||
SSLerrmessage())));
|
SSLerrmessage())));
|
||||||
close_SSL(port);
|
close_SSL(port);
|
||||||
return -1;
|
return -1;
|
||||||
@ -739,7 +722,8 @@ open_server_SSL(Port *port)
|
|||||||
NID_commonName, port->peer_cn, sizeof(port->peer_cn));
|
NID_commonName, port->peer_cn, sizeof(port->peer_cn));
|
||||||
port->peer_cn[sizeof(port->peer_cn) - 1] = '\0';
|
port->peer_cn[sizeof(port->peer_cn) - 1] = '\0';
|
||||||
}
|
}
|
||||||
elog(DEBUG2, "secure connection from \"%s\"", port->peer_cn);
|
ereport(DEBUG2,
|
||||||
|
(errmsg("secure connection from \"%s\"", port->peer_cn)));
|
||||||
|
|
||||||
/* set up debugging/info callback */
|
/* set up debugging/info callback */
|
||||||
SSL_CTX_set_info_callback(SSL_context, info_cb);
|
SSL_CTX_set_info_callback(SSL_context, info_cb);
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.160 2003/07/24 00:02:53 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.161 2003/07/27 21:49:53 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -389,8 +389,7 @@ Lock_AF_UNIX(unsigned short portNumber, char *unixSocketName)
|
|||||||
/*
|
/*
|
||||||
* Grab an interlock file associated with the socket file.
|
* Grab an interlock file associated with the socket file.
|
||||||
*/
|
*/
|
||||||
if (!CreateSocketLockFile(sock_path, true))
|
CreateSocketLockFile(sock_path, true);
|
||||||
return STATUS_ERROR;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Once we have the interlock, we can safely delete any pre-existing
|
* Once we have the interlock, we can safely delete any pre-existing
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.58 2003/07/04 16:41:21 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.59 2003/07/27 21:49:53 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -81,7 +81,8 @@ main(int argc, char *argv[])
|
|||||||
#if defined(__alpha)
|
#if defined(__alpha)
|
||||||
if (setsysinfo(SSI_NVPAIRS, buffer, 1, (caddr_t) NULL,
|
if (setsysinfo(SSI_NVPAIRS, buffer, 1, (caddr_t) NULL,
|
||||||
(unsigned long) NULL) < 0)
|
(unsigned long) NULL) < 0)
|
||||||
fprintf(stderr, gettext("%s: setsysinfo failed: %s\n"), argv[0], strerror(errno));
|
fprintf(stderr, gettext("%s: setsysinfo failed: %s\n"),
|
||||||
|
argv[0], strerror(errno));
|
||||||
#endif
|
#endif
|
||||||
#endif /* NOFIXADE || NOPRINTADE */
|
#endif /* NOFIXADE || NOPRINTADE */
|
||||||
|
|
||||||
@ -170,12 +171,12 @@ main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
if (geteuid() == 0)
|
if (geteuid() == 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, gettext(
|
fprintf(stderr,
|
||||||
"\"root\" execution of the PostgreSQL server is not permitted.\n\n"
|
gettext("\"root\" execution of the PostgreSQL server is not permitted.\n"
|
||||||
"The server must be started under an unprivileged user id to prevent\n"
|
"The server must be started under an unprivileged user id to prevent\n"
|
||||||
"a possible system security compromise. See the documentation for\n"
|
"possible system security compromise. See the documentation for\n"
|
||||||
"more information on how to properly start the server.\n\n"
|
"more information on how to properly start the server.\n"
|
||||||
));
|
));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#endif /* !__BEOS__ */
|
#endif /* !__BEOS__ */
|
||||||
@ -191,7 +192,8 @@ main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
if (getuid() != geteuid())
|
if (getuid() != geteuid())
|
||||||
{
|
{
|
||||||
fprintf(stderr, gettext("%s: real and effective user ids must match\n"),
|
fprintf(stderr,
|
||||||
|
gettext("%s: real and effective user ids must match\n"),
|
||||||
argv[0]);
|
argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -236,7 +238,7 @@ main(int argc, char *argv[])
|
|||||||
pw = getpwuid(geteuid());
|
pw = getpwuid(geteuid());
|
||||||
if (pw == NULL)
|
if (pw == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, gettext("%s: invalid current euid %d\n"),
|
fprintf(stderr, gettext("%s: invalid effective uid: %d\n"),
|
||||||
new_argv[0], (int) geteuid());
|
new_argv[0], (int) geteuid());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -249,7 +251,8 @@ main(int argc, char *argv[])
|
|||||||
pw_name_persist = malloc(namesize);
|
pw_name_persist = malloc(namesize);
|
||||||
if (!GetUserName(pw_name_persist, &namesize))
|
if (!GetUserName(pw_name_persist, &namesize))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: GetUserName failed\n", argv[0]);
|
fprintf(stderr, gettext("%s: GetUserName failed\n"),
|
||||||
|
new_argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/port/ipc_test.c,v 1.6 2003/07/22 23:30:39 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/port/ipc_test.c,v 1.7 2003/07/27 21:49:54 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -46,6 +46,8 @@ volatile bool ImmediateInterruptOK = false;
|
|||||||
volatile uint32 InterruptHoldoffCount = 0;
|
volatile uint32 InterruptHoldoffCount = 0;
|
||||||
volatile uint32 CritSectionCount = 0;
|
volatile uint32 CritSectionCount = 0;
|
||||||
|
|
||||||
|
const bool ExecBackend = false;
|
||||||
|
|
||||||
bool IsUnderPostmaster = false;
|
bool IsUnderPostmaster = false;
|
||||||
|
|
||||||
int MaxBackends = DEF_MAXBACKENDS;
|
int MaxBackends = DEF_MAXBACKENDS;
|
||||||
@ -128,14 +130,60 @@ ExceptionalCondition(char *conditionName,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
elog(int lev, const char *fmt,...)
|
|
||||||
|
bool
|
||||||
|
errstart(int elevel, const char *filename, int lineno,
|
||||||
|
const char *funcname)
|
||||||
{
|
{
|
||||||
if (lev >= ERROR)
|
return (elevel >= ERROR);
|
||||||
{
|
}
|
||||||
fprintf(stderr, "elog(%s)\n", fmt);
|
|
||||||
abort();
|
void
|
||||||
}
|
errfinish(int dummy, ...)
|
||||||
|
{
|
||||||
|
proc_exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
elog_finish(int elevel, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERROR: %s\n", fmt);
|
||||||
|
proc_exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
errcode(int sqlerrcode)
|
||||||
|
{
|
||||||
|
return 0; /* return value does not matter */
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
errmsg(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERROR: %s\n", fmt);
|
||||||
|
return 0; /* return value does not matter */
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
errmsg_internal(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERROR: %s\n", fmt);
|
||||||
|
return 0; /* return value does not matter */
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
errdetail(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "DETAIL: %s\n", fmt);
|
||||||
|
return 0; /* return value does not matter */
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
errhint(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "HINT: %s\n", fmt);
|
||||||
|
return 0; /* return value does not matter */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/port/posix_sema.c,v 1.7 2003/07/22 23:30:39 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/port/posix_sema.c,v 1.8 2003/07/27 21:49:54 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -89,9 +89,7 @@ PosixSemaphoreCreate(void)
|
|||||||
/*
|
/*
|
||||||
* Else complain and abort
|
* Else complain and abort
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "PosixSemaphoreCreate: sem_open(\"%s\") failed: %s\n",
|
elog(FATAL, "sem_open(\"%s\") failed: %m", semname);
|
||||||
semname, strerror(errno));
|
|
||||||
proc_exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -114,12 +112,9 @@ static void
|
|||||||
PosixSemaphoreCreate(sem_t * sem)
|
PosixSemaphoreCreate(sem_t * sem)
|
||||||
{
|
{
|
||||||
if (sem_init(sem, 1, 1) < 0)
|
if (sem_init(sem, 1, 1) < 0)
|
||||||
{
|
elog(FATAL, "sem_init failed: %m");
|
||||||
fprintf(stderr, "PosixSemaphoreCreate: sem_init failed: %s\n",
|
|
||||||
strerror(errno));
|
|
||||||
proc_exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* USE_NAMED_POSIX_SEMAPHORES */
|
#endif /* USE_NAMED_POSIX_SEMAPHORES */
|
||||||
|
|
||||||
|
|
||||||
@ -132,13 +127,11 @@ PosixSemaphoreKill(sem_t * sem)
|
|||||||
#ifdef USE_NAMED_POSIX_SEMAPHORES
|
#ifdef USE_NAMED_POSIX_SEMAPHORES
|
||||||
/* Got to use sem_close for named semaphores */
|
/* Got to use sem_close for named semaphores */
|
||||||
if (sem_close(sem) < 0)
|
if (sem_close(sem) < 0)
|
||||||
fprintf(stderr, "PosixSemaphoreKill: sem_close failed: %s\n",
|
elog(LOG, "sem_close failed: %m");
|
||||||
strerror(errno));
|
|
||||||
#else
|
#else
|
||||||
/* Got to use sem_destroy for unnamed semaphores */
|
/* Got to use sem_destroy for unnamed semaphores */
|
||||||
if (sem_destroy(sem) < 0)
|
if (sem_destroy(sem) < 0)
|
||||||
fprintf(stderr, "PosixSemaphoreKill: sem_destroy failed: %s\n",
|
elog(LOG, "sem_destroy failed: %m");
|
||||||
strerror(errno));
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,9 +228,7 @@ PGSemaphoreReset(PGSemaphore sema)
|
|||||||
break; /* got it down to 0 */
|
break; /* got it down to 0 */
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
continue; /* can this happen? */
|
continue; /* can this happen? */
|
||||||
fprintf(stderr, "PGSemaphoreReset: sem_trywait failed: %s\n",
|
elog(FATAL, "sem_trywait failed: %m");
|
||||||
strerror(errno));
|
|
||||||
proc_exit(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,11 +286,7 @@ PGSemaphoreLock(PGSemaphore sema, bool interruptOK)
|
|||||||
} while (errStatus < 0 && errno == EINTR);
|
} while (errStatus < 0 && errno == EINTR);
|
||||||
|
|
||||||
if (errStatus < 0)
|
if (errStatus < 0)
|
||||||
{
|
elog(FATAL, "sem_wait failed: %m");
|
||||||
fprintf(stderr, "PGSemaphoreLock: sem_wait failed: %s\n",
|
|
||||||
strerror(errno));
|
|
||||||
proc_exit(255);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -324,11 +311,7 @@ PGSemaphoreUnlock(PGSemaphore sema)
|
|||||||
} while (errStatus < 0 && errno == EINTR);
|
} while (errStatus < 0 && errno == EINTR);
|
||||||
|
|
||||||
if (errStatus < 0)
|
if (errStatus < 0)
|
||||||
{
|
elog(FATAL, "sem_post failed: %m");
|
||||||
fprintf(stderr, "PGSemaphoreUnlock: sem_post failed: %s\n",
|
|
||||||
strerror(errno));
|
|
||||||
proc_exit(255);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -356,9 +339,7 @@ PGSemaphoreTryLock(PGSemaphore sema)
|
|||||||
if (errno == EAGAIN || errno == EDEADLK)
|
if (errno == EAGAIN || errno == EDEADLK)
|
||||||
return false; /* failed to lock it */
|
return false; /* failed to lock it */
|
||||||
/* Otherwise we got trouble */
|
/* Otherwise we got trouble */
|
||||||
fprintf(stderr, "PGSemaphoreTryLock: sem_trywait failed: %s\n",
|
elog(FATAL, "sem_trywait failed: %m");
|
||||||
strerror(errno));
|
|
||||||
proc_exit(255);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/port/sysv_sema.c,v 1.6 2003/07/22 23:30:39 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/port/sysv_sema.c,v 1.7 2003/07/27 21:49:54 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -113,26 +113,22 @@ InternalIpcSemaphoreCreate(IpcSemaphoreKey semKey, int numSems)
|
|||||||
/*
|
/*
|
||||||
* Else complain and abort
|
* Else complain and abort
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "IpcSemaphoreCreate: semget(key=%d, num=%d, 0%o) failed: %s\n",
|
ereport(FATAL,
|
||||||
(int) semKey, numSems, (IPC_CREAT | IPC_EXCL | IPCProtection),
|
(errmsg("could not create semaphores: %m"),
|
||||||
strerror(errno));
|
errdetail("Failed syscall was semget(%d, %d, 0%o).",
|
||||||
|
(int) semKey, numSems,
|
||||||
if (errno == ENOSPC)
|
IPC_CREAT | IPC_EXCL | IPCProtection),
|
||||||
fprintf(stderr,
|
(errno == ENOSPC) ?
|
||||||
"\nThis error does *not* mean that you have run out of disk space.\n"
|
errhint("This error does *not* mean that you have run out of disk space.\n"
|
||||||
"\n"
|
"It occurs when either the system limit for the maximum number of "
|
||||||
"It occurs when either the system limit for the maximum number of\n"
|
"semaphore sets (SEMMNI), or the system wide maximum number of "
|
||||||
"semaphore sets (SEMMNI), or the system wide maximum number of\n"
|
"semaphores (SEMMNS), would be exceeded. You need to raise the "
|
||||||
"semaphores (SEMMNS), would be exceeded. You need to raise the\n"
|
"respective kernel parameter. Alternatively, reduce PostgreSQL's "
|
||||||
"respective kernel parameter. Alternatively, reduce PostgreSQL's\n"
|
"consumption of semaphores by reducing its max_connections parameter "
|
||||||
"consumption of semaphores by reducing its max_connections parameter\n"
|
"(currently %d).\n"
|
||||||
"(currently %d).\n"
|
"The PostgreSQL documentation contains more information about "
|
||||||
"\n"
|
"configuring your system for PostgreSQL.",
|
||||||
"The PostgreSQL documentation contains more information about\n"
|
MaxBackends) : 0));
|
||||||
"configuring your system for PostgreSQL.\n\n",
|
|
||||||
MaxBackends);
|
|
||||||
|
|
||||||
proc_exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return semId;
|
return semId;
|
||||||
@ -148,18 +144,13 @@ IpcSemaphoreInitialize(IpcSemaphoreId semId, int semNum, int value)
|
|||||||
|
|
||||||
semun.val = value;
|
semun.val = value;
|
||||||
if (semctl(semId, semNum, SETVAL, semun) < 0)
|
if (semctl(semId, semNum, SETVAL, semun) < 0)
|
||||||
{
|
ereport(FATAL,
|
||||||
fprintf(stderr, "IpcSemaphoreInitialize: semctl(id=%d, %d, SETVAL, %d) failed: %s\n",
|
(errmsg_internal("semctl(%d, %d, SETVAL, %d) failed: %m",
|
||||||
semId, semNum, value, strerror(errno));
|
semId, semNum, value),
|
||||||
|
(errno == ERANGE) ?
|
||||||
if (errno == ERANGE)
|
errhint("You possibly need to raise your kernel's SEMVMX value to be at least "
|
||||||
fprintf(stderr,
|
"%d. Look into the PostgreSQL documentation for details.",
|
||||||
"You possibly need to raise your kernel's SEMVMX value to be at least\n"
|
value) : 0));
|
||||||
"%d. Look into the PostgreSQL documentation for details.\n",
|
|
||||||
value);
|
|
||||||
|
|
||||||
proc_exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -173,13 +164,7 @@ IpcSemaphoreKill(IpcSemaphoreId semId)
|
|||||||
semun.val = 0; /* unused, but keep compiler quiet */
|
semun.val = 0; /* unused, but keep compiler quiet */
|
||||||
|
|
||||||
if (semctl(semId, 0, IPC_RMID, semun) < 0)
|
if (semctl(semId, 0, IPC_RMID, semun) < 0)
|
||||||
fprintf(stderr, "IpcSemaphoreKill: semctl(%d, 0, IPC_RMID, ...) failed: %s\n",
|
elog(LOG, "semctl(%d, 0, IPC_RMID, ...) failed: %m", semId);
|
||||||
semId, strerror(errno));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We used to report a failure via ereport(WARNING), but that's pretty
|
|
||||||
* pointless considering any client has long since disconnected ...
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the current value (semval) of the semaphore */
|
/* Get the current value (semval) of the semaphore */
|
||||||
@ -436,11 +421,7 @@ PGSemaphoreLock(PGSemaphore sema, bool interruptOK)
|
|||||||
} while (errStatus < 0 && errno == EINTR);
|
} while (errStatus < 0 && errno == EINTR);
|
||||||
|
|
||||||
if (errStatus < 0)
|
if (errStatus < 0)
|
||||||
{
|
elog(FATAL, "semop(id=%d) failed: %m", sema->semId);
|
||||||
fprintf(stderr, "PGSemaphoreLock: semop(id=%d) failed: %s\n",
|
|
||||||
sema->semId, strerror(errno));
|
|
||||||
proc_exit(255);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -470,11 +451,7 @@ PGSemaphoreUnlock(PGSemaphore sema)
|
|||||||
} while (errStatus < 0 && errno == EINTR);
|
} while (errStatus < 0 && errno == EINTR);
|
||||||
|
|
||||||
if (errStatus < 0)
|
if (errStatus < 0)
|
||||||
{
|
elog(FATAL, "semop(id=%d) failed: %m", sema->semId);
|
||||||
fprintf(stderr, "PGSemaphoreUnlock: semop(id=%d) failed: %s\n",
|
|
||||||
sema->semId, strerror(errno));
|
|
||||||
proc_exit(255);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -514,9 +491,7 @@ PGSemaphoreTryLock(PGSemaphore sema)
|
|||||||
return false; /* failed to lock it */
|
return false; /* failed to lock it */
|
||||||
#endif
|
#endif
|
||||||
/* Otherwise we got trouble */
|
/* Otherwise we got trouble */
|
||||||
fprintf(stderr, "PGSemaphoreTryLock: semop(id=%d) failed: %s\n",
|
elog(FATAL, "semop(id=%d) failed: %m", sema->semId);
|
||||||
sema->semId, strerror(errno));
|
|
||||||
proc_exit(255);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/port/sysv_shmem.c,v 1.12 2003/07/22 23:30:39 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/port/sysv_shmem.c,v 1.13 2003/07/27 21:49:54 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -88,56 +88,45 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size)
|
|||||||
/*
|
/*
|
||||||
* Else complain and abort
|
* Else complain and abort
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "IpcMemoryCreate: shmget(key=%d, size=%u, 0%o) failed: %s\n",
|
ereport(FATAL,
|
||||||
(int) memKey, size, (IPC_CREAT | IPC_EXCL | IPCProtection),
|
(errmsg("could not create shared memory segment: %m"),
|
||||||
strerror(errno));
|
errdetail("Failed syscall was shmget(key=%d, size=%u, 0%o).",
|
||||||
|
(int) memKey, size,
|
||||||
if (errno == EINVAL)
|
IPC_CREAT | IPC_EXCL | IPCProtection),
|
||||||
fprintf(stderr,
|
(errno == EINVAL) ?
|
||||||
"\nThis error usually means that PostgreSQL's request for a shared memory\n"
|
errhint("This error usually means that PostgreSQL's request for a shared memory "
|
||||||
"segment exceeded your kernel's SHMMAX parameter. You can either\n"
|
"segment exceeded your kernel's SHMMAX parameter. You can either "
|
||||||
"reduce the request size or reconfigure the kernel with larger SHMMAX.\n"
|
"reduce the request size or reconfigure the kernel with larger SHMMAX. "
|
||||||
"To reduce the request size (currently %u bytes), reduce\n"
|
"To reduce the request size (currently %u bytes), reduce "
|
||||||
"PostgreSQL's shared_buffers parameter (currently %d) and/or\n"
|
"PostgreSQL's shared_buffers parameter (currently %d) and/or "
|
||||||
"its max_connections parameter (currently %d).\n"
|
"its max_connections parameter (currently %d).\n"
|
||||||
"\n"
|
"If the request size is already small, it's possible that it is less than "
|
||||||
"If the request size is already small, it's possible that it is less than\n"
|
"your kernel's SHMMIN parameter, in which case raising the request size or "
|
||||||
"your kernel's SHMMIN parameter, in which case raising the request size or\n"
|
"reconfiguring SHMMIN is called for.\n"
|
||||||
"reconfiguring SHMMIN is called for.\n"
|
"The PostgreSQL documentation contains more information about shared "
|
||||||
"\n"
|
"memory configuration.",
|
||||||
"The PostgreSQL documentation contains more information about shared\n"
|
size, NBuffers, MaxBackends) : 0,
|
||||||
"memory configuration.\n\n",
|
(errno == ENOMEM) ?
|
||||||
size, NBuffers, MaxBackends);
|
errhint("This error usually means that PostgreSQL's request for a shared "
|
||||||
|
"memory segment exceeded available memory or swap space. "
|
||||||
else if (errno == ENOMEM)
|
"To reduce the request size (currently %u bytes), reduce "
|
||||||
fprintf(stderr,
|
"PostgreSQL's shared_buffers parameter (currently %d) and/or "
|
||||||
"\nThis error usually means that PostgreSQL's request for a shared\n"
|
"its max_connections parameter (currently %d).\n"
|
||||||
"memory segment exceeded available memory or swap space.\n"
|
"The PostgreSQL documentation contains more information about shared "
|
||||||
"To reduce the request size (currently %u bytes), reduce\n"
|
"memory configuration.",
|
||||||
"PostgreSQL's shared_buffers parameter (currently %d) and/or\n"
|
size, NBuffers, MaxBackends) : 0,
|
||||||
"its max_connections parameter (currently %d).\n"
|
(errno == ENOSPC) ?
|
||||||
"\n"
|
errhint("This error does *not* mean that you have run out of disk space. "
|
||||||
"The PostgreSQL documentation contains more information about shared\n"
|
"It occurs either if all available shared memory IDs have been taken, "
|
||||||
"memory configuration.\n\n",
|
"in which case you need to raise the SHMMNI parameter in your kernel, "
|
||||||
size, NBuffers, MaxBackends);
|
"or because the system's overall limit for shared memory has been "
|
||||||
|
"reached. If you cannot increase the shared memory limit, "
|
||||||
else if (errno == ENOSPC)
|
"reduce PostgreSQL's shared memory request (currently %u bytes), "
|
||||||
fprintf(stderr,
|
"by reducing its shared_buffers parameter (currently %d) and/or "
|
||||||
"\nThis error does *not* mean that you have run out of disk space.\n"
|
"its max_connections parameter (currently %d).\n"
|
||||||
"\n"
|
"The PostgreSQL documentation contains more information about shared "
|
||||||
"It occurs either if all available shared memory IDs have been taken,\n"
|
"memory configuration.",
|
||||||
"in which case you need to raise the SHMMNI parameter in your kernel,\n"
|
size, NBuffers, MaxBackends) : 0));
|
||||||
"or because the system's overall limit for shared memory has been\n"
|
|
||||||
"reached. If you cannot increase the shared memory limit,\n"
|
|
||||||
"reduce PostgreSQL's shared memory request (currently %u bytes),\n"
|
|
||||||
"by reducing its shared_buffers parameter (currently %d) and/or\n"
|
|
||||||
"its max_connections parameter (currently %d).\n"
|
|
||||||
"\n"
|
|
||||||
"The PostgreSQL documentation contains more information about shared\n"
|
|
||||||
"memory configuration.\n\n",
|
|
||||||
size, NBuffers, MaxBackends);
|
|
||||||
|
|
||||||
proc_exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register on-exit routine to delete the new segment */
|
/* Register on-exit routine to delete the new segment */
|
||||||
@ -152,11 +141,7 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (memAddress == (void *) -1)
|
if (memAddress == (void *) -1)
|
||||||
{
|
elog(FATAL, "shmat(id=%d) failed: %m", shmid);
|
||||||
fprintf(stderr, "IpcMemoryCreate: shmat(id=%d) failed: %s\n",
|
|
||||||
shmid, strerror(errno));
|
|
||||||
proc_exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Register on-exit routine to detach new segment before deleting */
|
/* Register on-exit routine to detach new segment before deleting */
|
||||||
on_shmem_exit(IpcMemoryDetach, PointerGetDatum(memAddress));
|
on_shmem_exit(IpcMemoryDetach, PointerGetDatum(memAddress));
|
||||||
@ -177,13 +162,7 @@ static void
|
|||||||
IpcMemoryDetach(int status, Datum shmaddr)
|
IpcMemoryDetach(int status, Datum shmaddr)
|
||||||
{
|
{
|
||||||
if (shmdt(DatumGetPointer(shmaddr)) < 0)
|
if (shmdt(DatumGetPointer(shmaddr)) < 0)
|
||||||
fprintf(stderr, "IpcMemoryDetach: shmdt(%p) failed: %s\n",
|
elog(LOG, "shmdt(%p) failed: %m", DatumGetPointer(shmaddr));
|
||||||
DatumGetPointer(shmaddr), strerror(errno));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We used to report a failure via ereport(WARNING), but that's pretty
|
|
||||||
* pointless considering any client has long since disconnected ...
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
@ -194,13 +173,8 @@ static void
|
|||||||
IpcMemoryDelete(int status, Datum shmId)
|
IpcMemoryDelete(int status, Datum shmId)
|
||||||
{
|
{
|
||||||
if (shmctl(DatumGetInt32(shmId), IPC_RMID, (struct shmid_ds *) NULL) < 0)
|
if (shmctl(DatumGetInt32(shmId), IPC_RMID, (struct shmid_ds *) NULL) < 0)
|
||||||
fprintf(stderr, "IpcMemoryDelete: shmctl(%d, %d, 0) failed: %s\n",
|
elog(LOG, "shmctl(%d, %d, 0) failed: %m",
|
||||||
DatumGetInt32(shmId), IPC_RMID, strerror(errno));
|
DatumGetInt32(shmId), IPC_RMID);
|
||||||
|
|
||||||
/*
|
|
||||||
* We used to report a failure via ereport(WARNING), but that's pretty
|
|
||||||
* pointless considering any client has long since disconnected ...
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -274,11 +248,8 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
|
|||||||
if (ExecBackend && UsedShmemSegAddr != NULL && !makePrivate)
|
if (ExecBackend && UsedShmemSegAddr != NULL && !makePrivate)
|
||||||
{
|
{
|
||||||
if ((hdr = PGSharedMemoryAttach(UsedShmemSegID, &shmid)) == NULL)
|
if ((hdr = PGSharedMemoryAttach(UsedShmemSegID, &shmid)) == NULL)
|
||||||
{
|
elog(FATAL, "could not attach to proper memory at fixed address: shmget(key=%d, addr=%p) failed: %m",
|
||||||
fprintf(stderr, "Unable to attach to proper memory at fixed address: shmget(key=%d, addr=%p) failed: %s\n",
|
(int) UsedShmemSegID, UsedShmemSegAddr);
|
||||||
(int) UsedShmemSegID, UsedShmemSegAddr, strerror(errno));
|
|
||||||
proc_exit(1);
|
|
||||||
}
|
|
||||||
return hdr;
|
return hdr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.336 2003/07/23 23:30:40 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.337 2003/07/27 21:49:54 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
*
|
*
|
||||||
@ -271,7 +271,7 @@ static void CleanupProc(int pid, int exitstatus);
|
|||||||
static void LogChildExit(int lev, const char *procname,
|
static void LogChildExit(int lev, const char *procname,
|
||||||
int pid, int exitstatus);
|
int pid, int exitstatus);
|
||||||
static int BackendFork(Port *port);
|
static int BackendFork(Port *port);
|
||||||
void ExitPostmaster(int status);
|
static void ExitPostmaster(int status);
|
||||||
static void usage(const char *);
|
static void usage(const char *);
|
||||||
static int ServerLoop(void);
|
static int ServerLoop(void);
|
||||||
static int BackendStartup(Port *port);
|
static int BackendStartup(Port *port);
|
||||||
@ -290,8 +290,7 @@ static void SignalChildren(int signal);
|
|||||||
static int CountChildren(void);
|
static int CountChildren(void);
|
||||||
static bool CreateOptsFile(int argc, char *argv[]);
|
static bool CreateOptsFile(int argc, char *argv[]);
|
||||||
static pid_t SSDataBase(int xlop);
|
static pid_t SSDataBase(int xlop);
|
||||||
void
|
static void postmaster_error(const char *fmt,...)
|
||||||
postmaster_error(const char *fmt,...)
|
|
||||||
/* This lets gcc check the format string for consistency. */
|
/* This lets gcc check the format string for consistency. */
|
||||||
__attribute__((format(printf, 1, 2)));
|
__attribute__((format(printf, 1, 2)));
|
||||||
|
|
||||||
@ -299,29 +298,21 @@ __attribute__((format(printf, 1, 2)));
|
|||||||
#define CheckPointDataBase() SSDataBase(BS_XLOG_CHECKPOINT)
|
#define CheckPointDataBase() SSDataBase(BS_XLOG_CHECKPOINT)
|
||||||
#define ShutdownDataBase() SSDataBase(BS_XLOG_SHUTDOWN)
|
#define ShutdownDataBase() SSDataBase(BS_XLOG_SHUTDOWN)
|
||||||
|
|
||||||
#ifdef USE_SSL
|
|
||||||
extern int secure_initialize(void);
|
|
||||||
extern void secure_destroy(void);
|
|
||||||
extern int secure_open_server(Port *);
|
|
||||||
extern void secure_close(Port *);
|
|
||||||
#endif /* USE_SSL */
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
checkDataDir(const char *checkdir)
|
checkDataDir(const char *checkdir)
|
||||||
{
|
{
|
||||||
char path[MAXPGPATH];
|
char path[MAXPGPATH];
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
|
|
||||||
if (checkdir == NULL)
|
if (checkdir == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, gettext(
|
fprintf(stderr,
|
||||||
"%s does not know where to find the database system data.\n"
|
gettext("%s does not know where to find the database system data.\n"
|
||||||
"You must specify the directory that contains the database system\n"
|
"You must specify the directory that contains the database system\n"
|
||||||
"either by specifying the -D invocation option or by setting the\n"
|
"either by specifying the -D invocation option or by setting the\n"
|
||||||
"PGDATA environment variable.\n\n"),
|
"PGDATA environment variable.\n"),
|
||||||
progname);
|
progname);
|
||||||
ExitPostmaster(2);
|
ExitPostmaster(2);
|
||||||
}
|
}
|
||||||
@ -353,7 +344,7 @@ checkDataDir(const char *checkdir)
|
|||||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||||
errmsg("data directory \"%s\" has group or world access",
|
errmsg("data directory \"%s\" has group or world access",
|
||||||
checkdir),
|
checkdir),
|
||||||
errdetail("permissions should be u=rwx (0700)")));
|
errdetail("Permissions should be u=rwx (0700).")));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Look for PG_VERSION before looking for pg_control */
|
/* Look for PG_VERSION before looking for pg_control */
|
||||||
@ -364,10 +355,10 @@ checkDataDir(const char *checkdir)
|
|||||||
fp = AllocateFile(path, PG_BINARY_R);
|
fp = AllocateFile(path, PG_BINARY_R);
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, gettext(
|
fprintf(stderr,
|
||||||
"%s does not find the database system.\n"
|
gettext("%s could not find the database system.\n"
|
||||||
"Expected to find it in the PGDATA directory \"%s\",\n"
|
"Expected to find it in the PGDATA directory \"%s\",\n"
|
||||||
"but unable to open file \"%s\": %s\n\n"),
|
"but failed to open file \"%s\": %s\n"),
|
||||||
progname, checkdir, path, strerror(errno));
|
progname, checkdir, path, strerror(errno));
|
||||||
ExitPostmaster(2);
|
ExitPostmaster(2);
|
||||||
}
|
}
|
||||||
@ -464,7 +455,7 @@ PostmasterMain(int argc, char *argv[])
|
|||||||
#ifdef USE_ASSERT_CHECKING
|
#ifdef USE_ASSERT_CHECKING
|
||||||
SetConfigOption("debug_assertions", optarg, PGC_POSTMASTER, PGC_S_ARGV);
|
SetConfigOption("debug_assertions", optarg, PGC_POSTMASTER, PGC_S_ARGV);
|
||||||
#else
|
#else
|
||||||
postmaster_error("Assert checking is not compiled in.");
|
postmaster_error("assert checking is not compiled in");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
@ -589,7 +580,9 @@ PostmasterMain(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, gettext("Try '%s --help' for more information.\n"), progname);
|
fprintf(stderr,
|
||||||
|
gettext("Try '%s --help' for more information.\n"),
|
||||||
|
progname);
|
||||||
ExitPostmaster(1);
|
ExitPostmaster(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -599,8 +592,9 @@ PostmasterMain(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
if (optind < argc)
|
if (optind < argc)
|
||||||
{
|
{
|
||||||
postmaster_error("invalid argument -- %s", argv[optind]);
|
postmaster_error("invalid argument: \"%s\"", argv[optind]);
|
||||||
fprintf(stderr, gettext("Try '%s --help' for more information.\n"),
|
fprintf(stderr,
|
||||||
|
gettext("Try '%s --help' for more information.\n"),
|
||||||
progname);
|
progname);
|
||||||
ExitPostmaster(1);
|
ExitPostmaster(1);
|
||||||
}
|
}
|
||||||
@ -626,13 +620,13 @@ PostmasterMain(int argc, char *argv[])
|
|||||||
* for lack of buffers. The specific choices here are somewhat
|
* for lack of buffers. The specific choices here are somewhat
|
||||||
* arbitrary.
|
* arbitrary.
|
||||||
*/
|
*/
|
||||||
postmaster_error("The number of buffers (-B) must be at least twice the number of allowed connections (-N) and at least 16.");
|
postmaster_error("the number of buffers (-B) must be at least twice the number of allowed connections (-N) and at least 16");
|
||||||
ExitPostmaster(1);
|
ExitPostmaster(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ReservedBackends >= MaxBackends)
|
if (ReservedBackends >= MaxBackends)
|
||||||
{
|
{
|
||||||
postmaster_error("superuser_reserved_connections must be less than max_connections.");
|
postmaster_error("superuser_reserved_connections must be less than max_connections");
|
||||||
ExitPostmaster(1);
|
ExitPostmaster(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,7 +635,7 @@ PostmasterMain(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
if (!CheckDateTokenTables())
|
if (!CheckDateTokenTables())
|
||||||
{
|
{
|
||||||
postmaster_error("Invalid datetoken tables, please fix.");
|
postmaster_error("invalid datetoken tables, please fix");
|
||||||
ExitPostmaster(1);
|
ExitPostmaster(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,8 +674,7 @@ PostmasterMain(int argc, char *argv[])
|
|||||||
#ifdef USE_SSL
|
#ifdef USE_SSL
|
||||||
if (EnableSSL && !NetServer)
|
if (EnableSSL && !NetServer)
|
||||||
{
|
{
|
||||||
postmaster_error("For SSL, TCP/IP connections must be enabled.");
|
postmaster_error("for SSL, TCP/IP connections must be enabled");
|
||||||
fprintf(stderr, gettext("Try '%s --help' for more information.\n"), progname);
|
|
||||||
ExitPostmaster(1);
|
ExitPostmaster(1);
|
||||||
}
|
}
|
||||||
if (EnableSSL)
|
if (EnableSSL)
|
||||||
@ -713,8 +706,7 @@ PostmasterMain(int argc, char *argv[])
|
|||||||
* :-(). For the same reason, it's best to grab the TCP socket before
|
* :-(). For the same reason, it's best to grab the TCP socket before
|
||||||
* the Unix socket.
|
* the Unix socket.
|
||||||
*/
|
*/
|
||||||
if (!CreateDataDirLockFile(DataDir, true))
|
CreateDataDirLockFile(DataDir, true);
|
||||||
ExitPostmaster(1);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove old temporary files. At this point there can be no other
|
* Remove old temporary files. At this point there can be no other
|
||||||
@ -754,10 +746,9 @@ PostmasterMain(int argc, char *argv[])
|
|||||||
UnixSocketDir,
|
UnixSocketDir,
|
||||||
ListenSocket, MAXLISTEN);
|
ListenSocket, MAXLISTEN);
|
||||||
if (status != STATUS_OK)
|
if (status != STATUS_OK)
|
||||||
{
|
ereport(LOG,
|
||||||
postmaster_error("could not create listen socket for \"%s\"",
|
(errmsg("could not create listen socket for \"%s\"",
|
||||||
curhost);
|
curhost)));
|
||||||
}
|
|
||||||
if (endptr)
|
if (endptr)
|
||||||
{
|
{
|
||||||
*endptr = c;
|
*endptr = c;
|
||||||
@ -774,9 +765,8 @@ PostmasterMain(int argc, char *argv[])
|
|||||||
UnixSocketDir,
|
UnixSocketDir,
|
||||||
ListenSocket, MAXLISTEN);
|
ListenSocket, MAXLISTEN);
|
||||||
if (status != STATUS_OK)
|
if (status != STATUS_OK)
|
||||||
{
|
ereport(LOG,
|
||||||
postmaster_error("could not create TCP/IP listen socket");
|
(errmsg("could not create TCP/IP listen socket")));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_RENDEZVOUS
|
#ifdef USE_RENDEZVOUS
|
||||||
@ -799,10 +789,8 @@ PostmasterMain(int argc, char *argv[])
|
|||||||
UnixSocketDir,
|
UnixSocketDir,
|
||||||
ListenSocket, MAXLISTEN);
|
ListenSocket, MAXLISTEN);
|
||||||
if (status != STATUS_OK)
|
if (status != STATUS_OK)
|
||||||
{
|
ereport(FATAL,
|
||||||
postmaster_error("could not create UNIX stream port");
|
(errmsg("could not create UNIX stream port")));
|
||||||
ExitPostmaster(1);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XLOGPathInit();
|
XLOGPathInit();
|
||||||
@ -922,9 +910,9 @@ pmdaemonize(int argc, char *argv[])
|
|||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid == (pid_t) -1)
|
if (pid == (pid_t) -1)
|
||||||
{
|
{
|
||||||
postmaster_error("fork failed: %s", strerror(errno));
|
postmaster_error("could not fork background process: %s",
|
||||||
|
strerror(errno));
|
||||||
ExitPostmaster(1);
|
ExitPostmaster(1);
|
||||||
return; /* not reached */
|
|
||||||
}
|
}
|
||||||
else if (pid)
|
else if (pid)
|
||||||
{ /* parent */
|
{ /* parent */
|
||||||
@ -944,7 +932,7 @@ pmdaemonize(int argc, char *argv[])
|
|||||||
#ifdef HAVE_SETSID
|
#ifdef HAVE_SETSID
|
||||||
if (setsid() < 0)
|
if (setsid() < 0)
|
||||||
{
|
{
|
||||||
postmaster_error("cannot disassociate from controlling TTY: %s",
|
postmaster_error("could not disassociate from controlling TTY: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
ExitPostmaster(1);
|
ExitPostmaster(1);
|
||||||
}
|
}
|
||||||
@ -1553,7 +1541,6 @@ ConnCreate(int serverFd)
|
|||||||
ereport(LOG,
|
ereport(LOG,
|
||||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||||
errmsg("out of memory")));
|
errmsg("out of memory")));
|
||||||
SignalChildren(SIGQUIT);
|
|
||||||
ExitPostmaster(1);
|
ExitPostmaster(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1842,6 +1829,7 @@ reaper(SIGNAL_ARGS)
|
|||||||
pid, exitstatus);
|
pid, exitstatus);
|
||||||
ExitPostmaster(1);
|
ExitPostmaster(1);
|
||||||
}
|
}
|
||||||
|
/* Normal postmaster exit is here */
|
||||||
ExitPostmaster(0);
|
ExitPostmaster(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2545,7 +2533,7 @@ BackendFork(Port *port)
|
|||||||
*
|
*
|
||||||
* Do NOT call exit() directly --- always go through here!
|
* Do NOT call exit() directly --- always go through here!
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
ExitPostmaster(int status)
|
ExitPostmaster(int status)
|
||||||
{
|
{
|
||||||
/* should cleanup shared memory and kill all backends */
|
/* should cleanup shared memory and kill all backends */
|
||||||
@ -2922,20 +2910,18 @@ static bool
|
|||||||
CreateOptsFile(int argc, char *argv[])
|
CreateOptsFile(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char fullprogname[MAXPGPATH];
|
char fullprogname[MAXPGPATH];
|
||||||
char *filename;
|
char filename[MAXPGPATH];
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
unsigned i;
|
int i;
|
||||||
|
|
||||||
if (FindExec(fullprogname, argv[0], "postmaster") < 0)
|
if (FindExec(fullprogname, argv[0], "postmaster") < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
filename = palloc(strlen(DataDir) + 17);
|
snprintf(filename, sizeof(filename), "%s/postmaster.opts", DataDir);
|
||||||
sprintf(filename, "%s/postmaster.opts", DataDir);
|
|
||||||
|
|
||||||
if ((fp = fopen(filename, "w")) == NULL)
|
if ((fp = fopen(filename, "w")) == NULL)
|
||||||
{
|
{
|
||||||
postmaster_error("cannot create file \"%s\": %s",
|
elog(LOG, "could not create file \"%s\": %m", filename);
|
||||||
filename, strerror(errno));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2944,9 +2930,10 @@ CreateOptsFile(int argc, char *argv[])
|
|||||||
fprintf(fp, " '%s'", argv[i]);
|
fprintf(fp, " '%s'", argv[i]);
|
||||||
fputs("\n", fp);
|
fputs("\n", fp);
|
||||||
|
|
||||||
|
fflush(fp);
|
||||||
if (ferror(fp))
|
if (ferror(fp))
|
||||||
{
|
{
|
||||||
postmaster_error("writing file %s failed", filename);
|
elog(LOG, "could not write file \"%s\": %m", filename);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2956,10 +2943,12 @@ CreateOptsFile(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This should be used only for reporting "interactive" errors (ie, errors
|
* This should be used only for reporting "interactive" errors (essentially,
|
||||||
* during startup). Once the postmaster is launched, use ereport.
|
* bogus arguments on the command line). Once the postmaster is launched,
|
||||||
|
* use ereport. In particular, don't use this for anything that occurs
|
||||||
|
* after pmdaemonize.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
postmaster_error(const char *fmt,...)
|
postmaster_error(const char *fmt,...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/s_lock.c,v 1.11 2003/04/20 21:54:34 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/s_lock.c,v 1.12 2003/07/27 21:49:54 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -27,13 +27,15 @@
|
|||||||
static void
|
static void
|
||||||
s_lock_stuck(volatile slock_t *lock, const char *file, int line)
|
s_lock_stuck(volatile slock_t *lock, const char *file, int line)
|
||||||
{
|
{
|
||||||
|
#if defined(S_LOCK_TEST)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"\nFATAL: s_lock(%p) at %s:%d, stuck spinlock. Aborting.\n",
|
"\nFATAL: stuck spinlock (%p) detected at %s:%d.\n",
|
||||||
lock, file, line);
|
|
||||||
fprintf(stdout,
|
|
||||||
"\nFATAL: s_lock(%p) at %s:%d, stuck spinlock. Aborting.\n",
|
|
||||||
lock, file, line);
|
lock, file, line);
|
||||||
abort();
|
abort();
|
||||||
|
#else
|
||||||
|
elog(PANIC, "stuck spinlock (%p) detected at %s:%d",
|
||||||
|
lock, file, line);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -238,7 +240,6 @@ main()
|
|||||||
|
|
||||||
printf("S_LOCK_TEST: failed, lock not locked~\n");
|
printf("S_LOCK_TEST: failed, lock not locked~\n");
|
||||||
exit(3);
|
exit(3);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* S_LOCK_TEST */
|
#endif /* S_LOCK_TEST */
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.351 2003/07/22 19:00:11 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.352 2003/07/27 21:49:54 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* this is the "main" module of the postgres backend and
|
* this is the "main" module of the postgres backend and
|
||||||
@ -2446,10 +2446,11 @@ PostgresMain(int argc, char *argv[], const char *username)
|
|||||||
{
|
{
|
||||||
if (!potential_DataDir)
|
if (!potential_DataDir)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s does not know where to find the database system "
|
fprintf(stderr,
|
||||||
"data. You must specify the directory that contains the "
|
gettext("%s does not know where to find the database system data.\n"
|
||||||
"database system either by specifying the -D invocation "
|
"You must specify the directory that contains the database system\n"
|
||||||
"option or by setting the PGDATA environment variable.\n\n",
|
"either by specifying the -D invocation option or by setting the\n"
|
||||||
|
"PGDATA environment variable.\n"),
|
||||||
argv[0]);
|
argv[0]);
|
||||||
proc_exit(1);
|
proc_exit(1);
|
||||||
}
|
}
|
||||||
@ -2567,8 +2568,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
|||||||
/*
|
/*
|
||||||
* Create lockfile for data directory.
|
* Create lockfile for data directory.
|
||||||
*/
|
*/
|
||||||
if (!CreateDataDirLockFile(DataDir, false))
|
CreateDataDirLockFile(DataDir, false);
|
||||||
proc_exit(1);
|
|
||||||
|
|
||||||
XLOGPathInit();
|
XLOGPathInit();
|
||||||
BaseInit();
|
BaseInit();
|
||||||
@ -2626,7 +2626,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
|||||||
if (!IsUnderPostmaster)
|
if (!IsUnderPostmaster)
|
||||||
{
|
{
|
||||||
puts("\nPOSTGRES backend interactive interface ");
|
puts("\nPOSTGRES backend interactive interface ");
|
||||||
puts("$Revision: 1.351 $ $Date: 2003/07/22 19:00:11 $\n");
|
puts("$Revision: 1.352 $ $Date: 2003/07/27 21:49:54 $\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.114 2003/07/22 19:00:12 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.115 2003/07/27 21:49:54 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -69,8 +69,8 @@ ErrorContextCallback *error_context_stack = NULL;
|
|||||||
|
|
||||||
/* GUC parameters */
|
/* GUC parameters */
|
||||||
PGErrorVerbosity Log_error_verbosity = PGERROR_VERBOSE;
|
PGErrorVerbosity Log_error_verbosity = PGERROR_VERBOSE;
|
||||||
bool Log_timestamp; /* show timestamps in stderr output */
|
bool Log_timestamp = false; /* show timestamps in stderr output */
|
||||||
bool Log_pid; /* show PIDs in stderr output */
|
bool Log_pid = false; /* show PIDs in stderr output */
|
||||||
|
|
||||||
#ifdef HAVE_SYSLOG
|
#ifdef HAVE_SYSLOG
|
||||||
/*
|
/*
|
||||||
@ -1344,11 +1344,7 @@ useful_strerror(int errnum)
|
|||||||
static char errorstr_buf[48];
|
static char errorstr_buf[48];
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
if (errnum == ERANGE)
|
str = strerror(errnum);
|
||||||
/* small trick to save creating many regression test result files */
|
|
||||||
str = gettext("Numerical result out of range");
|
|
||||||
else
|
|
||||||
str = strerror(errnum);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some strerror()s return an empty string for out-of-range errno.
|
* Some strerror()s return an empty string for out-of-range errno.
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.106 2003/07/27 19:39:13 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.107 2003/07/27 21:49:54 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -697,15 +697,13 @@ UnlinkLockFile(int status, Datum filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a lockfile, if possible
|
* Create a lockfile.
|
||||||
*
|
|
||||||
* Call CreateLockFile with the name of the lockfile to be created.
|
|
||||||
* Returns true if successful, false if not (with a message on stderr).
|
|
||||||
*
|
*
|
||||||
|
* filename is the name of the lockfile to create.
|
||||||
* amPostmaster is used to determine how to encode the output PID.
|
* amPostmaster is used to determine how to encode the output PID.
|
||||||
* isDDLock and refName are used to determine what error message to produce.
|
* isDDLock and refName are used to determine what error message to produce.
|
||||||
*/
|
*/
|
||||||
static bool
|
static void
|
||||||
CreateLockFile(const char *filename, bool amPostmaster,
|
CreateLockFile(const char *filename, bool amPostmaster,
|
||||||
bool isDDLock, const char *refName)
|
bool isDDLock, const char *refName)
|
||||||
{
|
{
|
||||||
@ -786,19 +784,17 @@ CreateLockFile(const char *filename, bool amPostmaster,
|
|||||||
))
|
))
|
||||||
{
|
{
|
||||||
/* lockfile belongs to a live process */
|
/* lockfile belongs to a live process */
|
||||||
fprintf(stderr, "Lock file \"%s\" already exists.\n",
|
ereport(FATAL,
|
||||||
filename);
|
(errcode(ERRCODE_LOCK_FILE_EXISTS),
|
||||||
if (isDDLock)
|
errmsg("lock file \"%s\" already exists",
|
||||||
fprintf(stderr,
|
filename),
|
||||||
"Is another %s (pid %d) running in \"%s\"?\n",
|
isDDLock ?
|
||||||
(encoded_pid < 0 ? "postgres" : "postmaster"),
|
errhint("Is another %s (pid %d) running in \"%s\"?",
|
||||||
(int) other_pid, refName);
|
(encoded_pid < 0 ? "postgres" : "postmaster"),
|
||||||
else
|
(int) other_pid, refName) :
|
||||||
fprintf(stderr,
|
errhint("Is another %s (pid %d) using \"%s\"?",
|
||||||
"Is another %s (pid %d) using \"%s\"?\n",
|
(encoded_pid < 0 ? "postgres" : "postmaster"),
|
||||||
(encoded_pid < 0 ? "postgres" : "postmaster"),
|
(int) other_pid, refName)));
|
||||||
(int) other_pid, refName);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -823,15 +819,16 @@ CreateLockFile(const char *filename, bool amPostmaster,
|
|||||||
if (sscanf(ptr, "%lu %lu", &id1, &id2) == 2)
|
if (sscanf(ptr, "%lu %lu", &id1, &id2) == 2)
|
||||||
{
|
{
|
||||||
if (PGSharedMemoryIsInUse(id1, id2))
|
if (PGSharedMemoryIsInUse(id1, id2))
|
||||||
{
|
ereport(FATAL,
|
||||||
fprintf(stderr,
|
(errcode(ERRCODE_LOCK_FILE_EXISTS),
|
||||||
"Found a pre-existing shared memory block (key %lu, id %lu) still in use.\n"
|
errmsg("pre-existing shared memory block "
|
||||||
"If you're sure there are no old backends still running,\n"
|
"(key %lu, id %lu) is still in use",
|
||||||
"remove the shared memory block with ipcrm(1), or just\n"
|
id1, id2),
|
||||||
"delete \"%s\".\n",
|
errhint("If you're sure there are no old "
|
||||||
id1, id2, filename);
|
"backends still running, remove "
|
||||||
return false;
|
"the shared memory block with "
|
||||||
}
|
"ipcrm(1), or just delete \"%s\".",
|
||||||
|
filename)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -876,34 +873,28 @@ CreateLockFile(const char *filename, bool amPostmaster,
|
|||||||
* Arrange for automatic removal of lockfile at proc_exit.
|
* Arrange for automatic removal of lockfile at proc_exit.
|
||||||
*/
|
*/
|
||||||
on_proc_exit(UnlinkLockFile, PointerGetDatum(strdup(filename)));
|
on_proc_exit(UnlinkLockFile, PointerGetDatum(strdup(filename)));
|
||||||
|
|
||||||
return true; /* Success! */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
CreateDataDirLockFile(const char *datadir, bool amPostmaster)
|
CreateDataDirLockFile(const char *datadir, bool amPostmaster)
|
||||||
{
|
{
|
||||||
char lockfile[MAXPGPATH];
|
char lockfile[MAXPGPATH];
|
||||||
|
|
||||||
snprintf(lockfile, sizeof(lockfile), "%s/postmaster.pid", datadir);
|
snprintf(lockfile, sizeof(lockfile), "%s/postmaster.pid", datadir);
|
||||||
if (!CreateLockFile(lockfile, amPostmaster, true, datadir))
|
CreateLockFile(lockfile, amPostmaster, true, datadir);
|
||||||
return false;
|
|
||||||
/* Save name of lockfile for RecordSharedMemoryInLockFile */
|
/* Save name of lockfile for RecordSharedMemoryInLockFile */
|
||||||
strcpy(directoryLockFile, lockfile);
|
strcpy(directoryLockFile, lockfile);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
CreateSocketLockFile(const char *socketfile, bool amPostmaster)
|
CreateSocketLockFile(const char *socketfile, bool amPostmaster)
|
||||||
{
|
{
|
||||||
char lockfile[MAXPGPATH];
|
char lockfile[MAXPGPATH];
|
||||||
|
|
||||||
snprintf(lockfile, sizeof(lockfile), "%s.lock", socketfile);
|
snprintf(lockfile, sizeof(lockfile), "%s.lock", socketfile);
|
||||||
if (!CreateLockFile(lockfile, amPostmaster, false, socketfile))
|
CreateLockFile(lockfile, amPostmaster, false, socketfile);
|
||||||
return false;
|
|
||||||
/* Save name of lockfile for TouchSocketLockFile */
|
/* Save name of lockfile for TouchSocketLockFile */
|
||||||
strcpy(socketLockFile, lockfile);
|
strcpy(socketLockFile, lockfile);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1062,7 +1053,7 @@ ValidatePgVersion(const char *path)
|
|||||||
if (*endptr == '.')
|
if (*endptr == '.')
|
||||||
my_minor = strtol(endptr + 1, NULL, 10);
|
my_minor = strtol(endptr + 1, NULL, 10);
|
||||||
|
|
||||||
snprintf(full_path, MAXPGPATH, "%s/PG_VERSION", path);
|
snprintf(full_path, sizeof(full_path), "%s/PG_VERSION", path);
|
||||||
|
|
||||||
file = AllocateFile(full_path, "r");
|
file = AllocateFile(full_path, "r");
|
||||||
if (!file)
|
if (!file)
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: miscadmin.h,v 1.127 2003/07/27 17:10:07 tgl Exp $
|
* $Id: miscadmin.h,v 1.128 2003/07/27 21:49:54 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* some of the information in this file should be moved to
|
* some of the information in this file should be moved to
|
||||||
@ -286,8 +286,8 @@ extern void InitPostgres(const char *dbname, const char *username);
|
|||||||
extern void BaseInit(void);
|
extern void BaseInit(void);
|
||||||
|
|
||||||
/* in utils/init/miscinit.c */
|
/* in utils/init/miscinit.c */
|
||||||
extern bool CreateDataDirLockFile(const char *datadir, bool amPostmaster);
|
extern void CreateDataDirLockFile(const char *datadir, bool amPostmaster);
|
||||||
extern bool CreateSocketLockFile(const char *socketfile, bool amPostmaster);
|
extern void CreateSocketLockFile(const char *socketfile, bool amPostmaster);
|
||||||
extern void TouchSocketLockFile(void);
|
extern void TouchSocketLockFile(void);
|
||||||
extern void RecordSharedMemoryInLockFile(unsigned long id1,
|
extern void RecordSharedMemoryInLockFile(unsigned long id1,
|
||||||
unsigned long id2);
|
unsigned long id2);
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2003, PostgreSQL Global Development Group
|
* Copyright (c) 2003, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $Id: errcodes.h,v 1.1 2003/07/27 18:37:52 tgl Exp $
|
* $Id: errcodes.h,v 1.2 2003/07/27 21:49:54 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -297,6 +297,7 @@
|
|||||||
|
|
||||||
/* Class F0 - Configuration File Error (PostgreSQL-specific error class) */
|
/* Class F0 - Configuration File Error (PostgreSQL-specific error class) */
|
||||||
#define ERRCODE_CONFIG_FILE_ERROR MAKE_SQLSTATE('F','0', '0','0','0')
|
#define ERRCODE_CONFIG_FILE_ERROR MAKE_SQLSTATE('F','0', '0','0','0')
|
||||||
|
#define ERRCODE_LOCK_FILE_EXISTS MAKE_SQLSTATE('F','0', '0','0','1')
|
||||||
|
|
||||||
/* Class XX - Internal Error (PostgreSQL-specific error class) */
|
/* Class XX - Internal Error (PostgreSQL-specific error class) */
|
||||||
/* (this is for "can't-happen" conditions and software bugs) */
|
/* (this is for "can't-happen" conditions and software bugs) */
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* procedural language
|
* procedural language
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.45 2003/07/25 23:37:28 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.46 2003/07/27 21:49:54 tgl Exp $
|
||||||
*
|
*
|
||||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||||
*
|
*
|
||||||
@ -553,7 +553,7 @@ decl_aliasitem : T_WORD
|
|||||||
|
|
||||||
plpgsql_convert_ident(yytext, &name, 1);
|
plpgsql_convert_ident(yytext, &name, 1);
|
||||||
if (name[0] != '$')
|
if (name[0] != '$')
|
||||||
yyerror("can only alias positional parameters");
|
yyerror("only positional parameters may be aliased");
|
||||||
|
|
||||||
plpgsql_ns_setlocal(false);
|
plpgsql_ns_setlocal(false);
|
||||||
nsi = plpgsql_ns_lookup(name, NULL);
|
nsi = plpgsql_ns_lookup(name, NULL);
|
||||||
@ -647,10 +647,10 @@ decl_defval : ';'
|
|||||||
switch (tok)
|
switch (tok)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
yyerror("unexpected end of file");
|
yyerror("unexpected end of function");
|
||||||
case K_NULL:
|
case K_NULL:
|
||||||
if (yylex() != ';')
|
if (yylex() != ';')
|
||||||
yyerror("expected ; after NULL");
|
yyerror("expected \";\" after \"NULL\"");
|
||||||
|
|
||||||
free(expr);
|
free(expr);
|
||||||
plpgsql_dstring_free(&ds);
|
plpgsql_dstring_free(&ds);
|
||||||
@ -1201,7 +1201,7 @@ stmt_return : K_RETURN lno
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (yylex() != ';')
|
if (yylex() != ';')
|
||||||
yyerror("expected ';'");
|
yyerror("expected \";\"");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
new->expr = plpgsql_read_expression(';', ";");
|
new->expr = plpgsql_read_expression(';', ";");
|
||||||
@ -1232,10 +1232,10 @@ stmt_return_next: K_RETURN_NEXT lno
|
|||||||
else if (tok == T_ROW)
|
else if (tok == T_ROW)
|
||||||
new->row = yylval.row;
|
new->row = yylval.row;
|
||||||
else
|
else
|
||||||
yyerror("Incorrect argument to RETURN NEXT");
|
yyerror("incorrect argument to RETURN NEXT");
|
||||||
|
|
||||||
if (yylex() != ';')
|
if (yylex() != ';')
|
||||||
yyerror("Expected ';'");
|
yyerror("expected \";\"");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
new->expr = plpgsql_read_expression(';', ";");
|
new->expr = plpgsql_read_expression(';', ";");
|
||||||
@ -1467,7 +1467,7 @@ stmt_open : K_OPEN lno cursor_varptr
|
|||||||
cp += strlen(cp) - 1;
|
cp += strlen(cp) - 1;
|
||||||
|
|
||||||
if (*cp != ')')
|
if (*cp != ')')
|
||||||
yyerror("missing )");
|
yyerror("expected \")\"");
|
||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2096,7 +2096,7 @@ check_assignable(PLpgSQL_datum *datum)
|
|||||||
yyerror("cannot assign to tg_argv");
|
yyerror("cannot assign to tg_argv");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
yyerror("check_assignable: unexpected datum type");
|
elog(ERROR, "unrecognized dtype: %d", datum->dtype);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* procedural language
|
* procedural language
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.62 2003/07/27 18:38:26 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.63 2003/07/27 21:49:54 tgl Exp $
|
||||||
*
|
*
|
||||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||||
*
|
*
|
||||||
@ -755,7 +755,7 @@ plpgsql_parse_word(char *word)
|
|||||||
trigarg->dtype = PLPGSQL_DTYPE_TRIGARG;
|
trigarg->dtype = PLPGSQL_DTYPE_TRIGARG;
|
||||||
|
|
||||||
if (plpgsql_yylex() != '[')
|
if (plpgsql_yylex() != '[')
|
||||||
plpgsql_yyerror("expected [");
|
plpgsql_yyerror("expected \"[\"");
|
||||||
|
|
||||||
trigarg->argnum = plpgsql_read_expression(']', "]");
|
trigarg->argnum = plpgsql_read_expression(']', "]");
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.56 2003/05/27 17:49:47 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.57 2003/07/27 21:49:55 tgl Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
@ -297,11 +297,7 @@ reverse_name(char *string)
|
|||||||
int len;
|
int len;
|
||||||
char *new_string;
|
char *new_string;
|
||||||
|
|
||||||
if (!(new_string = palloc0(NAMEDATALEN)))
|
new_string = palloc0(NAMEDATALEN);
|
||||||
{
|
|
||||||
fprintf(stderr, "reverse_name: palloc failed\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
for (i = 0; i < NAMEDATALEN && string[i]; ++i)
|
for (i = 0; i < NAMEDATALEN && string[i]; ++i)
|
||||||
;
|
;
|
||||||
if (i == NAMEDATALEN || !string[i])
|
if (i == NAMEDATALEN || !string[i])
|
||||||
|
Reference in New Issue
Block a user