• Tom Lane's avatar
    Dodge portability issue (apparent compiler bug) in new tablesample code. · d9476b83
    Tom Lane authored
    Some of the older OS X critters in the buildfarm are failing regression,
    with symptoms showing that a request for 100% sampling in BERNOULLI or
    SYSTEM methods actually gets only around 50% of the table.  gdb revealed
    that the computation of the "cutoff" number was producing 0x7FFFFFFF
    rather than the expected 0x100000000.  Inspecting the assembly code,
    it looks like gcc is trying to use lrint() instead of rint() and then
    fumbling the conversion from long double to uint64.  This seems like a
    clear compiler bug, but assigning the intermediate result into a plain
    double variable works around it, so let's just do that.  (Another idea
    would be to give up one bit of hash width so that we don't need to use
    a uint64 cutoff, but let's see if this is enough.)
    d9476b83
system.c 7.25 KB