cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.18k stars 3.82k forks source link

Support `ALTER SCHEMA ... RENAME TO ...` in declarative schema changer #115374

Open Xiang-Gu opened 12 months ago

Xiang-Gu commented 12 months ago

Support ALTER SCHEMA ... RENAME TO ... in declarative schema changer (doc link).

It should include tests in the schema changer testing suites (end-to-end, scbuild, scplan), in a logic test (if not already exists), and enable it in the schemachange workload.

To support this statement, we should probably only need to create a file in the "declarative schema changer builder layer", the entrance point for processing any DDL statement in declarative schema changer. For example, we'd like to add an entry first for this statement (ALTER SCHEMA) in here, and then create a file in scbuild/internal/ (maybe called alter_schema.go) in which we would try to implement the functionality of a ALTER SCHEMA ... RENAME TO. You will probably need logic there to see if it's a statement other than RENAME TO (recall: we also have other stmt like ALTER SCHEMA ... OWNER TO ...), and if so, return an scerror.unimplemented error so we could fall back to legacy schema changer.

The code documentation that describes the various schemachanger packages is at: https://github.com/cockroachdb/cockroach/blob/master/pkg/sql/schemachanger/doc.go

Epic: CRDB-25360

Jira issue: CRDB-33999

Xiang-Gu commented 11 months ago

@annrpom let us start you with https://github.com/cockroachdb/cockroach/issues/116247 instead. That one is similar in difficulty and instructions here also apply there as well.