* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.61 2008/11/03 15:10:17 alvherre Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.62 2008/11/11 13:19:16 heikki Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "access/xlogutils.h"
+#include "catalog/catalog.h"
#include "storage/bufmgr.h"
#include "storage/smgr.h"
+#include "utils/guc.h"
#include "utils/hsearch.h"
#include "utils/rel.h"
* tracing of the cause (note the elog context mechanism will tell us
* something about the XLOG record that generated the reference).
*/
- if (present)
- elog(DEBUG1, "page %u of relation %u/%u/%u/%u is uninitialized",
- blkno, node.spcNode, node.dbNode, node.relNode, forkno);
- else
- elog(DEBUG1, "page %u of relation %u/%u/%u/%u does not exist",
- blkno, node.spcNode, node.dbNode, node.relNode, forkno);
+ if (log_min_messages <= DEBUG1 || client_min_messages <= DEBUG1)
+ {
+ char *path = relpath(node, forkno);
+ if (present)
+ elog(DEBUG1, "page %u of relation %s is uninitialized",
+ blkno, path);
+ else
+ elog(DEBUG1, "page %u of relation %s does not exist",
+ blkno, path);
+ pfree(path);
+ }
if (invalid_page_tab == NULL)
{
hentry->key.forkno == forkno &&
hentry->key.blkno >= minblkno)
{
- elog(DEBUG2, "page %u of relation %u/%u/%u/%u has been dropped",
- hentry->key.blkno, hentry->key.node.spcNode,
- hentry->key.node.dbNode, hentry->key.node.relNode, forkno);
+ if (log_min_messages <= DEBUG2 || client_min_messages <= DEBUG2)
+ {
+ char *path = relpath(hentry->key.node, forkno);
+ elog(DEBUG2, "page %u of relation %s has been dropped",
+ hentry->key.blkno, path);
+ pfree(path);
+ }
if (hash_search(invalid_page_tab,
(void *) &hentry->key,
{
if (hentry->key.node.dbNode == dbid)
{
- elog(DEBUG2, "page %u of relation %u/%u/%u has been dropped",
- hentry->key.blkno, hentry->key.node.spcNode,
- hentry->key.node.dbNode, hentry->key.node.relNode);
+ if (log_min_messages <= DEBUG2 || client_min_messages <= DEBUG2)
+ {
+ char *path = relpath(hentry->key.node, hentry->key.forkno);
+ elog(DEBUG2, "page %u of relation %s has been dropped",
+ hentry->key.blkno, path);
+ pfree(path);
+ }
if (hash_search(invalid_page_tab,
(void *) &hentry->key,
*/
while ((hentry = (xl_invalid_page *) hash_seq_search(&status)) != NULL)
{
+ char *path = relpath(hentry->key.node, hentry->key.forkno);
if (hentry->present)
- elog(WARNING, "page %u of relation %u/%u/%u was uninitialized",
- hentry->key.blkno, hentry->key.node.spcNode,
- hentry->key.node.dbNode, hentry->key.node.relNode);
+ elog(WARNING, "page %u of relation %s was uninitialized",
+ hentry->key.blkno, path);
else
- elog(WARNING, "page %u of relation %u/%u/%u did not exist",
- hentry->key.blkno, hentry->key.node.spcNode,
- hentry->key.node.dbNode, hentry->key.node.relNode);
+ elog(WARNING, "page %u of relation %s did not exist",
+ hentry->key.blkno, path);
+ pfree(path);
foundone = true;
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.240 2008/10/31 15:05:00 heikki Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.241 2008/11/11 13:19:16 heikki Exp $
*
*-------------------------------------------------------------------------
*/
#include <sys/file.h>
#include <unistd.h>
+#include "catalog/catalog.h"
#include "miscadmin.h"
#include "pg_trace.h"
#include "pgstat.h"
bufBlock = isLocalBuf ? LocalBufHdrGetBlock(bufHdr) : BufHdrGetBlock(bufHdr);
if (!PageIsNew((Page) bufBlock))
ereport(ERROR,
- (errmsg("unexpected data beyond EOF in block %u of relation %u/%u/%u/%u",
- blockNum, smgr->smgr_rnode.spcNode, smgr->smgr_rnode.dbNode, smgr->smgr_rnode.relNode, forkNum),
+ (errmsg("unexpected data beyond EOF in block %u of relation %s",
+ blockNum, relpath(smgr->smgr_rnode, forkNum)),
errhint("This has been seen to occur with buggy kernels; consider updating your system.")));
/*
{
ereport(WARNING,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("invalid page header in block %u of relation %u/%u/%u/%u; zeroing out page",
+ errmsg("invalid page header in block %u of relation %s; zeroing out page",
blockNum,
- smgr->smgr_rnode.spcNode,
- smgr->smgr_rnode.dbNode,
- smgr->smgr_rnode.relNode,
- forkNum)));
+ relpath(smgr->smgr_rnode, forkNum))));
MemSet((char *) bufBlock, 0, BLCKSZ);
}
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("invalid page header in block %u of relation %u/%u/%u/%u",
- blockNum, smgr->smgr_rnode.spcNode,
- smgr->smgr_rnode.dbNode,
- smgr->smgr_rnode.relNode, forkNum)));
+ errmsg("invalid page header in block %u of relation %s",
+ blockNum,
+ relpath(smgr->smgr_rnode, forkNum))));
}
}
}
{
volatile BufferDesc *buf;
int32 loccount;
+ char *path;
Assert(BufferIsValid(buffer));
if (BufferIsLocal(buffer))
}
/* theoretically we should lock the bufhdr here */
+ path = relpath(buf->tag.rnode, buf->tag.forkNum);
elog(WARNING,
"buffer refcount leak: [%03d] "
- "(rel=%u/%u/%u, forkNum=%u, blockNum=%u, flags=0x%x, refcount=%u %d)",
- buffer,
- buf->tag.rnode.spcNode, buf->tag.rnode.dbNode,
- buf->tag.rnode.relNode, buf->tag.forkNum,
+ "(rel=%s, blockNum=%u, flags=0x%x, refcount=%u %d)",
+ buffer, path,
buf->tag.blockNum, buf->flags,
buf->refcount, loccount);
+ pfree(path);
}
/*
{
/* theoretically we should lock the bufhdr here */
elog(LOG,
- "[%02d] (freeNext=%d, rel=%u/%u/%u, forkNum=%u, "
+ "[%02d] (freeNext=%d, rel=%s, "
"blockNum=%u, flags=0x%x, refcount=%u %d)",
i, buf->freeNext,
- buf->tag.rnode.spcNode, buf->tag.rnode.dbNode,
- buf->tag.rnode.relNode, buf->tag.forkNum,
+ relpath(buf->tag.rnode, buf->tag.forkNum),
buf->tag.blockNum, buf->flags,
buf->refcount, PrivateRefCount[i]);
}
{
/* theoretically we should lock the bufhdr here */
elog(LOG,
- "[%02d] (freeNext=%d, rel=%u/%u/%u, forkNum=%u, "
+ "[%02d] (freeNext=%d, rel=%s, "
"blockNum=%u, flags=0x%x, refcount=%u %d)",
i, buf->freeNext,
- buf->tag.rnode.spcNode, buf->tag.rnode.dbNode,
- buf->tag.rnode.relNode, buf->tag.forkNum,
+ relpath(buf->tag.rnode, buf->tag.forkNum),
buf->tag.blockNum, buf->flags,
buf->refcount, PrivateRefCount[i]);
}
if (sv_flags & BM_IO_ERROR)
{
/* Buffer is pinned, so we can read tag without spinlock */
+ char *path = relpath(buf->tag.rnode, buf->tag.forkNum);
ereport(WARNING,
(errcode(ERRCODE_IO_ERROR),
- errmsg("could not write block %u of %u/%u/%u/%u",
- buf->tag.blockNum,
- buf->tag.rnode.spcNode,
- buf->tag.rnode.dbNode,
- buf->tag.rnode.relNode, buf->tag.forkNum),
+ errmsg("could not write block %u of %s",
+ buf->tag.blockNum, path),
errdetail("Multiple failures --- write error might be permanent.")));
+ pfree(path);
}
}
TerminateBufferIO(buf, false, BM_IO_ERROR);
/* Buffer is pinned, so we can read the tag without locking the spinlock */
if (bufHdr != NULL)
- errcontext("writing block %u of relation %u/%u/%u/%u",
- bufHdr->tag.blockNum,
- bufHdr->tag.rnode.spcNode,
- bufHdr->tag.rnode.dbNode,
- bufHdr->tag.rnode.relNode,
- bufHdr->tag.forkNum);
+ {
+ char *path = relpath(bufHdr->tag.rnode, bufHdr->tag.forkNum);
+ errcontext("writing block %u of relation %s",
+ bufHdr->tag.blockNum, path);
+ pfree(path);
+ }
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.139 2008/08/11 11:05:11 heikki Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.140 2008/11/11 13:19:16 heikki Exp $
*
*-------------------------------------------------------------------------
*/
errno = save_errno;
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not create relation %u/%u/%u/%u: %m",
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forkNum)));
+ errmsg("could not create relation %s: %m", path)));
}
}
if (!isRedo || errno != ENOENT)
ereport(WARNING,
(errcode_for_file_access(),
- errmsg("could not remove relation %u/%u/%u/%u: %m",
- rnode.spcNode,
- rnode.dbNode,
- rnode.relNode,
- forkNum)));
+ errmsg("could not remove relation %s: %m", path)));
}
/*
if (errno != ENOENT)
ereport(WARNING,
(errcode_for_file_access(),
- errmsg("could not remove segment %u of relation %u/%u/%u/%u: %m",
- segno,
- rnode.spcNode,
- rnode.dbNode,
- rnode.relNode,
- forkNum)));
+ errmsg("could not remove segment %u of relation %s: %m",
+ segno, path)));
break;
}
}
if (blocknum == InvalidBlockNumber)
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("cannot extend relation %u/%u/%u/%u beyond %u blocks",
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum,
+ errmsg("cannot extend relation %s beyond %u blocks",
+ relpath(reln->smgr_rnode, forknum),
InvalidBlockNumber)));
v = _mdfd_getseg(reln, forknum, blocknum, isTemp, EXTENSION_CREATE);
if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not seek to block %u of relation %u/%u/%u/%u: %m",
+ errmsg("could not seek to block %u of relation %s: %m",
blocknum,
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum)));
+ relpath(reln->smgr_rnode, forknum))));
if ((nbytes = FileWrite(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ)
{
if (nbytes < 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not extend relation %u/%u/%u/%u: %m",
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum),
+ errmsg("could not extend relation %s: %m",
+ relpath(reln->smgr_rnode, forknum)),
errhint("Check free disk space.")));
/* short write: complain appropriately */
ereport(ERROR,
(errcode(ERRCODE_DISK_FULL),
- errmsg("could not extend relation %u/%u/%u/%u: wrote only %d of %d bytes at block %u",
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum,
+ errmsg("could not extend relation %s: wrote only %d of %d bytes at block %u",
+ relpath(reln->smgr_rnode, forknum),
nbytes, BLCKSZ, blocknum),
errhint("Check free disk space.")));
}
return NULL;
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not open relation %u/%u/%u/%u: %m",
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum)));
+ errmsg("could not open relation %s: %m", path)));
}
}
if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not seek to block %u of relation %u/%u/%u/%u: %m",
- blocknum,
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum)));
+ errmsg("could not seek to block %u of relation %s: %m",
+ blocknum, relpath(reln->smgr_rnode, forknum))));
if ((nbytes = FileRead(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ)
{
if (nbytes < 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not read block %u of relation %u/%u/%u/%u: %m",
- blocknum,
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum)));
+ errmsg("could not read block %u of relation %s: %m",
+ blocknum, relpath(reln->smgr_rnode, forknum))));
/*
* Short read: we are at or past EOF, or we read a partial block at
else
ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED),
- errmsg("could not read block %u of relation %u/%u/%u/%u: read only %d of %d bytes",
- blocknum,
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum,
+ errmsg("could not read block %u of relation %s: read only %d of %d bytes",
+ blocknum, relpath(reln->smgr_rnode, forknum),
nbytes, BLCKSZ)));
}
}
if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not seek to block %u of relation %u/%u/%u/%u: %m",
- blocknum,
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum)));
+ errmsg("could not seek to block %u of relation %s: %m",
+ blocknum, relpath(reln->smgr_rnode, forknum))));
if ((nbytes = FileWrite(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ)
{
if (nbytes < 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not write block %u of relation %u/%u/%u/%u: %m",
- blocknum,
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum)));
+ errmsg("could not write block %u of relation %s: %m",
+ blocknum, relpath(reln->smgr_rnode, forknum))));
/* short write: complain appropriately */
ereport(ERROR,
(errcode(ERRCODE_DISK_FULL),
- errmsg("could not write block %u of relation %u/%u/%u/%u: wrote only %d of %d bytes",
+ errmsg("could not write block %u of relation %s: wrote only %d of %d bytes",
blocknum,
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum,
+ relpath(reln->smgr_rnode, forknum),
nbytes, BLCKSZ),
errhint("Check free disk space.")));
}
if (v->mdfd_chain == NULL)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not open segment %u of relation %u/%u/%u/%u: %m",
+ errmsg("could not open segment %u of relation %s: %m",
segno,
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum)));
+ relpath(reln->smgr_rnode, forknum))));
}
v = v->mdfd_chain;
if (InRecovery)
return;
ereport(ERROR,
- (errmsg("could not truncate relation %u/%u/%u/%u to %u blocks: it's only %u blocks now",
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum,
+ (errmsg("could not truncate relation %s to %u blocks: it's only %u blocks now",
+ relpath(reln->smgr_rnode, forknum),
nblocks, curnblk)));
}
if (nblocks == curnblk)
if (FileTruncate(v->mdfd_vfd, 0) < 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not truncate relation %u/%u/%u/%u to %u blocks: %m",
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum,
+ errmsg("could not truncate relation %s to %u blocks: %m",
+ relpath(reln->smgr_rnode, forknum),
nblocks)));
if (!isTemp)
register_dirty_segment(reln, forknum, v);
if (FileTruncate(v->mdfd_vfd, (off_t) lastsegblocks * BLCKSZ) < 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not truncate relation %u/%u/%u/%u to %u blocks: %m",
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum,
+ errmsg("could not truncate relation %s to %u blocks: %m",
+ relpath(reln->smgr_rnode, forknum),
nblocks)));
if (!isTemp)
register_dirty_segment(reln, forknum, v);
if (FileSync(v->mdfd_vfd) < 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not fsync segment %u of relation %u/%u/%u/%u: %m",
- v->mdfd_segno,
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum)));
+ errmsg("could not fsync segment %u of relation %s: %m",
+ v->mdfd_segno,
+ relpath(reln->smgr_rnode, forknum))));
v = v->mdfd_chain;
}
}
{
SMgrRelation reln;
MdfdVec *seg;
+ char *path;
/*
* Find or create an smgr hash entry for this relation. This
* Don't see one at the moment, but easy to change the test
* here if so.
*/
+ path = relpath(entry->tag.rnode, entry->tag.forknum);
if (!FILE_POSSIBLY_DELETED(errno) ||
failures > 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not fsync segment %u of relation %u/%u/%u/%u: %m",
- entry->tag.segno,
- entry->tag.rnode.spcNode,
- entry->tag.rnode.dbNode,
- entry->tag.rnode.relNode,
- entry->tag.forknum)));
+ errmsg("could not fsync segment %u of relation %s: %m",
+ entry->tag.segno, path)));
else
ereport(DEBUG1,
(errcode_for_file_access(),
- errmsg("could not fsync segment %u of relation %u/%u/%u/%u but retrying: %m",
- entry->tag.segno,
- entry->tag.rnode.spcNode,
- entry->tag.rnode.dbNode,
- entry->tag.rnode.relNode,
- entry->tag.forknum)));
+ errmsg("could not fsync segment %u of relation %s but retrying: %m",
+ entry->tag.segno, path)));
+ pfree(path);
/*
* Absorb incoming requests and check to see if canceled.
if (errno != ENOENT)
ereport(WARNING,
(errcode_for_file_access(),
- errmsg("could not remove relation %u/%u/%u/%u: %m",
- entry->rnode.spcNode,
- entry->rnode.dbNode,
- entry->rnode.relNode,
- MAIN_FORKNUM)));
+ errmsg("could not remove relation %s: %m", path)));
}
pfree(path);
if (FileSync(seg->mdfd_vfd) < 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not fsync segment %u of relation %u/%u/%u/%u: %m",
- seg->mdfd_segno,
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum)));
+ errmsg("could not fsync segment %u of relation %s: %m",
+ seg->mdfd_segno,
+ relpath(reln->smgr_rnode, forknum))));
}
}
return NULL;
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not open segment %u of relation %u/%u/%u/%u (target block %u): %m",
+ errmsg("could not open segment %u of relation %s (target block %u): %m",
nextsegno,
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum,
+ relpath(reln->smgr_rnode, forknum),
blkno)));
}
}
if (len < 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not seek to end of segment %u of relation %u/%u/%u/%u: %m",
- seg->mdfd_segno,
- reln->smgr_rnode.spcNode,
- reln->smgr_rnode.dbNode,
- reln->smgr_rnode.relNode,
- forknum)));
+ errmsg("could not seek to end of segment %u of relation %s: %m",
+ seg->mdfd_segno, relpath(reln->smgr_rnode, forknum))));
/* note that this calculation will ignore any partial block at EOF */
return (BlockNumber) (len / BLCKSZ);
}