Encode duration as bigint for pgx simple protocol#10529
Merged
simvlad merged 3 commits intoJun 5, 2026
Conversation
rodrigozhou
reviewed
Jun 4, 2026
Contributor
rodrigozhou
left a comment
There was a problem hiding this comment.
Can you pull the changes to the tests I made in #10524 here? It would run unit tests verifying that this works correctly.
rodrigozhou
reviewed
Jun 4, 2026
0e821c6 to
52ede9c
Compare
rodrigozhou
approved these changes
Jun 4, 2026
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed?
Remap
time.Durationto Postgres int8 (bigint) on pgx connections.Why?
See #10514. By default pgx encodes time.Duration as an interval (e.g. 00:00:05). Currently, there is a single Duration column VisibilityRow execution_duration which is written as a BigInt. Under the simple query protocol (PgBouncer transaction pooling) the write is rejected with invalid input syntax for type bigint. int8 sends the underlying int64 nanosecond count instead.
How did you test it?
Potential risks
The time.Duration → int8 mapping is changed for pgx driver, so not scoped to simple protocol. This should be fine, as tests exercise it with existing asserts and new
s.Equal(req.ExecutionDuration, resp.GetExecutionDuration().AsDuration())