IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 16, 2010, 11:52:45 AM (16 years ago)
Author:
Paul Price
Message:

Hack to work around MySQL dump bug.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/db/psDB.c

    r25315 r28350  
    15241524            }
    15251525        case PS_DATA_F64: {
    1526                 bind[i].length  = 0;
    1527                 bind[i].buffer  = &item->data.F64;
    1528                 bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.F64) ? &isNull : NULL;
    1529                 break;
    1530             }
     1526            // This hack is to work around a MySQL bug, where values of DBL_MAX are dumped (as text) with
     1527            // insufficient digits, causing the value to be rounded outside the bounds of DBL_MAX
     1528            // (specifically, -1.7976931348623157e+308 gets dumped as -1.79769313486232e+308 which is less
     1529            // than -DBL_MAX), which cannot then be loaded by MySQL.  We assume that we're using doubles for
     1530            // additional precision compared to floats, and not for additional size, so limiting to the
     1531            // maximum value of a float is not damaging.
     1532            if (item->data.F64 < -FLT_MAX) {
     1533                psWarning("Saturating double value at -FLT_MAX to work around MySQL bug: %lf --> %lf",
     1534                          item->data.F64, -FLT_MAX);
     1535                item->data.F64 = -FLT_MAX;
     1536            } else if (item->data.F64 > FLT_MAX) {
     1537                psWarning("Saturating double value at FLT_MAX to work around MySQL bug: %lf --> %lf",
     1538                          item->data.F64, FLT_MAX);
     1539                item->data.F64 = FLT_MAX;
     1540            }
     1541            bind[i].length  = 0;
     1542            bind[i].buffer  = &item->data.F64;
     1543            bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.F64) ? &isNull : NULL;
     1544            break;
     1545        }
    15311546        case PS_DATA_BOOL: {
    15321547                // XXX: ASC HACK NOTE (2005/06/03): set extreme bytes to the
Note: See TracChangeset for help on using the changeset viewer.