Repository navigation
Conversation
PostgreSQL writes the non-finite values of float4 and float8 as "NaN", "Infinity" and "-Infinity". Both drivers read them as 0.0: PgSqlResultIterator cast them with (float), and ext-pq's own conversion does the same. The pgsql iterator now maps the three words, and the pq connection registers a converter for the two float types. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Both drivers read the non-finite values of
float4andfloat8as0.0:Nothing fails, so the wrong number is easy to miss.
Cause and fix
PostgreSQL writes these values as the words
NaN,Infinityand-Infinity.PgSqlResultIteratorcast them with(float). It now maps the three words first.PqHandleregisters apq\Converterfor the two float types. It applies to array elements too.NaNis returned withfdiv(0, 0)because Psalm 6.15.1 on PHP 8.5 crashed analysing theNANconstant ("unexpected NAN value was coerced to string").Tests
The new test covers scalars and a
float8[]for both drivers, and fails on 2.x. The suite passes locally on theeventandstream_selectdrivers, and Psalm and php-cs-fixer report nothing new. With theevdriver the pgsql tests are skipped or fail on the existing pecl-ev check, as on 2.x.🤖 Generated with Claude Code