Commit 9a34123b authored by Alvaro Herrera's avatar Alvaro Herrera

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

Discussion: https://postgr.es/m/20160401170642.GA57509@alvherre.pgsql
parent 716c7d4b
...@@ -18,9 +18,9 @@ ERROR: type "foo" does not exist ...@@ -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 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 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 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 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)); -- ok
CREATE TRANSFORM FOR hstore LANGUAGE plperl (FROM SQL WITH FUNCTION hstore_to_plperl(internal), TO SQL WITH FUNCTION plperl_to_hstore(internal)); -- fail 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 ERROR: transform for type hstore language "plperl" already exists
......
...@@ -1819,7 +1819,8 @@ ExecGrant_Relation(InternalGrant *istmt) ...@@ -1819,7 +1819,8 @@ ExecGrant_Relation(InternalGrant *istmt)
*/ */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_GRANT_OPERATION), (errcode(ERRCODE_INVALID_GRANT_OPERATION),
errmsg("invalid privilege type USAGE for table"))); errmsg("invalid privilege type %s for table",
"USAGE")));
} }
} }
} }
......
...@@ -1598,7 +1598,8 @@ find_expr_references_walker(Node *node, ...@@ -1598,7 +1598,8 @@ find_expr_references_walker(Node *node,
case REGROLEOID: case REGROLEOID:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (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; break;
} }
} }
......
...@@ -498,7 +498,7 @@ CheckAttributeType(const char *attname, ...@@ -498,7 +498,7 @@ CheckAttributeType(const char *attname,
*/ */
ereport(WARNING, ereport(WARNING,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION), (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."))); errdetail("Proceeding with relation creation anyway.")));
} }
else if (att_typtype == TYPTYPE_PSEUDO) else if (att_typtype == TYPTYPE_PSEUDO)
......
...@@ -1482,11 +1482,13 @@ CreateCast(CreateCastStmt *stmt) ...@@ -1482,11 +1482,13 @@ CreateCast(CreateCastStmt *stmt)
if (nargs > 1 && procstruct->proargtypes.values[1] != INT4OID) if (nargs > 1 && procstruct->proargtypes.values[1] != INT4OID)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (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) if (nargs > 2 && procstruct->proargtypes.values[2] != BOOLOID)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (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)) if (!IsBinaryCoercible(procstruct->prorettype, targettypeid))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
...@@ -1776,7 +1778,8 @@ check_transform_function(Form_pg_proc procstruct) ...@@ -1776,7 +1778,8 @@ check_transform_function(Form_pg_proc procstruct)
if (procstruct->proargtypes.values[0] != INTERNALOID) if (procstruct->proargtypes.values[0] != INTERNALOID)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (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) ...@@ -1859,7 +1862,8 @@ CreateTransform(CreateTransformStmt *stmt)
if (procstruct->prorettype != INTERNALOID) if (procstruct->prorettype != INTERNALOID)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), (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); check_transform_function(procstruct);
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
} }
......
...@@ -278,8 +278,9 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) ...@@ -278,8 +278,9 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
{ {
ereport(WARNING, ereport(WARNING,
(errcode(ERRCODE_WRONG_OBJECT_TYPE), (errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("changing return type of function %s from \"opaque\" to \"language_handler\"", errmsg("changing return type of function %s from %s to %s",
NameListToString(stmt->plhandler)))); NameListToString(stmt->plhandler),
"opaque", "language_handler")));
SetFunctionReturnType(handlerOid, LANGUAGE_HANDLEROID); SetFunctionReturnType(handlerOid, LANGUAGE_HANDLEROID);
} }
else else
......
...@@ -522,8 +522,9 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString, ...@@ -522,8 +522,9 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
if (funcrettype == OPAQUEOID) if (funcrettype == OPAQUEOID)
{ {
ereport(WARNING, ereport(WARNING,
(errmsg("changing return type of function %s from \"opaque\" to \"trigger\"", (errmsg("changing return type of function %s from %s to %s",
NameListToString(stmt->funcname)))); NameListToString(stmt->funcname),
"opaque", "trigger")));
SetFunctionReturnType(funcoid, TRIGGEROID); SetFunctionReturnType(funcoid, TRIGGEROID);
} }
else else
......
...@@ -1077,8 +1077,9 @@ coerce_to_boolean(ParseState *pstate, Node *node, ...@@ -1077,8 +1077,9 @@ coerce_to_boolean(ParseState *pstate, Node *node,
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH), (errcode(ERRCODE_DATATYPE_MISMATCH),
/* translator: first %s is name of a SQL construct, eg WHERE */ /* translator: first %s is name of a SQL construct, eg WHERE */
errmsg("argument of %s must be type boolean, not type %s", errmsg("argument of %s must be type %s, not type %s",
constructName, format_type_be(inputTypeId)), constructName, "boolean",
format_type_be(inputTypeId)),
parser_errposition(pstate, exprLocation(node)))); parser_errposition(pstate, exprLocation(node))));
node = newnode; node = newnode;
} }
...@@ -1695,8 +1696,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, ...@@ -1695,8 +1696,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
if (!OidIsValid(array_typelem)) if (!OidIsValid(array_typelem))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH), (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("argument declared \"anyarray\" is not an array but type %s", errmsg("argument declared %s is not an array but type %s",
format_type_be(array_typeid)))); "anyarray", format_type_be(array_typeid))));
} }
if (!OidIsValid(elem_typeid)) if (!OidIsValid(elem_typeid))
...@@ -1711,7 +1712,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, ...@@ -1711,7 +1712,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
/* otherwise, they better match */ /* otherwise, they better match */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH), (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", errdetail("%s versus %s",
format_type_be(array_typeid), format_type_be(array_typeid),
format_type_be(elem_typeid)))); format_type_be(elem_typeid))));
...@@ -1732,7 +1734,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, ...@@ -1732,7 +1734,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
if (!OidIsValid(range_typelem)) if (!OidIsValid(range_typelem))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH), (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("argument declared \"anyrange\" is not a range type but type %s", errmsg("argument declared %s is not a range type but type %s",
"anyrange",
format_type_be(range_typeid)))); format_type_be(range_typeid))));
} }
...@@ -1748,7 +1751,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, ...@@ -1748,7 +1751,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
/* otherwise, they better match */ /* otherwise, they better match */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH), (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", errdetail("%s versus %s",
format_type_be(range_typeid), format_type_be(range_typeid),
format_type_be(elem_typeid)))); format_type_be(elem_typeid))));
...@@ -1768,7 +1772,8 @@ enforce_generic_type_consistency(Oid *actual_arg_types, ...@@ -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 */ /* Only way to get here is if all the generic args are UNKNOWN */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH), (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, ...@@ -1906,8 +1911,8 @@ resolve_generic_type(Oid declared_type,
if (!OidIsValid(array_typelem)) if (!OidIsValid(array_typelem))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH), (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("argument declared \"anyarray\" is not an array but type %s", errmsg("argument declared %s is not an array but type %s",
format_type_be(context_base_type)))); "anyarray", format_type_be(context_base_type))));
return context_base_type; return context_base_type;
} }
else if (context_declared_type == ANYELEMENTOID || else if (context_declared_type == ANYELEMENTOID ||
...@@ -1940,8 +1945,8 @@ resolve_generic_type(Oid declared_type, ...@@ -1940,8 +1945,8 @@ resolve_generic_type(Oid declared_type,
if (!OidIsValid(array_typelem)) if (!OidIsValid(array_typelem))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH), (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("argument declared \"anyarray\" is not an array but type %s", errmsg("argument declared %s is not an array but type %s",
format_type_be(context_base_type)))); "anyarray", format_type_be(context_base_type))));
return array_typelem; return array_typelem;
} }
else if (context_declared_type == ANYRANGEOID) else if (context_declared_type == ANYRANGEOID)
...@@ -1953,8 +1958,8 @@ resolve_generic_type(Oid declared_type, ...@@ -1953,8 +1958,8 @@ resolve_generic_type(Oid declared_type,
if (!OidIsValid(range_typelem)) if (!OidIsValid(range_typelem))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH), (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("argument declared \"anyrange\" is not a range type but type %s", errmsg("argument declared %s is not a range type but type %s",
format_type_be(context_base_type)))); "anyrange", format_type_be(context_base_type))));
return range_typelem; return range_typelem;
} }
else if (context_declared_type == ANYELEMENTOID || else if (context_declared_type == ANYELEMENTOID ||
......
...@@ -150,7 +150,8 @@ boolin(PG_FUNCTION_ARGS) ...@@ -150,7 +150,8 @@ boolin(PG_FUNCTION_ARGS)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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 */ /* not reached */
PG_RETURN_BOOL(false); PG_RETURN_BOOL(false);
......
...@@ -209,8 +209,8 @@ cash_in(PG_FUNCTION_ARGS) ...@@ -209,8 +209,8 @@ cash_in(PG_FUNCTION_ARGS)
if (newvalue / 10 != value) if (newvalue / 10 != value)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("value \"%s\" is out of range for type money", errmsg("value \"%s\" is out of range for type %s",
str))); str, "money")));
value = newvalue; value = newvalue;
...@@ -236,8 +236,8 @@ cash_in(PG_FUNCTION_ARGS) ...@@ -236,8 +236,8 @@ cash_in(PG_FUNCTION_ARGS)
if (value > 0) if (value > 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("value \"%s\" is out of range for type money", errmsg("value \"%s\" is out of range for type %s",
str))); str, "money")));
/* adjust for less than required decimal places */ /* adjust for less than required decimal places */
for (; dec < fpoint; dec++) for (; dec < fpoint; dec++)
...@@ -247,8 +247,8 @@ cash_in(PG_FUNCTION_ARGS) ...@@ -247,8 +247,8 @@ cash_in(PG_FUNCTION_ARGS)
if (newvalue / 10 != value) if (newvalue / 10 != value)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("value \"%s\" is out of range for type money", errmsg("value \"%s\" is out of range for type %s",
str))); str, "money")));
value = newvalue; value = newvalue;
} }
...@@ -276,8 +276,8 @@ cash_in(PG_FUNCTION_ARGS) ...@@ -276,8 +276,8 @@ cash_in(PG_FUNCTION_ARGS)
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type money: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
str))); "money", str)));
} }
/* If the value is supposed to be positive, flip the sign, but check for /* If the value is supposed to be positive, flip the sign, but check for
...@@ -288,8 +288,8 @@ cash_in(PG_FUNCTION_ARGS) ...@@ -288,8 +288,8 @@ cash_in(PG_FUNCTION_ARGS)
if (result < 0) if (result < 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("value \"%s\" is out of range for type money", errmsg("value \"%s\" is out of range for type %s",
str))); str, "money")));
} }
else else
result = value; result = value;
......
...@@ -439,7 +439,7 @@ esc_decode(const char *src, unsigned srclen, char *dst) ...@@ -439,7 +439,7 @@ esc_decode(const char *src, unsigned srclen, char *dst)
*/ */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type bytea"))); errmsg("invalid input syntax for type %s", "bytea")));
} }
len++; len++;
...@@ -504,7 +504,7 @@ esc_dec_len(const char *src, unsigned srclen) ...@@ -504,7 +504,7 @@ esc_dec_len(const char *src, unsigned srclen)
*/ */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type bytea"))); errmsg("invalid input syntax for type %s", "bytea")));
} }
len++; len++;
......
...@@ -241,8 +241,8 @@ float4in(PG_FUNCTION_ARGS) ...@@ -241,8 +241,8 @@ float4in(PG_FUNCTION_ARGS)
if (*num == '\0') if (*num == '\0')
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type real: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
orig_num))); "real", orig_num)));
errno = 0; errno = 0;
val = strtod(num, &endptr); val = strtod(num, &endptr);
...@@ -315,8 +315,8 @@ float4in(PG_FUNCTION_ARGS) ...@@ -315,8 +315,8 @@ float4in(PG_FUNCTION_ARGS)
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type real: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
orig_num))); "real", orig_num)));
} }
#ifdef HAVE_BUGGY_SOLARIS_STRTOD #ifdef HAVE_BUGGY_SOLARIS_STRTOD
else else
...@@ -339,8 +339,8 @@ float4in(PG_FUNCTION_ARGS) ...@@ -339,8 +339,8 @@ float4in(PG_FUNCTION_ARGS)
if (*endptr != '\0') if (*endptr != '\0')
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type real: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
orig_num))); "real", orig_num)));
/* /*
* if we get here, we have a legal double, still need to check to see if * if we get here, we have a legal double, still need to check to see if
......
...@@ -95,8 +95,8 @@ scanint8(const char *str, bool errorOK, int64 *result) ...@@ -95,8 +95,8 @@ scanint8(const char *str, bool errorOK, int64 *result)
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for integer: \"%s\"", errmsg("invalid input syntax for %s: \"%s\"",
str))); "integer", str)));
} }
/* process digits */ /* process digits */
...@@ -111,8 +111,8 @@ scanint8(const char *str, bool errorOK, int64 *result) ...@@ -111,8 +111,8 @@ scanint8(const char *str, bool errorOK, int64 *result)
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
errmsg("value \"%s\" is out of range for type bigint", errmsg("value \"%s\" is out of range for type %s",
str))); str, "bigint")));
} }
tmp = newtmp; tmp = newtmp;
} }
...@@ -130,8 +130,8 @@ gotdigits: ...@@ -130,8 +130,8 @@ gotdigits:
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for integer: \"%s\"", errmsg("invalid input syntax for %s: \"%s\"",
str))); "integer", str)));
} }
*result = (sign < 0) ? -tmp : tmp; *result = (sign < 0) ? -tmp : tmp;
......
...@@ -782,7 +782,7 @@ json_lex_string(JsonLexContext *lex) ...@@ -782,7 +782,7 @@ json_lex_string(JsonLexContext *lex)
lex->token_terminator = s; lex->token_terminator = s;
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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.", errdetail("Character with value 0x%02x must be escaped.",
(unsigned char) *s), (unsigned char) *s),
report_json_context(lex))); report_json_context(lex)));
...@@ -822,7 +822,8 @@ json_lex_string(JsonLexContext *lex) ...@@ -822,7 +822,8 @@ json_lex_string(JsonLexContext *lex)
lex->token_terminator = s + pg_mblen(s); lex->token_terminator = s + pg_mblen(s);
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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."), errdetail("\"\\u\" must be followed by four hexadecimal digits."),
report_json_context(lex))); report_json_context(lex)));
} }
...@@ -837,7 +838,8 @@ json_lex_string(JsonLexContext *lex) ...@@ -837,7 +838,8 @@ json_lex_string(JsonLexContext *lex)
if (hi_surrogate != -1) if (hi_surrogate != -1)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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."), errdetail("Unicode high surrogate must not follow a high surrogate."),
report_json_context(lex))); report_json_context(lex)));
hi_surrogate = (ch & 0x3ff) << 10; hi_surrogate = (ch & 0x3ff) << 10;
...@@ -848,7 +850,7 @@ json_lex_string(JsonLexContext *lex) ...@@ -848,7 +850,7 @@ json_lex_string(JsonLexContext *lex)
if (hi_surrogate == -1) if (hi_surrogate == -1)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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."), errdetail("Unicode low surrogate must follow a high surrogate."),
report_json_context(lex))); report_json_context(lex)));
ch = 0x10000 + hi_surrogate + (ch & 0x3ff); ch = 0x10000 + hi_surrogate + (ch & 0x3ff);
...@@ -858,7 +860,7 @@ json_lex_string(JsonLexContext *lex) ...@@ -858,7 +860,7 @@ json_lex_string(JsonLexContext *lex)
if (hi_surrogate != -1) if (hi_surrogate != -1)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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."), errdetail("Unicode low surrogate must follow a high surrogate."),
report_json_context(lex))); report_json_context(lex)));
...@@ -909,7 +911,8 @@ json_lex_string(JsonLexContext *lex) ...@@ -909,7 +911,8 @@ json_lex_string(JsonLexContext *lex)
if (hi_surrogate != -1) if (hi_surrogate != -1)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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."), errdetail("Unicode low surrogate must follow a high surrogate."),
report_json_context(lex))); report_json_context(lex)));
...@@ -940,7 +943,8 @@ json_lex_string(JsonLexContext *lex) ...@@ -940,7 +943,8 @@ json_lex_string(JsonLexContext *lex)
lex->token_terminator = s + pg_mblen(s); lex->token_terminator = s + pg_mblen(s);
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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.", errdetail("Escape sequence \"\\%s\" is invalid.",
extract_mb_char(s)), extract_mb_char(s)),
report_json_context(lex))); report_json_context(lex)));
...@@ -958,7 +962,7 @@ json_lex_string(JsonLexContext *lex) ...@@ -958,7 +962,7 @@ json_lex_string(JsonLexContext *lex)
lex->token_terminator = s + pg_mblen(s); lex->token_terminator = s + pg_mblen(s);
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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.", errdetail("Escape sequence \"\\%s\" is invalid.",
extract_mb_char(s)), extract_mb_char(s)),
report_json_context(lex))); report_json_context(lex)));
...@@ -970,7 +974,7 @@ json_lex_string(JsonLexContext *lex) ...@@ -970,7 +974,7 @@ json_lex_string(JsonLexContext *lex)
if (hi_surrogate != -1) if (hi_surrogate != -1)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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."), errdetail("Unicode low surrogate must follow a high surrogate."),
report_json_context(lex))); report_json_context(lex)));
...@@ -982,7 +986,7 @@ json_lex_string(JsonLexContext *lex) ...@@ -982,7 +986,7 @@ json_lex_string(JsonLexContext *lex)
if (hi_surrogate != -1) if (hi_surrogate != -1)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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."), errdetail("Unicode low surrogate must follow a high surrogate."),
report_json_context(lex))); report_json_context(lex)));
...@@ -1127,7 +1131,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) ...@@ -1127,7 +1131,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex)
if (lex->token_start == NULL || lex->token_type == JSON_TOKEN_END) if (lex->token_start == NULL || lex->token_type == JSON_TOKEN_END)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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."), errdetail("The input string ended unexpectedly."),
report_json_context(lex))); report_json_context(lex)));
...@@ -1141,7 +1145,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) ...@@ -1141,7 +1145,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex)
if (ctx == JSON_PARSE_END) if (ctx == JSON_PARSE_END)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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\".", errdetail("Expected end of input, but found \"%s\".",
token), token),
report_json_context(lex))); report_json_context(lex)));
...@@ -1152,7 +1156,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) ...@@ -1152,7 +1156,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex)
case JSON_PARSE_VALUE: case JSON_PARSE_VALUE:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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\".", errdetail("Expected JSON value, but found \"%s\".",
token), token),
report_json_context(lex))); report_json_context(lex)));
...@@ -1160,7 +1164,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) ...@@ -1160,7 +1164,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex)
case JSON_PARSE_STRING: case JSON_PARSE_STRING:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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\".", errdetail("Expected string, but found \"%s\".",
token), token),
report_json_context(lex))); report_json_context(lex)));
...@@ -1168,7 +1172,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) ...@@ -1168,7 +1172,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex)
case JSON_PARSE_ARRAY_START: case JSON_PARSE_ARRAY_START:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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\".", errdetail("Expected array element or \"]\", but found \"%s\".",
token), token),
report_json_context(lex))); report_json_context(lex)));
...@@ -1176,7 +1180,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) ...@@ -1176,7 +1180,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex)
case JSON_PARSE_ARRAY_NEXT: case JSON_PARSE_ARRAY_NEXT:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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\".", errdetail("Expected \",\" or \"]\", but found \"%s\".",
token), token),
report_json_context(lex))); report_json_context(lex)));
...@@ -1184,7 +1188,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) ...@@ -1184,7 +1188,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex)
case JSON_PARSE_OBJECT_START: case JSON_PARSE_OBJECT_START:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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\".", errdetail("Expected string or \"}\", but found \"%s\".",
token), token),
report_json_context(lex))); report_json_context(lex)));
...@@ -1192,7 +1196,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) ...@@ -1192,7 +1196,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex)
case JSON_PARSE_OBJECT_LABEL: case JSON_PARSE_OBJECT_LABEL:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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\".", errdetail("Expected \":\", but found \"%s\".",
token), token),
report_json_context(lex))); report_json_context(lex)));
...@@ -1200,7 +1204,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) ...@@ -1200,7 +1204,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex)
case JSON_PARSE_OBJECT_NEXT: case JSON_PARSE_OBJECT_NEXT:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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\".", errdetail("Expected \",\" or \"}\", but found \"%s\".",
token), token),
report_json_context(lex))); report_json_context(lex)));
...@@ -1208,7 +1212,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex) ...@@ -1208,7 +1212,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex)
case JSON_PARSE_OBJECT_COMMA: case JSON_PARSE_OBJECT_COMMA:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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\".", errdetail("Expected string, but found \"%s\".",
token), token),
report_json_context(lex))); report_json_context(lex)));
...@@ -1238,7 +1242,7 @@ report_invalid_token(JsonLexContext *lex) ...@@ -1238,7 +1242,7 @@ report_invalid_token(JsonLexContext *lex)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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), errdetail("Token \"%s\" is invalid.", token),
report_json_context(lex))); report_json_context(lex)));
} }
......
...@@ -65,7 +65,8 @@ macaddr_in(PG_FUNCTION_ARGS) ...@@ -65,7 +65,8 @@ macaddr_in(PG_FUNCTION_ARGS)
if (count != 6) if (count != 6)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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) || if ((a < 0) || (a > 255) || (b < 0) || (b > 255) ||
(c < 0) || (c > 255) || (d < 0) || (d > 255) || (c < 0) || (c > 255) || (d < 0) || (d > 255) ||
......
...@@ -1547,8 +1547,8 @@ parsetinterval(char *i_string, ...@@ -1547,8 +1547,8 @@ parsetinterval(char *i_string,
bogus: bogus:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_DATETIME_FORMAT), (errcode(ERRCODE_INVALID_DATETIME_FORMAT),
errmsg("invalid input syntax for type tinterval: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
i_string))); "tinterval", i_string)));
*i_start = *i_end = INVALID_ABSTIME; /* keep compiler quiet */ *i_start = *i_end = INVALID_ABSTIME; /* keep compiler quiet */
} }
......
...@@ -590,8 +590,8 @@ numeric_in(PG_FUNCTION_ARGS) ...@@ -590,8 +590,8 @@ numeric_in(PG_FUNCTION_ARGS)
if (!isspace((unsigned char) *cp)) if (!isspace((unsigned char) *cp))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type numeric: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
str))); "numeric", str)));
cp++; cp++;
} }
} }
...@@ -617,8 +617,8 @@ numeric_in(PG_FUNCTION_ARGS) ...@@ -617,8 +617,8 @@ numeric_in(PG_FUNCTION_ARGS)
if (!isspace((unsigned char) *cp)) if (!isspace((unsigned char) *cp))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type numeric: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
str))); "numeric", str)));
cp++; cp++;
} }
...@@ -5482,7 +5482,8 @@ set_var_from_str(const char *str, const char *cp, NumericVar *dest) ...@@ -5482,7 +5482,8 @@ set_var_from_str(const char *str, const char *cp, NumericVar *dest)
if (!isdigit((unsigned char) *cp)) if (!isdigit((unsigned char) *cp))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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); 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) ...@@ -5505,8 +5506,8 @@ set_var_from_str(const char *str, const char *cp, NumericVar *dest)
if (have_dp) if (have_dp)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type numeric: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
str))); "numeric", str)));
have_dp = TRUE; have_dp = TRUE;
cp++; cp++;
} }
...@@ -5529,8 +5530,8 @@ set_var_from_str(const char *str, const char *cp, NumericVar *dest) ...@@ -5529,8 +5530,8 @@ set_var_from_str(const char *str, const char *cp, NumericVar *dest)
if (endptr == cp) if (endptr == cp)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type numeric: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
str))); "numeric", str)));
cp = endptr; cp = endptr;
/* /*
...@@ -6331,8 +6332,8 @@ numeric_to_double_no_overflow(Numeric num) ...@@ -6331,8 +6332,8 @@ numeric_to_double_no_overflow(Numeric num)
/* shouldn't happen ... */ /* shouldn't happen ... */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type double precision: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
tmp))); "double precision", tmp)));
} }
pfree(tmp); pfree(tmp);
...@@ -6357,8 +6358,8 @@ numericvar_to_double_no_overflow(NumericVar *var) ...@@ -6357,8 +6358,8 @@ numericvar_to_double_no_overflow(NumericVar *var)
/* shouldn't happen ... */ /* shouldn't happen ... */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type double precision: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
tmp))); "double precision", tmp)));
} }
pfree(tmp); pfree(tmp);
......
...@@ -48,8 +48,8 @@ pg_atoi(const char *s, int size, int c) ...@@ -48,8 +48,8 @@ pg_atoi(const char *s, int size, int c)
if (*s == 0) if (*s == 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for integer: \"%s\"", errmsg("invalid input syntax for %s: \"%s\"",
s))); "integer", s)));
errno = 0; errno = 0;
l = strtol(s, &badp, 10); l = strtol(s, &badp, 10);
...@@ -58,8 +58,8 @@ pg_atoi(const char *s, int size, int c) ...@@ -58,8 +58,8 @@ pg_atoi(const char *s, int size, int c)
if (s == badp) if (s == badp)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for integer: \"%s\"", errmsg("invalid input syntax for %s: \"%s\"",
s))); "integer", s)));
switch (size) switch (size)
{ {
...@@ -72,13 +72,15 @@ pg_atoi(const char *s, int size, int c) ...@@ -72,13 +72,15 @@ pg_atoi(const char *s, int size, int c)
) )
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), (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; break;
case sizeof(int16): case sizeof(int16):
if (errno == ERANGE || l < SHRT_MIN || l > SHRT_MAX) if (errno == ERANGE || l < SHRT_MIN || l > SHRT_MAX)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), (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; break;
case sizeof(int8): case sizeof(int8):
if (errno == ERANGE || l < SCHAR_MIN || l > SCHAR_MAX) if (errno == ERANGE || l < SCHAR_MIN || l > SCHAR_MAX)
...@@ -100,8 +102,8 @@ pg_atoi(const char *s, int size, int c) ...@@ -100,8 +102,8 @@ pg_atoi(const char *s, int size, int c)
if (*badp && *badp != c) if (*badp && *badp != c)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for integer: \"%s\"", errmsg("invalid input syntax for %s: \"%s\"",
s))); "integer", s)));
return (int32) l; return (int32) l;
} }
......
...@@ -41,8 +41,8 @@ oidin_subr(const char *s, char **endloc) ...@@ -41,8 +41,8 @@ oidin_subr(const char *s, char **endloc)
if (*s == '\0') if (*s == '\0')
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type oid: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
s))); "oid", s)));
errno = 0; errno = 0;
cvt = strtoul(s, &endptr, 10); cvt = strtoul(s, &endptr, 10);
...@@ -55,19 +55,20 @@ oidin_subr(const char *s, char **endloc) ...@@ -55,19 +55,20 @@ oidin_subr(const char *s, char **endloc)
if (errno && errno != ERANGE && errno != EINVAL) if (errno && errno != ERANGE && errno != EINVAL)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type oid: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
s))); "oid", s)));
if (endptr == s && *s != '\0') if (endptr == s && *s != '\0')
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type oid: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
s))); "oid", s)));
if (errno == ERANGE) if (errno == ERANGE)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), (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) if (endloc)
{ {
...@@ -82,8 +83,8 @@ oidin_subr(const char *s, char **endloc) ...@@ -82,8 +83,8 @@ oidin_subr(const char *s, char **endloc)
if (*endptr) if (*endptr)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type oid: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
s))); "oid", s)));
} }
result = (Oid) cvt; result = (Oid) cvt;
...@@ -105,7 +106,8 @@ oidin_subr(const char *s, char **endloc) ...@@ -105,7 +106,8 @@ oidin_subr(const char *s, char **endloc)
cvt != (unsigned long) ((int) result)) cvt != (unsigned long) ((int) result))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), (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 #endif
return result; return result;
......
...@@ -41,12 +41,14 @@ pg_lsn_in(PG_FUNCTION_ARGS) ...@@ -41,12 +41,14 @@ pg_lsn_in(PG_FUNCTION_ARGS)
if (len1 < 1 || len1 > MAXPG_LSNCOMPONENT || str[len1] != '/') if (len1 < 1 || len1 > MAXPG_LSNCOMPONENT || str[len1] != '/')
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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"); len2 = strspn(str + len1 + 1, "0123456789abcdefABCDEF");
if (len2 < 1 || len2 > MAXPG_LSNCOMPONENT || str[len1 + 1 + len2] != '\0') if (len2 < 1 || len2 > MAXPG_LSNCOMPONENT || str[len1 + 1 + len2] != '\0')
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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. */ /* Decode result. */
id = (uint32) strtoul(str, NULL, 16); id = (uint32) strtoul(str, NULL, 16);
......
...@@ -68,24 +68,24 @@ tidin(PG_FUNCTION_ARGS) ...@@ -68,24 +68,24 @@ tidin(PG_FUNCTION_ARGS)
if (i < NTIDARGS) if (i < NTIDARGS)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type tid: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
str))); "tid", str)));
errno = 0; errno = 0;
blockNumber = strtoul(coord[0], &badp, 10); blockNumber = strtoul(coord[0], &badp, 10);
if (errno || *badp != DELIM) if (errno || *badp != DELIM)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type tid: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
str))); "tid", str)));
hold_offset = strtol(coord[1], &badp, 10); hold_offset = strtol(coord[1], &badp, 10);
if (errno || *badp != RDELIM || if (errno || *badp != RDELIM ||
hold_offset > USHRT_MAX || hold_offset < 0) hold_offset > USHRT_MAX || hold_offset < 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type tid: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
str))); "tid", str)));
offsetNumber = hold_offset; offsetNumber = hold_offset;
......
...@@ -336,8 +336,8 @@ parse_snapshot(const char *str) ...@@ -336,8 +336,8 @@ parse_snapshot(const char *str)
bad_format: bad_format:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type txid_snapshot: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
str_start))); "txid_snapshot", str_start)));
return NULL; /* keep compiler quiet */ return NULL; /* keep compiler quiet */
} }
......
...@@ -133,8 +133,8 @@ string_to_uuid(const char *source, pg_uuid_t *uuid) ...@@ -133,8 +133,8 @@ string_to_uuid(const char *source, pg_uuid_t *uuid)
syntax_error: syntax_error:
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for uuid: \"%s\"", errmsg("invalid input syntax for type %s: \"%s\"",
source))); "uuid", source)));
} }
Datum Datum
......
...@@ -294,7 +294,7 @@ byteain(PG_FUNCTION_ARGS) ...@@ -294,7 +294,7 @@ byteain(PG_FUNCTION_ARGS)
*/ */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (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) ...@@ -335,7 +335,7 @@ byteain(PG_FUNCTION_ARGS)
*/ */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type bytea"))); errmsg("invalid input syntax for type %s", "bytea")));
} }
} }
......
...@@ -1514,7 +1514,7 @@ SELECT dup(22); ...@@ -1514,7 +1514,7 @@ SELECT dup(22);
(1 row) (1 row)
SELECT dup('xyz'); -- fails 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); SELECT dup('xyz'::text);
dup dup
------------------- -------------------
......
...@@ -13,30 +13,30 @@ CREATE TABLE guid2 ...@@ -13,30 +13,30 @@ CREATE TABLE guid2
-- inserting invalid data tests -- inserting invalid data tests
-- too long -- too long
INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-1111-111111111111F'); 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... LINE 1: INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-111...
^ ^
-- too short -- too short
INSERT INTO guid1(guid_field) VALUES('{11111111-1111-1111-1111-11111111111}'); 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... LINE 1: INSERT INTO guid1(guid_field) VALUES('{11111111-1111-1111-11...
^ ^
-- valid data but invalid format -- valid data but invalid format
INSERT INTO guid1(guid_field) VALUES('111-11111-1111-1111-1111-111111111111'); 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... LINE 1: INSERT INTO guid1(guid_field) VALUES('111-11111-1111-1111-11...
^ ^
INSERT INTO guid1(guid_field) VALUES('{22222222-2222-2222-2222-222222222222 '); 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... LINE 1: INSERT INTO guid1(guid_field) VALUES('{22222222-2222-2222-22...
^ ^
-- invalid data -- invalid data
INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-G111-111111111111'); 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... LINE 1: INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-G11...
^ ^
INSERT INTO guid1(guid_field) VALUES('11+11111-1111-1111-1111-111111111111'); 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... LINE 1: INSERT INTO guid1(guid_field) VALUES('11+11111-1111-1111-111...
^ ^
--inserting three input formats --inserting three input formats
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment