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

Use appendStringInfoString instead of appendStringInfo where possible.

This shaves a few cycles, and generally seems like good programming
practice.

David Rowley
This commit is contained in:
Robert Haas
2013-10-31 10:55:59 -04:00
parent 343bb134ea
commit cacbdd7810
33 changed files with 399 additions and 404 deletions

View File

@@ -37,5 +37,5 @@ clog_desc(StringInfo buf, uint8 xl_info, char *rec)
appendStringInfo(buf, "truncate before: %d", pageno);
}
else
appendStringInfo(buf, "UNKNOWN");
appendStringInfoString(buf, "UNKNOWN");
}

View File

@@ -39,5 +39,5 @@ dbase_desc(StringInfo buf, uint8 xl_info, char *rec)
xlrec->db_id, xlrec->tablespace_id);
}
else
appendStringInfo(buf, "UNKNOWN");
appendStringInfoString(buf, "UNKNOWN");
}

View File

@@ -33,15 +33,15 @@ gin_desc(StringInfo buf, uint8 xl_info, char *rec)
switch (info)
{
case XLOG_GIN_CREATE_INDEX:
appendStringInfo(buf, "Create index, ");
appendStringInfoString(buf, "Create index, ");
desc_node(buf, *(RelFileNode *) rec, GIN_ROOT_BLKNO);
break;
case XLOG_GIN_CREATE_PTREE:
appendStringInfo(buf, "Create posting tree, ");
appendStringInfoString(buf, "Create posting tree, ");
desc_node(buf, ((ginxlogCreatePostingTree *) rec)->node, ((ginxlogCreatePostingTree *) rec)->blkno);
break;
case XLOG_GIN_INSERT:
appendStringInfo(buf, "Insert item, ");
appendStringInfoString(buf, "Insert item, ");
desc_node(buf, ((ginxlogInsert *) rec)->node, ((ginxlogInsert *) rec)->blkno);
appendStringInfo(buf, " offset: %u nitem: %u isdata: %c isleaf %c isdelete %c updateBlkno:%u",
((ginxlogInsert *) rec)->offset,
@@ -52,24 +52,24 @@ gin_desc(StringInfo buf, uint8 xl_info, char *rec)
((ginxlogInsert *) rec)->updateBlkno);
break;
case XLOG_GIN_SPLIT:
appendStringInfo(buf, "Page split, ");
appendStringInfoString(buf, "Page split, ");
desc_node(buf, ((ginxlogSplit *) rec)->node, ((ginxlogSplit *) rec)->lblkno);
appendStringInfo(buf, " isrootsplit: %c", (((ginxlogSplit *) rec)->isRootSplit) ? 'T' : 'F');
break;
case XLOG_GIN_VACUUM_PAGE:
appendStringInfo(buf, "Vacuum page, ");
appendStringInfoString(buf, "Vacuum page, ");
desc_node(buf, ((ginxlogVacuumPage *) rec)->node, ((ginxlogVacuumPage *) rec)->blkno);
break;
case XLOG_GIN_DELETE_PAGE:
appendStringInfo(buf, "Delete page, ");
appendStringInfoString(buf, "Delete page, ");
desc_node(buf, ((ginxlogDeletePage *) rec)->node, ((ginxlogDeletePage *) rec)->blkno);
break;
case XLOG_GIN_UPDATE_META_PAGE:
appendStringInfo(buf, "Update metapage, ");
appendStringInfoString(buf, "Update metapage, ");
desc_node(buf, ((ginxlogUpdateMeta *) rec)->node, GIN_METAPAGE_BLKNO);
break;
case XLOG_GIN_INSERT_LISTPAGE:
appendStringInfo(buf, "Insert new list page, ");
appendStringInfoString(buf, "Insert new list page, ");
desc_node(buf, ((ginxlogInsertListPage *) rec)->node, ((ginxlogInsertListPage *) rec)->blkno);
break;
case XLOG_GIN_DELETE_LISTPAGE:

View File

@@ -35,7 +35,7 @@ out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec)
static void
out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec)
{
appendStringInfo(buf, "page_split: ");
appendStringInfoString(buf, "page_split: ");
out_target(buf, xlrec->node);
appendStringInfo(buf, "; block number %u splits to %d pages",
xlrec->origblkno, xlrec->npage);
@@ -49,7 +49,7 @@ gist_desc(StringInfo buf, uint8 xl_info, char *rec)
switch (info)
{
case XLOG_GIST_PAGE_UPDATE:
appendStringInfo(buf, "page_update: ");
appendStringInfoString(buf, "page_update: ");
out_gistxlogPageUpdate(buf, (gistxlogPageUpdate *) rec);
break;
case XLOG_GIST_PAGE_SPLIT:

View File

@@ -29,15 +29,15 @@ static void
out_infobits(StringInfo buf, uint8 infobits)
{
if (infobits & XLHL_XMAX_IS_MULTI)
appendStringInfo(buf, "IS_MULTI ");
appendStringInfoString(buf, "IS_MULTI ");
if (infobits & XLHL_XMAX_LOCK_ONLY)
appendStringInfo(buf, "LOCK_ONLY ");
appendStringInfoString(buf, "LOCK_ONLY ");
if (infobits & XLHL_XMAX_EXCL_LOCK)
appendStringInfo(buf, "EXCL_LOCK ");
appendStringInfoString(buf, "EXCL_LOCK ");
if (infobits & XLHL_XMAX_KEYSHR_LOCK)
appendStringInfo(buf, "KEYSHR_LOCK ");
appendStringInfoString(buf, "KEYSHR_LOCK ");
if (infobits & XLHL_KEYS_UPDATED)
appendStringInfo(buf, "KEYS_UPDATED ");
appendStringInfoString(buf, "KEYS_UPDATED ");
}
void
@@ -51,16 +51,16 @@ heap_desc(StringInfo buf, uint8 xl_info, char *rec)
xl_heap_insert *xlrec = (xl_heap_insert *) rec;
if (xl_info & XLOG_HEAP_INIT_PAGE)
appendStringInfo(buf, "insert(init): ");
appendStringInfoString(buf, "insert(init): ");
else
appendStringInfo(buf, "insert: ");
appendStringInfoString(buf, "insert: ");
out_target(buf, &(xlrec->target));
}
else if (info == XLOG_HEAP_DELETE)
{
xl_heap_delete *xlrec = (xl_heap_delete *) rec;
appendStringInfo(buf, "delete: ");
appendStringInfoString(buf, "delete: ");
out_target(buf, &(xlrec->target));
appendStringInfoChar(buf, ' ');
out_infobits(buf, xlrec->infobits_set);
@@ -70,9 +70,9 @@ heap_desc(StringInfo buf, uint8 xl_info, char *rec)
xl_heap_update *xlrec = (xl_heap_update *) rec;
if (xl_info & XLOG_HEAP_INIT_PAGE)
appendStringInfo(buf, "update(init): ");
appendStringInfoString(buf, "update(init): ");
else
appendStringInfo(buf, "update: ");
appendStringInfoString(buf, "update: ");
out_target(buf, &(xlrec->target));
appendStringInfo(buf, " xmax %u ", xlrec->old_xmax);
out_infobits(buf, xlrec->old_infobits_set);
@@ -86,9 +86,9 @@ heap_desc(StringInfo buf, uint8 xl_info, char *rec)
xl_heap_update *xlrec = (xl_heap_update *) rec;
if (xl_info & XLOG_HEAP_INIT_PAGE) /* can this case happen? */
appendStringInfo(buf, "hot_update(init): ");
appendStringInfoString(buf, "hot_update(init): ");
else
appendStringInfo(buf, "hot_update: ");
appendStringInfoString(buf, "hot_update: ");
out_target(buf, &(xlrec->target));
appendStringInfo(buf, " xmax %u ", xlrec->old_xmax);
out_infobits(buf, xlrec->old_infobits_set);
@@ -119,11 +119,11 @@ heap_desc(StringInfo buf, uint8 xl_info, char *rec)
{
xl_heap_inplace *xlrec = (xl_heap_inplace *) rec;
appendStringInfo(buf, "inplace: ");
appendStringInfoString(buf, "inplace: ");
out_target(buf, &(xlrec->target));
}
else
appendStringInfo(buf, "UNKNOWN");
appendStringInfoString(buf, "UNKNOWN");
}
void
heap2_desc(StringInfo buf, uint8 xl_info, char *rec)
@@ -169,9 +169,9 @@ heap2_desc(StringInfo buf, uint8 xl_info, char *rec)
xl_heap_multi_insert *xlrec = (xl_heap_multi_insert *) rec;
if (xl_info & XLOG_HEAP_INIT_PAGE)
appendStringInfo(buf, "multi-insert (init): ");
appendStringInfoString(buf, "multi-insert (init): ");
else
appendStringInfo(buf, "multi-insert: ");
appendStringInfoString(buf, "multi-insert: ");
appendStringInfo(buf, "rel %u/%u/%u; blk %u; %d tuples",
xlrec->node.spcNode, xlrec->node.dbNode, xlrec->node.relNode,
xlrec->blkno, xlrec->ntuples);
@@ -185,5 +185,5 @@ heap2_desc(StringInfo buf, uint8 xl_info, char *rec)
out_target(buf, &(xlrec->target));
}
else
appendStringInfo(buf, "UNKNOWN");
appendStringInfoString(buf, "UNKNOWN");
}

View File

@@ -76,5 +76,5 @@ multixact_desc(StringInfo buf, uint8 xl_info, char *rec)
out_member(buf, &xlrec->members[i]);
}
else
appendStringInfo(buf, "UNKNOWN");
appendStringInfoString(buf, "UNKNOWN");
}

View File

@@ -36,7 +36,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
{
xl_btree_insert *xlrec = (xl_btree_insert *) rec;
appendStringInfo(buf, "insert: ");
appendStringInfoString(buf, "insert: ");
out_target(buf, &(xlrec->target));
break;
}
@@ -44,7 +44,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
{
xl_btree_insert *xlrec = (xl_btree_insert *) rec;
appendStringInfo(buf, "insert_upper: ");
appendStringInfoString(buf, "insert_upper: ");
out_target(buf, &(xlrec->target));
break;
}
@@ -52,7 +52,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
{
xl_btree_insert *xlrec = (xl_btree_insert *) rec;
appendStringInfo(buf, "insert_meta: ");
appendStringInfoString(buf, "insert_meta: ");
out_target(buf, &(xlrec->target));
break;
}
@@ -130,7 +130,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
{
xl_btree_delete_page *xlrec = (xl_btree_delete_page *) rec;
appendStringInfo(buf, "delete_page: ");
appendStringInfoString(buf, "delete_page: ");
out_target(buf, &(xlrec->target));
appendStringInfo(buf, "; dead %u; left %u; right %u",
xlrec->deadblk, xlrec->leftblk, xlrec->rightblk);
@@ -156,7 +156,7 @@ btree_desc(StringInfo buf, uint8 xl_info, char *rec)
break;
}
default:
appendStringInfo(buf, "UNKNOWN");
appendStringInfoString(buf, "UNKNOWN");
break;
}
}

View File

@@ -29,5 +29,5 @@ relmap_desc(StringInfo buf, uint8 xl_info, char *rec)
xlrec->dbid, xlrec->tsid, xlrec->nbytes);
}
else
appendStringInfo(buf, "UNKNOWN");
appendStringInfoString(buf, "UNKNOWN");
}

View File

@@ -24,10 +24,10 @@ seq_desc(StringInfo buf, uint8 xl_info, char *rec)
xl_seq_rec *xlrec = (xl_seq_rec *) rec;
if (info == XLOG_SEQ_LOG)
appendStringInfo(buf, "log: ");
appendStringInfoString(buf, "log: ");
else
{
appendStringInfo(buf, "UNKNOWN");
appendStringInfoString(buf, "UNKNOWN");
return;
}

View File

@@ -42,5 +42,5 @@ smgr_desc(StringInfo buf, uint8 xl_info, char *rec)
pfree(path);
}
else
appendStringInfo(buf, "UNKNOWN");
appendStringInfoString(buf, "UNKNOWN");
}

View File

@@ -64,7 +64,7 @@ spg_desc(StringInfo buf, uint8 xl_info, char *rec)
break;
case XLOG_SPGIST_PICKSPLIT:
out_target(buf, ((spgxlogPickSplit *) rec)->node);
appendStringInfo(buf, "split leaf page");
appendStringInfoString(buf, "split leaf page");
break;
case XLOG_SPGIST_VACUUM_LEAF:
out_target(buf, ((spgxlogVacuumLeaf *) rec)->node);

View File

@@ -33,7 +33,7 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
}
if (xlrec->subxid_overflow)
appendStringInfo(buf, "; subxid ovf");
appendStringInfoString(buf, "; subxid ovf");
}
void
@@ -46,7 +46,7 @@ standby_desc(StringInfo buf, uint8 xl_info, char *rec)
xl_standby_locks *xlrec = (xl_standby_locks *) rec;
int i;
appendStringInfo(buf, "AccessExclusive locks:");
appendStringInfoString(buf, "AccessExclusive locks:");
for (i = 0; i < xlrec->nlocks; i++)
appendStringInfo(buf, " xid %u db %u rel %u",
@@ -57,9 +57,9 @@ standby_desc(StringInfo buf, uint8 xl_info, char *rec)
{
xl_running_xacts *xlrec = (xl_running_xacts *) rec;
appendStringInfo(buf, "running xacts:");
appendStringInfoString(buf, "running xacts:");
standby_desc_running_xacts(buf, xlrec);
}
else
appendStringInfo(buf, "UNKNOWN");
appendStringInfoString(buf, "UNKNOWN");
}

View File

@@ -36,5 +36,5 @@ tblspc_desc(StringInfo buf, uint8 xl_info, char *rec)
appendStringInfo(buf, "drop tablespace: %u", xlrec->ts_id);
}
else
appendStringInfo(buf, "UNKNOWN");
appendStringInfoString(buf, "UNKNOWN");
}

View File

@@ -33,7 +33,7 @@ xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
if (xlrec->nrels > 0)
{
appendStringInfo(buf, "; rels:");
appendStringInfoString(buf, "; rels:");
for (i = 0; i < xlrec->nrels; i++)
{
char *path = relpathperm(xlrec->xnodes[i], MAIN_FORKNUM);
@@ -44,7 +44,7 @@ xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
}
if (xlrec->nsubxacts > 0)
{
appendStringInfo(buf, "; subxacts:");
appendStringInfoString(buf, "; subxacts:");
for (i = 0; i < xlrec->nsubxacts; i++)
appendStringInfo(buf, " %u", subxacts[i]);
}
@@ -58,7 +58,7 @@ xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
appendStringInfo(buf, "; relcache init file inval dbid %u tsid %u",
xlrec->dbId, xlrec->tsId);
appendStringInfo(buf, "; inval msgs:");
appendStringInfoString(buf, "; inval msgs:");
for (i = 0; i < xlrec->nmsgs; i++)
{
SharedInvalidationMessage *msg = &msgs[i];
@@ -71,10 +71,10 @@ xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
appendStringInfo(buf, " relcache %u", msg->rc.relId);
/* not expected, but print something anyway */
else if (msg->id == SHAREDINVALSMGR_ID)
appendStringInfo(buf, " smgr");
appendStringInfoString(buf, " smgr");
/* not expected, but print something anyway */
else if (msg->id == SHAREDINVALRELMAP_ID)
appendStringInfo(buf, " relmap");
appendStringInfoString(buf, " relmap");
else if (msg->id == SHAREDINVALSNAPSHOT_ID)
appendStringInfo(buf, " snapshot %u", msg->sn.relId);
else
@@ -92,7 +92,7 @@ xact_desc_commit_compact(StringInfo buf, xl_xact_commit_compact *xlrec)
if (xlrec->nsubxacts > 0)
{
appendStringInfo(buf, "; subxacts:");
appendStringInfoString(buf, "; subxacts:");
for (i = 0; i < xlrec->nsubxacts; i++)
appendStringInfo(buf, " %u", xlrec->subxacts[i]);
}
@@ -106,7 +106,7 @@ xact_desc_abort(StringInfo buf, xl_xact_abort *xlrec)
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
if (xlrec->nrels > 0)
{
appendStringInfo(buf, "; rels:");
appendStringInfoString(buf, "; rels:");
for (i = 0; i < xlrec->nrels; i++)
{
char *path = relpathperm(xlrec->xnodes[i], MAIN_FORKNUM);
@@ -120,7 +120,7 @@ xact_desc_abort(StringInfo buf, xl_xact_abort *xlrec)
TransactionId *xacts = (TransactionId *)
&xlrec->xnodes[xlrec->nrels];
appendStringInfo(buf, "; subxacts:");
appendStringInfoString(buf, "; subxacts:");
for (i = 0; i < xlrec->nsubxacts; i++)
appendStringInfo(buf, " %u", xacts[i]);
}
@@ -131,7 +131,7 @@ xact_desc_assignment(StringInfo buf, xl_xact_assignment *xlrec)
{
int i;
appendStringInfo(buf, "subxacts:");
appendStringInfoString(buf, "subxacts:");
for (i = 0; i < xlrec->nsubxacts; i++)
appendStringInfo(buf, " %u", xlrec->xsub[i]);
@@ -146,26 +146,26 @@ xact_desc(StringInfo buf, uint8 xl_info, char *rec)
{
xl_xact_commit_compact *xlrec = (xl_xact_commit_compact *) rec;
appendStringInfo(buf, "commit: ");
appendStringInfoString(buf, "commit: ");
xact_desc_commit_compact(buf, xlrec);
}
else if (info == XLOG_XACT_COMMIT)
{
xl_xact_commit *xlrec = (xl_xact_commit *) rec;
appendStringInfo(buf, "commit: ");
appendStringInfoString(buf, "commit: ");
xact_desc_commit(buf, xlrec);
}
else if (info == XLOG_XACT_ABORT)
{
xl_xact_abort *xlrec = (xl_xact_abort *) rec;
appendStringInfo(buf, "abort: ");
appendStringInfoString(buf, "abort: ");
xact_desc_abort(buf, xlrec);
}
else if (info == XLOG_XACT_PREPARE)
{
appendStringInfo(buf, "prepare");
appendStringInfoString(buf, "prepare");
}
else if (info == XLOG_XACT_COMMIT_PREPARED)
{
@@ -194,5 +194,5 @@ xact_desc(StringInfo buf, uint8 xl_info, char *rec)
xact_desc_assignment(buf, xlrec);
}
else
appendStringInfo(buf, "UNKNOWN");
appendStringInfoString(buf, "UNKNOWN");
}

View File

@@ -62,7 +62,7 @@ xlog_desc(StringInfo buf, uint8 xl_info, char *rec)
}
else if (info == XLOG_NOOP)
{
appendStringInfo(buf, "xlog no-op");
appendStringInfoString(buf, "xlog no-op");
}
else if (info == XLOG_NEXTOID)
{
@@ -73,7 +73,7 @@ xlog_desc(StringInfo buf, uint8 xl_info, char *rec)
}
else if (info == XLOG_SWITCH)
{
appendStringInfo(buf, "xlog switch");
appendStringInfoString(buf, "xlog switch");
}
else if (info == XLOG_RESTORE_POINT)
{
@@ -141,5 +141,5 @@ xlog_desc(StringInfo buf, uint8 xl_info, char *rec)
timestamptz_to_str(xlrec.end_time));
}
else
appendStringInfo(buf, "UNKNOWN");
appendStringInfoString(buf, "UNKNOWN");
}

View File

@@ -1248,7 +1248,7 @@ begin:;
xlog_outrec(&buf, rechdr);
if (rdata->data != NULL)
{
appendStringInfo(&buf, " - ");
appendStringInfoString(&buf, " - ");
RmgrTable[rechdr->xl_rmid].rm_desc(&buf, rechdr->xl_info, rdata->data);
}
elog(LOG, "%s", buf.data);
@@ -6677,7 +6677,7 @@ StartupXLOG(void)
(uint32) (ReadRecPtr >> 32), (uint32) ReadRecPtr,
(uint32) (EndRecPtr >> 32), (uint32) EndRecPtr);
xlog_outrec(&buf, record);
appendStringInfo(&buf, " - ");
appendStringInfoString(&buf, " - ");
RmgrTable[record->xl_rmid].rm_desc(&buf,
record->xl_info,
XLogRecGetData(record));