Commit 12c15520 authored by Peter Eisentraut's avatar Peter Eisentraut

Mark many strings in backend not covered by elog for translation. Also,

make strings in xlog.c look more like English and less like binary noise.
parent 277a47ad
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, 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/access/transam/xlog.c,v 1.67 2001/05/30 14:15:25 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.68 2001/06/03 14:53:56 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -411,7 +411,7 @@ static void MoveOfflineLogs(uint32 log, uint32 seg); ...@@ -411,7 +411,7 @@ static void MoveOfflineLogs(uint32 log, uint32 seg);
static XLogRecord *ReadRecord(XLogRecPtr *RecPtr, int emode, char *buffer); static XLogRecord *ReadRecord(XLogRecPtr *RecPtr, int emode, char *buffer);
static bool ValidXLOGHeader(XLogPageHeader hdr, int emode, bool checkSUI); static bool ValidXLOGHeader(XLogPageHeader hdr, int emode, bool checkSUI);
static XLogRecord *ReadCheckpointRecord(XLogRecPtr RecPtr, static XLogRecord *ReadCheckpointRecord(XLogRecPtr RecPtr,
const char *whichChkpt, int whichChkpt,
char *buffer); char *buffer);
static void WriteControlFile(void); static void WriteControlFile(void);
static void ReadControlFile(void); static void ReadControlFile(void);
...@@ -585,7 +585,7 @@ begin:; ...@@ -585,7 +585,7 @@ begin:;
* also remove the check for xl_len == 0 in ReadRecord, below. * also remove the check for xl_len == 0 in ReadRecord, below.
*/ */
if (len == 0 || len > MAXLOGRECSZ) if (len == 0 || len > MAXLOGRECSZ)
elog(STOP, "XLogInsert: invalid record len %u", len); elog(STOP, "XLogInsert: invalid record length %u", len);
START_CRIT_SECTION(); START_CRIT_SECTION();
...@@ -749,7 +749,7 @@ begin:; ...@@ -749,7 +749,7 @@ begin:;
strcat(buf, " - "); strcat(buf, " - ");
RmgrTable[record->xl_rmid].rm_desc(buf, record->xl_info, rdata->data); RmgrTable[record->xl_rmid].rm_desc(buf, record->xl_info, rdata->data);
} }
fprintf(stderr, "%s\n", buf); elog(DEBUG, "%s", buf);
} }
/* Record begin of record in appropriate places */ /* Record begin of record in appropriate places */
...@@ -1004,7 +1004,7 @@ XLogWrite(XLogwrtRqst WriteRqst) ...@@ -1004,7 +1004,7 @@ XLogWrite(XLogwrtRqst WriteRqst)
if (openLogFile >= 0) if (openLogFile >= 0)
{ {
if (close(openLogFile) != 0) if (close(openLogFile) != 0)
elog(STOP, "close(logfile %u seg %u) failed: %m", elog(STOP, "close of log file %u, segment %u failed: %m",
openLogId, openLogSeg); openLogId, openLogSeg);
openLogFile = -1; openLogFile = -1;
} }
...@@ -1043,7 +1043,7 @@ XLogWrite(XLogwrtRqst WriteRqst) ...@@ -1043,7 +1043,7 @@ XLogWrite(XLogwrtRqst WriteRqst)
(uint32) CheckPointSegments)) (uint32) CheckPointSegments))
{ {
if (XLOG_DEBUG) if (XLOG_DEBUG)
fprintf(stderr, "XLogWrite: time for a checkpoint, signaling postmaster\n"); elog(DEBUG, "XLogWrite: time for a checkpoint, signaling postmaster");
kill(getppid(), SIGUSR1); kill(getppid(), SIGUSR1);
} }
} }
...@@ -1062,14 +1062,14 @@ XLogWrite(XLogwrtRqst WriteRqst) ...@@ -1062,14 +1062,14 @@ XLogWrite(XLogwrtRqst WriteRqst)
{ {
openLogOff = (LogwrtResult.Write.xrecoff - BLCKSZ) % XLogSegSize; openLogOff = (LogwrtResult.Write.xrecoff - BLCKSZ) % XLogSegSize;
if (lseek(openLogFile, (off_t) openLogOff, SEEK_SET) < 0) if (lseek(openLogFile, (off_t) openLogOff, SEEK_SET) < 0)
elog(STOP, "lseek(logfile %u seg %u off %u) failed: %m", elog(STOP, "lseek of log file %u, segment %u, offset %u failed: %m",
openLogId, openLogSeg, openLogOff); openLogId, openLogSeg, openLogOff);
} }
/* OK to write the page */ /* OK to write the page */
from = XLogCtl->pages + Write->curridx * BLCKSZ; from = XLogCtl->pages + Write->curridx * BLCKSZ;
if (write(openLogFile, from, BLCKSZ) != BLCKSZ) if (write(openLogFile, from, BLCKSZ) != BLCKSZ)
elog(STOP, "write(logfile %u seg %u off %u) failed: %m", elog(STOP, "write of log file %u, segment %u, offset %u failed: %m",
openLogId, openLogSeg, openLogOff); openLogId, openLogSeg, openLogOff);
openLogOff += BLCKSZ; openLogOff += BLCKSZ;
...@@ -1113,7 +1113,7 @@ XLogWrite(XLogwrtRqst WriteRqst) ...@@ -1113,7 +1113,7 @@ XLogWrite(XLogwrtRqst WriteRqst)
!XLByteInPrevSeg(LogwrtResult.Write, openLogId, openLogSeg)) !XLByteInPrevSeg(LogwrtResult.Write, openLogId, openLogSeg))
{ {
if (close(openLogFile) != 0) if (close(openLogFile) != 0)
elog(STOP, "close(logfile %u seg %u) failed: %m", elog(STOP, "close of log file %u, segment %u failed: %m",
openLogId, openLogSeg); openLogId, openLogSeg);
openLogFile = -1; openLogFile = -1;
} }
...@@ -1161,7 +1161,7 @@ XLogFlush(XLogRecPtr record) ...@@ -1161,7 +1161,7 @@ XLogFlush(XLogRecPtr record)
if (XLOG_DEBUG) if (XLOG_DEBUG)
{ {
fprintf(stderr, "XLogFlush%s%s: rqst %u/%u; wrt %u/%u; flsh %u/%u\n", elog(DEBUG, "XLogFlush%s%s: request %u/%u; write %u/%u; flush %u/%u\n",
(IsBootstrapProcessingMode()) ? "(bootstrap)" : "", (IsBootstrapProcessingMode()) ? "(bootstrap)" : "",
(InRedo) ? "(redo)" : "", (InRedo) ? "(redo)" : "",
record.xlogid, record.xrecoff, record.xlogid, record.xrecoff,
...@@ -1287,8 +1287,8 @@ XLogFileInit(uint32 log, uint32 seg, ...@@ -1287,8 +1287,8 @@ XLogFileInit(uint32 log, uint32 seg,
if (fd < 0) if (fd < 0)
{ {
if (errno != ENOENT) if (errno != ENOENT)
elog(STOP, "InitOpen(logfile %u seg %u) failed: %m", elog(STOP, "open of %s (log file %u, segment %u) failed: %m",
log, seg); path, log, seg);
} }
else else
return (fd); return (fd);
...@@ -1309,7 +1309,7 @@ XLogFileInit(uint32 log, uint32 seg, ...@@ -1309,7 +1309,7 @@ XLogFileInit(uint32 log, uint32 seg,
fd = BasicOpenFile(tmppath, O_RDWR | O_CREAT | O_EXCL | PG_BINARY, fd = BasicOpenFile(tmppath, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
S_IRUSR | S_IWUSR); S_IRUSR | S_IWUSR);
if (fd < 0) if (fd < 0)
elog(STOP, "InitCreate(%s) failed: %m", tmppath); elog(STOP, "creation of file %s failed: %m", tmppath);
/* /*
* Zero-fill the file. We have to do this the hard way to ensure that * Zero-fill the file. We have to do this the hard way to ensure that
...@@ -1339,7 +1339,7 @@ XLogFileInit(uint32 log, uint32 seg, ...@@ -1339,7 +1339,7 @@ XLogFileInit(uint32 log, uint32 seg,
} }
if (pg_fsync(fd) != 0) if (pg_fsync(fd) != 0)
elog(STOP, "fsync(%s) failed: %m", tmppath); elog(STOP, "fsync of file %s failed: %m", tmppath);
close(fd); close(fd);
...@@ -1380,13 +1380,13 @@ XLogFileInit(uint32 log, uint32 seg, ...@@ -1380,13 +1380,13 @@ XLogFileInit(uint32 log, uint32 seg,
*/ */
#ifndef __BEOS__ #ifndef __BEOS__
if (link(tmppath, targpath) < 0) if (link(tmppath, targpath) < 0)
elog(STOP, "InitRelink(logfile %u seg %u) failed: %m", elog(STOP, "link from %s to %s (initialization of log file %u, segment %u) failed: %m",
targlog, targseg); tmppath, targpath, targlog, targseg);
unlink(tmppath); unlink(tmppath);
#else #else
if (rename(tmppath, targpath) < 0) if (rename(tmppath, targpath) < 0)
elog(STOP, "InitRelink(logfile %u seg %u) failed: %m", elog(STOP, "rename from %s to %s (initialization of log file %u, segment %u) failed: %m",
targlog, targseg); tmppath, targpath targlog, targseg);
#endif #endif
if (use_lock) if (use_lock)
...@@ -1399,8 +1399,8 @@ XLogFileInit(uint32 log, uint32 seg, ...@@ -1399,8 +1399,8 @@ XLogFileInit(uint32 log, uint32 seg,
fd = BasicOpenFile(path, O_RDWR | PG_BINARY | XLOG_SYNC_BIT, fd = BasicOpenFile(path, O_RDWR | PG_BINARY | XLOG_SYNC_BIT,
S_IRUSR | S_IWUSR); S_IRUSR | S_IWUSR);
if (fd < 0) if (fd < 0)
elog(STOP, "InitReopen(logfile %u seg %u) failed: %m", elog(STOP, "open of %s (log file %u, segment %u) failed: %m",
log, seg); path, log, seg);
return (fd); return (fd);
} }
...@@ -1422,12 +1422,12 @@ XLogFileOpen(uint32 log, uint32 seg, bool econt) ...@@ -1422,12 +1422,12 @@ XLogFileOpen(uint32 log, uint32 seg, bool econt)
{ {
if (econt && errno == ENOENT) if (econt && errno == ENOENT)
{ {
elog(LOG, "open(logfile %u seg %u) failed: %m", elog(LOG, "open of %s (log file %u, segment %u) failed: %m",
log, seg); path, log, seg);
return (fd); return (fd);
} }
elog(STOP, "open(logfile %u seg %u) failed: %m", elog(STOP, "open of %s (log file %u, segment %u) failed: %m",
log, seg); path, log, seg);
} }
return (fd); return (fd);
...@@ -1478,11 +1478,11 @@ MoveOfflineLogs(uint32 log, uint32 seg) ...@@ -1478,11 +1478,11 @@ MoveOfflineLogs(uint32 log, uint32 seg)
char lastoff[32]; char lastoff[32];
char path[MAXPGPATH]; char path[MAXPGPATH];
Assert(XLOG_archive_dir[0] == 0); /* ! implemented yet */ Assert(XLOG_archive_dir[0] == 0); /* not implemented yet */
xldir = opendir(XLogDir); xldir = opendir(XLogDir);
if (xldir == NULL) if (xldir == NULL)
elog(STOP, "MoveOfflineLogs: cannot open xlog dir: %m"); elog(STOP, "could not open transaction log directory (%s): %m", XLogDir);
sprintf(lastoff, "%08X%08X", log, seg); sprintf(lastoff, "%08X%08X", log, seg);
...@@ -1493,8 +1493,11 @@ MoveOfflineLogs(uint32 log, uint32 seg) ...@@ -1493,8 +1493,11 @@ MoveOfflineLogs(uint32 log, uint32 seg)
strspn(xlde->d_name, "0123456789ABCDEF") == 16 && strspn(xlde->d_name, "0123456789ABCDEF") == 16 &&
strcmp(xlde->d_name, lastoff) <= 0) strcmp(xlde->d_name, lastoff) <= 0)
{ {
elog(LOG, "MoveOfflineLogs: %s %s", (XLOG_archive_dir[0]) ? if (XLOG_archive_dir[0])
"archive" : "remove", xlde->d_name); elog(LOG, "archiving transaction log file %s", xlde->d_name);
else
elog(LOG, "removing transaction log file %s", xlde->d_name);
sprintf(path, "%s/%s", XLogDir, xlde->d_name); sprintf(path, "%s/%s", XLogDir, xlde->d_name);
if (XLOG_archive_dir[0] == 0) if (XLOG_archive_dir[0] == 0)
unlink(path); unlink(path);
...@@ -1502,7 +1505,7 @@ MoveOfflineLogs(uint32 log, uint32 seg) ...@@ -1502,7 +1505,7 @@ MoveOfflineLogs(uint32 log, uint32 seg)
errno = 0; errno = 0;
} }
if (errno) if (errno)
elog(STOP, "MoveOfflineLogs: cannot read xlog dir: %m"); elog(STOP, "could not read transaction log directory (%s): %m", XLogDir);
closedir(xldir); closedir(xldir);
} }
...@@ -1574,7 +1577,7 @@ RecordIsValid(XLogRecord *record, XLogRecPtr recptr, int emode) ...@@ -1574,7 +1577,7 @@ RecordIsValid(XLogRecord *record, XLogRecPtr recptr, int emode)
if (!EQ_CRC64(record->xl_crc, crc)) if (!EQ_CRC64(record->xl_crc, crc))
{ {
elog(emode, "ReadRecord: bad rmgr data CRC in record at %u/%u", elog(emode, "ReadRecord: bad resource manager data checksum in record at %u/%u",
recptr.xlogid, recptr.xrecoff); recptr.xlogid, recptr.xrecoff);
return (false); return (false);
} }
...@@ -1596,7 +1599,7 @@ RecordIsValid(XLogRecord *record, XLogRecPtr recptr, int emode) ...@@ -1596,7 +1599,7 @@ RecordIsValid(XLogRecord *record, XLogRecPtr recptr, int emode)
if (!EQ_CRC64(cbuf, crc)) if (!EQ_CRC64(cbuf, crc))
{ {
elog(emode, "ReadRecord: bad bkp block %d CRC in record at %u/%u", elog(emode, "ReadRecord: bad checksum of backup block %d in record at %u/%u",
i + 1, recptr.xlogid, recptr.xrecoff); i + 1, recptr.xlogid, recptr.xrecoff);
return (false); return (false);
} }
...@@ -1689,13 +1692,13 @@ ReadRecord(XLogRecPtr *RecPtr, int emode, char *buffer) ...@@ -1689,13 +1692,13 @@ ReadRecord(XLogRecPtr *RecPtr, int emode, char *buffer)
readOff = targetPageOff; readOff = targetPageOff;
if (lseek(readFile, (off_t) readOff, SEEK_SET) < 0) if (lseek(readFile, (off_t) readOff, SEEK_SET) < 0)
{ {
elog(emode, "ReadRecord: lseek(logfile %u seg %u off %u) failed: %m", elog(emode, "ReadRecord: lseek of log file %u, segment %u, offset %u failed: %m",
readId, readSeg, readOff); readId, readSeg, readOff);
goto next_record_is_invalid; goto next_record_is_invalid;
} }
if (read(readFile, readBuf, BLCKSZ) != BLCKSZ) if (read(readFile, readBuf, BLCKSZ) != BLCKSZ)
{ {
elog(emode, "ReadRecord: read(logfile %u seg %u off %u) failed: %m", elog(emode, "ReadRecord: read of log file %u, segment %u, offset %u failed: %m",
readId, readSeg, readOff); readId, readSeg, readOff);
goto next_record_is_invalid; goto next_record_is_invalid;
} }
...@@ -1719,7 +1722,7 @@ got_record:; ...@@ -1719,7 +1722,7 @@ got_record:;
*/ */
if (record->xl_len == 0) if (record->xl_len == 0)
{ {
elog(emode, "ReadRecord: record with zero len at (%u, %u)", elog(emode, "ReadRecord: record with zero length at (%u, %u)",
RecPtr->xlogid, RecPtr->xrecoff); RecPtr->xlogid, RecPtr->xrecoff);
goto next_record_is_invalid; goto next_record_is_invalid;
} }
...@@ -1743,7 +1746,7 @@ got_record:; ...@@ -1743,7 +1746,7 @@ got_record:;
*/ */
if (total_len > _INTL_MAXLOGRECSZ) if (total_len > _INTL_MAXLOGRECSZ)
{ {
elog(emode, "ReadRecord: too long record len %u at (%u, %u)", elog(emode, "ReadRecord: record length %u at (%u, %u) too long",
total_len, RecPtr->xlogid, RecPtr->xrecoff); total_len, RecPtr->xlogid, RecPtr->xrecoff);
goto next_record_is_invalid; goto next_record_is_invalid;
} }
...@@ -1779,7 +1782,7 @@ got_record:; ...@@ -1779,7 +1782,7 @@ got_record:;
} }
if (read(readFile, readBuf, BLCKSZ) != BLCKSZ) if (read(readFile, readBuf, BLCKSZ) != BLCKSZ)
{ {
elog(emode, "ReadRecord: read(logfile %u seg %u off %u) failed: %m", elog(emode, "ReadRecord: read of log file %u, segment %u, offset %u failed: %m",
readId, readSeg, readOff); readId, readSeg, readOff);
goto next_record_is_invalid; goto next_record_is_invalid;
} }
...@@ -1787,7 +1790,7 @@ got_record:; ...@@ -1787,7 +1790,7 @@ got_record:;
goto next_record_is_invalid; goto next_record_is_invalid;
if (!(((XLogPageHeader) readBuf)->xlp_info & XLP_FIRST_IS_CONTRECORD)) if (!(((XLogPageHeader) readBuf)->xlp_info & XLP_FIRST_IS_CONTRECORD))
{ {
elog(emode, "ReadRecord: there is no ContRecord flag in logfile %u seg %u off %u", elog(emode, "ReadRecord: there is no ContRecord flag in log file %u, segment %u, offset %u",
readId, readSeg, readOff); readId, readSeg, readOff);
goto next_record_is_invalid; goto next_record_is_invalid;
} }
...@@ -1795,7 +1798,7 @@ got_record:; ...@@ -1795,7 +1798,7 @@ got_record:;
if (contrecord->xl_rem_len == 0 || if (contrecord->xl_rem_len == 0 ||
total_len != (contrecord->xl_rem_len + gotlen)) total_len != (contrecord->xl_rem_len + gotlen))
{ {
elog(emode, "ReadRecord: invalid cont-record len %u in logfile %u seg %u off %u", elog(emode, "ReadRecord: invalid ContRecord length %u in log file %u, segment %u, offset %u",
contrecord->xl_rem_len, readId, readSeg, readOff); contrecord->xl_rem_len, readId, readSeg, readOff);
goto next_record_is_invalid; goto next_record_is_invalid;
} }
...@@ -1857,13 +1860,13 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode, bool checkSUI) ...@@ -1857,13 +1860,13 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode, bool checkSUI)
{ {
if (hdr->xlp_magic != XLOG_PAGE_MAGIC) if (hdr->xlp_magic != XLOG_PAGE_MAGIC)
{ {
elog(emode, "ReadRecord: invalid magic number %04X in logfile %u seg %u off %u", elog(emode, "ReadRecord: invalid magic number %04X in log file %u, segment %u, offset %u",
hdr->xlp_magic, readId, readSeg, readOff); hdr->xlp_magic, readId, readSeg, readOff);
return false; return false;
} }
if ((hdr->xlp_info & ~XLP_ALL_FLAGS) != 0) if ((hdr->xlp_info & ~XLP_ALL_FLAGS) != 0)
{ {
elog(emode, "ReadRecord: invalid info bits %04X in logfile %u seg %u off %u", elog(emode, "ReadRecord: invalid info bits %04X in log file %u, segment %u, offset %u",
hdr->xlp_info, readId, readSeg, readOff); hdr->xlp_info, readId, readSeg, readOff);
return false; return false;
} }
...@@ -1883,7 +1886,8 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode, bool checkSUI) ...@@ -1883,7 +1886,8 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode, bool checkSUI)
if (hdr->xlp_sui < lastReadSUI || if (hdr->xlp_sui < lastReadSUI ||
hdr->xlp_sui > lastReadSUI + 512) hdr->xlp_sui > lastReadSUI + 512)
{ {
elog(emode, "ReadRecord: out-of-sequence SUI %u (after %u) in logfile %u seg %u off %u", /* translator: SUI = startup id */
elog(emode, "ReadRecord: out-of-sequence SUI %u (after %u) in log file %u, segment %u, offset %u",
hdr->xlp_sui, lastReadSUI, readId, readSeg, readOff); hdr->xlp_sui, lastReadSUI, readId, readSeg, readOff);
return false; return false;
} }
...@@ -1936,11 +1940,11 @@ WriteControlFile(void) ...@@ -1936,11 +1940,11 @@ WriteControlFile(void)
#ifdef USE_LOCALE #ifdef USE_LOCALE
localeptr = setlocale(LC_COLLATE, NULL); localeptr = setlocale(LC_COLLATE, NULL);
if (!localeptr) if (!localeptr)
elog(STOP, "Invalid LC_COLLATE setting"); elog(STOP, "invalid LC_COLLATE setting");
StrNCpy(ControlFile->lc_collate, localeptr, LOCALE_NAME_BUFLEN); StrNCpy(ControlFile->lc_collate, localeptr, LOCALE_NAME_BUFLEN);
localeptr = setlocale(LC_CTYPE, NULL); localeptr = setlocale(LC_CTYPE, NULL);
if (!localeptr) if (!localeptr)
elog(STOP, "Invalid LC_CTYPE setting"); elog(STOP, "invalid LC_CTYPE setting");
StrNCpy(ControlFile->lc_ctype, localeptr, LOCALE_NAME_BUFLEN); StrNCpy(ControlFile->lc_ctype, localeptr, LOCALE_NAME_BUFLEN);
/* /*
...@@ -1955,10 +1959,10 @@ WriteControlFile(void) ...@@ -1955,10 +1959,10 @@ WriteControlFile(void)
"\n\tsuch queries, you may wish to set LC_COLLATE to \"C\" and" "\n\tsuch queries, you may wish to set LC_COLLATE to \"C\" and"
"\n\tre-initdb. For more information see the Administrator's Guide.", "\n\tre-initdb. For more information see the Administrator's Guide.",
ControlFile->lc_collate); ControlFile->lc_collate);
#else #else /* not USE_LOCALE */
strcpy(ControlFile->lc_collate, "C"); strcpy(ControlFile->lc_collate, "C");
strcpy(ControlFile->lc_ctype, "C"); strcpy(ControlFile->lc_ctype, "C");
#endif #endif /* not USE_LOCALE */
/* Contents are protected with a CRC */ /* Contents are protected with a CRC */
INIT_CRC64(ControlFile->crc); INIT_CRC64(ControlFile->crc);
...@@ -1975,7 +1979,7 @@ WriteControlFile(void) ...@@ -1975,7 +1979,7 @@ WriteControlFile(void)
* specific error than "couldn't read pg_control". * specific error than "couldn't read pg_control".
*/ */
if (sizeof(ControlFileData) > BLCKSZ) if (sizeof(ControlFileData) > BLCKSZ)
elog(STOP, "sizeof(ControlFileData) is too large ... fix xlog.c"); elog(STOP, "sizeof(ControlFileData) is larger than BLCKSZ; fix either one");
memset(buffer, 0, BLCKSZ); memset(buffer, 0, BLCKSZ);
memcpy(buffer, ControlFile, sizeof(ControlFileData)); memcpy(buffer, ControlFile, sizeof(ControlFileData));
...@@ -1983,14 +1987,14 @@ WriteControlFile(void) ...@@ -1983,14 +1987,14 @@ WriteControlFile(void)
fd = BasicOpenFile(ControlFilePath, O_RDWR | O_CREAT | O_EXCL | PG_BINARY, fd = BasicOpenFile(ControlFilePath, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
S_IRUSR | S_IWUSR); S_IRUSR | S_IWUSR);
if (fd < 0) if (fd < 0)
elog(STOP, "WriteControlFile failed to create control file (%s): %m", elog(STOP, "WriteControlFile: could not create control file (%s): %m",
ControlFilePath); ControlFilePath);
if (write(fd, buffer, BLCKSZ) != BLCKSZ) if (write(fd, buffer, BLCKSZ) != BLCKSZ)
elog(STOP, "WriteControlFile failed to write control file: %m"); elog(STOP, "WriteControlFile: write to control file failed: %m");
if (pg_fsync(fd) != 0) if (pg_fsync(fd) != 0)
elog(STOP, "WriteControlFile failed to fsync control file: %m"); elog(STOP, "WriteControlFile: fsync of control file failed: %m");
close(fd); close(fd);
} }
...@@ -2006,10 +2010,10 @@ ReadControlFile(void) ...@@ -2006,10 +2010,10 @@ ReadControlFile(void)
*/ */
fd = BasicOpenFile(ControlFilePath, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR); fd = BasicOpenFile(ControlFilePath, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR);
if (fd < 0) if (fd < 0)
elog(STOP, "open(\"%s\") failed: %m", ControlFilePath); elog(STOP, "could not open control file (%s): %m", ControlFilePath);
if (read(fd, ControlFile, sizeof(ControlFileData)) != sizeof(ControlFileData)) if (read(fd, ControlFile, sizeof(ControlFileData)) != sizeof(ControlFileData))
elog(STOP, "read(\"%s\") failed: %m", ControlFilePath); elog(STOP, "read from control file failed: %m");
close(fd); close(fd);
...@@ -2020,7 +2024,10 @@ ReadControlFile(void) ...@@ -2020,7 +2024,10 @@ ReadControlFile(void)
* more enlightening than complaining about wrong CRC. * more enlightening than complaining about wrong CRC.
*/ */
if (ControlFile->pg_control_version != PG_CONTROL_VERSION) if (ControlFile->pg_control_version != PG_CONTROL_VERSION)
elog(STOP, "database was initialized with PG_CONTROL_VERSION %d,\n\tbut the backend was compiled with PG_CONTROL_VERSION %d.\n\tlooks like you need to initdb.", elog(STOP,
"The database cluster was initialized with PG_CONTROL_VERSION %d,\n"
"\tbut the server was compiled with PG_CONTROL_VERSION %d.\n"
"\tIt looks like you need to initdb.",
ControlFile->pg_control_version, PG_CONTROL_VERSION); ControlFile->pg_control_version, PG_CONTROL_VERSION);
/* Now check the CRC. */ /* Now check the CRC. */
...@@ -2031,7 +2038,7 @@ ReadControlFile(void) ...@@ -2031,7 +2038,7 @@ ReadControlFile(void)
FIN_CRC64(crc); FIN_CRC64(crc);
if (!EQ_CRC64(crc, ControlFile->crc)) if (!EQ_CRC64(crc, ControlFile->crc))
elog(STOP, "Invalid CRC in control file"); elog(STOP, "invalid checksum in control file");
/* /*
* Do compatibility checking immediately. We do this here for 2 * Do compatibility checking immediately. We do this here for 2
...@@ -2046,27 +2053,45 @@ ReadControlFile(void) ...@@ -2046,27 +2053,45 @@ ReadControlFile(void)
* compatibility items because they can affect sort order of indexes.) * compatibility items because they can affect sort order of indexes.)
*/ */
if (ControlFile->catalog_version_no != CATALOG_VERSION_NO) if (ControlFile->catalog_version_no != CATALOG_VERSION_NO)
elog(STOP, "database was initialized with CATALOG_VERSION_NO %d,\n\tbut the backend was compiled with CATALOG_VERSION_NO %d.\n\tlooks like you need to initdb.", elog(STOP,
"The database cluster was initialized with CATALOG_VERSION_NO %d,\n"
"\tbut the backend was compiled with CATALOG_VERSION_NO %d.\n"
"\tIt looks like you need to initdb.",
ControlFile->catalog_version_no, CATALOG_VERSION_NO); ControlFile->catalog_version_no, CATALOG_VERSION_NO);
if (ControlFile->blcksz != BLCKSZ) if (ControlFile->blcksz != BLCKSZ)
elog(STOP, "database was initialized with BLCKSZ %d,\n\tbut the backend was compiled with BLCKSZ %d.\n\tlooks like you need to initdb.", elog(STOP,
"The database cluster was initialized with BLCKSZ %d,\n"
"\tbut the backend was compiled with BLCKSZ %d.\n"
"\tIt looks like you need to initdb.",
ControlFile->blcksz, BLCKSZ); ControlFile->blcksz, BLCKSZ);
if (ControlFile->relseg_size != RELSEG_SIZE) if (ControlFile->relseg_size != RELSEG_SIZE)
elog(STOP, "database was initialized with RELSEG_SIZE %d,\n\tbut the backend was compiled with RELSEG_SIZE %d.\n\tlooks like you need to initdb.", elog(STOP,
"The database cluster was initialized with RELSEG_SIZE %d,\n"
"\tbut the backend was compiled with RELSEG_SIZE %d.\n"
"\tIt looks like you need to initdb.",
ControlFile->relseg_size, RELSEG_SIZE); ControlFile->relseg_size, RELSEG_SIZE);
#ifdef USE_LOCALE #ifdef USE_LOCALE
if (setlocale(LC_COLLATE, ControlFile->lc_collate) == NULL) if (setlocale(LC_COLLATE, ControlFile->lc_collate) == NULL)
elog(STOP, "database was initialized with LC_COLLATE '%s',\n\twhich is not recognized by setlocale().\n\tlooks like you need to initdb.", elog(STOP,
"The database cluster was initialized with LC_COLLATE '%s',\n"
"\twhich is not recognized by setlocale().\n"
"\tIt looks like you need to initdb.",
ControlFile->lc_collate); ControlFile->lc_collate);
if (setlocale(LC_CTYPE, ControlFile->lc_ctype) == NULL) if (setlocale(LC_CTYPE, ControlFile->lc_ctype) == NULL)
elog(STOP, "database was initialized with LC_CTYPE '%s',\n\twhich is not recognized by setlocale().\n\tlooks like you need to initdb.", elog(STOP,
"The database cluster was initialized with LC_CTYPE '%s',\n"
"\twhich is not recognized by setlocale().\n"
"\tIt looks like you need to initdb.",
ControlFile->lc_ctype); ControlFile->lc_ctype);
#else #else /* not USE_LOCALE */
if (strcmp(ControlFile->lc_collate, "C") != 0 || if (strcmp(ControlFile->lc_collate, "C") != 0 ||
strcmp(ControlFile->lc_ctype, "C") != 0) strcmp(ControlFile->lc_ctype, "C") != 0)
elog(STOP, "database was initialized with LC_COLLATE '%s' and LC_CTYPE '%s',\n\tbut the backend was compiled without locale support.\n\tlooks like you need to initdb or recompile.", elog(STOP,
"The database cluster was initialized with LC_COLLATE '%s' and\n"
"\tLC_CTYPE '%s', but the server was compiled without locale support.\n"
"\tIt looks like you need to initdb or recompile.",
ControlFile->lc_collate, ControlFile->lc_ctype); ControlFile->lc_collate, ControlFile->lc_ctype);
#endif #endif /* not USE_LOCALE */
} }
void void
...@@ -2082,13 +2107,13 @@ UpdateControlFile(void) ...@@ -2082,13 +2107,13 @@ UpdateControlFile(void)
fd = BasicOpenFile(ControlFilePath, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR); fd = BasicOpenFile(ControlFilePath, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR);
if (fd < 0) if (fd < 0)
elog(STOP, "open(\"%s\") failed: %m", ControlFilePath); elog(STOP, "could not open control file (%s): %m", ControlFilePath);
if (write(fd, ControlFile, sizeof(ControlFileData)) != sizeof(ControlFileData)) if (write(fd, ControlFile, sizeof(ControlFileData)) != sizeof(ControlFileData))
elog(STOP, "write(cntlfile) failed: %m"); elog(STOP, "write to control file failed: %m");
if (pg_fsync(fd) != 0) if (pg_fsync(fd) != 0)
elog(STOP, "fsync(cntlfile) failed: %m"); elog(STOP, "fsync of control file failed: %m");
close(fd); close(fd);
} }
...@@ -2224,10 +2249,10 @@ BootStrapXLOG(void) ...@@ -2224,10 +2249,10 @@ BootStrapXLOG(void)
openLogFile = XLogFileInit(0, 0, &use_existent, false); openLogFile = XLogFileInit(0, 0, &use_existent, false);
if (write(openLogFile, buffer, BLCKSZ) != BLCKSZ) if (write(openLogFile, buffer, BLCKSZ) != BLCKSZ)
elog(STOP, "BootStrapXLOG failed to write logfile: %m"); elog(STOP, "BootStrapXLOG failed to write log file: %m");
if (pg_fsync(openLogFile) != 0) if (pg_fsync(openLogFile) != 0)
elog(STOP, "BootStrapXLOG failed to fsync logfile: %m"); elog(STOP, "BootStrapXLOG failed to fsync log file: %m");
close(openLogFile); close(openLogFile);
openLogFile = -1; openLogFile = -1;
...@@ -2302,7 +2327,7 @@ StartupXLOG(void) ...@@ -2302,7 +2327,7 @@ StartupXLOG(void)
else if (ControlFile->state == DB_IN_RECOVERY) else if (ControlFile->state == DB_IN_RECOVERY)
elog(LOG, "database system was interrupted being in recovery at %s\n" elog(LOG, "database system was interrupted being in recovery at %s\n"
"\tThis propably means that some data blocks are corrupted\n" "\tThis propably means that some data blocks are corrupted\n"
"\tand you will have to use last backup for recovery.", "\tand you will have to use the last backup for recovery.",
str_time(ControlFile->time)); str_time(ControlFile->time));
else if (ControlFile->state == DB_IN_PRODUCTION) else if (ControlFile->state == DB_IN_PRODUCTION)
elog(LOG, "database system was interrupted at %s", elog(LOG, "database system was interrupted at %s",
...@@ -2312,41 +2337,40 @@ StartupXLOG(void) ...@@ -2312,41 +2337,40 @@ StartupXLOG(void)
* Get the last valid checkpoint record. If the latest one according * Get the last valid checkpoint record. If the latest one according
* to pg_control is broken, try the next-to-last one. * to pg_control is broken, try the next-to-last one.
*/ */
record = ReadCheckpointRecord(ControlFile->checkPoint, record = ReadCheckpointRecord(ControlFile->checkPoint, 1, buffer);
"primary", buffer);
if (record != NULL) if (record != NULL)
{ {
checkPointLoc = ControlFile->checkPoint; checkPointLoc = ControlFile->checkPoint;
elog(LOG, "CheckPoint record at (%u, %u)", elog(LOG, "checkpoint record is at (%u, %u)",
checkPointLoc.xlogid, checkPointLoc.xrecoff); checkPointLoc.xlogid, checkPointLoc.xrecoff);
} }
else else
{ {
record = ReadCheckpointRecord(ControlFile->prevCheckPoint, record = ReadCheckpointRecord(ControlFile->prevCheckPoint, 2, buffer);
"secondary", buffer);
if (record != NULL) if (record != NULL)
{ {
checkPointLoc = ControlFile->prevCheckPoint; checkPointLoc = ControlFile->prevCheckPoint;
elog(LOG, "Using previous CheckPoint record at (%u, %u)", elog(LOG, "using previous checkpoint record at (%u, %u)",
checkPointLoc.xlogid, checkPointLoc.xrecoff); checkPointLoc.xlogid, checkPointLoc.xrecoff);
InRecovery = true; /* force recovery even if SHUTDOWNED */ InRecovery = true; /* force recovery even if SHUTDOWNED */
} }
else else
elog(STOP, "Unable to locate a valid CheckPoint record"); elog(STOP, "unable to locate a valid checkpoint record");
} }
LastRec = RecPtr = checkPointLoc; LastRec = RecPtr = checkPointLoc;
memcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint)); memcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint));
wasShutdown = (record->xl_info == XLOG_CHECKPOINT_SHUTDOWN); wasShutdown = (record->xl_info == XLOG_CHECKPOINT_SHUTDOWN);
elog(LOG, "Redo record at (%u, %u); Undo record at (%u, %u); Shutdown %s", elog(LOG, "redo record is at (%u, %u); undo record is at (%u, %u); shutdown %s",
checkPoint.redo.xlogid, checkPoint.redo.xrecoff, checkPoint.redo.xlogid, checkPoint.redo.xrecoff,
checkPoint.undo.xlogid, checkPoint.undo.xrecoff, checkPoint.undo.xlogid, checkPoint.undo.xrecoff,
wasShutdown ? "TRUE" : "FALSE"); wasShutdown ? "TRUE" : "FALSE");
elog(LOG, "NextTransactionId: %u; NextOid: %u", elog(LOG, "next transaction id: %u; next oid: %u",
checkPoint.nextXid, checkPoint.nextOid); checkPoint.nextXid, checkPoint.nextOid);
if (checkPoint.nextXid < FirstTransactionId || if (checkPoint.nextXid < FirstTransactionId)
checkPoint.nextOid < BootstrapObjectIdData) elog(STOP, "invalid next transaction id");
elog(STOP, "Invalid NextTransactionId/NextOid"); if (checkPoint.nextOid < BootstrapObjectIdData)
elog(STOP, "invalid next oid");
ShmemVariableCache->nextXid = checkPoint.nextXid; ShmemVariableCache->nextXid = checkPoint.nextXid;
ShmemVariableCache->nextOid = checkPoint.nextOid; ShmemVariableCache->nextOid = checkPoint.nextOid;
...@@ -2357,7 +2381,7 @@ StartupXLOG(void) ...@@ -2357,7 +2381,7 @@ StartupXLOG(void)
XLogCtl->RedoRecPtr = checkPoint.redo; XLogCtl->RedoRecPtr = checkPoint.redo;
if (XLByteLT(RecPtr, checkPoint.redo)) if (XLByteLT(RecPtr, checkPoint.redo))
elog(STOP, "Invalid redo in checkPoint record"); elog(STOP, "invalid redo in checkpoint record");
if (checkPoint.undo.xrecoff == 0) if (checkPoint.undo.xrecoff == 0)
checkPoint.undo = RecPtr; checkPoint.undo = RecPtr;
...@@ -2365,7 +2389,7 @@ StartupXLOG(void) ...@@ -2365,7 +2389,7 @@ StartupXLOG(void)
XLByteLT(checkPoint.redo, RecPtr)) XLByteLT(checkPoint.redo, RecPtr))
{ {
if (wasShutdown) if (wasShutdown)
elog(STOP, "Invalid Redo/Undo record in shutdown checkpoint"); elog(STOP, "invalid redo/undo record in shutdown checkpoint");
InRecovery = true; InRecovery = true;
} }
else if (ControlFile->state != DB_SHUTDOWNED) else if (ControlFile->state != DB_SHUTDOWNED)
...@@ -2375,7 +2399,7 @@ StartupXLOG(void) ...@@ -2375,7 +2399,7 @@ StartupXLOG(void)
if (InRecovery) if (InRecovery)
{ {
elog(LOG, "database system was not properly shut down; " elog(LOG, "database system was not properly shut down; "
"automatic recovery in progress..."); "automatic recovery in progress");
ControlFile->state = DB_IN_RECOVERY; ControlFile->state = DB_IN_RECOVERY;
ControlFile->time = time(NULL); ControlFile->time = time(NULL);
UpdateControlFile(); UpdateControlFile();
...@@ -2410,7 +2434,7 @@ StartupXLOG(void) ...@@ -2410,7 +2434,7 @@ StartupXLOG(void)
strcat(buf, " - "); strcat(buf, " - ");
RmgrTable[record->xl_rmid].rm_desc(buf, RmgrTable[record->xl_rmid].rm_desc(buf,
record->xl_info, XLogRecGetData(record)); record->xl_info, XLogRecGetData(record));
fprintf(stderr, "%s\n", buf); elog(DEBUG, "%s", buf);
} }
if (record->xl_info & XLR_BKP_BLOCK_MASK) if (record->xl_info & XLR_BKP_BLOCK_MASK)
...@@ -2548,7 +2572,7 @@ StartupXLOG(void) ...@@ -2548,7 +2572,7 @@ StartupXLOG(void)
ThisStartUpID++; ThisStartUpID++;
XLogCtl->ThisStartUpID = ThisStartUpID; XLogCtl->ThisStartUpID = ThisStartUpID;
elog(LOG, "database system is in production state"); elog(LOG, "database system is ready");
CritSectionCount--; CritSectionCount--;
/* Shut down readFile facility, free space */ /* Shut down readFile facility, free space */
...@@ -2566,17 +2590,22 @@ StartupXLOG(void) ...@@ -2566,17 +2590,22 @@ StartupXLOG(void)
free(buffer); free(buffer);
} }
/* Subroutine to try to fetch and validate a prior checkpoint record */ /*
* Subroutine to try to fetch and validate a prior checkpoint record.
* whichChkpt = 1 for "primary", 2 for "secondary", merely informative
*/
static XLogRecord * static XLogRecord *
ReadCheckpointRecord(XLogRecPtr RecPtr, ReadCheckpointRecord(XLogRecPtr RecPtr,
const char *whichChkpt, int whichChkpt,
char *buffer) char *buffer)
{ {
XLogRecord *record; XLogRecord *record;
if (!XRecOffIsValid(RecPtr.xrecoff)) if (!XRecOffIsValid(RecPtr.xrecoff))
{ {
elog(LOG, "Invalid %s checkPoint link in control file", whichChkpt); elog(LOG, (whichChkpt == 1 ?
"invalid primary checkpoint link in control file" :
"invalid secondary checkpoint link in control file"));
return NULL; return NULL;
} }
...@@ -2584,23 +2613,31 @@ ReadCheckpointRecord(XLogRecPtr RecPtr, ...@@ -2584,23 +2613,31 @@ ReadCheckpointRecord(XLogRecPtr RecPtr,
if (record == NULL) if (record == NULL)
{ {
elog(LOG, "Invalid %s checkPoint record", whichChkpt); elog(LOG, (whichChkpt == 1 ?
"invalid primary checkpoint record" :
"invalid secondary checkpoint record"));
return NULL; return NULL;
} }
if (record->xl_rmid != RM_XLOG_ID) if (record->xl_rmid != RM_XLOG_ID)
{ {
elog(LOG, "Invalid RMID in %s checkPoint record", whichChkpt); elog(LOG, (whichChkpt == 1 ?
"invalid resource manager id in primary checkpoint record" :
"invalid resource manager id in secondary checkpoint record"));
return NULL; return NULL;
} }
if (record->xl_info != XLOG_CHECKPOINT_SHUTDOWN && if (record->xl_info != XLOG_CHECKPOINT_SHUTDOWN &&
record->xl_info != XLOG_CHECKPOINT_ONLINE) record->xl_info != XLOG_CHECKPOINT_ONLINE)
{ {
elog(LOG, "Invalid xl_info in %s checkPoint record", whichChkpt); elog(LOG, (whichChkpt == 1 ?
"invalid xl_info in primary checkpoint record" :
"invalid xl_info in secondary checkpoint record"));
return NULL; return NULL;
} }
if (record->xl_len != sizeof(CheckPoint)) if (record->xl_len != sizeof(CheckPoint))
{ {
elog(LOG, "Invalid length of %s checkPoint record", whichChkpt); elog(LOG, (whichChkpt == 1 ?
"invalid length of primary checkpoint record" :
"invalid length of secondary checkpoint record"));
return NULL; return NULL;
} }
return record; return record;
...@@ -2768,7 +2805,7 @@ CreateCheckPoint(bool shutdown) ...@@ -2768,7 +2805,7 @@ CreateCheckPoint(bool shutdown)
checkPoint.undo = GetUndoRecPtr(); checkPoint.undo = GetUndoRecPtr();
if (shutdown && checkPoint.undo.xrecoff != 0) if (shutdown && checkPoint.undo.xrecoff != 0)
elog(STOP, "Active transaction while data base is shutting down"); elog(STOP, "active transaction while database system is shutting down");
/* /*
* Now we can release insert lock, allowing other xacts to proceed * Now we can release insert lock, allowing other xacts to proceed
...@@ -2812,7 +2849,7 @@ CreateCheckPoint(bool shutdown) ...@@ -2812,7 +2849,7 @@ CreateCheckPoint(bool shutdown)
* recptr = end of actual checkpoint record. * recptr = end of actual checkpoint record.
*/ */
if (shutdown && !XLByteEQ(checkPoint.redo, ProcLastRecPtr)) if (shutdown && !XLByteEQ(checkPoint.redo, ProcLastRecPtr))
elog(STOP, "XLog concurrent activity while data base is shutting down"); elog(STOP, "concurrent transaction log activity while database system is shutting down");
/* /*
* Remember location of prior checkpoint's earliest info. Oldest item * Remember location of prior checkpoint's earliest info. Oldest item
...@@ -3041,7 +3078,7 @@ assign_xlog_sync_method(const char *method) ...@@ -3041,7 +3078,7 @@ assign_xlog_sync_method(const char *method)
else else
{ {
/* Can't get here unless guc.c screwed up */ /* Can't get here unless guc.c screwed up */
elog(ERROR, "Bogus xlog sync method %s", method); elog(ERROR, "bogus wal_sync_method %s", method);
new_sync_method = 0; /* keep compiler quiet */ new_sync_method = 0; /* keep compiler quiet */
new_sync_bit = 0; new_sync_bit = 0;
} }
...@@ -3058,12 +3095,12 @@ assign_xlog_sync_method(const char *method) ...@@ -3058,12 +3095,12 @@ assign_xlog_sync_method(const char *method)
if (openLogFile >= 0) if (openLogFile >= 0)
{ {
if (pg_fsync(openLogFile) != 0) if (pg_fsync(openLogFile) != 0)
elog(STOP, "fsync(logfile %u seg %u) failed: %m", elog(STOP, "fsync of log file %u, segment %u failed: %m",
openLogId, openLogSeg); openLogId, openLogSeg);
if (open_sync_bit != new_sync_bit) if (open_sync_bit != new_sync_bit)
{ {
if (close(openLogFile) != 0) if (close(openLogFile) != 0)
elog(STOP, "close(logfile %u seg %u) failed: %m", elog(STOP, "close of log file %u, segment %u failed: %m",
openLogId, openLogSeg); openLogId, openLogSeg);
openLogFile = -1; openLogFile = -1;
} }
...@@ -3084,13 +3121,13 @@ issue_xlog_fsync(void) ...@@ -3084,13 +3121,13 @@ issue_xlog_fsync(void)
{ {
case SYNC_METHOD_FSYNC: case SYNC_METHOD_FSYNC:
if (pg_fsync(openLogFile) != 0) if (pg_fsync(openLogFile) != 0)
elog(STOP, "fsync(logfile %u seg %u) failed: %m", elog(STOP, "fsync of log file %u, segment %u failed: %m",
openLogId, openLogSeg); openLogId, openLogSeg);
break; break;
#ifdef HAVE_FDATASYNC #ifdef HAVE_FDATASYNC
case SYNC_METHOD_FDATASYNC: case SYNC_METHOD_FDATASYNC:
if (pg_fdatasync(openLogFile) != 0) if (pg_fdatasync(openLogFile) != 0)
elog(STOP, "fdatasync(logfile %u seg %u) failed: %m", elog(STOP, "fdatasync of log file %u, segment %u failed: %m",
openLogId, openLogSeg); openLogId, openLogSeg);
break; break;
#endif #endif
...@@ -3098,7 +3135,7 @@ issue_xlog_fsync(void) ...@@ -3098,7 +3135,7 @@ issue_xlog_fsync(void)
/* write synced it already */ /* write synced it already */
break; break;
default: default:
elog(STOP, "bogus sync_method %d", sync_method); elog(STOP, "bogus wal_sync_method %d", sync_method);
break; break;
} }
} }
...@@ -8,7 +8,7 @@ ...@@ -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.107 2001/05/12 01:48:49 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.108 2001/06/03 14:53:56 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -185,11 +185,13 @@ err_out(void) ...@@ -185,11 +185,13 @@ err_out(void)
static void static void
usage(void) usage(void)
{ {
fprintf(stderr, "Usage:\n postgres -boot [-d] [-D datadir] [-F] [-x num] dbname\n"); fprintf(stderr,
fprintf(stderr, " -d debug mode\n"); gettext("Usage:\n"
fprintf(stderr, " -D datadir data directory\n"); " postgres -boot [-d] [-D datadir] [-F] [-x num] dbname\n"
fprintf(stderr, " -F turn off fsync\n"); " -d debug mode\n"
fprintf(stderr, " -x num internal use\n"); " -D datadir data directory\n"
" -F turn off fsync\n"
" -x num internal use\n"));
proc_exit(1); proc_exit(1);
} }
...@@ -286,10 +288,11 @@ BootstrapMain(int argc, char *argv[]) ...@@ -286,10 +288,11 @@ BootstrapMain(int argc, char *argv[])
{ {
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\n"),
argv[0]); argv[0]);
proc_exit(1); proc_exit(1);
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.44 2001/06/02 18:25:17 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.45 2001/06/03 14:53:56 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -41,12 +41,6 @@ ...@@ -41,12 +41,6 @@
#include "tcop/tcopprot.h" #include "tcop/tcopprot.h"
#define NOROOTEXEC "\
\n\"root\" execution of the PostgreSQL server is not permitted.\n\n\
The server must be started under an unprivileged userid to prevent\n\
a possible system security compromise. See the INSTALL file for\n\
more information on how to properly start the server.\n\n"
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
...@@ -87,7 +81,7 @@ main(int argc, char *argv[]) ...@@ -87,7 +81,7 @@ 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, "setsysinfo failed: %d\n", errno); fprintf(stderr, gettext("%s: setsysinfo failed: %s\n"), argv[0], strerror(errno));
#endif #endif
#endif /* NOFIXADE || NOPRINTADE */ #endif /* NOFIXADE || NOPRINTADE */
...@@ -129,7 +123,12 @@ main(int argc, char *argv[]) ...@@ -129,7 +123,12 @@ main(int argc, char *argv[])
#ifndef __BEOS__ #ifndef __BEOS__
if (geteuid() == 0) if (geteuid() == 0)
{ {
fprintf(stderr, "%s", NOROOTEXEC); fprintf(stderr, gettext(
"\"root\" execution of the PostgreSQL server is not permitted.\n\n"
"The server must be started under an unprivileged user id to prevent\n"
"a possible system security compromise. See the documentation for\n"
"more information on how to properly start the server.\n\n"
));
exit(1); exit(1);
} }
#endif /* __BEOS__ */ #endif /* __BEOS__ */
...@@ -145,7 +144,7 @@ main(int argc, char *argv[]) ...@@ -145,7 +144,7 @@ main(int argc, char *argv[])
*/ */
if (getuid() != geteuid()) if (getuid() != geteuid())
{ {
fprintf(stderr, "%s: real and effective userids must match\n", fprintf(stderr, gettext("%s: real and effective user ids must match\n"),
argv[0]); argv[0]);
exit(1); exit(1);
} }
...@@ -194,7 +193,7 @@ main(int argc, char *argv[]) ...@@ -194,7 +193,7 @@ main(int argc, char *argv[])
pw = getpwuid(geteuid()); pw = getpwuid(geteuid());
if (pw == NULL) if (pw == NULL)
{ {
fprintf(stderr, "%s: invalid current euid %d\n", fprintf(stderr, gettext("%s: invalid current euid %d\n"),
argv[0], (int) geteuid()); argv[0], (int) geteuid());
exit(1); exit(1);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, 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: geqo_main.c,v 1.27 2001/03/22 03:59:33 momjian Exp $ * $Id: geqo_main.c,v 1.28 2001/06/03 14:53:56 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -217,24 +217,22 @@ geqo(Query *root, int number_of_rels, List *initial_rels) ...@@ -217,24 +217,22 @@ geqo(Query *root, int number_of_rels, List *initial_rels)
#if defined(ERX) && defined(GEQO_DEBUG) #if defined(ERX) && defined(GEQO_DEBUG)
if (edge_failures != 0) if (edge_failures != 0)
fprintf(stdout, "\nFailures: %d Avg: %d\n", edge_failures, (int) generation / edge_failures); elog(DEBUG, "[GEQO] failures: %d, average: %d",
edge_failures, (int) generation / edge_failures);
else else
fprintf(stdout, "No edge failures detected.\n"); elog(DEBUG, "[GEQO] No edge failures detected.");
#endif #endif
#if defined(CX) && defined(GEQO_DEBUG) #if defined(CX) && defined(GEQO_DEBUG)
if (mutations != 0) if (mutations != 0)
fprintf(stdout, "\nMutations: %d Generations: %d\n", mutations, generation); elog(DEBUG, "[GEQO] mutations: %d, generations: %d", mutations, generation);
else else
fprintf(stdout, "No mutations processed.\n"); elog(DEBUG, "[GEQO] No mutations processed.");
#endif #endif
#ifdef GEQO_DEBUG #ifdef GEQO_DEBUG
fprintf(stdout, "\n");
print_pool(stdout, pool, 0, pool_size - 1); print_pool(stdout, pool, 0, pool_size - 1);
#endif #endif
......
This source diff could not be displayed because it is too large. You can view the blob instead.
CATALOG_NAME := postgres CATALOG_NAME := postgres
AVAIL_LANGUAGES := de AVAIL_LANGUAGES := de
GETTEXT_FILES := + gettext-files GETTEXT_FILES := + gettext-files
GETTEXT_TRIGGERS:= elog:2 GETTEXT_TRIGGERS:= elog:2 postmaster_error
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.215 2001/05/30 14:15:26 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.216 2001/06/03 14:53:56 petere Exp $
* *
* NOTES * NOTES
* *
...@@ -243,6 +243,7 @@ static void RandomSalt(char *salt); ...@@ -243,6 +243,7 @@ static void RandomSalt(char *salt);
static void SignalChildren(int signal); 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 void postmaster_error(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
static pid_t SSDataBase(int xlop); static pid_t SSDataBase(int xlop);
...@@ -264,10 +265,11 @@ checkDataDir(const char *checkdir) ...@@ -264,10 +265,11 @@ checkDataDir(const char *checkdir)
if (checkdir == NULL) if (checkdir == NULL)
{ {
fprintf(stderr, "%s does not know where to find the database system " fprintf(stderr, gettext(
"data. You must specify the directory that contains the " "%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\n"),
progname); progname);
ExitPostmaster(2); ExitPostmaster(2);
} }
...@@ -277,9 +279,10 @@ checkDataDir(const char *checkdir) ...@@ -277,9 +279,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, "%s does not find the database system." fprintf(stderr, gettext(
"\n\tExpected to find it in the PGDATA directory \"%s\"," "%s does not find the database system.\n"
"\n\tbut unable to open file \"%s\": %s\n\n", "Expected to find it in the PGDATA directory \"%s\",\n"
"but unable to open file \"%s\": %s\n\n"),
progname, checkdir, path, strerror(errno)); progname, checkdir, path, strerror(errno));
ExitPostmaster(2); ExitPostmaster(2);
} }
...@@ -381,7 +384,7 @@ PostmasterMain(int argc, char *argv[]) ...@@ -381,7 +384,7 @@ PostmasterMain(int argc, char *argv[])
break; break;
case '?': case '?':
fprintf(stderr, "Try '%s --help' for more information.\n", progname); fprintf(stderr, gettext("Try '%s --help' for more information.\n"), progname);
ExitPostmaster(1); ExitPostmaster(1);
} }
} }
...@@ -391,8 +394,8 @@ PostmasterMain(int argc, char *argv[]) ...@@ -391,8 +394,8 @@ PostmasterMain(int argc, char *argv[])
*/ */
if (optind < argc) if (optind < argc)
{ {
fprintf(stderr, "%s: invalid argument -- %s\n", progname, argv[optind]); postmaster_error("invalid argument -- %s", argv[optind]);
fprintf(stderr, "Try '%s --help' for more information.\n", progname); fprintf(stderr, gettext("Try '%s --help' for more information.\n"), progname);
ExitPostmaster(1); ExitPostmaster(1);
} }
...@@ -413,7 +416,7 @@ PostmasterMain(int argc, char *argv[]) ...@@ -413,7 +416,7 @@ PostmasterMain(int argc, char *argv[])
{ {
case 'A': case 'A':
#ifndef USE_ASSERT_CHECKING #ifndef USE_ASSERT_CHECKING
fprintf(stderr, "Assert checking is not compiled in\n"); postmaster_error("Assert checking is not compiled in.");
#else #else
assert_enabled = atoi(optarg); assert_enabled = atoi(optarg);
#endif #endif
...@@ -539,7 +542,7 @@ PostmasterMain(int argc, char *argv[]) ...@@ -539,7 +542,7 @@ PostmasterMain(int argc, char *argv[])
default: default:
/* shouldn't get here */ /* shouldn't get here */
fprintf(stderr, "Try '%s --help' for more information.\n", progname); fprintf(stderr, gettext("Try '%s --help' for more information.\n"), progname);
ExitPostmaster(1); ExitPostmaster(1);
} }
} }
...@@ -555,8 +558,7 @@ PostmasterMain(int argc, char *argv[]) ...@@ -555,8 +558,7 @@ 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.
*/ */
fprintf(stderr, "%s: The number of buffers (-B) must be at least twice the number of allowed connections (-N) and at least 16.\n", postmaster_error("The number of buffers (-B) must be at least twice the number of allowed connections (-N) and at least 16.");
progname);
ExitPostmaster(1); ExitPostmaster(1);
} }
...@@ -600,8 +602,8 @@ PostmasterMain(int argc, char *argv[]) ...@@ -600,8 +602,8 @@ PostmasterMain(int argc, char *argv[])
#ifdef USE_SSL #ifdef USE_SSL
if (EnableSSL && !NetServer) if (EnableSSL && !NetServer)
{ {
fprintf(stderr, "%s: For SSL, TCP/IP connections must be enabled. See -? for help.\n", postmaster_error("For SSL, TCP/IP connections must be enabled.");
progname); fprintf(stderr, gettext("Try '%s --help' for more information.\n"), progname);
ExitPostmaster(1); ExitPostmaster(1);
} }
if (EnableSSL) if (EnableSSL)
...@@ -615,8 +617,7 @@ PostmasterMain(int argc, char *argv[]) ...@@ -615,8 +617,7 @@ PostmasterMain(int argc, char *argv[])
&ServerSock_INET); &ServerSock_INET);
if (status != STATUS_OK) if (status != STATUS_OK)
{ {
fprintf(stderr, "%s: cannot create INET stream port\n", postmaster_error("cannot create INET stream port");
progname);
ExitPostmaster(1); ExitPostmaster(1);
} }
} }
...@@ -627,8 +628,7 @@ PostmasterMain(int argc, char *argv[]) ...@@ -627,8 +628,7 @@ PostmasterMain(int argc, char *argv[])
&ServerSock_UNIX); &ServerSock_UNIX);
if (status != STATUS_OK) if (status != STATUS_OK)
{ {
fprintf(stderr, "%s: cannot create UNIX stream port\n", postmaster_error("cannot create UNIX stream port");
progname);
ExitPostmaster(1); ExitPostmaster(1);
} }
#endif #endif
...@@ -701,7 +701,7 @@ pmdaemonize(int argc, char *argv[]) ...@@ -701,7 +701,7 @@ pmdaemonize(int argc, char *argv[])
pid = fork(); pid = fork();
if (pid == (pid_t) -1) if (pid == (pid_t) -1)
{ {
perror("Failed to fork postmaster"); postmaster_error("fork failed: %s", strerror(errno));
ExitPostmaster(1); ExitPostmaster(1);
return; /* not reached */ return; /* not reached */
} }
...@@ -719,8 +719,8 @@ pmdaemonize(int argc, char *argv[]) ...@@ -719,8 +719,8 @@ pmdaemonize(int argc, char *argv[])
#ifdef HAVE_SETSID #ifdef HAVE_SETSID
if (setsid() < 0) if (setsid() < 0)
{ {
fprintf(stderr, "%s: ", progname); postmaster_error("cannot disassociate from controlling TTY: %s",
perror("cannot disassociate from controlling TTY"); strerror(errno));
ExitPostmaster(1); ExitPostmaster(1);
} }
#endif #endif
...@@ -739,38 +739,37 @@ pmdaemonize(int argc, char *argv[]) ...@@ -739,38 +739,37 @@ pmdaemonize(int argc, char *argv[])
static void static void
usage(const char *progname) usage(const char *progname)
{ {
printf("%s is the PostgreSQL server.\n\n", progname); printf(gettext("%s is the PostgreSQL server.\n\n"), progname);
printf("Usage:\n %s [options...]\n\n", progname); printf(gettext("Usage:\n %s [options...]\n\n"), progname);
printf("Options:\n"); printf(gettext("Options:\n"));
#ifdef USE_ASSERT_CHECKING #ifdef USE_ASSERT_CHECKING
printf(" -A 1|0 enable/disable run-time assert checking\n"); printf(gettext(" -A 1|0 enable/disable run-time assert checking\n"));
#endif #endif
printf(" -B NBUFFERS number of shared buffers (default %d)\n", DEF_NBUFFERS); printf(gettext(" -B NBUFFERS number of shared buffers (default %d)\n"), DEF_NBUFFERS);
printf(" -c NAME=VALUE set run-time parameter\n"); printf(gettext(" -c NAME=VALUE set run-time parameter\n"));
printf(" -d 1-5 debugging level\n"); printf(gettext(" -d 1-5 debugging level\n"));
printf(" -D DATADIR database directory\n"); printf(gettext(" -D DATADIR database directory\n"));
printf(" -F turn fsync off\n"); printf(gettext(" -F turn fsync off\n"));
printf(" -h HOSTNAME host name or IP address to listen on\n"); printf(gettext(" -h HOSTNAME host name or IP address to listen on\n"));
printf(" -i enable TCP/IP connections\n"); printf(gettext(" -i enable TCP/IP connections\n"));
printf(" -k DIRECTORY Unix-domain socket location\n"); printf(gettext(" -k DIRECTORY Unix-domain socket location\n"));
#ifdef USE_SSL #ifdef USE_SSL
printf(" -l enable SSL connections\n"); printf(gettext(" -l enable SSL connections\n"));
#endif #endif
printf(" -N MAX-CONNECT maximum number of allowed connections (1..%d, default %d)\n", printf(gettext(" -N MAX-CONNECT maximum number of allowed connections (1..%d, default %d)\n"),
MAXBACKENDS, DEF_MAXBACKENDS); MAXBACKENDS, DEF_MAXBACKENDS);
printf(" -o OPTIONS pass 'OPTIONS' to each backend server\n"); printf(gettext(" -o OPTIONS pass 'OPTIONS' to each backend server\n"));
printf(" -p PORT port number to listen on (default %d)\n", DEF_PGPORT); printf(gettext(" -p PORT port number to listen on (default %d)\n"), DEF_PGPORT);
printf(" -S silent mode (start in background without logging output)\n"); printf(gettext(" -S silent mode (start in background without logging output)\n"));
printf("\nDeveloper options:\n"); printf(gettext("\nDeveloper options:\n"));
printf(" -n do not reinitialize shared memory after abnormal exit\n"); printf(gettext(" -n do not reinitialize shared memory after abnormal exit\n"));
printf(" -s send SIGSTOP to all backend servers if one dies\n"); printf(gettext(" -s send SIGSTOP to all backend servers if one dies\n"));
printf("\nPlease read the documentation for the complete list of run-time\n" printf(gettext("\nPlease read the documentation for the complete list of run-time\n"
"configuration settings and how to set them on the command line or in\n" "configuration settings and how to set them on the command line or in\n"
"the configuration file.\n\n"); "the configuration file.\n\n"
"Report bugs to <pgsql-bugs@postgresql.org>.\n"));
printf("Report bugs to <pgsql-bugs@postgresql.org>.\n");
} }
static int static int
...@@ -860,8 +859,7 @@ ServerLoop(void) ...@@ -860,8 +859,7 @@ ServerLoop(void)
PG_SETMASK(&BlockSig); PG_SETMASK(&BlockSig);
if (errno == EINTR || errno == EWOULDBLOCK) if (errno == EINTR || errno == EWOULDBLOCK)
continue; continue;
fprintf(stderr, "%s: ServerLoop: select failed: %s\n", postmaster_error("ServerLoop: select failed: %s", strerror(errno));
progname, strerror(errno));
return STATUS_ERROR; return STATUS_ERROR;
} }
...@@ -941,8 +939,7 @@ ServerLoop(void) ...@@ -941,8 +939,7 @@ ServerLoop(void)
) )
{ {
if (DebugLvl > 1) if (DebugLvl > 1)
fprintf(stderr, "%s: ServerLoop:\t\thandling reading %d\n", postmaster_error("ServerLoop: handling reading %d", port->sock);
progname, port->sock);
if (PacketReceiveFragment(port) != STATUS_OK) if (PacketReceiveFragment(port) != STATUS_OK)
status = STATUS_ERROR; status = STATUS_ERROR;
...@@ -951,8 +948,7 @@ ServerLoop(void) ...@@ -951,8 +948,7 @@ ServerLoop(void)
if (FD_ISSET(port->sock, &wmask)) if (FD_ISSET(port->sock, &wmask))
{ {
if (DebugLvl > 1) if (DebugLvl > 1)
fprintf(stderr, "%s: ServerLoop:\t\thandling writing %d\n", postmaster_error("ServerLoop: handling writing %d", port->sock);
progname, port->sock);
if (PacketSendFragment(port) != STATUS_OK) if (PacketSendFragment(port) != STATUS_OK)
status = STATUS_ERROR; status = STATUS_ERROR;
...@@ -1100,7 +1096,8 @@ readStartupPacket(void *arg, PacketLen len, void *pkt) ...@@ -1100,7 +1096,8 @@ readStartupPacket(void *arg, PacketLen len, void *pkt)
#endif #endif
if (send(port->sock, &SSLok, 1, 0) != 1) if (send(port->sock, &SSLok, 1, 0) != 1)
{ {
perror("Failed to send SSL negotiation response"); postmaster_error("failed to send SSL negotiation response: %s",
strerror(errno));
return STATUS_ERROR;/* Close connection */ return STATUS_ERROR;/* Close connection */
} }
...@@ -1111,8 +1108,8 @@ readStartupPacket(void *arg, PacketLen len, void *pkt) ...@@ -1111,8 +1108,8 @@ readStartupPacket(void *arg, PacketLen len, void *pkt)
!SSL_set_fd(port->ssl, port->sock) || !SSL_set_fd(port->ssl, port->sock) ||
SSL_accept(port->ssl) <= 0) SSL_accept(port->ssl) <= 0)
{ {
fprintf(stderr, "Failed to initialize SSL connection: %s, errno: %d (%s)\n", postmaster_error("failed to initialize SSL connection: %s, errno: %d (%s)",
ERR_reason_error_string(ERR_get_error()), errno, strerror(errno)); ERR_reason_error_string(ERR_get_error()), errno, strerror(errno));
return STATUS_ERROR; return STATUS_ERROR;
} }
} }
...@@ -1216,8 +1213,7 @@ processCancelRequest(Port *port, PacketLen len, void *pkt) ...@@ -1216,8 +1213,7 @@ processCancelRequest(Port *port, PacketLen len, void *pkt)
if (backendPID == CheckPointPID) if (backendPID == CheckPointPID)
{ {
if (DebugLvl) if (DebugLvl)
fprintf(stderr, "%s: processCancelRequest: CheckPointPID in cancel request for process %d\n", postmaster_error("processCancelRequest: CheckPointPID in cancel request for process %d", backendPID);
progname, backendPID);
return STATUS_ERROR; return STATUS_ERROR;
} }
...@@ -1232,16 +1228,14 @@ processCancelRequest(Port *port, PacketLen len, void *pkt) ...@@ -1232,16 +1228,14 @@ processCancelRequest(Port *port, PacketLen len, void *pkt)
{ {
/* Found a match; signal that backend to cancel current op */ /* Found a match; signal that backend to cancel current op */
if (DebugLvl) if (DebugLvl)
fprintf(stderr, "%s: processCancelRequest: sending SIGINT to process %d\n", postmaster_error("processCancelRequest: sending SIGINT to process %d", bp->pid);
progname, bp->pid);
kill(bp->pid, SIGINT); kill(bp->pid, SIGINT);
} }
else else
{ {
/* Right PID, wrong key: no way, Jose */ /* Right PID, wrong key: no way, Jose */
if (DebugLvl) if (DebugLvl)
fprintf(stderr, "%s: processCancelRequest: bad key in cancel request for process %d\n", postmaster_error("processCancelRequest: bad key in cancel request for process %d", bp->pid);
progname, bp->pid);
} }
return STATUS_ERROR; return STATUS_ERROR;
} }
...@@ -1249,8 +1243,7 @@ processCancelRequest(Port *port, PacketLen len, void *pkt) ...@@ -1249,8 +1243,7 @@ processCancelRequest(Port *port, PacketLen len, void *pkt)
/* No matching backend */ /* No matching backend */
if (DebugLvl) if (DebugLvl)
fprintf(stderr, "%s: processCancelRequest: bad PID in cancel request for process %d\n", postmaster_error("processCancelRequest: bad PID in cancel request for process %d", backendPID);
progname, backendPID);
return STATUS_ERROR; return STATUS_ERROR;
} }
...@@ -1288,8 +1281,7 @@ ConnCreate(int serverFd) ...@@ -1288,8 +1281,7 @@ ConnCreate(int serverFd)
if (!(port = (Port *) calloc(1, sizeof(Port)))) if (!(port = (Port *) calloc(1, sizeof(Port))))
{ {
fprintf(stderr, "%s: ConnCreate: malloc failed\n", postmaster_error("ConnCreate: malloc failed");
progname);
SignalChildren(SIGQUIT); SignalChildren(SIGQUIT);
ExitPostmaster(1); ExitPostmaster(1);
} }
...@@ -1452,7 +1444,7 @@ pmdie(SIGNAL_ARGS) ...@@ -1452,7 +1444,7 @@ pmdie(SIGNAL_ARGS)
} }
Shutdown = SmartShutdown; Shutdown = SmartShutdown;
tnow = time(NULL); tnow = time(NULL);
fprintf(stderr, "Smart Shutdown request at %s", ctime(&tnow)); fprintf(stderr, gettext("Smart Shutdown request at %s"), ctime(&tnow));
fflush(stderr); fflush(stderr);
if (DLGetHead(BackendList)) /* let reaper() handle this */ if (DLGetHead(BackendList)) /* let reaper() handle this */
{ {
...@@ -1490,14 +1482,14 @@ pmdie(SIGNAL_ARGS) ...@@ -1490,14 +1482,14 @@ pmdie(SIGNAL_ARGS)
return; return;
} }
tnow = time(NULL); tnow = time(NULL);
fprintf(stderr, "Fast Shutdown request at %s", ctime(&tnow)); fprintf(stderr, gettext("Fast Shutdown request at %s"), ctime(&tnow));
fflush(stderr); fflush(stderr);
if (DLGetHead(BackendList)) /* let reaper() handle this */ if (DLGetHead(BackendList)) /* let reaper() handle this */
{ {
Shutdown = FastShutdown; Shutdown = FastShutdown;
if (!FatalError) if (!FatalError)
{ {
fprintf(stderr, "Aborting any active transaction...\n"); fprintf(stderr, gettext("Aborting any active transaction...\n"));
fflush(stderr); fflush(stderr);
SignalChildren(SIGTERM); SignalChildren(SIGTERM);
} }
...@@ -1537,7 +1529,7 @@ pmdie(SIGNAL_ARGS) ...@@ -1537,7 +1529,7 @@ pmdie(SIGNAL_ARGS)
* properly shutdown data base system. * properly shutdown data base system.
*/ */
tnow = time(NULL); tnow = time(NULL);
fprintf(stderr, "Immediate Shutdown request at %s", ctime(&tnow)); fprintf(stderr, gettext("Immediate Shutdown request at %s"), ctime(&tnow));
fflush(stderr); fflush(stderr);
if (ShutdownPID > 0) if (ShutdownPID > 0)
kill(ShutdownPID, SIGQUIT); kill(ShutdownPID, SIGQUIT);
...@@ -1575,8 +1567,7 @@ reaper(SIGNAL_ARGS) ...@@ -1575,8 +1567,7 @@ reaper(SIGNAL_ARGS)
pqsignal(SIGCHLD, reaper); pqsignal(SIGCHLD, reaper);
if (DebugLvl) if (DebugLvl)
fprintf(stderr, "%s: reaping dead processes...\n", postmaster_error("reaping dead processes");
progname);
#ifdef HAVE_WAITPID #ifdef HAVE_WAITPID
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
{ {
...@@ -1592,8 +1583,7 @@ reaper(SIGNAL_ARGS) ...@@ -1592,8 +1583,7 @@ reaper(SIGNAL_ARGS)
abort(); abort();
if (exitstatus != 0) if (exitstatus != 0)
{ {
fprintf(stderr, "%s: Shutdown proc %d exited with status %d\n", postmaster_error("Shutdown proc %d exited with status %d", pid, exitstatus);
progname, pid, exitstatus);
fflush(stderr); fflush(stderr);
ExitPostmaster(1); ExitPostmaster(1);
} }
...@@ -1605,8 +1595,8 @@ reaper(SIGNAL_ARGS) ...@@ -1605,8 +1595,8 @@ reaper(SIGNAL_ARGS)
abort(); abort();
if (exitstatus != 0) if (exitstatus != 0)
{ {
fprintf(stderr, "%s: Startup proc %d exited with status %d - abort\n", postmaster_error("Startup proc %d exited with status %d - abort",
progname, pid, exitstatus); pid, exitstatus);
fflush(stderr); fflush(stderr);
ExitPostmaster(1); ExitPostmaster(1);
} }
...@@ -1649,8 +1639,8 @@ reaper(SIGNAL_ARGS) ...@@ -1649,8 +1639,8 @@ reaper(SIGNAL_ARGS)
return; return;
} }
tnow = time(NULL); tnow = time(NULL);
fprintf(stderr, "Server processes were terminated at %s" fprintf(stderr, gettext("Server processes were terminated at %s"
"Reinitializing shared memory and semaphores\n", "Reinitializing shared memory and semaphores\n"),
ctime(&tnow)); ctime(&tnow));
fflush(stderr); fflush(stderr);
...@@ -1696,8 +1686,8 @@ CleanupProc(int pid, ...@@ -1696,8 +1686,8 @@ CleanupProc(int pid,
Backend *bp; Backend *bp;
if (DebugLvl) if (DebugLvl)
fprintf(stderr, "%s: CleanupProc: pid %d exited with status %d\n", postmaster_error("CleanupProc: pid %d exited with status %d",
progname, pid, exitstatus); pid, exitstatus);
/* /*
* If a backend dies in an ugly way (i.e. exit status not 0) then we * If a backend dies in an ugly way (i.e. exit status not 0) then we
...@@ -1745,8 +1735,8 @@ CleanupProc(int pid, ...@@ -1745,8 +1735,8 @@ CleanupProc(int pid,
{ {
/* Make log entry unless we did so already */ /* Make log entry unless we did so already */
tnow = time(NULL); tnow = time(NULL);
fprintf(stderr, "Server process (pid %d) exited with status %d at %s" fprintf(stderr, gettext("Server process (pid %d) exited with status %d at %s"
"Terminating any active server processes...\n", "Terminating any active server processes...\n"),
pid, exitstatus, ctime(&tnow)); pid, exitstatus, ctime(&tnow));
fflush(stderr); fflush(stderr);
} }
...@@ -1771,10 +1761,9 @@ CleanupProc(int pid, ...@@ -1771,10 +1761,9 @@ CleanupProc(int pid,
if (!FatalError) if (!FatalError)
{ {
if (DebugLvl) if (DebugLvl)
fprintf(stderr, "%s: CleanupProc: sending %s to process %d\n", postmaster_error("CleanupProc: sending %s to process %d",
progname, (SendStop ? "SIGSTOP" : "SIGQUIT"),
(SendStop ? "SIGSTOP" : "SIGQUIT"), bp->pid);
bp->pid);
kill(bp->pid, (SendStop ? SIGSTOP : SIGQUIT)); kill(bp->pid, (SendStop ? SIGSTOP : SIGQUIT));
} }
} }
...@@ -1895,7 +1884,7 @@ BackendStartup(Port *port) ...@@ -1895,7 +1884,7 @@ BackendStartup(Port *port)
if (DoBackend(port)) if (DoBackend(port))
{ {
fprintf(stderr, "%s child[%d]: BackendStartup: backend startup failed\n", fprintf(stderr, gettext("%s child[%d]: BackendStartup: backend startup failed\n"),
progname, (int) getpid()); progname, (int) getpid());
ExitPostmaster(1); ExitPostmaster(1);
} }
...@@ -1910,13 +1899,13 @@ BackendStartup(Port *port) ...@@ -1910,13 +1899,13 @@ BackendStartup(Port *port)
/* Specific beos backend startup actions */ /* Specific beos backend startup actions */
beos_backend_startup_failed(); beos_backend_startup_failed();
#endif #endif
fprintf(stderr, "%s: BackendStartup: fork failed: %s\n", fprintf(stderr, gettext("%s: BackendStartup: fork failed: %s\n"),
progname, strerror(errno)); progname, strerror(errno));
return STATUS_ERROR; return STATUS_ERROR;
} }
if (DebugLvl) if (DebugLvl)
fprintf(stderr, "%s: BackendStartup: pid %d user %s db %s socket %d\n", fprintf(stderr, gettext("%s: BackendStartup: pid %d user %s db %s socket %d\n"),
progname, pid, port->user, port->database, progname, pid, port->user, port->database,
port->sock); port->sock);
...@@ -1926,7 +1915,7 @@ BackendStartup(Port *port) ...@@ -1926,7 +1915,7 @@ BackendStartup(Port *port)
*/ */
if (!(bn = (Backend *) calloc(1, sizeof(Backend)))) if (!(bn = (Backend *) calloc(1, sizeof(Backend))))
{ {
fprintf(stderr, "%s: BackendStartup: malloc failed\n", fprintf(stderr, gettext("%s: BackendStartup: malloc failed\n"),
progname); progname);
ExitPostmaster(1); ExitPostmaster(1);
} }
...@@ -2269,24 +2258,28 @@ InitSSL(void) ...@@ -2269,24 +2258,28 @@ InitSSL(void)
SSL_context = SSL_CTX_new(SSLv23_method()); SSL_context = SSL_CTX_new(SSLv23_method());
if (!SSL_context) if (!SSL_context)
{ {
fprintf(stderr, "Failed to create SSL context: %s\n", ERR_reason_error_string(ERR_get_error())); postmaster_error("failed to create SSL context: %s",
ERR_reason_error_string(ERR_get_error()));
ExitPostmaster(1); ExitPostmaster(1);
} }
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))
{ {
fprintf(stderr, "Failed to load server certificate (%s): %s\n", fnbuf, ERR_reason_error_string(ERR_get_error())); postmaster_error("failed to load server certificate (%s): %s",
fnbuf, ERR_reason_error_string(ERR_get_error()));
ExitPostmaster(1); ExitPostmaster(1);
} }
snprintf(fnbuf, sizeof(fnbuf), "%s/server.key", DataDir); snprintf(fnbuf, sizeof(fnbuf), "%s/server.key", DataDir);
if (!SSL_CTX_use_PrivateKey_file(SSL_context, fnbuf, SSL_FILETYPE_PEM)) if (!SSL_CTX_use_PrivateKey_file(SSL_context, fnbuf, SSL_FILETYPE_PEM))
{ {
fprintf(stderr, "Failed to load private key file (%s): %s\n", fnbuf, ERR_reason_error_string(ERR_get_error())); postmaster_error("failed to load private key file (%s): %s",
fnbuf, ERR_reason_error_string(ERR_get_error()));
ExitPostmaster(1); ExitPostmaster(1);
} }
if (!SSL_CTX_check_private_key(SSL_context)) if (!SSL_CTX_check_private_key(SSL_context))
{ {
fprintf(stderr, "Check of private key failed: %s\n", ERR_reason_error_string(ERR_get_error())); postmaster_error("check of private key failed: %s",
ERR_reason_error_string(ERR_get_error()));
ExitPostmaster(1); ExitPostmaster(1);
} }
} }
...@@ -2388,8 +2381,7 @@ SSDataBase(int xlop) ...@@ -2388,8 +2381,7 @@ SSDataBase(int xlop)
{ {
if (!(bn = (Backend *) calloc(1, sizeof(Backend)))) if (!(bn = (Backend *) calloc(1, sizeof(Backend))))
{ {
fprintf(stderr, "%s: CheckPointDataBase: malloc failed\n", postmaster_error("CheckPointDataBase: malloc failed");
progname);
ExitPostmaster(1); ExitPostmaster(1);
} }
...@@ -2429,8 +2421,8 @@ CreateOptsFile(int argc, char *argv[]) ...@@ -2429,8 +2421,8 @@ CreateOptsFile(int argc, char *argv[])
fp = fopen(filename, "w"); fp = fopen(filename, "w");
if (fp == NULL) if (fp == NULL)
{ {
fprintf(stderr, "%s: cannot create file %s: %s\n", progname, postmaster_error("cannot create file %s: %s",
filename, strerror(errno)); filename, strerror(errno));
return false; return false;
} }
...@@ -2441,7 +2433,7 @@ CreateOptsFile(int argc, char *argv[]) ...@@ -2441,7 +2433,7 @@ CreateOptsFile(int argc, char *argv[])
if (ferror(fp)) if (ferror(fp))
{ {
fprintf(stderr, "%s: writing file %s failed\n", progname, filename); postmaster_error("writing file %s failed", filename);
fclose(fp); fclose(fp);
return false; return false;
} }
...@@ -2449,3 +2441,16 @@ CreateOptsFile(int argc, char *argv[]) ...@@ -2449,3 +2441,16 @@ CreateOptsFile(int argc, char *argv[])
fclose(fp); fclose(fp);
return true; return true;
} }
static void
postmaster_error(const char *fmt, ...)
{
va_list ap;
fprintf(stderr, "%s: ", progname);
va_start(ap, fmt);
fprintf(stderr, gettext(fmt), ap);
va_end(ap);
fprintf(stderr, "\n");
}
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, 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: c.h,v 1.94 2001/06/02 18:25:18 petere Exp $ * $Id: c.h,v 1.95 2001/06/03 14:53:56 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -122,6 +122,9 @@ ...@@ -122,6 +122,9 @@
#define dummyret char #define dummyret char
#endif #endif
#ifndef __GNUC__
#define __attribute__(x)
#endif
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
* Section 2: bool, true, false, TRUE, FALSE, NULL * Section 2: bool, true, false, TRUE, FALSE, NULL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment