Thanks, Chris. I tried your patch. It didn't segfault, but it still dumped core. The core was more informative though:
#0 0x006637a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x006a2e59 in raise () from /lib/tls/libc.so.6
#2 0x006a4882 in abort () from /lib/tls/libc.so.6
#3 0x00a74007 in __cxa_call_unexpected () from /usr/lib/libstdc++.so.5
#4 0x00a74044 in std::terminate () from /usr/lib/libstdc++.so.5
#5 0x00a741b6 in __cxa_throw () from /usr/lib/libstdc++.so.5
#6 0x00a29c70 in std::__throw_out_of_range () from /usr/lib/libstdc++.so.5
#7 0x08053eb5 in mysqlpp::Row::operator (this=0xfee6c7f0, i=5) at stl_vector.h:523
#8 0x0805404d in mysqlpp::Row::lookup_by_name (this=0xfee6c7f0, i=0x805b669 "weight") at result.h:355
#9 0x0804dce9 in print_stock_table (query=@0x831eef4) at const_string.h:58
#10 0x0804b386 in main (argc=1, argv=0xfee6ce44) at simple1.cpp:24
It looks like it is trying to access an index that is out of range. This seems to occur because the column meta information is not returned as part of the result set. When I change the query slightly from:
select * from stock
to use a table alias:
select s.* from stock
then the meta information does seem to be returned and an exception is no longer thrown.
I don't know if this is a problem with MySQL 5.0.1, or the combination of mysql++ and MySQL 5.0.1. I have noticed now, that using the MySQL command line client that the meta information is also missing sometimes. Has anyone experienced such a problem? Any suggestions? Thanks in advance!
> -----Original Message-----
> From: Chris Frey [mailto:cdfrey@stripped]
> Sent: Friday, February 04, 2005 8:04 PM
> To: plusplus@stripped
> Subject: Re: Problem with lookup_by_name
> On Fri, Feb 04, 2005 at 03:55:34PM -0800, Patrick Lin wrote:
> > Also, I'm using FC2 and MySQL 5.0.1. Ironically, the 1.7.21 binaries
> > built for FC2 and MySQL 4.0 work on my machine while those I build on
> > my machine do not.
> Just for fun, try this patch and see if the segfault turns into a C++
> - Chris
> diff -u row.cpp row.cpp
> --- row.cpp 18 Dec 2004 04:29:43 -0000 184.108.40.206
> +++ row.cpp 5 Feb 2005 03:45:26 -0000
> @@ -18,7 +18,7 @@
> return ColData();
> - return ColData(data[i].c_str(), res->types(i), is_nulls[i]);
> + return ColData(data.at(i).c_str(), res->types(i), is_nulls[i]);
> const ColData Row::lookup_by_name(const char* i) const
> MySQL++ Mailing List
> For list archives: http://lists.mysql.com/plusplus
> To unsubscribe: http://lists.mysql.com/plusplus?unsub=plin@stripped
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.300 / Virus Database: 265.8.5 - Release Date: 2/3/2005
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.8.5 - Release Date: 2/3/2005