Open up MySQL and run this:

SELECT 'foobar' = 0;

It turns up as "1" (MySQL 4.0.1-alpha). Now, the reason is fairly obvious: 
atof("foobar") is 0. I tried similar SELECT's in MSSQL and Postgres, and neither said 
'foobar' = 0 was true.

In my humble opinion, it isn't. But I don't have any standards in front of me, nor do 
I know how to get them...

Below is a patch to sql/item.h that fixes this problem. It works for me, but I haven't 
tested it very extensively.

Is this a valid problem? I'm basically relying on intuition alone here...

Adam Hooper
[EMAIL PROTECTED]

[adam@hera sql]$ diff item.h item.h-new -C 3
*** item.h      Mon May 27 21:09:27 2002
--- item.h-new  Mon May 27 21:09:16 2002
***************
*** 257,265 ****
--- 257,290 ----
    }
    ~Item_string() {}
    enum Type type() const { return STRING_ITEM; }
+ 
+   /*
    double val() { return atof(str_value.ptr()); }
    longlong val_int() { return strtoll(str_value.ptr(),(char**) 0,10); }
    String *val_str(String*) { return (String*) &str_value; }
+   */
+ 
+   double val() {
+     char *s;
+     char *e;
+     double result;
+ 
+     result = strtod( s = (char *) str_value.ptr(), &e );
+     null_value = s == e;
+     return result;
+   }
+   longlong val_int()
+   {
+     char *s;
+     char *e;
+     longlong result;
+ 
+     result = strtoll( s = (char *) str_value.ptr(), &e, 10 );
+     null_value = s == e;
+     return result;
+   }
+   String *val_str(String*) { null_value = 0; return (String*) &str_value; }
+ 
    bool save_in_field(Field *field);
    void make_field(Send_field *field);
    enum Item_result result_type () const { return STRING_RESULT; }
[adam@hera sql]$ 

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to