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

Improve the method of localizing column names and other fixed strings in

psql's \d commands and other uses of printQuery().  Previously we would pass
these strings through gettext() and then send them to the server as literals
in the SQL query.  But the code was not set up to handle doubling of quotes in
the strings, causing failure if a translation attempted to use the wrong kind
of quote marks, as indeed is now the case for (at least) the French
translation of \dFp.  Another hazard was that gettext() would translate to
whatever encoding was implied by the client's LC_CTYPE setting, which might be
different from the client_encoding setting, which would probably cause the
server to reject the query as mis-encoded.  The new arrangement is to send the
untranslated ASCII strings to the server, and do the translations inside
printQuery() after the query results come back.  Per report from Guillaume
Lelarge and subsequent discussion.
This commit is contained in:
Tom Lane
2007-12-12 21:41:47 +00:00
parent 286049dbe4
commit df4271fedd
7 changed files with 241 additions and 125 deletions

View File

@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.24 2007/12/11 19:57:32 tgl Exp $
* $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.25 2007/12/12 21:41:47 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -136,6 +136,7 @@ main(int argc, char *argv[])
if (listlangs)
{
printQueryOpt popt;
static const bool trans_columns[] = {false, true};
conn = connectDatabase(dbname, host, port, username, password,
progname);
@ -143,7 +144,9 @@ main(int argc, char *argv[])
printfPQExpBuffer(&sql, "SELECT lanname as \"%s\", "
"(CASE WHEN lanpltrusted THEN '%s' ELSE '%s' END) as \"%s\" "
"FROM pg_catalog.pg_language WHERE lanispl;",
_("Name"), _("yes"), _("no"), _("Trusted?"));
gettext_noop("Name"),
gettext_noop("yes"), gettext_noop("no"),
gettext_noop("Trusted?"));
result = executeQuery(conn, sql.data, progname, echo);
memset(&popt, 0, sizeof(popt));
@ -153,6 +156,8 @@ main(int argc, char *argv[])
popt.topt.stop_table = true;
popt.topt.encoding = PQclientEncoding(conn);
popt.title = _("Procedural Languages");
popt.trans_headers = true;
popt.trans_columns = trans_columns;
printQuery(result, &popt, stdout, NULL);
PQfinish(conn);