On Mon, 2025-02-24 at 15:03 -0500, Tom Lane wrote:
> Jeff Davis <pg...@j-davis.com> writes:
> > But you have a point in that float4in() does slightly more work
> > than
> > strtof() to handle platform differences about NaN/Inf. I'm not sure
> > how
> > much to weigh that concern, but I agree that there is non-zero
> > cognitive overhead here.
> 
> If we're speaking strictly about the reltuples value, I'm not hugely
> concerned about that.  reltuples should never be NaN or Inf.

There actually is a concern here, in that the backend always has
LC_NUMERIC=C when doing float4in/out, but pg_dump does not. Patch
attached.

Regards,
        Jeff Davis

diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 955550b91d2..ed85d843d5f 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -521,6 +521,9 @@ main(int argc, char **argv)
 		{NULL, 0, NULL, 0}
 	};
 
+	/* ensure that locale does not affect floating point interpretation */
+	setlocale(LC_NUMERIC, "C");
+
 	pg_logging_init(argv[0]);
 	pg_logging_set_level(PG_LOG_WARNING);
 	set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_dump"));

Reply via email to