1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

Replace appendPQExpBuffer(..., <constant>) with appendPQExpBufferStr

Arguably makes the code a bit more readable, and might give a small
performance gain.

David Rowley
This commit is contained in:
Heikki Linnakangas
2013-11-18 18:29:01 +02:00
parent f1df4731ee
commit 32ceba3ea7
15 changed files with 739 additions and 750 deletions

View File

@ -196,12 +196,12 @@ cluster_one_database(const char *dbname, bool verbose, const char *table,
initPQExpBuffer(&sql);
appendPQExpBuffer(&sql, "CLUSTER");
appendPQExpBufferStr(&sql, "CLUSTER");
if (verbose)
appendPQExpBuffer(&sql, " VERBOSE");
appendPQExpBufferStr(&sql, " VERBOSE");
if (table)
appendPQExpBuffer(&sql, " %s", table);
appendPQExpBuffer(&sql, ";\n");
appendPQExpBufferStr(&sql, ";\n");
conn = connectDatabase(dbname, host, port, username, prompt_password,
progname, false);

View File

@ -195,7 +195,7 @@ main(int argc, char *argv[])
if (lc_ctype)
appendPQExpBuffer(&sql, " LC_CTYPE '%s'", lc_ctype);
appendPQExpBuffer(&sql, ";\n");
appendPQExpBufferStr(&sql, ";\n");
/* 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);
appendPQExpBuffer(&sql, ";\n");
appendPQExpBufferStr(&sql, ";\n");
if (echo)
printf("%s", sql.data);

View File

@ -254,10 +254,10 @@ main(int argc, char *argv[])
if (newpassword)
{
if (encrypted == TRI_YES)
appendPQExpBuffer(&sql, " ENCRYPTED");
appendPQExpBufferStr(&sql, " ENCRYPTED");
if (encrypted == TRI_NO)
appendPQExpBuffer(&sql, " UNENCRYPTED");
appendPQExpBuffer(&sql, " PASSWORD ");
appendPQExpBufferStr(&sql, " UNENCRYPTED");
appendPQExpBufferStr(&sql, " PASSWORD ");
if (encrypted != TRI_NO)
{
@ -277,32 +277,32 @@ main(int argc, char *argv[])
appendStringLiteralConn(&sql, newpassword, conn);
}
if (superuser == TRI_YES)
appendPQExpBuffer(&sql, " SUPERUSER");
appendPQExpBufferStr(&sql, " SUPERUSER");
if (superuser == TRI_NO)
appendPQExpBuffer(&sql, " NOSUPERUSER");
appendPQExpBufferStr(&sql, " NOSUPERUSER");
if (createdb == TRI_YES)
appendPQExpBuffer(&sql, " CREATEDB");
appendPQExpBufferStr(&sql, " CREATEDB");
if (createdb == TRI_NO)
appendPQExpBuffer(&sql, " NOCREATEDB");
appendPQExpBufferStr(&sql, " NOCREATEDB");
if (createrole == TRI_YES)
appendPQExpBuffer(&sql, " CREATEROLE");
appendPQExpBufferStr(&sql, " CREATEROLE");
if (createrole == TRI_NO)
appendPQExpBuffer(&sql, " NOCREATEROLE");
appendPQExpBufferStr(&sql, " NOCREATEROLE");
if (inherit == TRI_YES)
appendPQExpBuffer(&sql, " INHERIT");
appendPQExpBufferStr(&sql, " INHERIT");
if (inherit == TRI_NO)
appendPQExpBuffer(&sql, " NOINHERIT");
appendPQExpBufferStr(&sql, " NOINHERIT");
if (login == TRI_YES)
appendPQExpBuffer(&sql, " LOGIN");
appendPQExpBufferStr(&sql, " LOGIN");
if (login == TRI_NO)
appendPQExpBuffer(&sql, " NOLOGIN");
appendPQExpBufferStr(&sql, " NOLOGIN");
if (replication == TRI_YES)
appendPQExpBuffer(&sql, " REPLICATION");
appendPQExpBufferStr(&sql, " REPLICATION");
if (replication == TRI_NO)
appendPQExpBuffer(&sql, " NOREPLICATION");
appendPQExpBufferStr(&sql, " NOREPLICATION");
if (conn_limit != NULL)
appendPQExpBuffer(&sql, " CONNECTION LIMIT %s", conn_limit);
appendPQExpBuffer(&sql, ";\n");
appendPQExpBufferStr(&sql, ";\n");
if (echo)
printf("%s", sql.data);

View File

@ -246,14 +246,14 @@ reindex_one_database(const char *name, const char *dbname, const char *type,
initPQExpBuffer(&sql);
appendPQExpBuffer(&sql, "REINDEX");
appendPQExpBufferStr(&sql, "REINDEX");
if (strcmp(type, "TABLE") == 0)
appendPQExpBuffer(&sql, " TABLE %s", name);
else if (strcmp(type, "INDEX") == 0)
appendPQExpBuffer(&sql, " INDEX %s", name);
else if (strcmp(type, "DATABASE") == 0)
appendPQExpBuffer(&sql, " DATABASE %s", fmtId(name));
appendPQExpBuffer(&sql, ";\n");
appendPQExpBufferStr(&sql, ";\n");
conn = connectDatabase(dbname, host, port, username, prompt_password,
progname, false);

View File

@ -248,13 +248,13 @@ vacuum_one_database(const char *dbname, bool full, bool verbose, bool and_analyz
if (analyze_only)
{
appendPQExpBuffer(&sql, "ANALYZE");
appendPQExpBufferStr(&sql, "ANALYZE");
if (verbose)
appendPQExpBuffer(&sql, " VERBOSE");
appendPQExpBufferStr(&sql, " VERBOSE");
}
else
{
appendPQExpBuffer(&sql, "VACUUM");
appendPQExpBufferStr(&sql, "VACUUM");
if (PQserverVersion(conn) >= 90000)
{
const char *paren = " (";
@ -282,23 +282,23 @@ vacuum_one_database(const char *dbname, bool full, bool verbose, bool and_analyz
sep = comma;
}
if (sep != paren)
appendPQExpBuffer(&sql, ")");
appendPQExpBufferStr(&sql, ")");
}
else
{
if (full)
appendPQExpBuffer(&sql, " FULL");
appendPQExpBufferStr(&sql, " FULL");
if (freeze)
appendPQExpBuffer(&sql, " FREEZE");
appendPQExpBufferStr(&sql, " FREEZE");
if (verbose)
appendPQExpBuffer(&sql, " VERBOSE");
appendPQExpBufferStr(&sql, " VERBOSE");
if (and_analyze)
appendPQExpBuffer(&sql, " ANALYZE");
appendPQExpBufferStr(&sql, " ANALYZE");
}
}
if (table)
appendPQExpBuffer(&sql, " %s", table);
appendPQExpBuffer(&sql, ";\n");
appendPQExpBufferStr(&sql, ";\n");
if (!executeMaintenanceCommand(conn, sql.data, echo))
{