[MDEV-19214] Virtual column type cannot be converted from one to another - unhelpful error message Created: 2019-04-08  Updated: 2019-04-20

Status: Open
Project: MariaDB Server
Component/s: Server, Virtual Columns
Affects Version/s: 10.3.14
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Manjot Singh (Inactive) Assignee: Sergei Golubchik
Resolution: Unresolved Votes: 3
Labels: None

Issue Links:
Relates
relates to MDEV-14046 Allow ALGORITHM=INPLACE for 10.1 tabl... Closed
relates to MDEV-14341 Allow LOCK=NONE in table-rebuilding A... Open
relates to MDEV-15476 Inplace algorithm doesn't support cha... Stalled
relates to MDEV-16332 Allow ALGORITHM=NOCOPY or INSTANT for... Confirmed
relates to MDEV-17468 Avoid table rebuild on operations on ... Stalled

 Description   

Unable to convert virtual to generated in MariaDB as I can in MySQL:

MariaDB [test]> show create table  bad_with_key\G
*************************** 1. row ***************************
       Table: bad_with_key
Create Table: CREATE TABLE `bad_with_key` (
  `id` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `id_md5` char(32) GENERATED ALWAYS AS (md5(`id`)) VIRTUAL,
  `f` float DEFAULT NULL,
  `ts` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  UNIQUE KEY `id` (`id`,`id_md5`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
1 row in set (0.000 sec)
 
MariaDB [test]> alter table bad_with_key change column id_len id_md5 binary(16) generated always as (unhex(md5(id))) PERSISTENT AFTER id;
ERROR 1054 (42S22): Unknown column 'id_len' in 'bad_with_key'
MariaDB [test]> alter table bad_with_key modify  column id_md5 binary(16) generated always as (unhex(md5(id))) PERSISTENT AFTER id;
ERROR 1907 (HY000): This is not yet supported for generated columns
MariaDB [test]> alter table bad_with_key modify column id_md5 char(32) generated always as (unhex(md5(id))) PERSISTENT AFTER id;
ERROR 1907 (HY000): This is not yet supported for generated columns
MariaDB [test]> alter table bad_with_key modify column id_md5 char(32) generated always as (md5(id)) PERSISTENT AFTER id;
ERROR 1907 (HY000): This is not yet supported for generated columns
MariaDB [test]> alter table bad_with_key modify  column id_md5 binary(16) as (unhex(md5(id))) PERSISTENT AFTER id;
ERROR 1907 (HY000): This is not yet supported for generated columns
MariaDB [test]> alter table bad_with_key modify  column id_md5 char(32) as (unhex(md5(id))) PERSISTENT AFTER id;
ERROR 1907 (HY000): This is not yet supported for generated columns
MariaDB [test]> alter table bad_with_key drop index id;
Query OK, 0 rows affected (0.030 sec)
Records: 0  Duplicates: 0  Warnings: 0
MariaDB [test]> alter table bad_with_key modify  column id_md5 binary(16) generated always as (unhex(md5(id))) PERSISTENT AFTER id;
ERROR 1907 (HY000): This is not yet supported for generated columns
 
MariaDB [test]> show create table bad_with_key
    -> \G
*************************** 1. row ***************************
       Table: bad_with_key
Create Table: CREATE TABLE `bad_with_key` (
  `id` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `id_md5` char(32) GENERATED ALWAYS AS (md5(`id`)) VIRTUAL,
  `f` float DEFAULT NULL,
  `ts` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
1 row in set (0.000 sec)
 
MariaDB [test]> alter table bad_with_key drop column  id_md5;
Query OK, 0 rows affected (0.035 sec)
Records: 0  Duplicates: 0  Warnings: 0
 
MariaDB [test]> alter table bad_with_key add column id_md5 binary(16) generated always as (unhex(md5(id))) PERSISTENT AFTER id;
Query OK, 8 rows affected (0.059 sec)
Records: 8  Duplicates: 0  Warnings: 0



 Comments   
Comment by Elena Stepanova [ 2019-04-08 ]

Which part of it do you consider to be a bug?

Comment by Manjot Singh (Inactive) [ 2019-04-08 ]

The part where I could not alter a VIRTUAL column to be PERSISTENT (and also the other way), without having to drop the column and create it again.

The error message is also very unclear on what is not supported and I had to try many methods to figure it out. The error is similar to "Error: General Error"

Comment by Elena Stepanova [ 2019-04-08 ]

Okay. I hate that message too, on the same reason, so I'm going to keep it as a bug report and assign to serg to see if it's possible to minimize those and produce something useful instead.
The initial problem, unsupported conversion, is a different story and should be apparently a feature request, if it's desired.

Comment by Manjot Singh (Inactive) [ 2019-04-08 ]

I don't see how changing a column type should be FR.

Generated at Thu Feb 08 08:49:54 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.