cockroachdb / cockroachdb/cockroach
sql: track UPDATE SET column dependencies in UDFs and SPs
Open
C-bug
T-sql-queries
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
Related to #102771.
We don't currently track UDF and SP dependencies on `SET` column in `UPDATE` statements in the routine body. This allows these columns to be renamed or dropped, which breaks the routine. For example:
```sql
CREATE TABLE t (
a INT PRIMARY KEY,
b INT
);
CREATE FUNCTION up() RETURNS VOID LANGUAGE SQL AS $$
UPDATE t SET b = 11 WHERE a = 1
$$;
-- This should fail, but it succeeds.
ALTER TABLE t RENAME COLUMN b TO b2;
-- Now, this fails.
SELECT up();
-- ERROR: column "b" does not exist
-- SQLSTATE: 42703
```
Jira issue: CRDB-36895
Contributor guide
Assessment
This issue has not been assessed yet.