# Makefile for libpq subsystem (backend half of libpq interface)
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/libpq/Makefile,v 1.28 2001/11/13 22:06:58 momjian Exp $
+# $Header: /cvsroot/pgsql/src/backend/libpq/Makefile,v 1.29 2002/03/04 01:46:02 tgl Exp $
#
#-------------------------------------------------------------------------
OBJS = be-fsstubs.o \
auth.o crypt.o hba.o md5.o password.o \
- pqcomm.o pqformat.o pqsignal.o util.o
+ pqcomm.o pqformat.o pqsignal.o
all: SUBSYS.o
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.76 2002/03/02 21:39:25 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.77 2002/03/04 01:46:02 tgl Exp $
*
*-------------------------------------------------------------------------
*/
version);
if (status != KSUCCESS)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pg_krb4_recvauth: kerberos error: %s\n",
- krb_err_txt[status]);
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "pg_krb4_recvauth: kerberos error: %s",
+ krb_err_txt[status]);
return STATUS_ERROR;
}
- if (strncmp(version, PG_KRB4_VERSION, KRB_SENDAUTH_VLEN))
+ if (strncmp(version, PG_KRB4_VERSION, KRB_SENDAUTH_VLEN) != 0)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pg_krb4_recvauth: protocol version != \"%s\"\n",
- PG_KRB4_VERSION);
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "pg_krb4_recvauth: protocol version \"%s\" != \"%s\"",
+ version, PG_KRB4_VERSION);
return STATUS_ERROR;
}
- if (strncmp(port->user, auth_data.pname, SM_USER))
+ if (strncmp(port->user, auth_data.pname, SM_USER) != 0)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pg_krb4_recvauth: name \"%s\" != \"%s\"\n",
- port->user, auth_data.pname);
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "pg_krb4_recvauth: name \"%s\" != \"%s\"",
+ port->user, auth_data.pname);
return STATUS_ERROR;
}
return STATUS_OK;
}
#else
+
static int
pg_krb4_recvauth(Port *port)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pg_krb4_recvauth: Kerberos not implemented on this server.\n");
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
-
+ elog(LOG, "pg_krb4_recvauth: Kerberos not implemented on this server");
return STATUS_ERROR;
}
+
#endif /* KRB4 */
retval = krb5_init_context(&pg_krb5_context);
if (retval)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pg_krb5_init: krb5_init_context returned"
- " Kerberos error %d\n", retval);
+ elog(LOG, "pg_krb5_init: krb5_init_context returned Kerberos error %d",
+ retval);
com_err("postgres", retval, "while initializing krb5");
return STATUS_ERROR;
}
retval = krb5_kt_resolve(pg_krb5_context, pg_krb_server_keyfile, &pg_krb5_keytab);
if (retval)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pg_krb5_init: krb5_kt_resolve returned"
- " Kerberos error %d\n", retval);
+ elog(LOG, "pg_krb5_init: krb5_kt_resolve returned Kerberos error %d",
+ retval);
com_err("postgres", retval, "while resolving keytab file %s",
pg_krb_server_keyfile);
krb5_free_context(pg_krb5_context);
KRB5_NT_SRV_HST, &pg_krb5_server);
if (retval)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pg_krb5_init: krb5_sname_to_principal returned"
- " Kerberos error %d\n", retval);
+ elog(LOG, "pg_krb5_init: krb5_sname_to_principal returned Kerberos error %d",
+ retval);
com_err("postgres", retval,
"while getting server principal for service %s",
PG_KRB_SRVNAM);
pg_krb5_server, 0, pg_krb5_keytab, &ticket);
if (retval)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pg_krb5_recvauth: krb5_recvauth returned"
- " Kerberos error %d\n", retval);
+ elog(LOG, "pg_krb5_recvauth: krb5_recvauth returned Kerberos error %d",
+ retval);
com_err("postgres", retval, "from krb5_recvauth");
return STATUS_ERROR;
}
#endif
if (retval)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pg_krb5_recvauth: krb5_unparse_name returned"
- " Kerberos error %d\n", retval);
+ elog(LOG, "pg_krb5_recvauth: krb5_unparse_name returned Kerberos error %d",
+ retval);
com_err("postgres", retval, "while unparsing client name");
krb5_free_ticket(pg_krb5_context, ticket);
krb5_auth_con_free(pg_krb5_context, auth_context);
kusername = pg_an_to_ln(kusername);
if (strncmp(port->user, kusername, SM_USER))
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pg_krb5_recvauth: user name \"%s\" != krb5 name \"%s\"\n",
- port->user, kusername);
+ elog(LOG, "pg_krb5_recvauth: user name \"%s\" != krb5 name \"%s\"",
+ port->user, kusername);
ret = STATUS_ERROR;
}
else
}
#else
+
static int
pg_krb5_recvauth(Port *port)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pg_krb5_recvauth: Kerberos not implemented on this server.\n");
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
-
+ elog(LOG, "pg_krb5_recvauth: Kerberos not implemented on this server");
return STATUS_ERROR;
}
+
#endif /* KRB5 */
if (user == NULL || password == NULL)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pg_password_recvauth: badly formed password packet.\n");
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "pg_password_recvauth: badly formed password packet");
status = STATUS_ERROR;
}
else
if (port->raddr.sa.sa_family == AF_INET)
hostinfo = inet_ntoa(port->raddr.in.sin_addr);
elog(FATAL,
- "No pg_hba.conf entry for host %s, user %s, database %s",
+ "No pg_hba.conf entry for host %s, user %s, database %s",
hostinfo, port->user, port->database);
break;
}
int on = 1;
if (setsockopt(port->sock, 0, LOCAL_CREDS, &on, sizeof(on)) < 0)
- elog(FATAL,
- "pg_local_sendauth: can't do setsockopt: %s\n", strerror(errno));
+ elog(FATAL, "pg_local_sendauth: can't do setsockopt: %m");
}
#endif
if (port->raddr.sa.sa_family == AF_UNIX)
switch (msg[0]->msg_style)
{
case PAM_ERROR_MSG:
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pam_passwd_conv_proc: Error from underlying PAM layer: '%s'\n", msg[0]->msg);
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "pam_passwd_conv_proc: Error from underlying PAM layer: '%s'",
+ msg[0]->msg);
return PAM_CONV_ERR;
default:
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "pam_passwd_conv_proc: Unexpected PAM conversation %d/'%s'\n",
- msg[0]->msg_style, msg[0]->msg);
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "pam_passwd_conv_proc: Unexpected PAM conversation %d/'%s'",
+ msg[0]->msg_style, msg[0]->msg);
return PAM_CONV_ERR;
}
}
initStringInfo(&buf);
pq_getstr(&buf);
- elog(DEBUG5, "received PAM packet with len=%d, pw=%s\n", len, buf.data);
+ elog(DEBUG5, "received PAM packet with len=%d, pw=%s", len, buf.data);
if (strlen(buf.data) == 0)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH, "pam_passwd_conv_proc: no password\n");
- fputs(PQerrormsg, stderr);
+ elog(LOG, "pam_passwd_conv_proc: no password");
return PAM_CONV_ERR;
}
appdata_ptr = buf.data;
*resp = calloc(num_msg, sizeof(struct pam_response));
if (!*resp)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH, "pam_passwd_conv_proc: Out of memory!\n");
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "pam_passwd_conv_proc: Out of memory!");
if (buf.data)
pfree(buf.data);
return PAM_CONV_ERR;
if (retval != PAM_SUCCESS)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "CheckPAMAuth: Failed to create PAM authenticator: '%s'\n",
- pam_strerror(pamh, retval));
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "CheckPAMAuth: Failed to create PAM authenticator: '%s'",
+ pam_strerror(pamh, retval));
pam_passwd = NULL; /* Unset pam_passwd */
return STATUS_ERROR;
}
if (retval != PAM_SUCCESS)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "CheckPAMAuth: pam_set_item(PAM_USER) failed: '%s'\n",
- pam_strerror(pamh, retval));
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "CheckPAMAuth: pam_set_item(PAM_USER) failed: '%s'",
+ pam_strerror(pamh, retval));
pam_passwd = NULL; /* Unset pam_passwd */
return STATUS_ERROR;
}
if (retval != PAM_SUCCESS)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "CheckPAMAuth: pam_set_item(PAM_CONV) failed: '%s'\n",
- pam_strerror(pamh, retval));
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "CheckPAMAuth: pam_set_item(PAM_CONV) failed: '%s'",
+ pam_strerror(pamh, retval));
pam_passwd = NULL; /* Unset pam_passwd */
return STATUS_ERROR;
}
if (retval != PAM_SUCCESS)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "CheckPAMAuth: pam_authenticate failed: '%s'\n",
- pam_strerror(pamh, retval));
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "CheckPAMAuth: pam_authenticate failed: '%s'",
+ pam_strerror(pamh, retval));
pam_passwd = NULL; /* Unset pam_passwd */
return STATUS_ERROR;
}
if (retval != PAM_SUCCESS)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "CheckPAMAuth: pam_acct_mgmt failed: '%s'\n",
- pam_strerror(pamh, retval));
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "CheckPAMAuth: pam_acct_mgmt failed: '%s'",
+ pam_strerror(pamh, retval));
pam_passwd = NULL; /* Unset pam_passwd */
return STATUS_ERROR;
}
if (retval != PAM_SUCCESS)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "CheckPAMAuth: Failed to release PAM authenticator: '%s'\n",
- pam_strerror(pamh, retval));
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "CheckPAMAuth: Failed to release PAM authenticator: '%s'",
+ pam_strerror(pamh, retval));
}
pam_passwd = NULL; /* Unset pam_passwd */
return STATUS_EOF;
}
- elog(DEBUG5, "received password packet with len=%d, pw=%s\n",
- len, buf.data);
+ elog(DEBUG5, "received password packet with len=%d, pw=%s",
+ len, buf.data);
result = checkPassword(port, port->user, buf.data);
pfree(buf.data);
break;
default:
- fprintf(stderr, "Invalid startup message type: %u\n", msgtype);
+ elog(LOG, "Invalid startup message type: %u", msgtype);
return STATUS_ERROR;
}
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/libpq/crypt.c,v 1.43 2002/03/02 21:39:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/crypt.c,v 1.44 2002/03/04 01:46:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/* If they encrypt their password, force MD5 */
if (isMD5(passwd) && port->auth_method != uaMD5)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "Password is stored MD5 encrypted. "
- "'password' and 'crypt' auth methods cannot be used.\n");
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "Password is stored MD5 encrypted. "
+ "'password' and 'crypt' auth methods cannot be used.");
return STATUS_ERROR;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.79 2002/01/09 19:13:40 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.80 2002/03/04 01:46:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* to a database named port->database. If so, return *found_p true
* and fill in the auth arguments into the appropriate port fields.
* If not, leave *found_p as it was. If the record has a syntax error,
- * return *error_p true, after issuing a message to stderr. If no error,
+ * return *error_p true, after issuing a message to the log. If no error,
* leave *error_p as it was.
*/
static void
return;
hba_syntax:
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "parse_hba: invalid syntax in pg_hba.conf file at line %d, token \"%s\"\n",
- line_number,
- line ? (const char *) lfirst(line) : "(end of line)");
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "parse_hba: invalid syntax in pg_hba.conf file at line %d, token \"%s\"",
+ line_number,
+ line ? (const char *) lfirst(line) : "(end of line)");
*error_p = true;
return;
{
/* Old config file exists. Tell this guy he needs to upgrade. */
close(fd);
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "A file exists by the name used for host-based authentication "
- "in prior releases of Postgres (%s). The name and format of "
- "the configuration file have changed, so this file should be "
- "converted.\n", old_conf_file);
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "A file exists by the name used for host-based authentication "
+ "in prior releases of Postgres (%s). The name and format of "
+ "the configuration file have changed, so this file should be "
+ "converted.", old_conf_file);
}
else
{
if (file == NULL)
{
/* The open of the config file failed. */
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "load_hba: Unable to open authentication config file \"%s\": %s\n",
- conf_file, strerror(errno));
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "load_hba: Unable to open authentication config file \"%s\": %m",
+ conf_file);
}
else
{
return;
ident_syntax:
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "parse_ident_usermap: invalid syntax in pg_ident.conf file at line %d, token \"%s\"\n",
- line_number,
- line ? (const char *) lfirst(line) : "(end of line)");
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "parse_ident_usermap: invalid syntax in pg_ident.conf file at line %d, token \"%s\"",
+ line_number,
+ line ? (const char *) lfirst(line) : "(end of line)");
*error_p = true;
return;
if (usermap_name[0] == '\0')
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "check_ident_usermap: hba configuration file does not "
- "have the usermap field filled in in the entry that pertains "
- "to this connection. That field is essential for Ident-based "
- "authentication.\n");
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "check_ident_usermap: hba configuration file does not "
+ "have the usermap field filled in in the entry that pertains "
+ "to this connection. That field is essential for Ident-based "
+ "authentication.");
found_entry = false;
}
else if (strcmp(usermap_name, "sameuser") == 0)
if (file == NULL)
{
/* The open of the map file failed. */
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "load_ident: Unable to open usermap file \"%s\": %s\n",
- map_file, strerror(errno));
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "load_ident: Unable to open usermap file \"%s\": %m",
+ map_file);
}
else
{
sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
if (sock_fd == -1)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "Failed to create socket on which to talk to Ident server. "
- "socket() returned errno = %s (%d)\n", strerror(errno), errno);
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "Failed to create socket on which to talk to Ident server: %m");
ident_return = false;
}
else
}
if (rc != 0)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "Unable to connect to Ident server on the host which is "
- "trying to connect to Postgres "
- "(IP address %s, Port %d). "
- "errno = %s (%d)\n",
- inet_ntoa(remote_ip_addr), IDENT_PORT, strerror(errno), errno);
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ /* save_errno is in case inet_ntoa changes errno */
+ int save_errno = errno;
+
+ elog(LOG, "Unable to connect to Ident server on the host which is "
+ "trying to connect to Postgres "
+ "(IP address %s, Port %d): %s",
+ inet_ntoa(remote_ip_addr), IDENT_PORT,
+ strerror(save_errno));
ident_return = false;
}
else
} while (rc < 0 && errno == EINTR);
if (rc < 0)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "Unable to send query to Ident server on the host which is "
- "trying to connect to Postgres (Host %s, Port %d),"
- "even though we successfully connected to it. "
- "errno = %s (%d)\n",
- inet_ntoa(remote_ip_addr), IDENT_PORT,
- strerror(errno), errno);
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ int save_errno = errno;
+
+ elog(LOG, "Unable to send query to Ident server on the host which is "
+ "trying to connect to Postgres (Host %s, Port %d), "
+ "even though we successfully connected to it: %s",
+ inet_ntoa(remote_ip_addr), IDENT_PORT,
+ strerror(save_errno));
ident_return = false;
}
else
sizeof(ident_response) - 1, 0);
if (rc < 0)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "Unable to receive response from Ident server "
- "on the host which is "
- "trying to connect to Postgres (Host %s, Port %d),"
- "even though we successfully sent our query to it. "
- "errno = %s (%d)\n",
- inet_ntoa(remote_ip_addr), IDENT_PORT,
- strerror(errno), errno);
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ int save_errno = errno;
+
+ elog(LOG, "Unable to receive response from Ident server "
+ "on the host which is "
+ "trying to connect to Postgres (Host %s, Port %d), "
+ "even though we successfully sent our query to it: %s",
+ inet_ntoa(remote_ip_addr), IDENT_PORT,
+ strerror(save_errno));
ident_return = false;
}
else
so_len != sizeof(peercred))
{
/* We didn't get a valid credentials struct. */
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "ident_unix: error receiving credentials: %s\n",
- strerror(errno));
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "ident_unix: error receiving credentials: %m");
return false;
}
if (pass == NULL)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "ident_unix: unknown local user with uid %d\n", peercred.uid);
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "ident_unix: unknown local user with uid %d",
+ (int) peercred.uid);
return false;
}
cmsg->cmsg_len < sizeof(cmsgmem) ||
cmsg->cmsg_type != SCM_CREDS)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "ident_unix: error receiving credentials: %s\n",
- strerror(errno));
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "ident_unix: error receiving credentials: %m");
return false;
}
pw = getpwuid(cred->cruid);
if (pw == NULL)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "ident_unix: unknown local user with uid %d\n",
- cred->cruid);
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "ident_unix: unknown local user with uid %d",
+ (int) cred->cruid);
return false;
}
return true;
#else
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "'ident' auth is not supported on local connections on this platform\n");
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "'ident' auth is not supported on local connections on this platform");
return false;
#endif
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: password.c,v 1.40 2001/10/25 05:49:30 momjian Exp $
+ * $Id: password.c,v 1.41 2002/03/04 01:46:03 tgl Exp $
*
*/
pw_file = AllocateFile(pw_file_fullname, PG_BINARY_R);
if (!pw_file)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "verify_password: Unable to open password file \"%s\": %s\n",
- pw_file_fullname, strerror(errno));
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "verify_password: Unable to open password file \"%s\": %m",
+ pw_file_fullname);
pfree(pw_file_fullname);
return STATUS_OK;
}
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "verify_password: password mismatch for '%s'.\n",
- user);
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "verify_password: password mismatch for '%s'",
+ user);
return STATUS_ERROR;
}
FreeFile(pw_file);
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "verify_password: user '%s' not found in password file.\n",
- user);
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "verify_password: user '%s' not found in password file",
+ user);
return STATUS_ERROR;
}
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqcomm.c,v 1.127 2002/03/02 21:39:26 momjian Exp $
+ * $Id: pqcomm.c,v 1.128 2002/03/04 01:46:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
if ((fd = socket(family, SOCK_STREAM, 0)) < 0)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "FATAL: StreamServerPort: socket() failed: %s\n",
- strerror(errno));
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "StreamServerPort: socket() failed: %m");
return STATUS_ERROR;
}
if ((setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one,
sizeof(one))) == -1)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "FATAL: StreamServerPort: setsockopt(SO_REUSEADDR) failed: %s\n",
- strerror(errno));
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "StreamServerPort: setsockopt(SO_REUSEADDR) failed: %m");
return STATUS_ERROR;
}
}
hp = gethostbyname(hostName);
if ((hp == NULL) || (hp->h_addrtype != AF_INET))
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "FATAL: StreamServerPort: gethostbyname(%s) failed\n",
- hostName);
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "StreamServerPort: gethostbyname(%s) failed",
+ hostName);
return STATUS_ERROR;
}
memmove((char *) &(saddr.in.sin_addr), (char *) hp->h_addr,
err = bind(fd, (struct sockaddr *) & saddr.sa, len);
if (err < 0)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "FATAL: StreamServerPort: bind() failed: %s\n"
- "\tIs another postmaster already running on port %d?\n",
- strerror(errno), (int) portNumber);
if (family == AF_UNIX)
- snprintf(PQerrormsg + strlen(PQerrormsg),
- PQERRORMSG_LENGTH - strlen(PQerrormsg),
- "\tIf not, remove socket node (%s) and retry.\n",
- sock_path);
+ elog(LOG, "StreamServerPort: bind() failed: %m\n"
+ "\tIs another postmaster already running on port %d?\n"
+ "\tIf not, remove socket node (%s) and retry.",
+ (int) portNumber, sock_path);
else
- snprintf(PQerrormsg + strlen(PQerrormsg),
- PQERRORMSG_LENGTH - strlen(PQerrormsg),
- "\tIf not, wait a few seconds and retry.\n");
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "StreamServerPort: bind() failed: %m\n"
+ "\tIs another postmaster already running on port %d?\n"
+ "\tIf not, wait a few seconds and retry.",
+ (int) portNumber);
return STATUS_ERROR;
}
gr = getgrnam(Unix_socket_group);
if (!gr)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "FATAL: no such group '%s'\n",
- Unix_socket_group);
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "No such group as '%s'",
+ Unix_socket_group);
return STATUS_ERROR;
}
gid = gr->gr_gid;
}
if (chown(sock_path, -1, gid) == -1)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "FATAL: could not set group of %s: %s\n",
- sock_path, strerror(errno));
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "Could not set group of %s: %m",
+ sock_path);
return STATUS_ERROR;
}
}
if (chmod(sock_path, Unix_socket_permissions) == -1)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "FATAL: could not set permissions on %s: %s\n",
- sock_path, strerror(errno));
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "Could not set permissions on %s: %m",
+ sock_path);
return STATUS_ERROR;
}
}
err = listen(fd, maxconn);
if (err < 0)
{
- snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "FATAL: StreamServerPort: listen() failed: %s\n",
- strerror(errno));
- fputs(PQerrormsg, stderr);
- pqdebug("%s", PQerrormsg);
+ elog(LOG, "StreamServerPort: listen() failed: %m");
return STATUS_ERROR;
}
* the Postmaster uses select() to tell when the server master
* socket is ready for accept().
*
- * NB: this can NOT call elog() because it is invoked in the postmaster,
- * not in standard backend context. If we get an error, the best we can do
- * is log it to stderr.
- *
* RETURNS: STATUS_OK or STATUS_ERROR
*/
int
* Careful: an elog() that tries to write to the client
* would cause recursion to here, leading to stack overflow
* and core dump! This message must go *only* to the postmaster
- * log. elog(LOG) is presently safe.
+ * log.
*/
- elog(LOG, "pq_recvbuf: recv() failed: %m");
+ elog(COMMERROR, "pq_recvbuf: recv() failed: %m");
return EOF;
}
if (r == 0)
{
/* as above, only write to postmaster log */
- elog(LOG, "pq_recvbuf: unexpected EOF on client connection");
+ elog(COMMERROR, "pq_recvbuf: unexpected EOF on client connection");
return EOF;
}
/* r contains number of bytes read, so just incr length */
* Careful: an elog() that tries to write to the client
* would cause recursion to here, leading to stack overflow
* and core dump! This message must go *only* to the postmaster
- * log. elog(LOG) is presently safe.
+ * log.
*
* If a client disconnects while we're in the midst of output,
* we might write quite a bit of data before we get to a safe
if (errno != last_reported_send_errno)
{
last_reported_send_errno = errno;
- elog(LOG, "pq_flush: send() failed: %m");
+ elog(COMMERROR, "pq_flush: send() failed: %m");
}
/*
if (res < 0)
{
/* can log to postmaster log only */
- elog(LOG, "pq_eof: recv() failed: %m");
+ elog(COMMERROR, "pq_eof: recv() failed: %m");
return EOF;
}
if (res == 0)
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqformat.c,v 1.19 2001/12/04 20:57:22 tgl Exp $
+ * $Id: pqformat.c,v 1.20 2002/03/04 01:46:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* if we elog(ERROR) here, we will lose sync with the
* frontend, so just complain to postmaster log instead...
*/
- fprintf(stderr, "pq_getint: unsupported size %d\n", b);
+ elog(COMMERROR, "pq_getint: unsupported size %d", b);
status = EOF;
*result = 0;
break;
+++ /dev/null
-/*-------------------------------------------------------------------------
- *
- * util.c
- * general routines for backend libpq modules
- *
- * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/util.c,v 1.18 2001/10/25 05:49:30 momjian Exp $
- *
- *-------------------------------------------------------------------------
- */
-/*
- * UTILITY ROUTINES
- * pqdebug - send a string to the debugging output port
- * PQtrace - turn on pqdebug() tracing
- * PQuntrace - turn off pqdebug() tracing
- */
-
-#include "postgres.h"
-
-#include "libpq/libpq.h"
-
-
-/* ----------------
- * global variables for backend libpq
- * ----------------
- */
-char PQerrormsg[PQERRORMSG_LENGTH];
-
-/*
- * These are not really global --- they are referred to nowhere else.
- * We declare them as global symbols to make them easier to set in a debugger.
- */
-
-int PQtracep = 0; /* 1 to print out debugging messages */
-
-FILE *debug_port = (FILE *) NULL;
-
-/* ----------------------------------------------------------------
- * PQ utility routines
- * ----------------------------------------------------------------
- */
-
-void
-pqdebug(char *fmt, char *msg)
-{
- if (!fmt)
- return;
-
- if (PQtracep)
- {
- /*
- * if nothing else was suggested default to stderr
- */
- if (!debug_port)
- debug_port = stderr;
- fprintf(debug_port, fmt, msg);
- fprintf(debug_port, "\n");
- }
-}
-
-/* --------------------------------
- * PQtrace() / PQuntrace()
- * --------------------------------
- */
-void
-PQtrace()
-{
- PQtracep = 1;
-}
-
-void
-PQuntrace()
-{
- PQtracep = 0;
-}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.269 2002/03/02 21:39:28 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.270 2002/03/04 01:46:03 tgl Exp $
*
* NOTES
*
static bool FatalError = false; /* T if recovering from backend crash */
+bool ClientAuthInProgress = false; /* T during new-client authentication */
+
/*
* State for assigning random salts and cancel keys.
* Also, the global MyCancelKey passes the cancel key assigned to a given
static void sigusr1_handler(SIGNAL_ARGS);
static void dummy_handler(SIGNAL_ARGS);
static void CleanupProc(int pid, int exitstatus);
-static void LogChildExit(const char *procname, int pid, int exitstatus);
+static void LogChildExit(int lev, const char *procname,
+ int pid, int exitstatus);
static int DoBackend(Port *port);
static void ExitPostmaster(int status);
static void usage(const char *);
/*
* Reset whereToSendOutput from Debug (its starting state) to None.
- * This prevents elog from sending messages to stderr unless the
+ * This prevents elog from sending log messages to stderr unless the
* syslog/stderr switch permits. We don't do this until the
* postmaster is fully launched, since startup failures may as well be
* reported to stderr.
#endif
if (send(port->sock, &SSLok, 1, 0) != 1)
{
- elog(LOG, "failed to send SSL negotiation response: %s",
- strerror(errno));
+ elog(LOG, "failed to send SSL negotiation response: %m");
return STATUS_ERROR; /* close the connection */
}
if (Shutdown <= SmartShutdown)
{
+ elog(LOG, "Received SIGHUP, reloading configuration files");
SignalChildren(SIGHUP);
ProcessConfigFile(PGC_SIGHUP);
load_hba_and_ident();
PG_SETMASK(&BlockSig);
- elog(DEBUG1, "reaping dead processes");
+ elog(DEBUG3, "reaping dead processes");
#ifdef HAVE_WAITPID
while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
{
*/
if (pgstat_ispgstat(pid))
{
- LogChildExit(gettext("statistics collector process"),
+ LogChildExit(LOG, gettext("statistics collector process"),
pid, exitstatus);
pgstat_start();
continue;
{
if (exitstatus != 0)
{
- LogChildExit(gettext("shutdown process"),
+ LogChildExit(LOG, gettext("shutdown process"),
pid, exitstatus);
ExitPostmaster(1);
}
{
if (exitstatus != 0)
{
- LogChildExit(gettext("startup process"),
+ LogChildExit(LOG, gettext("startup process"),
pid, exitstatus);
elog(LOG, "aborting startup due to startup process failure");
ExitPostmaster(1);
*next;
Backend *bp;
- LogChildExit(gettext("child process"), pid, exitstatus);
+ LogChildExit(DEBUG1, gettext("child process"), pid, exitstatus);
/*
* If a backend dies in an ugly way (i.e. exit status not 0) then we
/* Make log entry unless we did so already */
if (!FatalError)
{
- LogChildExit(gettext("server process"), pid, exitstatus);
+ LogChildExit(LOG, gettext("server process"), pid, exitstatus);
elog(LOG, "terminating any other active server processes");
}
* Log the death of a child process.
*/
static void
-LogChildExit(const char *procname, int pid, int exitstatus)
+LogChildExit(int lev, const char *procname, int pid, int exitstatus)
{
/*
* translator: the first %s in these messages is a noun phrase
* describing a child process, such as "server process"
*/
if (WIFEXITED(exitstatus))
- elog(LOG, "%s (pid %d) exited with exit code %d",
+ elog(lev, "%s (pid %d) exited with exit code %d",
procname, pid, WEXITSTATUS(exitstatus));
else if (WIFSIGNALED(exitstatus))
- elog(LOG, "%s (pid %d) was terminated by signal %d",
+ elog(lev, "%s (pid %d) was terminated by signal %d",
procname, pid, WTERMSIG(exitstatus));
else
- elog(LOG, "%s (pid %d) exited with unexpected status %d",
+ elog(lev, "%s (pid %d) exited with unexpected status %d",
procname, pid, exitstatus);
}
IsUnderPostmaster = true; /* we are a postmaster subprocess now */
+ ClientAuthInProgress = true; /* limit visibility of log messages */
+
/* We don't want the postmaster's proc_exit() handlers */
on_exit_reset();
*/
elog(DEBUG2, "%s child[%d]: starting with (", progname, MyProcPid);
for (i = 0; i < ac; ++i)
- elog(DEBUG2, "%s ", av[i]);
- elog(DEBUG2, ")\n");
+ elog(DEBUG2, "\t%s", av[i]);
+ elog(DEBUG2, ")");
+
+ ClientAuthInProgress = false; /* client_min_messages is active now */
return (PostgresMain(ac, av, port->user));
}
switch (xlop)
{
case BS_XLOG_STARTUP:
- elog(LOG, "could not launch startup process (fork failure): %s",
- strerror(errno));
+ elog(LOG, "could not launch startup process (fork failure): %m");
break;
case BS_XLOG_CHECKPOINT:
- elog(LOG, "could not launch checkpoint process (fork failure): %s",
- strerror(errno));
+ elog(LOG, "could not launch checkpoint process (fork failure): %m");
break;
case BS_XLOG_SHUTDOWN:
+ elog(LOG, "could not launch shutdown process (fork failure): %m");
+ break;
default:
- elog(LOG, "could not launch shutdown process (fork failure): %s",
- strerror(errno));
break;
}
return true;
}
-
+/*
+ * This should be used only for reporting "interactive" errors (ie, errors
+ * during startup. Once the postmaster is launched, use elog.
+ */
static void
postmaster_error(const char *fmt,...)
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.252 2002/03/02 21:39:31 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.253 2002/03/04 01:46:03 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
DBName = argv[optind];
else if ((DBName = username) == NULL)
{
- elog(NOTICE, "%s: user name undefined and no database specified\n",
+ elog(NOTICE, "%s: user name undefined and no database specified",
argv[0]);
proc_exit(1);
}
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.252 $ $Date: 2002/03/02 21:39:31 $\n");
+ puts("$Revision: 1.253 $ $Date: 2002/03/04 01:46:03 $\n");
}
/*
if (HandleFunctionRequest() == EOF)
{
/* lost frontend connection during F message input */
+ /*
+ * Reset whereToSendOutput to prevent elog from attempting
+ * to send any more messages to client.
+ */
+ if (whereToSendOutput == Remote)
+ whereToSendOutput = None;
+
proc_exit(0);
}
}
break;
- /* ----------------
+ /*
* 'X' means that the frontend is closing down the socket.
* EOF means unexpected loss of frontend connection.
* Either way, perform normal shutdown.
- * ----------------
*/
case 'X':
case EOF:
+ /*
+ * Reset whereToSendOutput to prevent elog from attempting
+ * to send any more messages to client.
+ */
+ if (whereToSendOutput == Remote)
+ whereToSendOutput = None;
/*
* NOTE: if you are tempted to add more code here, DON'T!
if (assert_enabled)
{
/* val != 0 should be trapped by previous Assert */
- elog(INFO, "Assert test successfull (val = %d)", val);
+ elog(INFO, "Assert test successful (val = %d)", val);
}
else
elog(INFO, "Assert checking is disabled (val = %d)", val);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.92 2002/03/02 21:39:33 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.93 2002/03/04 01:46:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "mb/pg_wchar.h"
#endif
-#define DEFAULT_SERVER_MIN_MESSAGES_STR "notice"
int server_min_messages;
char *server_min_messages_str = NULL;
-const char server_min_messages_str_default[] = DEFAULT_SERVER_MIN_MESSAGES_STR;
+const char server_min_messages_str_default[] = "notice";
-#define DEFAULT_CLIENT_MIN_MESSAGES_STR "info"
int client_min_messages;
char *client_min_messages_str = NULL;
-const char client_min_messages_str_default[] = DEFAULT_CLIENT_MIN_MESSAGES_STR;
+const char client_min_messages_str_default[] = "info";
#ifdef ENABLE_SYSLOG
/*
elog(int lev, const char *fmt,...)
{
va_list ap;
-
/*
* The expanded format and final output message are dynamically
* allocated if necessary, but not if they fit in the "reasonable
char msg_fixedbuf[256];
char *fmt_buf = fmt_fixedbuf;
char *msg_buf = msg_fixedbuf;
-
- /* for COPY line numbers */
- char copylineno_buf[32];
-
+ char copylineno_buf[32]; /* for COPY line numbers */
const char *errorstr;
const char *prefix;
const char *cp;
char *bp;
size_t space_needed;
+ size_t timestamp_size; /* prefix len for timestamp+pid */
bool output_to_server = false;
bool output_to_client = false;
- /* size of the prefix needed for timestamp and pid, if enabled */
- size_t timestamp_size;
-
/* Check for old elog calls. Codes were renumbered in 7.3. 2002-02-24 */
if (lev < DEBUG5)
elog(FATAL, "Pre-7.3 object file made an elog() call. Recompile.");
- if (Use_syslog <= 1 || whereToSendOutput == Debug)
- {
- if (lev == LOG)
- {
- if (server_min_messages == LOG)
- output_to_server = true;
- else if (server_min_messages < FATAL)
- output_to_server = true;
- }
- /* lev != LOG */
- else
- {
- if (server_min_messages == LOG)
- {
- if (lev >= FATAL)
- output_to_server = true;
- }
- /* Neither is LOG */
- else if (lev >= server_min_messages)
- output_to_server = true;
- }
- }
-
- if (lev >= client_min_messages && whereToSendOutput == Remote)
- output_to_client = true;
-
- /* optimization to prevent work for messages that would never be output */
- if (lev < ERROR && Use_syslog < 1 &&
- output_to_server == false && output_to_client == false)
- return;
-
- /* Save error str before calling any function that might change errno */
- errorstr = useful_strerror(errno);
-
/*
* Convert initialization errors into fatal errors. This is probably
* redundant, because Warn_restart_ready won't be set anyway.
* If we are inside a critical section, all errors become PANIC
* errors. See miscadmin.h.
*/
- if (lev == ERROR || lev == FATAL)
+ if (lev >= ERROR)
{
if (CritSectionCount > 0)
lev = PANIC;
}
+ /* Determine whether message is enabled for server log output */
+ /* Complicated because LOG is sorted out-of-order for this purpose */
+ if (lev == LOG || lev == COMMERROR)
+ {
+ if (server_min_messages == LOG)
+ output_to_server = true;
+ else if (server_min_messages < FATAL)
+ output_to_server = true;
+ }
+ else
+ {
+ /* lev != LOG */
+ if (server_min_messages == LOG)
+ {
+ if (lev >= FATAL)
+ output_to_server = true;
+ }
+ /* Neither is LOG */
+ else if (lev >= server_min_messages)
+ output_to_server = true;
+ }
+
+ /* Determine whether message is enabled for client output */
+ if (whereToSendOutput == Remote && lev != COMMERROR)
+ {
+ /*
+ * client_min_messages is honored only after we complete the
+ * authentication handshake. This is required both for security
+ * reasons and because many clients can't handle NOTICE messages
+ * during authentication.
+ */
+ if (ClientAuthInProgress)
+ output_to_client = (lev >= ERROR);
+ else
+ output_to_client = (lev >= client_min_messages);
+ }
+
+ /* Skip formatting effort if non-error message will not be output */
+ if (lev < ERROR && !output_to_server && !output_to_client)
+ return;
+
+ /* Save error str before calling any function that might change errno */
+ errorstr = useful_strerror(errno);
+
+ /* Internationalize the error format string */
+ fmt = gettext(fmt);
+
+ /* Begin formatting by determining prefix information */
prefix = elog_message_prefix(lev);
timestamp_size = 0;
if (Log_pid)
timestamp_size += PID_SIZE;
- fmt = gettext(fmt);
-
/*
* Set up the expanded format, consisting of the prefix string plus
* input format, with any %m replaced by strerror() string (since
{
/*
* Prints the failure line of the COPY. Wow, what a hack! bjm
- * Translators: Error message will be truncated at 31 characters.
+ * Translator: Error message will be truncated at 31 characters.
*/
snprintf(copylineno_buf, 32, gettext("copy: line %d, "), copy_lineno);
space_needed += strlen(copylineno_buf);
{
/* We're up against it, convert to out-of-memory error */
fmt_buf = fmt_fixedbuf;
- if (lev != FATAL && lev != PANIC)
+ if (lev < ERROR)
{
lev = ERROR;
prefix = elog_message_prefix(lev);
if (copy_lineno)
{
strcat(fmt_buf, copylineno_buf);
- if (lev == ERROR || lev == FATAL || lev == PANIC)
+ if (lev >= ERROR)
copy_lineno = 0;
}
{
/* We're up against it, convert to out-of-memory error */
msg_buf = msg_fixedbuf;
- if (lev != FATAL && lev != PANIC)
+ if (lev < ERROR)
{
lev = ERROR;
prefix = elog_message_prefix(lev);
#ifdef ENABLE_SYSLOG
/* Write to syslog, if enabled */
- if (Use_syslog >= 1)
+ if (output_to_server && Use_syslog >= 1)
{
int syslog_level;
syslog_level = LOG_DEBUG;
break;
case LOG:
+ case COMMERROR:
case INFO:
syslog_level = LOG_INFO;
break;
/* syslog doesn't want a trailing newline, but other destinations do */
strcat(msg_buf, "\n");
- /* Write to server logs or server terminal */
- if (output_to_server)
+ /* Write to stderr, if enabled */
+ if (output_to_server && (Use_syslog <= 1 || whereToSendOutput == Debug))
write(2, msg_buf, strlen(msg_buf));
- /* Should we output to the client too? */
+ /* Send to client, if enabled */
if (output_to_client)
{
/* Send IPC message to the front-end program */
/* Prevent immediate interrupt while entering error recovery */
ImmediateInterruptOK = false;
+ /*
+ * If we just reported a startup failure, the client will
+ * disconnect on receiving it, so don't send any more to the client.
+ */
+ if (!Warn_restart_ready && whereToSendOutput == Remote)
+ whereToSendOutput = None;
+
/*
* For a FATAL error, we let proc_exit clean up and exit.
*
siglongjmp(Warn_restart, 1);
}
- if (lev == FATAL || lev == PANIC)
+ if (lev == PANIC)
{
/*
* Serious crash time. Postmaster will observe nonzero process
ImmediateInterruptOK = false;
fflush(stdout);
fflush(stderr);
- proc_exit(lev);
+ proc_exit(2);
}
/* We reach here if lev <= NOTICE. OK to return to caller. */
* translator: This string will be truncated at 47 characters
* expanded.
*/
- snprintf(errorstr_buf, 48, gettext("operating system error %d"), errnum);
+ snprintf(errorstr_buf, 48, gettext("operating system error %d"),
+ errnum);
str = errorstr_buf;
}
prefix = gettext("DEBUG: ");
break;
case LOG:
+ case COMMERROR:
prefix = gettext("LOG: ");
break;
case INFO:
if (strcasecmp(lev, "debug") == 0 ||
strcasecmp(lev, "debug1") == 0 ||
strcasecmp(lev, "debug2") == 0 ||
- strcasecmp(lev, "debub3") == 0 ||
+ strcasecmp(lev, "debug3") == 0 ||
strcasecmp(lev, "debug4") == 0 ||
strcasecmp(lev, "debug5") == 0 ||
strcasecmp(lev, "log") == 0 ||
void
assign_server_min_messages(const char *lev)
{
- if (strcasecmp(lev, "debug1") == 0)
+ if (strcasecmp(lev, "debug") == 0)
+ server_min_messages = DEBUG1;
+ else if (strcasecmp(lev, "debug1") == 0)
server_min_messages = DEBUG1;
else if (strcasecmp(lev, "debug2") == 0)
server_min_messages = DEBUG2;
void
assign_client_min_messages(const char *lev)
{
- if (strcasecmp(lev, "debug1") == 0)
+ if (strcasecmp(lev, "debug") == 0)
+ client_min_messages = DEBUG1;
+ else if (strcasecmp(lev, "debug1") == 0)
client_min_messages = DEBUG1;
else if (strcasecmp(lev, "debug2") == 0)
client_min_messages = DEBUG2;
/* Can't get here unless guc.c screwed up */
elog(ERROR, "bogus client_min_messages %s", lev);
}
-
-
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpq.h,v 1.49 2001/12/04 19:40:17 tgl Exp $
+ * $Id: libpq.h,v 1.50 2002/03/04 01:46:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
} u;
} PQArgBlock;
-/*
- * PQerrormsg[] is used only for error messages generated within backend
- * libpq, none of which are remarkably long. Note that this length should
- * NOT be taken as any indication of the maximum error message length that
- * the backend can create! elog() can in fact produce extremely long messages.
- */
-
-#define PQERRORMSG_LENGTH 1024
-
-extern char PQerrormsg[PQERRORMSG_LENGTH]; /* in libpq/util.c */
-
/*
* External functions.
*/
extern void pq_startcopyout(void);
extern void pq_endcopyout(bool errorAbort);
-/*
- * prototypes for functions in util.c
- */
-extern void pqdebug(char *fmt, char *msg);
-extern void PQtrace(void);
-extern void PQuntrace(void);
-
#endif /* LIBPQ_H */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: miscadmin.h,v 1.100 2002/03/02 21:39:34 momjian Exp $
+ * $Id: miscadmin.h,v 1.101 2002/03/04 01:46:04 tgl Exp $
*
* NOTES
* some of the information in this file should be moved to
/*
* from postmaster/postmaster.c
*/
+extern bool IsUnderPostmaster;
+extern bool ClientAuthInProgress;
+
extern int PostmasterMain(int argc, char *argv[]);
extern void ClosePostmasterPorts(bool pgstat_too);
*/
extern DLLIMPORT Oid MyDatabaseId;
-extern bool IsUnderPostmaster;
-
/* Date/Time Configuration
*
* Constants to pass info from runtime environment:
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: elog.h,v 1.31 2002/03/02 21:39:35 momjian Exp $
+ * $Id: elog.h,v 1.32 2002/03/04 01:46:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#define ELOG_H
/* Error level codes */
-#define DEBUG5 10 /* sent only to server logs, label DEBUG */
-#define DEBUG4 11 /* logs in decreasing detail */
+#define DEBUG5 10 /* Debugging messages, in categories
+ * of decreasing detail. */
+#define DEBUG4 11
#define DEBUG3 12
#define DEBUG2 13
#define DEBUG1 14
-#define LOG 15 /* sent only to server logs by default,
- * label LOG. */
-#define INFO 16 /* sent only to client by default, for
- * informative messages that are part of
- * normal query operation. */
-#define NOTICE 17 /* sent to client and server by default,
- * important messages, for unusual cases that
+#define LOG 15 /* Server operational history messages;
+ * sent only to server log by default. */
+#define COMMERROR 16 /* Client communication problems; same as
+ * LOG for server reporting, but never ever
+ * try to send to client. */
+#define INFO 17 /* Informative messages that are part of
+ * normal query operation; sent only to
+ * client by default. */
+#define NOTICE 18 /* Important messages, for unusual cases that
* should be reported but are not serious
- * enough to abort the query. */
-#define ERROR 18 /* user error - return to known state */
-#define FATAL 19 /* fatal error - abort process */
-#define PANIC 20 /* take down the other backends with me */
+ * enough to abort the query. Sent to client
+ * and server log by default. */
+#define ERROR 19 /* user error - return to known state */
+#define FATAL 20 /* fatal error - abort process */
+#define PANIC 21 /* take down the other backends with me */
-/*#define DEBUG DEBUG5*/ /* Backward compatibility with pre-7.3 */
+/*#define DEBUG DEBUG1*/ /* Backward compatibility with pre-7.3 */
/* Configurable parameters */
#ifdef ENABLE_SYSLOG