mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
Try to fix portability issue in enum renumbering (again).
The hack embodied in commit4ba61a487
no longer works after today's change to allow DatumGetFloat4/Float4GetDatum to be inlined (commit14cca1bf8
). Probably what's happening is that the faulty compilers are deciding that the now-inlined assignment is a no-op and so they're not required to round to float4 width. We had a bunch of similar issues earlier this year in the degree-based trig functions, and eventually settled on using volatile intermediate variables as the least ugly method of forcing recalcitrant compilers to do what the C standard says (cf commit82311bcdd
). Let's see if that method works here. Discussion: <4640.1472664476@sss.pgh.pa.us>
This commit is contained in:
@@ -315,21 +315,21 @@ restart:
|
|||||||
newelemorder = nbr_en->enumsortorder + 1;
|
newelemorder = nbr_en->enumsortorder + 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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
|
* The midpoint value computed here has to be rounded to float4
|
||||||
* wider than float4. We need to force it to be rounded to float4
|
* precision, else our equality comparisons against the adjacent
|
||||||
* precision before making the following comparisons, or we'll get
|
* values are meaningless. The most portable way of forcing that
|
||||||
* wrong results. (Such behavior violates the C standard, but
|
* to happen with non-C-standard-compliant compilers is to store
|
||||||
* fixing the compilers is out of our reach.)
|
* it into a volatile variable.
|
||||||
*/
|
*/
|
||||||
newelemorder = DatumGetFloat4(Float4GetDatum(newelemorder));
|
volatile float4 midpoint;
|
||||||
|
|
||||||
if (newelemorder == nbr_en->enumsortorder ||
|
other_nbr_en = (Form_pg_enum) GETSTRUCT(existing[other_nbr_index]);
|
||||||
newelemorder == other_nbr_en->enumsortorder)
|
midpoint = (nbr_en->enumsortorder +
|
||||||
|
other_nbr_en->enumsortorder) / 2;
|
||||||
|
|
||||||
|
if (midpoint == nbr_en->enumsortorder ||
|
||||||
|
midpoint == other_nbr_en->enumsortorder)
|
||||||
{
|
{
|
||||||
RenumberEnumType(pg_enum, existing, nelems);
|
RenumberEnumType(pg_enum, existing, nelems);
|
||||||
/* Clean up and start over */
|
/* Clean up and start over */
|
||||||
@@ -337,6 +337,8 @@ restart:
|
|||||||
ReleaseCatCacheList(list);
|
ReleaseCatCacheList(list);
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newelemorder = midpoint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user