Skip to content

Commit 4ba61a4

Browse files
committed
Work around rounding misbehavior exposed by buildfarm.
1 parent 2d01ec0 commit 4ba61a4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/backend/catalog/pg_enum.c

+10
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,16 @@ AddEnumLabel(Oid enumTypeOid,
287287
other_nbr_en = (Form_pg_enum) GETSTRUCT(existing[other_nbr_index]);
288288
newelemorder = (nbr_en->enumsortorder +
289289
other_nbr_en->enumsortorder) / 2;
290+
291+
/*
292+
* On some machines, newelemorder may be in a register that's
293+
* wider than float4. We need to force it to be rounded to
294+
* float4 precision before making the following comparisons,
295+
* or we'll get wrong results. (Such behavior violates the C
296+
* standard, but fixing the compilers is out of our reach.)
297+
*/
298+
newelemorder = DatumGetFloat4(Float4GetDatum(newelemorder));
299+
290300
if (newelemorder == nbr_en->enumsortorder ||
291301
newelemorder == other_nbr_en->enumsortorder)
292302
{

0 commit comments

Comments
 (0)