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.
This commit is contained in:
Peter Eisentraut 2001-06-03 14:53:56 +00:00
parent 277a47ad0f
commit 12c1552066
8 changed files with 1608 additions and 1545 deletions

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* 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);
static XLogRecord *ReadRecord(XLogRecPtr *RecPtr, int emode, char *buffer);
static bool ValidXLOGHeader(XLogPageHeader hdr, int emode, bool checkSUI);
static XLogRecord *ReadCheckpointRecord(XLogRecPtr RecPtr,
const char *whichChkpt,
int whichChkpt,
char *buffer);
static void WriteControlFile(void);
static void ReadControlFile(void);
@ -585,7 +585,7 @@ begin:;
* also remove the check for xl_len == 0 in ReadRecord, below.
*/
if (len == 0 || len > MAXLOGRECSZ)
elog(STOP, "XLogInsert: invalid record len %u", len);
elog(STOP, "XLogInsert: invalid record length %u", len);
START_CRIT_SECTION();
@ -749,7 +749,7 @@ begin:;
strcat(buf, " - ");
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 */
@ -1004,7 +1004,7 @@ XLogWrite(XLogwrtRqst WriteRqst)
if (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);
openLogFile = -1;
}
@ -1043,7 +1043,7 @@ XLogWrite(XLogwrtRqst WriteRqst)
(uint32) CheckPointSegments))
{
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);
}
}
@ -1062,14 +1062,14 @@ XLogWrite(XLogwrtRqst WriteRqst)
{
openLogOff = (LogwrtResult.Write.xrecoff - BLCKSZ) % XLogSegSize;
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);
}
/* OK to write the page */
from = XLogCtl->pages + Write->curridx * 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);
openLogOff += BLCKSZ;
@ -1113,7 +1113,7 @@ XLogWrite(XLogwrtRqst WriteRqst)
!XLByteInPrevSeg(LogwrtResult.Write, openLogId, openLogSeg))
{
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);
openLogFile = -1;
}
@ -1161,7 +1161,7 @@ XLogFlush(XLogRecPtr record)
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)" : "",
(InRedo) ? "(redo)" : "",
record.xlogid, record.xrecoff,
@ -1287,8 +1287,8 @@ XLogFileInit(uint32 log, uint32 seg,
if (fd < 0)
{
if (errno != ENOENT)
elog(STOP, "InitOpen(logfile %u seg %u) failed: %m",
log, seg);
elog(STOP, "open of %s (log file %u, segment %u) failed: %m",
path, log, seg);
}
else
return (fd);
@ -1309,7 +1309,7 @@ XLogFileInit(uint32 log, uint32 seg,
fd = BasicOpenFile(tmppath, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
S_IRUSR | S_IWUSR);
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
@ -1339,7 +1339,7 @@ XLogFileInit(uint32 log, uint32 seg,
}
if (pg_fsync(fd) != 0)
elog(STOP, "fsync(%s) failed: %m", tmppath);
elog(STOP, "fsync of file %s failed: %m", tmppath);
close(fd);
@ -1380,13 +1380,13 @@ XLogFileInit(uint32 log, uint32 seg,
*/
#ifndef __BEOS__
if (link(tmppath, targpath) < 0)
elog(STOP, "InitRelink(logfile %u seg %u) failed: %m",
targlog, targseg);
elog(STOP, "link from %s to %s (initialization of log file %u, segment %u) failed: %m",
tmppath, targpath, targlog, targseg);
unlink(tmppath);
#else
if (rename(tmppath, targpath) < 0)
elog(STOP, "InitRelink(logfile %u seg %u) failed: %m",
targlog, targseg);
elog(STOP, "rename from %s to %s (initialization of log file %u, segment %u) failed: %m",
tmppath, targpath targlog, targseg);
#endif
if (use_lock)
@ -1399,8 +1399,8 @@ XLogFileInit(uint32 log, uint32 seg,
fd = BasicOpenFile(path, O_RDWR | PG_BINARY | XLOG_SYNC_BIT,
S_IRUSR | S_IWUSR);
if (fd < 0)
elog(STOP, "InitReopen(logfile %u seg %u) failed: %m",
log, seg);
elog(STOP, "open of %s (log file %u, segment %u) failed: %m",
path, log, seg);
return (fd);
}
@ -1422,12 +1422,12 @@ XLogFileOpen(uint32 log, uint32 seg, bool econt)
{
if (econt && errno == ENOENT)
{
elog(LOG, "open(logfile %u seg %u) failed: %m",
log, seg);
elog(LOG, "open of %s (log file %u, segment %u) failed: %m",
path, log, seg);
return (fd);
}
elog(STOP, "open(logfile %u seg %u) failed: %m",
log, seg);
elog(STOP, "open of %s (log file %u, segment %u) failed: %m",
path, log, seg);
}
return (fd);
@ -1478,11 +1478,11 @@ MoveOfflineLogs(uint32 log, uint32 seg)
char lastoff[32];
char path[MAXPGPATH];
Assert(XLOG_archive_dir[0] == 0); /* ! implemented yet */
Assert(XLOG_archive_dir[0] == 0); /* not implemented yet */
xldir = opendir(XLogDir);
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);
@ -1493,8 +1493,11 @@ MoveOfflineLogs(uint32 log, uint32 seg)
strspn(xlde->d_name, "0123456789ABCDEF") == 16 &&
strcmp(xlde->d_name, lastoff) <= 0)
{
elog(LOG, "MoveOfflineLogs: %s %s", (XLOG_archive_dir[0]) ?
"archive" : "remove", xlde->d_name);
if (XLOG_archive_dir[0])
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);
if (XLOG_archive_dir[0] == 0)
unlink(path);
@ -1502,7 +1505,7 @@ MoveOfflineLogs(uint32 log, uint32 seg)
errno = 0;
}
if (errno)
elog(STOP, "MoveOfflineLogs: cannot read xlog dir: %m");
elog(STOP, "could not read transaction log directory (%s): %m", XLogDir);
closedir(xldir);
}
@ -1574,7 +1577,7 @@ RecordIsValid(XLogRecord *record, XLogRecPtr recptr, int emode)
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);
return (false);
}
@ -1596,7 +1599,7 @@ RecordIsValid(XLogRecord *record, XLogRecPtr recptr, int emode)
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);
return (false);
}
@ -1689,13 +1692,13 @@ ReadRecord(XLogRecPtr *RecPtr, int emode, char *buffer)
readOff = targetPageOff;
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);
goto next_record_is_invalid;
}
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);
goto next_record_is_invalid;
}
@ -1719,7 +1722,7 @@ got_record:;
*/
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);
goto next_record_is_invalid;
}
@ -1743,7 +1746,7 @@ got_record:;
*/
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);
goto next_record_is_invalid;
}
@ -1779,7 +1782,7 @@ got_record:;
}
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);
goto next_record_is_invalid;
}
@ -1787,7 +1790,7 @@ got_record:;
goto next_record_is_invalid;
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);
goto next_record_is_invalid;
}
@ -1795,7 +1798,7 @@ got_record:;
if (contrecord->xl_rem_len == 0 ||
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);
goto next_record_is_invalid;
}
@ -1857,13 +1860,13 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode, bool checkSUI)
{
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);
return false;
}
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);
return false;
}
@ -1883,7 +1886,8 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode, bool checkSUI)
if (hdr->xlp_sui < lastReadSUI ||
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);
return false;
}
@ -1936,11 +1940,11 @@ WriteControlFile(void)
#ifdef USE_LOCALE
localeptr = setlocale(LC_COLLATE, NULL);
if (!localeptr)
elog(STOP, "Invalid LC_COLLATE setting");
elog(STOP, "invalid LC_COLLATE setting");
StrNCpy(ControlFile->lc_collate, localeptr, LOCALE_NAME_BUFLEN);
localeptr = setlocale(LC_CTYPE, NULL);
if (!localeptr)
elog(STOP, "Invalid LC_CTYPE setting");
elog(STOP, "invalid LC_CTYPE setting");
StrNCpy(ControlFile->lc_ctype, localeptr, LOCALE_NAME_BUFLEN);
/*
@ -1955,10 +1959,10 @@ WriteControlFile(void)
"\n\tsuch queries, you may wish to set LC_COLLATE to \"C\" and"
"\n\tre-initdb. For more information see the Administrator's Guide.",
ControlFile->lc_collate);
#else
#else /* not USE_LOCALE */
strcpy(ControlFile->lc_collate, "C");
strcpy(ControlFile->lc_ctype, "C");
#endif
#endif /* not USE_LOCALE */
/* Contents are protected with a CRC */
INIT_CRC64(ControlFile->crc);
@ -1975,7 +1979,7 @@ WriteControlFile(void)
* specific error than "couldn't read pg_control".
*/
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);
memcpy(buffer, ControlFile, sizeof(ControlFileData));
@ -1983,14 +1987,14 @@ WriteControlFile(void)
fd = BasicOpenFile(ControlFilePath, O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
S_IRUSR | S_IWUSR);
if (fd < 0)
elog(STOP, "WriteControlFile failed to create control file (%s): %m",
elog(STOP, "WriteControlFile: could not create control file (%s): %m",
ControlFilePath);
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)
elog(STOP, "WriteControlFile failed to fsync control file: %m");
elog(STOP, "WriteControlFile: fsync of control file failed: %m");
close(fd);
}
@ -2006,10 +2010,10 @@ ReadControlFile(void)
*/
fd = BasicOpenFile(ControlFilePath, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR);
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))
elog(STOP, "read(\"%s\") failed: %m", ControlFilePath);
elog(STOP, "read from control file failed: %m");
close(fd);
@ -2020,7 +2024,10 @@ ReadControlFile(void)
* more enlightening than complaining about wrong CRC.
*/
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);
/* Now check the CRC. */
@ -2031,7 +2038,7 @@ ReadControlFile(void)
FIN_CRC64(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
@ -2046,27 +2053,45 @@ ReadControlFile(void)
* compatibility items because they can affect sort order of indexes.)
*/
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);
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);
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);
#ifdef USE_LOCALE
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);
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);
#else
#else /* not USE_LOCALE */
if (strcmp(ControlFile->lc_collate, "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);
#endif
#endif /* not USE_LOCALE */
}
void
@ -2082,13 +2107,13 @@ UpdateControlFile(void)
fd = BasicOpenFile(ControlFilePath, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR);
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))
elog(STOP, "write(cntlfile) failed: %m");
elog(STOP, "write to control file failed: %m");
if (pg_fsync(fd) != 0)
elog(STOP, "fsync(cntlfile) failed: %m");
elog(STOP, "fsync of control file failed: %m");
close(fd);
}
@ -2224,10 +2249,10 @@ BootStrapXLOG(void)
openLogFile = XLogFileInit(0, 0, &use_existent, false);
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)
elog(STOP, "BootStrapXLOG failed to fsync logfile: %m");
elog(STOP, "BootStrapXLOG failed to fsync log file: %m");
close(openLogFile);
openLogFile = -1;
@ -2302,7 +2327,7 @@ StartupXLOG(void)
else if (ControlFile->state == DB_IN_RECOVERY)
elog(LOG, "database system was interrupted being in recovery at %s\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));
else if (ControlFile->state == DB_IN_PRODUCTION)
elog(LOG, "database system was interrupted at %s",
@ -2312,41 +2337,40 @@ StartupXLOG(void)
* Get the last valid checkpoint record. If the latest one according
* to pg_control is broken, try the next-to-last one.
*/
record = ReadCheckpointRecord(ControlFile->checkPoint,
"primary", buffer);
record = ReadCheckpointRecord(ControlFile->checkPoint, 1, buffer);
if (record != NULL)
{
checkPointLoc = ControlFile->checkPoint;
elog(LOG, "CheckPoint record at (%u, %u)",
elog(LOG, "checkpoint record is at (%u, %u)",
checkPointLoc.xlogid, checkPointLoc.xrecoff);
}
else
{
record = ReadCheckpointRecord(ControlFile->prevCheckPoint,
"secondary", buffer);
record = ReadCheckpointRecord(ControlFile->prevCheckPoint, 2, buffer);
if (record != NULL)
{
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);
InRecovery = true; /* force recovery even if SHUTDOWNED */
}
else
elog(STOP, "Unable to locate a valid CheckPoint record");
elog(STOP, "unable to locate a valid checkpoint record");
}
LastRec = RecPtr = checkPointLoc;
memcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint));
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.undo.xlogid, checkPoint.undo.xrecoff,
wasShutdown ? "TRUE" : "FALSE");
elog(LOG, "NextTransactionId: %u; NextOid: %u",
elog(LOG, "next transaction id: %u; next oid: %u",
checkPoint.nextXid, checkPoint.nextOid);
if (checkPoint.nextXid < FirstTransactionId ||
checkPoint.nextOid < BootstrapObjectIdData)
elog(STOP, "Invalid NextTransactionId/NextOid");
if (checkPoint.nextXid < FirstTransactionId)
elog(STOP, "invalid next transaction id");
if (checkPoint.nextOid < BootstrapObjectIdData)
elog(STOP, "invalid next oid");
ShmemVariableCache->nextXid = checkPoint.nextXid;
ShmemVariableCache->nextOid = checkPoint.nextOid;
@ -2357,7 +2381,7 @@ StartupXLOG(void)
XLogCtl->RedoRecPtr = 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)
checkPoint.undo = RecPtr;
@ -2365,7 +2389,7 @@ StartupXLOG(void)
XLByteLT(checkPoint.redo, RecPtr))
{
if (wasShutdown)
elog(STOP, "Invalid Redo/Undo record in shutdown checkpoint");
elog(STOP, "invalid redo/undo record in shutdown checkpoint");
InRecovery = true;
}
else if (ControlFile->state != DB_SHUTDOWNED)
@ -2375,7 +2399,7 @@ StartupXLOG(void)
if (InRecovery)
{
elog(LOG, "database system was not properly shut down; "
"automatic recovery in progress...");
"automatic recovery in progress");
ControlFile->state = DB_IN_RECOVERY;
ControlFile->time = time(NULL);
UpdateControlFile();
@ -2410,7 +2434,7 @@ StartupXLOG(void)
strcat(buf, " - ");
RmgrTable[record->xl_rmid].rm_desc(buf,
record->xl_info, XLogRecGetData(record));
fprintf(stderr, "%s\n", buf);
elog(DEBUG, "%s", buf);
}
if (record->xl_info & XLR_BKP_BLOCK_MASK)
@ -2548,7 +2572,7 @@ StartupXLOG(void)
ThisStartUpID++;
XLogCtl->ThisStartUpID = ThisStartUpID;
elog(LOG, "database system is in production state");
elog(LOG, "database system is ready");
CritSectionCount--;
/* Shut down readFile facility, free space */
@ -2566,17 +2590,22 @@ StartupXLOG(void)
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 *
ReadCheckpointRecord(XLogRecPtr RecPtr,
const char *whichChkpt,
int whichChkpt,
char *buffer)
{
XLogRecord *record;
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;
}
@ -2584,23 +2613,31 @@ ReadCheckpointRecord(XLogRecPtr RecPtr,
if (record == NULL)
{
elog(LOG, "Invalid %s checkPoint record", whichChkpt);
elog(LOG, (whichChkpt == 1 ?
"invalid primary checkpoint record" :
"invalid secondary checkpoint record"));
return NULL;
}
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;
}
if (record->xl_info != XLOG_CHECKPOINT_SHUTDOWN &&
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;
}
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 record;
@ -2768,7 +2805,7 @@ CreateCheckPoint(bool shutdown)
checkPoint.undo = GetUndoRecPtr();
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
@ -2812,7 +2849,7 @@ CreateCheckPoint(bool shutdown)
* recptr = end of actual checkpoint record.
*/
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
@ -3041,7 +3078,7 @@ assign_xlog_sync_method(const char *method)
else
{
/* 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_bit = 0;
}
@ -3058,12 +3095,12 @@ assign_xlog_sync_method(const char *method)
if (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);
if (open_sync_bit != new_sync_bit)
{
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);
openLogFile = -1;
}
@ -3084,13 +3121,13 @@ issue_xlog_fsync(void)
{
case SYNC_METHOD_FSYNC:
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);
break;
#ifdef HAVE_FDATASYNC
case SYNC_METHOD_FDATASYNC:
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);
break;
#endif
@ -3098,7 +3135,7 @@ issue_xlog_fsync(void)
/* write synced it already */
break;
default:
elog(STOP, "bogus sync_method %d", sync_method);
elog(STOP, "bogus wal_sync_method %d", sync_method);
break;
}
}

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* 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)
static void
usage(void)
{
fprintf(stderr, "Usage:\n postgres -boot [-d] [-D datadir] [-F] [-x num] dbname\n");
fprintf(stderr, " -d debug mode\n");
fprintf(stderr, " -D datadir data directory\n");
fprintf(stderr, " -F turn off fsync\n");
fprintf(stderr, " -x num internal use\n");
fprintf(stderr,
gettext("Usage:\n"
" postgres -boot [-d] [-D datadir] [-F] [-x num] dbname\n"
" -d debug mode\n"
" -D datadir data directory\n"
" -F turn off fsync\n"
" -x num internal use\n"));
proc_exit(1);
}
@ -286,10 +288,11 @@ BootstrapMain(int argc, char *argv[])
{
if (!potential_DataDir)
{
fprintf(stderr, "%s does not know where to find the database system "
"data. You must specify the directory that contains the "
"database system either by specifying the -D invocation "
"option or by setting the PGDATA environment variable.\n\n",
fprintf(stderr,
gettext("%s does not know where to find the database system data.\n"
"You must specify the directory that contains the database system\n"
"either by specifying the -D invocation option or by setting the\n"
"PGDATA environment variable.\n\n"),
argv[0]);
proc_exit(1);
}

View File

@ -13,7 +13,7 @@
*
*
* 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 @@
#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
main(int argc, char *argv[])
@ -87,7 +81,7 @@ main(int argc, char *argv[])
#if defined(__alpha)
if (setsysinfo(SSI_NVPAIRS, buffer, 1, (caddr_t) NULL,
(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 /* NOFIXADE || NOPRINTADE */
@ -129,7 +123,12 @@ main(int argc, char *argv[])
#ifndef __BEOS__
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);
}
#endif /* __BEOS__ */
@ -145,7 +144,7 @@ main(int argc, char *argv[])
*/
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]);
exit(1);
}
@ -194,7 +193,7 @@ main(int argc, char *argv[])
pw = getpwuid(geteuid());
if (pw == NULL)
{
fprintf(stderr, "%s: invalid current euid %d\n",
fprintf(stderr, gettext("%s: invalid current euid %d\n"),
argv[0], (int) geteuid());
exit(1);
}

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* 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)
#if defined(ERX) && defined(GEQO_DEBUG)
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
fprintf(stdout, "No edge failures detected.\n");
elog(DEBUG, "[GEQO] No edge failures detected.");
#endif
#if defined(CX) && defined(GEQO_DEBUG)
if (mutations != 0)
fprintf(stdout, "\nMutations: %d Generations: %d\n", mutations, generation);
elog(DEBUG, "[GEQO] mutations: %d, generations: %d", mutations, generation);
else
fprintf(stdout, "No mutations processed.\n");
elog(DEBUG, "[GEQO] No mutations processed.");
#endif
#ifdef GEQO_DEBUG
fprintf(stdout, "\n");
print_pool(stdout, pool, 0, pool_size - 1);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
CATALOG_NAME := postgres
AVAIL_LANGUAGES := de
GETTEXT_FILES := + gettext-files
GETTEXT_TRIGGERS:= elog:2
GETTEXT_TRIGGERS:= elog:2 postmaster_error

View File

@ -28,7 +28,7 @@
*
*
* 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
*
@ -243,6 +243,7 @@ static void RandomSalt(char *salt);
static void SignalChildren(int signal);
static int CountChildren(void);
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);
@ -264,10 +265,11 @@ checkDataDir(const char *checkdir)
if (checkdir == NULL)
{
fprintf(stderr, "%s does not know where to find the database system "
"data. You must specify the directory that contains the "
"database system either by specifying the -D invocation "
"option or by setting the PGDATA environment variable.\n\n",
fprintf(stderr, gettext(
"%s does not know where to find the database system data.\n"
"You must specify the directory that contains the database system\n"
"either by specifying the -D invocation option or by setting the\n"
"PGDATA environment variable.\n\n"),
progname);
ExitPostmaster(2);
}
@ -277,9 +279,10 @@ checkDataDir(const char *checkdir)
fp = AllocateFile(path, PG_BINARY_R);
if (fp == NULL)
{
fprintf(stderr, "%s does not find the database system."
"\n\tExpected to find it in the PGDATA directory \"%s\","
"\n\tbut unable to open file \"%s\": %s\n\n",
fprintf(stderr, gettext(
"%s does not find the database system.\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));
ExitPostmaster(2);
}
@ -381,7 +384,7 @@ PostmasterMain(int argc, char *argv[])
break;
case '?':
fprintf(stderr, "Try '%s --help' for more information.\n", progname);
fprintf(stderr, gettext("Try '%s --help' for more information.\n"), progname);
ExitPostmaster(1);
}
}
@ -391,8 +394,8 @@ PostmasterMain(int argc, char *argv[])
*/
if (optind < argc)
{
fprintf(stderr, "%s: invalid argument -- %s\n", progname, argv[optind]);
fprintf(stderr, "Try '%s --help' for more information.\n", progname);
postmaster_error("invalid argument -- %s", argv[optind]);
fprintf(stderr, gettext("Try '%s --help' for more information.\n"), progname);
ExitPostmaster(1);
}
@ -413,7 +416,7 @@ PostmasterMain(int argc, char *argv[])
{
case 'A':
#ifndef USE_ASSERT_CHECKING
fprintf(stderr, "Assert checking is not compiled in\n");
postmaster_error("Assert checking is not compiled in.");
#else
assert_enabled = atoi(optarg);
#endif
@ -539,7 +542,7 @@ PostmasterMain(int argc, char *argv[])
default:
/* 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);
}
}
@ -555,8 +558,7 @@ PostmasterMain(int argc, char *argv[])
* for lack of buffers. The specific choices here are somewhat
* 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",
progname);
postmaster_error("The number of buffers (-B) must be at least twice the number of allowed connections (-N) and at least 16.");
ExitPostmaster(1);
}
@ -600,8 +602,8 @@ PostmasterMain(int argc, char *argv[])
#ifdef USE_SSL
if (EnableSSL && !NetServer)
{
fprintf(stderr, "%s: For SSL, TCP/IP connections must be enabled. See -? for help.\n",
progname);
postmaster_error("For SSL, TCP/IP connections must be enabled.");
fprintf(stderr, gettext("Try '%s --help' for more information.\n"), progname);
ExitPostmaster(1);
}
if (EnableSSL)
@ -615,8 +617,7 @@ PostmasterMain(int argc, char *argv[])
&ServerSock_INET);
if (status != STATUS_OK)
{
fprintf(stderr, "%s: cannot create INET stream port\n",
progname);
postmaster_error("cannot create INET stream port");
ExitPostmaster(1);
}
}
@ -627,8 +628,7 @@ PostmasterMain(int argc, char *argv[])
&ServerSock_UNIX);
if (status != STATUS_OK)
{
fprintf(stderr, "%s: cannot create UNIX stream port\n",
progname);
postmaster_error("cannot create UNIX stream port");
ExitPostmaster(1);
}
#endif
@ -701,7 +701,7 @@ pmdaemonize(int argc, char *argv[])
pid = fork();
if (pid == (pid_t) -1)
{
perror("Failed to fork postmaster");
postmaster_error("fork failed: %s", strerror(errno));
ExitPostmaster(1);
return; /* not reached */
}
@ -719,8 +719,8 @@ pmdaemonize(int argc, char *argv[])
#ifdef HAVE_SETSID
if (setsid() < 0)
{
fprintf(stderr, "%s: ", progname);
perror("cannot disassociate from controlling TTY");
postmaster_error("cannot disassociate from controlling TTY: %s",
strerror(errno));
ExitPostmaster(1);
}
#endif
@ -739,38 +739,37 @@ pmdaemonize(int argc, char *argv[])
static void
usage(const char *progname)
{
printf("%s is the PostgreSQL server.\n\n", progname);
printf("Usage:\n %s [options...]\n\n", progname);
printf("Options:\n");
printf(gettext("%s is the PostgreSQL server.\n\n"), progname);
printf(gettext("Usage:\n %s [options...]\n\n"), progname);
printf(gettext("Options:\n"));
#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
printf(" -B NBUFFERS number of shared buffers (default %d)\n", DEF_NBUFFERS);
printf(" -c NAME=VALUE set run-time parameter\n");
printf(" -d 1-5 debugging level\n");
printf(" -D DATADIR database directory\n");
printf(" -F turn fsync off\n");
printf(" -h HOSTNAME host name or IP address to listen on\n");
printf(" -i enable TCP/IP connections\n");
printf(" -k DIRECTORY Unix-domain socket location\n");
printf(gettext(" -B NBUFFERS number of shared buffers (default %d)\n"), DEF_NBUFFERS);
printf(gettext(" -c NAME=VALUE set run-time parameter\n"));
printf(gettext(" -d 1-5 debugging level\n"));
printf(gettext(" -D DATADIR database directory\n"));
printf(gettext(" -F turn fsync off\n"));
printf(gettext(" -h HOSTNAME host name or IP address to listen on\n"));
printf(gettext(" -i enable TCP/IP connections\n"));
printf(gettext(" -k DIRECTORY Unix-domain socket location\n"));
#ifdef USE_SSL
printf(" -l enable SSL connections\n");
printf(gettext(" -l enable SSL connections\n"));
#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);
printf(" -o OPTIONS pass 'OPTIONS' to each backend server\n");
printf(" -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(" -o OPTIONS pass 'OPTIONS' to each backend server\n"));
printf(gettext(" -p PORT port number to listen on (default %d)\n"), DEF_PGPORT);
printf(gettext(" -S silent mode (start in background without logging output)\n"));
printf("\nDeveloper options:\n");
printf(" -n do not reinitialize shared memory after abnormal exit\n");
printf(" -s send SIGSTOP to all backend servers if one dies\n");
printf(gettext("\nDeveloper options:\n"));
printf(gettext(" -n do not reinitialize shared memory after abnormal exit\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"
"configuration settings and how to set them on the command line or in\n"
"the configuration file.\n\n");
printf("Report bugs to <pgsql-bugs@postgresql.org>.\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"
"the configuration file.\n\n"
"Report bugs to <pgsql-bugs@postgresql.org>.\n"));
}
static int
@ -860,8 +859,7 @@ ServerLoop(void)
PG_SETMASK(&BlockSig);
if (errno == EINTR || errno == EWOULDBLOCK)
continue;
fprintf(stderr, "%s: ServerLoop: select failed: %s\n",
progname, strerror(errno));
postmaster_error("ServerLoop: select failed: %s", strerror(errno));
return STATUS_ERROR;
}
@ -941,8 +939,7 @@ ServerLoop(void)
)
{
if (DebugLvl > 1)
fprintf(stderr, "%s: ServerLoop:\t\thandling reading %d\n",
progname, port->sock);
postmaster_error("ServerLoop: handling reading %d", port->sock);
if (PacketReceiveFragment(port) != STATUS_OK)
status = STATUS_ERROR;
@ -951,8 +948,7 @@ ServerLoop(void)
if (FD_ISSET(port->sock, &wmask))
{
if (DebugLvl > 1)
fprintf(stderr, "%s: ServerLoop:\t\thandling writing %d\n",
progname, port->sock);
postmaster_error("ServerLoop: handling writing %d", port->sock);
if (PacketSendFragment(port) != STATUS_OK)
status = STATUS_ERROR;
@ -1100,7 +1096,8 @@ readStartupPacket(void *arg, PacketLen len, void *pkt)
#endif
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 */
}
@ -1111,8 +1108,8 @@ readStartupPacket(void *arg, PacketLen len, void *pkt)
!SSL_set_fd(port->ssl, port->sock) ||
SSL_accept(port->ssl) <= 0)
{
fprintf(stderr, "Failed to initialize SSL connection: %s, errno: %d (%s)\n",
ERR_reason_error_string(ERR_get_error()), errno, strerror(errno));
postmaster_error("failed to initialize SSL connection: %s, errno: %d (%s)",
ERR_reason_error_string(ERR_get_error()), errno, strerror(errno));
return STATUS_ERROR;
}
}
@ -1216,8 +1213,7 @@ processCancelRequest(Port *port, PacketLen len, void *pkt)
if (backendPID == CheckPointPID)
{
if (DebugLvl)
fprintf(stderr, "%s: processCancelRequest: CheckPointPID in cancel request for process %d\n",
progname, backendPID);
postmaster_error("processCancelRequest: CheckPointPID in cancel request for process %d", backendPID);
return STATUS_ERROR;
}
@ -1232,16 +1228,14 @@ processCancelRequest(Port *port, PacketLen len, void *pkt)
{
/* Found a match; signal that backend to cancel current op */
if (DebugLvl)
fprintf(stderr, "%s: processCancelRequest: sending SIGINT to process %d\n",
progname, bp->pid);
postmaster_error("processCancelRequest: sending SIGINT to process %d", bp->pid);
kill(bp->pid, SIGINT);
}
else
{
/* Right PID, wrong key: no way, Jose */
if (DebugLvl)
fprintf(stderr, "%s: processCancelRequest: bad key in cancel request for process %d\n",
progname, bp->pid);
postmaster_error("processCancelRequest: bad key in cancel request for process %d", bp->pid);
}
return STATUS_ERROR;
}
@ -1249,8 +1243,7 @@ processCancelRequest(Port *port, PacketLen len, void *pkt)
/* No matching backend */
if (DebugLvl)
fprintf(stderr, "%s: processCancelRequest: bad PID in cancel request for process %d\n",
progname, backendPID);
postmaster_error("processCancelRequest: bad PID in cancel request for process %d", backendPID);
return STATUS_ERROR;
}
@ -1288,8 +1281,7 @@ ConnCreate(int serverFd)
if (!(port = (Port *) calloc(1, sizeof(Port))))
{
fprintf(stderr, "%s: ConnCreate: malloc failed\n",
progname);
postmaster_error("ConnCreate: malloc failed");
SignalChildren(SIGQUIT);
ExitPostmaster(1);
}
@ -1452,7 +1444,7 @@ pmdie(SIGNAL_ARGS)
}
Shutdown = SmartShutdown;
tnow = time(NULL);
fprintf(stderr, "Smart Shutdown request at %s", ctime(&tnow));
fprintf(stderr, gettext("Smart Shutdown request at %s"), ctime(&tnow));
fflush(stderr);
if (DLGetHead(BackendList)) /* let reaper() handle this */
{
@ -1490,14 +1482,14 @@ pmdie(SIGNAL_ARGS)
return;
}
tnow = time(NULL);
fprintf(stderr, "Fast Shutdown request at %s", ctime(&tnow));
fprintf(stderr, gettext("Fast Shutdown request at %s"), ctime(&tnow));
fflush(stderr);
if (DLGetHead(BackendList)) /* let reaper() handle this */
{
Shutdown = FastShutdown;
if (!FatalError)
{
fprintf(stderr, "Aborting any active transaction...\n");
fprintf(stderr, gettext("Aborting any active transaction...\n"));
fflush(stderr);
SignalChildren(SIGTERM);
}
@ -1537,7 +1529,7 @@ pmdie(SIGNAL_ARGS)
* properly shutdown data base system.
*/
tnow = time(NULL);
fprintf(stderr, "Immediate Shutdown request at %s", ctime(&tnow));
fprintf(stderr, gettext("Immediate Shutdown request at %s"), ctime(&tnow));
fflush(stderr);
if (ShutdownPID > 0)
kill(ShutdownPID, SIGQUIT);
@ -1575,8 +1567,7 @@ reaper(SIGNAL_ARGS)
pqsignal(SIGCHLD, reaper);
if (DebugLvl)
fprintf(stderr, "%s: reaping dead processes...\n",
progname);
postmaster_error("reaping dead processes");
#ifdef HAVE_WAITPID
while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
{
@ -1592,8 +1583,7 @@ reaper(SIGNAL_ARGS)
abort();
if (exitstatus != 0)
{
fprintf(stderr, "%s: Shutdown proc %d exited with status %d\n",
progname, pid, exitstatus);
postmaster_error("Shutdown proc %d exited with status %d", pid, exitstatus);
fflush(stderr);
ExitPostmaster(1);
}
@ -1605,8 +1595,8 @@ reaper(SIGNAL_ARGS)
abort();
if (exitstatus != 0)
{
fprintf(stderr, "%s: Startup proc %d exited with status %d - abort\n",
progname, pid, exitstatus);
postmaster_error("Startup proc %d exited with status %d - abort",
pid, exitstatus);
fflush(stderr);
ExitPostmaster(1);
}
@ -1649,8 +1639,8 @@ reaper(SIGNAL_ARGS)
return;
}
tnow = time(NULL);
fprintf(stderr, "Server processes were terminated at %s"
"Reinitializing shared memory and semaphores\n",
fprintf(stderr, gettext("Server processes were terminated at %s"
"Reinitializing shared memory and semaphores\n"),
ctime(&tnow));
fflush(stderr);
@ -1696,8 +1686,8 @@ CleanupProc(int pid,
Backend *bp;
if (DebugLvl)
fprintf(stderr, "%s: CleanupProc: pid %d exited with status %d\n",
progname, pid, exitstatus);
postmaster_error("CleanupProc: pid %d exited with status %d",
pid, exitstatus);
/*
* If a backend dies in an ugly way (i.e. exit status not 0) then we
@ -1745,8 +1735,8 @@ CleanupProc(int pid,
{
/* Make log entry unless we did so already */
tnow = time(NULL);
fprintf(stderr, "Server process (pid %d) exited with status %d at %s"
"Terminating any active server processes...\n",
fprintf(stderr, gettext("Server process (pid %d) exited with status %d at %s"
"Terminating any active server processes...\n"),
pid, exitstatus, ctime(&tnow));
fflush(stderr);
}
@ -1771,10 +1761,9 @@ CleanupProc(int pid,
if (!FatalError)
{
if (DebugLvl)
fprintf(stderr, "%s: CleanupProc: sending %s to process %d\n",
progname,
(SendStop ? "SIGSTOP" : "SIGQUIT"),
bp->pid);
postmaster_error("CleanupProc: sending %s to process %d",
(SendStop ? "SIGSTOP" : "SIGQUIT"),
bp->pid);
kill(bp->pid, (SendStop ? SIGSTOP : SIGQUIT));
}
}
@ -1895,7 +1884,7 @@ BackendStartup(Port *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());
ExitPostmaster(1);
}
@ -1910,13 +1899,13 @@ BackendStartup(Port *port)
/* Specific beos backend startup actions */
beos_backend_startup_failed();
#endif
fprintf(stderr, "%s: BackendStartup: fork failed: %s\n",
fprintf(stderr, gettext("%s: BackendStartup: fork failed: %s\n"),
progname, strerror(errno));
return STATUS_ERROR;
}
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,
port->sock);
@ -1926,7 +1915,7 @@ BackendStartup(Port *port)
*/
if (!(bn = (Backend *) calloc(1, sizeof(Backend))))
{
fprintf(stderr, "%s: BackendStartup: malloc failed\n",
fprintf(stderr, gettext("%s: BackendStartup: malloc failed\n"),
progname);
ExitPostmaster(1);
}
@ -2269,24 +2258,28 @@ InitSSL(void)
SSL_context = SSL_CTX_new(SSLv23_method());
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);
}
snprintf(fnbuf, sizeof(fnbuf), "%s/server.crt", DataDir);
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);
}
snprintf(fnbuf, sizeof(fnbuf), "%s/server.key", DataDir);
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);
}
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);
}
}
@ -2388,8 +2381,7 @@ SSDataBase(int xlop)
{
if (!(bn = (Backend *) calloc(1, sizeof(Backend))))
{
fprintf(stderr, "%s: CheckPointDataBase: malloc failed\n",
progname);
postmaster_error("CheckPointDataBase: malloc failed");
ExitPostmaster(1);
}
@ -2429,8 +2421,8 @@ CreateOptsFile(int argc, char *argv[])
fp = fopen(filename, "w");
if (fp == NULL)
{
fprintf(stderr, "%s: cannot create file %s: %s\n", progname,
filename, strerror(errno));
postmaster_error("cannot create file %s: %s",
filename, strerror(errno));
return false;
}
@ -2441,7 +2433,7 @@ CreateOptsFile(int argc, char *argv[])
if (ferror(fp))
{
fprintf(stderr, "%s: writing file %s failed\n", progname, filename);
postmaster_error("writing file %s failed", filename);
fclose(fp);
return false;
}
@ -2449,3 +2441,16 @@ CreateOptsFile(int argc, char *argv[])
fclose(fp);
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");
}

View File

@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* 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 @@
#define dummyret char
#endif
#ifndef __GNUC__
#define __attribute__(x)
#endif
/* ----------------------------------------------------------------
* Section 2: bool, true, false, TRUE, FALSE, NULL