Skip to content

pgtype: quote text range bounds - #2647

Open
sueun-dev wants to merge 1 commit into
jackc:masterfrom
sueun-dev:fix-range-text-quoting-20260906
Open

pgtype: quote text range bounds#2647
sueun-dev wants to merge 1 commit into
jackc:masterfrom
sueun-dev:fix-range-text-quoting-20260906

Conversation

@sueun-dev

Copy link
Copy Markdown
Contributor

RangeCodec appends text bounds without quoting them. For a custom range with a text subtype, an empty string becomes an unbounded endpoint, a comma or quote produces a malformed range literal, and a backslash can disappear from the bound PostgreSQL reads.

Quote bounds containing range syntax and escape embedded quotes and backslashes with the existing quoting helper. Binary encoding is unchanged. The tests use a real PostgreSQL text range, check both endpoints and buffer reuse, and include plain text, whitespace and braces as controls.

Tested with Go 1.25.13 and PostgreSQL 18.6 on Linux arm64:

go test ./pgtype -run 'TestRangeCodecText(Bounds|FiniteBounds)$' -count=20
go test -race ./... -count=1
go build ./...

Both regression tests fail on the base commit and pass with this change. Optional authentication, TLS and PgBouncer tests were not configured. go vet and golangci-lint 2.13.2 report existing unkeyed test literals and formatting findings, reproduced on the base tree as well.

This is an AI proposal produced with Codex. The task was to investigate a held range-encoding defect, reproduce it against PostgreSQL, and prepare a minimal fix with regression and broader tests. It has not had human code review.

Signed-off-by: Sueun Cho <sueun.dev@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.

1 participant