Commit cc63c43
committed
fix(bug-7): prevent NULL columns from collapsing CONCAT checksum
MySQL CONCAT() returns NULL if any argument is NULL, causing SHA2(CONCAT(...))
to produce NULL for any row with nullable columns. Two genuinely different
rows both hash to NULL and compare as equal — silently dropping real
data differences from the diff output.
Fix: wrap each column in IFNULL(col, '\0') inside the CAST before
concatenation, and add a NULL-presence bitmap (IF(col IS NULL, '1', '0'))
as a secondary comparison column. The WHERE clause now checks both
hash1 <> hash2 OR nullmap1 <> nullmap2, so:
- NULL vs empty string are distinguished (different bitmaps)
- NULL vs non-NULL values are caught (different hashes + bitmaps)
- Regular value changes continue to work via hash comparison
Refs: bugs.md Bug #7, PR #77, PR #631 parent c5c2b75 commit cc63c43
1 file changed
Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
385 | | - | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
386 | 393 | | |
387 | 394 | | |
388 | 395 | | |
389 | 396 | | |
390 | 397 | | |
| 398 | + | |
391 | 399 | | |
392 | 400 | | |
| 401 | + | |
393 | 402 | | |
394 | 403 | | |
395 | 404 | | |
| |||
399 | 408 | | |
400 | 409 | | |
401 | 410 | | |
402 | | - | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
403 | 414 | | |
404 | 415 | | |
405 | | - | |
| 416 | + | |
406 | 417 | | |
407 | 418 | | |
408 | 419 | | |
| |||
0 commit comments