Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple columns in the same table to be modified within the same ALTER statement (one operation) #80578

Open
daniel-crlabs opened this issue Apr 26, 2022 · 1 comment
Labels
A-sql-execution Relating to SQL execution. A-sql-executor SQL txn logic C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@daniel-crlabs
Copy link
Contributor

daniel-crlabs commented Apr 26, 2022

Is your feature request related to a problem? Please describe.

This is a feature request.
Currently we are not able to make multiple modifications to different columns on the same table within the same ALTER statement. We need to issue multiple ALTER statements to the same table in order to make multiple changes. This can be problematic, especially for very large tables, as the "downtime" for the table affected can be quite substantial.

The following fails when modifying 2 existing columns simultaneously within the same alter table statement on the same table:

root@lab-kub01:30007/test> alter table t3 alter column c3 type INT8, alter column c4 type INT8;
ERROR: unimplemented: ALTER COLUMN TYPE cannot be used in combination with other ALTER TABLE commands
SQLSTATE: 0A000
HINT: You have attempted to use a feature that is not yet implemented.
See: https://go.crdb.dev/issue-v/49351/v21.2

The following works, if we are adding 2 new columns:

root@lab-kub01:30007/test> alter table t3 ADD COLUMN c5 varchar, ADD COLUMN c6 int;
ALTER TABLE


Time: 568ms total (execution 568ms / network 1ms)

Describe the solution you'd like

The solution here would be to allow something other RDBMS already do (PostgreSQL does as well) which is allow someone to make multiple changes to the same table within the same ALTER statement.

i.e. This should work

alter table t3 alter column c3 type INT8, alter column c4 type INT8;

Describe alternatives you've considered

The current alternative is to issue 2 separate alter table statements as shown below:

root@lab-kub01:30007/test> alter table t3 alter column c3 type INT8;
NOTICE: ALTER COLUMN TYPE changes are finalized asynchronously; further schema changes on this table may be restricted until the job completes; some writes to the altered column may be rejected until the schema change is finalized
ALTER TABLE

Time: 1.185s total (execution 1.184s / network 0.001s)

root@lab-kub01:30007/test> alter table t3 alter column c4 type INT8;
ALTER TABLE


Time: 199ms total (execution 198ms / network 1ms)

root@lab-kub01:30007/test>

Jira issue: CRDB-15339

@daniel-crlabs daniel-crlabs added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-schema-deprecated Use T-sql-foundations instead labels Apr 26, 2022
@ajwerner
Copy link
Contributor

Relates to #49329, seems like a duplicate of #47137.

@jlinder jlinder added sync-me and removed sync-me labels May 20, 2022
@daniel-crlabs daniel-crlabs added A-sql-execution Relating to SQL execution. A-sql-executor SQL txn logic T-sql-queries SQL Queries Team T-sql-execution labels Jul 22, 2022
@healthy-pod healthy-pod added T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) and removed T-sql-schema-deprecated Use T-sql-foundations instead labels May 17, 2023
@exalate-issue-sync exalate-issue-sync bot removed the T-sql-queries SQL Queries Team label May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-execution Relating to SQL execution. A-sql-executor SQL txn logic C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
None yet
Development

No branches or pull requests

5 participants