* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gist/gistxlog.c,v 1.10 2006/03/05 15:58:20 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gist/gistxlog.c,v 1.11 2006/03/24 04:32:12 tgl Exp $
*-------------------------------------------------------------------------
*/
#include "postgres.h"
}
static void
-out_target(char *buf, RelFileNode node, ItemPointerData key)
+out_target(StringInfo buf, RelFileNode node, ItemPointerData key)
{
- sprintf(buf + strlen(buf), "rel %u/%u/%u; tid %u/%u",
+ appendStringInfo(buf, "rel %u/%u/%u; tid %u/%u",
node.spcNode, node.dbNode, node.relNode,
ItemPointerGetBlockNumber(&key),
ItemPointerGetOffsetNumber(&key));
}
static void
-out_gistxlogEntryUpdate(char *buf, gistxlogEntryUpdate *xlrec)
+out_gistxlogEntryUpdate(StringInfo buf, gistxlogEntryUpdate *xlrec)
{
out_target(buf, xlrec->node, xlrec->key);
- sprintf(buf + strlen(buf), "; block number %u",
- xlrec->blkno);
+ appendStringInfo(buf, "; block number %u", xlrec->blkno);
}
static void
-out_gistxlogPageSplit(char *buf, gistxlogPageSplit *xlrec)
+out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
{
- strcat(buf, "page_split: ");
+ appendStringInfo(buf, "page_split: ");
out_target(buf, xlrec->node, xlrec->key);
- sprintf(buf + strlen(buf), "; block number %u splits to %d pages",
+ appendStringInfo(buf, "; block number %u splits to %d pages",
xlrec->origblkno, xlrec->npage);
}
void
-gist_desc(char *buf, uint8 xl_info, char *rec)
+gist_desc(StringInfo buf, uint8 xl_info, char *rec)
{
uint8 info = xl_info & ~XLR_INFO_MASK;
switch (info)
{
case XLOG_GIST_ENTRY_UPDATE:
- strcat(buf, "entry_update: ");
+ appendStringInfo(buf, "entry_update: ");
out_gistxlogEntryUpdate(buf, (gistxlogEntryUpdate *) rec);
break;
case XLOG_GIST_ENTRY_DELETE:
- strcat(buf, "entry_delete: ");
+ appendStringInfo(buf, "entry_delete: ");
out_gistxlogEntryUpdate(buf, (gistxlogEntryUpdate *) rec);
break;
case XLOG_GIST_NEW_ROOT:
- strcat(buf, "new_root: ");
+ appendStringInfo(buf, "new_root: ");
out_target(buf, ((gistxlogEntryUpdate *) rec)->node, ((gistxlogEntryUpdate *) rec)->key);
break;
case XLOG_GIST_PAGE_SPLIT:
out_gistxlogPageSplit(buf, (gistxlogPageSplit *) rec);
break;
case XLOG_GIST_CREATE_INDEX:
- sprintf(buf + strlen(buf), "create_index: rel %u/%u/%u",
+ appendStringInfo(buf, "create_index: rel %u/%u/%u",
((RelFileNode *) rec)->spcNode,
((RelFileNode *) rec)->dbNode,
((RelFileNode *) rec)->relNode);
break;
case XLOG_GIST_INSERT_COMPLETE:
- sprintf(buf + strlen(buf), "complete_insert: rel %u/%u/%u",
+ appendStringInfo(buf, "complete_insert: rel %u/%u/%u",
((gistxlogInsertComplete *) rec)->node.spcNode,
((gistxlogInsertComplete *) rec)->node.dbNode,
((gistxlogInsertComplete *) rec)->node.relNode);
break;
default:
- elog(PANIC, "gist_desc: unknown op code %u", info);
+ appendStringInfo(buf, "unknown gist op code %u", info);
+ break;
}
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.87 2006/03/05 15:58:20 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.88 2006/03/24 04:32:12 tgl Exp $
*
* NOTES
* This file contains only the public interface routines.
}
void
-hash_desc(char *buf, uint8 xl_info, char *rec)
+hash_desc(StringInfo buf, uint8 xl_info, char *rec)
{
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.208 2006/03/05 15:58:21 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.209 2006/03/24 04:32:12 tgl Exp $
*
*
* INTERFACE ROUTINES
}
static void
-out_target(char *buf, xl_heaptid *target)
+out_target(StringInfo buf, xl_heaptid *target)
{
- sprintf(buf + strlen(buf), "rel %u/%u/%u; tid %u/%u",
+ appendStringInfo(buf, "rel %u/%u/%u; tid %u/%u",
target->node.spcNode, target->node.dbNode, target->node.relNode,
ItemPointerGetBlockNumber(&(target->tid)),
ItemPointerGetOffsetNumber(&(target->tid)));
}
void
-heap_desc(char *buf, uint8 xl_info, char *rec)
+heap_desc(StringInfo buf, uint8 xl_info, char *rec)
{
uint8 info = xl_info & ~XLR_INFO_MASK;
{
xl_heap_insert *xlrec = (xl_heap_insert *) rec;
- strcat(buf, "insert: ");
+ appendStringInfo(buf, "insert: ");
out_target(buf, &(xlrec->target));
}
else if (info == XLOG_HEAP_DELETE)
{
xl_heap_delete *xlrec = (xl_heap_delete *) rec;
- strcat(buf, "delete: ");
+ appendStringInfo(buf, "delete: ");
out_target(buf, &(xlrec->target));
}
else if (info == XLOG_HEAP_UPDATE || info == XLOG_HEAP_MOVE)
xl_heap_update *xlrec = (xl_heap_update *) rec;
if (info == XLOG_HEAP_UPDATE)
- strcat(buf, "update: ");
+ appendStringInfo(buf, "update: ");
else
- strcat(buf, "move: ");
+ appendStringInfo(buf, "move: ");
out_target(buf, &(xlrec->target));
- sprintf(buf + strlen(buf), "; new %u/%u",
+ appendStringInfo(buf, "; new %u/%u",
ItemPointerGetBlockNumber(&(xlrec->newtid)),
ItemPointerGetOffsetNumber(&(xlrec->newtid)));
}
{
xl_heap_clean *xlrec = (xl_heap_clean *) rec;
- sprintf(buf + strlen(buf), "clean: rel %u/%u/%u; blk %u",
+ appendStringInfo(buf, "clean: rel %u/%u/%u; blk %u",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block);
}
{
xl_heap_newpage *xlrec = (xl_heap_newpage *) rec;
- sprintf(buf + strlen(buf), "newpage: rel %u/%u/%u; blk %u",
+ appendStringInfo(buf, "newpage: rel %u/%u/%u; blk %u",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->blkno);
}
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
if (xlrec->shared_lock)
- strcat(buf, "shared_lock: ");
+ appendStringInfo(buf, "shared_lock: ");
else
- strcat(buf, "exclusive_lock: ");
+ appendStringInfo(buf, "exclusive_lock: ");
if (xlrec->xid_is_mxact)
- strcat(buf, "mxid ");
+ appendStringInfo(buf, "mxid ");
else
- strcat(buf, "xid ");
- sprintf(buf + strlen(buf), "%u ", xlrec->locking_xid);
+ appendStringInfo(buf, "xid ");
+ appendStringInfo(buf, "%u ", xlrec->locking_xid);
out_target(buf, &(xlrec->target));
}
else
- strcat(buf, "UNKNOWN");
+ appendStringInfo(buf, "UNKNOWN");
}
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.26 2006/03/05 15:58:21 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.27 2006/03/24 04:32:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
}
static void
-out_target(char *buf, xl_btreetid *target)
+out_target(StringInfo buf, xl_btreetid *target)
{
- sprintf(buf + strlen(buf), "rel %u/%u/%u; tid %u/%u",
+ appendStringInfo(buf, "rel %u/%u/%u; tid %u/%u",
target->node.spcNode, target->node.dbNode, target->node.relNode,
ItemPointerGetBlockNumber(&(target->tid)),
ItemPointerGetOffsetNumber(&(target->tid)));
}
void
-btree_desc(char *buf, uint8 xl_info, char *rec)
+btree_desc(StringInfo buf, uint8 xl_info, char *rec)
{
uint8 info = xl_info & ~XLR_INFO_MASK;
{
xl_btree_insert *xlrec = (xl_btree_insert *) rec;
- strcat(buf, "insert: ");
+ appendStringInfo(buf, "insert: ");
out_target(buf, &(xlrec->target));
break;
}
{
xl_btree_insert *xlrec = (xl_btree_insert *) rec;
- strcat(buf, "insert_upper: ");
+ appendStringInfo(buf, "insert_upper: ");
out_target(buf, &(xlrec->target));
break;
}
{
xl_btree_insert *xlrec = (xl_btree_insert *) rec;
- strcat(buf, "insert_meta: ");
+ appendStringInfo(buf, "insert_meta: ");
out_target(buf, &(xlrec->target));
break;
}
{
xl_btree_split *xlrec = (xl_btree_split *) rec;
- strcat(buf, "split_l: ");
+ appendStringInfo(buf, "split_l: ");
out_target(buf, &(xlrec->target));
- sprintf(buf + strlen(buf), "; oth %u; rgh %u",
+ appendStringInfo(buf, "; oth %u; rgh %u",
xlrec->otherblk, xlrec->rightblk);
break;
}
{
xl_btree_split *xlrec = (xl_btree_split *) rec;
- strcat(buf, "split_r: ");
+ appendStringInfo(buf, "split_r: ");
out_target(buf, &(xlrec->target));
- sprintf(buf + strlen(buf), "; oth %u; rgh %u",
+ appendStringInfo(buf, "; oth %u; rgh %u",
xlrec->otherblk, xlrec->rightblk);
break;
}
{
xl_btree_split *xlrec = (xl_btree_split *) rec;
- strcat(buf, "split_l_root: ");
+ appendStringInfo(buf, "split_l_root: ");
out_target(buf, &(xlrec->target));
- sprintf(buf + strlen(buf), "; oth %u; rgh %u",
+ appendStringInfo(buf, "; oth %u; rgh %u",
xlrec->otherblk, xlrec->rightblk);
break;
}
{
xl_btree_split *xlrec = (xl_btree_split *) rec;
- strcat(buf, "split_r_root: ");
+ appendStringInfo(buf, "split_r_root: ");
out_target(buf, &(xlrec->target));
- sprintf(buf + strlen(buf), "; oth %u; rgh %u",
+ appendStringInfo(buf, "; oth %u; rgh %u",
xlrec->otherblk, xlrec->rightblk);
break;
}
{
xl_btree_delete *xlrec = (xl_btree_delete *) rec;
- sprintf(buf + strlen(buf), "delete: rel %u/%u/%u; blk %u",
+ appendStringInfo(buf, "delete: rel %u/%u/%u; blk %u",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode, xlrec->block);
break;
{
xl_btree_delete_page *xlrec = (xl_btree_delete_page *) rec;
- strcat(buf, "delete_page: ");
+ appendStringInfo(buf, "delete_page: ");
out_target(buf, &(xlrec->target));
- sprintf(buf + strlen(buf), "; dead %u; left %u; right %u",
+ appendStringInfo(buf, "; dead %u; left %u; right %u",
xlrec->deadblk, xlrec->leftblk, xlrec->rightblk);
break;
}
{
xl_btree_newroot *xlrec = (xl_btree_newroot *) rec;
- sprintf(buf + strlen(buf), "newroot: rel %u/%u/%u; root %u lev %u",
+ appendStringInfo(buf, "newroot: rel %u/%u/%u; root %u lev %u",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
xlrec->rootblk, xlrec->level);
{
xl_btree_newmeta *xlrec = (xl_btree_newmeta *) rec;
- sprintf(buf + strlen(buf), "newmeta: rel %u/%u/%u; root %u lev %u fast %u lev %u",
+ appendStringInfo(buf, "newmeta: rel %u/%u/%u; root %u lev %u fast %u lev %u",
xlrec->node.spcNode, xlrec->node.dbNode,
xlrec->node.relNode,
xlrec->meta.root, xlrec->meta.level,
break;
}
default:
- strcat(buf, "UNKNOWN");
+ appendStringInfo(buf, "UNKNOWN");
break;
}
}
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.37 2006/03/05 15:58:21 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.38 2006/03/24 04:32:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
}
void
-clog_desc(char *buf, uint8 xl_info, char *rec)
+clog_desc(StringInfo buf, uint8 xl_info, char *rec)
{
- uint8 info = xl_info & ~XLR_INFO_MASK;
+ uint8 info = xl_info & ~XLR_INFO_MASK;
if (info == CLOG_ZEROPAGE)
{
int pageno;
memcpy(&pageno, rec, sizeof(int));
- sprintf(buf + strlen(buf), "zeropage: %d", pageno);
+ appendStringInfo(buf, "zeropage: %d", pageno);
}
else
- strcat(buf, "UNKNOWN");
+ appendStringInfo(buf, "UNKNOWN");
}
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.16 2006/03/05 15:58:21 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.17 2006/03/24 04:32:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
}
void
-multixact_desc(char *buf, uint8 xl_info, char *rec)
+multixact_desc(StringInfo buf, uint8 xl_info, char *rec)
{
uint8 info = xl_info & ~XLR_INFO_MASK;
int pageno;
memcpy(&pageno, rec, sizeof(int));
- sprintf(buf + strlen(buf), "zero offsets page: %d", pageno);
+ appendStringInfo(buf, "zero offsets page: %d", pageno);
}
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
{
int pageno;
memcpy(&pageno, rec, sizeof(int));
- sprintf(buf + strlen(buf), "zero members page: %d", pageno);
+ appendStringInfo(buf, "zero members page: %d", pageno);
}
else if (info == XLOG_MULTIXACT_CREATE_ID)
{
xl_multixact_create *xlrec = (xl_multixact_create *) rec;
int i;
- sprintf(buf + strlen(buf), "create multixact %u offset %u:",
+ appendStringInfo(buf, "create multixact %u offset %u:",
xlrec->mid, xlrec->moff);
for (i = 0; i < xlrec->nxids; i++)
- sprintf(buf + strlen(buf), " %u", xlrec->xids[i]);
+ appendStringInfo(buf, " %u", xlrec->xids[i]);
}
else
- strcat(buf, "UNKNOWN");
+ appendStringInfo(buf, "UNKNOWN");
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.217 2006/03/05 15:58:22 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.218 2006/03/24 04:32:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
}
static void
-xact_desc_commit(char *buf, xl_xact_commit *xlrec)
+xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
{
struct tm *tm = localtime(&xlrec->xtime);
int i;
- sprintf(buf + strlen(buf), "%04u-%02u-%02u %02u:%02u:%02u",
+ appendStringInfo(buf, "%04u-%02u-%02u %02u:%02u:%02u",
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
if (xlrec->nrels > 0)
{
- sprintf(buf + strlen(buf), "; rels:");
+ appendStringInfo(buf, "; rels:");
for (i = 0; i < xlrec->nrels; i++)
{
RelFileNode rnode = xlrec->xnodes[i];
- sprintf(buf + strlen(buf), " %u/%u/%u",
+ appendStringInfo(buf, " %u/%u/%u",
rnode.spcNode, rnode.dbNode, rnode.relNode);
}
}
TransactionId *xacts = (TransactionId *)
&xlrec->xnodes[xlrec->nrels];
- sprintf(buf + strlen(buf), "; subxacts:");
+ appendStringInfo(buf, "; subxacts:");
for (i = 0; i < xlrec->nsubxacts; i++)
- sprintf(buf + strlen(buf), " %u", xacts[i]);
+ appendStringInfo(buf, " %u", xacts[i]);
}
}
static void
-xact_desc_abort(char *buf, xl_xact_abort *xlrec)
+xact_desc_abort(StringInfo buf, xl_xact_abort *xlrec)
{
struct tm *tm = localtime(&xlrec->xtime);
int i;
- sprintf(buf + strlen(buf), "%04u-%02u-%02u %02u:%02u:%02u",
+ appendStringInfo(buf, "%04u-%02u-%02u %02u:%02u:%02u",
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
if (xlrec->nrels > 0)
{
- sprintf(buf + strlen(buf), "; rels:");
+ appendStringInfo(buf, "; rels:");
for (i = 0; i < xlrec->nrels; i++)
{
RelFileNode rnode = xlrec->xnodes[i];
- sprintf(buf + strlen(buf), " %u/%u/%u",
+ appendStringInfo(buf, " %u/%u/%u",
rnode.spcNode, rnode.dbNode, rnode.relNode);
}
}
TransactionId *xacts = (TransactionId *)
&xlrec->xnodes[xlrec->nrels];
- sprintf(buf + strlen(buf), "; subxacts:");
+ appendStringInfo(buf, "; subxacts:");
for (i = 0; i < xlrec->nsubxacts; i++)
- sprintf(buf + strlen(buf), " %u", xacts[i]);
+ appendStringInfo(buf, " %u", xacts[i]);
}
}
void
-xact_desc(char *buf, uint8 xl_info, char *rec)
+xact_desc(StringInfo buf, uint8 xl_info, char *rec)
{
- uint8 info = xl_info & ~XLR_INFO_MASK;
+ uint8 info = xl_info & ~XLR_INFO_MASK;
if (info == XLOG_XACT_COMMIT)
{
xl_xact_commit *xlrec = (xl_xact_commit *) rec;
- strcat(buf, "commit: ");
+ appendStringInfo(buf, "commit: ");
xact_desc_commit(buf, xlrec);
}
else if (info == XLOG_XACT_ABORT)
{
xl_xact_abort *xlrec = (xl_xact_abort *) rec;
- strcat(buf, "abort: ");
+ appendStringInfo(buf, "abort: ");
xact_desc_abort(buf, xlrec);
}
else if (info == XLOG_XACT_PREPARE)
{
- strcat(buf, "prepare");
+ appendStringInfo(buf, "prepare");
}
else if (info == XLOG_XACT_COMMIT_PREPARED)
{
xl_xact_commit_prepared *xlrec = (xl_xact_commit_prepared *) rec;
- sprintf(buf + strlen(buf), "commit %u: ", xlrec->xid);
+ appendStringInfo(buf, "commit %u: ", xlrec->xid);
xact_desc_commit(buf, &xlrec->crec);
}
else if (info == XLOG_XACT_ABORT_PREPARED)
{
xl_xact_abort_prepared *xlrec = (xl_xact_abort_prepared *) rec;
- sprintf(buf + strlen(buf), "abort %u: ", xlrec->xid);
+ appendStringInfo(buf, "abort %u: ", xlrec->xid);
xact_desc_abort(buf, &xlrec->arec);
}
else
- strcat(buf, "UNKNOWN");
+ appendStringInfo(buf, "UNKNOWN");
}
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.227 2006/03/05 15:58:22 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.228 2006/03/24 04:32:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
static void issue_xlog_fsync(void);
#ifdef WAL_DEBUG
-static void xlog_outrec(char *buf, XLogRecord *record);
+static void xlog_outrec(StringInfo buf, XLogRecord *record);
#endif
static bool read_backup_label(XLogRecPtr *checkPointLoc);
static void remove_backup_label(void);
+static void rm_redo_error_callback(void *arg);
/*
#ifdef WAL_DEBUG
if (XLOG_DEBUG)
{
- char buf[8192];
+ StringInfoData buf;
- sprintf(buf, "INSERT @ %X/%X: ", RecPtr.xlogid, RecPtr.xrecoff);
- xlog_outrec(buf, record);
+ initStringInfo(&buf);
+ appendStringInfo(&buf, "INSERT @ %X/%X: ",
+ RecPtr.xlogid, RecPtr.xrecoff);
+ xlog_outrec(&buf, record);
if (rdata->data != NULL)
{
- strcat(buf, " - ");
- RmgrTable[record->xl_rmid].rm_desc(buf, record->xl_info, rdata->data);
+ appendStringInfo(&buf, " - ");
+ RmgrTable[record->xl_rmid].rm_desc(&buf, record->xl_info, rdata->data);
}
- elog(LOG, "%s", buf);
+ elog(LOG, "%s", buf.data);
+ pfree(buf.data);
}
#endif
{
bool recoveryContinue = true;
bool recoveryApply = true;
+ ErrorContextCallback errcontext;
InRedo = true;
ereport(LOG,
#ifdef WAL_DEBUG
if (XLOG_DEBUG)
{
- char buf[8192];
+ StringInfoData buf;
- sprintf(buf, "REDO @ %X/%X; LSN %X/%X: ",
+ initStringInfo(&buf);
+ appendStringInfo(&buf, "REDO @ %X/%X; LSN %X/%X: ",
ReadRecPtr.xlogid, ReadRecPtr.xrecoff,
EndRecPtr.xlogid, EndRecPtr.xrecoff);
- xlog_outrec(buf, record);
- strcat(buf, " - ");
- RmgrTable[record->xl_rmid].rm_desc(buf,
- record->xl_info, XLogRecGetData(record));
- elog(LOG, "%s", buf);
+ xlog_outrec(&buf, record);
+ appendStringInfo(&buf, " - ");
+ RmgrTable[record->xl_rmid].rm_desc(&buf,
+ record->xl_info,
+ XLogRecGetData(record));
+ elog(LOG, "%s", buf.data);
+ pfree(buf.data);
}
#endif
break;
}
+ /* Setup error traceback support for ereport() */
+ errcontext.callback = rm_redo_error_callback;
+ errcontext.arg = (void *) record;
+ errcontext.previous = error_context_stack;
+ error_context_stack = &errcontext;
+
/* nextXid must be beyond record's xid */
if (TransactionIdFollowsOrEquals(record->xl_xid,
ShmemVariableCache->nextXid))
RmgrTable[record->xl_rmid].rm_redo(EndRecPtr, record);
+ /* Pop the error context stack */
+ error_context_stack = errcontext.previous;
+
LastRec = ReadRecPtr;
record = ReadRecord(NULL, LOG);
}
void
-xlog_desc(char *buf, uint8 xl_info, char *rec)
+xlog_desc(StringInfo buf, uint8 xl_info, char *rec)
{
- uint8 info = xl_info & ~XLR_INFO_MASK;
+ uint8 info = xl_info & ~XLR_INFO_MASK;
if (info == XLOG_CHECKPOINT_SHUTDOWN ||
info == XLOG_CHECKPOINT_ONLINE)
{
CheckPoint *checkpoint = (CheckPoint *) rec;
- sprintf(buf + strlen(buf), "checkpoint: redo %X/%X; undo %X/%X; "
+ appendStringInfo(buf, "checkpoint: redo %X/%X; undo %X/%X; "
"tli %u; xid %u; oid %u; multi %u; offset %u; %s",
checkpoint->redo.xlogid, checkpoint->redo.xrecoff,
checkpoint->undo.xlogid, checkpoint->undo.xrecoff,
Oid nextOid;
memcpy(&nextOid, rec, sizeof(Oid));
- sprintf(buf + strlen(buf), "nextOid: %u", nextOid);
+ appendStringInfo(buf, "nextOid: %u", nextOid);
}
else
- strcat(buf, "UNKNOWN");
+ appendStringInfo(buf, "UNKNOWN");
}
#ifdef WAL_DEBUG
static void
-xlog_outrec(char *buf, XLogRecord *record)
+xlog_outrec(StringInfo buf, XLogRecord *record)
{
int bkpb;
int i;
- sprintf(buf + strlen(buf), "prev %X/%X; xid %u",
+ appendStringInfo(buf, "prev %X/%X; xid %u",
record->xl_prev.xlogid, record->xl_prev.xrecoff,
record->xl_xid);
}
if (bkpb)
- sprintf(buf + strlen(buf), "; bkpb %d", bkpb);
+ appendStringInfo(buf, "; bkpb %d", bkpb);
- sprintf(buf + strlen(buf), ": %s",
+ appendStringInfo(buf, ": %s",
RmgrTable[record->xl_rmid].rm_name);
}
#endif /* WAL_DEBUG */
errmsg("could not remove file \"%s\": %m",
BACKUP_LABEL_FILE)));
}
+
+/*
+ * Error context callback for errors occurring during rm_redo().
+ */
+static void
+rm_redo_error_callback(void *arg)
+{
+ XLogRecord *record = (XLogRecord *) arg;
+ StringInfoData buf;
+
+ initStringInfo(&buf);
+ RmgrTable[record->xl_rmid].rm_desc(&buf,
+ record->xl_info,
+ XLogRecGetData(record));
+
+ /* don't bother emitting empty description */
+ if (buf.len > 0)
+ errcontext("xlog redo %s", buf.data);
+
+ pfree(buf.data);
+}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.177 2006/03/05 15:58:24 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.178 2006/03/24 04:32:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
}
void
-dbase_desc(char *buf, uint8 xl_info, char *rec)
+dbase_desc(StringInfo buf, uint8 xl_info, char *rec)
{
uint8 info = xl_info & ~XLR_INFO_MASK;
{
xl_dbase_create_rec *xlrec = (xl_dbase_create_rec *) rec;
- sprintf(buf + strlen(buf), "create db: copy dir %u/%u to %u/%u",
+ appendStringInfo(buf, "create db: copy dir %u/%u to %u/%u",
xlrec->src_db_id, xlrec->src_tablespace_id,
xlrec->db_id, xlrec->tablespace_id);
}
{
xl_dbase_drop_rec *xlrec = (xl_dbase_drop_rec *) rec;
- sprintf(buf + strlen(buf), "drop db: dir %u/%u",
+ appendStringInfo(buf, "drop db: dir %u/%u",
xlrec->db_id, xlrec->tablespace_id);
}
else
- strcat(buf, "UNKNOWN");
+ appendStringInfo(buf, "UNKNOWN");
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.129 2006/03/14 22:48:18 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.130 2006/03/24 04:32:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
}
void
-seq_desc(char *buf, uint8 xl_info, char *rec)
+seq_desc(StringInfo buf, uint8 xl_info, char *rec)
{
uint8 info = xl_info & ~XLR_INFO_MASK;
xl_seq_rec *xlrec = (xl_seq_rec *) rec;
if (info == XLOG_SEQ_LOG)
- strcat(buf, "log: ");
+ appendStringInfo(buf, "log: ");
else
{
- strcat(buf, "UNKNOWN");
+ appendStringInfo(buf, "UNKNOWN");
return;
}
- sprintf(buf + strlen(buf), "rel %u/%u/%u",
+ appendStringInfo(buf, "rel %u/%u/%u",
xlrec->node.spcNode, xlrec->node.dbNode, xlrec->node.relNode);
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.31 2006/03/05 15:58:25 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.32 2006/03/24 04:32:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
}
void
-tblspc_desc(char *buf, uint8 xl_info, char *rec)
+tblspc_desc(StringInfo buf, uint8 xl_info, char *rec)
{
uint8 info = xl_info & ~XLR_INFO_MASK;
{
xl_tblspc_create_rec *xlrec = (xl_tblspc_create_rec *) rec;
- sprintf(buf + strlen(buf), "create ts: %u \"%s\"",
+ appendStringInfo(buf, "create ts: %u \"%s\"",
xlrec->ts_id, xlrec->ts_path);
}
else if (info == XLOG_TBLSPC_DROP)
{
xl_tblspc_drop_rec *xlrec = (xl_tblspc_drop_rec *) rec;
- sprintf(buf + strlen(buf), "drop ts: %u",
- xlrec->ts_id);
+ appendStringInfo(buf, "drop ts: %u", xlrec->ts_id);
}
else
- strcat(buf, "UNKNOWN");
+ appendStringInfo(buf, "UNKNOWN");
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.96 2006/03/05 15:58:39 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.97 2006/03/24 04:32:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
}
void
-smgr_desc(char *buf, uint8 xl_info, char *rec)
+smgr_desc(StringInfo buf, uint8 xl_info, char *rec)
{
uint8 info = xl_info & ~XLR_INFO_MASK;
{
xl_smgr_create *xlrec = (xl_smgr_create *) rec;
- sprintf(buf + strlen(buf), "file create: %u/%u/%u",
+ appendStringInfo(buf, "file create: %u/%u/%u",
xlrec->rnode.spcNode, xlrec->rnode.dbNode,
xlrec->rnode.relNode);
}
{
xl_smgr_truncate *xlrec = (xl_smgr_truncate *) rec;
- sprintf(buf + strlen(buf), "file truncate: %u/%u/%u to %u blocks",
+ appendStringInfo(buf, "file truncate: %u/%u/%u to %u blocks",
xlrec->rnode.spcNode, xlrec->rnode.dbNode,
xlrec->rnode.relNode, xlrec->blkno);
}
else
- strcat(buf, "UNKNOWN");
+ appendStringInfo(buf, "UNKNOWN");
}
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/clog.h,v 1.16 2006/03/05 15:58:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/clog.h,v 1.17 2006/03/24 04:32:13 tgl Exp $
*/
#ifndef CLOG_H
#define CLOG_H
#define CLOG_ZEROPAGE 0x00
extern void clog_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void clog_desc(char *buf, uint8 xl_info, char *rec);
+extern void clog_desc(StringInfo buf, uint8 xl_info, char *rec);
#endif /* CLOG_H */
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/gist_private.h,v 1.10 2006/03/05 15:58:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/gist_private.h,v 1.11 2006/03/24 04:32:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/* gistxlog.c */
extern void gist_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void gist_desc(char *buf, uint8 xl_info, char *rec);
+extern void gist_desc(StringInfo buf, uint8 xl_info, char *rec);
extern void gist_xlog_startup(void);
extern void gist_xlog_cleanup(void);
extern IndexTuple gist_form_invalid_tuple(BlockNumber blkno);
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/hash.h,v 1.66 2006/03/05 15:58:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/hash.h,v 1.67 2006/03/24 04:32:13 tgl Exp $
*
* NOTES
* modeled after Margo Seltzer's hash implementation for unix.
/* hash.c */
extern void hash_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void hash_desc(char *buf, uint8 xl_info, char *rec);
+extern void hash_desc(StringInfo buf, uint8 xl_info, char *rec);
#endif /* HASH_H */
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.106 2006/03/05 15:58:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.107 2006/03/24 04:32:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
extern void heap_restrpos(HeapScanDesc scan);
extern void heap_redo(XLogRecPtr lsn, XLogRecord *rptr);
-extern void heap_desc(char *buf, uint8 xl_info, char *rec);
+extern void heap_desc(StringInfo buf, uint8 xl_info, char *rec);
extern XLogRecPtr log_heap_clean(Relation reln, Buffer buffer,
OffsetNumber *unused, int uncnt);
extern XLogRecPtr log_heap_move(Relation reln, Buffer oldbuf,
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/multixact.h,v 1.9 2006/03/05 15:58:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/multixact.h,v 1.10 2006/03/24 04:32:13 tgl Exp $
*/
#ifndef MULTIXACT_H
#define MULTIXACT_H
MultiXactOffset minMultiOffset);
extern void multixact_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void multixact_desc(char *buf, uint8 xl_info, char *rec);
+extern void multixact_desc(StringInfo buf, uint8 xl_info, char *rec);
#endif /* MULTIXACT_H */
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.92 2006/03/05 15:58:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.93 2006/03/24 04:32:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* prototypes for functions in nbtxlog.c
*/
extern void btree_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void btree_desc(char *buf, uint8 xl_info, char *rec);
+extern void btree_desc(StringInfo buf, uint8 xl_info, char *rec);
extern void btree_xlog_startup(void);
extern void btree_xlog_cleanup(void);
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/xact.h,v 1.80 2006/03/05 15:58:54 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/xact.h,v 1.81 2006/03/24 04:32:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
extern int xactGetCommittedChildren(TransactionId **ptr);
extern void xact_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void xact_desc(char *buf, uint8 xl_info, char *rec);
+extern void xact_desc(StringInfo buf, uint8 xl_info, char *rec);
#endif /* XACT_H */
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.70 2006/03/05 15:58:54 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.71 2006/03/24 04:32:13 tgl Exp $
*/
#ifndef XLOG_H
#define XLOG_H
#include "access/rmgr.h"
#include "access/transam.h"
#include "access/xlogdefs.h"
+#include "lib/stringinfo.h"
#include "storage/buf.h"
#include "utils/pg_crc.h"
extern void XLogFlush(XLogRecPtr RecPtr);
extern void xlog_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void xlog_desc(char *buf, uint8 xl_info, char *rec);
+extern void xlog_desc(StringInfo buf, uint8 xl_info, char *rec);
extern void UpdateControlFile(void);
extern Size XLOGShmemSize(void);
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/xlog_internal.h,v 1.10 2006/03/05 15:58:54 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/xlog_internal.h,v 1.11 2006/03/24 04:32:13 tgl Exp $
*/
#ifndef XLOG_INTERNAL_H
#define XLOG_INTERNAL_H
{
const char *rm_name;
void (*rm_redo) (XLogRecPtr lsn, XLogRecord *rptr);
- void (*rm_desc) (char *buf, uint8 xl_info, char *rec);
+ void (*rm_desc) (StringInfo buf, uint8 xl_info, char *rec);
void (*rm_startup) (void);
void (*rm_cleanup) (void);
} RmgrData;
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/commands/dbcommands.h,v 1.44 2006/03/05 15:58:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/commands/dbcommands.h,v 1.45 2006/03/24 04:32:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
extern char *get_database_name(Oid dbid);
extern void dbase_redo(XLogRecPtr lsn, XLogRecord *rptr);
-extern void dbase_desc(char *buf, uint8 xl_info, char *rec);
+extern void dbase_desc(StringInfo buf, uint8 xl_info, char *rec);
#endif /* DBCOMMANDS_H */
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/commands/sequence.h,v 1.35 2006/03/05 15:58:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/commands/sequence.h,v 1.36 2006/03/24 04:32:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
extern void AlterSequence(AlterSeqStmt *stmt);
extern void seq_redo(XLogRecPtr lsn, XLogRecord *rptr);
-extern void seq_desc(char *buf, uint8 xl_info, char *rec);
+extern void seq_desc(StringInfo buf, uint8 xl_info, char *rec);
/* Set the upper and lower bounds of a sequence */
#ifndef INT64_IS_BUSTED
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/commands/tablespace.h,v 1.12 2006/03/05 15:58:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/commands/tablespace.h,v 1.13 2006/03/24 04:32:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
extern bool directory_is_empty(const char *path);
extern void tblspc_redo(XLogRecPtr lsn, XLogRecord *rptr);
-extern void tblspc_desc(char *buf, uint8 xl_info, char *rec);
+extern void tblspc_desc(StringInfo buf, uint8 xl_info, char *rec);
#endif /* TABLESPACE_H */
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/smgr.h,v 1.54 2006/03/05 15:59:00 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/storage/smgr.h,v 1.55 2006/03/24 04:32:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
extern void smgrsync(void);
extern void smgr_redo(XLogRecPtr lsn, XLogRecord *record);
-extern void smgr_desc(char *buf, uint8 xl_info, char *rec);
+extern void smgr_desc(StringInfo buf, uint8 xl_info, char *rec);
/* internals: move me elsewhere -- ay 7/94 */