Index: branches/pap/psLib/src/db/psDB.c
===================================================================
--- branches/pap/psLib/src/db/psDB.c	(revision 28179)
+++ branches/pap/psLib/src/db/psDB.c	(revision 28484)
@@ -1524,9 +1524,24 @@
             }
         case PS_DATA_F64: {
-                bind[i].length  = 0;
-                bind[i].buffer  = &item->data.F64;
-                bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.F64) ? &isNull : NULL;
-                break;
-            }
+            // This hack is to work around a MySQL bug, where values of DBL_MAX are dumped (as text) with
+            // insufficient digits, causing the value to be rounded outside the bounds of DBL_MAX
+            // (specifically, -1.7976931348623157e+308 gets dumped as -1.79769313486232e+308 which is less
+            // than -DBL_MAX), which cannot then be loaded by MySQL.  We assume that we're using doubles for
+            // additional precision compared to floats, and not for additional size, so limiting to the
+            // maximum value of a float is not damaging.
+            if (item->data.F64 < -FLT_MAX) {
+                psWarning("Saturating double value at -FLT_MAX to work around MySQL bug: %lf --> %lf",
+                          item->data.F64, -FLT_MAX);
+                item->data.F64 = -FLT_MAX;
+            } else if (item->data.F64 > FLT_MAX) {
+                psWarning("Saturating double value at FLT_MAX to work around MySQL bug: %lf --> %lf",
+                          item->data.F64, FLT_MAX);
+                item->data.F64 = FLT_MAX;
+            }
+            bind[i].length  = 0;
+            bind[i].buffer  = &item->data.F64;
+            bind[i].is_null = psDBIsPTypeNaN(item->type, &item->data.F64) ? &isNull : NULL;
+            break;
+        }
         case PS_DATA_BOOL: {
                 // XXX: ASC HACK NOTE (2005/06/03): set extreme bytes to the
