Improve error message with JSON_SERIALIZE()
The error message introduced in 3c633f3 can share the same format string with an existing message used for JSON(), reducing the translation effort. Author: Kyotaro Horiguchi Discussion: https://postgr.es/m/20220708.154135.2123613118233840495.horikyota.ntt@gmail.com Backpatch-through: 15
This commit is contained in:
parent
b2b6c1be05
commit
834fce52f9
@ -4587,8 +4587,9 @@ transformJsonSerializeExpr(ParseState *pstate, JsonSerializeExpr *expr)
|
|||||||
if (typcategory != TYPCATEGORY_STRING)
|
if (typcategory != TYPCATEGORY_STRING)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
(errcode(ERRCODE_DATATYPE_MISMATCH),
|
||||||
errmsg("cannot use RETURNING type %s in JSON_SERIALIZE",
|
errmsg("cannot use RETURNING type %s in %s",
|
||||||
format_type_be(returning->typid)),
|
format_type_be(returning->typid),
|
||||||
|
"JSON_SERIALIZE()"),
|
||||||
errhint("Try returning a string type or bytea")));
|
errhint("Try returning a string type or bytea")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ SELECT pg_typeof(JSON_SERIALIZE(NULL));
|
|||||||
|
|
||||||
-- only string types or bytea allowed
|
-- only string types or bytea allowed
|
||||||
SELECT JSON_SERIALIZE('{ "a" : 1 } ' RETURNING jsonb);
|
SELECT JSON_SERIALIZE('{ "a" : 1 } ' RETURNING jsonb);
|
||||||
ERROR: cannot use RETURNING type jsonb in JSON_SERIALIZE
|
ERROR: cannot use RETURNING type jsonb in JSON_SERIALIZE()
|
||||||
HINT: Try returning a string type or bytea
|
HINT: Try returning a string type or bytea
|
||||||
EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SERIALIZE('{}');
|
EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SERIALIZE('{}');
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
|
Loading…
x
Reference in New Issue
Block a user