Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 341f0bc

Browse files
committed
Fix translatability markings in psql, and add defenses against future bugs.
Several previous commits have added columns to various \d queries without updating their translate_columns[] arrays, leading to potentially incorrect translations in NLS-enabled builds. Offenders include commit 8936867 (added prosecdef to \df+), c9ac00e (added description to \dc+) and 3b17efd (added description to \dC+). Fix those cases back to 9.3 or 9.2 as appropriate. Since this is evidently more easily missed than one would like, in HEAD also add an Assert that the supplied array is long enough. This requires an API change for printQuery(), so it seems inappropriate for back branches, but presumably all future changes will be tested in HEAD anyway. In HEAD and 9.3, also clean up a whole lot of sloppiness in the emitted SQL for \dy (event triggers): lack of translatability due to failing to pass words-to-be-translated through gettext_noop(), inadequate schema qualification, and sloppy formatting resulting in unnecessarily ugly -E output. Peter Eisentraut and Tom Lane, per bug #8702 from Sergey Burladyan
1 parent 948a3df commit 341f0bc

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

src/bin/psql/describe.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool
217217
PQExpBufferData buf;
218218
PGresult *res;
219219
printQueryOpt myopt = pset.popt;
220-
static const bool translate_columns[] = {false, false, false, false, true, true, false, false, false, false};
220+
static const bool translate_columns[] = {false, false, false, false, true, true, true, false, false, false, false};
221221

222222
if (strlen(functypes) != strspn(functypes, "antwS+"))
223223
{
@@ -2945,7 +2945,8 @@ listConversions(const char *pattern, bool verbose, bool showSystem)
29452945
PQExpBufferData buf;
29462946
PGresult *res;
29472947
printQueryOpt myopt = pset.popt;
2948-
static const bool translate_columns[] = {false, false, false, false, true};
2948+
static const bool translate_columns[] =
2949+
{false, false, false, false, true, false};
29492950

29502951
initPQExpBuffer(&buf);
29512952

@@ -3025,19 +3026,23 @@ listEventTriggers(const char *pattern, bool verbose)
30253026
initPQExpBuffer(&buf);
30263027

30273028
printfPQExpBuffer(&buf,
3028-
"select evtname as \"%s\", "
3029-
"evtevent as \"%s\", "
3030-
"pg_catalog.pg_get_userbyid(e.evtowner) AS \"%s\", "
3031-
"case evtenabled when 'O' then 'enabled' "
3032-
" when 'R' then 'replica' "
3033-
" when 'A' then 'always' "
3034-
" when 'D' then 'disabled' end as \"%s\", "
3035-
"e.evtfoid::regproc as \"%s\", "
3036-
"array_to_string(array(select x "
3037-
" from unnest(evttags) as t(x)), ', ') as \"%s\" ",
3029+
"SELECT evtname as \"%s\", "
3030+
"evtevent as \"%s\", "
3031+
"pg_catalog.pg_get_userbyid(e.evtowner) as \"%s\",\n"
3032+
" case evtenabled when 'O' then '%s'"
3033+
" when 'R' then '%s'"
3034+
" when 'A' then '%s'"
3035+
" when 'D' then '%s' end as \"%s\",\n"
3036+
" e.evtfoid::pg_catalog.regproc as \"%s\", "
3037+
"pg_catalog.array_to_string(array(select x"
3038+
" from pg_catalog.unnest(evttags) as t(x)), ', ') as \"%s\"",
30383039
gettext_noop("Name"),
30393040
gettext_noop("Event"),
30403041
gettext_noop("Owner"),
3042+
gettext_noop("enabled"),
3043+
gettext_noop("replica"),
3044+
gettext_noop("always"),
3045+
gettext_noop("disabled"),
30413046
gettext_noop("Enabled"),
30423047
gettext_noop("Procedure"),
30433048
gettext_noop("Tags"));
@@ -3046,7 +3051,7 @@ listEventTriggers(const char *pattern, bool verbose)
30463051
",\npg_catalog.obj_description(e.oid, 'pg_event_trigger') as \"%s\"",
30473052
gettext_noop("Description"));
30483053
appendPQExpBuffer(&buf,
3049-
"\nFROM pg_event_trigger e ");
3054+
"\nFROM pg_catalog.pg_event_trigger e ");
30503055

30513056
processSQLNamePattern(pset.db, &buf, pattern, false, false,
30523057
NULL, "evtname", NULL, NULL);
@@ -3080,7 +3085,7 @@ listCasts(const char *pattern, bool verbose)
30803085
PQExpBufferData buf;
30813086
PGresult *res;
30823087
printQueryOpt myopt = pset.popt;
3083-
static const bool translate_columns[] = {false, false, false, true};
3088+
static const bool translate_columns[] = {false, false, false, true, false};
30843089

30853090
initPQExpBuffer(&buf);
30863091

0 commit comments

Comments
 (0)