mirror of
https://github.com/postgres/postgres.git
synced 2025-05-14 00:03:46 -04:00
Use appendStringInfoString and appendPQExpBufferStr where possible
This changes various places where appendPQExpBuffer was used in places where it was possible to use appendPQExpBufferStr, and likewise for appendStringInfo and appendStringInfoString. This is really just a stylistic improvement, but there are also small performance gains to be had from doing this. Discussion: http://postgr.es/m/CAKJS1f9P=M-3ULmPvr8iCno8yvfDViHibJjpriHU8+SXUgeZ=w@mail.gmail.com
This commit is contained in:
parent
5683b34956
commit
8abc13a889
@ -1531,7 +1531,7 @@ deparseFromExprForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel,
|
|||||||
{
|
{
|
||||||
Assert(fpinfo->jointype == JOIN_INNER);
|
Assert(fpinfo->jointype == JOIN_INNER);
|
||||||
Assert(fpinfo->joinclauses == NIL);
|
Assert(fpinfo->joinclauses == NIL);
|
||||||
appendStringInfo(buf, "%s", join_sql_o.data);
|
appendStringInfoString(buf, join_sql_o.data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1552,7 +1552,7 @@ deparseFromExprForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel,
|
|||||||
{
|
{
|
||||||
Assert(fpinfo->jointype == JOIN_INNER);
|
Assert(fpinfo->jointype == JOIN_INNER);
|
||||||
Assert(fpinfo->joinclauses == NIL);
|
Assert(fpinfo->joinclauses == NIL);
|
||||||
appendStringInfo(buf, "%s", join_sql_i.data);
|
appendStringInfoString(buf, join_sql_i.data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1861,7 +1861,7 @@ deparseDirectUpdateSql(StringInfo buf, PlannerInfo *root,
|
|||||||
{
|
{
|
||||||
List *ignore_conds = NIL;
|
List *ignore_conds = NIL;
|
||||||
|
|
||||||
appendStringInfo(buf, " FROM ");
|
appendStringInfoString(buf, " FROM ");
|
||||||
deparseFromExprForRel(buf, root, foreignrel, true, rtindex,
|
deparseFromExprForRel(buf, root, foreignrel, true, rtindex,
|
||||||
&ignore_conds, params_list);
|
&ignore_conds, params_list);
|
||||||
remote_conds = list_concat(remote_conds, ignore_conds);
|
remote_conds = list_concat(remote_conds, ignore_conds);
|
||||||
@ -1944,7 +1944,7 @@ deparseDirectDeleteSql(StringInfo buf, PlannerInfo *root,
|
|||||||
{
|
{
|
||||||
List *ignore_conds = NIL;
|
List *ignore_conds = NIL;
|
||||||
|
|
||||||
appendStringInfo(buf, " USING ");
|
appendStringInfoString(buf, " USING ");
|
||||||
deparseFromExprForRel(buf, root, foreignrel, true, rtindex,
|
deparseFromExprForRel(buf, root, foreignrel, true, rtindex,
|
||||||
&ignore_conds, params_list);
|
&ignore_conds, params_list);
|
||||||
remote_conds = list_concat(remote_conds, ignore_conds);
|
remote_conds = list_concat(remote_conds, ignore_conds);
|
||||||
|
@ -63,7 +63,7 @@ sepgsql_database_post_create(Oid databaseId, const char *dtemplate)
|
|||||||
* check db_database:{getattr} permission
|
* check db_database:{getattr} permission
|
||||||
*/
|
*/
|
||||||
initStringInfo(&audit_name);
|
initStringInfo(&audit_name);
|
||||||
appendStringInfo(&audit_name, "%s", quote_identifier(dtemplate));
|
appendStringInfoString(&audit_name, quote_identifier(dtemplate));
|
||||||
sepgsql_avc_check_perms_label(tcontext,
|
sepgsql_avc_check_perms_label(tcontext,
|
||||||
SEPG_CLASS_DB_DATABASE,
|
SEPG_CLASS_DB_DATABASE,
|
||||||
SEPG_DB_DATABASE__GETATTR,
|
SEPG_DB_DATABASE__GETATTR,
|
||||||
@ -101,8 +101,8 @@ sepgsql_database_post_create(Oid databaseId, const char *dtemplate)
|
|||||||
* check db_database:{create} permission
|
* check db_database:{create} permission
|
||||||
*/
|
*/
|
||||||
resetStringInfo(&audit_name);
|
resetStringInfo(&audit_name);
|
||||||
appendStringInfo(&audit_name, "%s",
|
appendStringInfoString(&audit_name,
|
||||||
quote_identifier(NameStr(datForm->datname)));
|
quote_identifier(NameStr(datForm->datname)));
|
||||||
sepgsql_avc_check_perms_label(ncontext,
|
sepgsql_avc_check_perms_label(ncontext,
|
||||||
SEPG_CLASS_DB_DATABASE,
|
SEPG_CLASS_DB_DATABASE,
|
||||||
SEPG_DB_DATABASE__CREATE,
|
SEPG_DB_DATABASE__CREATE,
|
||||||
|
@ -676,7 +676,7 @@ quote_object_name(const char *src1, const char *src2,
|
|||||||
if (src1)
|
if (src1)
|
||||||
{
|
{
|
||||||
temp = quote_identifier(src1);
|
temp = quote_identifier(src1);
|
||||||
appendStringInfo(&result, "%s", temp);
|
appendStringInfoString(&result, temp);
|
||||||
if (src1 != temp)
|
if (src1 != temp)
|
||||||
pfree((void *) temp);
|
pfree((void *) temp);
|
||||||
}
|
}
|
||||||
|
@ -702,7 +702,7 @@ sepgsql_audit_log(bool denied,
|
|||||||
appendStringInfo(&buf, " %s", av_name);
|
appendStringInfo(&buf, " %s", av_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
appendStringInfo(&buf, " }");
|
appendStringInfoString(&buf, " }");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call external audit module, if loaded
|
* Call external audit module, if loaded
|
||||||
|
@ -518,9 +518,9 @@ pg_decode_truncate(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
|
|||||||
|| change->data.truncate.cascade)
|
|| change->data.truncate.cascade)
|
||||||
{
|
{
|
||||||
if (change->data.truncate.restart_seqs)
|
if (change->data.truncate.restart_seqs)
|
||||||
appendStringInfo(ctx->out, " restart_seqs");
|
appendStringInfoString(ctx->out, " restart_seqs");
|
||||||
if (change->data.truncate.cascade)
|
if (change->data.truncate.cascade)
|
||||||
appendStringInfo(ctx->out, " cascade");
|
appendStringInfoString(ctx->out, " cascade");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
appendStringInfoString(ctx->out, " (no-flags)");
|
appendStringInfoString(ctx->out, " (no-flags)");
|
||||||
|
@ -86,9 +86,9 @@ heap_desc(StringInfo buf, XLogReaderState *record)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (xlrec->flags & XLH_TRUNCATE_CASCADE)
|
if (xlrec->flags & XLH_TRUNCATE_CASCADE)
|
||||||
appendStringInfo(buf, "cascade ");
|
appendStringInfoString(buf, "cascade ");
|
||||||
if (xlrec->flags & XLH_TRUNCATE_RESTART_SEQS)
|
if (xlrec->flags & XLH_TRUNCATE_RESTART_SEQS)
|
||||||
appendStringInfo(buf, "restart_seqs ");
|
appendStringInfoString(buf, "restart_seqs ");
|
||||||
appendStringInfo(buf, "nrelids %u relids", xlrec->nrelids);
|
appendStringInfo(buf, "nrelids %u relids", xlrec->nrelids);
|
||||||
for (i = 0; i < xlrec->nrelids; i++)
|
for (i = 0; i < xlrec->nrelids; i++)
|
||||||
appendStringInfo(buf, " %u", xlrec->relids[i]);
|
appendStringInfo(buf, " %u", xlrec->relids[i]);
|
||||||
|
@ -822,7 +822,7 @@ ExplainPrintJIT(ExplainState *es, int jit_flags,
|
|||||||
if (for_workers)
|
if (for_workers)
|
||||||
appendStringInfo(es->str, "JIT for worker %u:\n", worker_num);
|
appendStringInfo(es->str, "JIT for worker %u:\n", worker_num);
|
||||||
else
|
else
|
||||||
appendStringInfo(es->str, "JIT:\n");
|
appendStringInfoString(es->str, "JIT:\n");
|
||||||
es->indent += 1;
|
es->indent += 1;
|
||||||
|
|
||||||
ExplainPropertyInteger("Functions", NULL, ji->created_functions, es);
|
ExplainPropertyInteger("Functions", NULL, ji->created_functions, es);
|
||||||
|
@ -1723,7 +1723,7 @@ pg_get_partkeydef_worker(Oid relid, int prettyFlags,
|
|||||||
{
|
{
|
||||||
case PARTITION_STRATEGY_HASH:
|
case PARTITION_STRATEGY_HASH:
|
||||||
if (!attrsOnly)
|
if (!attrsOnly)
|
||||||
appendStringInfo(&buf, "HASH");
|
appendStringInfoString(&buf, "HASH");
|
||||||
break;
|
break;
|
||||||
case PARTITION_STRATEGY_LIST:
|
case PARTITION_STRATEGY_LIST:
|
||||||
if (!attrsOnly)
|
if (!attrsOnly)
|
||||||
|
@ -500,19 +500,19 @@ CreateReplicationSlot(PGconn *conn, const char *slot_name, const char *plugin,
|
|||||||
/* Build query */
|
/* Build query */
|
||||||
appendPQExpBuffer(query, "CREATE_REPLICATION_SLOT \"%s\"", slot_name);
|
appendPQExpBuffer(query, "CREATE_REPLICATION_SLOT \"%s\"", slot_name);
|
||||||
if (is_temporary)
|
if (is_temporary)
|
||||||
appendPQExpBuffer(query, " TEMPORARY");
|
appendPQExpBufferStr(query, " TEMPORARY");
|
||||||
if (is_physical)
|
if (is_physical)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(query, " PHYSICAL");
|
appendPQExpBufferStr(query, " PHYSICAL");
|
||||||
if (reserve_wal)
|
if (reserve_wal)
|
||||||
appendPQExpBuffer(query, " RESERVE_WAL");
|
appendPQExpBufferStr(query, " RESERVE_WAL");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(query, " LOGICAL \"%s\"", plugin);
|
appendPQExpBuffer(query, " LOGICAL \"%s\"", plugin);
|
||||||
if (PQserverVersion(conn) >= 100000)
|
if (PQserverVersion(conn) >= 100000)
|
||||||
/* pg_recvlogical doesn't use an exported snapshot, so suppress */
|
/* pg_recvlogical doesn't use an exported snapshot, so suppress */
|
||||||
appendPQExpBuffer(query, " NOEXPORT_SNAPSHOT");
|
appendPQExpBufferStr(query, " NOEXPORT_SNAPSHOT");
|
||||||
}
|
}
|
||||||
|
|
||||||
res = PQexec(conn, query->data);
|
res = PQexec(conn, query->data);
|
||||||
|
@ -1481,14 +1481,14 @@ pgwin32_CommandLine(bool registration)
|
|||||||
appendPQExpBuffer(cmdLine, " -e \"%s\"", event_source);
|
appendPQExpBuffer(cmdLine, " -e \"%s\"", event_source);
|
||||||
|
|
||||||
if (registration && do_wait)
|
if (registration && do_wait)
|
||||||
appendPQExpBuffer(cmdLine, " -w");
|
appendPQExpBufferStr(cmdLine, " -w");
|
||||||
|
|
||||||
/* Don't propagate a value from an environment variable. */
|
/* Don't propagate a value from an environment variable. */
|
||||||
if (registration && wait_seconds_arg && wait_seconds != DEFAULT_WAIT)
|
if (registration && wait_seconds_arg && wait_seconds != DEFAULT_WAIT)
|
||||||
appendPQExpBuffer(cmdLine, " -t %d", wait_seconds);
|
appendPQExpBuffer(cmdLine, " -t %d", wait_seconds);
|
||||||
|
|
||||||
if (registration && silent_mode)
|
if (registration && silent_mode)
|
||||||
appendPQExpBuffer(cmdLine, " -s");
|
appendPQExpBufferStr(cmdLine, " -s");
|
||||||
|
|
||||||
if (post_opts)
|
if (post_opts)
|
||||||
{
|
{
|
||||||
|
@ -425,7 +425,7 @@ buildDefaultACLCommands(const char *type, const char *nspname,
|
|||||||
|
|
||||||
if (strlen(initacls) != 0 || strlen(initracls) != 0)
|
if (strlen(initacls) != 0 || strlen(initracls) != 0)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\n");
|
appendPQExpBufferStr(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\n");
|
||||||
if (!buildACLCommands("", NULL, NULL, type,
|
if (!buildACLCommands("", NULL, NULL, type,
|
||||||
initacls, initracls, owner,
|
initacls, initracls, owner,
|
||||||
prefix->data, remoteVersion, sql))
|
prefix->data, remoteVersion, sql))
|
||||||
@ -433,7 +433,7 @@ buildDefaultACLCommands(const char *type, const char *nspname,
|
|||||||
destroyPQExpBuffer(prefix);
|
destroyPQExpBuffer(prefix);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
|
appendPQExpBufferStr(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!buildACLCommands("", NULL, NULL, type,
|
if (!buildACLCommands("", NULL, NULL, type,
|
||||||
|
@ -554,8 +554,8 @@ RestoreArchive(Archive *AHX)
|
|||||||
*/
|
*/
|
||||||
if (strncmp(dropStmt, "ALTER TABLE", 11) == 0)
|
if (strncmp(dropStmt, "ALTER TABLE", 11) == 0)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(ftStmt,
|
appendPQExpBufferStr(ftStmt,
|
||||||
"ALTER TABLE IF EXISTS");
|
"ALTER TABLE IF EXISTS");
|
||||||
dropStmt = dropStmt + 11;
|
dropStmt = dropStmt + 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4870,7 +4870,7 @@ CloneArchive(ArchiveHandle *AH)
|
|||||||
* any data to/from the database.
|
* any data to/from the database.
|
||||||
*/
|
*/
|
||||||
initPQExpBuffer(&connstr);
|
initPQExpBuffer(&connstr);
|
||||||
appendPQExpBuffer(&connstr, "dbname=");
|
appendPQExpBufferStr(&connstr, "dbname=");
|
||||||
appendConnStrVal(&connstr, PQdb(AH->connection));
|
appendConnStrVal(&connstr, PQdb(AH->connection));
|
||||||
pghost = PQhost(AH->connection);
|
pghost = PQhost(AH->connection);
|
||||||
pgport = PQport(AH->connection);
|
pgport = PQport(AH->connection);
|
||||||
|
@ -149,7 +149,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser)
|
|||||||
}
|
}
|
||||||
|
|
||||||
initPQExpBuffer(&connstr);
|
initPQExpBuffer(&connstr);
|
||||||
appendPQExpBuffer(&connstr, "dbname=");
|
appendPQExpBufferStr(&connstr, "dbname=");
|
||||||
appendConnStrVal(&connstr, newdb);
|
appendConnStrVal(&connstr, newdb);
|
||||||
|
|
||||||
do
|
do
|
||||||
|
@ -1205,7 +1205,7 @@ setup_connection(Archive *AH, const char *dumpencoding,
|
|||||||
{
|
{
|
||||||
PQExpBuffer query = createPQExpBuffer();
|
PQExpBuffer query = createPQExpBuffer();
|
||||||
|
|
||||||
appendPQExpBuffer(query, "SET TRANSACTION SNAPSHOT ");
|
appendPQExpBufferStr(query, "SET TRANSACTION SNAPSHOT ");
|
||||||
appendStringLiteralConn(query, AH->sync_snapshot_id, conn);
|
appendStringLiteralConn(query, AH->sync_snapshot_id, conn);
|
||||||
ExecuteSqlStatement(AH, query->data);
|
ExecuteSqlStatement(AH, query->data);
|
||||||
destroyPQExpBuffer(query);
|
destroyPQExpBuffer(query);
|
||||||
@ -1315,8 +1315,8 @@ expand_schema_name_patterns(Archive *fout,
|
|||||||
|
|
||||||
for (cell = patterns->head; cell; cell = cell->next)
|
for (cell = patterns->head; cell; cell = cell->next)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(query,
|
appendPQExpBufferStr(query,
|
||||||
"SELECT oid FROM pg_catalog.pg_namespace n\n");
|
"SELECT oid FROM pg_catalog.pg_namespace n\n");
|
||||||
processSQLNamePattern(GetConnection(fout), query, cell->val, false,
|
processSQLNamePattern(GetConnection(fout), query, cell->val, false,
|
||||||
false, NULL, "n.nspname", NULL, NULL);
|
false, NULL, "n.nspname", NULL, NULL);
|
||||||
|
|
||||||
@ -3733,7 +3733,7 @@ dumpPolicy(Archive *fout, PolicyInfo *polinfo)
|
|||||||
if (polinfo->polwithcheck != NULL)
|
if (polinfo->polwithcheck != NULL)
|
||||||
appendPQExpBuffer(query, " WITH CHECK (%s)", polinfo->polwithcheck);
|
appendPQExpBuffer(query, " WITH CHECK (%s)", polinfo->polwithcheck);
|
||||||
|
|
||||||
appendPQExpBuffer(query, ";\n");
|
appendPQExpBufferStr(query, ";\n");
|
||||||
|
|
||||||
appendPQExpBuffer(delqry, "DROP POLICY %s", fmtId(polinfo->polname));
|
appendPQExpBuffer(delqry, "DROP POLICY %s", fmtId(polinfo->polname));
|
||||||
appendPQExpBuffer(delqry, " ON %s;\n", fmtQualifiedDumpable(tbinfo));
|
appendPQExpBuffer(delqry, " ON %s;\n", fmtQualifiedDumpable(tbinfo));
|
||||||
@ -4560,7 +4560,7 @@ getNamespaces(Archive *fout, int *numNamespaces)
|
|||||||
init_acl_subquery->data,
|
init_acl_subquery->data,
|
||||||
init_racl_subquery->data);
|
init_racl_subquery->data);
|
||||||
|
|
||||||
appendPQExpBuffer(query, ") ");
|
appendPQExpBufferStr(query, ") ");
|
||||||
|
|
||||||
destroyPQExpBuffer(acl_subquery);
|
destroyPQExpBuffer(acl_subquery);
|
||||||
destroyPQExpBuffer(racl_subquery);
|
destroyPQExpBuffer(racl_subquery);
|
||||||
@ -5248,9 +5248,9 @@ getAccessMethods(Archive *fout, int *numAccessMethods)
|
|||||||
query = createPQExpBuffer();
|
query = createPQExpBuffer();
|
||||||
|
|
||||||
/* Select all access methods from pg_am table */
|
/* Select all access methods from pg_am table */
|
||||||
appendPQExpBuffer(query, "SELECT tableoid, oid, amname, amtype, "
|
appendPQExpBufferStr(query, "SELECT tableoid, oid, amname, amtype, "
|
||||||
"amhandler::pg_catalog.regproc AS amhandler "
|
"amhandler::pg_catalog.regproc AS amhandler "
|
||||||
"FROM pg_am");
|
"FROM pg_am");
|
||||||
|
|
||||||
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
|
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
|
||||||
|
|
||||||
@ -8128,10 +8128,10 @@ getTransforms(Archive *fout, int *numTransforms)
|
|||||||
|
|
||||||
query = createPQExpBuffer();
|
query = createPQExpBuffer();
|
||||||
|
|
||||||
appendPQExpBuffer(query, "SELECT tableoid, oid, "
|
appendPQExpBufferStr(query, "SELECT tableoid, oid, "
|
||||||
"trftype, trflang, trffromsql::oid, trftosql::oid "
|
"trftype, trflang, trffromsql::oid, trftosql::oid "
|
||||||
"FROM pg_transform "
|
"FROM pg_transform "
|
||||||
"ORDER BY 3,4");
|
"ORDER BY 3,4");
|
||||||
|
|
||||||
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
|
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
|
||||||
|
|
||||||
@ -8255,55 +8255,55 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
|
|||||||
|
|
||||||
resetPQExpBuffer(q);
|
resetPQExpBuffer(q);
|
||||||
|
|
||||||
appendPQExpBuffer(q,
|
appendPQExpBufferStr(q,
|
||||||
"SELECT\n"
|
"SELECT\n"
|
||||||
"a.attnum,\n"
|
"a.attnum,\n"
|
||||||
"a.attname,\n"
|
"a.attname,\n"
|
||||||
"a.atttypmod,\n"
|
"a.atttypmod,\n"
|
||||||
"a.attstattarget,\n"
|
"a.attstattarget,\n"
|
||||||
"a.attstorage,\n"
|
"a.attstorage,\n"
|
||||||
"t.typstorage,\n"
|
"t.typstorage,\n"
|
||||||
"a.attnotnull,\n"
|
"a.attnotnull,\n"
|
||||||
"a.atthasdef,\n"
|
"a.atthasdef,\n"
|
||||||
"a.attisdropped,\n"
|
"a.attisdropped,\n"
|
||||||
"a.attlen,\n"
|
"a.attlen,\n"
|
||||||
"a.attalign,\n"
|
"a.attalign,\n"
|
||||||
"a.attislocal,\n"
|
"a.attislocal,\n"
|
||||||
"pg_catalog.format_type(t.oid, a.atttypmod) AS atttypname,\n");
|
"pg_catalog.format_type(t.oid, a.atttypmod) AS atttypname,\n");
|
||||||
|
|
||||||
if (fout->remoteVersion >= 120000)
|
if (fout->remoteVersion >= 120000)
|
||||||
appendPQExpBuffer(q,
|
appendPQExpBufferStr(q,
|
||||||
"a.attgenerated,\n");
|
"a.attgenerated,\n");
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(q,
|
appendPQExpBufferStr(q,
|
||||||
"'' AS attgenerated,\n");
|
"'' AS attgenerated,\n");
|
||||||
|
|
||||||
if (fout->remoteVersion >= 110000)
|
if (fout->remoteVersion >= 110000)
|
||||||
appendPQExpBuffer(q,
|
appendPQExpBufferStr(q,
|
||||||
"CASE WHEN a.atthasmissing AND NOT a.attisdropped "
|
"CASE WHEN a.atthasmissing AND NOT a.attisdropped "
|
||||||
"THEN a.attmissingval ELSE null END AS attmissingval,\n");
|
"THEN a.attmissingval ELSE null END AS attmissingval,\n");
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(q,
|
appendPQExpBufferStr(q,
|
||||||
"NULL AS attmissingval,\n");
|
"NULL AS attmissingval,\n");
|
||||||
|
|
||||||
if (fout->remoteVersion >= 100000)
|
if (fout->remoteVersion >= 100000)
|
||||||
appendPQExpBuffer(q,
|
appendPQExpBufferStr(q,
|
||||||
"a.attidentity,\n");
|
"a.attidentity,\n");
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(q,
|
appendPQExpBufferStr(q,
|
||||||
"'' AS attidentity,\n");
|
"'' AS attidentity,\n");
|
||||||
|
|
||||||
if (fout->remoteVersion >= 90200)
|
if (fout->remoteVersion >= 90200)
|
||||||
appendPQExpBuffer(q,
|
appendPQExpBufferStr(q,
|
||||||
"pg_catalog.array_to_string(ARRAY("
|
"pg_catalog.array_to_string(ARRAY("
|
||||||
"SELECT pg_catalog.quote_ident(option_name) || "
|
"SELECT pg_catalog.quote_ident(option_name) || "
|
||||||
"' ' || pg_catalog.quote_literal(option_value) "
|
"' ' || pg_catalog.quote_literal(option_value) "
|
||||||
"FROM pg_catalog.pg_options_to_table(attfdwoptions) "
|
"FROM pg_catalog.pg_options_to_table(attfdwoptions) "
|
||||||
"ORDER BY option_name"
|
"ORDER BY option_name"
|
||||||
"), E',\n ') AS attfdwoptions,\n");
|
"), E',\n ') AS attfdwoptions,\n");
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(q,
|
appendPQExpBufferStr(q,
|
||||||
"'' AS attfdwoptions,\n");
|
"'' AS attfdwoptions,\n");
|
||||||
|
|
||||||
if (fout->remoteVersion >= 90100)
|
if (fout->remoteVersion >= 90100)
|
||||||
{
|
{
|
||||||
@ -8312,20 +8312,20 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
|
|||||||
* collation is different from their type's default, we use a CASE
|
* collation is different from their type's default, we use a CASE
|
||||||
* here to suppress uninteresting attcollations cheaply.
|
* here to suppress uninteresting attcollations cheaply.
|
||||||
*/
|
*/
|
||||||
appendPQExpBuffer(q,
|
appendPQExpBufferStr(q,
|
||||||
"CASE WHEN a.attcollation <> t.typcollation "
|
"CASE WHEN a.attcollation <> t.typcollation "
|
||||||
"THEN a.attcollation ELSE 0 END AS attcollation,\n");
|
"THEN a.attcollation ELSE 0 END AS attcollation,\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(q,
|
appendPQExpBufferStr(q,
|
||||||
"0 AS attcollation,\n");
|
"0 AS attcollation,\n");
|
||||||
|
|
||||||
if (fout->remoteVersion >= 90000)
|
if (fout->remoteVersion >= 90000)
|
||||||
appendPQExpBuffer(q,
|
appendPQExpBufferStr(q,
|
||||||
"array_to_string(a.attoptions, ', ') AS attoptions\n");
|
"array_to_string(a.attoptions, ', ') AS attoptions\n");
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(q,
|
appendPQExpBufferStr(q,
|
||||||
"'' AS attoptions\n");
|
"'' AS attoptions\n");
|
||||||
|
|
||||||
/* need left join here to not fail on dropped columns ... */
|
/* need left join here to not fail on dropped columns ... */
|
||||||
appendPQExpBuffer(q,
|
appendPQExpBuffer(q,
|
||||||
@ -12331,7 +12331,7 @@ dumpTransform(Archive *fout, TransformInfo *transform)
|
|||||||
if (transform->trftosql)
|
if (transform->trftosql)
|
||||||
{
|
{
|
||||||
if (transform->trffromsql)
|
if (transform->trffromsql)
|
||||||
appendPQExpBuffer(defqry, ", ");
|
appendPQExpBufferStr(defqry, ", ");
|
||||||
|
|
||||||
if (tosqlFuncInfo)
|
if (tosqlFuncInfo)
|
||||||
{
|
{
|
||||||
@ -12349,7 +12349,7 @@ dumpTransform(Archive *fout, TransformInfo *transform)
|
|||||||
pg_log_warning("bogus value in pg_transform.trftosql field");
|
pg_log_warning("bogus value in pg_transform.trftosql field");
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBuffer(defqry, ");\n");
|
appendPQExpBufferStr(defqry, ");\n");
|
||||||
|
|
||||||
appendPQExpBuffer(labelq, "TRANSFORM FOR %s LANGUAGE %s",
|
appendPQExpBuffer(labelq, "TRANSFORM FOR %s LANGUAGE %s",
|
||||||
transformType, lanname);
|
transformType, lanname);
|
||||||
@ -12724,10 +12724,10 @@ dumpAccessMethod(Archive *fout, AccessMethodInfo *aminfo)
|
|||||||
switch (aminfo->amtype)
|
switch (aminfo->amtype)
|
||||||
{
|
{
|
||||||
case AMTYPE_INDEX:
|
case AMTYPE_INDEX:
|
||||||
appendPQExpBuffer(q, "TYPE INDEX ");
|
appendPQExpBufferStr(q, "TYPE INDEX ");
|
||||||
break;
|
break;
|
||||||
case AMTYPE_TABLE:
|
case AMTYPE_TABLE:
|
||||||
appendPQExpBuffer(q, "TYPE TABLE ");
|
appendPQExpBufferStr(q, "TYPE TABLE ");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pg_log_warning("invalid type \"%c\" of access method \"%s\"",
|
pg_log_warning("invalid type \"%c\" of access method \"%s\"",
|
||||||
@ -13433,23 +13433,23 @@ dumpCollation(Archive *fout, CollInfo *collinfo)
|
|||||||
qcollname = pg_strdup(fmtId(collinfo->dobj.name));
|
qcollname = pg_strdup(fmtId(collinfo->dobj.name));
|
||||||
|
|
||||||
/* Get collation-specific details */
|
/* Get collation-specific details */
|
||||||
appendPQExpBuffer(query, "SELECT ");
|
appendPQExpBufferStr(query, "SELECT ");
|
||||||
|
|
||||||
if (fout->remoteVersion >= 100000)
|
if (fout->remoteVersion >= 100000)
|
||||||
appendPQExpBuffer(query,
|
appendPQExpBufferStr(query,
|
||||||
"collprovider, "
|
"collprovider, "
|
||||||
"collversion, ");
|
"collversion, ");
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(query,
|
appendPQExpBufferStr(query,
|
||||||
"'c' AS collprovider, "
|
"'c' AS collprovider, "
|
||||||
"NULL AS collversion, ");
|
"NULL AS collversion, ");
|
||||||
|
|
||||||
if (fout->remoteVersion >= 120000)
|
if (fout->remoteVersion >= 120000)
|
||||||
appendPQExpBuffer(query,
|
appendPQExpBufferStr(query,
|
||||||
"collisdeterministic, ");
|
"collisdeterministic, ");
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(query,
|
appendPQExpBufferStr(query,
|
||||||
"true AS collisdeterministic, ");
|
"true AS collisdeterministic, ");
|
||||||
|
|
||||||
appendPQExpBuffer(query,
|
appendPQExpBuffer(query,
|
||||||
"collcollate, "
|
"collcollate, "
|
||||||
@ -13665,7 +13665,7 @@ format_aggregate_signature(AggInfo *agginfo, Archive *fout, bool honor_quotes)
|
|||||||
appendPQExpBufferStr(&buf, agginfo->aggfn.dobj.name);
|
appendPQExpBufferStr(&buf, agginfo->aggfn.dobj.name);
|
||||||
|
|
||||||
if (agginfo->aggfn.nargs == 0)
|
if (agginfo->aggfn.nargs == 0)
|
||||||
appendPQExpBuffer(&buf, "(*)");
|
appendPQExpBufferStr(&buf, "(*)");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBufferChar(&buf, '(');
|
appendPQExpBufferChar(&buf, '(');
|
||||||
@ -14883,13 +14883,13 @@ dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId,
|
|||||||
*/
|
*/
|
||||||
if (strlen(initacls) != 0 || strlen(initracls) != 0)
|
if (strlen(initacls) != 0 || strlen(initracls) != 0)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\n");
|
appendPQExpBufferStr(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\n");
|
||||||
if (!buildACLCommands(name, subname, nspname, type,
|
if (!buildACLCommands(name, subname, nspname, type,
|
||||||
initacls, initracls, owner,
|
initacls, initracls, owner,
|
||||||
"", fout->remoteVersion, sql))
|
"", fout->remoteVersion, sql))
|
||||||
fatal("could not parse initial GRANT ACL list (%s) or initial REVOKE ACL list (%s) for object \"%s\" (%s)",
|
fatal("could not parse initial GRANT ACL list (%s) or initial REVOKE ACL list (%s) for object \"%s\" (%s)",
|
||||||
initacls, initracls, name, type);
|
initacls, initracls, name, type);
|
||||||
appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
|
appendPQExpBufferStr(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!buildACLCommands(name, subname, nspname, type,
|
if (!buildACLCommands(name, subname, nspname, type,
|
||||||
@ -16591,7 +16591,7 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (indxinfo->indnkeyattrs < indxinfo->indnattrs)
|
if (indxinfo->indnkeyattrs < indxinfo->indnattrs)
|
||||||
appendPQExpBuffer(q, ") INCLUDE (");
|
appendPQExpBufferStr(q, ") INCLUDE (");
|
||||||
|
|
||||||
for (k = indxinfo->indnkeyattrs; k < indxinfo->indnattrs; k++)
|
for (k = indxinfo->indnkeyattrs; k < indxinfo->indnattrs; k++)
|
||||||
{
|
{
|
||||||
@ -16988,9 +16988,9 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
|
|||||||
"ALTER COLUMN %s ADD GENERATED ",
|
"ALTER COLUMN %s ADD GENERATED ",
|
||||||
fmtId(owning_tab->attnames[tbinfo->owning_col - 1]));
|
fmtId(owning_tab->attnames[tbinfo->owning_col - 1]));
|
||||||
if (owning_tab->attidentity[tbinfo->owning_col - 1] == ATTRIBUTE_IDENTITY_ALWAYS)
|
if (owning_tab->attidentity[tbinfo->owning_col - 1] == ATTRIBUTE_IDENTITY_ALWAYS)
|
||||||
appendPQExpBuffer(query, "ALWAYS");
|
appendPQExpBufferStr(query, "ALWAYS");
|
||||||
else if (owning_tab->attidentity[tbinfo->owning_col - 1] == ATTRIBUTE_IDENTITY_BY_DEFAULT)
|
else if (owning_tab->attidentity[tbinfo->owning_col - 1] == ATTRIBUTE_IDENTITY_BY_DEFAULT)
|
||||||
appendPQExpBuffer(query, "BY DEFAULT");
|
appendPQExpBufferStr(query, "BY DEFAULT");
|
||||||
appendPQExpBuffer(query, " AS IDENTITY (\n SEQUENCE NAME %s\n",
|
appendPQExpBuffer(query, " AS IDENTITY (\n SEQUENCE NAME %s\n",
|
||||||
fmtQualifiedDumpable(tbinfo));
|
fmtQualifiedDumpable(tbinfo));
|
||||||
}
|
}
|
||||||
|
@ -1432,8 +1432,8 @@ expand_dbname_patterns(PGconn *conn,
|
|||||||
|
|
||||||
for (SimpleStringListCell *cell = patterns->head; cell; cell = cell->next)
|
for (SimpleStringListCell *cell = patterns->head; cell; cell = cell->next)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(query,
|
appendPQExpBufferStr(query,
|
||||||
"SELECT datname FROM pg_catalog.pg_database n\n");
|
"SELECT datname FROM pg_catalog.pg_database n\n");
|
||||||
processSQLNamePattern(conn, query, cell->val, false,
|
processSQLNamePattern(conn, query, cell->val, false,
|
||||||
false, NULL, "datname", NULL, NULL);
|
false, NULL, "datname", NULL, NULL);
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ generate_old_dump(void)
|
|||||||
escaped_connstr;
|
escaped_connstr;
|
||||||
|
|
||||||
initPQExpBuffer(&connstr);
|
initPQExpBuffer(&connstr);
|
||||||
appendPQExpBuffer(&connstr, "dbname=");
|
appendPQExpBufferStr(&connstr, "dbname=");
|
||||||
appendConnStrVal(&connstr, old_db->db_name);
|
appendConnStrVal(&connstr, old_db->db_name);
|
||||||
initPQExpBuffer(&escaped_connstr);
|
initPQExpBuffer(&escaped_connstr);
|
||||||
appendShellString(&escaped_connstr, connstr.data);
|
appendShellString(&escaped_connstr, connstr.data);
|
||||||
|
@ -2992,7 +2992,7 @@ do_connect(enum trivalue reuse_previous_specification,
|
|||||||
if (!dbname && reuse_previous)
|
if (!dbname && reuse_previous)
|
||||||
{
|
{
|
||||||
initPQExpBuffer(&connstr);
|
initPQExpBuffer(&connstr);
|
||||||
appendPQExpBuffer(&connstr, "dbname=");
|
appendPQExpBufferStr(&connstr, "dbname=");
|
||||||
appendConnStrVal(&connstr, PQdb(o_conn));
|
appendConnStrVal(&connstr, PQdb(o_conn));
|
||||||
dbname = connstr.data;
|
dbname = connstr.data;
|
||||||
/* has_connection_string=true would be a dead store */
|
/* has_connection_string=true would be a dead store */
|
||||||
@ -4576,7 +4576,7 @@ lookup_object_oid(EditableObjectType obj_type, const char *desc,
|
|||||||
*/
|
*/
|
||||||
appendPQExpBufferStr(query, "SELECT ");
|
appendPQExpBufferStr(query, "SELECT ");
|
||||||
appendStringLiteralConn(query, desc, pset.db);
|
appendStringLiteralConn(query, desc, pset.db);
|
||||||
appendPQExpBuffer(query, "::pg_catalog.regclass::pg_catalog.oid");
|
appendPQExpBufferStr(query, "::pg_catalog.regclass::pg_catalog.oid");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2115,8 +2115,8 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
" pg_catalog.pg_get_expr(c.relpartbound, inhrelid)");
|
" pg_catalog.pg_get_expr(c.relpartbound, inhrelid)");
|
||||||
/* If verbose, also request the partition constraint definition */
|
/* If verbose, also request the partition constraint definition */
|
||||||
if (verbose)
|
if (verbose)
|
||||||
appendPQExpBuffer(&buf,
|
appendPQExpBufferStr(&buf,
|
||||||
",\n pg_catalog.pg_get_partition_constraintdef(inhrelid)");
|
",\n pg_catalog.pg_get_partition_constraintdef(inhrelid)");
|
||||||
appendPQExpBuffer(&buf,
|
appendPQExpBuffer(&buf,
|
||||||
"\nFROM pg_catalog.pg_class c"
|
"\nFROM pg_catalog.pg_class c"
|
||||||
" JOIN pg_catalog.pg_inherits i"
|
" JOIN pg_catalog.pg_inherits i"
|
||||||
@ -2203,9 +2203,9 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
" false AS condeferrable, false AS condeferred,\n");
|
" false AS condeferrable, false AS condeferred,\n");
|
||||||
|
|
||||||
if (pset.sversion >= 90400)
|
if (pset.sversion >= 90400)
|
||||||
appendPQExpBuffer(&buf, "i.indisreplident,\n");
|
appendPQExpBufferStr(&buf, "i.indisreplident,\n");
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(&buf, "false AS indisreplident,\n");
|
appendPQExpBufferStr(&buf, "false AS indisreplident,\n");
|
||||||
|
|
||||||
appendPQExpBuffer(&buf, " a.amname, c2.relname, "
|
appendPQExpBuffer(&buf, " a.amname, c2.relname, "
|
||||||
"pg_catalog.pg_get_expr(i.indpred, i.indrelid, true)\n"
|
"pg_catalog.pg_get_expr(i.indpred, i.indrelid, true)\n"
|
||||||
@ -2263,7 +2263,7 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
appendPQExpBufferStr(&tmpbuf, _(", initially deferred"));
|
appendPQExpBufferStr(&tmpbuf, _(", initially deferred"));
|
||||||
|
|
||||||
if (strcmp(indisreplident, "t") == 0)
|
if (strcmp(indisreplident, "t") == 0)
|
||||||
appendPQExpBuffer(&tmpbuf, _(", replica identity"));
|
appendPQExpBufferStr(&tmpbuf, _(", replica identity"));
|
||||||
|
|
||||||
printTableAddFooter(&cont, tmpbuf.data);
|
printTableAddFooter(&cont, tmpbuf.data);
|
||||||
add_tablespace_footer(&cont, tableinfo.relkind,
|
add_tablespace_footer(&cont, tableinfo.relkind,
|
||||||
@ -2374,7 +2374,7 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
appendPQExpBufferStr(&buf, " INVALID");
|
appendPQExpBufferStr(&buf, " INVALID");
|
||||||
|
|
||||||
if (strcmp(PQgetvalue(result, i, 10), "t") == 0)
|
if (strcmp(PQgetvalue(result, i, 10), "t") == 0)
|
||||||
appendPQExpBuffer(&buf, " REPLICA IDENTITY");
|
appendPQExpBufferStr(&buf, " REPLICA IDENTITY");
|
||||||
|
|
||||||
printTableAddFooter(&cont, buf.data);
|
printTableAddFooter(&cont, buf.data);
|
||||||
|
|
||||||
@ -2457,8 +2457,8 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
oid);
|
oid);
|
||||||
|
|
||||||
if (pset.sversion >= 120000)
|
if (pset.sversion >= 120000)
|
||||||
appendPQExpBuffer(&buf, " AND conparentid = 0\n");
|
appendPQExpBufferStr(&buf, " AND conparentid = 0\n");
|
||||||
appendPQExpBuffer(&buf, "ORDER BY conname");
|
appendPQExpBufferStr(&buf, "ORDER BY conname");
|
||||||
}
|
}
|
||||||
|
|
||||||
result = PSQLexec(buf.data);
|
result = PSQLexec(buf.data);
|
||||||
@ -2556,11 +2556,11 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
{
|
{
|
||||||
printfPQExpBuffer(&buf, "SELECT pol.polname,");
|
printfPQExpBuffer(&buf, "SELECT pol.polname,");
|
||||||
if (pset.sversion >= 100000)
|
if (pset.sversion >= 100000)
|
||||||
appendPQExpBuffer(&buf,
|
appendPQExpBufferStr(&buf,
|
||||||
" pol.polpermissive,\n");
|
" pol.polpermissive,\n");
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(&buf,
|
appendPQExpBufferStr(&buf,
|
||||||
" 't' as polpermissive,\n");
|
" 't' as polpermissive,\n");
|
||||||
appendPQExpBuffer(&buf,
|
appendPQExpBuffer(&buf,
|
||||||
" CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
|
" CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n"
|
||||||
" pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
|
" pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n"
|
||||||
@ -2608,7 +2608,7 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
PQgetvalue(result, i, 0));
|
PQgetvalue(result, i, 0));
|
||||||
|
|
||||||
if (*(PQgetvalue(result, i, 1)) == 'f')
|
if (*(PQgetvalue(result, i, 1)) == 'f')
|
||||||
appendPQExpBuffer(&buf, " AS RESTRICTIVE");
|
appendPQExpBufferStr(&buf, " AS RESTRICTIVE");
|
||||||
|
|
||||||
if (!PQgetisnull(result, i, 5))
|
if (!PQgetisnull(result, i, 5))
|
||||||
appendPQExpBuffer(&buf, " FOR %s",
|
appendPQExpBuffer(&buf, " FOR %s",
|
||||||
@ -2913,12 +2913,12 @@ describeOneTableDetails(const char *schemaname,
|
|||||||
"t.tgconstraint <> 0 AS tgisinternal" :
|
"t.tgconstraint <> 0 AS tgisinternal" :
|
||||||
"false AS tgisinternal"), oid);
|
"false AS tgisinternal"), oid);
|
||||||
if (pset.sversion >= 110000)
|
if (pset.sversion >= 110000)
|
||||||
appendPQExpBuffer(&buf, "(NOT t.tgisinternal OR (t.tgisinternal AND t.tgenabled = 'D') \n"
|
appendPQExpBufferStr(&buf, "(NOT t.tgisinternal OR (t.tgisinternal AND t.tgenabled = 'D') \n"
|
||||||
" OR EXISTS (SELECT 1 FROM pg_catalog.pg_depend WHERE objid = t.oid \n"
|
" OR EXISTS (SELECT 1 FROM pg_catalog.pg_depend WHERE objid = t.oid \n"
|
||||||
" AND refclassid = 'pg_catalog.pg_trigger'::pg_catalog.regclass))");
|
" AND refclassid = 'pg_catalog.pg_trigger'::pg_catalog.regclass))");
|
||||||
else if (pset.sversion >= 90000)
|
else if (pset.sversion >= 90000)
|
||||||
/* display/warn about disabled internal triggers */
|
/* display/warn about disabled internal triggers */
|
||||||
appendPQExpBuffer(&buf, "(NOT t.tgisinternal OR (t.tgisinternal AND t.tgenabled = 'D'))");
|
appendPQExpBufferStr(&buf, "(NOT t.tgisinternal OR (t.tgisinternal AND t.tgenabled = 'D'))");
|
||||||
else if (pset.sversion >= 80300)
|
else if (pset.sversion >= 80300)
|
||||||
appendPQExpBufferStr(&buf, "(t.tgconstraint = 0 OR (t.tgconstraint <> 0 AND t.tgenabled = 'D'))");
|
appendPQExpBufferStr(&buf, "(t.tgconstraint = 0 OR (t.tgconstraint <> 0 AND t.tgenabled = 'D'))");
|
||||||
else
|
else
|
||||||
@ -3935,33 +3935,33 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose)
|
|||||||
{
|
{
|
||||||
if (pset.sversion < 120000)
|
if (pset.sversion < 120000)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&buf,
|
appendPQExpBufferStr(&buf,
|
||||||
",\n LATERAL (WITH RECURSIVE d\n"
|
",\n LATERAL (WITH RECURSIVE d\n"
|
||||||
" AS (SELECT inhrelid AS oid, 1 AS level\n"
|
" AS (SELECT inhrelid AS oid, 1 AS level\n"
|
||||||
" FROM pg_catalog.pg_inherits\n"
|
" FROM pg_catalog.pg_inherits\n"
|
||||||
" WHERE inhparent = c.oid\n"
|
" WHERE inhparent = c.oid\n"
|
||||||
" UNION ALL\n"
|
" UNION ALL\n"
|
||||||
" SELECT inhrelid, level + 1\n"
|
" SELECT inhrelid, level + 1\n"
|
||||||
" FROM pg_catalog.pg_inherits i\n"
|
" FROM pg_catalog.pg_inherits i\n"
|
||||||
" JOIN d ON i.inhparent = d.oid)\n"
|
" JOIN d ON i.inhparent = d.oid)\n"
|
||||||
" SELECT pg_catalog.pg_size_pretty(sum(pg_catalog.pg_table_size("
|
" SELECT pg_catalog.pg_size_pretty(sum(pg_catalog.pg_table_size("
|
||||||
"d.oid))) AS tps,\n"
|
"d.oid))) AS tps,\n"
|
||||||
" pg_catalog.pg_size_pretty(sum("
|
" pg_catalog.pg_size_pretty(sum("
|
||||||
"\n CASE WHEN d.level = 1"
|
"\n CASE WHEN d.level = 1"
|
||||||
" THEN pg_catalog.pg_table_size(d.oid) ELSE 0 END)) AS dps\n"
|
" THEN pg_catalog.pg_table_size(d.oid) ELSE 0 END)) AS dps\n"
|
||||||
" FROM d) s");
|
" FROM d) s");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* PostgreSQL 12 has pg_partition_tree function */
|
/* PostgreSQL 12 has pg_partition_tree function */
|
||||||
appendPQExpBuffer(&buf,
|
appendPQExpBufferStr(&buf,
|
||||||
",\n LATERAL (SELECT pg_catalog.pg_size_pretty(sum("
|
",\n LATERAL (SELECT pg_catalog.pg_size_pretty(sum("
|
||||||
"\n CASE WHEN ppt.isleaf AND ppt.level = 1"
|
"\n CASE WHEN ppt.isleaf AND ppt.level = 1"
|
||||||
"\n THEN pg_catalog.pg_table_size(ppt.relid)"
|
"\n THEN pg_catalog.pg_table_size(ppt.relid)"
|
||||||
" ELSE 0 END)) AS dps"
|
" ELSE 0 END)) AS dps"
|
||||||
",\n pg_catalog.pg_size_pretty(sum("
|
",\n pg_catalog.pg_size_pretty(sum("
|
||||||
"pg_catalog.pg_table_size(ppt.relid))) AS tps"
|
"pg_catalog.pg_table_size(ppt.relid))) AS tps"
|
||||||
"\n FROM pg_catalog.pg_partition_tree(c.oid) ppt) s");
|
"\n FROM pg_catalog.pg_partition_tree(c.oid) ppt) s");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4003,7 +4003,7 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
initPQExpBuffer(&title);
|
initPQExpBuffer(&title);
|
||||||
appendPQExpBuffer(&title, "%s", tabletitle);
|
appendPQExpBufferStr(&title, tabletitle);
|
||||||
|
|
||||||
myopt.nullPrint = NULL;
|
myopt.nullPrint = NULL;
|
||||||
myopt.title = title.data;
|
myopt.title = title.data;
|
||||||
@ -4567,8 +4567,8 @@ listSchemas(const char *pattern, bool verbose, bool showSystem)
|
|||||||
gettext_noop("Description"));
|
gettext_noop("Description"));
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBuffer(&buf,
|
appendPQExpBufferStr(&buf,
|
||||||
"\nFROM pg_catalog.pg_namespace n\n");
|
"\nFROM pg_catalog.pg_namespace n\n");
|
||||||
|
|
||||||
if (!showSystem && !pattern)
|
if (!showSystem && !pattern)
|
||||||
appendPQExpBufferStr(&buf,
|
appendPQExpBufferStr(&buf,
|
||||||
@ -5768,10 +5768,10 @@ describePublications(const char *pattern)
|
|||||||
" pg_catalog.pg_get_userbyid(pubowner) AS owner,\n"
|
" pg_catalog.pg_get_userbyid(pubowner) AS owner,\n"
|
||||||
" puballtables, pubinsert, pubupdate, pubdelete");
|
" puballtables, pubinsert, pubupdate, pubdelete");
|
||||||
if (has_pubtruncate)
|
if (has_pubtruncate)
|
||||||
appendPQExpBuffer(&buf,
|
appendPQExpBufferStr(&buf,
|
||||||
", pubtruncate");
|
", pubtruncate");
|
||||||
appendPQExpBuffer(&buf,
|
appendPQExpBufferStr(&buf,
|
||||||
"\nFROM pg_catalog.pg_publication\n");
|
"\nFROM pg_catalog.pg_publication\n");
|
||||||
|
|
||||||
processSQLNamePattern(pset.db, &buf, pattern, false, false,
|
processSQLNamePattern(pset.db, &buf, pattern, false, false,
|
||||||
NULL, "pubname", NULL,
|
NULL, "pubname", NULL,
|
||||||
|
@ -254,7 +254,7 @@ cluster_all_databases(bool verbose, const char *maintenance_db,
|
|||||||
}
|
}
|
||||||
|
|
||||||
resetPQExpBuffer(&connstr);
|
resetPQExpBuffer(&connstr);
|
||||||
appendPQExpBuffer(&connstr, "dbname=");
|
appendPQExpBufferStr(&connstr, "dbname=");
|
||||||
appendConnStrVal(&connstr, dbname);
|
appendConnStrVal(&connstr, dbname);
|
||||||
|
|
||||||
cluster_one_database(connstr.data, verbose, NULL,
|
cluster_one_database(connstr.data, verbose, NULL,
|
||||||
|
@ -420,7 +420,7 @@ reindex_all_databases(const char *maintenance_db,
|
|||||||
}
|
}
|
||||||
|
|
||||||
resetPQExpBuffer(&connstr);
|
resetPQExpBuffer(&connstr);
|
||||||
appendPQExpBuffer(&connstr, "dbname=");
|
appendPQExpBufferStr(&connstr, "dbname=");
|
||||||
appendConnStrVal(&connstr, dbname);
|
appendConnStrVal(&connstr, dbname);
|
||||||
|
|
||||||
reindex_one_database(NULL, connstr.data, REINDEX_DATABASE, host,
|
reindex_one_database(NULL, connstr.data, REINDEX_DATABASE, host,
|
||||||
|
@ -477,16 +477,16 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
|
|||||||
|
|
||||||
if (!tables_listed)
|
if (!tables_listed)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&catalog_query,
|
appendPQExpBufferStr(&catalog_query,
|
||||||
"WITH listed_tables (table_oid, column_list) "
|
"WITH listed_tables (table_oid, column_list) "
|
||||||
"AS (\n VALUES (");
|
"AS (\n VALUES (");
|
||||||
tables_listed = true;
|
tables_listed = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(&catalog_query, ",\n (");
|
appendPQExpBufferStr(&catalog_query, ",\n (");
|
||||||
|
|
||||||
appendStringLiteralConn(&catalog_query, just_table, conn);
|
appendStringLiteralConn(&catalog_query, just_table, conn);
|
||||||
appendPQExpBuffer(&catalog_query, "::pg_catalog.regclass, ");
|
appendPQExpBufferStr(&catalog_query, "::pg_catalog.regclass, ");
|
||||||
|
|
||||||
if (just_columns && just_columns[0] != '\0')
|
if (just_columns && just_columns[0] != '\0')
|
||||||
appendStringLiteralConn(&catalog_query, just_columns, conn);
|
appendStringLiteralConn(&catalog_query, just_columns, conn);
|
||||||
@ -500,24 +500,24 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
|
|||||||
|
|
||||||
/* Finish formatting the CTE */
|
/* Finish formatting the CTE */
|
||||||
if (tables_listed)
|
if (tables_listed)
|
||||||
appendPQExpBuffer(&catalog_query, "\n)\n");
|
appendPQExpBufferStr(&catalog_query, "\n)\n");
|
||||||
|
|
||||||
appendPQExpBuffer(&catalog_query, "SELECT c.relname, ns.nspname");
|
appendPQExpBufferStr(&catalog_query, "SELECT c.relname, ns.nspname");
|
||||||
|
|
||||||
if (tables_listed)
|
if (tables_listed)
|
||||||
appendPQExpBuffer(&catalog_query, ", listed_tables.column_list");
|
appendPQExpBufferStr(&catalog_query, ", listed_tables.column_list");
|
||||||
|
|
||||||
appendPQExpBuffer(&catalog_query,
|
appendPQExpBufferStr(&catalog_query,
|
||||||
" FROM pg_catalog.pg_class c\n"
|
" FROM pg_catalog.pg_class c\n"
|
||||||
" JOIN pg_catalog.pg_namespace ns"
|
" JOIN pg_catalog.pg_namespace ns"
|
||||||
" ON c.relnamespace OPERATOR(pg_catalog.=) ns.oid\n"
|
" ON c.relnamespace OPERATOR(pg_catalog.=) ns.oid\n"
|
||||||
" LEFT JOIN pg_catalog.pg_class t"
|
" LEFT JOIN pg_catalog.pg_class t"
|
||||||
" ON c.reltoastrelid OPERATOR(pg_catalog.=) t.oid\n");
|
" ON c.reltoastrelid OPERATOR(pg_catalog.=) t.oid\n");
|
||||||
|
|
||||||
/* Used to match the tables listed by the user */
|
/* Used to match the tables listed by the user */
|
||||||
if (tables_listed)
|
if (tables_listed)
|
||||||
appendPQExpBuffer(&catalog_query, " JOIN listed_tables"
|
appendPQExpBufferStr(&catalog_query, " JOIN listed_tables"
|
||||||
" ON listed_tables.table_oid OPERATOR(pg_catalog.=) c.oid\n");
|
" ON listed_tables.table_oid OPERATOR(pg_catalog.=) c.oid\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If no tables were listed, filter for the relevant relation types. If
|
* If no tables were listed, filter for the relevant relation types. If
|
||||||
@ -527,9 +527,9 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
|
|||||||
*/
|
*/
|
||||||
if (!tables_listed)
|
if (!tables_listed)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&catalog_query, " WHERE c.relkind OPERATOR(pg_catalog.=) ANY (array["
|
appendPQExpBufferStr(&catalog_query, " WHERE c.relkind OPERATOR(pg_catalog.=) ANY (array["
|
||||||
CppAsString2(RELKIND_RELATION) ", "
|
CppAsString2(RELKIND_RELATION) ", "
|
||||||
CppAsString2(RELKIND_MATVIEW) "])\n");
|
CppAsString2(RELKIND_MATVIEW) "])\n");
|
||||||
has_where = true;
|
has_where = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -568,7 +568,7 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
|
|||||||
* Execute the catalog query. We use the default search_path for this
|
* Execute the catalog query. We use the default search_path for this
|
||||||
* query for consistency with table lookups done elsewhere by the user.
|
* query for consistency with table lookups done elsewhere by the user.
|
||||||
*/
|
*/
|
||||||
appendPQExpBuffer(&catalog_query, " ORDER BY c.relpages DESC;");
|
appendPQExpBufferStr(&catalog_query, " ORDER BY c.relpages DESC;");
|
||||||
executeCommand(conn, "RESET search_path;", progname, echo);
|
executeCommand(conn, "RESET search_path;", progname, echo);
|
||||||
res = executeQuery(conn, catalog_query.data, progname, echo);
|
res = executeQuery(conn, catalog_query.data, progname, echo);
|
||||||
termPQExpBuffer(&catalog_query);
|
termPQExpBuffer(&catalog_query);
|
||||||
@ -775,7 +775,7 @@ vacuum_all_databases(vacuumingOptions *vacopts,
|
|||||||
for (i = 0; i < PQntuples(result); i++)
|
for (i = 0; i < PQntuples(result); i++)
|
||||||
{
|
{
|
||||||
resetPQExpBuffer(&connstr);
|
resetPQExpBuffer(&connstr);
|
||||||
appendPQExpBuffer(&connstr, "dbname=");
|
appendPQExpBufferStr(&connstr, "dbname=");
|
||||||
appendConnStrVal(&connstr, PQgetvalue(result, i, 0));
|
appendConnStrVal(&connstr, PQgetvalue(result, i, 0));
|
||||||
|
|
||||||
vacuum_one_database(connstr.data, vacopts,
|
vacuum_one_database(connstr.data, vacopts,
|
||||||
@ -792,7 +792,7 @@ vacuum_all_databases(vacuumingOptions *vacopts,
|
|||||||
for (i = 0; i < PQntuples(result); i++)
|
for (i = 0; i < PQntuples(result); i++)
|
||||||
{
|
{
|
||||||
resetPQExpBuffer(&connstr);
|
resetPQExpBuffer(&connstr);
|
||||||
appendPQExpBuffer(&connstr, "dbname=");
|
appendPQExpBufferStr(&connstr, "dbname=");
|
||||||
appendConnStrVal(&connstr, PQgetvalue(result, i, 0));
|
appendConnStrVal(&connstr, PQgetvalue(result, i, 0));
|
||||||
|
|
||||||
vacuum_one_database(connstr.data, vacopts,
|
vacuum_one_database(connstr.data, vacopts,
|
||||||
|
@ -624,10 +624,10 @@ appendPsqlMetaConnect(PQExpBuffer buf, const char *dbname)
|
|||||||
PQExpBufferData connstr;
|
PQExpBufferData connstr;
|
||||||
|
|
||||||
initPQExpBuffer(&connstr);
|
initPQExpBuffer(&connstr);
|
||||||
appendPQExpBuffer(&connstr, "dbname=");
|
appendPQExpBufferStr(&connstr, "dbname=");
|
||||||
appendConnStrVal(&connstr, dbname);
|
appendConnStrVal(&connstr, dbname);
|
||||||
|
|
||||||
appendPQExpBuffer(buf, "-reuse-previous=on ");
|
appendPQExpBufferStr(buf, "-reuse-previous=on ");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As long as the name does not contain a newline, SQL identifier
|
* As long as the name does not contain a newline, SQL identifier
|
||||||
|
@ -346,7 +346,7 @@ build_client_first_message(fe_scram_state *state)
|
|||||||
if (strcmp(state->sasl_mechanism, SCRAM_SHA_256_PLUS_NAME) == 0)
|
if (strcmp(state->sasl_mechanism, SCRAM_SHA_256_PLUS_NAME) == 0)
|
||||||
{
|
{
|
||||||
Assert(conn->ssl_in_use);
|
Assert(conn->ssl_in_use);
|
||||||
appendPQExpBuffer(&buf, "p=tls-server-end-point");
|
appendPQExpBufferStr(&buf, "p=tls-server-end-point");
|
||||||
}
|
}
|
||||||
#ifdef HAVE_PGTLS_GET_PEER_CERTIFICATE_HASH
|
#ifdef HAVE_PGTLS_GET_PEER_CERTIFICATE_HASH
|
||||||
else if (conn->ssl_in_use)
|
else if (conn->ssl_in_use)
|
||||||
@ -354,7 +354,7 @@ build_client_first_message(fe_scram_state *state)
|
|||||||
/*
|
/*
|
||||||
* Client supports channel binding, but thinks the server does not.
|
* Client supports channel binding, but thinks the server does not.
|
||||||
*/
|
*/
|
||||||
appendPQExpBuffer(&buf, "y");
|
appendPQExpBufferChar(&buf, 'y');
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
@ -362,7 +362,7 @@ build_client_first_message(fe_scram_state *state)
|
|||||||
/*
|
/*
|
||||||
* Client does not support channel binding.
|
* Client does not support channel binding.
|
||||||
*/
|
*/
|
||||||
appendPQExpBuffer(&buf, "n");
|
appendPQExpBufferChar(&buf, 'n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PQExpBufferDataBroken(buf))
|
if (PQExpBufferDataBroken(buf))
|
||||||
@ -437,7 +437,7 @@ build_client_final_message(fe_scram_state *state)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBuffer(&buf, "c=");
|
appendPQExpBufferStr(&buf, "c=");
|
||||||
|
|
||||||
/* p=type,, */
|
/* p=type,, */
|
||||||
cbind_header_len = strlen("p=tls-server-end-point,,");
|
cbind_header_len = strlen("p=tls-server-end-point,,");
|
||||||
@ -475,10 +475,10 @@ build_client_final_message(fe_scram_state *state)
|
|||||||
}
|
}
|
||||||
#ifdef HAVE_PGTLS_GET_PEER_CERTIFICATE_HASH
|
#ifdef HAVE_PGTLS_GET_PEER_CERTIFICATE_HASH
|
||||||
else if (conn->ssl_in_use)
|
else if (conn->ssl_in_use)
|
||||||
appendPQExpBuffer(&buf, "c=eSws"); /* base64 of "y,," */
|
appendPQExpBufferStr(&buf, "c=eSws"); /* base64 of "y,," */
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(&buf, "c=biws"); /* base64 of "n,," */
|
appendPQExpBufferStr(&buf, "c=biws"); /* base64 of "n,," */
|
||||||
|
|
||||||
if (PQExpBufferDataBroken(buf))
|
if (PQExpBufferDataBroken(buf))
|
||||||
goto oom_error;
|
goto oom_error;
|
||||||
@ -496,7 +496,7 @@ build_client_final_message(fe_scram_state *state)
|
|||||||
state->client_final_message_without_proof,
|
state->client_final_message_without_proof,
|
||||||
client_proof);
|
client_proof);
|
||||||
|
|
||||||
appendPQExpBuffer(&buf, ",p=");
|
appendPQExpBufferStr(&buf, ",p=");
|
||||||
if (!enlargePQExpBuffer(&buf, pg_b64_enc_len(SCRAM_KEY_LEN)))
|
if (!enlargePQExpBuffer(&buf, pg_b64_enc_len(SCRAM_KEY_LEN)))
|
||||||
goto oom_error;
|
goto oom_error;
|
||||||
buf.len += pg_b64_encode((char *) client_proof,
|
buf.len += pg_b64_encode((char *) client_proof,
|
||||||
|
@ -2772,8 +2772,8 @@ keep_going: /* We will come back to here until there is
|
|||||||
}
|
}
|
||||||
else if (!conn->gctx && conn->gssencmode[0] == 'r')
|
else if (!conn->gctx && conn->gssencmode[0] == 'r')
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&conn->errorMessage,
|
appendPQExpBufferStr(&conn->errorMessage,
|
||||||
libpq_gettext("GSSAPI encryption required, but was impossible (possibly no ccache, no server support, or using a local socket)\n"));
|
libpq_gettext("GSSAPI encryption required, but was impossible (possibly no ccache, no server support, or using a local socket)\n"));
|
||||||
goto error_return;
|
goto error_return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -996,7 +996,7 @@ pqBuildErrorMessage3(PQExpBuffer msg, const PGresult *res,
|
|||||||
/* If we couldn't allocate a PGresult, just say "out of memory" */
|
/* If we couldn't allocate a PGresult, just say "out of memory" */
|
||||||
if (res == NULL)
|
if (res == NULL)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(msg, libpq_gettext("out of memory\n"));
|
appendPQExpBufferStr(msg, libpq_gettext("out of memory\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1009,7 +1009,7 @@ pqBuildErrorMessage3(PQExpBuffer msg, const PGresult *res,
|
|||||||
if (res->errMsg && res->errMsg[0])
|
if (res->errMsg && res->errMsg[0])
|
||||||
appendPQExpBufferStr(msg, res->errMsg);
|
appendPQExpBufferStr(msg, res->errMsg);
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(msg, libpq_gettext("no error message available\n"));
|
appendPQExpBufferStr(msg, libpq_gettext("no error message available\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user