Commit 16e196b
committed
MDEV-24931: Fix Bitmap<64>::is_prefix assertion with >64-column NATURAL JOIN on derived table
When a NATURAL JOIN operates on a derived table (or view with
derived_merge=off) having more than 64 columns, the optimizer's
generate_derived_keys_for_table() would:
1) Overflow a 32-bit shift: (key_part_map)(1 << parts) when parts >= 32
2) Create a derived key with more parts than Bitmap<64>/key_part_map can hold
3) Crash on DBUG_ASSERT(prefix_size <= width) in Bitmap<64>::is_prefix(65)
Fix: cap derived keys at sizeof(key_part_map)*8 (64) parts. Excess columns
are excluded from the key (keyuse->key = MAX_KEY). Also fix the shift to
cast before shifting: (key_part_map) 1 << parts.1 parent c43bf13 commit 16e196b
3 files changed
Lines changed: 85 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
567 | 567 | | |
568 | 568 | | |
569 | 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 | + | |
570 | 602 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
439 | 439 | | |
440 | 440 | | |
441 | 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 | + | |
442 | 480 | | |
443 | 481 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14071 | 14071 | | |
14072 | 14072 | | |
14073 | 14073 | | |
| 14074 | + | |
14074 | 14075 | | |
14075 | 14076 | | |
14076 | 14077 | | |
14077 | 14078 | | |
14078 | 14079 | | |
14079 | 14080 | | |
14080 | 14081 | | |
14081 | | - | |
| 14082 | + | |
14082 | 14083 | | |
14083 | 14084 | | |
14084 | 14085 | | |
14085 | 14086 | | |
14086 | 14087 | | |
14087 | 14088 | | |
14088 | | - | |
| 14089 | + | |
| 14090 | + | |
14089 | 14091 | | |
14090 | 14092 | | |
14091 | 14093 | | |
14092 | 14094 | | |
14093 | 14095 | | |
| 14096 | + | |
| 14097 | + | |
| 14098 | + | |
| 14099 | + | |
| 14100 | + | |
| 14101 | + | |
| 14102 | + | |
| 14103 | + | |
| 14104 | + | |
| 14105 | + | |
| 14106 | + | |
14094 | 14107 | | |
14095 | 14108 | | |
14096 | 14109 | | |
| |||
0 commit comments