Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostGIS+PGraster: pass exact floating-point numbers in SQL queries #4089

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lightmare
Copy link
Contributor

Fixes #4079
Refs #2361

Pass floating-point numbers in SQL queries with explicit type cast and in hexfloat format (exact value). Postgres parses floats with stdtod, which understands hexfloat since C99.

On plugin side, I intended to use stream format std::hexfloat, but to my surprise libstdc++ 4.9 (which clang builds on travis still use) does not implement it (was added in libstdc++ 5.1). In the end, using C99 snprintf to produce what's going to be parsed by C99 strtod seems like a much better idea.

TODO

The table has proper ID and GEOM columns, so it must be usable even
though there's no data in it.
ST_MakeEnvelope accepts coordinates as float8 (double precision).
Use hexfloat format to pass exact values, avoiding wonky conversion
to and from decimal.
@codecov
Copy link

codecov bot commented Sep 26, 2019

Codecov Report

Merging #4089 into master will increase coverage by 0.02%.
The diff coverage is 44.82%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4089      +/-   ##
==========================================
+ Coverage   72.05%   72.07%   +0.02%     
==========================================
  Files         452      453       +1     
  Lines       24324    24314      -10     
==========================================
- Hits        17526    17525       -1     
+ Misses       6798     6789       -9
Impacted Files Coverage Δ
plugins/input/pgraster/pgraster_datasource.hpp 0% <ø> (ø) ⬆️
plugins/input/pgraster/pgraster_datasource.cpp 0.95% <0%> (+0.01%) ⬆️
plugins/input/pgcommon/sql_utils.hpp 100% <100%> (ø)
plugins/input/postgis/postgis_datasource.cpp 79.64% <41.66%> (-0.36%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fdf6004...6c2faf3. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

postgis: select with unbounded extent fails
1 participant