]> granicus.if.org Git - postgresql/commitdiff
Fix translatability markings in psql, and add defenses against future bugs.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 4 Jan 2014 21:05:20 +0000 (16:05 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 4 Jan 2014 21:05:20 +0000 (16:05 -0500)
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 893686762
(added prosecdef to \df+), c9ac00e6e (added description to \dc+) and
3b17efdfd (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

src/bin/psql/describe.c

index 9b6b9c2cd0a61485cfe18c708da45656ae310187..b1d35fe75fbf35c16334d6ee6a08a9210cde9ead 100644 (file)
@@ -217,7 +217,7 @@ describeFunctions(const char *functypes, const char *pattern, bool verbose, bool
        PQExpBufferData buf;
        PGresult   *res;
        printQueryOpt myopt = pset.popt;
-       static const bool translate_columns[] = {false, false, false, false, true, true, false, false, false, false};
+       static const bool translate_columns[] = {false, false, false, false, true, true, true, false, false, false, false};
 
        if (strlen(functypes) != strspn(functypes, "antwS+"))
        {
@@ -2945,7 +2945,8 @@ listConversions(const char *pattern, bool verbose, bool showSystem)
        PQExpBufferData buf;
        PGresult   *res;
        printQueryOpt myopt = pset.popt;
-       static const bool translate_columns[] = {false, false, false, false, true};
+       static const bool translate_columns[] =
+               {false, false, false, false, true, false};
 
        initPQExpBuffer(&buf);
 
@@ -3025,19 +3026,23 @@ listEventTriggers(const char *pattern, bool verbose)
        initPQExpBuffer(&buf);
 
        printfPQExpBuffer(&buf,
-                                         "select evtname as \"%s\", "
-                                         "evtevent as  \"%s\", "
-                                         "pg_catalog.pg_get_userbyid(e.evtowner) AS \"%s\", "
-                                         "case evtenabled when 'O' then 'enabled' "
-                                         "  when 'R' then 'replica' "
-                                         "  when 'A' then 'always' "
-                                         "  when 'D' then 'disabled' end as  \"%s\", "
-                                         "e.evtfoid::regproc as \"%s\", "
-                                         "array_to_string(array(select x "
-                                       "      from unnest(evttags) as t(x)), ', ') as  \"%s\" ",
+                                         "SELECT evtname as \"%s\", "
+                                         "evtevent as \"%s\", "
+                                         "pg_catalog.pg_get_userbyid(e.evtowner) as \"%s\",\n"
+                                         " case evtenabled when 'O' then '%s'"
+                                         "  when 'R' then '%s'"
+                                         "  when 'A' then '%s'"
+                                         "  when 'D' then '%s' end as \"%s\",\n"
+                                         " e.evtfoid::pg_catalog.regproc as \"%s\", "
+                                         "pg_catalog.array_to_string(array(select x"
+                                         " from pg_catalog.unnest(evttags) as t(x)), ', ') as \"%s\"",
                                          gettext_noop("Name"),
                                          gettext_noop("Event"),
                                          gettext_noop("Owner"),
+                                         gettext_noop("enabled"),
+                                         gettext_noop("replica"),
+                                         gettext_noop("always"),
+                                         gettext_noop("disabled"),
                                          gettext_noop("Enabled"),
                                          gettext_noop("Procedure"),
                                          gettext_noop("Tags"));
@@ -3046,7 +3051,7 @@ listEventTriggers(const char *pattern, bool verbose)
                ",\npg_catalog.obj_description(e.oid, 'pg_event_trigger') as \"%s\"",
                                                  gettext_noop("Description"));
        appendPQExpBuffer(&buf,
-                                         "\nFROM pg_event_trigger e ");
+                                         "\nFROM pg_catalog.pg_event_trigger e ");
 
        processSQLNamePattern(pset.db, &buf, pattern, false, false,
                                                  NULL, "evtname", NULL, NULL);
@@ -3080,7 +3085,7 @@ listCasts(const char *pattern, bool verbose)
        PQExpBufferData buf;
        PGresult   *res;
        printQueryOpt myopt = pset.popt;
-       static const bool translate_columns[] = {false, false, false, true};
+       static const bool translate_columns[] = {false, false, false, true, false};
 
        initPQExpBuffer(&buf);