aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_node.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-12-11 17:54:10 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2020-12-11 18:58:21 -0500
commit653aa603f501aa6e4865105a928cd13082ee7152 (patch)
tree158acf06d799a63fa44fc83e9800a3896ad66255 /src/backend/parser/parse_node.c
parentd2a2808eb444986d2fe716a48e21993329142f3d (diff)
downloadpostgresql-653aa603f501aa6e4865105a928cd13082ee7152.tar.gz
postgresql-653aa603f501aa6e4865105a928cd13082ee7152.zip
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.)
Diffstat (limited to 'src/backend/parser/parse_node.c')
-rw-r--r--src/backend/parser/parse_node.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c
index e90f6c9d010..3e20dfff2e2 100644
--- a/src/backend/parser/parse_node.c
+++ b/src/backend/parser/parse_node.c
@@ -271,6 +271,12 @@ transformContainerSubscripts(ParseState *pstate,
* functions and typelem.
*/
sbsroutines = getSubscriptingRoutines(containerType, &elementType);
+ if (!sbsroutines)
+ ereport(ERROR,
+ (errcode(ERRCODE_DATATYPE_MISMATCH),
+ errmsg("cannot subscript type %s because it does not support subscripting",
+ format_type_be(containerType)),
+ parser_errposition(pstate, exprLocation(containerBase))));
/*
* Detect whether any of the indirection items are slice specifiers.