fix insert ignore panic#22754
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||||||
PR Code Suggestions ✨No code suggestions found for the PR. |
Fixes panic `index out of range [29] with length 29` in `INSERT IGNORE` with duplicate primary keys. **Root cause**: When `Batches.Shrink()` removes duplicate rows (35→23), `InputBatchRowCount` was not updated, causing bitmap initialization with wrong size. **Test**: Added test case with 35 rows (12 duplicates) to verify deduplication works correctly. Approved by: @ouyuanning, @heni02
User description
What type of PR is this?
Which issue(s) this PR fixes:
issue #22733
What this PR does / why we need it:
Fixes panic
index out of range [29] with length 29inINSERT IGNOREwith duplicate primary keys.Root cause: When
Batches.Shrink()removes duplicate rows (35→23),InputBatchRowCountwas not updated, causing bitmap initialization with wrong size.Test: Added test case with 35 rows (12 duplicates) to verify deduplication works correctly.
PR Type
Bug fix
Description
Fix panic in INSERT IGNORE with duplicate primary keys
Update InputBatchRowCount after Batches.Shrink removes duplicates
Add comprehensive test case with 35 rows and 12 duplicates
Diagram Walkthrough
File Walkthrough
hashmap_util.go
Update InputBatchRowCount after shrinking batchespkg/sql/colexec/hashmap_util/hashmap_util.go
InputBatchRowCountafterBatches.Shrink()removes duplicaterows
duplicates
insert_ignore.sql
Add regression test for INSERT IGNORE panictest/distributed/cases/dml/insert/insert_ignore.sql
behavior
insert_ignore.result
Add expected results for INSERT IGNORE testtest/distributed/cases/dml/insert/insert_ignore.result