| 1 |
SET @@session.default_storage_engine = 'ndbcluster'; |
| 2 |
create table t1 (a int, |
| 3 |
b int generated always as (-a) virtual, |
| 4 |
c int generated always as (-a) stored); |
| 5 |
set sql_warnings = 1; |
| 6 |
# |
| 7 |
# *** INSERT *** |
| 8 |
# |
| 9 |
# INSERT INTO tbl_name VALUES... DEFAULT is specified against gcols |
| 10 |
insert into t1 values (1,default,default); |
| 11 |
select * from t1; |
| 12 |
a b c |
| 13 |
1 -1 -1 |
| 14 |
delete from t1; |
| 15 |
select * from t1; |
| 16 |
a b c |
| 17 |
# INSERT INTO tbl_name VALUES... NULL is specified against gcols |
| 18 |
insert into t1 values (1,null,null); |
| 19 |
ERROR HY000: The value specified for generated column 'b' in table 't1' is not allowed. |
| 20 |
select * from t1; |
| 21 |
a b c |
| 22 |
delete from t1; |
| 23 |
select * from t1; |
| 24 |
a b c |
| 25 |
# INSERT INTO tbl_name VALUES... a non-NULL value is specified against gcols |
| 26 |
insert into t1 values (1,2,3); |
| 27 |
ERROR HY000: The value specified for generated column 'b' in table 't1' is not allowed. |
| 28 |
select * from t1; |
| 29 |
a b c |
| 30 |
delete from t1; |
| 31 |
select * from t1; |
| 32 |
a b c |
| 33 |
# INSERT INTO tbl_name (<non_gcol_list>) VALUES... |
| 34 |
insert into t1 (a) values (1), (2); |
| 35 |
select * from t1 order by a; |
| 36 |
a b c |
| 37 |
1 -1 -1 |
| 38 |
2 -2 -2 |
| 39 |
delete from t1; |
| 40 |
select * from t1; |
| 41 |
a b c |
| 42 |
# INSERT INTO tbl_name (<normal+gcols>) VALUES... DEFAULT is specified |
| 43 |
# against gcols |
| 44 |
insert into t1 (a,b) values (1,default), (2,default); |
| 45 |
select * from t1; |
| 46 |
a b c |
| 47 |
1 -1 -1 |
| 48 |
2 -2 -2 |
| 49 |
delete from t1; |
| 50 |
select * from t1; |
| 51 |
a b c |
| 52 |
# INSERT INTO tbl_name (<normal+gcols>) VALUES... NULL is specified against gcols |
| 53 |
insert into t1 (a,b) values (1,null), (2,null); |
| 54 |
ERROR HY000: The value specified for generated column 'b' in table 't1' is not allowed. |
| 55 |
select * from t1; |
| 56 |
a b c |
| 57 |
delete from t1; |
| 58 |
select * from t1; |
| 59 |
a b c |
| 60 |
# INSERT INTO tbl_name (<normal+gcols>) VALUES... a non-NULL value is specified |
| 61 |
# against gcols |
| 62 |
insert into t1 (a,b) values (1,3), (2,4); |
| 63 |
ERROR HY000: The value specified for generated column 'b' in table 't1' is not allowed. |
| 64 |
select * from t1; |
| 65 |
a b c |
| 66 |
delete from t1; |
| 67 |
select * from t1; |
| 68 |
a b c |
| 69 |
drop table t1; |
| 70 |
# Table with UNIQUE non-gcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE |
| 71 |
# KEY UPDATE <non_gcol>=expr, <gcol>=expr |
| 72 |
create table t1 (a int unique, |
| 73 |
b int generated always as (-a) virtual, |
| 74 |
c int generated always as (-a) stored); |
| 75 |
insert into t1 values (1,default,default); |
| 76 |
insert into t1 values (1,default,default) |
| 77 |
on duplicate key update a=2, b=default; |
| 78 |
select a,b,c from t1; |
| 79 |
a b c |
| 80 |
2 -2 -2 |
| 81 |
delete from t1 where b in (1,2); |
| 82 |
select * from t1; |
| 83 |
a b c |
| 84 |
2 -2 -2 |
| 85 |
drop table t1; |
| 86 |
# Table with UNIQUE gcol field. INSERT INTO tbl_name VALUES... ON DUPLICATE |
| 87 |
# KEY UPDATE <non_gcol>=expr, <gcol>=expr |
| 88 |
create table t1 (a int, |
| 89 |
b int generated always as (-a) virtual, |
| 90 |
c int generated always as (-a) stored unique); |
| 91 |
insert into t1 values (1,default,default); |
| 92 |
insert into t1 values (1,default,default) |
| 93 |
on duplicate key update a=2, b=default; |
| 94 |
select a,b,c from t1; |
| 95 |
a b c |
| 96 |
2 -2 -2 |
| 97 |
# CREATE new_table ... LIKE old_table |
| 98 |
# INSERT INTO new_table SELECT * from old_table |
| 99 |
create table t2 like t1; |
| 100 |
insert into t2 select * from t1; |
| 101 |
ERROR HY000: The value specified for generated column 'b' in table 't2' is not allowed. |
| 102 |
insert into t2(a) select a from t1; |
| 103 |
select * from t2; |
| 104 |
a b c |
| 105 |
2 -2 -2 |
| 106 |
drop table t2; |
| 107 |
# CREATE new_table ... LIKE old_table INSERT INTO new_table (<non-gcols>, <gcols>) |
| 108 |
# SELECT <non-gcols>, <gcols> from old_table |
| 109 |
insert into t1 values (1,default,default); |
| 110 |
select * from t1; |
| 111 |
a b c |
| 112 |
1 -1 -1 |
| 113 |
2 -2 -2 |
| 114 |
create table t2 like t1; |
| 115 |
insert into t2 (a,b) select a,b from t1; |
| 116 |
ERROR HY000: The value specified for generated column 'b' in table 't2' is not allowed. |
| 117 |
insert into t2 (a) select a from t1; |
| 118 |
select * from t2 order by a; |
| 119 |
a b c |
| 120 |
1 -1 -1 |
| 121 |
2 -2 -2 |
| 122 |
drop table t2; |
| 123 |
drop table t1; |
| 124 |
# |
| 125 |
# *** UPDATE *** |
| 126 |
# |
| 127 |
# UPDATE tbl_name SET non-gcol=expr WHERE non-gcol=expr |
| 128 |
create table t1 (a int, |
| 129 |
b int generated always as (-a) virtual, |
| 130 |
c int generated always as (-a) stored); |
| 131 |
insert into t1 (a) values (1), (2); |
| 132 |
select * from t1 order by a; |
| 133 |
a b c |
| 134 |
1 -1 -1 |
| 135 |
2 -2 -2 |
| 136 |
update t1 set a=3 where a=2; |
| 137 |
select * from t1 order by a; |
| 138 |
a b c |
| 139 |
1 -1 -1 |
| 140 |
3 -3 -3 |
| 141 |
delete from t1; |
| 142 |
select * from t1; |
| 143 |
a b c |
| 144 |
# UPDATE tbl_name SET gcol=expr WHERE non-gcol=expr |
| 145 |
insert into t1 (a) values (1), (2); |
| 146 |
select * from t1; |
| 147 |
a b c |
| 148 |
1 -1 -1 |
| 149 |
2 -2 -2 |
| 150 |
update t1 set c=3 where a=2; |
| 151 |
ERROR HY000: The value specified for generated column 'c' in table 't1' is not allowed. |
| 152 |
select * from t1; |
| 153 |
a b c |
| 154 |
1 -1 -1 |
| 155 |
2 -2 -2 |
| 156 |
delete from t1; |
| 157 |
select * from t1; |
| 158 |
a b c |
| 159 |
# UPDATE tbl_name SET non-gcol=expr WHERE gcol=expr |
| 160 |
insert into t1 (a) values (1), (2); |
| 161 |
select * from t1; |
| 162 |
a b c |
| 163 |
1 -1 -1 |
| 164 |
2 -2 -2 |
| 165 |
update t1 set a=3 where b=-2; |
| 166 |
select * from t1; |
| 167 |
a b c |
| 168 |
1 -1 -1 |
| 169 |
3 -3 -3 |
| 170 |
delete from t1; |
| 171 |
select * from t1; |
| 172 |
a b c |
| 173 |
# UPDATE tbl_name SET gcol=expr WHERE gcol=expr |
| 174 |
insert into t1 (a) values (1), (2); |
| 175 |
select * from t1; |
| 176 |
a b c |
| 177 |
1 -1 -1 |
| 178 |
2 -2 -2 |
| 179 |
update t1 set c=3 where b=-2; |
| 180 |
ERROR HY000: The value specified for generated column 'c' in table 't1' is not allowed. |
| 181 |
select * from t1; |
| 182 |
a b c |
| 183 |
1 -1 -1 |
| 184 |
2 -2 -2 |
| 185 |
delete from t1; |
| 186 |
select * from t1; |
| 187 |
a b c |
| 188 |
drop table t1; |
| 189 |
# INDEX created on gcol |
| 190 |
# UPDATE tbl_name SET non-gcol=expr WHERE gcol=const |
| 191 |
create table t1 (a int, |
| 192 |
b int generated always as (-a) virtual, |
| 193 |
c int generated always as (-a) stored unique); |
| 194 |
insert into t1 (a) values (1), (2); |
| 195 |
select * from t1 order by a; |
| 196 |
a b c |
| 197 |
1 -1 -1 |
| 198 |
2 -2 -2 |
| 199 |
update t1 set a=3 where c=-2; |
| 200 |
select * from t1; |
| 201 |
a b c |
| 202 |
1 -1 -1 |
| 203 |
3 -3 -3 |
| 204 |
delete from t1; |
| 205 |
select * from t1; |
| 206 |
a b c |
| 207 |
# INDEX created on gcol |
| 208 |
# UPDATE tbl_name SET non-gcol=expr WHERE gcol=between const1 and const2 |
| 209 |
insert into t1 (a) values (1), (2); |
| 210 |
select * from t1; |
| 211 |
a b c |
| 212 |
1 -1 -1 |
| 213 |
2 -2 -2 |
| 214 |
update t1 set a=3 where c between -3 and -2; |
| 215 |
select * from t1; |
| 216 |
a b c |
| 217 |
1 -1 -1 |
| 218 |
3 -3 -3 |
| 219 |
delete from t1; |
| 220 |
select * from t1; |
| 221 |
a b c |
| 222 |
# No INDEX created on gcol |
| 223 |
# UPDATE tbl_name SET non-gcol=expr WHERE gcol=between const1 and const2 |
| 224 |
insert into t1 (a) values (1), (2); |
| 225 |
select * from t1; |
| 226 |
a b c |
| 227 |
1 -1 -1 |
| 228 |
2 -2 -2 |
| 229 |
update t1 set a=3 where b between -3 and -2; |
| 230 |
select * from t1; |
| 231 |
a b c |
| 232 |
1 -1 -1 |
| 233 |
3 -3 -3 |
| 234 |
delete from t1; |
| 235 |
select * from t1; |
| 236 |
a b c |
| 237 |
# INDEX created on gcol |
| 238 |
# UPDATE tbl_name SET non-gcol=expr |
| 239 |
# WHERE gcol=between const1 and const2 ORDER BY gcol |
| 240 |
insert into t1 (a) values (1), (2), (3), (4), (5); |
| 241 |
select * from t1; |
| 242 |
a b c |
| 243 |
1 -1 -1 |
| 244 |
2 -2 -2 |
| 245 |
3 -3 -3 |
| 246 |
4 -4 -4 |
| 247 |
5 -5 -5 |
| 248 |
update t1 set a=6 where c between -1 and 0 |
| 249 |
order by c; |
| 250 |
select * from t1; |
| 251 |
a b c |
| 252 |
2 -2 -2 |
| 253 |
3 -3 -3 |
| 254 |
4 -4 -4 |
| 255 |
5 -5 -5 |
| 256 |
6 -6 -6 |
| 257 |
delete from t1 where c between -6 and 0; |
| 258 |
select * from t1; |
| 259 |
a b c |
| 260 |
# INDEX created on gcol |
| 261 |
# UPDATE tbl_name SET non-gcol=expr |
| 262 |
# WHERE gcol=between const1 and const2 ORDER BY gcol LIMIT 2 |
| 263 |
insert into t1 (a) values (1), (2), (3), (4), (5); |
| 264 |
select * from t1 order by a; |
| 265 |
a b c |
| 266 |
1 -1 -1 |
| 267 |
2 -2 -2 |
| 268 |
3 -3 -3 |
| 269 |
4 -4 -4 |
| 270 |
5 -5 -5 |
| 271 |
update t1 set a=6 where c between -1 and 0 |
| 272 |
order by c limit 2; |
| 273 |
select * from t1; |
| 274 |
a b c |
| 275 |
2 -2 -2 |
| 276 |
3 -3 -3 |
| 277 |
4 -4 -4 |
| 278 |
5 -5 -5 |
| 279 |
6 -6 -6 |
| 280 |
delete from t1 where c between -2 and 0 order by c; |
| 281 |
select * from t1 order by a; |
| 282 |
a b c |
| 283 |
3 -3 -3 |
| 284 |
4 -4 -4 |
| 285 |
5 -5 -5 |
| 286 |
6 -6 -6 |
| 287 |
delete from t1; |
| 288 |
# INDEX created on gcol |
| 289 |
# UPDATE tbl_name SET non-gcol=expr |
| 290 |
# WHERE indexed gcol=between const1 and const2 and non-indexed gcol=const3 |
| 291 |
insert into t1 (a) values (1), (2), (3), (4), (5); |
| 292 |
select * from t1; |
| 293 |
a b c |
| 294 |
1 -1 -1 |
| 295 |
2 -2 -2 |
| 296 |
3 -3 -3 |
| 297 |
4 -4 -4 |
| 298 |
5 -5 -5 |
| 299 |
update t1 set a=6 where (c between -2 and 0) and (b=-1); |
| 300 |
select * from t1; |
| 301 |
a b c |
| 302 |
2 -2 -2 |
| 303 |
3 -3 -3 |
| 304 |
4 -4 -4 |
| 305 |
5 -5 -5 |
| 306 |
6 -6 -6 |
| 307 |
delete from t1; |
| 308 |
# INDEX created on gcol |
| 309 |
# UPDATE tbl_name SET non-gcol=expr |
| 310 |
# WHERE indexed gcol=between const1 and const2 and non-indexed gcol=const3 |
| 311 |
# ORDER BY indexed gcol |
| 312 |
insert into t1 (a) values (1), (2), (3), (4), (5); |
| 313 |
select * from t1; |
| 314 |
a b c |
| 315 |
1 -1 -1 |
| 316 |
2 -2 -2 |
| 317 |
3 -3 -3 |
| 318 |
4 -4 -4 |
| 319 |
5 -5 -5 |
| 320 |
update t1 set a=6 where (c between -2 and 0) and (b=-1) order by c; |
| 321 |
select * from t1; |
| 322 |
a b c |
| 323 |
2 -2 -2 |
| 324 |
3 -3 -3 |
| 325 |
4 -4 -4 |
| 326 |
5 -5 -5 |
| 327 |
6 -6 -6 |
| 328 |
delete from t1; |
| 329 |
drop table t1; |
| 330 |
# |
| 331 |
# *** REPLACE *** |
| 332 |
# |
| 333 |
# UNIQUE INDEX on gcol |
| 334 |
# REPLACE tbl_name (non-gcols) VALUES (non-gcols); |
| 335 |
create table t1 (a int, |
| 336 |
b int generated always as (-a) virtual, |
| 337 |
c int generated always as (-a) stored unique, |
| 338 |
d varchar(16)); |
| 339 |
insert into t1 (a,d) values (1,'a'), (2,'b'); |
| 340 |
select * from t1 order by a; |
| 341 |
a b c d |
| 342 |
1 -1 -1 a |
| 343 |
2 -2 -2 b |
| 344 |
replace t1 (a,d) values (1,'c'); |
| 345 |
select * from t1 order by a; |
| 346 |
a b c d |
| 347 |
1 -1 -1 c |
| 348 |
2 -2 -2 b |
| 349 |
delete from t1; |
| 350 |
select * from t1; |
| 351 |
a b c d |
| 352 |
set sql_warnings = 0; |
| 353 |
drop table t1; |
| 354 |
Bug#20170778: WL411:FAILING ASSERTION `!TABLE || (!TABLE->WRITE_SET || |
| 355 |
BITMAP_IS_SET(TABLE->WR |
| 356 |
# |
| 357 |
CREATE TABLE t1 (col1 INT, col2 INT, col3 INT, col4 INT, col5 |
| 358 |
INT GENERATED ALWAYS AS (col3 * col2) VIRTUAL, col6 INT GENERATED ALWAYS AS |
| 359 |
(col4 * col1) STORED, col7 INT GENERATED ALWAYS AS (col6 + col6) VIRTUAL, |
| 360 |
col8 INT GENERATED ALWAYS AS (col6 / col5) STORED, col9 TEXT); |
| 361 |
Warnings: |
| 362 |
Warning 1478 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK' |
| 363 |
SET @fill_amount = (@@innodb_page_size / 2 ) + 1; |
| 364 |
INSERT INTO t1 (col1,col2,col3,col4,col5,col6,col7,col8,col9) VALUES /* 3 */ |
| 365 |
(3, 3 / 3, 3 + 3, 3 / 3, DEFAULT, DEFAULT, DEFAULT, DEFAULT ,REPEAT(CAST(3 AS |
| 366 |
CHAR(1)),@fill_amount)) , (3, 3 * 3, 3 + 3, 3 / 3, DEFAULT, DEFAULT, DEFAULT, |
| 367 |
DEFAULT ,REPEAT(CAST(3 AS CHAR(1)),@fill_amount)); |
| 368 |
UPDATE t1 SET col1 = 2; |
| 369 |
UPDATE t1 SET col7 = DEFAULT; |
| 370 |
UPDATE t1 SET col8 = DEFAULT; |
| 371 |
DROP TABLE t1; |
| 372 |
# Bug#21081742: ASSERTION !TABLE || (!TABLE->WRITE_SET || |
| 373 |
# BITMAP_IS_SET(TABLE->WRITE_SET |
| 374 |
# |
| 375 |
CREATE TABLE b ( |
| 376 |
pk INTEGER AUTO_INCREMENT, |
| 377 |
col_varchar_nokey VARCHAR(1), |
| 378 |
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS |
| 379 |
(CONCAT(col_varchar_nokey, col_varchar_nokey)), |
| 380 |
PRIMARY KEY (pk) |
| 381 |
); |
| 382 |
INSERT INTO b (col_varchar_nokey) VALUES ('v'),('v'); |
| 383 |
CREATE TABLE d ( |
| 384 |
pk INTEGER AUTO_INCREMENT, |
| 385 |
col_varchar_nokey VARCHAR(1), |
| 386 |
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS |
| 387 |
(CONCAT(col_varchar_nokey, col_varchar_nokey)), |
| 388 |
PRIMARY KEY (pk) |
| 389 |
) ; |
| 390 |
INSERT INTO d (col_varchar_nokey) VALUES ('q'),('g'),('e'),('l'),(NULL),('v'),('c'),('u'),('x'); |
| 391 |
CREATE TABLE bb ( |
| 392 |
pk INTEGER AUTO_INCREMENT, |
| 393 |
col_varchar_nokey VARCHAR(1) /*! NULL */, |
| 394 |
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS |
| 395 |
(CONCAT(col_varchar_nokey, col_varchar_nokey)), |
| 396 |
PRIMARY KEY (pk) |
| 397 |
); |
| 398 |
INSERT INTO bb (col_varchar_nokey) VALUES ('j'),('h'); |
| 399 |
EXPLAIN UPDATE |
| 400 |
d AS outr1, b AS outr2 |
| 401 |
SET outr1.col_varchar_nokey = NULL |
| 402 |
WHERE |
| 403 |
( 't', 'b' ) IN |
| 404 |
( |
| 405 |
SELECT |
| 406 |
innr1.col_varchar_nokey AS x, |
| 407 |
innr1.col_varchar_key AS y |
| 408 |
FROM bb AS innr1 |
| 409 |
WHERE outr1.pk = 1 |
| 410 |
); |
| 411 |
id select_type table partitions type possible_keys key key_len ref rows filtered Extra |
| 412 |
1 UPDATE outr1 p0,p1,p2,p3,p4,p5,p6,p7 eq_ref PRIMARY PRIMARY 4 const 1 100.00 NULL |
| 413 |
1 SIMPLE innr1 p0,p1,p2,p3,p4,p5,p6,p7 ALL NULL NULL NULL NULL 2 50.00 Using where; Using pushed condition (`test`.`innr1`.`col_varchar_nokey` = 't'); FirstMatch(outr1) |
| 414 |
1 SIMPLE outr2 p0,p1,p2,p3,p4,p5,p6,p7 ALL NULL NULL NULL NULL 2 100.00 NULL |
| 415 |
Warnings: |
| 416 |
Note 1276 Field or reference 'test.outr1.pk' of SELECT #2 was resolved in SELECT #1 |
| 417 |
Note 1003 Table 'outr1' is not pushable: lock modes other than 'read committed' not implemented |
| 418 |
Note 1003 Can't push table 'outr2' as child, 'type' must be a 'ref' access |
| 419 |
Note 1003 update `test`.`d` `outr1` join `test`.`b` `outr2` semi join (`test`.`bb` `innr1`) set `test`.`outr1`.`col_varchar_nokey` = NULL where ((`test`.`outr1`.`pk` = 1) and (`test`.`innr1`.`col_varchar_key` = 'b') and (`test`.`innr1`.`col_varchar_nokey` = 't')) |
| 420 |
DROP TABLE IF EXISTS b,bb,d; |
| 421 |
# |
| 422 |
# Bug#21216067 ASSERTION FAILED ROW_UPD_SEC_INDEX_ENTRY (INNOBASE/ROW/ROW0UPD.CC:2103) |
| 423 |
# |
| 424 |
CREATE TABLE t ( |
| 425 |
x INT, y INT, gc INT GENERATED ALWAYS AS (x+1) STORED |
| 426 |
); |
| 427 |
INSERT INTO t VALUES (); |
| 428 |
UPDATE t t1, t t2 SET t2.y = 1, t1.x = 2; |
| 429 |
SELECT * FROM t; |
| 430 |
x y gc |
| 431 |
2 1 3 |
| 432 |
DROP TABLE t; |
| 433 |
# stored |
| 434 |
CREATE TABLE c ( |
| 435 |
col_varchar_nokey VARCHAR(1), |
| 436 |
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS |
| 437 |
(CONCAT(col_varchar_nokey, col_varchar_nokey)) STORED |
| 438 |
); |
| 439 |
INSERT INTO c (col_varchar_nokey) VALUES ('c'); |
| 440 |
EXPLAIN UPDATE c AS outr1, c AS outr2 |
| 441 |
SET outr1.`col_varchar_nokey` = 'f', |
| 442 |
outr2.`col_varchar_nokey` = "a"; |
| 443 |
id select_type table partitions type possible_keys key key_len ref rows filtered Extra |
| 444 |
1 UPDATE outr1 p0,p1,p2,p3,p4,p5,p6,p7 ALL NULL NULL NULL NULL 2 100.00 NULL |
| 445 |
1 UPDATE outr2 p0,p1,p2,p3,p4,p5,p6,p7 ALL NULL NULL NULL NULL 2 100.00 NULL |
| 446 |
Warnings: |
| 447 |
Note 1003 Table 'outr1' is not pushable: lock modes other than 'read committed' not implemented |
| 448 |
Note 1003 update `test`.`c` `outr1` join `test`.`c` `outr2` set `test`.`outr1`.`col_varchar_nokey` = 'f',`test`.`outr2`.`col_varchar_nokey` = 'a' |
| 449 |
UPDATE c AS outr1, c AS outr2 |
| 450 |
SET outr1.`col_varchar_nokey` = 'f', |
| 451 |
outr2.`col_varchar_nokey` = "a"; |
| 452 |
SELECT * from c; |
| 453 |
col_varchar_nokey col_varchar_key |
| 454 |
a aa |
| 455 |
DROP TABLE c; |
| 456 |
# stored, indexed |
| 457 |
CREATE TABLE c ( |
| 458 |
col_varchar_nokey VARCHAR(1), |
| 459 |
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS |
| 460 |
(CONCAT(col_varchar_nokey, col_varchar_nokey)) STORED, |
| 461 |
KEY (col_varchar_key, col_varchar_nokey) |
| 462 |
); |
| 463 |
INSERT INTO c (col_varchar_nokey) VALUES ('c'); |
| 464 |
EXPLAIN UPDATE c AS outr1, c AS outr2 |
| 465 |
SET outr1.`col_varchar_nokey` = 'f', |
| 466 |
outr2.`col_varchar_nokey` = "a"; |
| 467 |
id select_type table partitions type possible_keys key key_len ref rows filtered Extra |
| 468 |
1 UPDATE outr1 p0,p1,p2,p3,p4,p5,p6,p7 ALL NULL NULL NULL NULL 2 100.00 NULL |
| 469 |
1 UPDATE outr2 p0,p1,p2,p3,p4,p5,p6,p7 ALL NULL NULL NULL NULL 2 100.00 NULL |
| 470 |
Warnings: |
| 471 |
Note 1003 Table 'outr1' is not pushable: lock modes other than 'read committed' not implemented |
| 472 |
Note 1003 update `test`.`c` `outr1` join `test`.`c` `outr2` set `test`.`outr1`.`col_varchar_nokey` = 'f',`test`.`outr2`.`col_varchar_nokey` = 'a' |
| 473 |
UPDATE c AS outr1, c AS outr2 |
| 474 |
SET outr1.`col_varchar_nokey` = 'f', |
| 475 |
outr2.`col_varchar_nokey` = "a"; |
| 476 |
SELECT * from c; |
| 477 |
col_varchar_nokey col_varchar_key |
| 478 |
a aa |
| 479 |
DROP TABLE c; |
| 480 |
# virtual |
| 481 |
CREATE TABLE c ( |
| 482 |
col_varchar_nokey VARCHAR(1), |
| 483 |
col_varchar_key VARCHAR(2) GENERATED ALWAYS AS |
| 484 |
(CONCAT(col_varchar_nokey, col_varchar_nokey)) VIRTUAL |
| 485 |
); |
| 486 |
INSERT INTO c (col_varchar_nokey) VALUES ('c'); |
| 487 |
EXPLAIN UPDATE c AS outr1, c AS outr2 |
| 488 |
SET outr1.`col_varchar_nokey` = 'f', |
| 489 |
outr2.`col_varchar_nokey` = "a"; |
| 490 |
id select_type table partitions type possible_keys key key_len ref rows filtered Extra |
| 491 |
1 UPDATE outr1 p0,p1,p2,p3,p4,p5,p6,p7 ALL NULL NULL NULL NULL 2 100.00 NULL |
| 492 |
1 UPDATE outr2 p0,p1,p2,p3,p4,p5,p6,p7 ALL NULL NULL NULL NULL 2 100.00 NULL |
| 493 |
Warnings: |
| 494 |
Note 1003 Table 'outr1' is not pushable: lock modes other than 'read committed' not implemented |
| 495 |
Note 1003 update `test`.`c` `outr1` join `test`.`c` `outr2` set `test`.`outr1`.`col_varchar_nokey` = 'f',`test`.`outr2`.`col_varchar_nokey` = 'a' |
| 496 |
UPDATE c AS outr1, c AS outr2 |
| 497 |
SET outr1.`col_varchar_nokey` = 'f', |
| 498 |
outr2.`col_varchar_nokey` = "a"; |
| 499 |
SELECT * from c; |
| 500 |
col_varchar_nokey col_varchar_key |
| 501 |
a aa |
| 502 |
DROP TABLE c; |
| 503 |
#Bug#21929967:GCOLS:GCOL VALUE CHANGES WHEN SESSION CHANGES SQL_MODE |
| 504 |
CREATE TABLE t(c1 INT GENERATED ALWAYS AS (1) VIRTUAL NOT NULL, |
| 505 |
c2 INT GENERATED ALWAYS AS(2) STORED NOT NULL); |
| 506 |
INSERT INTO t VALUES(DEFAULT, DEFAULT); |
| 507 |
SELECT * FROM t; |
| 508 |
c1 c2 |
| 509 |
1 2 |
| 510 |
CREATE TABLE t1(c1 INT, c2 INT GENERATED ALWAYS AS(c1 + 1) STORED); |
| 511 |
INSERT INTO t1(c2) VALUES(DEFAULT); |
| 512 |
SELECT * FROM t1; |
| 513 |
c1 c2 |
| 514 |
NULL NULL |
| 515 |
CREATE TABLE t2(c1 INT DEFAULT 1, c2 INT GENERATED ALWAYS AS(c1 + 1) STORED NOT NULL); |
| 516 |
INSERT INTO t2(c2) VALUES(DEFAULT); |
| 517 |
SELECT * FROM t2; |
| 518 |
c1 c2 |
| 519 |
1 2 |
| 520 |
DROP TABLE t, t1, t2; |
| 521 |
# Bug#22179637: INSERT INTO TABLE FROM SELECT ACCEPTS TO INSERT INTO |
| 522 |
# GENERATED COLUMNS |
| 523 |
CREATE TABLE t1 ( |
| 524 |
i1 INTEGER, |
| 525 |
i2 INTEGER GENERATED ALWAYS AS (i1 + i1) |
| 526 |
); |
| 527 |
INSERT INTO t1 (i1, i2) SELECT 5, 6; |
| 528 |
ERROR HY000: The value specified for generated column 'i2' in table 't1' is not allowed. |
| 529 |
INSERT INTO t1 (i1) SELECT 5; |
| 530 |
INSERT INTO t1 (i1) SELECT 5 ON DUPLICATE KEY UPDATE i2= 4; |
| 531 |
ERROR HY000: The value specified for generated column 'i2' in table 't1' is not allowed. |
| 532 |
INSERT INTO t1 (i1) SELECT 5 ON DUPLICATE KEY UPDATE i2= DEFAULT; |
| 533 |
SELECT * FROM t1; |
| 534 |
i1 i2 |
| 535 |
5 10 |
| 536 |
5 10 |
| 537 |
CREATE TABLE t2 ( |
| 538 |
i1 INTEGER, |
| 539 |
i2 INTEGER GENERATED ALWAYS AS (i1 + i1) STORED |
| 540 |
); |
| 541 |
INSERT INTO t2 (i1, i2) SELECT 5, 6; |
| 542 |
ERROR HY000: The value specified for generated column 'i2' in table 't2' is not allowed. |
| 543 |
INSERT INTO t2 (i1, i2) SELECT * FROM t1; |
| 544 |
ERROR HY000: The value specified for generated column 'i2' in table 't2' is not allowed. |
| 545 |
INSERT INTO t2 (i1) SELECT 5; |
| 546 |
INSERT INTO t2 (i1) SELECT 5 ON DUPLICATE KEY UPDATE i2= 4; |
| 547 |
ERROR HY000: The value specified for generated column 'i2' in table 't2' is not allowed. |
| 548 |
INSERT INTO t2 (i1) SELECT 5 ON DUPLICATE KEY UPDATE i2= DEFAULT; |
| 549 |
SELECT * FROM t2; |
| 550 |
i1 i2 |
| 551 |
5 10 |
| 552 |
5 10 |
| 553 |
DROP TABLE t1,t2; |
| 554 |
DROP VIEW IF EXISTS v1,v2; |
| 555 |
DROP TABLE IF EXISTS t1,t2,t3; |
| 556 |
DROP PROCEDURE IF EXISTS p1; |
| 557 |
DROP FUNCTION IF EXISTS f1; |
| 558 |
DROP TRIGGER IF EXISTS trg1; |
| 559 |
DROP TRIGGER IF EXISTS trg2; |
| 560 |
set sql_warnings = 0; |