cockroachdb / cockroachdb/cockroach
sql: update Index and Column IDs in UDF/View statements after `TRUNCATE`, `ALTER COLUMN TYPE` and `REFRESH MATERIALIZED VIEW`
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
We're moving into the direction of rewriting UDF/View statements to reference objects by IDs. However, certain schema changes would cause ID changes. As of this issue is created, the following things can cause ID changes:
1. `TRUNCATE` would cause index ID changes because we create new empty indexes (which has new IDs) and drop old indexes.
2. `ALTER COLUMN TYPE`. In certain cases of this statement, a new column (with new id) is created to replace the old one and requires a backfill.
3. `REFRESH MATERIALIZED VIEW` also creates new indexes.
4. ALTER PRIMARY KEY would rewrite indexes sometimes
5. ALTER TABLE ADD COLUMN would cause a new primary index
This need to be done when we support rewriting UDF/View to reference column and index by IDs.
Note: backup/restore of course would cause ID changes, but it's more about descriptor ID changes, and should be handle within the same PR doing the UDF/View statement rewrite. Like in [this commit](https://github.com/cockroachdb/cockroach/pull/101755/commits/0cdf46213c418f670a6066149f6bd791d52d64ad).
Jira issue: CRDB-30181
Epic CRDB-19496
Contributor guide
Assessment
This issue has not been assessed yet.