|
I run this script:
SET NAMES latin1;
|
SET @a=2;
|
CREATE OR REPLACE TABLE t1 AS SELECT CAST(1 AS BINARY), CAST(@a AS BINARY), CAST(@b:=3 AS BINARY);
|
SHOW CREATE TABLE t1;
|
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| t1 | CREATE TABLE `t1` (
|
`CAST(1 AS BINARY)` varbinary(1) DEFAULT NULL,
|
`CAST(@a AS BINARY)` varbinary(20) DEFAULT NULL,
|
`CAST(@b:=3 AS BINARY)` varbinary(1) DEFAULT NULL
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
|
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
Looks fine so far.
Now I change the character set to utf8:
SET NAMES utf8;
|
SET @a=2;
|
CREATE OR REPLACE TABLE t1 AS SELECT CAST(1 AS BINARY), CAST(@a AS BINARY), CAST(@b:=3 AS BINARY);
|
SHOW CREATE TABLE t1;
|
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| t1 | CREATE TABLE `t1` (
|
`CAST(1 AS BINARY)` varbinary(1) DEFAULT NULL,
|
`CAST(@a AS BINARY)` varbinary(60) DEFAULT NULL,
|
`CAST(@b:=3 AS BINARY)` varbinary(3) DEFAULT NULL
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
|
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
Notice, the data type has changed for the second and the third columns.
Looks wrong. The behaviour of numeric user variables should not depend on the character set.
|