[MDEV-11637] CONVERT TO CHARACTER SET does not work if there are no columns to convert Created: 2016-12-22  Updated: 2020-12-01

Status: Open
Project: MariaDB Server
Component/s: Character Sets, Data Definition - Alter Table
Affects Version/s: 10.1, 10.2
Fix Version/s: 10.2

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Found on stackoverflow.

MariaDB [test]> create table t1 (i int) charset latin1;
Query OK, 0 rows affected (0.43 sec)
 
MariaDB [test]> alter table t1 convert to character set utf8;
Query OK, 0 rows affected (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 0
 
MariaDB [test]> show create table t1 \G
*************************** 1. row ***************************
       Table: t1
Create Table: CREATE TABLE `t1` (
  `i` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

This works:

MariaDB [test]> alter table t1 convert to character set utf8, force;
Query OK, 0 rows affected (1.16 sec)
Records: 0  Duplicates: 0  Warnings: 0
 
MariaDB [test]> show create table t1 \G
*************************** 1. row ***************************
       Table: t1
Create Table: CREATE TABLE `t1` (
  `i` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

This also works:

MariaDB [test]> alter table t1 convert to character set utf8, algorithm=copy;
Query OK, 0 rows affected (1.16 sec)
Records: 0  Duplicates: 0  Warnings: 0
 
MariaDB [test]> show create table t1 \G
*************************** 1. row ***************************
       Table: t1
Create Table: CREATE TABLE `t1` (
  `i` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

And this:

MariaDB [test]> create table t1 (c char) charset latin1;
Query OK, 0 rows affected (0.33 sec)
 
MariaDB [test]> alter table t1 convert to character set utf8;
Query OK, 0 rows affected (1.18 sec)               
Records: 0  Duplicates: 0  Warnings: 0
 
MariaDB [test]> show create table t1 \G
*************************** 1. row ***************************
       Table: t1
Create Table: CREATE TABLE `t1` (
  `c` char(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

Not reproducible on MySQL 5.6-5.7.


Generated at Thu Feb 08 07:51:30 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.