1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
|
#
# MDEV-16325 CREATE..SELECT..UNION creates a wrong field type for old varchar
#
SET character_set_database=latin1;
CREATE PROCEDURE p1(col VARCHAR(32))
BEGIN
EXECUTE IMMEDIATE REPLACE('CREATE TABLE t2_simple CHARSET=latin1 AS SELECT col FROM t1old','col',col);
SHOW CREATE TABLE t2_simple;
DROP TABLE t2_simple;
EXECUTE IMMEDIATE REPLACE('CREATE TABLE t2_union_vv CHARSET=latin1 AS SELECT col FROM t1old UNION SELECT col FROM t1old','col',col);
SHOW CREATE TABLE t2_union_vv;
DROP TABLE t2_union_vv;
EXECUTE IMMEDIATE REPLACE('CREATE TABLE t2_union_vn CHARSET=latin1 AS SELECT col FROM t1old UNION SELECT NULL','col',col);
SHOW CREATE TABLE t2_union_vn;
DROP TABLE t2_union_vn;
EXECUTE IMMEDIATE REPLACE('CREATE TABLE t2_union_nv CHARSET=latin1 AS SELECT NULL AS col UNION SELECT col FROM t1old','col',col);
SHOW CREATE TABLE t2_union_nv;
DROP TABLE t2_union_nv;
EXECUTE IMMEDIATE REPLACE('CREATE TABLE t2 CHARSET=latin1 AS SELECT
COALESCE(col),
COALESCE(col,col),
COALESCE(col,NULL),
COALESCE(NULL,col)
FROM t1old', 'col', col);
SHOW CREATE TABLE t2;
DROP TABLE t2;
EXECUTE IMMEDIATE REPLACE('CREATE TABLE t2 CHARSET=latin1 AS SELECT
LEAST(col,col),
LEAST(col,NULL),
LEAST(NULL,col)
FROM t1old','col',col);
SHOW CREATE TABLE t2;
DROP TABLE t2;
END;
$$
TRUNCATE TABLE t1old;
SHOW CREATE TABLE t1old;
Table Create Table
t1old CREATE TABLE `t1old` (
`v` varchar(30)/*old*/ DEFAULT NULL,
`c` char(3) DEFAULT NULL,
`e` enum('abc','def','ghi') DEFAULT NULL,
`t` text DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
CALL p1('v');
Table Create Table
t2_simple CREATE TABLE `t2_simple` (
`v` varchar(30) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
Table Create Table
t2_union_vv CREATE TABLE `t2_union_vv` (
`v` varchar(30) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
Table Create Table
t2_union_vn CREATE TABLE `t2_union_vn` (
`v` varchar(30) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
Table Create Table
t2_union_nv CREATE TABLE `t2_union_nv` (
`v` varchar(30) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
Table Create Table
t2 CREATE TABLE `t2` (
`COALESCE(v)` varchar(30) DEFAULT NULL,
`COALESCE(v,v)` varchar(30) DEFAULT NULL,
`COALESCE(v,NULL)` varchar(30) DEFAULT NULL,
`COALESCE(NULL,v)` varchar(30) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
Table Create Table
t2 CREATE TABLE `t2` (
`LEAST(v,v)` varchar(30) DEFAULT NULL,
`LEAST(v,NULL)` varchar(30) DEFAULT NULL,
`LEAST(NULL,v)` varchar(30) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1old;
TRUNCATE TABLE t1old;
SHOW CREATE TABLE t1old;
Table Create Table
t1old CREATE TABLE `t1old` (
`a` varbinary(255)/*old*/ DEFAULT NULL,
`b` varchar(255)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
CALL p1('a');
Table Create Table
t2_simple CREATE TABLE `t2_simple` (
`a` varbinary(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
Table Create Table
t2_union_vv CREATE TABLE `t2_union_vv` (
`a` varbinary(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
Table Create Table
t2_union_vn CREATE TABLE `t2_union_vn` (
`a` varbinary(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
Table Create Table
t2_union_nv CREATE TABLE `t2_union_nv` (
`a` varbinary(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
Table Create Table
t2 CREATE TABLE `t2` (
`COALESCE(a)` varbinary(255) DEFAULT NULL,
`COALESCE(a,a)` varbinary(255) DEFAULT NULL,
`COALESCE(a,NULL)` varbinary(255) DEFAULT NULL,
`COALESCE(NULL,a)` varbinary(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
Table Create Table
t2 CREATE TABLE `t2` (
`LEAST(a,a)` varbinary(255) DEFAULT NULL,
`LEAST(a,NULL)` varbinary(255) DEFAULT NULL,
`LEAST(NULL,a)` varbinary(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1old;
DROP PROCEDURE p1;
SET character_set_database=DEFAULT;
#
# Start of 10.11 tests
#
#
# MDEV-33442 REPAIR TABLE corrupts UUIDs
#
CREATE PROCEDURE show_table()
BEGIN
SHOW CREATE TABLE t1;
SELECT VERSION FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
SELECT * FROM t1 ORDER BY a,b;
END;
$$
# Upgrade using REPAIR
TRUNCATE TABLE t1;
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255)/*old*/ DEFAULT NULL,
`b` varchar(255)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
9
a b
CHECK TABLE t1 FOR UPGRADE;
Table Op Msg_type Msg_text
test.t1 check error Table rebuild required. Please do "ALTER TABLE `t1` FORCE" or dump/reload to fix it!
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255)/*old*/ DEFAULT NULL,
`b` varchar(255)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
9
a b
CHECK TABLE t1 FOR UPGRADE;
Table Op Msg_type Msg_text
test.t1 check error Table rebuild required. Please do "ALTER TABLE `t1` FORCE" or dump/reload to fix it!
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255)/*old*/ DEFAULT NULL,
`b` varchar(255)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
9
a b
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair status OK
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255) DEFAULT NULL,
`b` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
CHECK TABLE t1 FOR UPGRADE;
Table Op Msg_type Msg_text
test.t1 check status OK
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255) DEFAULT NULL,
`b` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
DROP TABLE t1;
# Upgrade using ALTER, adding a table COMMENT
TRUNCATE TABLE t1;
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255)/*old*/ DEFAULT NULL,
`b` varchar(255)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
9
a b
# ALTER..INPLACE should fail - the old columns need upgrade
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test10';
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
ALTER IGNORE TABLE t1 COMMENT 'test11';
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255) DEFAULT NULL,
`b` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='test11'
VERSION
10
a b
# Now ALTER..INPLACE should work
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test12';
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255) DEFAULT NULL,
`b` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='test12'
VERSION
10
a b
DROP TABLE t1;
# Upgrade using ALTER, adding a column DEFAULT
TRUNCATE TABLE t1;
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255)/*old*/ DEFAULT NULL,
`b` varchar(255)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
9
a b
# ALTER..INPLACE should fail - the old columns need upgrade
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY a VARBINARY(255) DEFAULT 'a10';
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
ALTER IGNORE TABLE t1 MODIFY a VARBINARY(255) DEFAULT 'a11';
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255) DEFAULT x'613131',
`b` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
# Now ALTER..INPLACE should work
ALTER IGNORE TABLE t1 MODIFY a VARBINARY(255) DEFAULT 'a12';
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255) DEFAULT x'613132',
`b` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
DROP TABLE t1;
DROP PROCEDURE show_table;
#
# End of 10.11 tests
#
|