Commit 9f84451d authored by Alexander Barkov's avatar Alexander Barkov

MDEV-15960 Wrong data type on CREATE..SELECT char_or_enum_or_text_spvar

parent c555dc76
......@@ -701,7 +701,7 @@ Table Create Table
t2 CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL,
`b` text DEFAULT NULL,
`c` varchar(1) DEFAULT NULL
`c` char(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP PROCEDURE p2;
DROP PROCEDURE p1;
......
......@@ -462,15 +462,15 @@ t2 CREATE TABLE `t2` (
`dc100` decimal(10,0) DEFAULT NULL,
`dc103` decimal(10,3) DEFAULT NULL,
`dc209` decimal(20,9) DEFAULT NULL,
`cc` varchar(10) DEFAULT NULL,
`cc` char(10) DEFAULT NULL,
`cv` varchar(10) DEFAULT NULL,
`cvu` varchar(10) CHARACTER SET utf8 DEFAULT NULL,
`t1` tinytext DEFAULT NULL,
`t2` text DEFAULT NULL,
`t3` mediumtext DEFAULT NULL,
`t4` longtext DEFAULT NULL,
`enum1` varchar(1) DEFAULT NULL,
`set1` varchar(5) DEFAULT NULL,
`enum1` char(1) DEFAULT NULL,
`set1` char(5) DEFAULT NULL,
`blob1` tinyblob DEFAULT NULL,
`blob2` blob DEFAULT NULL,
`blob3` mediumblob DEFAULT NULL,
......@@ -624,15 +624,15 @@ t2 CREATE TABLE `t2` (
`dc100` decimal(10,0) DEFAULT NULL,
`dc103` decimal(10,3) DEFAULT NULL,
`dc209` decimal(20,9) DEFAULT NULL,
`cc` varchar(10) DEFAULT NULL,
`cc` char(10) DEFAULT NULL,
`cv` varchar(10) DEFAULT NULL,
`cvu` varchar(10) CHARACTER SET utf8 DEFAULT NULL,
`t1` tinytext DEFAULT NULL,
`t2` text DEFAULT NULL,
`t3` mediumtext DEFAULT NULL,
`t4` longtext DEFAULT NULL,
`enum1` varchar(1) DEFAULT NULL,
`set1` varchar(5) DEFAULT NULL,
`enum1` char(1) DEFAULT NULL,
`set1` char(5) DEFAULT NULL,
`blob1` tinyblob DEFAULT NULL,
`blob2` blob DEFAULT NULL,
`blob3` mediumblob DEFAULT NULL,
......@@ -1042,7 +1042,7 @@ t1 CREATE TABLE `t1` (
`a_flt0` float DEFAULT NULL,
`a_dbl0` double DEFAULT NULL,
`a_bit3` bit(3) DEFAULT NULL,
`a_enum0` varchar(1) DEFAULT NULL,
`a_enum0` char(1) DEFAULT NULL,
`a_varchar10` varchar(10) DEFAULT NULL,
`a_text1` text DEFAULT NULL,
`a_tinytext1` tinytext DEFAULT NULL,
......@@ -1060,7 +1060,7 @@ t1 CREATE TABLE `t1` (
`aa_flt0` float DEFAULT NULL,
`aa_dbl0` double DEFAULT NULL,
`aa_bit3` bit(3) DEFAULT NULL,
`aa_enum0` varchar(1) DEFAULT NULL,
`aa_enum0` char(1) DEFAULT NULL,
`aa_varchar10` varchar(10) DEFAULT NULL,
`aa_text1` text DEFAULT NULL,
`aa_tinytext1` tinytext DEFAULT NULL,
......
......@@ -1795,8 +1795,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`var` varchar(1) DEFAULT NULL,
`rec.var` varchar(1) DEFAULT NULL
`var` char(1) DEFAULT NULL,
`rec.var` char(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
DROP PROCEDURE p1;
......@@ -1805,8 +1805,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`var` varbinary(1) DEFAULT NULL,
`rec.var` varbinary(1) DEFAULT NULL
`var` binary(1) DEFAULT NULL,
`rec.var` binary(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
DROP PROCEDURE p1;
......@@ -1815,8 +1815,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`var` varchar(1) DEFAULT NULL,
`rec.var` varchar(1) DEFAULT NULL
`var` char(1) DEFAULT NULL,
`rec.var` char(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
DROP PROCEDURE p1;
......@@ -1825,8 +1825,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`var` varchar(10) DEFAULT NULL,
`rec.var` varchar(10) DEFAULT NULL
`var` char(10) DEFAULT NULL,
`rec.var` char(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
DROP PROCEDURE p1;
......@@ -1835,8 +1835,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`var` varchar(10) CHARACTER SET utf8 DEFAULT NULL,
`rec.var` varchar(10) CHARACTER SET utf8 DEFAULT NULL
`var` char(10) CHARACTER SET utf8 DEFAULT NULL,
`rec.var` char(10) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
DROP PROCEDURE p1;
......@@ -1845,8 +1845,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`var` varbinary(10) DEFAULT NULL,
`rec.var` varbinary(10) DEFAULT NULL
`var` binary(10) DEFAULT NULL,
`rec.var` binary(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
DROP PROCEDURE p1;
......@@ -2084,8 +2084,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`var` mediumtext CHARACTER SET utf8 DEFAULT NULL,
`rec.var` mediumtext CHARACTER SET utf8 DEFAULT NULL
`var` text CHARACTER SET utf8 DEFAULT NULL,
`rec.var` text CHARACTER SET utf8 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
DROP PROCEDURE p1;
......@@ -2094,8 +2094,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`var` text CHARACTER SET utf8 DEFAULT NULL,
`rec.var` text CHARACTER SET utf8 DEFAULT NULL
`var` tinytext CHARACTER SET utf8 DEFAULT NULL,
`rec.var` tinytext CHARACTER SET utf8 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
DROP PROCEDURE p1;
......@@ -2104,8 +2104,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`var` longtext CHARACTER SET utf8 DEFAULT NULL,
`rec.var` longtext CHARACTER SET utf8 DEFAULT NULL
`var` mediumtext CHARACTER SET utf8 DEFAULT NULL,
`rec.var` mediumtext CHARACTER SET utf8 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
DROP PROCEDURE p1;
......
......@@ -1241,3 +1241,72 @@ t1 CREATE TABLE "t1" (
"a" year(4) DEFAULT NULL
)
DROP PROCEDURE p1;
#
# MDEV-15960 Wrong data type on CREATE..SELECT char_or_enum_or_text_spvar
#
BEGIN NOT ATOMIC
DECLARE var TINYTEXT CHARACTER SET utf8;
CREATE TABLE t1 AS SELECT var;
END;
$$
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"var" tinytext CHARACTER SET utf8 DEFAULT NULL
)
DROP TABLE t1;
BEGIN NOT ATOMIC
DECLARE var TEXT CHARACTER SET utf8;
CREATE TABLE t1 AS SELECT var;
END;
$$
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"var" text CHARACTER SET utf8 DEFAULT NULL
)
DROP TABLE t1;
BEGIN NOT ATOMIC
DECLARE var MEDIUMTEXT CHARACTER SET utf8;
CREATE TABLE t1 AS SELECT var;
END;
$$
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"var" mediumtext CHARACTER SET utf8 DEFAULT NULL
)
DROP TABLE t1;
BEGIN NOT ATOMIC
DECLARE var LONGTEXT CHARACTER SET utf8;
CREATE TABLE t1 AS SELECT var;
END;
$$
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"var" longtext CHARACTER SET utf8 DEFAULT NULL
)
DROP TABLE t1;
BEGIN NOT ATOMIC
DECLARE var CHAR(1);
CREATE TABLE t1 AS SELECT var;
END;
$$
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"var" char(1) DEFAULT NULL
)
DROP TABLE t1;
BEGIN NOT ATOMIC
DECLARE var ENUM('a');
CREATE TABLE t1 AS SELECT var;
END;
$$
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"var" char(1) DEFAULT NULL
)
DROP TABLE t1;
......@@ -1536,3 +1536,70 @@ $$
DELIMITER ;$$
CALL p1;
DROP PROCEDURE p1;
--echo #
--echo # MDEV-15960 Wrong data type on CREATE..SELECT char_or_enum_or_text_spvar
--echo #
DELIMITER $$;
BEGIN NOT ATOMIC
DECLARE var TINYTEXT CHARACTER SET utf8;
CREATE TABLE t1 AS SELECT var;
END;
$$
DELIMITER ;$$
SHOW CREATE TABLE t1;
DROP TABLE t1;
DELIMITER $$;
BEGIN NOT ATOMIC
DECLARE var TEXT CHARACTER SET utf8;
CREATE TABLE t1 AS SELECT var;
END;
$$
DELIMITER ;$$
SHOW CREATE TABLE t1;
DROP TABLE t1;
DELIMITER $$;
BEGIN NOT ATOMIC
DECLARE var MEDIUMTEXT CHARACTER SET utf8;
CREATE TABLE t1 AS SELECT var;
END;
$$
DELIMITER ;$$
SHOW CREATE TABLE t1;
DROP TABLE t1;
DELIMITER $$;
BEGIN NOT ATOMIC
DECLARE var LONGTEXT CHARACTER SET utf8;
CREATE TABLE t1 AS SELECT var;
END;
$$
DELIMITER ;$$
SHOW CREATE TABLE t1;
DROP TABLE t1;
DELIMITER $$;
BEGIN NOT ATOMIC
DECLARE var CHAR(1);
CREATE TABLE t1 AS SELECT var;
END;
$$
DELIMITER ;$$
SHOW CREATE TABLE t1;
DROP TABLE t1;
DELIMITER $$;
BEGIN NOT ATOMIC
DECLARE var ENUM('a');
CREATE TABLE t1 AS SELECT var;
END;
$$
DELIMITER ;$$
SHOW CREATE TABLE t1;
DROP TABLE t1;
......@@ -21,7 +21,7 @@ Table Create Table
t2 CREATE TABLE "t2" (
"a" int(11) DEFAULT NULL,
"b" text DEFAULT NULL,
"c" varchar(1) DEFAULT NULL
"c" char(1) DEFAULT NULL
)
DROP PROCEDURE p2;
DROP PROCEDURE p1;
......
......@@ -1872,8 +1872,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"var" varchar(1) DEFAULT NULL,
"rec.var" varchar(1) DEFAULT NULL
"var" char(1) DEFAULT NULL,
"rec.var" char(1) DEFAULT NULL
)
DROP TABLE t1;
DROP PROCEDURE p1;
......@@ -1882,8 +1882,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"var" varbinary(1) DEFAULT NULL,
"rec.var" varbinary(1) DEFAULT NULL
"var" binary(1) DEFAULT NULL,
"rec.var" binary(1) DEFAULT NULL
)
DROP TABLE t1;
DROP PROCEDURE p1;
......@@ -1892,8 +1892,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"var" varchar(1) DEFAULT NULL,
"rec.var" varchar(1) DEFAULT NULL
"var" char(1) DEFAULT NULL,
"rec.var" char(1) DEFAULT NULL
)
DROP TABLE t1;
DROP PROCEDURE p1;
......@@ -1902,8 +1902,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"var" varchar(10) DEFAULT NULL,
"rec.var" varchar(10) DEFAULT NULL
"var" char(10) DEFAULT NULL,
"rec.var" char(10) DEFAULT NULL
)
DROP TABLE t1;
DROP PROCEDURE p1;
......@@ -1912,8 +1912,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"var" varchar(10) CHARACTER SET utf8 DEFAULT NULL,
"rec.var" varchar(10) CHARACTER SET utf8 DEFAULT NULL
"var" char(10) CHARACTER SET utf8 DEFAULT NULL,
"rec.var" char(10) CHARACTER SET utf8 DEFAULT NULL
)
DROP TABLE t1;
DROP PROCEDURE p1;
......@@ -1922,8 +1922,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"var" varbinary(10) DEFAULT NULL,
"rec.var" varbinary(10) DEFAULT NULL
"var" binary(10) DEFAULT NULL,
"rec.var" binary(10) DEFAULT NULL
)
DROP TABLE t1;
DROP PROCEDURE p1;
......@@ -2161,8 +2161,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"var" mediumtext CHARACTER SET utf8 DEFAULT NULL,
"rec.var" mediumtext CHARACTER SET utf8 DEFAULT NULL
"var" text CHARACTER SET utf8 DEFAULT NULL,
"rec.var" text CHARACTER SET utf8 DEFAULT NULL
)
DROP TABLE t1;
DROP PROCEDURE p1;
......@@ -2171,8 +2171,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"var" text CHARACTER SET utf8 DEFAULT NULL,
"rec.var" text CHARACTER SET utf8 DEFAULT NULL
"var" tinytext CHARACTER SET utf8 DEFAULT NULL,
"rec.var" tinytext CHARACTER SET utf8 DEFAULT NULL
)
DROP TABLE t1;
DROP PROCEDURE p1;
......@@ -2181,8 +2181,8 @@ CALL p1();
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"var" longtext CHARACTER SET utf8 DEFAULT NULL,
"rec.var" longtext CHARACTER SET utf8 DEFAULT NULL
"var" mediumtext CHARACTER SET utf8 DEFAULT NULL,
"rec.var" mediumtext CHARACTER SET utf8 DEFAULT NULL
)
DROP TABLE t1;
DROP PROCEDURE p1;
......
......@@ -1704,15 +1704,15 @@ t2 CREATE TABLE "t2" (
"dc100" decimal(10,0) DEFAULT NULL,
"dc103" decimal(10,3) DEFAULT NULL,
"dc209" decimal(20,9) DEFAULT NULL,
"cc" varchar(10) DEFAULT NULL,
"cc" char(10) DEFAULT NULL,
"cv" varchar(10) DEFAULT NULL,
"cvu" varchar(10) CHARACTER SET utf8 DEFAULT NULL,
"t1" tinytext DEFAULT NULL,
"t2" text DEFAULT NULL,
"t3" mediumtext DEFAULT NULL,
"t4" longtext DEFAULT NULL,
"enum1" varchar(1) DEFAULT NULL,
"set1" varchar(5) DEFAULT NULL,
"enum1" char(1) DEFAULT NULL,
"set1" char(5) DEFAULT NULL,
"blob1" tinyblob DEFAULT NULL,
"blob2" longblob DEFAULT NULL,
"blob3" mediumblob DEFAULT NULL,
......@@ -1866,15 +1866,15 @@ t2 CREATE TABLE "t2" (
"dc100" decimal(10,0) DEFAULT NULL,
"dc103" decimal(10,3) DEFAULT NULL,
"dc209" decimal(20,9) DEFAULT NULL,
"cc" varchar(10) DEFAULT NULL,
"cc" char(10) DEFAULT NULL,
"cv" varchar(10) DEFAULT NULL,
"cvu" varchar(10) CHARACTER SET utf8 DEFAULT NULL,
"t1" tinytext DEFAULT NULL,
"t2" text DEFAULT NULL,
"t3" mediumtext DEFAULT NULL,
"t4" longtext DEFAULT NULL,
"enum1" varchar(1) DEFAULT NULL,
"set1" varchar(5) DEFAULT NULL,
"enum1" char(1) DEFAULT NULL,
"set1" char(5) DEFAULT NULL,
"blob1" tinyblob DEFAULT NULL,
"blob2" longblob DEFAULT NULL,
"blob3" mediumblob DEFAULT NULL,
......@@ -2382,7 +2382,7 @@ t1 CREATE TABLE "t1" (
"a_flt0" float DEFAULT NULL,
"a_dbl0" double DEFAULT NULL,
"a_bit3" bit(3) DEFAULT NULL,
"a_enum0" varchar(1) DEFAULT NULL,
"a_enum0" char(1) DEFAULT NULL,
"a_varchar10" varchar(10) DEFAULT NULL,
"a_text1" text DEFAULT NULL,
"a_tinytext1" tinytext DEFAULT NULL,
......@@ -2400,7 +2400,7 @@ t1 CREATE TABLE "t1" (
"aa_flt0" float DEFAULT NULL,
"aa_dbl0" double DEFAULT NULL,
"aa_bit3" bit(3) DEFAULT NULL,
"aa_enum0" varchar(1) DEFAULT NULL,
"aa_enum0" char(1) DEFAULT NULL,
"aa_varchar10" varchar(10) DEFAULT NULL,
"aa_text1" text DEFAULT NULL,
"aa_tinytext1" tinytext DEFAULT NULL,
......
......@@ -2505,7 +2505,7 @@ class Item_splocal :public Item_sp_variable,
based on result_type(), which is less exact.
*/
Field *create_field_for_create_select(TABLE *table)
{ return tmp_table_field_from_field_type(table); }
{ return create_table_field_from_handler(table); }
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment