From 9665b5a591feb72289b580caf79a7dc7fc92f03c Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Wed, 31 Dec 2025 13:39:35 +0000 Subject: [PATCH] Don't reset extra_float_digits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In PostgreSQL ≤11 the extra_float_digits parameter controlled how many digits were used for floating point numbers. It was set here to ensure people didn't accidentally needlessly lose precision (in 78a464e it was set to 3. In 5941153 it was changed to 2 as people reported problems on PostgreSQL ≤8.4, see #199). Since PostgreSQL 12 it will always use maximum precision unless it's set to ≤0. We only support PostgreSQL ≥14 now, so we can just remove it here. Ref: https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-FLOAT Fixes #475 Fixes #1150 Fixes #1146 --- conn_test.go | 17 ++++++++--------- connector.go | 3 --- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/conn_test.go b/conn_test.go index f719a4456..d2648a751 100644 --- a/conn_test.go +++ b/conn_test.go @@ -197,15 +197,14 @@ localhost:*:*:*:pass_C assertPassword := func(extra values, expected string) { o := values{ - "host": "localhost", - "sslmode": "disable", - "connect_timeout": "20", - "user": "majid", - "port": "5432", - "extra_float_digits": "2", - "dbname": "pqgotest", - "client_encoding": "UTF8", - "datestyle": "ISO, MDY", + "host": "localhost", + "sslmode": "disable", + "connect_timeout": "20", + "user": "majid", + "port": "5432", + "dbname": "pqgotest", + "client_encoding": "UTF8", + "datestyle": "ISO, MDY", } for k, v := range extra { o[k] = v diff --git a/connector.go b/connector.go index 1145e1225..b15325e86 100644 --- a/connector.go +++ b/connector.go @@ -55,9 +55,6 @@ func NewConnector(dsn string) (*Connector, error) { // * Explicitly passed connection information o["host"] = "localhost" o["port"] = "5432" - // N.B.: Extra float digits should be set to 3, but that breaks - // Postgres 8.4 and older, where the max is 2. - o["extra_float_digits"] = "2" for k, v := range parseEnviron(os.Environ()) { o[k] = v }