cockroachdb / cockroachdb/cockroach
sql: function/procedure type-checking misses invalid composite types
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
When a function or procedure that takes a composite type is called with an argument using `ROW()` syntax, type-checking fails to recognize when too many or too few elements are supplied:
```
CREATE TYPE t AS (x INT, y INT);
CREATE PROCEDURE bar(v t) LANGUAGE SQL AS $$ SELECT 0; $$;
root@localhost:26257/defaultdb> CALL bar(ROW());
CALL
Time: 2ms total (execution 1ms / network 0ms)
root@localhost:26257/defaultdb> CALL bar(ROW(1));
CALL
Time: 2ms total (execution 1ms / network 0ms)
root@localhost:26257/defaultdb> CALL bar(ROW(1,2,3));
CALL
Time: 1ms total (execution 1ms / network 0ms)
```
These examples should be failing with errors like the following:
```
postgres=# CALL bar(ROW());
ERROR: 42846: cannot cast type record to t
LINE 1: CALL bar(ROW());
^
DETAIL: Input has too few columns.
LOCATION: coerce_record_to_complex, parse_coerce.c:1092
```
Jira issue: CRDB-33627
Contributor guide
Assessment
This issue has not been assessed yet.