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 f402b99501.

Discussion: https://postgr.es/m/20160401170642.GA57509@alvherre.pgsql
This commit is contained in:
Alvaro Herrera 2017-01-18 16:08:20 -03:00
parent 716c7d4b24
commit 9a34123bc3
26 changed files with 155 additions and 129 deletions

View File

@ -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

View File

@ -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")));
}
}
}

View File

@ -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;
}
}

View File

@ -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)

View File

@ -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);
}

View File

@ -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

View File

@ -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

View File

@ -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 ||

View File

@ -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);

View File

@ -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;

View File

@ -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++;

View File

@ -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

View File

@ -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;

View File

@ -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)));
}

View File

@ -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) ||

View File

@ -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 */
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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 */
}

View File

@ -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

View File

@ -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")));
}
}

View File

@ -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
-------------------

View File

@ -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