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 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739
|
# Tests for setting innodb-page-size=16k; default value
--source include/big_test.inc
SET default_storage_engine=InnoDB;
--disable_query_log
let $MYSQLD_DATADIR = `select @@datadir`;
let $INNODB_PAGE_SIZE = `select @@innodb_page_size`;
call mtr.add_suppression("Cannot add field .* in table .* because after adding it, the row size is");
# These values can change during the test
--enable_query_log
--echo # Test 1) Show the page size from Information Schema
--disable_warnings
SELECT variable_value FROM performance_schema.global_status
WHERE LOWER(variable_name) = 'innodb_page_size';
--enable_warnings
--echo # Test 2) The number of buffer pool pages is dependent upon the page size.
--disable_warnings
--replace_result 1535 {checked_valid} 1536 {checked_valid}
SELECT variable_value FROM performance_schema.global_status
WHERE LOWER(variable_name) = 'innodb_buffer_pool_pages_total';
--enable_warnings
--echo # Test 3) Query some information_shema tables that are dependent upon
--echo # the page size.
# Show the metadata for tables in schema 'mysql'.
# Pulled from innodb-system-table-view.test
# The IDs of mysql.innodb_table_stats and mysql.innodb_index_stats are
# unpredictable. They depend on whether mtr has created the database for
# this test from scratch or is using a previously created database where
# those tables have been dropped and recreated. Since we cannot force mtr
# to use a freshly created database for this test we do not return the
# table or index IDs. We can return the space IS of mysql schema tables
# since they are created consistently during bootstrap.
SELECT t.name table_name, t.n_cols, t.flag table_flags,
i.name index_name, i.page_no root_page, i.type,
i.n_fields, i.merge_threshold
FROM INFORMATION_SCHEMA.INNODB_TABLES t,
INFORMATION_SCHEMA.INNODB_INDEXES i
WHERE t.table_id = i.table_id
AND t.name LIKE 'mysql%'
AND t.name NOT LIKE 'mysql/ndb_binlog_index'
ORDER BY t.name, i.index_id;
CREATE TABLE t1 (a INT KEY, b TEXT) ROW_FORMAT=REDUNDANT ENGINE=innodb;
CREATE TABLE t2 (a INT KEY, b TEXT) ROW_FORMAT=COMPACT ENGINE=innodb;
CREATE TABLE t3 (a INT KEY, b TEXT) ROW_FORMAT=COMPRESSED ENGINE=innodb;
CREATE TABLE t4 (a INT KEY, b TEXT) ROW_FORMAT=DYNAMIC ENGINE=innodb;
# Show the metadata for tables in schema 'test'.
# Do not return the space ID since this tablespace may have existed before
# this test runs. The root page number of each index should be consistent
# within a file-per-table tablespace.
SELECT t.name table_name, t.n_cols, t.flag table_flags,
i.name index_name, i.page_no root_page, i.type,
i.n_fields, i.merge_threshold
FROM INFORMATION_SCHEMA.INNODB_TABLES t,
INFORMATION_SCHEMA.INNODB_INDEXES i
WHERE t.table_id = i.table_id
AND t.name LIKE 'test%'
ORDER BY t.name, i.name;
--source suite/innodb/include/show_i_s_tablespaces.inc
DROP TABLE t1, t2, t3, t4;
--echo # Test 4) The maximum row size is dependent upon the page size.
--echo # Redundant: 8123, Compact: 8126.
--echo # Compressed: 8126, Dynamic: 8126.
--echo # Each row format has its own amount of overhead that
--echo # varies depending on number of fields and other overhead.
SET SESSION innodb_strict_mode = ON;
# Redundant table; 8122 bytes with 40 char fields
# Calculation :
# 6 (extra bytes)
# 2 * 43 = 86 (fields len) = 2 * n_fields (3 system fields + 40 user fields)
# 6 + 6 + 7 = 19 (ROW_ID, TRX_ID, ROLL_PTR)
# 200 * 39 = 7800 (each char(200) field)
# 211 = (char(211))
# T0tal = 8122
# NOTE : charset latin1 causes each char to have max 1 bytes. If we use default
# (utf8_mb4) then each char will need 4 bytes. So char(200) will need
# max 800 bytes.
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(200),
c21 char(200), c22 char(200), c23 char(200), c24 char(200), c25 char(200),
c26 char(200), c27 char(200), c28 char(200), c29 char(200), c30 char(200),
c31 char(200), c32 char(200), c33 char(200), c34 char(200), c35 char(200),
c36 char(200), c37 char(200), c38 char(200), c39 char(200), c40 char(211)
) charset latin1 ROW_FORMAT=redundant;
DROP TABLE t1;
# Redundant table; 8123 bytes with 40 char fields
--error ER_TOO_BIG_ROWSIZE
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(200),
c21 char(200), c22 char(200), c23 char(200), c24 char(200), c25 char(200),
c26 char(200), c27 char(200), c28 char(200), c29 char(200), c30 char(200),
c31 char(200), c32 char(200), c33 char(200), c34 char(200), c35 char(200),
c36 char(200), c37 char(200), c38 char(200), c39 char(200), c40 char(212)
) charset latin1 ROW_FORMAT=redundant;
# Compact table; 8125 bytes with 40 CHAR fields
# Calculation :
# 5 (extra bytes)
# 5 (null bitmap)
# 6 + 6 + 7 = 19 (ROW_ID, TRX_ID, ROLL_PTR)
# 200 * 38 = 7600 (each char(200) field)
# 250 = (char(250))
# 246 = (char(246))
# Total = 8125
# NOTE : charset latin1 causes each char to have max 1 bytes. If we use default
# (utf8_mb4) then each char will need 4 bytes. So char(200) will need
# max 800 bytes.
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(200),
c21 char(200), c22 char(200), c23 char(200), c24 char(200), c25 char(200),
c26 char(200), c27 char(200), c28 char(200), c29 char(200), c30 char(200),
c31 char(200), c32 char(200), c33 char(200), c34 char(200), c35 char(200),
c36 char(200), c37 char(200), c38 char(200), c39 char(250), c40 char(246)
) charset latin1 ROW_FORMAT=compact;
DROP TABLE t1;
# Compact table; 8126 bytes with 40 CHAR fields
--error ER_TOO_BIG_ROWSIZE
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(200),
c21 char(200), c22 char(200), c23 char(200), c24 char(200), c25 char(200),
c26 char(200), c27 char(200), c28 char(200), c29 char(200), c30 char(200),
c31 char(200), c32 char(200), c33 char(200), c34 char(200), c35 char(200),
c36 char(200), c37 char(200), c38 char(200), c39 char(250), c40 char(247)
) charset latin1 ROW_FORMAT=compact;
# Compressed table; 7959 bytes with 40 CHAR fields
# Bug#13391353 Limit is 7957 on 32-Linux only
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(200),
c21 char(200), c22 char(200), c23 char(200), c24 char(200), c25 char(200),
c26 char(200), c27 char(200), c28 char(200), c29 char(200), c30 char(200),
c31 char(200), c32 char(200), c33 char(200), c34 char(200), c35 char(200),
c36 char(200), c37 char(200), c38 char(200), c39 char(200), c40 char(157)
) ROW_FORMAT=compressed;
DROP TABLE t1;
--error ER_TOO_BIG_ROWSIZE
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(200),
c21 char(200), c22 char(200), c23 char(200), c24 char(200), c25 char(200),
c26 char(200), c27 char(200), c28 char(200), c29 char(200), c30 char(200),
c31 char(200), c32 char(200), c33 char(200), c34 char(200), c35 char(200),
c36 char(200), c37 char(200), c38 char(200), c39 char(200), c40 char(160)
) charset latin1 ROW_FORMAT=compressed;
# Dynamic table; 8096 bytes with 40 CHAR fields
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(200),
c21 char(200), c22 char(200), c23 char(200), c24 char(200), c25 char(200),
c26 char(200), c27 char(200), c28 char(200), c29 char(200), c30 char(200),
c31 char(200), c32 char(200), c33 char(200), c34 char(200), c35 char(200),
c36 char(200), c37 char(200), c38 char(200), c39 char(250), c40 char(246)
) ROW_FORMAT=dynamic;
DROP TABLE t1;
--error ER_TOO_BIG_ROWSIZE
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(200),
c21 char(200), c22 char(200), c23 char(200), c24 char(200), c25 char(200),
c26 char(200), c27 char(200), c28 char(200), c29 char(200), c30 char(200),
c31 char(200), c32 char(200), c33 char(200), c34 char(200), c35 char(200),
c36 char(200), c37 char(200), c38 char(200), c39 char(250), c40 char(247)
) charset latin1 ROW_FORMAT=dynamic;
#
# Test the maximum key length
# Moved from innodb-index.test since each page size has its own max key length.
# Max Key Length is 3072 for 16k pages.
# Max key Part length is 767
# InnoDB assumes 3 bytes for each UTF8 character.
#
CREATE TABLE t1 (a varchar(255) character set utf8,
b varchar(255) character set utf8,
c varchar(255) character set utf8,
d varchar(255) character set utf8,
e varchar(4) character set utf8,
PRIMARY KEY (a,b,c,d,e))
ENGINE=innodb;
DROP TABLE t1;
--error ER_TOO_LONG_KEY
CREATE TABLE t1 (a varchar(255) character set utf8,
b varchar(255) character set utf8,
c varchar(255) character set utf8,
d varchar(255) character set utf8,
e varchar(5) character set utf8,
PRIMARY KEY (a,b,c,d,e))
ENGINE=innodb;
CREATE TABLE t1 (a varchar(255) character set utf8,
b varchar(255) character set utf8,
c varchar(255) character set utf8,
d varchar(255) character set utf8,
e varchar(255) character set utf8,
f varchar(4) character set utf8,
PRIMARY KEY (a), KEY (b,c,d,e,f))
ENGINE=innodb;
DROP TABLE t1;
--error ER_TOO_LONG_KEY
CREATE TABLE t1 (a varchar(255) character set utf8,
b varchar(255) character set utf8,
c varchar(255) character set utf8,
d varchar(255) character set utf8,
e varchar(255) character set utf8,
f varchar(5) character set utf8,
PRIMARY KEY (a), KEY (b,c,d,e,f))
ENGINE=innodb;
--echo # Test 5) Make sure that KEY_BLOCK_SIZE=16, 8, 4, 2 & 1
--echo # are all accepted.
SET SESSION innodb_strict_mode = ON;
CREATE TABLE t1 (i int) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
FROM information_schema.tables WHERE table_name = 't1';
ALTER TABLE t1 KEY_BLOCK_SIZE=8;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
FROM information_schema.tables WHERE table_name = 't1';
ALTER TABLE t1 KEY_BLOCK_SIZE=4;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
FROM information_schema.tables WHERE table_name = 't1';
ALTER TABLE t1 KEY_BLOCK_SIZE=2;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
FROM information_schema.tables WHERE table_name = 't1';
ALTER TABLE t1 KEY_BLOCK_SIZE=1;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
FROM information_schema.tables WHERE table_name = 't1';
ALTER TABLE t1 KEY_BLOCK_SIZE=0;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
FROM information_schema.tables WHERE table_name = 't1';
DROP TABLE t1;
SET SESSION innodb_strict_mode = OFF;
CREATE TABLE t1 (i int) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
FROM information_schema.tables WHERE table_name = 't1';
ALTER TABLE t1 KEY_BLOCK_SIZE=8;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
FROM information_schema.tables WHERE table_name = 't1';
ALTER TABLE t1 KEY_BLOCK_SIZE=4;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
FROM information_schema.tables WHERE table_name = 't1';
ALTER TABLE t1 KEY_BLOCK_SIZE=2;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
FROM information_schema.tables WHERE table_name = 't1';
ALTER TABLE t1 KEY_BLOCK_SIZE=1;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
FROM information_schema.tables WHERE table_name = 't1';
ALTER TABLE t1 KEY_BLOCK_SIZE=0;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
FROM information_schema.tables WHERE table_name = 't1';
DROP TABLE t1;
--echo # Test 6) Make sure that KEY_BLOCK_SIZE = 8 and 16
--echo # are rejected when innodb_file_per_table=OFF
# Moved from innodb-zip.test
SET SESSION innodb_strict_mode = ON;
SET GLOBAL innodb_file_per_table = OFF;
SHOW VARIABLES LIKE 'innodb_file_per_table';
--error ER_ILLEGAL_HA
CREATE TABLE t4 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=8;
SHOW WARNINGS;
--error ER_ILLEGAL_HA
CREATE TABLE t5 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=16;
SHOW WARNINGS;
SET GLOBAL innodb_file_per_table = ON;
CREATE TABLE t4 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=8;
SHOW WARNINGS;
CREATE TABLE t5 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=16;
SHOW WARNINGS;
DROP TABLE t4,t5;
--echo # Test 7) This series of tests were moved from innodb-index to here
--echo # because the second alter table t1 assumes a 16k page size.
--echo # Moving the test allows the rest of innodb-index to be run on all
--echo # page sizes. The previously disabled portions of this test were
--echo # moved as well.
CREATE TABLE t2(d varchar(17) PRIMARY KEY) ENGINE=innodb DEFAULT CHARSET=utf8;
CREATE TABLE t3(a int PRIMARY KEY) ENGINE=innodb;
INSERT INTO t3 VALUES (22),(44),(33),(55),(66);
INSERT INTO t2 VALUES ('jejdkrun87'),('adfd72nh9k'),
('adfdpplkeock'),('adfdijnmnb78k'),('adfdijn0loKNHJik');
CREATE TABLE t1(a int, b blob, c text, d text NOT NULL)
ENGINE=innodb DEFAULT CHARSET=utf8 STATS_PERSISTENT=0;
INSERT INTO t1
SELECT a,LEFT(REPEAT(d,100*a),65535),REPEAT(d,20*a),d FROM t2,t3 order by a, d;
DROP TABLE t2, t3;
SELECT COUNT(*) FROM t1 WHERE a=44;
SET SESSION sort_buffer_size = 1048576;
SELECT a,
LENGTH(b),b=LEFT(REPEAT(d,100*a),65535),LENGTH(c),c=REPEAT(d,20*a),d FROM t1
ORDER BY 1, 2, 3, 4, 5, 6;
SET SESSION sort_buffer_size = DEFAULT;
# in-place alter table should trigger ER_PRIMARY_CANT_HAVE_NULL
--replace_regex /'\d\d'/'NN'/
--error ER_DUP_ENTRY
ALTER TABLE t1 ADD PRIMARY KEY (a), ADD KEY (b(20));
DELETE FROM t1 WHERE d='null';
--replace_regex /'\d\d'/'NN'/
--error ER_DUP_ENTRY
ALTER TABLE t1 ADD PRIMARY KEY (a), ADD KEY (b(20));
DELETE FROM t1 WHERE a%2;
CHECK TABLE t1;
# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on.
# And adding a PRIMARY KEY will also add NOT NULL implicitly!
ALTER TABLE t1 ADD PRIMARY KEY (a,b(255),c(255)), ADD KEY (b(767));
SELECT COUNT(*) FROM t1 WHERE a=44;
SELECT a,
LENGTH(b), b=LEFT(REPEAT(d,100*a), 65535),LENGTH(c), c=REPEAT(d,20*a), d FROM t1;
SHOW CREATE TABLE t1;
CHECK TABLE t1;
EXPLAIN SELECT * FROM t1 WHERE b LIKE 'adfd%';
# The following tests are disabled because of the introduced timeouts for
# metadata locks at the MySQL level as part of the fix for
# Bug#45225 Locking: hang if drop table with no timeout
# The following commands now play with MySQL metadata locks instead of
# InnoDB locks
# start disabled45225_1
##
## Test locking
##
#
#CREATE TABLE t2(a int, b varchar(255), PRIMARY KEY(a,b)) ENGINE=innodb;
#INSERT INTO t2 SELECT a,LEFT(b,255) FROM t1;
#DROP TABLE t1;
#RENAME TABLE t2 to t1;
#
#connect (a,localhost,root,,);
#connect (b,localhost,root,,);
#connection a;
#SET innodb_lock_wait_timeout=1;
#begin;
## Obtain an IX lock on the table
#SELECT a FROM t1 limit 1 FOR UPDATE;
#connection b;
#SET innodb_lock_wait_timeout=1;
## This would require an S lock on the table, conflicting with the IX lock.
#--error ER_LOCK_WAIT_TIMEOUT
#CREATE INDEX t1ba ON t1 (b,a);
#connection a;
#commit;
#begin;
## Obtain an IS lock on the table
#SELECT a FROM t1 limit 1 lock in share mode;
#connection b;
## This will require an S lock on the table. No conflict with the IS lock.
#CREATE INDEX t1ba ON t1 (b,a);
## This would require an X lock on the table, conflicting with the IS lock.
#--error ER_LOCK_WAIT_TIMEOUT
#DROP INDEX t1ba ON t1;
#connection a;
#commit;
#EXPLAIN SELECT a FROM t1 ORDER BY b;
#--send
#SELECT a,sleep(2+a/100) FROM t1 ORDER BY b limit 3;
#
## The following DROP INDEX will succeed, altough the SELECT above has
## opened a read view. However, during the execution of the SELECT,
## MySQL should hold a table lock that should block the execution
## of the DROP INDEX below.
#
#connection b;
#SELECT sleep(1);
#DROP INDEX t1ba ON t1;
#
## After the index was dropped, subsequent SELECTs will use the same
## read view, but they should not be accessing the dropped index any more.
#
#connection a;
#reap;
#EXPLAIN SELECT a FROM t1 ORDER BY b;
#SELECT a FROM t1 ORDER BY b limit 3;
#commit;
#
#connection default;
#disconnect a;
#disconnect b;
#
# end disabled45225_1
DROP TABLE t1;
--echo # Test 8) Test creating a table that could lead to undo log overflow.
CREATE TABLE t1(a blob,b blob,c blob,d blob,e blob,f blob,g blob,
h blob,i blob,j blob,k blob,l blob,m blob,n blob,
o blob,p blob,q blob,r blob,s blob,t blob,u blob)
ENGINE=InnoDB ROW_FORMAT=dynamic;
SET @a = repeat('a', 767);
SET @b = repeat('b', 767);
SET @c = repeat('c', 767);
SET @d = repeat('d', 767);
SET @e = repeat('e', 767);
# With no indexes defined, we can update all columns to max key part length.
INSERT INTO t1 VALUES (@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a);
UPDATE t1 SET a=@b,b=@b,c=@b,d=@b,e=@b,f=@b,g=@b,h=@b,i=@b,j=@b,
k=@b,l=@b,m=@b,n=@b,o=@b,p=@b,q=@b,r=@b,s=@b,t=@b,u=@b;
# With this many indexes defined, we can still update all fields.
CREATE INDEX t1a ON t1 (a(767));
CREATE INDEX t1b ON t1 (b(767));
CREATE INDEX t1c ON t1 (c(767));
CREATE INDEX t1d ON t1 (d(767));
CREATE INDEX t1e ON t1 (e(767));
UPDATE t1 SET a=@c,b=@c,c=@c,d=@c,e=@c,f=@c,g=@c,h=@c,i=@c,j=@c,
k=@c,l=@c,m=@c,n=@c,o=@c,p=@c,q=@c,r=@c,s=@c,t=@c,u=@c;
# Add one more index and the UNDO record becomes too big to update all columns.
# But a single transaction can update the columns in separate statements.
# because the UNDO records will be smaller.
CREATE INDEX t1f ON t1 (f(767));
--error ER_UNDO_RECORD_TOO_BIG
UPDATE t1 SET a=@d,b=@d,c=@d,d=@d,e=@d,f=@d,g=@d,h=@d,i=@d,j=@d,
k=@d,l=@d,m=@d,n=@d,o=@d,p=@d,q=@d,r=@d,s=@d,t=@d,u=@d;
BEGIN;
UPDATE t1 SET a=@d,b=@d,c=@d,d=@d,e=@d;
UPDATE t1 SET f=@d,g=@d,h=@d,i=@d,j=@d,k=@d,l=@d,m=@d,
n=@d,o=@d,p=@d,q=@d,r=@d,s=@d,t=@d,u=@d;
COMMIT;
# More indexes can still be added and a single field can still be updated
CREATE INDEX t1g ON t1 (g(767));
UPDATE t1 SET g=@e;
CREATE INDEX t1h ON t1 (h(767));
UPDATE t1 SET h=@e;
CREATE INDEX t1i ON t1 (i(767));
UPDATE t1 SET i=@e;
CREATE INDEX t1j ON t1 (j(767));
UPDATE t1 SET j=@e;
CREATE INDEX t1k ON t1 (k(767));
UPDATE t1 SET k=@e;
CREATE INDEX t1l ON t1 (l(767));
UPDATE t1 SET l=@e;
CREATE INDEX t1m ON t1 (m(767));
UPDATE t1 SET m=@e;
CREATE INDEX t1n ON t1 (n(767));
UPDATE t1 SET n=@e;
CREATE INDEX t1o ON t1 (o(767));
UPDATE t1 SET o=@e;
CREATE INDEX t1p ON t1 (p(767));
UPDATE t1 SET p=@e;
CREATE INDEX t1q ON t1 (q(767));
UPDATE t1 SET q=@e;
CREATE INDEX t1r ON t1 (r(767));
UPDATE t1 SET r=@e;
CREATE INDEX t1s ON t1 (s(767));
UPDATE t1 SET s=@e;
# Add one more index and we cannot update a column to its defined index length.
# This is a problem. It means that the DDL is allowed to create a table
# that CANNOT be updated. See bug#12953735.
CREATE INDEX t1t ON t1 (t(767));
--error ER_UNDO_RECORD_TOO_BIG
UPDATE t1 SET t=@e;
CREATE INDEX t1u ON t1 (u(767));
CREATE INDEX t1ut ON t1 (u(767), t(767));
CREATE INDEX t1st ON t1 (s(767), t(767));
SHOW CREATE TABLE t1;
DROP TABLE t1;
--echo # Bug #12429576 - Test an assertion failure on purge.
# This test is not in innodb_8k or innodb_4k since the bug is not about
# page size. It just tests the condition that caused the assertion.
CREATE TABLE t1_purge (
A int,
B blob, C blob, D blob, E blob,
F blob, G blob, H blob,
PRIMARY KEY (B(767), C(767), D(767), E(767), A),
INDEX (A)
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
INSERT INTO t1_purge VALUES (1,
REPEAT('b', 766), REPEAT('c', 766), REPEAT('d', 766), REPEAT('e', 766),
REPEAT('f', 766), REPEAT('g', 766), REPEAT('h', 766));
CREATE TABLE t2_purge (
A int PRIMARY KEY,
B blob, C blob, D blob, E blob,
F blob, G blob, H blob, I blob,
J blob, K blob, L blob,
INDEX (B(767))) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
INSERT INTO t2_purge VALUES (1,
REPEAT('b', 766), REPEAT('c', 766), REPEAT('d', 766), REPEAT('e', 766),
REPEAT('f', 766), REPEAT('g', 766), REPEAT('h', 766), REPEAT('i', 766),
REPEAT('j', 766), REPEAT('k', 766), REPEAT('l', 766));
CREATE TABLE t3_purge (
A int,
B varchar(800), C varchar(800), D varchar(800), E varchar(800),
F varchar(800), G varchar(800), H varchar(800),
PRIMARY KEY (B(767), C(767), D(767), E(767), A),
INDEX (A)
) charset latin1 ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
INSERT INTO t3_purge SELECT * FROM t1_purge;
CREATE TABLE t4_purge (
A int PRIMARY KEY,
B varchar(800), C varchar(800), D varchar(800), E varchar(800),
F varchar(800), G varchar(800), H varchar(800), I varchar(800),
J varchar(800), K varchar(800), L varchar(800),
INDEX (B(767))) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
INSERT INTO t4_purge SELECT * FROM t2_purge;
# This would trigger the failure (Bug #12429576)
# if purge gets a chance to run before DROP TABLE t1_purge, ....
DELETE FROM t1_purge;
DELETE FROM t2_purge;
DELETE FROM t3_purge;
DELETE FROM t4_purge;
# We need to activate the purge thread.
# Instead of doing a --sleep 10 now, do it once at the end.
# Bug#12637786 - Assertion hit; ut_ad(index->is_clustered());
# A secondary index tuple is found to be too long to fit into a page.
# This test is not in innodb_8k or innodb_4k since the bug is not about
# page size. It just tests the condition that caused the assertion.
SET @r=REPEAT('a',500);
CREATE TABLE t12637786(a int,
v1 varchar(500), v2 varchar(500), v3 varchar(500),
v4 varchar(500), v5 varchar(500), v6 varchar(500),
v7 varchar(500), v8 varchar(500), v9 varchar(500),
v10 varchar(500), v11 varchar(500), v12 varchar(500),
v13 varchar(500), v14 varchar(500), v15 varchar(500),
v16 varchar(500), v17 varchar(500), v18 varchar(500)
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
CREATE INDEX idx1 ON t12637786(a,v1);
INSERT INTO t12637786 VALUES(9,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r);
UPDATE t12637786 SET a=1000;
DELETE FROM t12637786;
# We need to activate the purge thread to make sure it does not assert and
# is able to clean up the old versions of secondary index entries.
# Instead of doing a --sleep 10 now for each test, do it once at the end.
--echo # Bug#12963823 - Test that the purge thread does not crash when
# the number of indexes has changed since the UNDO record was logged.
# This test is not in innodb_8k or innodb_4k since the bug is not about
# page size. It just tests the condition that caused the crash.
CREATE TABLE t12963823(a blob,b blob,c blob,d blob,e blob,f blob,g blob,h blob,
i blob,j blob,k blob,l blob,m blob,n blob,o blob,p blob)
ENGINE=innodb ROW_FORMAT=dynamic;
SET @r = REPEAT('a', 767);
INSERT INTO t12963823 VALUES (@r,@r,@r,@r, @r,@r,@r,@r, @r,@r,@r,@r, @r,@r,@r,@r);
CREATE INDEX ndx_a ON t12963823 (a(500));
CREATE INDEX ndx_b ON t12963823 (b(500));
CREATE INDEX ndx_c ON t12963823 (c(500));
CREATE INDEX ndx_d ON t12963823 (d(500));
CREATE INDEX ndx_e ON t12963823 (e(500));
CREATE INDEX ndx_f ON t12963823 (f(500));
CREATE INDEX ndx_k ON t12963823 (k(500));
CREATE INDEX ndx_l ON t12963823 (l(500));
SET @r = REPEAT('b', 500);
UPDATE t12963823 set a=@r,b=@r,c=@r,d=@r;
UPDATE t12963823 set e=@r,f=@r,g=@r,h=@r;
UPDATE t12963823 set i=@r,j=@r,k=@r,l=@r;
UPDATE t12963823 set m=@r,n=@r,o=@r,p=@r;
ALTER TABLE t12963823 DROP INDEX ndx_a;
ALTER TABLE t12963823 DROP INDEX ndx_b;
CREATE INDEX ndx_g ON t12963823 (g(500));
CREATE INDEX ndx_h ON t12963823 (h(500));
CREATE INDEX ndx_i ON t12963823 (i(500));
CREATE INDEX ndx_j ON t12963823 (j(500));
CREATE INDEX ndx_m ON t12963823 (m(500));
CREATE INDEX ndx_n ON t12963823 (n(500));
CREATE INDEX ndx_o ON t12963823 (o(500));
CREATE INDEX ndx_p ON t12963823 (p(500));
SHOW CREATE TABLE t12963823;
# We need to activate the purge thread at this point to see if it crashes.
# Instead of doing a --sleep 10 now for each test, do it once at the end.
--echo # Bug#12547647 UPDATE LOGGING COULD EXCEED LOG PAGE SIZE
# InnoDB cannot know that this undo record would be too big for the undo
# page. Too much of text field is stored in the clustered record in this
# DYNAMIC row formatted record.
# This test is not in innodb_8k or innodb_4k since the bug is not about
# page size. It just tests the condition that caused the hang.
SET SESSION innodb_strict_mode = ON;
CREATE TABLE bug12547647(
a int NOT NULL, b blob NOT NULL, c text,
PRIMARY KEY (b(10), a), INDEX (c(767)), INDEX(b(767))
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
INSERT INTO bug12547647 VALUES (5,REPEAT('khdfo5AlOq',1900),REPEAT('g',7751));
COMMIT;
# The following used to cause a hang while doing infinite undo log allocation.
--error ER_UNDO_RECORD_TOO_BIG
UPDATE bug12547647 SET c = REPEAT('b',16928);
SHOW WARNINGS;
DROP TABLE bug12547647;
# The following should fail in non-strict mode too.
# (The fix of Bug #50945 only affects REDUNDANT and COMPACT tables.)
SET SESSION innodb_strict_mode = off;
CREATE TABLE t1(
c text NOT NULL, d text NOT NULL,
PRIMARY KEY (c(767),d(767)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
DROP TABLE t1;
CREATE TABLE t1(
c text NOT NULL, d text NOT NULL,
PRIMARY KEY (c(767),d(767)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2 CHARSET=ASCII;
DROP TABLE t1;
CREATE TABLE t1(
c text NOT NULL, d text NOT NULL,
PRIMARY KEY (c(767),d(767)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4 CHARSET=ASCII;
drop table t1;
CREATE TABLE t1(c text, PRIMARY KEY (c(440)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
DROP TABLE t1;
CREATE TABLE t1(c text, PRIMARY KEY (c(438)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
INSERT INTO t1 VALUES(REPEAT('A',512)),(REPEAT('B',512));
DROP TABLE t1;
--echo #
--echo # Bug#56862 Execution of a query that uses index merge returns a wrong result
--echo #
# Moved to here from innodb_mysql.test. Some PB3 systems sporadically
# had timeouts doing this with smaller page sizes.
CREATE TABLE t1 (
pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
a int,
b int,
INDEX idx(a))
ENGINE=INNODB;
INSERT INTO t1(a,b) VALUES
(11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500),
(3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800),
(6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700),
(13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000);
INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1;
INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1;
INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1 VALUES (1000000, 0, 0);
set @optimizer_switch_saved=@@optimizer_switch;
SET SESSION optimizer_switch='derived_merge=off';
SET SESSION sort_buffer_size = 1024*36;
EXPLAIN
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
SELECT COUNT(*) FROM
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
set @@optimizer_switch=@optimizer_switch_saved;
SET SESSION sort_buffer_size = DEFAULT;
DROP TABLE t1;
# The tests that uses these tables required the purge thread to run.
# Just in case it has not by now, provide a 10 second wait.
--sleep 10
DROP TABLE t1_purge, t2_purge, t3_purge, t4_purge;
DROP TABLE t12637786;
DROP TABLE t12963823;
|