1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

Provide an error cursor for "can't subscript" error messages.

Commit c7aba7c14 didn't add this, but after more fooling with the
feature I feel that it'd be useful.  To make this possible, refactor
getSubscriptingRoutines() so that the caller is responsible for
throwing any error.  (In clauses.c, I just chose to make the
most conservative assumption rather than throwing an error.  We don't
expect failures there anyway really, so the code space for an error
message would be a poor investment.)
This commit is contained in:
Tom Lane
2020-12-11 17:54:10 -05:00
parent d2a2808eb4
commit 653aa603f5
5 changed files with 21 additions and 7 deletions

View File

@ -3031,7 +3031,7 @@ get_typsubscript(Oid typid, Oid *typelemp)
* getSubscriptingRoutines
*
* Given the type OID, fetch the type's subscripting methods struct.
* Fail if type is not subscriptable.
* Return NULL if type is not subscriptable.
*
* If typelemp isn't NULL, we also store the type's typelem value there.
* This saves some callers an extra catalog lookup.
@ -3042,10 +3042,7 @@ getSubscriptingRoutines(Oid typid, Oid *typelemp)
RegProcedure typsubscript = get_typsubscript(typid, typelemp);
if (!OidIsValid(typsubscript))
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("cannot subscript type %s because it does not support subscripting",
format_type_be(typid))));
return NULL;
return (const struct SubscriptRoutines *)
DatumGetPointer(OidFunctionCall0(typsubscript));