|
503 | 503 |
|
504 | 504 |
|
505 | 505 |
|
| 506 | +# |
| 507 | +# Bug#22195588 : SETTING NULL TO A DYNAMIC IN-MEMORY COLUMN CORRUPTS DISK COLUMN VALUES |
| 508 | +# |
| 509 | +# Setting up tables |
| 510 | +create table t1( |
| 511 | +a int unsigned auto_increment primary key, |
| 512 | +b int, |
| 513 | +c int default null column_format dynamic storage memory, |
| 514 | +d varchar(100) default null column_format dynamic storage memory |
| 515 | +)tablespace table_space1 storage disk engine=ndbcluster; |
| 516 | +# Populate t1 |
| 517 | +# Setting all the dynamic columns to NULL and varying disk parts |
| 518 | +insert into t1 () values(); |
| 519 | +insert into t1 (b) values (10); |
| 520 | +# Populating values to single dynamic column and varying disk parts |
| 521 | +insert into t1 (c) values (20); |
| 522 | +insert into t1 (b, c) values (10, 20); |
| 523 | +insert into t1 (d) values (repeat('0123456789', 3)); |
| 524 | +insert into t1 (d) values (repeat('0123456789', 10)); |
| 525 | +insert into t1 (b, d) values (10, repeat('0123456789',3)); |
| 526 | +insert into t1 (b, d) values (10, repeat('0123456789',10)); |
| 527 | +# Both dynamic columns have non NULL values and disk columns varied |
| 528 | +insert into t1 (c, d) values (20, repeat('0123456789',3)); |
| 529 | +insert into t1 (c, d) values (20, repeat('0123456789',10)); |
| 530 | +insert into t1 (b, c, d) values (10, 20, repeat('0123456789',3)); |
| 531 | +insert into t1 (b, c, d) values (10, 20, repeat('0123456789',10)); |
| 532 | +# Verify that they are properly stored and retrieved |
| 533 | +select * from t1 order by a; |
| 534 | +a b c d |
| 535 | +1 NULL NULL NULL |
| 536 | +2 10 NULL NULL |
| 537 | +3 NULL 20 NULL |
| 538 | +4 10 20 NULL |
| 539 | +5 NULL NULL 012345678901234567890123456789 |
| 540 | +6 NULL NULL 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 |
| 541 | +7 10 NULL 012345678901234567890123456789 |
| 542 | +8 10 NULL 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 |
| 543 | +9 NULL 20 012345678901234567890123456789 |
| 544 | +10 NULL 20 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 |
| 545 | +11 10 20 012345678901234567890123456789 |
| 546 | +12 10 20 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 |
| 547 | +# Update some rows to verify that the varpart is reallocating properly |
| 548 | +# Updating NULL dynamic columns and assigning NON-NULL values |
| 549 | +update t1 set c = 10 where a in (1,2); |
| 550 | +select * from t1 where a in (1,2) order by a; |
| 551 | +a b c d |
| 552 | +1 NULL 10 NULL |
| 553 | +2 10 10 NULL |
| 554 | +# Updating and setting NULL to NON-NULL dynamic columns |
| 555 | +update t1 set c = null where a in (1,2); |
| 556 | +select * from t1 where a in (1,2) order by a; |
| 557 | +a b c d |
| 558 | +1 NULL NULL NULL |
| 559 | +2 10 NULL NULL |
| 560 | +# Updating NULL dynamic var columns and assigning NON-NULL values |
| 561 | +update t1 set d = repeat('0123456789', 5) where a in (1,2); |
| 562 | +select * from t1 where a in (1,2) order by a; |
| 563 | +a b c d |
| 564 | +1 NULL NULL 01234567890123456789012345678901234567890123456789 |
| 565 | +2 10 NULL 01234567890123456789012345678901234567890123456789 |
| 566 | +# Updating NULL to NON-NULL and vice versa in dynamic columns |
| 567 | +update t1 set c = null, d = repeat('0123456789', 10) where a in (3,4); |
| 568 | +select * from t1 where a in (3,4) order by a; |
| 569 | +a b c d |
| 570 | +3 NULL NULL 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 |
| 571 | +4 10 NULL 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 |
| 572 | +# Updating and setting NULL to NON-NULL dynamic var columns |
| 573 | +update t1 set c = 20, d = null where a in (5,6,7,8); |
| 574 | +select * from t1 where a in (5,6,7,8) order by a; |
| 575 | +a b c d |
| 576 | +5 NULL 20 NULL |
| 577 | +6 NULL 20 NULL |
| 578 | +7 10 20 NULL |
| 579 | +8 10 20 NULL |
| 580 | +# Update all dynamic columns to NULL |
| 581 | +update t1 set c = null, d = null where a > 8; |
| 582 | +select * from t1 where a > 8 order by a; |
| 583 | +a b c d |
| 584 | +9 NULL NULL NULL |
| 585 | +10 NULL NULL NULL |
| 586 | +11 10 NULL NULL |
| 587 | +12 10 NULL NULL |
| 588 | +# Update all dynamic columns to NON-NULL values |
| 589 | +update t1 set c = 20, d = '0123456789' where a > 8; |
| 590 | +select * from t1 where a > 8 order by a; |
| 591 | +a b c d |
| 592 | +9 NULL 20 0123456789 |
| 593 | +10 NULL 20 0123456789 |
| 594 | +11 10 20 0123456789 |
| 595 | +12 10 20 0123456789 |
| 596 | +select * from t1 order by a; |
| 597 | +a b c d |
| 598 | +1 NULL NULL 01234567890123456789012345678901234567890123456789 |
| 599 | +2 10 NULL 01234567890123456789012345678901234567890123456789 |
| 600 | +3 NULL NULL 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 |
| 601 | +4 10 NULL 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 |
| 602 | +5 NULL 20 NULL |
| 603 | +6 NULL 20 NULL |
| 604 | +7 10 20 NULL |
| 605 | +8 10 20 NULL |
| 606 | +9 NULL 20 0123456789 |
| 607 | +10 NULL 20 0123456789 |
| 608 | +11 10 20 0123456789 |
| 609 | +12 10 20 0123456789 |
| 610 | +# Now do some transactions with multiple operations |
| 611 | +# Add more data to dynamic varchar and then set to NULL |
| 612 | +# Meanwhile insert value into int column |
| 613 | +select * from t1 where a = 1; |
| 614 | +a b c d |
| 615 | +1 NULL NULL 01234567890123456789012345678901234567890123456789 |
| 616 | +begin; |
| 617 | +update t1 set d = repeat('0123456789', 10) where a = 1; |
| 618 | +update t1 set b = 20 where a = 1; |
| 619 | +update t1 set d = NULL where a = 1; |
| 620 | +update t1 set c = 30 where a = 1; |
| 621 | +commit; |
| 622 | +select * from t1 where a = 1; |
| 623 | +a b c d |
| 624 | +1 20 30 NULL |
| 625 | +# Setting up next transaction - make dynamic columns NULL |
| 626 | +update t1 set c = NULL where a = 1; |
| 627 | +# Insert and later set null to dynamic columns in the same transaction |
| 628 | +select * from t1 where a = 1; |
| 629 | +a b c d |
| 630 | +1 20 NULL NULL |
| 631 | +begin; |
| 632 | +update t1 set c = 30 where a = 1; |
| 633 | +update t1 set b = 30 where a = 1; |
| 634 | +update t1 set d = repeat('0123456789', 10) where a = 1; |
| 635 | +update t1 set b = 45 where a = 1; |
| 636 | +update t1 set d = repeat('0123456789', 5) where a = 1; |
| 637 | +update t1 set c = NULL where a = 1; |
| 638 | +update t1 set d = NULL where a = 1; |
| 639 | +commit; |
| 640 | +select * from t1 where a = 1; |
| 641 | +a b c d |
| 642 | +1 45 NULL NULL |
| 643 | +# Grow the dynamic varchar and then shrink it but still having more data than when it was at start. |
| 644 | +# Insert alternatively the other dynamic column with NULL but back to a NON-NULL value at end |
| 645 | +select * from t1 where a = 12; |
| 646 | +a b c d |
| 647 | +12 10 20 0123456789 |
| 648 | +begin; |
| 649 | +update t1 set c = 42 where a = 12; |
| 650 | +update t1 set d = repeat('0123456789', 5) where a = 12; |
| 651 | +update t1 set c = NULL where a = 12; |
| 652 | +update t1 set d = repeat('0123456789', 10) where a = 12; |
| 653 | +update t1 set c = 30 where a = 12; |
| 654 | +update t1 set d = repeat('0123456789', 2) where a = 12; |
| 655 | +commit; |
| 656 | +select * from t1 where a = 12; |
| 657 | +a b c d |
| 658 | +12 10 30 01234567890123456789 |
| 659 | +# Cleanup |
| 660 | +drop table t1; |
| 661 | +ALTER TABLESPACE table_space1 |
| 662 | +DROP DATAFILE './table_space1/datafile.dat' |
| 663 | +ENGINE = NDB; |
| 664 | +DROP TABLESPACE table_space1 |
| 665 | +ENGINE = NDB; |
| 666 | +DROP LOGFILE GROUP log_group1 |
| 667 | +ENGINE =NDB; |
0 commit comments