]> granicus.if.org Git - postgresql/commitdiff
Improve internationalization of messages involving type names
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 28 Mar 2016 17:12:00 +0000 (14:12 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 28 Mar 2016 17:24:37 +0000 (14:24 -0300)
Change the slightly different variations of the message
  function FOO must return type BAR
to a single wording, removing the variability in type name so that they
all create a single translation entry; since the type name is not to be
translated, there's no point in it being part of the message anyway.

Also, change them all to use the same quoting convention, namely that
the function name is not to be quoted but the type name is.  (I'm not
quite sure why this is so, but it's the clear majority.)

Some similar messages such as "encoding conversion function FOO must ..."
are also changed.

src/backend/commands/conversioncmds.c
src/backend/commands/event_trigger.c
src/backend/commands/foreigncmds.c
src/backend/commands/operatorcmds.c
src/backend/commands/proclang.c
src/backend/commands/trigger.c
src/backend/commands/typecmds.c
src/backend/parser/parse_clause.c

index 752e2a2fef19fe1ea92ed7151ec198de5b58d45d..a5a63f45754575983cc947977f1b4d69f0de2d1e 100644 (file)
@@ -85,8 +85,8 @@ CreateConversionCommand(CreateConversionStmt *stmt)
        if (get_func_rettype(funcoid) != VOIDOID)
                ereport(ERROR,
                                (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-                 errmsg("encoding conversion function %s must return type \"void\"",
-                                NameListToString(func_name))));
+                 errmsg("encoding conversion function %s must return type \"%s\"",
+                                NameListToString(func_name), "void")));
 
        /* Check we have EXECUTE rights for the function */
        aclresult = pg_proc_aclcheck(funcoid, GetUserId(), ACL_EXECUTE);
index 3f52ad836b4a2be1d95047f0949607d8cbbb283d..3735d44ee9d0b89f35ca8e8fb00b1a8dbbaa6362 100644 (file)
@@ -237,8 +237,8 @@ CreateEventTrigger(CreateEventTrigStmt *stmt)
        if (funcrettype != EVTTRIGGEROID)
                ereport(ERROR,
                                (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-                                errmsg("function \"%s\" must return type \"event_trigger\"",
-                                               NameListToString(stmt->funcname))));
+                                errmsg("function %s must return type \"%s\"",
+                                               NameListToString(stmt->funcname), "event_trigger")));
 
        /* Insert catalog entries. */
        return insert_event_trigger_tuple(stmt->trigname, stmt->eventname,
index 7036eb1246922baaea34f75064fdc3d53bbf4eeb..72c819317e0081a4f52e1d6a2bf75af76be30bbd 100644 (file)
@@ -486,8 +486,8 @@ lookup_fdw_handler_func(DefElem *handler)
        if (get_func_rettype(handlerOid) != FDW_HANDLEROID)
                ereport(ERROR,
                                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
-                                errmsg("function %s must return type \"fdw_handler\"",
-                                               NameListToString((List *) handler->arg))));
+                                errmsg("function %s must return type \"%s\"",
+                                               NameListToString((List *) handler->arg), "fdw_handler")));
 
        return handlerOid;
 }
index d32ba2d61f626299bedb73bcb2fac62b3f3baf01..6edbe85ef5328ad10bcf8afc9c37e6bee5399ad4 100644 (file)
@@ -275,8 +275,8 @@ ValidateRestrictionEstimator(List *restrictionName)
        if (get_func_rettype(restrictionOid) != FLOAT8OID)
                ereport(ERROR,
                                (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-                                errmsg("restriction estimator function %s must return type \"float8\"",
-                                               NameListToString(restrictionName))));
+                                errmsg("restriction estimator function %s must return type \"%s\"",
+                                               NameListToString(restrictionName), "float8")));
 
        /* Require EXECUTE rights for the estimator */
        aclresult = pg_proc_aclcheck(restrictionOid, GetUserId(), ACL_EXECUTE);
@@ -321,8 +321,8 @@ ValidateJoinEstimator(List *joinName)
        if (get_func_rettype(joinOid) != FLOAT8OID)
                ereport(ERROR,
                                (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-                        errmsg("join estimator function %s must return type \"float8\"",
-                                       NameListToString(joinName))));
+                        errmsg("join estimator function %s must return type \"%s\"",
+                                       NameListToString(joinName), "float8")));
 
        /* Require EXECUTE rights for the estimator */
        aclresult = pg_proc_aclcheck(joinOid, GetUserId(), ACL_EXECUTE);
index 5696dc214d1b9b2b6afdc40b02ca04fc73f122f9..43581ec310245b867aaf84090894cb2c997b9f39 100644 (file)
@@ -114,8 +114,8 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
                        if (funcrettype != LANGUAGE_HANDLEROID)
                                ereport(ERROR,
                                                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
-                                 errmsg("function %s must return type \"language_handler\"",
-                                                NameListToString(funcname))));
+                                 errmsg("function %s must return type \"%s\"",
+                                                NameListToString(funcname), "language_handler")));
                }
                else
                {
@@ -285,8 +285,8 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
                        else
                                ereport(ERROR,
                                                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
-                                 errmsg("function %s must return type \"language_handler\"",
-                                                NameListToString(stmt->plhandler))));
+                                 errmsg("function %s must return type \"%s\"",
+                                                NameListToString(stmt->plhandler), "language_handler")));
                }
 
                /* validate the inline function */
index 28260e86600adae325727ccab319dc0a97cb0fbd..5429aab1c152bf7f53d4413cce89d9b4950f90f8 100644 (file)
@@ -438,8 +438,8 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
                else
                        ereport(ERROR,
                                        (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-                                        errmsg("function %s must return type \"trigger\"",
-                                                       NameListToString(stmt->funcname))));
+                                        errmsg("function %s must return type \"%s\"",
+                                                       NameListToString(stmt->funcname), "trigger")));
        }
 
        /*
index 227d382a38c2847e38fc55fdb4315e6c8416cbad..3de29b766dea32293f1fdded61f327940381eab5 100644 (file)
@@ -450,14 +450,14 @@ DefineType(List *names, List *parameters)
                {
                        /* backwards-compatibility hack */
                        ereport(WARNING,
-                                       (errmsg("changing return type of function %s from \"opaque\" to %s",
-                                                       NameListToString(inputName), typeName)));
+                                       (errmsg("changing return type of function %s from \"%s\" to \"%s\"",
+                                                       NameListToString(inputName), "opaque", typeName)));
                        SetFunctionReturnType(inputOid, typoid);
                }
                else
                        ereport(ERROR,
                                        (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-                                        errmsg("type input function %s must return type %s",
+                                        errmsg("type input function %s must return type \"%s\"",
                                                        NameListToString(inputName), typeName)));
        }
        resulttype = get_func_rettype(outputOid);
@@ -467,15 +467,15 @@ DefineType(List *names, List *parameters)
                {
                        /* backwards-compatibility hack */
                        ereport(WARNING,
-                                       (errmsg("changing return type of function %s from \"opaque\" to \"cstring\"",
-                                                       NameListToString(outputName))));
+                                       (errmsg("changing return type of function %s from \"%s\" to \"%s\"",
+                                                       NameListToString(outputName), "opaque", "cstring")));
                        SetFunctionReturnType(outputOid, CSTRINGOID);
                }
                else
                        ereport(ERROR,
                                        (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-                          errmsg("type output function %s must return type \"cstring\"",
-                                         NameListToString(outputName))));
+                          errmsg("type output function %s must return type \"%s\"",
+                                         NameListToString(outputName), "cstring")));
        }
        if (receiveOid)
        {
@@ -483,7 +483,7 @@ DefineType(List *names, List *parameters)
                if (resulttype != typoid)
                        ereport(ERROR,
                                        (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-                                        errmsg("type receive function %s must return type %s",
+                                        errmsg("type receive function %s must return type \"%s\"",
                                                        NameListToString(receiveName), typeName)));
        }
        if (sendOid)
@@ -492,8 +492,8 @@ DefineType(List *names, List *parameters)
                if (resulttype != BYTEAOID)
                        ereport(ERROR,
                                        (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-                                  errmsg("type send function %s must return type \"bytea\"",
-                                                 NameListToString(sendName))));
+                                  errmsg("type send function %s must return type \"%s\"",
+                                                 NameListToString(sendName), "bytea")));
        }
 
        /*
@@ -1834,8 +1834,8 @@ findTypeTypmodinFunction(List *procname)
        if (get_func_rettype(procOid) != INT4OID)
                ereport(ERROR,
                                (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-                                errmsg("typmod_in function %s must return type \"integer\"",
-                                               NameListToString(procname))));
+                                errmsg("typmod_in function %s must return type \"%s\"",
+                                               NameListToString(procname), "integer")));
 
        return procOid;
 }
@@ -1861,8 +1861,8 @@ findTypeTypmodoutFunction(List *procname)
        if (get_func_rettype(procOid) != CSTRINGOID)
                ereport(ERROR,
                                (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-                                errmsg("typmod_out function %s must return type \"cstring\"",
-                                               NameListToString(procname))));
+                                errmsg("typmod_out function %s must return type \"%s\"",
+                                               NameListToString(procname), "cstring")));
 
        return procOid;
 }
@@ -1888,8 +1888,8 @@ findTypeAnalyzeFunction(List *procname, Oid typeOid)
        if (get_func_rettype(procOid) != BOOLOID)
                ereport(ERROR,
                                (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-                         errmsg("type analyze function %s must return type \"boolean\"",
-                                        NameListToString(procname))));
+                         errmsg("type analyze function %s must return type \"%s\"",
+                                        NameListToString(procname), "boolean")));
 
        return procOid;
 }
@@ -2007,8 +2007,9 @@ findRangeSubtypeDiffFunction(List *procname, Oid subtype)
        if (get_func_rettype(procOid) != FLOAT8OID)
                ereport(ERROR,
                                (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-                                errmsg("range subtype diff function %s must return type double precision",
-                                               func_signature_string(procname, 2, NIL, argList))));
+                                errmsg("range subtype diff function %s must return type \"%s\"",
+                                               func_signature_string(procname, 2, NIL, argList),
+                                               "double precision")));
 
        if (func_volatile(procOid) != PROVOLATILE_IMMUTABLE)
                ereport(ERROR,
index 4d9febee642a6db3905a121d06cbb7ffb7bba16e..8dbe94374198dafdafd46867b0f0ddb2cef21969 100644 (file)
@@ -758,8 +758,8 @@ transformRangeTableSample(ParseState *pstate, RangeTableSample *rts)
        if (get_func_rettype(handlerOid) != TSM_HANDLEROID)
                ereport(ERROR,
                                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
-                                errmsg("function %s must return type \"tsm_handler\"",
-                                               NameListToString(rts->method)),
+                                errmsg("function %s must return type \"%s\"",
+                                               NameListToString(rts->method), "tsm_handler"),
                                 parser_errposition(pstate, rts->location)));
 
        /* OK, run the handler to get TsmRoutine, for argument type info */