cockroachdb / cockroachdb/cockroach
Add INACCESSIBLE stage to support multi-statement transactions within the declarative schema changer
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
For multistatement transactions, we may need to add an additional stage that moves a column to INACCESSIBLE before it moves to WRITE_ONLY. This stage will make the column inaccessible in user facing queries but the column won't have any mutation on it. Currently, columns with dependencies like constraints and virtual computed columns move to WRITE_ONLY in the PostCommit phase. By moving them to inaccessible, we can prevent the execution of any other DDL that accesses them within the same transaction.
For example, a slightly contrived scenario is show below:
```
BEGIN;
ALTER TABLE t DROP COLUMN v CASCADE;
CREATE INDEX idx on t ((v+1)); -- should not be allowed and will need to be prevented by moving v to INACCESSIBLE within the StatementPhase
COMMIT;
```
Filed while working on https://github.com/cockroachdb/cockroach/pull/120794
Jira issue: CRDB-36906
Epic CRDB-31472
Contributor guide
Research direction
Start by reading the declarative schema changer work in PR #120794 and tracing the StatementPhase and PostCommit handling described here. Confirm that the INACCESSIBLE transition blocks the shown CREATE INDEX in the same transaction while preserving the intended later WRITE_ONLY behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100