Skip to content

fix: csv import honors MAX_RECORD instead of a fixed 1KB line cap (#67) - #70

Merged
mscasso-scanoss merged 1 commit into
masterfrom
fix/issue-67-csv-max-record-4.x
Oct 27, 2026
Merged

mscasso-scanoss merged 1 commit into
masterfrom
fix/issue-67-csv-max-record-4.x

Conversation

@mscasso-scanoss

Copy link
Copy Markdown
Collaborator

Summary

Fixes #67 on the master (4.x / MD5) line. Port of the same fix merged into crc64 (#69). bulk insert from CSV silently skipped every line longer than 1,023 bytes (a fixed MAX_CSV_LINE_LEN cap applied to the whole getline() line), ignoring MAX_RECORD. Records that should fit (e.g. with MAX_RECORD=2048) were lost, and the skip was only logged at debug level.

Changes

  • Remove the fixed 1 KB whole-line cap in ldb_import_csv (src/import.c). The lower bound (line too short to hold a key + separators) is kept; the upper bound now follows MAX_RECORD.
  • Enforce MAX_RECORD on the record data size (r_size), consistent with collate's size > max_rec_ln filter. Hard-capped by the 2-byte record-size field (LDB_MAX_REC_LN).
  • No more silent drops: an oversized record is counted in the import summary and logged at info level.
  • data_bin grows with the line buffer instead of being a fixed 1 KB stack array, so binary (.enc/base64) records are no longer truncated; freed on every exit path.
  • collate.c: raise tuple_bin from MAX_CSV_LINE_LEN to LDB_MAX_REC_LN so delete/collate can decode and match records up to MAX_RECORD (this buffer does not exist on the crc64 branch, which already uses LDB_MAX_REC_LN-sized buffers).
  • Bump version to 4.1.13; document the MAX_RECORD import behaviour in README.md.

Testing

  • New regression test test_13_import_respects_max_record_not_fixed_line_len in test/test_kb: lines of 1000/1100/2000/3000 bytes imported with MAX_RECORD=2048 — the 1100 and 2000-byte records (dropped by the old cap) are now stored; the 3000-byte one (data > MAX_RECORD) is skipped, counted, and logged.
  • Reproduced the bug against master HEAD (lines ≥1024 dropped) and confirmed the fix.
  • Full suite (./run_test.sh) passes: Overall result: SUCCESS.

🤖 Generated with Claude Code

bulk insert silently skipped every CSV line longer than 1,023 bytes via a
fixed MAX_CSV_LINE_LEN cap applied to the whole getline() line, ignoring
MAX_RECORD. Records that should fit (e.g. with MAX_RECORD=2048) were lost,
and the skip was only logged at debug level.

The upper bound now follows MAX_RECORD and is enforced on the record data
size, consistent with collate (size > max_rec_ln). Oversized records are
counted in the import summary and logged at info level instead of being
dropped in silence. The base64 decode buffer (data_bin) grows with the line
buffer instead of being a fixed 1 KB stack array, so binary records are no
longer truncated. collate's tuple_bin decode buffer is likewise raised from
the 1 KB constant to LDB_MAX_REC_LN so delete/collate can match records up to
MAX_RECORD.

Adds test_13 to test/test_kb, bumps version to 4.1.13, and documents the
MAX_RECORD import behaviour in README.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mscasso-scanoss mscasso-scanoss self-assigned this Oct 27, 2026
@mscasso-scanoss
mscasso-scanoss merged commit e7b8342 into master Oct 27, 2026
@mscasso-scanoss
mscasso-scanoss deleted the fix/issue-67-csv-max-record-4.x branch October 27, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

csv bulk import silently drops lines longer than 1,023 bytes, ignoring MAX_RECORD

1 participant