Fix set of NLS translation issues
authorMichael Paquier <michael@paquier.xyz>
Tue, 21 Aug 2018 06:17:13 +0000 (15:17 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 21 Aug 2018 06:17:13 +0000 (15:17 +0900)
While monitoring the code, a couple of issues related to string
translation has showed up:
- Some routines for auto-updatable views return an error string, which
sometimes missed the shot.  A comment regarding string translation is
added for each routine to help with future features.
- GSSAPI authentication missed two translations.
- vacuumdb handles non-translated strings.
- GetConfigOptionByNum should translate strings.  This part is not
back-patched as after a minor upgrade this could be surprising for
users.

Reported-by: Kyotaro Horiguchi
Author: Kyotaro Horiguchi
Reviewed-by: Michael Paquier, Tom Lane
Discussion: https://postgr.es/m/20180810.152131.31921918.horiguchi.kyotaro@lab.ntt.co.jp
Backpatch-through: 9.3

src/backend/commands/tablecmds.c
src/backend/commands/view.c
src/backend/libpq/auth.c
src/backend/rewrite/rewriteHandler.c
src/backend/utils/misc/guc.c
src/bin/scripts/vacuumdb.c

index 7cedc28c6b5e72187ddd5a377acbff0f814da0ed..2a12d64aeb7782ea667759d4418b6acdd4170dbc 100644 (file)
@@ -10826,7 +10826,7 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
                ereport(ERROR,
                        (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                         errmsg("WITH CHECK OPTION is supported only on automatically updatable views"),
-                        errhint("%s", view_updatable_error)));
+                        errhint("%s", _(view_updatable_error))));
        }
    }
 
index 7d4511c585b8e3464c0c865316091371823a37f0..ffb71c0ea7c292b474c8c16035289ca5d59b056d 100644 (file)
@@ -502,7 +502,7 @@ DefineView(ViewStmt *stmt, const char *queryString,
            ereport(ERROR,
                    (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                     errmsg("WITH CHECK OPTION is supported only on automatically updatable views"),
-                    errhint("%s", view_updatable_error)));
+                    errhint("%s", _(view_updatable_error))));
    }
 
    /*
index cecd104b4a52320ed330f5baee557aada60b2e82..68bb62d873c69b60c81630f4397a6903d550bc96 100644 (file)
@@ -1037,6 +1037,10 @@ static GSS_DLLIMP gss_OID GSS_C_NT_USER_NAME = &GSS_C_NT_USER_NAME_desc;
 #endif
 
 
+/*
+ * Generate an error for GSSAPI authentication.  The caller should apply
+ * _() to errmsg to make it translatable.
+ */
 static void
 pg_GSS_error(int severity, const char *errmsg, OM_uint32 maj_stat, OM_uint32 min_stat)
 {
@@ -1227,7 +1231,7 @@ pg_GSS_recvauth(Port *port)
        {
            gss_delete_sec_context(&lmin_s, &port->gss->ctx, GSS_C_NO_BUFFER);
            pg_GSS_error(ERROR,
-                        gettext_noop("accepting GSS security context failed"),
+                        _("accepting GSS security context failed"),
                         maj_stat, min_stat);
        }
 
@@ -1253,7 +1257,7 @@ pg_GSS_recvauth(Port *port)
    maj_stat = gss_display_name(&min_stat, port->gss->name, &gbuf, NULL);
    if (maj_stat != GSS_S_COMPLETE)
        pg_GSS_error(ERROR,
-                    gettext_noop("retrieving GSS user name failed"),
+                    _("retrieving GSS user name failed"),
                     maj_stat, min_stat);
 
    /*
@@ -1317,6 +1321,11 @@ pg_GSS_recvauth(Port *port)
  *----------------------------------------------------------------
  */
 #ifdef ENABLE_SSPI
+
+/*
+ * Generate an error for SSPI authentication.  The caller should apply
+ * _() to errmsg to make it translatable.
+ */
 static void
 pg_SSPI_error(int severity, const char *errmsg, SECURITY_STATUS r)
 {
index 3123ee274dbd760f6bcc54a77d2cc7f91d6eb275..d830569641804bbc3472a7342b04d451bf818b35 100644 (file)
@@ -2217,6 +2217,9 @@ view_has_instead_trigger(Relation view, CmdType event)
  * is auto-updatable. Returns NULL (if the column can be updated) or a message
  * string giving the reason that it cannot be.
  *
+ * The returned string has not been translated; if it is shown as an error
+ * message, the caller should apply _() to translate it.
+ *
  * Note that the checks performed here are local to this view. We do not check
  * whether the referenced column of the underlying base relation is updatable.
  */
@@ -2256,6 +2259,9 @@ view_col_is_auto_updatable(RangeTblRef *rtr, TargetEntry *tle)
  * view_query_is_auto_updatable - test whether the specified view definition
  * represents an auto-updatable view. Returns NULL (if the view can be updated)
  * or a message string giving the reason that it cannot be.
+
+ * The returned string has not been translated; if it is shown as an error
+ * message, the caller should apply _() to translate it.
  *
  * If check_cols is true, the view is required to have at least one updatable
  * column (necessary for INSERT/UPDATE). Otherwise the view's columns are not
@@ -2396,6 +2402,9 @@ view_query_is_auto_updatable(Query *viewquery, bool check_cols)
  * required columns can be updated) or a message string giving the reason that
  * they cannot be.
  *
+ * The returned string has not been translated; if it is shown as an error
+ * message, the caller should apply _() to translate it.
+ *
  * This should be used for INSERT/UPDATE to ensure that we don't attempt to
  * assign to any non-updatable columns.
  *
index 2a874dc78d421613fb52e97e11edd604dd9324ab..0625eff2191119656702ed1c4980e829d10de2d5 100644 (file)
@@ -8454,13 +8454,13 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
        values[2] = NULL;
 
    /* group */
-   values[3] = config_group_names[conf->group];
+   values[3] = _(config_group_names[conf->group]);
 
    /* short_desc */
-   values[4] = conf->short_desc;
+   values[4] = _(conf->short_desc);
 
    /* extra_desc */
-   values[5] = conf->long_desc;
+   values[5] = _(conf->long_desc);
 
    /* context */
    values[6] = GucContext_Names[conf->context];
index 6ab77b6206381bbe53f7d8d65e21229ea53f6279..bcea9e556dc53770931887c9161584d1146ca5b3 100644 (file)
@@ -371,7 +371,7 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
    {
        if (stage != ANALYZE_NO_STAGE)
            printf(_("%s: processing database \"%s\": %s\n"),
-                  progname, PQdb(conn), stage_messages[stage]);
+                  progname, PQdb(conn), _(stage_messages[stage]));
        else
            printf(_("%s: vacuuming database \"%s\"\n"),
                   progname, PQdb(conn));