From 9a34123bc315e55b33038464422ef1cd2b67dab2 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera <alvherre@alvh.no-ip.org> Date: Wed, 18 Jan 2017 16:08:20 -0300 Subject: [PATCH] Make messages mentioning type names more uniform This avoids additional translatable strings for each distinct type, as well as making our quoting style around type names more consistent (namely, that we don't quote type names). This continues what started as f402b9950120. Discussion: https://postgr.es/m/20160401170642.GA57509@alvherre.pgsql --- .../expected/create_transform.out | 4 +- src/backend/catalog/aclchk.c | 3 +- src/backend/catalog/dependency.c | 3 +- src/backend/catalog/heap.c | 2 +- src/backend/commands/functioncmds.c | 12 +++-- src/backend/commands/proclang.c | 5 +- src/backend/commands/trigger.c | 5 +- src/backend/parser/parse_coerce.c | 35 ++++++++------ src/backend/utils/adt/bool.c | 3 +- src/backend/utils/adt/cash.c | 20 ++++---- src/backend/utils/adt/encode.c | 4 +- src/backend/utils/adt/float.c | 12 ++--- src/backend/utils/adt/int8.c | 12 ++--- src/backend/utils/adt/json.c | 46 ++++++++++--------- src/backend/utils/adt/mac.c | 3 +- src/backend/utils/adt/nabstime.c | 4 +- src/backend/utils/adt/numeric.c | 27 +++++------ src/backend/utils/adt/numutils.c | 18 ++++---- src/backend/utils/adt/oid.c | 22 +++++---- src/backend/utils/adt/pg_lsn.c | 6 ++- src/backend/utils/adt/tid.c | 12 ++--- src/backend/utils/adt/txid.c | 4 +- src/backend/utils/adt/uuid.c | 4 +- src/backend/utils/adt/varlena.c | 4 +- src/test/regress/expected/rangefuncs.out | 2 +- src/test/regress/expected/uuid.out | 12 ++--- 26 files changed, 155 insertions(+), 129 deletions(-) diff --git a/contrib/hstore_plperl/expected/create_transform.out b/contrib/hstore_plperl/expected/create_transform.out index c588d33ab84..02dc62af0da 100644 --- a/contrib/hstore_plperl/expected/create_transform.out +++ b/contrib/hstore_plperl/expected/create_transform.out @@ -18,9 +18,9 @@ ERROR: type "foo" does not exist CREATE TRANSFORM FOR hstore LANGUAGE foo (FROM SQL WITH FUNCTION hstore_to_plperl(internal), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- fail ERROR: language "foo" does not exist CREATE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_out(hstore), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- fail -ERROR: return data type of FROM SQL function must be "internal" +ERROR: return data type of FROM SQL function must be internal CREATE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION internal_in(cstring), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- fail -ERROR: first argument of transform function must be type "internal" +ERROR: first argument of transform function must be type internal CREATE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_to_plperl(internal), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- ok CREATE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_to_plperl(internal), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- fail ERROR: transform for type hstore language "plperl" already exists diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c index 7803d0d3684..640632784c1 100644 --- a/src/backend/catalog/aclchk.c +++ b/src/backend/catalog/aclchk.c @@ -1819,7 +1819,8 @@ ExecGrant_Relation(InternalGrant *istmt) */ ereport(ERROR, (errcode(ERRCODE_INVALID_GRANT_OPERATION), - errmsg("invalid privilege type USAGE for table"))); + errmsg("invalid privilege type %s for table", + "USAGE"))); } } } diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c index d82b8baef22..359719e4504 100644 --- a/src/backend/catalog/dependency.c +++ b/src/backend/catalog/dependency.c @@ -1598,7 +1598,8 @@ find_expr_references_walker(Node *node, case REGROLEOID: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("constant of the type \"regrole\" cannot be used here"))); + errmsg("constant of the type %s cannot be used here", + "regrole"))); break; } } diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index 72aa0dd6c84..bfc54a8b9f2 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -498,7 +498,7 @@ CheckAttributeType(const char *attname, */ ereport(WARNING, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), - errmsg("column \"%s\" has type \"unknown\"", attname), + errmsg("column \"%s\" has type %s", attname, "unknown"), errdetail("Proceeding with relation creation anyway."))); } else if (att_typtype == TYPTYPE_PSEUDO) diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index 015a5fb67df..22aecb24f92 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -1482,11 +1482,13 @@ CreateCast(CreateCastStmt *stmt) if (nargs > 1 && procstruct->proargtypes.values[1] != INT4OID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("second argument of cast function must be type integer"))); + errmsg("second argument of cast function must be type %s", + "integer"))); if (nargs > 2 && procstruct->proargtypes.values[2] != BOOLOID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("third argument of cast function must be type boolean"))); + errmsg("third argument of cast function must be type %s", + "boolean"))); if (!IsBinaryCoercible(procstruct->prorettype, targettypeid)) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), @@ -1776,7 +1778,8 @@ check_transform_function(Form_pg_proc procstruct) if (procstruct->proargtypes.values[0] != INTERNALOID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("first argument of transform function must be type \"internal\""))); + errmsg("first argument of transform function must be type %s", + "internal"))); } @@ -1859,7 +1862,8 @@ CreateTransform(CreateTransformStmt *stmt) if (procstruct->prorettype != INTERNALOID) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("return data type of FROM SQL function must be \"internal\""))); + errmsg("return data type of FROM SQL function must be %s", + "internal"))); check_transform_function(procstruct); ReleaseSysCache(tuple); } diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c index c5ce5bdd117..b684f413c06 100644 --- a/src/backend/commands/proclang.c +++ b/src/backend/commands/proclang.c @@ -278,8 +278,9 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) { ereport(WARNING, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("changing return type of function %s from \"opaque\" to \"language_handler\"", - NameListToString(stmt->plhandler)))); + errmsg("changing return type of function %s from %s to %s", + NameListToString(stmt->plhandler), + "opaque", "language_handler"))); SetFunctionReturnType(handlerOid, LANGUAGE_HANDLEROID); } else diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index b404d1ea16f..3fc3a21cee8 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -522,8 +522,9 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, if (funcrettype == OPAQUEOID) { ereport(WARNING, - (errmsg("changing return type of function %s from \"opaque\" to \"trigger\"", - NameListToString(stmt->funcname)))); + (errmsg("changing return type of function %s from %s to %s", + NameListToString(stmt->funcname), + "opaque", "trigger"))); SetFunctionReturnType(funcoid, TRIGGEROID); } else diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c index 29278cf4fa5..2a2ac321573 100644 --- a/src/backend/parser/parse_coerce.c +++ b/src/backend/parser/parse_coerce.c @@ -1077,8 +1077,9 @@ coerce_to_boolean(ParseState *pstate, Node *node, ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), /* translator: first %s is name of a SQL construct, eg WHERE */ - errmsg("argument of %s must be type boolean, not type %s", - constructName, format_type_be(inputTypeId)), + errmsg("argument of %s must be type %s, not type %s", + constructName, "boolean", + format_type_be(inputTypeId)), parser_errposition(pstate, exprLocation(node)))); node = newnode; } @@ -1695,8 +1696,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, if (!OidIsValid(array_typelem)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("argument declared \"anyarray\" is not an array but type %s", - format_type_be(array_typeid)))); + errmsg("argument declared %s is not an array but type %s", + "anyarray", format_type_be(array_typeid)))); } if (!OidIsValid(elem_typeid)) @@ -1711,7 +1712,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, /* otherwise, they better match */ ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("argument declared \"anyarray\" is not consistent with argument declared \"anyelement\""), + errmsg("argument declared %s is not consistent with argument declared %s", + "anyarray", "anyelement"), errdetail("%s versus %s", format_type_be(array_typeid), format_type_be(elem_typeid)))); @@ -1732,8 +1734,9 @@ enforce_generic_type_consistency(Oid *actual_arg_types, if (!OidIsValid(range_typelem)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("argument declared \"anyrange\" is not a range type but type %s", - format_type_be(range_typeid)))); + errmsg("argument declared %s is not a range type but type %s", + "anyrange", + format_type_be(range_typeid)))); } if (!OidIsValid(elem_typeid)) @@ -1748,7 +1751,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, /* otherwise, they better match */ ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("argument declared \"anyrange\" is not consistent with argument declared \"anyelement\""), + errmsg("argument declared %s is not consistent with argument declared %s", + "anyrange", "anyelement"), errdetail("%s versus %s", format_type_be(range_typeid), format_type_be(elem_typeid)))); @@ -1768,7 +1772,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, /* Only way to get here is if all the generic args are UNKNOWN */ ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("could not determine polymorphic type because input has type \"unknown\""))); + errmsg("could not determine polymorphic type because input has type %s", + "unknown"))); } } @@ -1906,8 +1911,8 @@ resolve_generic_type(Oid declared_type, if (!OidIsValid(array_typelem)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("argument declared \"anyarray\" is not an array but type %s", - format_type_be(context_base_type)))); + errmsg("argument declared %s is not an array but type %s", + "anyarray", format_type_be(context_base_type)))); return context_base_type; } else if (context_declared_type == ANYELEMENTOID || @@ -1940,8 +1945,8 @@ resolve_generic_type(Oid declared_type, if (!OidIsValid(array_typelem)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("argument declared \"anyarray\" is not an array but type %s", - format_type_be(context_base_type)))); + errmsg("argument declared %s is not an array but type %s", + "anyarray", format_type_be(context_base_type)))); return array_typelem; } else if (context_declared_type == ANYRANGEOID) @@ -1953,8 +1958,8 @@ resolve_generic_type(Oid declared_type, if (!OidIsValid(range_typelem)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("argument declared \"anyrange\" is not a range type but type %s", - format_type_be(context_base_type)))); + errmsg("argument declared %s is not a range type but type %s", + "anyrange", format_type_be(context_base_type)))); return range_typelem; } else if (context_declared_type == ANYELEMENTOID || diff --git a/src/backend/utils/adt/bool.c b/src/backend/utils/adt/bool.c index 5dfb30cc8e7..6c87e211407 100644 --- a/src/backend/utils/adt/bool.c +++ b/src/backend/utils/adt/bool.c @@ -150,7 +150,8 @@ boolin(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type boolean: \"%s\"", in_str))); + errmsg("invalid input syntax for type %s: \"%s\"", + "boolean", in_str))); /* not reached */ PG_RETURN_BOOL(false); diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index a146b0a0bc8..ac8f74fee63 100644 --- a/src/backend/utils/adt/cash.c +++ b/src/backend/utils/adt/cash.c @@ -209,8 +209,8 @@ cash_in(PG_FUNCTION_ARGS) if (newvalue / 10 != value) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("value \"%s\" is out of range for type money", - str))); + errmsg("value \"%s\" is out of range for type %s", + str, "money"))); value = newvalue; @@ -236,8 +236,8 @@ cash_in(PG_FUNCTION_ARGS) if (value > 0) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("value \"%s\" is out of range for type money", - str))); + errmsg("value \"%s\" is out of range for type %s", + str, "money"))); /* adjust for less than required decimal places */ for (; dec < fpoint; dec++) @@ -247,8 +247,8 @@ cash_in(PG_FUNCTION_ARGS) if (newvalue / 10 != value) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("value \"%s\" is out of range for type money", - str))); + errmsg("value \"%s\" is out of range for type %s", + str, "money"))); value = newvalue; } @@ -276,8 +276,8 @@ cash_in(PG_FUNCTION_ARGS) else ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type money: \"%s\"", - str))); + errmsg("invalid input syntax for type %s: \"%s\"", + "money", str))); } /* If the value is supposed to be positive, flip the sign, but check for @@ -288,8 +288,8 @@ cash_in(PG_FUNCTION_ARGS) if (result < 0) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("value \"%s\" is out of range for type money", - str))); + errmsg("value \"%s\" is out of range for type %s", + str, "money"))); } else result = value; diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c index 4d8f1a81a90..027f28eb623 100644 --- a/src/backend/utils/adt/encode.c +++ b/src/backend/utils/adt/encode.c @@ -439,7 +439,7 @@ esc_decode(const char *src, unsigned srclen, char *dst) */ ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type bytea"))); + errmsg("invalid input syntax for type %s", "bytea"))); } len++; @@ -504,7 +504,7 @@ esc_dec_len(const char *src, unsigned srclen) */ ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type bytea"))); + errmsg("invalid input syntax for type %s", "bytea"))); } len++; diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index 86b46ded88d..894f026a41b 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -241,8 +241,8 @@ float4in(PG_FUNCTION_ARGS) if (*num == '\0') ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type real: \"%s\"", - orig_num))); + errmsg("invalid input syntax for type %s: \"%s\"", + "real", orig_num))); errno = 0; val = strtod(num, &endptr); @@ -315,8 +315,8 @@ float4in(PG_FUNCTION_ARGS) else ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type real: \"%s\"", - orig_num))); + errmsg("invalid input syntax for type %s: \"%s\"", + "real", orig_num))); } #ifdef HAVE_BUGGY_SOLARIS_STRTOD else @@ -339,8 +339,8 @@ float4in(PG_FUNCTION_ARGS) if (*endptr != '\0') ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type real: \"%s\"", - orig_num))); + errmsg("invalid input syntax for type %s: \"%s\"", + "real", orig_num))); /* * if we get here, we have a legal double, still need to check to see if diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c index b7aa0ad8832..0c6a412f2aa 100644 --- a/src/backend/utils/adt/int8.c +++ b/src/backend/utils/adt/int8.c @@ -95,8 +95,8 @@ scanint8(const char *str, bool errorOK, int64 *result) else ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for integer: \"%s\"", - str))); + errmsg("invalid input syntax for %s: \"%s\"", + "integer", str))); } /* process digits */ @@ -111,8 +111,8 @@ scanint8(const char *str, bool errorOK, int64 *result) else ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("value \"%s\" is out of range for type bigint", - str))); + errmsg("value \"%s\" is out of range for type %s", + str, "bigint"))); } tmp = newtmp; } @@ -130,8 +130,8 @@ gotdigits: else ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for integer: \"%s\"", - str))); + errmsg("invalid input syntax for %s: \"%s\"", + "integer", str))); } *result = (sign < 0) ? -tmp : tmp; diff --git a/src/backend/utils/adt/json.c b/src/backend/utils/adt/json.c index 190ac3651ea..628e9de6166 100644 --- a/src/backend/utils/adt/json.c +++ b/src/backend/utils/adt/json.c @@ -782,7 +782,7 @@ json_lex_string(JsonLexContext *lex) lex->token_terminator = s; ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("Character with value 0x%02x must be escaped.", (unsigned char) *s), report_json_context(lex))); @@ -822,7 +822,8 @@ json_lex_string(JsonLexContext *lex) lex->token_terminator = s + pg_mblen(s); ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", + "json"), errdetail("\"\\u\" must be followed by four hexadecimal digits."), report_json_context(lex))); } @@ -837,7 +838,8 @@ json_lex_string(JsonLexContext *lex) if (hi_surrogate != -1) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", + "json"), errdetail("Unicode high surrogate must not follow a high surrogate."), report_json_context(lex))); hi_surrogate = (ch & 0x3ff) << 10; @@ -848,7 +850,7 @@ json_lex_string(JsonLexContext *lex) if (hi_surrogate == -1) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("Unicode low surrogate must follow a high surrogate."), report_json_context(lex))); ch = 0x10000 + hi_surrogate + (ch & 0x3ff); @@ -858,7 +860,7 @@ json_lex_string(JsonLexContext *lex) if (hi_surrogate != -1) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("Unicode low surrogate must follow a high surrogate."), report_json_context(lex))); @@ -909,7 +911,8 @@ json_lex_string(JsonLexContext *lex) if (hi_surrogate != -1) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", + "json"), errdetail("Unicode low surrogate must follow a high surrogate."), report_json_context(lex))); @@ -940,7 +943,8 @@ json_lex_string(JsonLexContext *lex) lex->token_terminator = s + pg_mblen(s); ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", + "json"), errdetail("Escape sequence \"\\%s\" is invalid.", extract_mb_char(s)), report_json_context(lex))); @@ -958,7 +962,7 @@ json_lex_string(JsonLexContext *lex) lex->token_terminator = s + pg_mblen(s); ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("Escape sequence \"\\%s\" is invalid.", extract_mb_char(s)), report_json_context(lex))); @@ -970,7 +974,7 @@ json_lex_string(JsonLexContext *lex) if (hi_surrogate != -1) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("Unicode low surrogate must follow a high surrogate."), report_json_context(lex))); @@ -982,7 +986,7 @@ json_lex_string(JsonLexContext *lex) if (hi_surrogate != -1) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("Unicode low surrogate must follow a high surrogate."), report_json_context(lex))); @@ -1127,7 +1131,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) if (lex->token_start == NULL || lex->token_type == JSON_TOKEN_END) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("The input string ended unexpectedly."), report_json_context(lex))); @@ -1141,7 +1145,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) if (ctx == JSON_PARSE_END) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("Expected end of input, but found \"%s\".", token), report_json_context(lex))); @@ -1152,7 +1156,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) case JSON_PARSE_VALUE: ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("Expected JSON value, but found \"%s\".", token), report_json_context(lex))); @@ -1160,7 +1164,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) case JSON_PARSE_STRING: ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("Expected string, but found \"%s\".", token), report_json_context(lex))); @@ -1168,7 +1172,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) case JSON_PARSE_ARRAY_START: ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("Expected array element or \"]\", but found \"%s\".", token), report_json_context(lex))); @@ -1176,7 +1180,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) case JSON_PARSE_ARRAY_NEXT: ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("Expected \",\" or \"]\", but found \"%s\".", token), report_json_context(lex))); @@ -1184,7 +1188,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) case JSON_PARSE_OBJECT_START: ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("Expected string or \"}\", but found \"%s\".", token), report_json_context(lex))); @@ -1192,7 +1196,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) case JSON_PARSE_OBJECT_LABEL: ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("Expected \":\", but found \"%s\".", token), report_json_context(lex))); @@ -1200,7 +1204,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) case JSON_PARSE_OBJECT_NEXT: ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("Expected \",\" or \"}\", but found \"%s\".", token), report_json_context(lex))); @@ -1208,7 +1212,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) case JSON_PARSE_OBJECT_COMMA: ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("Expected string, but found \"%s\".", token), report_json_context(lex))); @@ -1238,7 +1242,7 @@ report_invalid_token(JsonLexContext *lex) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type json"), + errmsg("invalid input syntax for type %s", "json"), errdetail("Token \"%s\" is invalid.", token), report_json_context(lex))); } diff --git a/src/backend/utils/adt/mac.c b/src/backend/utils/adt/mac.c index 509315ae0e4..2270b223eab 100644 --- a/src/backend/utils/adt/mac.c +++ b/src/backend/utils/adt/mac.c @@ -65,7 +65,8 @@ macaddr_in(PG_FUNCTION_ARGS) if (count != 6) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type macaddr: \"%s\"", str))); + errmsg("invalid input syntax for type %s: \"%s\"", "macaddr", + str))); if ((a < 0) || (a > 255) || (b < 0) || (b > 255) || (c < 0) || (c > 255) || (d < 0) || (d > 255) || diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index 0364afcc454..c9d0b0d7fbc 100644 --- a/src/backend/utils/adt/nabstime.c +++ b/src/backend/utils/adt/nabstime.c @@ -1547,8 +1547,8 @@ parsetinterval(char *i_string, bogus: ereport(ERROR, (errcode(ERRCODE_INVALID_DATETIME_FORMAT), - errmsg("invalid input syntax for type tinterval: \"%s\"", - i_string))); + errmsg("invalid input syntax for type %s: \"%s\"", + "tinterval", i_string))); *i_start = *i_end = INVALID_ABSTIME; /* keep compiler quiet */ } diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 5cc8de5af21..fa4e1b1e628 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -590,8 +590,8 @@ numeric_in(PG_FUNCTION_ARGS) if (!isspace((unsigned char) *cp)) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type numeric: \"%s\"", - str))); + errmsg("invalid input syntax for type %s: \"%s\"", + "numeric", str))); cp++; } } @@ -617,8 +617,8 @@ numeric_in(PG_FUNCTION_ARGS) if (!isspace((unsigned char) *cp)) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type numeric: \"%s\"", - str))); + errmsg("invalid input syntax for type %s: \"%s\"", + "numeric", str))); cp++; } @@ -5482,7 +5482,8 @@ set_var_from_str(const char *str, const char *cp, NumericVar *dest) if (!isdigit((unsigned char) *cp)) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type numeric: \"%s\"", str))); + errmsg("invalid input syntax for type %s: \"%s\"", + "numeric", str))); decdigits = (unsigned char *) palloc(strlen(cp) + DEC_DIGITS * 2); @@ -5505,8 +5506,8 @@ set_var_from_str(const char *str, const char *cp, NumericVar *dest) if (have_dp) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type numeric: \"%s\"", - str))); + errmsg("invalid input syntax for type %s: \"%s\"", + "numeric", str))); have_dp = TRUE; cp++; } @@ -5529,8 +5530,8 @@ set_var_from_str(const char *str, const char *cp, NumericVar *dest) if (endptr == cp) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type numeric: \"%s\"", - str))); + errmsg("invalid input syntax for type %s: \"%s\"", + "numeric", str))); cp = endptr; /* @@ -6331,8 +6332,8 @@ numeric_to_double_no_overflow(Numeric num) /* shouldn't happen ... */ ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type double precision: \"%s\"", - tmp))); + errmsg("invalid input syntax for type %s: \"%s\"", + "double precision", tmp))); } pfree(tmp); @@ -6357,8 +6358,8 @@ numericvar_to_double_no_overflow(NumericVar *var) /* shouldn't happen ... */ ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type double precision: \"%s\"", - tmp))); + errmsg("invalid input syntax for type %s: \"%s\"", + "double precision", tmp))); } pfree(tmp); diff --git a/src/backend/utils/adt/numutils.c b/src/backend/utils/adt/numutils.c index 045603f55cc..4ea2892c983 100644 --- a/src/backend/utils/adt/numutils.c +++ b/src/backend/utils/adt/numutils.c @@ -48,8 +48,8 @@ pg_atoi(const char *s, int size, int c) if (*s == 0) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for integer: \"%s\"", - s))); + errmsg("invalid input syntax for %s: \"%s\"", + "integer", s))); errno = 0; l = strtol(s, &badp, 10); @@ -58,8 +58,8 @@ pg_atoi(const char *s, int size, int c) if (s == badp) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for integer: \"%s\"", - s))); + errmsg("invalid input syntax for %s: \"%s\"", + "integer", s))); switch (size) { @@ -72,13 +72,15 @@ pg_atoi(const char *s, int size, int c) ) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("value \"%s\" is out of range for type integer", s))); + errmsg("value \"%s\" is out of range for type %s", s, + "integer"))); break; case sizeof(int16): if (errno == ERANGE || l < SHRT_MIN || l > SHRT_MAX) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("value \"%s\" is out of range for type smallint", s))); + errmsg("value \"%s\" is out of range for type %s", s, + "smallint"))); break; case sizeof(int8): if (errno == ERANGE || l < SCHAR_MIN || l > SCHAR_MAX) @@ -100,8 +102,8 @@ pg_atoi(const char *s, int size, int c) if (*badp && *badp != c) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for integer: \"%s\"", - s))); + errmsg("invalid input syntax for %s: \"%s\"", + "integer", s))); return (int32) l; } diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c index b0478f78bd4..12ef783b3fc 100644 --- a/src/backend/utils/adt/oid.c +++ b/src/backend/utils/adt/oid.c @@ -41,8 +41,8 @@ oidin_subr(const char *s, char **endloc) if (*s == '\0') ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type oid: \"%s\"", - s))); + errmsg("invalid input syntax for type %s: \"%s\"", + "oid", s))); errno = 0; cvt = strtoul(s, &endptr, 10); @@ -55,19 +55,20 @@ oidin_subr(const char *s, char **endloc) if (errno && errno != ERANGE && errno != EINVAL) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type oid: \"%s\"", - s))); + errmsg("invalid input syntax for type %s: \"%s\"", + "oid", s))); if (endptr == s && *s != '\0') ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type oid: \"%s\"", - s))); + errmsg("invalid input syntax for type %s: \"%s\"", + "oid", s))); if (errno == ERANGE) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("value \"%s\" is out of range for type oid", s))); + errmsg("value \"%s\" is out of range for type %s", + s, "oid"))); if (endloc) { @@ -82,8 +83,8 @@ oidin_subr(const char *s, char **endloc) if (*endptr) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type oid: \"%s\"", - s))); + errmsg("invalid input syntax for type %s: \"%s\"", + "oid", s))); } result = (Oid) cvt; @@ -105,7 +106,8 @@ oidin_subr(const char *s, char **endloc) cvt != (unsigned long) ((int) result)) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("value \"%s\" is out of range for type oid", s))); + errmsg("value \"%s\" is out of range for type %s", + s, "oid"))); #endif return result; diff --git a/src/backend/utils/adt/pg_lsn.c b/src/backend/utils/adt/pg_lsn.c index 16c9a0756e4..aefbb876808 100644 --- a/src/backend/utils/adt/pg_lsn.c +++ b/src/backend/utils/adt/pg_lsn.c @@ -41,12 +41,14 @@ pg_lsn_in(PG_FUNCTION_ARGS) if (len1 < 1 || len1 > MAXPG_LSNCOMPONENT || str[len1] != '/') ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type pg_lsn: \"%s\"", str))); + errmsg("invalid input syntax for type %s: \"%s\"", + "pg_lsn", str))); len2 = strspn(str + len1 + 1, "0123456789abcdefABCDEF"); if (len2 < 1 || len2 > MAXPG_LSNCOMPONENT || str[len1 + 1 + len2] != '\0') ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type pg_lsn: \"%s\"", str))); + errmsg("invalid input syntax for type %s: \"%s\"", + "pg_lsn", str))); /* Decode result. */ id = (uint32) strtoul(str, NULL, 16); diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c index 6eec25e2e50..aa7e5e5242f 100644 --- a/src/backend/utils/adt/tid.c +++ b/src/backend/utils/adt/tid.c @@ -68,24 +68,24 @@ tidin(PG_FUNCTION_ARGS) if (i < NTIDARGS) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type tid: \"%s\"", - str))); + errmsg("invalid input syntax for type %s: \"%s\"", + "tid", str))); errno = 0; blockNumber = strtoul(coord[0], &badp, 10); if (errno || *badp != DELIM) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type tid: \"%s\"", - str))); + errmsg("invalid input syntax for type %s: \"%s\"", + "tid", str))); hold_offset = strtol(coord[1], &badp, 10); if (errno || *badp != RDELIM || hold_offset > USHRT_MAX || hold_offset < 0) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type tid: \"%s\"", - str))); + errmsg("invalid input syntax for type %s: \"%s\"", + "tid", str))); offsetNumber = hold_offset; diff --git a/src/backend/utils/adt/txid.c b/src/backend/utils/adt/txid.c index 4945c43a8d1..772d7c72031 100644 --- a/src/backend/utils/adt/txid.c +++ b/src/backend/utils/adt/txid.c @@ -336,8 +336,8 @@ parse_snapshot(const char *str) bad_format: ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type txid_snapshot: \"%s\"", - str_start))); + errmsg("invalid input syntax for type %s: \"%s\"", + "txid_snapshot", str_start))); return NULL; /* keep compiler quiet */ } diff --git a/src/backend/utils/adt/uuid.c b/src/backend/utils/adt/uuid.c index 322116614d0..eaf2f8064d4 100644 --- a/src/backend/utils/adt/uuid.c +++ b/src/backend/utils/adt/uuid.c @@ -133,8 +133,8 @@ string_to_uuid(const char *source, pg_uuid_t *uuid) syntax_error: ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for uuid: \"%s\"", - source))); + errmsg("invalid input syntax for type %s: \"%s\"", + "uuid", source))); } Datum diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index fb532fc8d4b..d66e85aa1ef 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -294,7 +294,7 @@ byteain(PG_FUNCTION_ARGS) */ ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type bytea"))); + errmsg("invalid input syntax for type %s", "bytea"))); } } @@ -335,7 +335,7 @@ byteain(PG_FUNCTION_ARGS) */ ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), - errmsg("invalid input syntax for type bytea"))); + errmsg("invalid input syntax for type %s", "bytea"))); } } diff --git a/src/test/regress/expected/rangefuncs.out b/src/test/regress/expected/rangefuncs.out index f06cfa4b21d..275b66204ab 100644 --- a/src/test/regress/expected/rangefuncs.out +++ b/src/test/regress/expected/rangefuncs.out @@ -1514,7 +1514,7 @@ SELECT dup(22); (1 row) SELECT dup('xyz'); -- fails -ERROR: could not determine polymorphic type because input has type "unknown" +ERROR: could not determine polymorphic type because input has type unknown SELECT dup('xyz'::text); dup ------------------- diff --git a/src/test/regress/expected/uuid.out b/src/test/regress/expected/uuid.out index 59cb1e0ba6f..423f27787f3 100644 --- a/src/test/regress/expected/uuid.out +++ b/src/test/regress/expected/uuid.out @@ -13,30 +13,30 @@ CREATE TABLE guid2 -- inserting invalid data tests -- too long INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-1111-111111111111F'); -ERROR: invalid input syntax for uuid: "11111111-1111-1111-1111-111111111111F" +ERROR: invalid input syntax for type uuid: "11111111-1111-1111-1111-111111111111F" LINE 1: INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-111... ^ -- too short INSERT INTO guid1(guid_field) VALUES('{11111111-1111-1111-1111-11111111111}'); -ERROR: invalid input syntax for uuid: "{11111111-1111-1111-1111-11111111111}" +ERROR: invalid input syntax for type uuid: "{11111111-1111-1111-1111-11111111111}" LINE 1: INSERT INTO guid1(guid_field) VALUES('{11111111-1111-1111-11... ^ -- valid data but invalid format INSERT INTO guid1(guid_field) VALUES('111-11111-1111-1111-1111-111111111111'); -ERROR: invalid input syntax for uuid: "111-11111-1111-1111-1111-111111111111" +ERROR: invalid input syntax for type uuid: "111-11111-1111-1111-1111-111111111111" LINE 1: INSERT INTO guid1(guid_field) VALUES('111-11111-1111-1111-11... ^ INSERT INTO guid1(guid_field) VALUES('{22222222-2222-2222-2222-222222222222 '); -ERROR: invalid input syntax for uuid: "{22222222-2222-2222-2222-222222222222 " +ERROR: invalid input syntax for type uuid: "{22222222-2222-2222-2222-222222222222 " LINE 1: INSERT INTO guid1(guid_field) VALUES('{22222222-2222-2222-22... ^ -- invalid data INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-G111-111111111111'); -ERROR: invalid input syntax for uuid: "11111111-1111-1111-G111-111111111111" +ERROR: invalid input syntax for type uuid: "11111111-1111-1111-G111-111111111111" LINE 1: INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-G11... ^ INSERT INTO guid1(guid_field) VALUES('11+11111-1111-1111-1111-111111111111'); -ERROR: invalid input syntax for uuid: "11+11111-1111-1111-1111-111111111111" +ERROR: invalid input syntax for type uuid: "11+11111-1111-1111-1111-111111111111" LINE 1: INSERT INTO guid1(guid_field) VALUES('11+11111-1111-1111-111... ^ --inserting three input formats -- GitLab