aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gistxlog.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-03-24 04:32:13 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-03-24 04:32:13 +0000
commit0a202070603bf38ce2e2fc11a7f897fc06603b80 (patch)
treea856ccc9da2bf3ec6ec57da03788e27e89c22428 /src/backend/access/gist/gistxlog.c
parent4fb92718be654b38652dfe893d075f3862e84eae (diff)
downloadpostgresql-0a202070603bf38ce2e2fc11a7f897fc06603b80.tar.gz
postgresql-0a202070603bf38ce2e2fc11a7f897fc06603b80.zip
Arrange to emit a description of the current XLOG record as error context
when an error occurs during xlog replay. Also, replace the former risky 'write into a fixed-size buffer with no overflow detection' API for XLOG record description routines; use an expansible StringInfo instead. (The latter accounts for most of the patch bulk.) Qingqing Zhou
Diffstat (limited to 'src/backend/access/gist/gistxlog.c')
-rw-r--r--src/backend/access/gist/gistxlog.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/backend/access/gist/gistxlog.c b/src/backend/access/gist/gistxlog.c
index e60317c0b34..911c9a02a9c 100644
--- a/src/backend/access/gist/gistxlog.c
+++ b/src/backend/access/gist/gistxlog.c
@@ -8,7 +8,7 @@
* 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"
@@ -442,67 +442,67 @@ gist_redo(XLogRecPtr lsn, XLogRecord *record)
}
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;
}
}