Details
-
Bug
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL)
-
None
Description
In this script:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a INT, b ENUM('2','3'));
|
INSERT INTO t1 VALUES(2,'2');
|
UPDATE t1 SET b=a;
|
SELECT b FROM t1;
|
copying is done using val_int() method of the field "a", which returns 2 and then further converts to ENUM value[2], which is '3'. So the script returns:
+------+
|
| b |
|
+------+
|
| 3 |
|
+------+
|
The same behavior is demonstrated in this script:
DROP TABLE IF EXISTS t1,t2;
|
CREATE TABLE t1 (a INT);
|
INSERT INTO t1 VALUES (2);
|
CREATE TABLE t2 (b ENUM('2','3'));
|
INSERT INTO t2 SELECT * FROM t1;
|
SELECT *FROM t2;
|
+------+
|
| b |
|
+------+
|
| 3 |
|
+------+
|
Now if I use ALTER:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a INT);
|
INSERT INTO t1 VALUES(2);
|
ALTER TABLE t1 CHANGE a b ENUM('2','3');
|
SELECT * FROM t1;
|
it goes through val_str() of the field "a" which returns string '2', so the result is:
+------+
|
| b |
|
+------+
|
| 2 |
|
+------+
|
All three cases should return the same result.