I've applied the attached patch to try to fix this problem with minimal
run-time cost.  Since I don't have a Solaris machine I can't positively
confirm it works --- would one of you please test?

                        regards, tom lane


*** src/backend/utils/adt/float.c.orig  Wed Aug  4 17:34:02 2004
--- src/backend/utils/adt/float.c       Wed Aug 11 13:16:58 2004
***************
*** 317,322 ****
--- 317,334 ----
                                         errmsg("invalid input syntax for type real: 
\"%s\"",
                                                        orig_num)));
        }
+ #ifdef HAVE_BUGGY_SOLARIS_STRTOD
+       else
+       {
+               /*
+                * Many versions of Solaris have a bug wherein strtod sets endptr
+                * to point one byte beyond the end of the string when given
+                * "inf" or "infinity".
+                */
+               if (endptr != num && endptr[-1] == '\0')
+                       endptr--;
+       }
+ #endif /* HAVE_BUGGY_SOLARIS_STRTOD */
  
        /* skip trailing whitespace */
        while (*endptr != '\0' && isspace((unsigned char) *endptr))
***************
*** 482,487 ****
--- 494,511 ----
                                         errmsg("invalid input syntax for type double 
precision: \"%s\"",
                                                        orig_num)));
        }
+ #ifdef HAVE_BUGGY_SOLARIS_STRTOD
+       else
+       {
+               /*
+                * Many versions of Solaris have a bug wherein strtod sets endptr
+                * to point one byte beyond the end of the string when given
+                * "inf" or "infinity".
+                */
+               if (endptr != num && endptr[-1] == '\0')
+                       endptr--;
+       }
+ #endif /* HAVE_BUGGY_SOLARIS_STRTOD */
  
        /* skip trailing whitespace */
        while (*endptr != '\0' && isspace((unsigned char) *endptr))
*** src/include/port/solaris.h.orig     Sun Mar 14 22:29:22 2004
--- src/include/port/solaris.h  Wed Aug 11 13:16:50 2004
***************
*** 35,37 ****
--- 35,44 ----
  #define                BYTE_ORDER              LITTLE_ENDIAN
  #endif
  #endif
+ 
+ /*
+  * Many versions of Solaris have broken strtod() --- see bug #4751182.
+  * For the moment we just assume they all do; it's probably not worth
+  * the trouble to add a configure test for this.
+  */
+ #define HAVE_BUGGY_SOLARIS_STRTOD

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faqs/FAQ.html

Reply via email to