Bug #27071 Some column name changes not possible to do in one step
Submitted: 13 Mar 2007 9:22 Modified: 13 Mar 2007 9:57
Reporter: Heinz Schweitzer (Gold Quality Contributor) Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Administrator Severity:S3 (Non-critical)
Version:1.2.10 OS:Windows (XP)
Assigned to: CPU Architecture:Any

[13 Mar 2007 9:22] Heinz Schweitzer
Description:
Some column name changes not possible to do in one step

You have two fields named 'a' and 'b'

If you want to rename 'a' to 'b' 
and 'b' to a' in one step you just can't because the generated SQL 
renames only one field leading to an error.

The workaround is to do it in three steps just like a swap.

'a' to 'b1'
'b' to 'a'
'b1' to 'b'

NOTE: this gets even more complicated if one or more fields are part of a key.

MySQL Administrator 1.2.10
MySQL Server Information
--------------------------------------------------------------------------------
Connected to MySQL Server Instance
  Username:                root
  Hostname:                localhost
  Port:                    3306
--------------------------------------------------------------------------------
Server Information
  MySQL Version:           MySQL 5.0.27-community-nt via TCP/IP
  Network Name:            localhost
  IP:                      127.0.0.1
--------------------------------------------------------------------------------
Client Information
  Version:                 MySQL Client Version 5.1.11
  Network Name:            xxxxxxxxxxx
  IP:                      xxxxxxxxxxx
  Operating System:        Windows XP
  Hardware:                2x Intel(R) Core(TM)2 CPU         T7200  @ 2.00GHz, 2.0 GB RAM

How to repeat:

Prerequisite:

	Have schema with a table defining three fields

Open MySQL Administrator 1.2.10

From catalogs select a schema you can fool around with.
See screen shot s1

In the right pane activate the 'Schema Tables' tab and open a
table like t2 and say 'edit'

In the table at the top of the table Editor:

Now in one step change field 'b' to 'b1' and 
field 'c' to 'c1'
Say apply changes and you will get (screen shot s2)

ALTER TABLE `test`.`t2` 
CHANGE COLUMN `b` `b1` VARCHAR(45) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
CHANGE COLUMN `c` `c1` VARCHAR(45) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL;

In the 'Confirm Table Edit' dialog press 'Cancel' then say 'Discard Changes'

Now try to rename 'b' to 'c' and 'c' to 'b' you will get (screen shot s3)

ALTER TABLE `test`.`t2` 
CHANGE COLUMN `b` `c` VARCHAR(45) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL;

The expectation here would be to see :

ALTER TABLE `test`.`t2` 
CHANGE COLUMN `b` `c` VARCHAR(45) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
CHANGE COLUMN `c` `b` VARCHAR(45) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL;
[13 Mar 2007 9:23] Heinz Schweitzer
s1

Attachment: s1.jpg (image/jpeg, text), 165.48 KiB.

[13 Mar 2007 9:23] Heinz Schweitzer
s2

Attachment: s2.jpg (image/jpeg, text), 176.30 KiB.

[13 Mar 2007 9:23] Heinz Schweitzer
s3

Attachment: s3.jpg (image/jpeg, text), 169.53 KiB.

[13 Mar 2007 9:57] Sveta Smirnova
Thank you for the reasonable feature request.
[13 Mar 2014 13:35] Omer Barnir
This bug is not scheduled to be fixed at this time.