cockroachdb / cockroachdb/cockroach

sql: qualifying parameter names with a UDF function name fails with an error

Open
#99,720 0 comments 0 reactions 0 assignees View on GitHub
A-sql-routine C-bug O-qa T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Describe the problem**

UDFs in CRDB do not support qualifying parameter names with the name of the UDF.

**To Reproduce**

On `./cockroach demo` on master (or 23.1), run the following:

```
CREATE TABLE emp (name TEXT, salary INT);

CREATE FUNCTION foo(salary text) RETURNS int AS '
SELECT salary FROM emp WHERE salary = foo.salary::int;
' LANGUAGE SQL;
```

This succeeds on Postgres but fails in CRDB with the error:
```
ERROR: no data source matches prefix: foo in this context
SQLSTATE: 42P01
```

**Expected behavior**

This should succeed on CRDB and allow users to use named parameters that may conflict with table or column names used in the UDF statement.

**Environment:**
- CockroachDB version: master (i.e. 23.1 alpha)
- Server OS: MacOS Ventura (Apple M1 Pro)
- Client app: cockroach demo

Jira issue: CRDB-26036

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.