Skip to content

MINOR: [perl] skip bytes and fixed relative to current position in decoder - #3964

Open
arib06 wants to merge 1 commit into
apache:mainfrom
arib06:perl-skip-relative-seek
Open

MINOR: [perl] skip bytes and fixed relative to current position in decoder#3964
arib06 wants to merge 1 commit into
apache:mainfrom
arib06:perl-skip-relative-seek

Conversation

@arib06

@arib06 arib06 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of the change

Avro::BinaryDecoder skips a writer field it does not need with $reader->seek($n, 0), but whence 0 is SEEK_SET (absolute) rather than SEEK_CUR (relative). skip_bytes (also used for skip_string) and skip_fixed therefore jump to an absolute offset equal to the field length instead of advancing past the field.

When a reader schema projects away a bytes/string/fixed field that is not the last writer field, the stream position is left wrong and every following field is decoded from the wrong offset, silently yielding wrong values (or a later marker-mismatch error on data files). The sibling decode_bytes/decode_fixed consume exactly the field bytes, so this only affects the skip path. Using Fcntl->SEEK_CUR makes the skip advance from the current position.

Verifying this change

This change added tests and can be verified as follows:

  • Added cases to t/03_bin_decode.t that decode a record with a projecting reader schema where a skipped bytes field and a skipped fixed field are each followed by another field. The trailing field now decodes correctly; on the current code it reads a wrong value.

Documentation

  • Does this pull request introduce a new feature? no

@github-actions github-actions Bot added the Perl label Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant