SOCI / soci

Official repository of the SOCI - The C++ Database Access Library
http://soci.sourceforge.net/
Boost Software License 1.0
1.42k stars 478 forks source link

std::bad_cast when query on pgsql #939

Open atari83 opened 2 years ago

atari83 commented 2 years ago

Hello !

I'm trying to understand whats the issue here. New soci port (4.0.3) has been landed on FreeBSD and I've built it on my PC (clang 11.0.1), I didn't change my code but the program throws "std::bad_cast" exception. Previously and on 4.0.1 my program was working. I don't know if it happens because of bad packaging or build config on my BSD machine or something goes wrong on soci code-base. ldd shows me that the program is normally linked to soci shared libraries and the pgsql back-end.

Please help me to troubleshoot this issue. Thanks.

vadz commented 2 years ago

Sorry, it's impossible to say anything without having at least some information, i.e. either a (minimal) way of reproducing the problem or at least some results of debugging, i.e. where is the exception thrown and what does it say exactly.

Thiesius commented 1 year ago

Currently I have bad_cast as well. The column in my Postgre database is of type "smallint" which is 2 byte value with range -32768 to +32767. However when I invoke obj.level = row.get<int16_t>(6); on my row an exception is thrown. Using int32_t instead of int16_t works fine, therefor I'm not sure if the type check/type identification is implemented correctly.

Exception is thrown from checked_ptr_cast in type_holder.h