From 4ba61a487e39eaf859cd9face9520b30127e6a91 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 25 Oct 2010 01:13:22 -0400 Subject: [PATCH] Work around rounding misbehavior exposed by buildfarm. --- src/backend/catalog/pg_enum.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/backend/catalog/pg_enum.c b/src/backend/catalog/pg_enum.c index 0c384def7b..5f3a5415ce 100644 --- a/src/backend/catalog/pg_enum.c +++ b/src/backend/catalog/pg_enum.c @@ -287,6 +287,16 @@ restart: other_nbr_en = (Form_pg_enum) GETSTRUCT(existing[other_nbr_index]); newelemorder = (nbr_en->enumsortorder + other_nbr_en->enumsortorder) / 2; + + /* + * On some machines, newelemorder may be in a register that's + * wider than float4. We need to force it to be rounded to + * float4 precision before making the following comparisons, + * or we'll get wrong results. (Such behavior violates the C + * standard, but fixing the compilers is out of our reach.) + */ + newelemorder = DatumGetFloat4(Float4GetDatum(newelemorder)); + if (newelemorder == nbr_en->enumsortorder || newelemorder == other_nbr_en->enumsortorder) { -- 2.40.0