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:
parent
f1df4731ee
commit
32ceba3ea7
@ -168,11 +168,11 @@ fmtQualifiedId(int remoteVersion, const char *schema, const char *id)
|
||||
{
|
||||
appendPQExpBuffer(lcl_pqexp, "%s.", fmtId(schema));
|
||||
}
|
||||
appendPQExpBuffer(lcl_pqexp, "%s", fmtId(id));
|
||||
appendPQExpBufferStr(lcl_pqexp, fmtId(id));
|
||||
|
||||
id_return = getLocalPQExpBuffer();
|
||||
|
||||
appendPQExpBuffer(id_return, "%s", lcl_pqexp->data);
|
||||
appendPQExpBufferStr(id_return, lcl_pqexp->data);
|
||||
destroyPQExpBuffer(lcl_pqexp);
|
||||
|
||||
return id_return->data;
|
||||
@ -625,7 +625,7 @@ buildACLCommands(const char *name, const char *subname,
|
||||
appendPQExpBuffer(secondsql, "%sGRANT %s ON %s %s TO ",
|
||||
prefix, privs->data, type, name);
|
||||
if (grantee->len == 0)
|
||||
appendPQExpBuffer(secondsql, "PUBLIC;\n");
|
||||
appendPQExpBufferStr(secondsql, "PUBLIC;\n");
|
||||
else if (strncmp(grantee->data, "group ",
|
||||
strlen("group ")) == 0)
|
||||
appendPQExpBuffer(secondsql, "GROUP %s;\n",
|
||||
@ -638,19 +638,19 @@ buildACLCommands(const char *name, const char *subname,
|
||||
appendPQExpBuffer(secondsql, "%sGRANT %s ON %s %s TO ",
|
||||
prefix, privswgo->data, type, name);
|
||||
if (grantee->len == 0)
|
||||
appendPQExpBuffer(secondsql, "PUBLIC");
|
||||
appendPQExpBufferStr(secondsql, "PUBLIC");
|
||||
else if (strncmp(grantee->data, "group ",
|
||||
strlen("group ")) == 0)
|
||||
appendPQExpBuffer(secondsql, "GROUP %s",
|
||||
fmtId(grantee->data + strlen("group ")));
|
||||
else
|
||||
appendPQExpBuffer(secondsql, "%s", fmtId(grantee->data));
|
||||
appendPQExpBuffer(secondsql, " WITH GRANT OPTION;\n");
|
||||
appendPQExpBufferStr(secondsql, fmtId(grantee->data));
|
||||
appendPQExpBufferStr(secondsql, " WITH GRANT OPTION;\n");
|
||||
}
|
||||
|
||||
if (grantor->len > 0
|
||||
&& (!owner || strcmp(owner, grantor->data) != 0))
|
||||
appendPQExpBuffer(secondsql, "RESET SESSION AUTHORIZATION;\n");
|
||||
appendPQExpBufferStr(secondsql, "RESET SESSION AUTHORIZATION;\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -947,7 +947,7 @@ AddAcl(PQExpBuffer aclbuf, const char *keyword, const char *subname)
|
||||
{
|
||||
if (aclbuf->len > 0)
|
||||
appendPQExpBufferChar(aclbuf, ',');
|
||||
appendPQExpBuffer(aclbuf, "%s", keyword);
|
||||
appendPQExpBufferStr(aclbuf, keyword);
|
||||
if (subname)
|
||||
appendPQExpBuffer(aclbuf, "(%s)", subname);
|
||||
}
|
||||
@ -1205,7 +1205,7 @@ emitShSecLabels(PGconn *conn, PGresult *res, PQExpBuffer buffer,
|
||||
" %s IS ",
|
||||
fmtId(objname));
|
||||
appendStringLiteralConn(buffer, label, conn);
|
||||
appendPQExpBuffer(buffer, ";\n");
|
||||
appendPQExpBufferStr(buffer, ";\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2619,7 +2619,7 @@ _doSetSessionAuth(ArchiveHandle *AH, const char *user)
|
||||
{
|
||||
PQExpBuffer cmd = createPQExpBuffer();
|
||||
|
||||
appendPQExpBuffer(cmd, "SET SESSION AUTHORIZATION ");
|
||||
appendPQExpBufferStr(cmd, "SET SESSION AUTHORIZATION ");
|
||||
|
||||
/*
|
||||
* SQL requires a string literal here. Might as well be correct.
|
||||
@ -2627,8 +2627,8 @@ _doSetSessionAuth(ArchiveHandle *AH, const char *user)
|
||||
if (user && *user)
|
||||
appendStringLiteralAHX(cmd, user, AH);
|
||||
else
|
||||
appendPQExpBuffer(cmd, "DEFAULT");
|
||||
appendPQExpBuffer(cmd, ";");
|
||||
appendPQExpBufferStr(cmd, "DEFAULT");
|
||||
appendPQExpBufferChar(cmd, ';');
|
||||
|
||||
if (RestoringToDB(AH))
|
||||
{
|
||||
@ -2798,7 +2798,7 @@ _selectOutputSchema(ArchiveHandle *AH, const char *schemaName)
|
||||
appendPQExpBuffer(qry, "SET search_path = %s",
|
||||
fmtId(schemaName));
|
||||
if (strcmp(schemaName, "pg_catalog") != 0)
|
||||
appendPQExpBuffer(qry, ", pg_catalog");
|
||||
appendPQExpBufferStr(qry, ", pg_catalog");
|
||||
|
||||
if (RestoringToDB(AH))
|
||||
{
|
||||
@ -2853,7 +2853,7 @@ _selectTablespace(ArchiveHandle *AH, const char *tablespace)
|
||||
if (strcmp(want, "") == 0)
|
||||
{
|
||||
/* We want the tablespace to be the database's default */
|
||||
appendPQExpBuffer(qry, "SET default_tablespace = ''");
|
||||
appendPQExpBufferStr(qry, "SET default_tablespace = ''");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3119,7 +3119,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
|
||||
{
|
||||
PQExpBuffer temp = createPQExpBuffer();
|
||||
|
||||
appendPQExpBuffer(temp, "ALTER ");
|
||||
appendPQExpBufferStr(temp, "ALTER ");
|
||||
_getObjectDescription(temp, te, AH);
|
||||
appendPQExpBuffer(temp, " OWNER TO %s;", fmtId(te->owner));
|
||||
ahprintf(AH, "%s\n\n", temp->data);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -199,7 +199,7 @@ main(int argc, char *argv[])
|
||||
{
|
||||
case 'a':
|
||||
data_only = true;
|
||||
appendPQExpBuffer(pgdumpopts, " -a");
|
||||
appendPQExpBufferStr(pgdumpopts, " -a");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
@ -212,7 +212,7 @@ main(int argc, char *argv[])
|
||||
|
||||
case 'f':
|
||||
filename = pg_strdup(optarg);
|
||||
appendPQExpBuffer(pgdumpopts, " -f ");
|
||||
appendPQExpBufferStr(pgdumpopts, " -f ");
|
||||
doShellQuoting(pgdumpopts, filename);
|
||||
break;
|
||||
|
||||
@ -233,11 +233,11 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
appendPQExpBuffer(pgdumpopts, " -o");
|
||||
appendPQExpBufferStr(pgdumpopts, " -o");
|
||||
break;
|
||||
|
||||
case 'O':
|
||||
appendPQExpBuffer(pgdumpopts, " -O");
|
||||
appendPQExpBufferStr(pgdumpopts, " -O");
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
@ -249,11 +249,11 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 's':
|
||||
appendPQExpBuffer(pgdumpopts, " -s");
|
||||
appendPQExpBufferStr(pgdumpopts, " -s");
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
appendPQExpBuffer(pgdumpopts, " -S ");
|
||||
appendPQExpBufferStr(pgdumpopts, " -S ");
|
||||
doShellQuoting(pgdumpopts, optarg);
|
||||
break;
|
||||
|
||||
@ -267,35 +267,35 @@ main(int argc, char *argv[])
|
||||
|
||||
case 'v':
|
||||
verbose = true;
|
||||
appendPQExpBuffer(pgdumpopts, " -v");
|
||||
appendPQExpBufferStr(pgdumpopts, " -v");
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
prompt_password = TRI_NO;
|
||||
appendPQExpBuffer(pgdumpopts, " -w");
|
||||
appendPQExpBufferStr(pgdumpopts, " -w");
|
||||
break;
|
||||
|
||||
case 'W':
|
||||
prompt_password = TRI_YES;
|
||||
appendPQExpBuffer(pgdumpopts, " -W");
|
||||
appendPQExpBufferStr(pgdumpopts, " -W");
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
skip_acls = true;
|
||||
appendPQExpBuffer(pgdumpopts, " -x");
|
||||
appendPQExpBufferStr(pgdumpopts, " -x");
|
||||
break;
|
||||
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 2:
|
||||
appendPQExpBuffer(pgdumpopts, " --lock-wait-timeout ");
|
||||
appendPQExpBufferStr(pgdumpopts, " --lock-wait-timeout ");
|
||||
doShellQuoting(pgdumpopts, optarg);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
use_role = pg_strdup(optarg);
|
||||
appendPQExpBuffer(pgdumpopts, " --role ");
|
||||
appendPQExpBufferStr(pgdumpopts, " --role ");
|
||||
doShellQuoting(pgdumpopts, use_role);
|
||||
break;
|
||||
|
||||
@ -345,25 +345,25 @@ main(int argc, char *argv[])
|
||||
|
||||
/* Add long options to the pg_dump argument list */
|
||||
if (binary_upgrade)
|
||||
appendPQExpBuffer(pgdumpopts, " --binary-upgrade");
|
||||
appendPQExpBufferStr(pgdumpopts, " --binary-upgrade");
|
||||
if (column_inserts)
|
||||
appendPQExpBuffer(pgdumpopts, " --column-inserts");
|
||||
appendPQExpBufferStr(pgdumpopts, " --column-inserts");
|
||||
if (disable_dollar_quoting)
|
||||
appendPQExpBuffer(pgdumpopts, " --disable-dollar-quoting");
|
||||
appendPQExpBufferStr(pgdumpopts, " --disable-dollar-quoting");
|
||||
if (disable_triggers)
|
||||
appendPQExpBuffer(pgdumpopts, " --disable-triggers");
|
||||
appendPQExpBufferStr(pgdumpopts, " --disable-triggers");
|
||||
if (inserts)
|
||||
appendPQExpBuffer(pgdumpopts, " --inserts");
|
||||
appendPQExpBufferStr(pgdumpopts, " --inserts");
|
||||
if (no_tablespaces)
|
||||
appendPQExpBuffer(pgdumpopts, " --no-tablespaces");
|
||||
appendPQExpBufferStr(pgdumpopts, " --no-tablespaces");
|
||||
if (quote_all_identifiers)
|
||||
appendPQExpBuffer(pgdumpopts, " --quote-all-identifiers");
|
||||
appendPQExpBufferStr(pgdumpopts, " --quote-all-identifiers");
|
||||
if (use_setsessauth)
|
||||
appendPQExpBuffer(pgdumpopts, " --use-set-session-authorization");
|
||||
appendPQExpBufferStr(pgdumpopts, " --use-set-session-authorization");
|
||||
if (no_security_labels)
|
||||
appendPQExpBuffer(pgdumpopts, " --no-security-labels");
|
||||
appendPQExpBufferStr(pgdumpopts, " --no-security-labels");
|
||||
if (no_unlogged_table_data)
|
||||
appendPQExpBuffer(pgdumpopts, " --no-unlogged-table-data");
|
||||
appendPQExpBufferStr(pgdumpopts, " --no-unlogged-table-data");
|
||||
|
||||
/*
|
||||
* If there was a database specified on the command line, use that,
|
||||
@ -746,7 +746,7 @@ dumpRoles(PGconn *conn)
|
||||
|
||||
if (binary_upgrade)
|
||||
{
|
||||
appendPQExpBuffer(buf, "\n-- For binary upgrade, must preserve pg_authid.oid\n");
|
||||
appendPQExpBufferStr(buf, "\n-- For binary upgrade, must preserve pg_authid.oid\n");
|
||||
appendPQExpBuffer(buf,
|
||||
"SELECT binary_upgrade.set_next_pg_authid_oid('%u'::pg_catalog.oid);\n\n",
|
||||
auth_oid);
|
||||
@ -766,34 +766,34 @@ dumpRoles(PGconn *conn)
|
||||
appendPQExpBuffer(buf, "ALTER ROLE %s WITH", fmtId(rolename));
|
||||
|
||||
if (strcmp(PQgetvalue(res, i, i_rolsuper), "t") == 0)
|
||||
appendPQExpBuffer(buf, " SUPERUSER");
|
||||
appendPQExpBufferStr(buf, " SUPERUSER");
|
||||
else
|
||||
appendPQExpBuffer(buf, " NOSUPERUSER");
|
||||
appendPQExpBufferStr(buf, " NOSUPERUSER");
|
||||
|
||||
if (strcmp(PQgetvalue(res, i, i_rolinherit), "t") == 0)
|
||||
appendPQExpBuffer(buf, " INHERIT");
|
||||
appendPQExpBufferStr(buf, " INHERIT");
|
||||
else
|
||||
appendPQExpBuffer(buf, " NOINHERIT");
|
||||
appendPQExpBufferStr(buf, " NOINHERIT");
|
||||
|
||||
if (strcmp(PQgetvalue(res, i, i_rolcreaterole), "t") == 0)
|
||||
appendPQExpBuffer(buf, " CREATEROLE");
|
||||
appendPQExpBufferStr(buf, " CREATEROLE");
|
||||
else
|
||||
appendPQExpBuffer(buf, " NOCREATEROLE");
|
||||
appendPQExpBufferStr(buf, " NOCREATEROLE");
|
||||
|
||||
if (strcmp(PQgetvalue(res, i, i_rolcreatedb), "t") == 0)
|
||||
appendPQExpBuffer(buf, " CREATEDB");
|
||||
appendPQExpBufferStr(buf, " CREATEDB");
|
||||
else
|
||||
appendPQExpBuffer(buf, " NOCREATEDB");
|
||||
appendPQExpBufferStr(buf, " NOCREATEDB");
|
||||
|
||||
if (strcmp(PQgetvalue(res, i, i_rolcanlogin), "t") == 0)
|
||||
appendPQExpBuffer(buf, " LOGIN");
|
||||
appendPQExpBufferStr(buf, " LOGIN");
|
||||
else
|
||||
appendPQExpBuffer(buf, " NOLOGIN");
|
||||
appendPQExpBufferStr(buf, " NOLOGIN");
|
||||
|
||||
if (strcmp(PQgetvalue(res, i, i_rolreplication), "t") == 0)
|
||||
appendPQExpBuffer(buf, " REPLICATION");
|
||||
appendPQExpBufferStr(buf, " REPLICATION");
|
||||
else
|
||||
appendPQExpBuffer(buf, " NOREPLICATION");
|
||||
appendPQExpBufferStr(buf, " NOREPLICATION");
|
||||
|
||||
if (strcmp(PQgetvalue(res, i, i_rolconnlimit), "-1") != 0)
|
||||
appendPQExpBuffer(buf, " CONNECTION LIMIT %s",
|
||||
@ -801,7 +801,7 @@ dumpRoles(PGconn *conn)
|
||||
|
||||
if (!PQgetisnull(res, i, i_rolpassword))
|
||||
{
|
||||
appendPQExpBuffer(buf, " PASSWORD ");
|
||||
appendPQExpBufferStr(buf, " PASSWORD ");
|
||||
appendStringLiteralConn(buf, PQgetvalue(res, i, i_rolpassword), conn);
|
||||
}
|
||||
|
||||
@ -809,13 +809,13 @@ dumpRoles(PGconn *conn)
|
||||
appendPQExpBuffer(buf, " VALID UNTIL '%s'",
|
||||
PQgetvalue(res, i, i_rolvaliduntil));
|
||||
|
||||
appendPQExpBuffer(buf, ";\n");
|
||||
appendPQExpBufferStr(buf, ";\n");
|
||||
|
||||
if (!PQgetisnull(res, i, i_rolcomment))
|
||||
{
|
||||
appendPQExpBuffer(buf, "COMMENT ON ROLE %s IS ", fmtId(rolename));
|
||||
appendStringLiteralConn(buf, PQgetvalue(res, i, i_rolcomment), conn);
|
||||
appendPQExpBuffer(buf, ";\n");
|
||||
appendPQExpBufferStr(buf, ";\n");
|
||||
}
|
||||
|
||||
if (!no_security_labels && server_version >= 90200)
|
||||
@ -1068,9 +1068,9 @@ dumpTablespaces(PGconn *conn)
|
||||
appendPQExpBuffer(buf, "CREATE TABLESPACE %s", fspcname);
|
||||
appendPQExpBuffer(buf, " OWNER %s", fmtId(spcowner));
|
||||
|
||||
appendPQExpBuffer(buf, " LOCATION ");
|
||||
appendPQExpBufferStr(buf, " LOCATION ");
|
||||
appendStringLiteralConn(buf, spclocation, conn);
|
||||
appendPQExpBuffer(buf, ";\n");
|
||||
appendPQExpBufferStr(buf, ";\n");
|
||||
|
||||
if (spcoptions && spcoptions[0] != '\0')
|
||||
appendPQExpBuffer(buf, "ALTER TABLESPACE %s SET (%s);\n",
|
||||
@ -1090,7 +1090,7 @@ dumpTablespaces(PGconn *conn)
|
||||
{
|
||||
appendPQExpBuffer(buf, "COMMENT ON TABLESPACE %s IS ", fspcname);
|
||||
appendStringLiteralConn(buf, spccomment, conn);
|
||||
appendPQExpBuffer(buf, ";\n");
|
||||
appendPQExpBufferStr(buf, ";\n");
|
||||
}
|
||||
|
||||
if (!no_security_labels && server_version >= 90200)
|
||||
@ -1320,26 +1320,26 @@ dumpCreateDB(PGconn *conn)
|
||||
{
|
||||
appendPQExpBuffer(buf, "CREATE DATABASE %s", fdbname);
|
||||
|
||||
appendPQExpBuffer(buf, " WITH TEMPLATE = template0");
|
||||
appendPQExpBufferStr(buf, " WITH TEMPLATE = template0");
|
||||
|
||||
if (strlen(dbowner) != 0)
|
||||
appendPQExpBuffer(buf, " OWNER = %s", fmtId(dbowner));
|
||||
|
||||
if (default_encoding && strcmp(dbencoding, default_encoding) != 0)
|
||||
{
|
||||
appendPQExpBuffer(buf, " ENCODING = ");
|
||||
appendPQExpBufferStr(buf, " ENCODING = ");
|
||||
appendStringLiteralConn(buf, dbencoding, conn);
|
||||
}
|
||||
|
||||
if (default_collate && strcmp(dbcollate, default_collate) != 0)
|
||||
{
|
||||
appendPQExpBuffer(buf, " LC_COLLATE = ");
|
||||
appendPQExpBufferStr(buf, " LC_COLLATE = ");
|
||||
appendStringLiteralConn(buf, dbcollate, conn);
|
||||
}
|
||||
|
||||
if (default_ctype && strcmp(dbctype, default_ctype) != 0)
|
||||
{
|
||||
appendPQExpBuffer(buf, " LC_CTYPE = ");
|
||||
appendPQExpBufferStr(buf, " LC_CTYPE = ");
|
||||
appendStringLiteralConn(buf, dbctype, conn);
|
||||
}
|
||||
|
||||
@ -1359,24 +1359,24 @@ dumpCreateDB(PGconn *conn)
|
||||
appendPQExpBuffer(buf, " CONNECTION LIMIT = %s",
|
||||
dbconnlimit);
|
||||
|
||||
appendPQExpBuffer(buf, ";\n");
|
||||
appendPQExpBufferStr(buf, ";\n");
|
||||
|
||||
if (strcmp(dbistemplate, "t") == 0)
|
||||
{
|
||||
appendPQExpBuffer(buf, "UPDATE pg_catalog.pg_database SET datistemplate = 't' WHERE datname = ");
|
||||
appendPQExpBufferStr(buf, "UPDATE pg_catalog.pg_database SET datistemplate = 't' WHERE datname = ");
|
||||
appendStringLiteralConn(buf, dbname, conn);
|
||||
appendPQExpBuffer(buf, ";\n");
|
||||
appendPQExpBufferStr(buf, ";\n");
|
||||
}
|
||||
|
||||
if (binary_upgrade)
|
||||
{
|
||||
appendPQExpBuffer(buf, "-- For binary upgrade, set datfrozenxid.\n");
|
||||
appendPQExpBufferStr(buf, "-- For binary upgrade, set datfrozenxid.\n");
|
||||
appendPQExpBuffer(buf, "UPDATE pg_catalog.pg_database "
|
||||
"SET datfrozenxid = '%u' "
|
||||
"WHERE datname = ",
|
||||
dbfrozenxid);
|
||||
appendStringLiteralConn(buf, dbname, conn);
|
||||
appendPQExpBuffer(buf, ";\n");
|
||||
appendPQExpBufferStr(buf, ";\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1472,7 +1472,7 @@ dumpUserConfig(PGconn *conn, const char *username)
|
||||
printfPQExpBuffer(buf, "SELECT useconfig[%d] FROM pg_shadow WHERE usename = ", count);
|
||||
appendStringLiteralConn(buf, username, conn);
|
||||
if (server_version >= 90000)
|
||||
appendPQExpBuffer(buf, ")");
|
||||
appendPQExpBufferChar(buf, ')');
|
||||
|
||||
res = executeQuery(conn, buf->data);
|
||||
if (PQntuples(res) == 1 &&
|
||||
@ -1561,10 +1561,10 @@ makeAlterConfigCommand(PGconn *conn, const char *arrayitem,
|
||||
*/
|
||||
if (pg_strcasecmp(mine, "DateStyle") == 0
|
||||
|| pg_strcasecmp(mine, "search_path") == 0)
|
||||
appendPQExpBuffer(buf, "%s", pos + 1);
|
||||
appendPQExpBufferStr(buf, pos + 1);
|
||||
else
|
||||
appendStringLiteralConn(buf, pos + 1, conn);
|
||||
appendPQExpBuffer(buf, ";\n");
|
||||
appendPQExpBufferStr(buf, ";\n");
|
||||
|
||||
fprintf(OPF, "%s", buf->data);
|
||||
destroyPQExpBuffer(buf);
|
||||
@ -1644,9 +1644,9 @@ runPgDump(const char *dbname)
|
||||
* format.
|
||||
*/
|
||||
if (filename)
|
||||
appendPQExpBuffer(cmd, " -Fa ");
|
||||
appendPQExpBufferStr(cmd, " -Fa ");
|
||||
else
|
||||
appendPQExpBuffer(cmd, " -Fp ");
|
||||
appendPQExpBufferStr(cmd, " -Fp ");
|
||||
|
||||
/*
|
||||
* Append the database name to the already-constructed stem of connection
|
||||
@ -1657,7 +1657,7 @@ runPgDump(const char *dbname)
|
||||
|
||||
doShellQuoting(cmd, connstrbuf->data);
|
||||
|
||||
appendPQExpBuffer(cmd, "%s", SYSTEMQUOTE);
|
||||
appendPQExpBufferStr(cmd, SYSTEMQUOTE);
|
||||
|
||||
if (verbose)
|
||||
fprintf(stderr, _("%s: running \"%s\"\n"), progname, cmd->data);
|
||||
@ -2082,7 +2082,7 @@ doShellQuoting(PQExpBuffer buf, const char *str)
|
||||
for (p = str; *p; p++)
|
||||
{
|
||||
if (*p == '\'')
|
||||
appendPQExpBuffer(buf, "'\"'\"'");
|
||||
appendPQExpBufferStr(buf, "'\"'\"'");
|
||||
else
|
||||
appendPQExpBufferChar(buf, *p);
|
||||
}
|
||||
@ -2093,7 +2093,7 @@ doShellQuoting(PQExpBuffer buf, const char *str)
|
||||
for (p = str; *p; p++)
|
||||
{
|
||||
if (*p == '"')
|
||||
appendPQExpBuffer(buf, "\\\"");
|
||||
appendPQExpBufferStr(buf, "\\\"");
|
||||
else
|
||||
appendPQExpBufferChar(buf, *p);
|
||||
}
|
||||
|
@ -2786,7 +2786,7 @@ lookup_function_oid(PGconn *conn, const char *desc, Oid *foid)
|
||||
PGresult *res;
|
||||
|
||||
query = createPQExpBuffer();
|
||||
printfPQExpBuffer(query, "SELECT ");
|
||||
appendPQExpBufferStr(query, "SELECT ");
|
||||
appendStringLiteralConn(query, desc, conn);
|
||||
appendPQExpBuffer(query, "::pg_catalog.%s::pg_catalog.oid",
|
||||
strchr(desc, '(') ? "regprocedure" : "regproc");
|
||||
|
@ -362,9 +362,9 @@ do_copy(const char *args)
|
||||
printfPQExpBuffer(&query, "COPY ");
|
||||
appendPQExpBufferStr(&query, options->before_tofrom);
|
||||
if (options->from)
|
||||
appendPQExpBuffer(&query, " FROM STDIN ");
|
||||
appendPQExpBufferStr(&query, " FROM STDIN ");
|
||||
else
|
||||
appendPQExpBuffer(&query, " TO STDOUT ");
|
||||
appendPQExpBufferStr(&query, " TO STDOUT ");
|
||||
if (options->after_tofrom)
|
||||
appendPQExpBufferStr(&query, options->after_tofrom);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3613,8 +3613,8 @@ _complete_from_query(int is_schema_query, const char *text, int state)
|
||||
"pg_catalog.pg_class c") == 0 &&
|
||||
strncmp(text, "pg_", 3) !=0)
|
||||
{
|
||||
appendPQExpBuffer(&query_buffer,
|
||||
" AND c.relnamespace <> (SELECT oid FROM"
|
||||
appendPQExpBufferStr(&query_buffer,
|
||||
" AND c.relnamespace <> (SELECT oid FROM"
|
||||
" pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')");
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -1601,9 +1601,9 @@ PQconnectPoll(PGconn *conn)
|
||||
break;
|
||||
|
||||
default:
|
||||
appendPQExpBuffer(&conn->errorMessage,
|
||||
libpq_gettext(
|
||||
"invalid connection state, "
|
||||
appendPQExpBufferStr(&conn->errorMessage,
|
||||
libpq_gettext(
|
||||
"invalid connection state, "
|
||||
"probably indicative of memory corruption\n"
|
||||
));
|
||||
goto error_return;
|
||||
@ -1695,8 +1695,8 @@ keep_going: /* We will come back to here until there is
|
||||
|
||||
if (usekeepalives < 0)
|
||||
{
|
||||
appendPQExpBuffer(&conn->errorMessage,
|
||||
libpq_gettext("keepalives parameter must be an integer\n"));
|
||||
appendPQExpBufferStr(&conn->errorMessage,
|
||||
libpq_gettext("keepalives parameter must be an integer\n"));
|
||||
err = 1;
|
||||
}
|
||||
else if (usekeepalives == 0)
|
||||
@ -1920,8 +1920,8 @@ keep_going: /* We will come back to here until there is
|
||||
* stub
|
||||
*/
|
||||
if (errno == ENOSYS)
|
||||
appendPQExpBuffer(&conn->errorMessage,
|
||||
libpq_gettext("requirepeer parameter is not supported on this platform\n"));
|
||||
appendPQExpBufferStr(&conn->errorMessage,
|
||||
libpq_gettext("requirepeer parameter is not supported on this platform\n"));
|
||||
else
|
||||
appendPQExpBuffer(&conn->errorMessage,
|
||||
libpq_gettext("could not get peer credentials: %s\n"),
|
||||
@ -2084,8 +2084,8 @@ keep_going: /* We will come back to here until there is
|
||||
* "verify-full" */
|
||||
{
|
||||
/* Require SSL, but server does not want it */
|
||||
appendPQExpBuffer(&conn->errorMessage,
|
||||
libpq_gettext("server does not support SSL, but SSL was required\n"));
|
||||
appendPQExpBufferStr(&conn->errorMessage,
|
||||
libpq_gettext("server does not support SSL, but SSL was required\n"));
|
||||
goto error_return;
|
||||
}
|
||||
/* Otherwise, proceed with normal startup */
|
||||
@ -2470,8 +2470,8 @@ keep_going: /* We will come back to here until there is
|
||||
if (res)
|
||||
{
|
||||
if (res->resultStatus != PGRES_FATAL_ERROR)
|
||||
appendPQExpBuffer(&conn->errorMessage,
|
||||
libpq_gettext("unexpected message from server during startup\n"));
|
||||
appendPQExpBufferStr(&conn->errorMessage,
|
||||
libpq_gettext("unexpected message from server during startup\n"));
|
||||
else if (conn->send_appname &&
|
||||
(conn->appname || conn->fbappname))
|
||||
{
|
||||
|
@ -204,7 +204,7 @@ main(int argc, char **argv)
|
||||
"AND holder.granted "
|
||||
"AND holder.pid <> $1 AND holder.pid IN (");
|
||||
/* The spec syntax requires at least one session; assume that here. */
|
||||
appendPQExpBuffer(&wait_query, "%s", backend_pids[1]);
|
||||
appendPQExpBufferStr(&wait_query, backend_pids[1]);
|
||||
for (i = 2; i < nconns; i++)
|
||||
appendPQExpBuffer(&wait_query, ", %s", backend_pids[i]);
|
||||
appendPQExpBufferStr(&wait_query,
|
||||
|
Loading…
x
Reference in New Issue
Block a user