20 messages in com.mysql.lists.plusplusRe: exception when the field's value ...| From | Sent On | Attachments |
|---|---|---|
| Reeza Awoodun | 28 Mar 2004 03:59 | |
| Sinisa Milivojevic | 29 Mar 2004 03:44 | |
| Tommy Tang | 30 Mar 2004 18:21 | |
| Sinisa Milivojevic | 31 Mar 2004 02:39 | |
| Tommy Tang | 31 Mar 2004 04:28 | |
| Tommy Tang | 31 Mar 2004 04:55 | |
| Jae Joo | 31 Mar 2004 06:14 | |
| Tommy Tang | 31 Mar 2004 17:32 | |
| Sinisa Milivojevic | 01 Apr 2004 02:41 | |
| Sinisa Milivojevic | 01 Apr 2004 02:42 | |
| Tommy Tang | 01 Apr 2004 03:56 | |
| Sinisa Milivojevic | 01 Apr 2004 04:05 | |
| Tommy Tang | 15 Apr 2004 03:37 | |
| Jae Joo | 15 Apr 2004 06:26 | |
| Tommy Tang | 15 Apr 2004 17:32 | |
| Sinisa Milivojevic | 19 Apr 2004 10:44 | |
| Tommy Tang | 19 Apr 2004 18:32 | |
| Sinisa Milivojevic | 20 Apr 2004 02:52 | |
| tommy | 20 Apr 2004 03:01 | |
| Sinisa Milivojevic | 20 Apr 2004 04:24 |
| Subject: | Re: exception when the field's value is NULL![]() |
|---|---|
| From: | Tommy Tang (tom...@vlinetech.com) |
| Date: | 04/15/2004 05:32:30 PM |
| List: | com.mysql.lists.plusplus |
Yes, I am also confused by these codes, for example why if (*end == '.') ?
By the way, I got it why it behaves different in Visual C++ and gcc when the
field is NULL, because the buf is "NULL" in gcc but 0 in Visual C++, so in
Visual C++ it is ok.
----- Original Message ----- From: "Jae Joo" <jaey...@yahoo.com> To: "Tommy Tang" <tom...@vlinetech.com> Cc: <plus...@lists.mysql.com> Sent: Thursday, April 15, 2004 9:26 PM Subject: Re: exception when the field's value is NULL
Any one knows why in the coldata4.hh?
template <class Str> template<class Type> Type mysql_ColData<Str>::conv (Type dummy) const { std::string strbuf = buf; strip_all_blanks(strbuf); size_t len = strbuf.size(); const char *str = strbuf.c_str(); const char *end = str; Type num = mysql_convert<Type>(str, end); if (*end == '.') { end++; for (;*end == '0'; end++); --> Why check '0'? } if (*end != '\0' && end != NULL ) { -- > Is always true? throw BadConversion (typeid(Type).name(), c_str(), end - str, len); } return num; } --- Tommy Tang <tom...@vlinetech.com> wrote:
I have investigated the reason why it still failed in my computer, I used gdb to debug the real reason and got the following information:
1. I set a breakpoint on the line : unsigned int nMaxID = row["MaxID"],
2. step into it and get to MysqlRow::operator[](char const*) const (i="MaxID") at row2.hh:19 return (*this)[res->field_num(std::string(i)];
3.step to MysqlResUse:;field_num(std::string const &) const at result2.hh:12 if ( !_names ) _names = new FieldNames(this);
4. next to get to the line 13: return (*_names)[i];
5. next to get to MysqlRow::operator[](char const*) const (i="MaxID") at row2.hh:20
6. step into to get to Mysql_ColData<const_string>::operator unsigned() const at coldata1.hh:80 operator unsigned int() const { return conv((unsigned int)0); }
7.step into to get to unsigned
mysql_ColData<const_string>::conv<unsigned>(unsigned)
const(dummy=0) at coldata4.hh:12 std::string strbuf = buf;
8. next till to the line 18 of coldata4.hh if (*end == '.'){
but I found here that the end ="NULL" and it doesn't meet if (*end !='0' && end != NULL ), so then it went to line 23 : throw BadConversion(typeid(Type).name(), c_str(), end - str, len );
That is just the reason why I should catch the BadConversion, but I don't like to do it because it changes the code executing routine, what I expect is to when the filed is NULL, just set it to 0(for number filed), just like the mysql++ in Visual studio. I am surprised at this because it behaves different in Visual studio and gcc.
----- Original Message ----- From: "Sinisa Milivojevic" <sin...@mysql.com> To: "Tommy Tang" <tom...@vlinetech.com> Cc: <plus...@lists.mysql.com> Sent: Thursday, April 01, 2004 8:05 PM Subject: Re: exception when the field's value is NULL
Tommy Tang wrote:
Yes, you are right, the coldata3.hh on my
computer is 'N' 'U' 'U' 'L'. Then I changed it to 'N''U''L''L', and rebuild the mysql++ again, but unfortunately it still can't works. Even I added try and catch it was still the same.
Should work with try and catch.
Run all examples programs.
If they run so should yours.
--
Sincerely,
-- For technical support contracts, go to https://order.mysql.com/?ref=msmi __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic <sin...@mysql.com> / /|_/ / // /\ \/ /_/ / /__ MySQL AB /_/ /_/\_, /___/\___\_\___/ Full time Developer and Support Coordinator <___/ www.mysql.com Larnaca, Cyprus
Meet the MySQL at User Conference ! (April 14-16, 2004) http://www.mysql.com/uc2004/
-- MySQL++ Mailing List For list archives: http://lists.mysql.com/plusplus To unsubscribe:
http://lists.mysql.com/plusplus?unsub=tom...@vlinetech.com
__________________________________ Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html
-- MySQL++ Mailing List For list archives: http://lists.mysql.com/plusplus To unsubscribe: http://lists.mysql.com/plusplus?unsub=tom...@vlinetech.com




