cockroachdb / cockroachdb/cockroach

Impossible to dereference table valued function call by function name

Open
#167,213 1 comment 0 reactions 0 assignees View on GitHub
A-sql-pgcompat C-bug O-community T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Describe the problem**

When using a table valued function, it should be possible to use the function name just like any other table name in the query.

**To Reproduce**

This works just fine in PostgreSQL

```
CREATE FUNCTION tvf()
RETURNS TABLE (c INTEGER)
AS $$
BEGIN
RETURN QUERY SELECT 1;
END;
$$ LANGUAGE plpgsql;

SELECT tvf.*
FROM tvf();
```

Returning:

```
|c |
|---|
|1 |
```

In CockroachDB, this produces:

> SQL Error [42P01]: ERROR: no data source matches pattern: tvf.*

The workaround is to alias the function call

```
SELECT tvf.*
FROM tvf() as tvf;
```

**Expected behavior**

CockroachDB should work like PostgreSQL here.

**Environment:**
- CockroachDB version: CockroachDB CCL v26.1.1 (x86_64-pc-linux-gnu, built 2026/03/04 12:08:22, go1.25.5)
- Server OS: Linux on Docker on Windows
- Client app: JDBC

Jira issue: CRDB-62305

Epic CRDB-60811

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.