From: Alvaro Herrera Date: Fri, 1 Apr 2016 16:35:48 +0000 (-0300) Subject: Type names should not be quoted X-Git-Tag: REL9_6_BETA1~319 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f402b9950120358d1870aacc10070e121d8a17de;p=postgresql Type names should not be quoted Our actual convention, contrary to what I said in 59a2111b23f, is not to quote type names, as evidenced by unquoted use of format_type_be() result value in error messages. Remove quotes from recently tweaked messages accordingly. Per note from Tom Lane --- diff --git a/src/backend/commands/amcmds.c b/src/backend/commands/amcmds.c index 68ea5f3c58..904dc1cbd1 100644 --- a/src/backend/commands/amcmds.c +++ b/src/backend/commands/amcmds.c @@ -260,7 +260,7 @@ lookup_index_am_handler_func(List *handler_name, char amtype) if (get_func_rettype(handlerOid) != INDEX_AM_HANDLEROID) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("function %s must return type \"%s\"", + errmsg("function %s must return type %s", NameListToString(handler_name), "index_am_handler"))); break; diff --git a/src/backend/commands/conversioncmds.c b/src/backend/commands/conversioncmds.c index a5a63f4575..ad9b8ba156 100644 --- a/src/backend/commands/conversioncmds.c +++ b/src/backend/commands/conversioncmds.c @@ -85,7 +85,7 @@ CreateConversionCommand(CreateConversionStmt *stmt) if (get_func_rettype(funcoid) != VOIDOID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("encoding conversion function %s must return type \"%s\"", + errmsg("encoding conversion function %s must return type %s", NameListToString(func_name), "void"))); /* Check we have EXECUTE rights for the function */ diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c index 3735d44ee9..50c89b827b 100644 --- a/src/backend/commands/event_trigger.c +++ b/src/backend/commands/event_trigger.c @@ -237,7 +237,7 @@ CreateEventTrigger(CreateEventTrigStmt *stmt) if (funcrettype != EVTTRIGGEROID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("function %s must return type \"%s\"", + errmsg("function %s must return type %s", NameListToString(stmt->funcname), "event_trigger"))); /* Insert catalog entries. */ diff --git a/src/backend/commands/foreigncmds.c b/src/backend/commands/foreigncmds.c index 72c819317e..804bab2e1f 100644 --- a/src/backend/commands/foreigncmds.c +++ b/src/backend/commands/foreigncmds.c @@ -486,7 +486,7 @@ 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 \"%s\"", + errmsg("function %s must return type %s", NameListToString((List *) handler->arg), "fdw_handler"))); return handlerOid; diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c index 6edbe85ef5..672f2eb212 100644 --- a/src/backend/commands/operatorcmds.c +++ b/src/backend/commands/operatorcmds.c @@ -275,7 +275,7 @@ ValidateRestrictionEstimator(List *restrictionName) if (get_func_rettype(restrictionOid) != FLOAT8OID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("restriction estimator function %s must return type \"%s\"", + errmsg("restriction estimator function %s must return type %s", NameListToString(restrictionName), "float8"))); /* Require EXECUTE rights for the estimator */ @@ -321,7 +321,7 @@ ValidateJoinEstimator(List *joinName) if (get_func_rettype(joinOid) != FLOAT8OID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("join estimator function %s must return type \"%s\"", + errmsg("join estimator function %s must return type %s", NameListToString(joinName), "float8"))); /* Require EXECUTE rights for the estimator */ diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c index 43581ec310..0515f4d3df 100644 --- a/src/backend/commands/proclang.c +++ b/src/backend/commands/proclang.c @@ -114,7 +114,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) if (funcrettype != LANGUAGE_HANDLEROID) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("function %s must return type \"%s\"", + errmsg("function %s must return type %s", NameListToString(funcname), "language_handler"))); } else @@ -285,7 +285,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) else ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("function %s must return type \"%s\"", + errmsg("function %s must return type %s", NameListToString(stmt->plhandler), "language_handler"))); } diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 5429aab1c1..6f728ff0fc 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -438,7 +438,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, else ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("function %s must return type \"%s\"", + errmsg("function %s must return type %s", NameListToString(stmt->funcname), "trigger"))); } diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c index 3de29b766d..71d4df9c79 100644 --- a/src/backend/commands/typecmds.c +++ b/src/backend/commands/typecmds.c @@ -450,14 +450,14 @@ DefineType(List *names, List *parameters) { /* backwards-compatibility hack */ ereport(WARNING, - (errmsg("changing return type of function %s from \"%s\" to \"%s\"", + (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,14 +467,14 @@ DefineType(List *names, List *parameters) { /* backwards-compatibility hack */ ereport(WARNING, - (errmsg("changing return type of function %s from \"%s\" to \"%s\"", + (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 \"%s\"", + 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,7 +492,7 @@ DefineType(List *names, List *parameters) if (resulttype != BYTEAOID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("type send function %s must return type \"%s\"", + errmsg("type send function %s must return type %s", NameListToString(sendName), "bytea"))); } @@ -1834,7 +1834,7 @@ findTypeTypmodinFunction(List *procname) if (get_func_rettype(procOid) != INT4OID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("typmod_in function %s must return type \"%s\"", + errmsg("typmod_in function %s must return type %s", NameListToString(procname), "integer"))); return procOid; @@ -1861,7 +1861,7 @@ findTypeTypmodoutFunction(List *procname) if (get_func_rettype(procOid) != CSTRINGOID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("typmod_out function %s must return type \"%s\"", + errmsg("typmod_out function %s must return type %s", NameListToString(procname), "cstring"))); return procOid; @@ -1888,7 +1888,7 @@ 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 \"%s\"", + errmsg("type analyze function %s must return type %s", NameListToString(procname), "boolean"))); return procOid; @@ -2007,7 +2007,7 @@ 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 \"%s\"", + errmsg("range subtype diff function %s must return type %s", func_signature_string(procname, 2, NIL, argList), "double precision"))); diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index 8dbe943741..c9edd881ee 100644 --- a/src/backend/parser/parse_clause.c +++ b/src/backend/parser/parse_clause.c @@ -758,7 +758,7 @@ 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 \"%s\"", + errmsg("function %s must return type %s", NameListToString(rts->method), "tsm_handler"), parser_errposition(pstate, rts->location))); diff --git a/src/test/regress/expected/event_trigger.out b/src/test/regress/expected/event_trigger.out index 87254ef8fe..ee68317e5d 100644 --- a/src/test/regress/expected/event_trigger.out +++ b/src/test/regress/expected/event_trigger.out @@ -2,7 +2,7 @@ create event trigger regress_event_trigger on ddl_command_start execute procedure pg_backend_pid(); -ERROR: function pg_backend_pid must return type "event_trigger" +ERROR: function pg_backend_pid must return type event_trigger -- OK create function test_event_trigger() returns event_trigger as $$ BEGIN