cockroachdb / cockroachdb/cockroach

plpgsql: missing table name in error message

Open
#145,411 1 comment 0 reactions 0 assignees View on GitHub
A-sql-plpgsql A-sql-routine C-bug T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

For some reason, attempting to reference a nonexistent relation in a PL/pgSQL `RETURN QUERY` statement seems to lose the name in the error message:
```
root@localhost:26257/defaultdb> CREATE FUNCTION tp_chk_data(OUT pktb regclass, OUT pkval int, OUT fktb regclass, OUT fkval
-> int)
-> RETURNS SETOF record LANGUAGE plpgsql AS $$
-> BEGIN
-> RETURN QUERY SELECT
-> pk.tableoid::regclass, pk.a, fk.tableoid::regclass, fk.a
-> FROM truncprim pk FULL JOIN truncpart fk USING (a)
-> ORDER BY 2, 4;
-> END
-> $$;
ERROR: relation "NULL" does not exist
SQLSTATE: 42P01
root@localhost:26257/defaultdb> SELECT
-> pk.tableoid::regclass, pk.a, fk.tableoid::regclass, fk.a
-> FROM truncprim pk FULL JOIN truncpart fk USING (a)
-> ORDER BY 2, 4;
ERROR: relation "truncprim" does not exist
SQLSTATE: 42P01
```

Jira issue: CRDB-49885

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.