Skip to content

Preserve stdin and successful diagnostics in noninteractive psql - #59

Open
puncsky wants to merge 1 commit into
render-oss:mainfrom
puncsky:fix/preserve-successful-psql-diagnostics-20261029
Open

puncsky wants to merge 1 commit into
render-oss:mainfrom
puncsky:fix/preserve-successful-psql-diagnostics-20261029

Conversation

@puncsky

@puncsky puncsky commented Oct 30, 2026

Copy link
Copy Markdown

Summary

Noninteractive psql starts its child without stdin and discards stderr when the command succeeds. Forward Cobra's input reader to the child and send successful WARNING/NOTICE output to Cobra's stderr writer while keeping stdout as the structured result.

Motivation

Piped COPY / pstdin imports can read EOF and import no rows, and successful SQL can silently lose important diagnostics. The same subprocess helper now preserves both streams; nonzero child errors retain their existing error path.

How to verify

go test ./cmd/... ./pkg/... ./internal/...
  • All 57 development packages pass on the candidate.
  • Real child-process tests cover exact CSV/Unicode/newline input, empty input, commands that do not read input, stdout plus warning, notice-only success, and nonzero errors. Removing stdin forwarding or diagnostics forwarding fails the corresponding behavioral tests.
  • New-code lint is clean against c31e586e; full lint on unmodified main reports 92 pre-existing findings with the pinned golangci-lint v2.14.0.

Release notes

Noninteractive psql forwards piped input and preserves successful PostgreSQL warnings and notices on stderr.

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.

1 participant