Bug #20695 Charset introducer overrides charset definition for column
Submitted: 26 Jun 2006 13:13 Modified: 14 Sep 2006 3:43
Reporter: Alexander Nozdrin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Charsets Severity:S3 (Non-critical)
Version:4.1BK/5.0BK/5.1BK OS:Linux (Suse Linux 10)
Assigned to: Ramil Kalimullin CPU Architecture:Any

[26 Jun 2006 13:13] Alexander Nozdrin
Description:
Charset introducer for column default value in CREATE TABLE
overrides specified character set for the column.

How to repeat:
mysql> CREATE TABLE t1(c VARCHAR(25) CHARACTER SET koi8r default "qqq");
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW CREATE TABLE t1 \G
*************************** 1. row ***************************
       Table: t1
Create Table: CREATE TABLE `t1` (
  `c` varchar(25) character set koi8r default 'qqq'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

----------------------------------------------------------------------------

mysql> CREATE TABLE t2(c VARCHAR(25) CHARACTER SET koi8r default _cp1251 "qqq");
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW CREATE TABLE t2 \G
*************************** 1. row ***************************
       Table: t2
Create Table: CREATE TABLE `t2` (
  `c` varchar(25) character set cp1251 default 'qqq'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

----------------------------------------------------------------------------

mysql> CREATE TABLE t3(c VARCHAR(25) default "qqq");
Query OK, 0 rows affected (0.01 sec)

mysql> SHOW CREATE TABLE t3 \G
*************************** 1. row ***************************
       Table: t3
Create Table: CREATE TABLE `t3` (
  `c` varchar(25) default 'qqq'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

----------------------------------------------------------------------------

mysql> CREATE TABLE t4(c VARCHAR(25) default _cp1251 "qqq");
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW CREATE TABLE t4 \G
*************************** 1. row ***************************
       Table: t4
Create Table: CREATE TABLE `t4` (
  `c` varchar(25) character set cp1251 default 'qqq'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

----------------------------------------------------------------------------

mysql> select version();
+--------------+
| version()    |
+--------------+
| 5.0.23-debug |
+--------------+
1 row in set (0.00 sec)
[26 Jun 2006 14:54] MySQL Verification Team
Thank you for the bug report. Verified as described.
[15 Aug 2006 10:22] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/10447

ChangeSet@1.2530, 2006-08-15 15:24:07+05:00, ramil@mysql.com +6 -0
  Fix for bug #20695: Charset introducer overrides charset definition for column.
    - if there are two character set definitions in the column declaration,
      we replace the first one with the second one as we store both in the LEX->charset
      slot. Add a separate slot to the LEX structure to store underscore charset.
    - convert default values to the column charset of STRING, VARSTRING fields 
      if necessary as well.
[15 Aug 2006 10:32] Alexander Barkov
The patch looks ok to push.
[16 Aug 2006 15:50] Konstantin Osipov
Approved by email.
[17 Aug 2006 10:30] Ramil Kalimullin
fixed in 4.1.22
[18 Aug 2006 14:26] Jon Stephens
We can't document until we have 3-part version numbers for all affected versions, and this is tagged 5.1. Thanks!
[2 Sep 2006 9:18] Timothy Smith
Pushed to 5.0 (will be in 5.0.25)

TODO: Merge to 5.1
[13 Sep 2006 1:59] Paul DuBois
Noted in 4.1.22, 5.0.25 changelogs.

If a column definition contained a character set declaration, but a DEFAULT value began with an introducer, the introducer character set was used as the column character set.

Resetting report to NDI pending merge into 5.1.
[13 Sep 2006 8:23] Timothy Smith
Pushed to 5.1.12
[14 Sep 2006 3:43] Paul DuBois
Noted in 5.1.12 changelog.