Conversation
This branch has not been deployed
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.
Summary
Carry libpq PQfmod into numeric result-field metadata as POSTGRESQL:typmod. The proposed spelling follows POSTGRESQL:type and is open to review. Numeric values remain UTF-8 with the existing opaque extension; there is no numeric conversion, inference, buffering, or additional query.
The modifier is preserved by COPY result description and the non-COPY reader. Only numeric fields with an explicitly supplied modifier receive the key; -1 remains distinguishable from absent metadata. Parameter schemas and catalog discovery are unchanged.
Motivation and scope
PostgreSQL already supplies declared numeric precision and scale through the result-column type modifier returned by
PQfmod, but that information is not currently carried into the driver's Arrow result fields. A downstream consumer receives the exact numeric string without those declared bounds. Preserving the modifier lets consumers make informed conversion decisions without parsing SQL or requiring callers to supply types that PostgreSQL has already described. When PostgreSQL supplies no modifier, this change preserves-1; it does not invent precision or scale.This is deliberately narrower than converting numeric values into Arrow decimals, inferring bounds from returned values, or accepting a caller-requested output schema. It preserves information already supplied by PostgreSQL while leaving the value representation and conversion policy unchanged. Those features could use this metadata, but this change does not implement or replace them.
Relative to the related work, this carries the result modifier discussed in #758 alongside the type-name metadata added in #4687. It does not implement the requested-output-schema proposal in #1514 or the numeric conversion option in #1521.
Tests
Related: the PQfmod discussion in #758 and numeric metadata in #4687. This exposes existing result metadata and does not implement #1514 or #1521.
Closes #4797
Assisted-by: OpenAI Codex