[MDEV-6390] CONVERT TO CHARACTER SET utf8 doesn't change DEFAULT CHARSET Created: 2014-06-26  Updated: 2020-08-25  Resolved: 2017-02-26

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table
Affects Version/s: 10.0.12, 10.1.0
Fix Version/s: 10.0.30

Type: Bug Priority: Major
Reporter: Daniel Black Assignee: Alexey Botchkov
Resolution: Fixed Votes: 0
Labels: upstream-fixed
Environment:

debian6 x86_64


Issue Links:
Duplicate
is duplicated by MDEV-9982 "CONVERT TO CHARACTER SET" has no eff... Closed
Sprint: 10.0.30

 Description   

in the case where no text columns

> show create table seller_counters;
| seller_counters | CREATE TABLE `seller_counters` (
  `seller_id` int(11) NOT NULL,
  `category_id` int(11) NOT NULL,
  `counter` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`seller_id`,`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
 
> select count(*) from seller_counters;
| count(*) |
|     1859 |
 
> alter table seller_counters CONVERT TO CHARACTER SET utf8;
Query OK, 0 rows affected (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 0
 
> show create table seller_counters;
| Table           | Create Table                                                                                                                                                                                                                  |
| seller_counters | CREATE TABLE `seller_counters` (
  `seller_id` int(11) NOT NULL,
  `category_id` int(11) NOT NULL,
  `counter` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`seller_id`,`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |



 Comments   
Comment by Elena Stepanova [ 2014-06-30 ]

Also reproducible on current MySQL 5.6. It happens when there are no char columns in the table.

Daniel,

Will you report the bug upstream, or should I do it on your behalf?

Comment by Daniel Black [ 2014-07-01 ]

done: http://bugs.mysql.com/bug.php?id=73153

Comment by Elena Stepanova [ 2016-05-13 ]

Apparently the upstream bug was fixed in 5.6 by this commit:

commit 11c684f91e3ae34ffa6cce2edffd181f702c8e46
Author: Nisha Gopalakrishnan <nisha.gopalakrishnan@oracle.com>
Date:   Thu Dec 24 16:39:33 2015 +0530
 
    Bug#21345391: ALTER TABLE ... CONVERT TO CHARACTER SET NOT EFFECT
                  AND REMAIN A TEMP TABLE
    
    Analysis:
    =========
    ALTER TABLE, CONVERT TO CHARACTER SET operation remains
    ineffective if
    a) Table contains only numerical data types.
    b) Algorithm used is INPLACE.
    Also the temporary '.frm' file created during the
    operation is not cleaned up.
    
    For the above ALTER TABLE operation, appropriate handler
    flag is not set, resulting in a no-op. Hence the operation
    remains ineffective and the CHARACTER SET is not altered.
    Also the temporary '.frm' file created was not cleaned up
    at the end of no-op.
    
    Note: The above operation for tables having character
    data types reports an appropriate error.
    
    Fix:
    ===
    a) Removed the ALTER_CONVERT flag used by parser
       to flag the CONVERT TO CHARACTER SET operation
       since it has similar use as that of ALTER_OPTIONS.
    b) ALTER_OPTIONS is now used to indicate the CONVERT
       TO CHARACTER SET operation as well.
    c) Added code to clean up the temporary '.frm' file
       created during no-op.

Comment by Alexey Botchkov [ 2017-02-26 ]

http://lists.askmonty.org/pipermail/commits/2017-February/010754.html

Comment by Daniel Black [ 2017-02-27 ]

Thanks holyfoot for fixing this.

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