1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

Install infrastructure to manage psql's hidden query labels better.

Commit 41d69e6dc added labels to psql's internally-generated queries,
which are sent to the server and possibly recorded in the server log.
In that commit we always attempted to translate the labels per psql's
NLS environment, but that is hazardous: non-ASCII labels might fail
to be translatable to the server's encoding, rendering some or all of
these operations unusable since the server will throw an error and
not execute the query.  Hence, we need some gating checks to decide
whether it's safe to translate a label.

To allow that to be managed in just one place, invent a new function
addQueryComment() that is responsible for outputting these labels.
(Probably it should have been done that way to start with, but better
late than never.)

This commit just does the heavy lifting of creating that function and
fixing all the call sites.  The actual choice of whether to translate
is stubbed out, so that this commit in itself changes no behavior.
Once we've settled on the correct gating checks to use, a much smaller
follow-on commit will install them.

Author: shihao zhong <zhong950419@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAGRkXqRv7yhBOhF0YvSr6ZB7rvsPCjnXSPj8=3bKcSJuYvNrBA@mail.gmail.com
Backpatch-through: 19
This commit is contained in:
Tom Lane
2026-10-15 14:45:14 -04:00
parent a39e53a700
commit 294d2196c7
5 changed files with 110 additions and 116 deletions

View File

@@ -6220,7 +6220,7 @@ lookup_object_oid(EditableObjectType obj_type, const char *desc,
* query to retrieve the function's OID using a cast to regproc or
* regprocedure (as appropriate).
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get function's OID"));
addQueryComment(query, "Get function's OID");
appendPQExpBufferStr(query, "SELECT ");
appendStringLiteralConn(query, desc, pset.db);
appendPQExpBuffer(query, "::pg_catalog.%s::pg_catalog.oid",
@@ -6234,7 +6234,7 @@ lookup_object_oid(EditableObjectType obj_type, const char *desc,
* this code doesn't check if the relation is actually a view.
* We'll detect that in get_create_object_cmd().
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's OID"));
addQueryComment(query, "Get view's OID");
appendPQExpBufferStr(query, "SELECT ");
appendStringLiteralConn(query, desc, pset.db);
appendPQExpBufferStr(query, "::pg_catalog.regclass::pg_catalog.oid");
@@ -6276,7 +6276,7 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
switch (obj_type)
{
case EditableFunction:
printfPQExpBuffer(query, "/* %s */\n", _("Get function's definition"));
addQueryComment(query, "Get function's definition");
appendPQExpBuffer(query,
"SELECT pg_catalog.pg_get_functiondef(%u)",
oid);
@@ -6295,7 +6295,7 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid,
* and so need to be retrieved separately. Materialized views may
* have arbitrary storage parameter reloptions.
*/
printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details"));
addQueryComment(query, "Get view's definition and details");
appendPQExpBuffer(query,
"SELECT nspname, relname, relkind, "
"pg_catalog.pg_get_viewdef(c.oid, true), "

View File

@@ -2617,6 +2617,28 @@ command_no_begin(const char *query)
}
/*
* addQueryComment
*
* Reset buf and insert a comment holding label. The comment will show up
* in -E output and in the server log.
*
* If it's safe, we attempt to translate the label string.
* (addQueryComment is marked as a gettext trigger, so this requires no
* special effort at call sites.)
*/
void
addQueryComment(PQExpBuffer buf, const char *label)
{
#if defined(ENABLE_NLS)
/* This will become conditional once we've settled on the tests to use */
label = _(label);
#endif
printfPQExpBuffer(buf, "/* %s */\n", label);
}
/*
* Test if the current user is a database superuser.
*/

View File

@@ -36,6 +36,8 @@ extern int PSQLexecWatch(const char *query, const printQueryOpt *opt, FILE *prin
extern bool SendQuery(const char *query, int num_copy_from_stdin);
extern void addQueryComment(PQExpBuffer buf, const char *label);
extern bool is_superuser(void);
extern bool standard_strings(void);
extern const char *session_username(void);

View File

@@ -83,7 +83,7 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching aggregates"));
addQueryComment(&buf, "Get matching aggregates");
appendPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" p.proname AS \"%s\",\n"
@@ -155,7 +155,7 @@ describeAccessMethods(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods"));
addQueryComment(&buf, "Get matching access methods");
appendPQExpBuffer(&buf,
"SELECT amname AS \"%s\",\n"
" CASE amtype"
@@ -219,7 +219,7 @@ describeTablespaces(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching tablespaces"));
addQueryComment(&buf, "Get matching tablespaces");
appendPQExpBuffer(&buf,
"SELECT spcname AS \"%s\",\n"
" pg_catalog.pg_get_userbyid(spcowner) AS \"%s\",\n"
@@ -327,7 +327,7 @@ describeFunctions(const char *functypes, const char *func_pattern,
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching functions"));
addQueryComment(&buf, "Get matching functions");
appendPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" p.proname as \"%s\",\n",
@@ -626,7 +626,7 @@ describeTypes(const char *pattern, bool verbose, bool showSystem)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching types"));
addQueryComment(&buf, "Get matching types");
appendPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" pg_catalog.format_type(t.oid, NULL) AS \"%s\",\n",
@@ -801,7 +801,7 @@ describeOperators(const char *oper_pattern,
* to pre-v14 servers.
*/
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching operators"));
addQueryComment(&buf, "Get matching operators");
appendPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" o.oprname AS \"%s\",\n"
@@ -935,7 +935,7 @@ listAllDbs(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching databases"));
addQueryComment(&buf, "Get matching databases");
appendPQExpBuffer(&buf,
"SELECT\n"
" d.datname as \"%s\",\n"
@@ -1045,8 +1045,7 @@ permissionsList(const char *pattern, bool showSystem)
/*
* we ignore indexes and toast tables since they have no meaningful rights
*/
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get access privileges of matching relations"));
addQueryComment(&buf, "Get access privileges of matching relations");
appendPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" c.relname as \"%s\",\n"
@@ -1176,7 +1175,7 @@ listDefaultACLs(const char *pattern)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching default ACLs"));
addQueryComment(&buf, "Get matching default ACLs");
appendPQExpBuffer(&buf,
"SELECT pg_catalog.pg_get_userbyid(d.defaclrole) AS \"%s\",\n"
" n.nspname AS \"%s\",\n"
@@ -1258,7 +1257,7 @@ objectDescription(const char *pattern, bool showSystem)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching object comments"));
addQueryComment(&buf, "Get matching object comments");
appendPQExpBuffer(&buf,
"SELECT DISTINCT tt.nspname AS \"%s\", tt.name AS \"%s\", tt.object AS \"%s\", d.description AS \"%s\"\n"
"FROM (\n",
@@ -1451,8 +1450,7 @@ describeTableDetails(const char *pattern, bool verbose, bool showSystem)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get matching relations to describe"));
addQueryComment(&buf, "Get matching relations to describe");
appendPQExpBufferStr(&buf,
"SELECT c.oid,\n"
" n.nspname,\n"
@@ -1589,8 +1587,7 @@ describeOneTableDetails(const char *schemaname,
initPQExpBuffer(&tmpbuf);
/* Get general table info */
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get general information about one relation"));
addQueryComment(&buf, "Get general information about one relation");
if (pset.sversion >= 120000)
{
appendPQExpBuffer(&buf,
@@ -1671,7 +1668,7 @@ describeOneTableDetails(const char *schemaname,
printQueryOpt popt = pset.popt;
char *footers[3] = {NULL, NULL, NULL};
printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information"));
addQueryComment(&buf, "Get sequence information");
appendPQExpBuffer(&buf,
"SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n"
" seqstart AS \"%s\",\n"
@@ -1699,8 +1696,7 @@ describeOneTableDetails(const char *schemaname,
goto error_return;
/* Get the column that owns this sequence */
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get the column that owns this sequence"));
addQueryComment(&buf, "Get the column that owns this sequence");
appendPQExpBuffer(&buf, "SELECT pg_catalog.quote_ident(nspname) || '.' ||"
"\n pg_catalog.quote_ident(relname) || '.' ||"
"\n pg_catalog.quote_ident(attname),"
@@ -1745,8 +1741,7 @@ describeOneTableDetails(const char *schemaname,
/* Print any publications */
if (pset.sversion >= 190000)
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get publications containing this sequence"));
addQueryComment(&buf, "Get publications containing this sequence");
appendPQExpBuffer(&buf, "SELECT pubname FROM pg_catalog.pg_publication p"
"\nWHERE p.puballsequences"
"\n AND pg_catalog.pg_relation_is_publishable('%s')"
@@ -1816,8 +1811,7 @@ describeOneTableDetails(const char *schemaname,
* duplicative test logic below.
*/
cols = 0;
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get per-column information for one relation"));
addQueryComment(&buf, "Get per-column information for one relation");
appendPQExpBufferStr(&buf, "SELECT a.attname");
attname_col = cols++;
appendPQExpBufferStr(&buf, ",\n pg_catalog.format_type(a.atttypid, a.atttypmod)");
@@ -2117,8 +2111,7 @@ describeOneTableDetails(const char *schemaname,
/* Footer information for a partition child table */
PGresult *result;
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get partitioning information for this partition"));
addQueryComment(&buf, "Get partitioning information for this partition");
appendPQExpBufferStr(&buf,
"SELECT inhparent::pg_catalog.regclass,\n"
" pg_catalog.pg_get_expr(c.relpartbound, c.oid),\n ");
@@ -2174,8 +2167,7 @@ describeOneTableDetails(const char *schemaname,
/* Footer information for a partitioned table (partitioning parent) */
PGresult *result;
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get partitioning information for this table"));
addQueryComment(&buf, "Get partitioning information for this table");
appendPQExpBuffer(&buf,
"SELECT pg_catalog.pg_get_partkeydef('%s'::pg_catalog.oid);",
oid);
@@ -2198,8 +2190,7 @@ describeOneTableDetails(const char *schemaname,
/* For a TOAST table, print name of owning table */
PGresult *result;
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get the table that owns this TOAST table"));
addQueryComment(&buf, "Get the table that owns this TOAST table");
appendPQExpBuffer(&buf,
"SELECT n.nspname, c.relname\n"
"FROM pg_catalog.pg_class c"
@@ -2228,7 +2219,7 @@ describeOneTableDetails(const char *schemaname,
/* Footer information about an index */
PGresult *result;
printfPQExpBuffer(&buf, "/* %s */\n", _("Get index details"));
addQueryComment(&buf, "Get index details");
appendPQExpBufferStr(&buf,
"SELECT i.indisunique, i.indisprimary, i.indisclustered, "
"i.indisvalid,\n"
@@ -2347,7 +2338,7 @@ describeOneTableDetails(const char *schemaname,
/* print indexes */
if (tableinfo.hasindex)
{
printfPQExpBuffer(&buf, "/* %s */\n", _("Get indexes for this table"));
addQueryComment(&buf, "Get indexes for this table");
appendPQExpBufferStr(&buf,
"SELECT c2.relname, i.indisprimary, i.indisunique, "
"i.indisclustered, i.indisvalid, "
@@ -2449,8 +2440,7 @@ describeOneTableDetails(const char *schemaname,
/* print table (and column) check constraints */
if (tableinfo.checks)
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get check constraints for this table"));
addQueryComment(&buf, "Get check constraints for this table");
appendPQExpBuffer(&buf,
"SELECT r.conname, "
"pg_catalog.pg_get_constraintdef(r.oid, true)\n"
@@ -2482,8 +2472,7 @@ describeOneTableDetails(const char *schemaname,
}
/* Print foreign-key constraints */
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get foreign key constraints for this table"));
addQueryComment(&buf, "Get foreign key constraints for this table");
if (pset.sversion >= 120000 &&
(tableinfo.ispartition || tableinfo.relkind == RELKIND_PARTITIONED_TABLE))
{
@@ -2554,8 +2543,7 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print incoming foreign-key references */
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get foreign keys referencing this table"));
addQueryComment(&buf, "Get foreign keys referencing this table");
if (pset.sversion >= 120000)
{
appendPQExpBuffer(&buf,
@@ -2605,8 +2593,7 @@ describeOneTableDetails(const char *schemaname,
PQclear(result);
/* print any row-level policies */
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get row-level policies for this table"));
addQueryComment(&buf, "Get row-level policies for this table");
appendPQExpBufferStr(&buf, "SELECT pol.polname,");
appendPQExpBufferStr(&buf,
" pol.polpermissive,\n");
@@ -2683,8 +2670,7 @@ describeOneTableDetails(const char *schemaname,
/* print any extended statistics */
if (pset.sversion >= 140000)
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get extended statistics for this table"));
addQueryComment(&buf, "Get extended statistics for this table");
appendPQExpBuffer(&buf,
"SELECT oid, "
"stxrelid::pg_catalog.regclass, "
@@ -2783,8 +2769,7 @@ describeOneTableDetails(const char *schemaname,
}
else
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get extended statistics for this table"));
addQueryComment(&buf, "Get extended statistics for this table");
appendPQExpBufferStr(&buf,
"SELECT oid, "
"stxrelid::pg_catalog.regclass, "
@@ -2864,8 +2849,7 @@ describeOneTableDetails(const char *schemaname,
/* print rules */
if (tableinfo.hasrules && tableinfo.relkind != RELKIND_MATVIEW)
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get rules for this relation"));
addQueryComment(&buf, "Get rules for this relation");
appendPQExpBuffer(&buf,
"SELECT r.rulename, trim(trailing ';' from pg_catalog.pg_get_ruledef(r.oid, true)), "
"ev_enabled\n"
@@ -2947,8 +2931,7 @@ describeOneTableDetails(const char *schemaname,
}
/* print any publications */
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get publications that publish this table"));
addQueryComment(&buf, "Get publications that publish this table");
if (pset.sversion >= 150000)
{
appendPQExpBuffer(&buf,
@@ -3070,8 +3053,7 @@ describeOneTableDetails(const char *schemaname,
/* Print publications where the table is in the EXCEPT clause */
if (pset.sversion >= 190000)
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get publications that exclude this table"));
addQueryComment(&buf, "Get publications that exclude this table");
appendPQExpBuffer(&buf,
"SELECT pubname\n"
"FROM pg_catalog.pg_publication p\n"
@@ -3104,8 +3086,7 @@ describeOneTableDetails(const char *schemaname,
*/
if (verbose)
{
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get not-null constraints for this table"));
addQueryComment(&buf, "Get not-null constraints for this table");
appendPQExpBuffer(&buf,
"SELECT c.conname, a.attname, c.connoinherit,\n"
" c.conislocal, c.coninhcount <> 0,\n"
@@ -3155,7 +3136,7 @@ describeOneTableDetails(const char *schemaname,
{
PGresult *result;
printfPQExpBuffer(&buf, "/* %s */\n", _("Get view's definition"));
addQueryComment(&buf, "Get view's definition");
appendPQExpBuffer(&buf,
"SELECT pg_catalog.pg_get_viewdef('%s'::pg_catalog.oid, true);",
oid);
@@ -3180,7 +3161,7 @@ describeOneTableDetails(const char *schemaname,
/* print rules */
if (tableinfo.hasrules)
{
printfPQExpBuffer(&buf, "/* %s */\n", _("Get rules for this view"));
addQueryComment(&buf, "Get rules for this view");
appendPQExpBuffer(&buf,
"SELECT r.rulename, trim(trailing ';' from pg_catalog.pg_get_ruledef(r.oid, true))\n"
"FROM pg_catalog.pg_rewrite r\n"
@@ -3218,8 +3199,7 @@ describeOneTableDetails(const char *schemaname,
PGresult *result;
int tuples;
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get triggers for this relation"));
addQueryComment(&buf, "Get triggers for this relation");
appendPQExpBufferStr(&buf,
"SELECT t.tgname, "
"pg_catalog.pg_get_triggerdef(t.oid, true), "
@@ -3403,8 +3383,7 @@ describeOneTableDetails(const char *schemaname,
char *ftoptions;
/* Footer information about foreign table */
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get foreign server for this table"));
addQueryComment(&buf, "Get foreign server for this table");
appendPQExpBuffer(&buf,
"SELECT s.srvname,\n"
" pg_catalog.array_to_string(ARRAY(\n"
@@ -3440,8 +3419,7 @@ describeOneTableDetails(const char *schemaname,
}
/* print tables inherited from (exclude partitioned parents) */
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get inheritance parent tables"));
addQueryComment(&buf, "Get inheritance parent tables");
appendPQExpBuffer(&buf,
"SELECT c.oid::pg_catalog.regclass\n"
"FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n"
@@ -3476,7 +3454,7 @@ describeOneTableDetails(const char *schemaname,
}
/* print child tables (with additional info if partitions) */
printfPQExpBuffer(&buf, "/* %s */\n", _("Get child tables"));
addQueryComment(&buf, "Get child tables");
if (pset.sversion >= 140000)
appendPQExpBuffer(&buf,
"SELECT c.oid::pg_catalog.regclass, c.relkind,"
@@ -3662,8 +3640,7 @@ add_tablespace_footer(printTableContent *cont, char relkind,
PQExpBufferData buf;
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get tablespace information for this relation"));
addQueryComment(&buf, "Get tablespace information for this relation");
appendPQExpBuffer(&buf,
"SELECT spcname FROM pg_catalog.pg_tablespace\n"
"WHERE oid = '%u';", tablespace);
@@ -3725,7 +3702,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching roles"));
addQueryComment(&buf, "Get matching roles");
appendPQExpBufferStr(&buf,
"SELECT r.rolname, r.rolsuper, r.rolinherit,\n"
" r.rolcreaterole, r.rolcreatedb, r.rolcanlogin,\n"
@@ -3860,7 +3837,7 @@ listDbRoleSettings(const char *pattern, const char *pattern2)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get per-database and per-role settings"));
addQueryComment(&buf, "Get per-database and per-role settings");
appendPQExpBuffer(&buf, "SELECT rolname AS \"%s\", datname AS \"%s\",\n"
"pg_catalog.array_to_string(setconfig, E'\\n') AS \"%s\"\n"
"FROM pg_catalog.pg_db_role_setting s\n"
@@ -3928,7 +3905,7 @@ describeRoleGrants(const char *pattern, bool showSystem)
printQueryOpt myopt = pset.popt;
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching role grants"));
addQueryComment(&buf, "Get matching role grants");
appendPQExpBuffer(&buf,
"SELECT m.rolname AS \"%s\", r.rolname AS \"%s\",\n"
" pg_catalog.concat_ws(', ',\n",
@@ -4026,7 +4003,7 @@ listTables(const char *tabtypes, const char *pattern, bool verbose, bool showSys
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching relations"));
addQueryComment(&buf, "Get matching relations");
appendPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" c.relname as \"%s\",\n"
@@ -4287,8 +4264,7 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get matching partitioned relations"));
addQueryComment(&buf, "Get matching partitioned relations");
appendPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" c.relname as \"%s\",\n"
@@ -4464,7 +4440,7 @@ listLanguages(const char *pattern, bool verbose, bool showSystem)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching procedural languages"));
addQueryComment(&buf, "Get matching procedural languages");
appendPQExpBuffer(&buf,
"SELECT l.lanname AS \"%s\",\n"
" pg_catalog.pg_get_userbyid(l.lanowner) as \"%s\",\n"
@@ -4541,7 +4517,7 @@ listDomains(const char *pattern, bool verbose, bool showSystem)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching domains"));
addQueryComment(&buf, "Get matching domains");
appendPQExpBuffer(&buf,
"SELECT n.nspname as \"%s\",\n"
" t.typname as \"%s\",\n"
@@ -4627,7 +4603,7 @@ listConversions(const char *pattern, bool verbose, bool showSystem)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching conversions"));
addQueryComment(&buf, "Get matching conversions");
appendPQExpBuffer(&buf,
"SELECT n.nspname AS \"%s\",\n"
" c.conname AS \"%s\",\n"
@@ -4707,8 +4683,7 @@ describeConfigurationParameters(const char *pattern, bool verbose,
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get matching configuration parameters"));
addQueryComment(&buf, "Get matching configuration parameters");
appendPQExpBuffer(&buf,
"SELECT s.name AS \"%s\", "
"pg_catalog.current_setting(s.name) AS \"%s\"",
@@ -4779,7 +4754,7 @@ listEventTriggers(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers"));
addQueryComment(&buf, "Get matching event triggers");
appendPQExpBuffer(&buf,
"SELECT evtname as \"%s\", "
"evtevent as \"%s\", "
@@ -4848,7 +4823,7 @@ listExtendedStats(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics"));
addQueryComment(&buf, "Get matching extended statistics");
appendPQExpBuffer(&buf,
"SELECT \n"
"es.stxnamespace::pg_catalog.regnamespace::pg_catalog.text AS \"%s\", \n"
@@ -4942,7 +4917,7 @@ listCasts(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching casts"));
addQueryComment(&buf, "Get matching casts");
appendPQExpBuffer(&buf,
"SELECT pg_catalog.format_type(castsource, NULL) AS \"%s\",\n"
" pg_catalog.format_type(casttarget, NULL) AS \"%s\",\n",
@@ -5067,7 +5042,7 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching collations"));
addQueryComment(&buf, "Get matching collations");
appendPQExpBuffer(&buf,
"SELECT\n"
" n.nspname AS \"%s\",\n"
@@ -5187,7 +5162,7 @@ listSchemas(const char *pattern, bool verbose, bool showSystem)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching schemas"));
addQueryComment(&buf, "Get matching schemas");
appendPQExpBuffer(&buf,
"SELECT n.nspname AS \"%s\",\n"
" pg_catalog.pg_get_userbyid(n.nspowner) AS \"%s\"",
@@ -5231,8 +5206,7 @@ listSchemas(const char *pattern, bool verbose, bool showSystem)
PGresult *result;
int i;
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get publications that publish this schema"));
addQueryComment(&buf, "Get publications that publish this schema");
appendPQExpBuffer(&buf,
"SELECT pubname \n"
"FROM pg_catalog.pg_publication p\n"
@@ -5313,7 +5287,7 @@ listTSParsers(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching text search parsers"));
addQueryComment(&buf, "Get matching text search parsers");
appendPQExpBuffer(&buf,
"SELECT\n"
" n.nspname as \"%s\",\n"
@@ -5363,7 +5337,7 @@ listTSParsersVerbose(const char *pattern)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching text search parsers"));
addQueryComment(&buf, "Get matching text search parsers");
appendPQExpBufferStr(&buf,
"SELECT p.oid,\n"
" n.nspname,\n"
@@ -5441,7 +5415,7 @@ describeOneTSParser(const char *oid, const char *nspname, const char *prsname)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get text search parser details"));
addQueryComment(&buf, "Get text search parser details");
appendPQExpBuffer(&buf,
"SELECT '%s' AS \"%s\",\n"
" p.prsstart::pg_catalog.regproc AS \"%s\",\n"
@@ -5510,8 +5484,7 @@ describeOneTSParser(const char *oid, const char *nspname, const char *prsname)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get text search parser token types"));
addQueryComment(&buf, "Get text search parser token types");
appendPQExpBuffer(&buf,
"SELECT t.alias as \"%s\",\n"
" t.description as \"%s\"\n"
@@ -5562,7 +5535,7 @@ listTSDictionaries(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching text search dictionaries"));
addQueryComment(&buf, "Get matching text search dictionaries");
appendPQExpBuffer(&buf,
"SELECT\n"
" n.nspname as \"%s\",\n"
@@ -5628,7 +5601,7 @@ listTSTemplates(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching text search templates"));
addQueryComment(&buf, "Get matching text search templates");
if (verbose)
appendPQExpBuffer(&buf,
"SELECT\n"
@@ -5697,7 +5670,7 @@ listTSConfigs(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching text search configurations"));
addQueryComment(&buf, "Get matching text search configurations");
appendPQExpBuffer(&buf,
"SELECT\n"
" n.nspname as \"%s\",\n"
@@ -5744,7 +5717,7 @@ listTSConfigsVerbose(const char *pattern)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching text search configurations"));
addQueryComment(&buf, "Get matching text search configurations");
appendPQExpBufferStr(&buf,
"SELECT c.oid, c.cfgname,\n"
" n.nspname,\n"
@@ -5831,7 +5804,7 @@ describeOneTSConfig(const char *oid, const char *nspname, const char *cfgname,
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get text search configuration details"));
addQueryComment(&buf, "Get text search configuration details");
appendPQExpBuffer(&buf,
"SELECT\n"
" ( SELECT t.alias FROM\n"
@@ -5901,7 +5874,7 @@ listForeignDataWrappers(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching foreign-data wrappers"));
addQueryComment(&buf, "Get matching foreign-data wrappers");
appendPQExpBuffer(&buf,
"SELECT fdw.fdwname AS \"%s\",\n"
" pg_catalog.pg_get_userbyid(fdw.fdwowner) AS \"%s\",\n"
@@ -5974,7 +5947,7 @@ listForeignServers(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching foreign servers"));
addQueryComment(&buf, "Get matching foreign servers");
appendPQExpBuffer(&buf,
"SELECT s.srvname AS \"%s\",\n"
" pg_catalog.pg_get_userbyid(s.srvowner) AS \"%s\",\n"
@@ -6052,7 +6025,7 @@ listUserMappings(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching user mappings"));
addQueryComment(&buf, "Get matching user mappings");
appendPQExpBuffer(&buf,
"SELECT um.srvname AS \"%s\",\n"
" um.usename AS \"%s\"",
@@ -6109,7 +6082,7 @@ listForeignTables(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching foreign tables"));
addQueryComment(&buf, "Get matching foreign tables");
appendPQExpBuffer(&buf,
"SELECT n.nspname AS \"%s\",\n"
" c.relname AS \"%s\",\n"
@@ -6183,7 +6156,7 @@ listExtensions(const char *pattern)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching installed extensions"));
addQueryComment(&buf, "Get matching installed extensions");
appendPQExpBuffer(&buf,
"SELECT e.extname AS \"%s\", "
"e.extversion AS \"%s\", ae.default_version AS \"%s\","
@@ -6239,7 +6212,7 @@ listExtensionContents(const char *pattern)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching installed extensions"));
addQueryComment(&buf, "Get matching installed extensions");
appendPQExpBufferStr(&buf,
"SELECT e.extname, e.oid\n"
"FROM pg_catalog.pg_extension e\n");
@@ -6309,7 +6282,7 @@ listOneExtensionContents(const char *extname, const char *oid)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get installed extension's contents"));
addQueryComment(&buf, "Get installed extension's contents");
appendPQExpBuffer(&buf,
"SELECT pg_catalog.pg_describe_object(classid, objid, 0) AS \"%s\"\n"
"FROM pg_catalog.pg_depend\n"
@@ -6408,7 +6381,7 @@ listPublications(const char *pattern)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications"));
addQueryComment(&buf, "Get matching publications");
appendPQExpBuffer(&buf,
"SELECT pubname AS \"%s\",\n"
" pg_catalog.pg_get_userbyid(pubowner) AS \"%s\",\n"
@@ -6550,7 +6523,7 @@ describePublications(const char *pattern)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get details about matching publications"));
addQueryComment(&buf, "Get details about matching publications");
appendPQExpBufferStr(&buf,
"SELECT oid, pubname,\n"
" pg_catalog.pg_get_userbyid(pubowner) AS owner,\n"
@@ -6687,8 +6660,7 @@ describePublications(const char *pattern)
if (!puballtables)
{
/* Get the tables for the specified publication */
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get tables published by this publication"));
addQueryComment(&buf, "Get tables published by this publication");
appendPQExpBufferStr(&buf, "SELECT n.nspname, c.relname");
if (pset.sversion >= 150000)
{
@@ -6738,8 +6710,7 @@ describePublications(const char *pattern)
if (pset.sversion >= 150000)
{
/* Get the schemas for the specified publication */
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get schemas published by this publication"));
addQueryComment(&buf, "Get schemas published by this publication");
appendPQExpBuffer(&buf,
"SELECT n.nspname\n"
"FROM pg_catalog.pg_namespace n\n"
@@ -6756,8 +6727,7 @@ describePublications(const char *pattern)
if (pset.sversion >= 190000)
{
/* Get tables in the EXCEPT clause for this publication */
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get tables excluded by this publication"));
addQueryComment(&buf, "Get tables excluded by this publication");
appendPQExpBuffer(&buf,
"SELECT n.nspname || '.' || c.relname\n"
"FROM pg_catalog.pg_class c\n"
@@ -6808,7 +6778,7 @@ describeSubscriptions(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions"));
addQueryComment(&buf, "Get matching subscriptions");
appendPQExpBuffer(&buf,
"SELECT subname AS \"%s\"\n"
", pg_catalog.pg_get_userbyid(subowner) AS \"%s\"\n"
@@ -6978,7 +6948,7 @@ listOperatorClasses(const char *access_method_pattern,
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching operator classes"));
addQueryComment(&buf, "Get matching operator classes");
appendPQExpBuffer(&buf,
"SELECT\n"
" am.amname AS \"%s\",\n"
@@ -7080,7 +7050,7 @@ listOperatorFamilies(const char *access_method_pattern,
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching operator families"));
addQueryComment(&buf, "Get matching operator families");
appendPQExpBuffer(&buf,
"SELECT\n"
" am.amname AS \"%s\",\n"
@@ -7171,7 +7141,7 @@ listOpFamilyOperators(const char *access_method_pattern,
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get operators of matching operator families"));
addQueryComment(&buf, "Get operators of matching operator families");
appendPQExpBuffer(&buf,
"SELECT\n"
" am.amname AS \"%s\",\n"
@@ -7278,8 +7248,7 @@ listOpFamilyFunctions(const char *access_method_pattern,
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n",
_("Get support functions of matching operator families"));
addQueryComment(&buf, "Get support functions of matching operator families");
appendPQExpBuffer(&buf,
"SELECT\n"
" am.amname AS \"%s\",\n"
@@ -7366,7 +7335,7 @@ listLargeObjects(bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf, "/* %s */\n", _("Get large objects"));
addQueryComment(&buf, "Get large objects");
appendPQExpBuffer(&buf,
"SELECT oid as \"%s\",\n"
" pg_catalog.pg_get_userbyid(lomowner) as \"%s\",\n ",

View File

@@ -25,6 +25,7 @@ GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
../../common/username.c \
../../common/wait_error.c
GETTEXT_TRIGGERS = $(FRONTEND_COMMON_GETTEXT_TRIGGERS) \
HELP0 HELPN N_ simple_prompt simple_prompt_extended
HELP0 HELPN N_ addQueryComment:2 simple_prompt \
simple_prompt_extended
GETTEXT_FLAGS = $(FRONTEND_COMMON_GETTEXT_FLAGS) \
HELPN:1:c-format