]> granicus.if.org Git - postgresql/commitdiff
Use appendStringInfoString/Char et al where appropriate.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 2 Jul 2015 09:32:48 +0000 (12:32 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 2 Jul 2015 09:36:31 +0000 (12:36 +0300)
Patch by David Rowley. Backpatch to 9.5, as some of the calls were new in
9.5, and keeping the code in sync with master makes future backpatching
easier.

17 files changed:
contrib/postgres_fdw/postgres_fdw.c
src/backend/access/rmgrdesc/gindesc.c
src/backend/access/rmgrdesc/spgdesc.c
src/backend/access/rmgrdesc/xactdesc.c
src/backend/access/transam/xlog.c
src/backend/lib/pairingheap.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/xml.c
src/bin/pg_basebackup/pg_basebackup.c
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_dump.c
src/bin/psql/describe.c
src/bin/scripts/clusterdb.c
src/bin/scripts/createdb.c
src/bin/scripts/createuser.c
src/bin/scripts/reindexdb.c
src/bin/scripts/vacuumdb.c

index 6da01e1d6f35fcb28bbd80ea290faf5a4c7592a2..e4d799cecd541c777e21e7b48339b83c9e4b17b9 100644 (file)
@@ -2738,7 +2738,7 @@ postgresImportForeignSchema(ImportForeignSchemaStmt *stmt, Oid serverOid)
                }
 
                /* Append ORDER BY at the end of query to ensure output ordering */
-               appendStringInfo(&buf, " ORDER BY c.relname, a.attnum");
+               appendStringInfoString(&buf, " ORDER BY c.relname, a.attnum");
 
                /* Fetch the data */
                res = PQexec(conn, buf.data);
index 324efa3769906c81cf23f44e167b40f56915c02e..09e928fb7c6dab1c1aa08ff8643f041be53ab103 100644 (file)
@@ -113,7 +113,7 @@ gin_desc(StringInfo buf, XLogReaderState *record)
                                        (ginxlogRecompressDataLeaf *) payload;
 
                                        if (XLogRecHasBlockImage(record, 0))
-                                               appendStringInfo(buf, " (full page image)");
+                                               appendStringInfoString(buf, " (full page image)");
                                        else
                                                desc_recompress_leaf(buf, insertData);
                                }
@@ -147,7 +147,7 @@ gin_desc(StringInfo buf, XLogReaderState *record)
                                ginxlogVacuumDataLeafPage *xlrec = (ginxlogVacuumDataLeafPage *) rec;
 
                                if (XLogRecHasBlockImage(record, 0))
-                                       appendStringInfo(buf, " (full page image)");
+                                       appendStringInfoString(buf, " (full page image)");
                                else
                                        desc_recompress_leaf(buf, &xlrec->data);
                        }
index 6e426d7b8c721037cab754300feb5fc5fc552717..478f50c7a0d2055a258c77ff5c47ee859ef21dca 100644 (file)
@@ -30,14 +30,14 @@ spg_desc(StringInfo buf, XLogReaderState *record)
                        {
                                spgxlogAddLeaf *xlrec = (spgxlogAddLeaf *) rec;
 
-                               appendStringInfo(buf, "add leaf to page");
+                               appendStringInfoString(buf, "add leaf to page");
                                appendStringInfo(buf, "; off %u; headoff %u; parentoff %u",
                                                                 xlrec->offnumLeaf, xlrec->offnumHeadLeaf,
                                                                 xlrec->offnumParent);
                                if (xlrec->newPage)
-                                       appendStringInfo(buf, " (newpage)");
+                                       appendStringInfoString(buf, " (newpage)");
                                if (xlrec->storesNulls)
-                                       appendStringInfo(buf, " (nulls)");
+                                       appendStringInfoString(buf, " (nulls)");
                        }
                        break;
                case XLOG_SPGIST_MOVE_LEAFS:
@@ -63,9 +63,9 @@ spg_desc(StringInfo buf, XLogReaderState *record)
                                appendStringInfo(buf, "ndel %u; nins %u",
                                                                 xlrec->nDelete, xlrec->nInsert);
                                if (xlrec->innerIsParent)
-                                       appendStringInfo(buf, " (innerIsParent)");
+                                       appendStringInfoString(buf, " (innerIsParent)");
                                if (xlrec->isRootSplit)
-                                       appendStringInfo(buf, " (isRootSplit)");
+                                       appendStringInfoString(buf, " (isRootSplit)");
                        }
                        break;
                case XLOG_SPGIST_VACUUM_LEAF:
index 7b5f98305070c9db43367a301983cef749ba04f1..e811c0a61ee463190f5b12079afc17e55b2273b0 100644 (file)
@@ -232,7 +232,7 @@ xact_desc_commit(StringInfo buf, uint8 info, xl_xact_commit *xlrec, RepOriginId
        }
 
        if (XactCompletionForceSyncCommit(parsed.xinfo))
-               appendStringInfo(buf, "; sync");
+               appendStringInfoString(buf, "; sync");
 
        if (parsed.xinfo & XACT_XINFO_HAS_ORIGIN)
        {
index bb7cd9f775c9c126e9510e3ec205c713d7c8647a..1dd31b37ffe06e67bd3756489f2b139cea6dfce7 100644 (file)
@@ -1097,7 +1097,7 @@ XLogInsertRecord(XLogRecData *rdata, XLogRecPtr fpw_lsn)
 
                if (!debug_reader)
                {
-                       appendStringInfo(&buf, "error decoding record: out of memory");
+                       appendStringInfoString(&buf, "error decoding record: out of memory");
                }
                else if (!DecodeXLogRecord(debug_reader, (XLogRecord *) recordBuf.data,
                                                                   &errormsg))
@@ -9528,7 +9528,7 @@ xlog_outrec(StringInfo buf, XLogReaderState *record)
                                                         rnode.spcNode, rnode.dbNode, rnode.relNode,
                                                         blk);
                if (XLogRecHasBlockImage(record, block_id))
-                       appendStringInfo(buf, " FPW");
+                       appendStringInfoString(buf, " FPW");
        }
 }
 #endif   /* WAL_DEBUG */
index 3d8a5ea56189c2a909111018305efdcbba2b081c..7ca35452ded66a2b7de908cd8a33779bcdcc52f6 100644 (file)
@@ -306,7 +306,7 @@ pairingheap_dump_recurse(StringInfo buf,
 
                appendStringInfoSpaces(buf, depth * 4);
                dumpfunc(node, buf, opaque);
-               appendStringInfoString(buf, "\n");
+               appendStringInfoChar(buf, '\n');
                if (node->first_child)
                        pairingheap_dump_recurse(buf, node->first_child, dumpfunc, opaque, depth + 1, node);
                prev_or_parent = node;
index 2cd4b62701f6faec029dd033501066e1334aa32b..5112cac90173595d56c7cc14beba8ebfcc9113e7 100644 (file)
@@ -5487,7 +5487,7 @@ get_insert_query_def(Query *query, deparse_context *context)
        {
                OnConflictExpr *confl = query->onConflict;
 
-               appendStringInfo(buf, " ON CONFLICT");
+               appendStringInfoString(buf, " ON CONFLICT");
 
                if (confl->arbiterElems)
                {
index 99bc832ab826b937a1974ec349dcf49f2ecc711f..31dfc4d2a7a912ede4b9bc975da41b1655731c66 100644 (file)
@@ -2473,7 +2473,7 @@ query_to_xml_internal(const char *query, char *tablename,
        {
                xmldata_root_element_start(result, xmltn, xmlschema,
                                                                   targetns, top_level);
-               appendStringInfoString(result, "\n");
+               appendStringInfoChar(result, '\n');
        }
 
        if (xmlschema)
@@ -2637,7 +2637,7 @@ schema_to_xml_internal(Oid nspid, const char *xmlschema, bool nulls,
        result = makeStringInfo();
 
        xmldata_root_element_start(result, xmlsn, xmlschema, targetns, top_level);
-       appendStringInfoString(result, "\n");
+       appendStringInfoChar(result, '\n');
 
        if (xmlschema)
                appendStringInfo(result, "%s\n\n", xmlschema);
@@ -2815,7 +2815,7 @@ database_to_xml_internal(const char *xmlschema, bool nulls,
        result = makeStringInfo();
 
        xmldata_root_element_start(result, xmlcn, xmlschema, targetns, true);
-       appendStringInfoString(result, "\n");
+       appendStringInfoChar(result, '\n');
 
        if (xmlschema)
                appendStringInfo(result, "%s\n\n", xmlschema);
index 5dd2887d12e9b633b1f54e028ff8c004d24e2c45..536368020b004545736bf51e2a7379e45fa4b0ae 100644 (file)
@@ -1516,7 +1516,7 @@ GenerateRecoveryConf(PGconn *conn)
 
                /* Separate key-value pairs with spaces */
                if (conninfo_buf.len != 0)
-                       appendPQExpBufferStr(&conninfo_buf, " ");
+                       appendPQExpBufferChar(&conninfo_buf, ' ');
 
                /*
                 * Write "keyword=value" pieces, the value string is escaped and/or
index f9b564eee41a0a9421611d9a38c8a5044b366052..0d52babc4f1794f3ce006e3846a1813b4b7c834a 100644 (file)
@@ -533,7 +533,7 @@ RestoreArchive(Archive *AHX)
                                                         * search for hardcoded "DROP CONSTRAINT" instead.
                                                         */
                                                        if (strcmp(te->desc, "DEFAULT") == 0)
-                                                               appendPQExpBuffer(ftStmt, "%s", dropStmt);
+                                                               appendPQExpBufferStr(ftStmt, dropStmt);
                                                        else
                                                        {
                                                                if (strcmp(te->desc, "CONSTRAINT") == 0 ||
index a72dfe93da939d466fed007105cc3d408d229bf5..0a8129020bdda59682f88048922bf7bbbb83b8bc 100644 (file)
@@ -1659,7 +1659,7 @@ dumpTableData_insert(Archive *fout, DumpOptions *dopt, void *dcontext)
                                        /* append the list of column names if required */
                                        if (dopt->column_inserts)
                                        {
-                                               appendPQExpBufferStr(insertStmt, "(");
+                                               appendPQExpBufferChar(insertStmt, '(');
                                                for (field = 0; field < nfields; field++)
                                                {
                                                        if (field > 0)
@@ -11332,7 +11332,7 @@ dumpOpclass(Archive *fout, DumpOptions *dopt, OpclassInfo *opcinfo)
                appendPQExpBufferStr(q, " FAMILY ");
                if (strcmp(opcfamilynsp, opcinfo->dobj.namespace->dobj.name) != 0)
                        appendPQExpBuffer(q, "%s.", fmtId(opcfamilynsp));
-               appendPQExpBuffer(q, "%s", fmtId(opcfamilyname));
+               appendPQExpBufferStr(q, fmtId(opcfamilyname));
        }
        appendPQExpBufferStr(q, " AS\n    ");
 
@@ -13844,7 +13844,7 @@ dumpTableSchema(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
                                        if (actual_atts == 0)
                                                appendPQExpBufferStr(q, " (");
                                        else
-                                               appendPQExpBufferStr(q, ",");
+                                               appendPQExpBufferChar(q, ',');
                                        appendPQExpBufferStr(q, "\n    ");
                                        actual_atts++;
 
index db568096dcef988c68bccd651b17784531fc6937..f63c7e90d3c0a512305e84dc6ffa0906e6096284 100644 (file)
@@ -1611,7 +1611,7 @@ describeOneTableDetails(const char *schemaname,
                        if (!PQgetisnull(res, i, 5))
                        {
                                if (tmpbuf.len > 0)
-                                       appendPQExpBufferStr(&tmpbuf, " ");
+                                       appendPQExpBufferChar(&tmpbuf, ' ');
                                appendPQExpBuffer(&tmpbuf, _("collate %s"),
                                                                  PQgetvalue(res, i, 5));
                        }
@@ -1619,7 +1619,7 @@ describeOneTableDetails(const char *schemaname,
                        if (strcmp(PQgetvalue(res, i, 3), "t") == 0)
                        {
                                if (tmpbuf.len > 0)
-                                       appendPQExpBufferStr(&tmpbuf, " ");
+                                       appendPQExpBufferChar(&tmpbuf, ' ');
                                appendPQExpBufferStr(&tmpbuf, _("not null"));
                        }
 
@@ -1628,7 +1628,7 @@ describeOneTableDetails(const char *schemaname,
                        if (strlen(PQgetvalue(res, i, 2)) != 0)
                        {
                                if (tmpbuf.len > 0)
-                                       appendPQExpBufferStr(&tmpbuf, " ");
+                                       appendPQExpBufferChar(&tmpbuf, ' ');
                                /* translator: default values of column definitions */
                                appendPQExpBuffer(&tmpbuf, _("default %s"),
                                                                  PQgetvalue(res, i, 2));
@@ -2440,7 +2440,7 @@ describeOneTableDetails(const char *schemaname,
                                        printfPQExpBuffer(&buf, "%*s  %s",
                                                                          sw, "", PQgetvalue(result, i, 0));
                                if (i < tuples - 1)
-                                       appendPQExpBufferStr(&buf, ",");
+                                       appendPQExpBufferChar(&buf, ',');
 
                                printTableAddFooter(&cont, buf.data);
                        }
index 85087af7956718ad92dca5d81f4e5c47c2c8f19b..8c0e7cfab28ddb2e323f2465b2bc06bacea16fc3 100644 (file)
@@ -201,7 +201,7 @@ cluster_one_database(const char *dbname, bool verbose, const char *table,
                appendPQExpBufferStr(&sql, " VERBOSE");
        if (table)
                appendPQExpBuffer(&sql, " %s", table);
-       appendPQExpBufferStr(&sql, ";");
+       appendPQExpBufferChar(&sql, ';');
 
        conn = connectDatabase(dbname, host, port, username, prompt_password,
                                                   progname, false);
index a958bb86f014c47257482b5278c3dd41ea0558c5..4d3fb22622aa69a2997c551b7506925b10230627 100644 (file)
@@ -195,7 +195,7 @@ main(int argc, char *argv[])
        if (lc_ctype)
                appendPQExpBuffer(&sql, " LC_CTYPE '%s'", lc_ctype);
 
-       appendPQExpBufferStr(&sql, ";");
+       appendPQExpBufferChar(&sql, ';');
 
        /* No point in trying to use postgres db when creating postgres db. */
        if (maintenance_db == NULL && strcmp(dbname, "postgres") == 0)
@@ -222,7 +222,7 @@ main(int argc, char *argv[])
        {
                printfPQExpBuffer(&sql, "COMMENT ON DATABASE %s IS ", fmtId(dbname));
                appendStringLiteralConn(&sql, comment, conn);
-               appendPQExpBufferStr(&sql, ";");
+               appendPQExpBufferChar(&sql, ';');
 
                if (echo)
                        printf("%s\n", sql.data);
index fba21a1c659979d85431b402aff30b7fbbd76392..c8bcf0d0b2e65c79dc6f6240f2859991bed690e3 100644 (file)
@@ -321,7 +321,7 @@ main(int argc, char *argv[])
                                appendPQExpBuffer(&sql, "%s", fmtId(cell->val));
                }
        }
-       appendPQExpBufferStr(&sql, ";");
+       appendPQExpBufferChar(&sql, ';');
 
        if (echo)
                printf("%s\n", sql.data);
index 941729da2e7871235394c3cb74e916ef023cbe51..80c78860bee5ca859397c796255941101c0b906f 100644 (file)
@@ -295,7 +295,7 @@ reindex_one_database(const char *name, const char *dbname, const char *type,
                appendPQExpBuffer(&sql, " SCHEMA %s", name);
        else if (strcmp(type, "DATABASE") == 0)
                appendPQExpBuffer(&sql, " DATABASE %s", fmtId(name));
-       appendPQExpBufferStr(&sql, ";");
+       appendPQExpBufferChar(&sql, ';');
 
        conn = connectDatabase(dbname, host, port, username, prompt_password,
                                                   progname, false);
index f600b0514a8d8832ef4bc24fdb6e40e5b3eb5661..ca6d00368325f6b9a27c21ecf00d9e022f9f4cb0 100644 (file)
@@ -392,7 +392,7 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
                ntups = PQntuples(res);
                for (i = 0; i < ntups; i++)
                {
-                       appendPQExpBuffer(&buf, "%s",
+                       appendPQExpBufferStr(&buf,
                                                          fmtQualifiedId(PQserverVersion(conn),
                                                                                         PQgetvalue(res, i, 1),
                                                                                         PQgetvalue(res, i, 0)));
@@ -643,7 +643,7 @@ prepare_vacuum_command(PQExpBuffer sql, PGconn *conn, vacuumingOptions *vacopts,
                                sep = comma;
                        }
                        if (sep != paren)
-                               appendPQExpBufferStr(sql, ")");
+                               appendPQExpBufferChar(sql, ')');
                }
                else
                {