Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

NUMERIC read as DOUBLE doesn't match Postgres's float8 cast

Chiusa
#604 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Una pull request collegata è già stata integrata.

  • #610 di @ItsM0rty — integrata

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp, postgresql
Ambito
databases

Direzione di ricerca

The issue identifies DecimalConversionDouble in the binary numeric decoder; start by finding that implementation and the tests for decoding PostgreSQL numeric values as DOUBLE. Compare binary protocol results with the text protocol and PostgreSQL's numeric::float8 cast for the reported values. Done means the binary path returns the same nearest double as PostgreSQL for these cases.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

On main (8d201d4), numeric values that the extension reads as DOUBLE (unconstrained numeric, or a numeric too wide for DuckDB's DECIMAL) sometimes differ from Postgres's own numeric::float8 cast:

memory D ATTACH '' as pg (TYPE postgres);
memory D SELECT n AS duckdb, f AS postgres, n = f AS same
         FROM postgres_query('pg', 'SELECT n, n::float8 AS f FROM (
            SELECT 8629433::numeric / 1000
            UNION ALL SELECT avg(x) FROM (VALUES (275.38), (232.58), (785.33)) v(x)
            UNION ALL SELECT 1e32
          ) t(n)');
┌───────────────────────┬───────────────────┬─────────┐
│        duckdb         │     postgres      │  same   │
│        double         │      double       │ boolean │
├───────────────────────┼───────────────────┼─────────┤
│     8629.432999999999 │          8629.433 │ false   │
│    431.09666666666664 │ 431.0966666666667 │ false   │
│ 9.999999999999999e+31 │             1e+32 │ false   │
└───────────────────────┴───────────────────┴─────────┘

These aren't the nearest double to the exact value, which is what Postgres's cast (through strtod) gives.

With SET pg_use_text_protocol = true the same query returns the correct values, so the problem is in decoding the binary numeric format. The cause is DecimalConversionDouble, which builds the double with floating-point arithmetic that rounds at each step.

Lingua principale
C++
Stelle
373
Fork
112
Merge medio
9h 48m
PR unite (30g)
28

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di duckdb/duckdb-postgres

Tutte le issue di duckdb/duckdb-postgres

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.