cockroachdb / cockroachdb/cockroach

sql: allow table and column renaming if only references are in udfs

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

Description

Postgres allows tables and columns to be renamed using `ALTER TABLE` even if they are referenced by UDFs. For example, the following commands succeed in postgres:

```
CREATE TABLE t_twocol (a INT, b INT);

CREATE FUNCTION f_unqualified_twocol() RETURNS t_twocol AS
$$
SELECT * FROM t_twocol;
$$ LANGUAGE SQL;

-- CRDB failure: cannot rename column "a" because function "f_unqualified_twocol" depends on it
ALTER TABLE t_twocol RENAME COLUMN a TO d;

-- CRDB failure: cannot rename relation "t_twocol" because function "f_unqualified_twocol" depends on it
ALTER TABLE t_twocol RENAME TO t_twocol_prime;
```

This should be possible once we're able to rewrite queries with table and column IDs.

Jira issue: CRDB-27189

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.