Skip to content

fix(pgcopy): return clear error when row has more columns than tuple size#437

Open
SAY-5 wants to merge 1 commit intoGreenmaskIO:mainfrom
SAY-5:fix/pgcopy-decode-column-overflow-432
Open

fix(pgcopy): return clear error when row has more columns than tuple size#437
SAY-5 wants to merge 1 commit intoGreenmaskIO:mainfrom
SAY-5:fix/pgcopy-decode-column-overflow-432

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 23, 2026

Fixes #432.

Problem

Row.Decode assumed the delimited columns in the raw COPY stream matched tupleSize. A transformation with a user query: that returns additional columns (for join/lookup use cases) exceeded len(r.columnPos) in the static branch, and r.columnPos[idx] panicked the dump pipeline:

panic: runtime error: index out of range [5] with length 5
internal/db/postgres/pgcopy.(*Row).Decode row.go:103
internal/db/postgres/dumpers.(*TransformationPipeline).Dump transformation_pipeline.go:160

Fix

Return a descriptive error naming tupleSize so operators see an actionable message instead of a hard panic. The isDynamic path is unchanged.

Test

go test ./internal/db/postgres/pgcopy/... passes locally.

…size

Row.Decode assumed the number of delimited columns in the raw stream
matched the configured tupleSize. When a transformation's query:
parameter returned additional columns (for join/lookup use cases),
the static-size branch fell through to r.columnPos[idx] with
idx >= len(columnPos) and panicked the dump pipeline with
'runtime error: index out of range [N] with length N' inside
transformation_pipeline.Dump.

Return a descriptive error naming tupleSize so operators see a
actionable message rather than a hard panic. The isDynamic path
is unchanged.

Refs GreenmaskIO/greenmask issue 432.

Signed-off-by: SAY-5 <say.apm35@gmail.com>
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.

"panic: runtime error: index out of range [5] with length 5" if selecting additional columns

1 participant