cockroachdb / cockroachdb/cockroach
sql: comparison between anyelement UDF parameters causes error
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Describe the problem**
When I try to create a function that performs a comparison between anyelement parameters, CRDB returns an error.
**To Reproduce**
In `cockroach demo` on master / 23.1, run the following:
```
CREATE FUNCTION is_greater(anyelement, anyelement) RETURNS boolean AS $$
SELECT $1 > $2;
$$ LANGUAGE SQL;
```
This succeeds on Postgres, but on CRDB it fails with the error:
```
ERROR: ambiguous comparison operator: >
SQLSTATE: 42725
HINT: candidates are:
>(bool, bool) -> bool
...
```
**Expected behavior**
Creating this function should succeed, and calling it with valid arguments should succeed too.
Jira issue: CRDB-26310
Contributor guide
Research direction
Start by reproducing the CREATE FUNCTION example in cockroach demo on master or 23.1 and inspect the SQL function type-resolution and comparison-operator paths involved in the reported ambiguous operator error. Done means the function can be created and called with valid arguments, matching the stated PostgreSQL behavior, with regression coverage for the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100