Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit341f0bc

Browse files
committed
Fix translatability markings in psql, and add defenses against future bugs.
Several previous commits have added columns to various \d queries withoutupdating their translate_columns[] arrays, leading to potentially incorrecttranslations in NLS-enabled builds. Offenders include commit8936867(added prosecdef to \df+),c9ac00e (added description to \dc+) and3b17efd (added description to \dC+). Fix those cases back to 9.3 or9.2 as appropriate.Since this is evidently more easily missed than one would like, in HEADalso add an Assert that the supplied array is long enough. This requiresan API change for printQuery(), so it seems inappropriate for backbranches, 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 emittedSQL for \dy (event triggers): lack of translatability due to failing topass words-to-be-translated through gettext_noop(), inadequate schemaqualification, and sloppy formatting resulting in unnecessarily ugly-E output.Peter Eisentraut and Tom Lane, per bug #8702 from Sergey Burladyan
1 parent948a3df commit341f0bc

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
PQExpBufferDatabuf;
218218
PGresult*res;
219219
printQueryOptmyopt=pset.popt;
220-
staticconstbooltranslate_columns[]= {false, false, false, false, true, true, false, false, false, false};
220+
staticconstbooltranslate_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
PQExpBufferDatabuf;
29462946
PGresult*res;
29472947
printQueryOptmyopt=pset.popt;
2948-
staticconstbooltranslate_columns[]= {false, false, false, false, true};
2948+
staticconstbooltranslate_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+
"frompg_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+
"\nFROMpg_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
PQExpBufferDatabuf;
30813086
PGresult*res;
30823087
printQueryOptmyopt=pset.popt;
3083-
staticconstbooltranslate_columns[]= {false, false, false, true};
3088+
staticconstbooltranslate_columns[]= {false, false, false, true, false};
30843089

30853090
initPQExpBuffer(&buf);
30863091

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp