dolt icon indicating copy to clipboard operation
dolt copied to clipboard

Dolt should block column renames when another column has a default dependency on it.

Open VinaiRachakonda opened this issue 2 years ago • 1 comments

Consider the following table

CREATE TABLE `test` (
  `pk` bigint NOT NULL,
  `v2` int NOT NULL DEFAULT '100',
  `v3` int DEFAULT ((`v2` + 1)),
  PRIMARY KEY (`pk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Running the query alter table test rename column v2 to mycol in MySQL returns the following

ERROR 3766 (HY000): Column 'v2' of table 'test' has a default value expression dependency and cannot be dropped or renamed.

The same query in Dolt successfully executes and modifies the schema

CREATE TABLE `test` (
  `pk` bigint NOT NULL,
  `mycol` int NOT NULL DEFAULT "100",
  `v3` int DEFAULT ((mycol + 1)),
  PRIMARY KEY (`pk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

VinaiRachakonda avatar Mar 28 '22 20:03 VinaiRachakonda

Skipped enginetest here

VinaiRachakonda avatar Aug 08 '22 22:08 VinaiRachakonda