1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-12 05:01:15 +03:00

Error message editing in backend/storage.

This commit is contained in:
Tom Lane
2003-07-24 22:04:15 +00:00
parent 658fca8d3a
commit cfa191f3b8
25 changed files with 425 additions and 320 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.94 2003/01/07 01:19:12 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.95 2003/07/24 22:04:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -249,7 +249,7 @@ mdextend(Relation reln, BlockNumber blocknum, char *buffer)
seekpos = (long) (BLCKSZ * (blocknum % ((BlockNumber) RELSEG_SIZE)));
#ifdef DIAGNOSTIC
if (seekpos >= BLCKSZ * RELSEG_SIZE)
elog(FATAL, "seekpos too big!");
elog(FATAL, "seekpos too big");
#endif
#else
seekpos = (long) (BLCKSZ * (blocknum));
@@ -284,7 +284,7 @@ mdextend(Relation reln, BlockNumber blocknum, char *buffer)
#ifndef LET_OS_MANAGE_FILESIZE
#ifdef DIAGNOSTIC
if (_mdnblocks(v->mdfd_vfd, BLCKSZ) > ((BlockNumber) RELSEG_SIZE))
elog(FATAL, "segment too big!");
elog(FATAL, "segment too big");
#endif
#endif
@@ -338,7 +338,7 @@ mdopen(Relation reln)
#ifdef DIAGNOSTIC
if (_mdnblocks(fd, BLCKSZ) > ((BlockNumber) RELSEG_SIZE))
elog(FATAL, "segment too big on relopen!");
elog(FATAL, "segment too big");
#endif
#endif
@@ -421,7 +421,7 @@ mdread(Relation reln, BlockNumber blocknum, char *buffer)
#ifdef DIAGNOSTIC
if (seekpos >= BLCKSZ * RELSEG_SIZE)
elog(FATAL, "seekpos too big!");
elog(FATAL, "seekpos too big");
#endif
#else
seekpos = (long) (BLCKSZ * (blocknum));
@@ -468,7 +468,7 @@ mdwrite(Relation reln, BlockNumber blocknum, char *buffer)
seekpos = (long) (BLCKSZ * (blocknum % ((BlockNumber) RELSEG_SIZE)));
#ifdef DIAGNOSTIC
if (seekpos >= BLCKSZ * RELSEG_SIZE)
elog(FATAL, "seekpos too big!");
elog(FATAL, "seekpos too big");
#endif
#else
seekpos = (long) (BLCKSZ * (blocknum));
@@ -507,7 +507,7 @@ mdblindwrt(RelFileNode rnode,
seekpos = (long) (BLCKSZ * (blkno % ((BlockNumber) RELSEG_SIZE)));
#ifdef DIAGNOSTIC
if (seekpos >= BLCKSZ * RELSEG_SIZE)
elog(FATAL, "seekpos too big!");
elog(FATAL, "seekpos too big");
#endif
#else
seekpos = (long) (BLCKSZ * (blkno));
@@ -516,7 +516,7 @@ mdblindwrt(RelFileNode rnode,
errno = 0;
if (lseek(fd, seekpos, SEEK_SET) != seekpos)
{
elog(LOG, "mdblindwrt: lseek(%ld) failed: %m", seekpos);
elog(LOG, "lseek(%ld) failed: %m", seekpos);
close(fd);
return SM_FAIL;
}
@@ -530,13 +530,13 @@ mdblindwrt(RelFileNode rnode,
/* if write didn't set errno, assume problem is no disk space */
if (errno == 0)
errno = ENOSPC;
elog(LOG, "mdblindwrt: write() failed: %m");
elog(LOG, "write() failed: %m");
status = SM_FAIL;
}
if (close(fd) < 0)
{
elog(LOG, "mdblindwrt: close() failed: %m");
elog(LOG, "close() failed: %m");
status = SM_FAIL;
}
@@ -551,7 +551,7 @@ mdblindwrt(RelFileNode rnode,
* called, then only segments up to the last one actually touched
* are present in the chain...
*
* Returns # of blocks, elog's on error.
* Returns # of blocks, ereport's on error.
*/
BlockNumber
mdnblocks(Relation reln)
@@ -588,7 +588,7 @@ mdnblocks(Relation reln)
{
nblocks = _mdnblocks(v->mdfd_vfd, BLCKSZ);
if (nblocks > ((BlockNumber) RELSEG_SIZE))
elog(FATAL, "segment too big in mdnblocks!");
elog(FATAL, "segment too big");
if (nblocks < ((BlockNumber) RELSEG_SIZE))
return (segno * ((BlockNumber) RELSEG_SIZE)) + nblocks;
@@ -608,7 +608,7 @@ mdnblocks(Relation reln)
*/
v->mdfd_chain = _mdfd_openseg(reln, segno, O_CREAT);
if (v->mdfd_chain == (MdfdVec *) NULL)
elog(ERROR, "cannot count blocks for %s -- open failed: %m",
elog(ERROR, "could not count blocks for \"%s\": %m",
RelationGetRelationName(reln));
}
@@ -855,7 +855,7 @@ _mdfd_openseg(Relation reln, BlockNumber segno, int oflags)
#ifdef DIAGNOSTIC
if (_mdnblocks(fd, BLCKSZ) > ((BlockNumber) RELSEG_SIZE))
elog(FATAL, "segment too big on openseg!");
elog(FATAL, "segment too big");
#endif
#endif
@@ -874,7 +874,7 @@ _mdfd_getrelnfd(Relation reln)
if (fd < 0)
{
if ((fd = mdopen(reln)) < 0)
elog(ERROR, "_mdfd_getrelnfd: cannot open relation %s: %m",
elog(ERROR, "could not open relation \"%s\": %m",
RelationGetRelationName(reln));
reln->rd_fd = fd;
}
@@ -917,7 +917,7 @@ _mdfd_getseg(Relation reln, BlockNumber blkno)
v->mdfd_chain = _mdfd_openseg(reln, i, (segno == 1) ? O_CREAT : 0);
if (v->mdfd_chain == (MdfdVec *) NULL)
elog(ERROR, "cannot open segment %u of relation %s (target block %u): %m",
elog(ERROR, "could not open segment %u of relation \"%s\" (target block %u): %m",
i, RelationGetRelationName(reln), blkno);
}
v = v->mdfd_chain;
@@ -970,7 +970,7 @@ _mdfd_blind_getseg(RelFileNode rnode, BlockNumber blkno)
/* call fd.c to allow other FDs to be closed if needed */
fd = BasicOpenFile(path, O_RDWR | PG_BINARY, 0600);
if (fd < 0)
elog(LOG, "_mdfd_blind_getseg: couldn't open %s: %m", path);
elog(LOG, "could not open \"%s\": %m", path);
pfree(path);

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.32 2002/08/06 02:36:34 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.33 2003/07/24 22:04:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -186,7 +186,9 @@ mmcreate(Relation reln)
if (entry == (MMRelHashEntry *) NULL)
{
LWLockRelease(MMCacheLock);
elog(FATAL, "main memory storage mgr hash table out of memory");
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
}
if (found)
@@ -229,7 +231,7 @@ mmunlink(RelFileNode rnode)
if (entry == (MMHashEntry *) NULL)
{
LWLockRelease(MMCacheLock);
elog(FATAL, "mmunlink: cache hash table corrupted");
elog(FATAL, "cache hash table corrupted");
}
MMBlockTags[i].mmct_dbid = (Oid) 0;
MMBlockTags[i].mmct_relid = (Oid) 0;
@@ -246,7 +248,7 @@ mmunlink(RelFileNode rnode)
if (rentry == (MMRelHashEntry *) NULL)
{
LWLockRelease(MMCacheLock);
elog(FATAL, "mmunlink: rel cache hash table corrupted");
elog(FATAL, "rel cache hash table corrupted");
}
(*MMCurRelno)--;
@@ -309,7 +311,7 @@ mmextend(Relation reln, BlockNumber blocknum, char *buffer)
if (rentry == (MMRelHashEntry *) NULL)
{
LWLockRelease(MMCacheLock);
elog(FATAL, "mmextend: rel cache hash table corrupt");
elog(FATAL, "rel cache hash table corrupted");
}
tag.mmct_blkno = rentry->mmrhe_nblocks;
@@ -320,7 +322,7 @@ mmextend(Relation reln, BlockNumber blocknum, char *buffer)
if (entry == (MMHashEntry *) NULL || found)
{
LWLockRelease(MMCacheLock);
elog(FATAL, "mmextend: cache hash table corrupt");
elog(FATAL, "cache hash table corrupted");
}
entry->mmhe_bufno = i;
@@ -431,7 +433,7 @@ mmwrite(Relation reln, BlockNumber blocknum, char *buffer)
if (entry == (MMHashEntry *) NULL)
{
LWLockRelease(MMCacheLock);
elog(FATAL, "mmwrite: hash table missing requested page");
elog(FATAL, "cache hash table missing requested page");
}
offset = (entry->mmhe_bufno * BLCKSZ);

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.62 2003/03/04 21:51:21 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.63 2003/07/24 22:04:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -129,7 +129,7 @@ smgrinit(void)
if (smgrsw[i].smgr_init)
{
if ((*(smgrsw[i].smgr_init)) () == SM_FAIL)
elog(FATAL, "initialization failed on %s: %m",
elog(FATAL, "smgr initialization failed on %s: %m",
DatumGetCString(DirectFunctionCall1(smgrout,
Int16GetDatum(i))));
}
@@ -151,7 +151,7 @@ smgrshutdown(void)
if (smgrsw[i].smgr_shutdown)
{
if ((*(smgrsw[i].smgr_shutdown)) () == SM_FAIL)
elog(FATAL, "shutdown failed on %s: %m",
elog(FATAL, "smgr shutdown failed on %s: %m",
DatumGetCString(DirectFunctionCall1(smgrout,
Int16GetDatum(i))));
}
@@ -171,7 +171,10 @@ smgrcreate(int16 which, Relation reln)
PendingRelDelete *pending;
if ((fd = (*(smgrsw[which].smgr_create)) (reln)) < 0)
elog(ERROR, "cannot create %s: %m", RelationGetRelationName(reln));
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not create \"%s\": %m",
RelationGetRelationName(reln))));
/* Add the relation to the list of stuff to delete at abort */
pending = (PendingRelDelete *)
@@ -243,8 +246,11 @@ smgrextend(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
status = (*(smgrsw[which].smgr_extend)) (reln, blocknum, buffer);
if (status == SM_FAIL)
elog(ERROR, "cannot extend %s: %m.\n\tCheck free disk space.",
RelationGetRelationName(reln));
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not extend \"%s\": %m",
RelationGetRelationName(reln)),
errhint("Check free disk space.")));
return status;
}
@@ -267,7 +273,10 @@ smgropen(int16 which, Relation reln, bool failOK)
return -1;
if ((fd = (*(smgrsw[which].smgr_open)) (reln)) < 0)
if (!failOK)
elog(ERROR, "cannot open %s: %m", RelationGetRelationName(reln));
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not open \"%s\": %m",
RelationGetRelationName(reln))));
return fd;
}
@@ -281,7 +290,10 @@ int
smgrclose(int16 which, Relation reln)
{
if ((*(smgrsw[which].smgr_close)) (reln) == SM_FAIL)
elog(ERROR, "cannot close %s: %m", RelationGetRelationName(reln));
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not close \"%s\": %m",
RelationGetRelationName(reln))));
return SM_SUCCESS;
}
@@ -304,8 +316,10 @@ smgrread(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
status = (*(smgrsw[which].smgr_read)) (reln, blocknum, buffer);
if (status == SM_FAIL)
elog(ERROR, "cannot read block %d of %s: %m",
blocknum, RelationGetRelationName(reln));
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not read block %d of \"%s\": %m",
blocknum, RelationGetRelationName(reln))));
return status;
}
@@ -328,8 +342,10 @@ smgrwrite(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
status = (*(smgrsw[which].smgr_write)) (reln, blocknum, buffer);
if (status == SM_FAIL)
elog(ERROR, "cannot write block %d of %s: %m",
blocknum, RelationGetRelationName(reln));
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not write block %d of \"%s\": %m",
blocknum, RelationGetRelationName(reln))));
return status;
}
@@ -357,8 +373,10 @@ smgrblindwrt(int16 which,
status = (*(smgrsw[which].smgr_blindwrt)) (rnode, blkno, buffer);
if (status == SM_FAIL)
elog(ERROR, "cannot write block %d of %u/%u blind: %m",
blkno, rnode.tblNode, rnode.relNode);
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not write block %d of %u/%u blind: %m",
blkno, rnode.tblNode, rnode.relNode)));
return status;
}
@@ -384,8 +402,10 @@ smgrnblocks(int16 which, Relation reln)
* actually is InvalidBlockNumber.
*/
if (nblocks == InvalidBlockNumber)
elog(ERROR, "cannot count blocks for %s: %m",
RelationGetRelationName(reln));
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not count blocks of \"%s\": %m",
RelationGetRelationName(reln))));
return nblocks;
}
@@ -414,8 +434,10 @@ smgrtruncate(int16 which, Relation reln, BlockNumber nblocks)
newblks = (*(smgrsw[which].smgr_truncate)) (reln, nblocks);
if (newblks == InvalidBlockNumber)
elog(ERROR, "cannot truncate %s to %u blocks: %m",
RelationGetRelationName(reln), nblocks);
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not truncate \"%s\" to %u blocks: %m",
RelationGetRelationName(reln), nblocks)));
}
return newblks;
@@ -456,8 +478,11 @@ smgrDoPendingDeletes(bool isCommit)
* current xact.
*/
if ((*(smgrsw[pending->which].smgr_unlink)) (pending->relnode) == SM_FAIL)
elog(WARNING, "cannot unlink %u/%u: %m",
pending->relnode.tblNode, pending->relnode.relNode);
ereport(WARNING,
(errcode_for_file_access(),
errmsg("could not unlink %u/%u: %m",
pending->relnode.tblNode,
pending->relnode.relNode)));
}
pfree(pending);
}
@@ -539,7 +564,7 @@ bool
smgriswo(int16 smgrno)
{
if (smgrno < 0 || smgrno >= NSmgr)
elog(ERROR, "illegal storage manager number %d", smgrno);
elog(ERROR, "invalid storage manager id: %d", smgrno);
return smgrwo[smgrno];
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgrtype.c,v 1.19 2002/06/20 20:29:36 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgrtype.c,v 1.20 2003/07/24 22:04:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -48,7 +48,7 @@ smgrin(PG_FUNCTION_ARGS)
if (strcmp(s, StorageManager[i].smgr_name) == 0)
PG_RETURN_INT16(i);
}
elog(ERROR, "smgrin: unknown storage manager name '%s'", s);
elog(ERROR, "unrecognized storage manager name \"%s\"", s);
PG_RETURN_INT16(0);
}
@@ -59,7 +59,7 @@ smgrout(PG_FUNCTION_ARGS)
char *s;
if (i >= NStorageManagers || i < 0)
elog(ERROR, "Illegal storage manager id %d", i);
elog(ERROR, "invalid storage manager id: %d", i);
s = pstrdup(StorageManager[i].smgr_name);
PG_RETURN_CSTRING(s);