Hi,

does it segfault in operator[] or when accessing the value? operator[] returns a tntdb::Value, which may be null and you can ask, if it null. And you should before accessing the value. You must not fetch a value from a tntdb::Value, which is actually null. If you do, the reaction is the same as accessing a std::vector outside its bounds. And that is undefined. Most probably a segfault.

For every value you fetch from a database, which may be null you should always first ask, if it is null.

I use one of the variants of method tntdb::Value::get to fetch the value, which does the right job quite easily. This should work:

    tntdb::Row r = stmt.selectRow();

    unsigned value1;
    std::string value2;
    double value3;
    r[0].get(value1);
    r[1].get(value2);
    r[2].get(value3);

The get methods return a bool, whether the value is null. If it is, the original value is not changed nor the tntdb::Value is accessed. So if you do need to do something special there, you can do something like:

    if (!r[1].get(value2))
      std::cout << "oh - value2 was null somehow" << std::endl;

If it still segfault, you have hit a bug, and you shoul tell us.

Tommi

On 11/27/2011 07:49 PM, Carlos Franke wrote:
Hi!

I am getting a segfault with tntdb, using the following ingredients:
1. An tntdb::Row with an empty cell. (Created by selecting from a suitable table with a tntdb::Statement and selectRow())
 2. Accesing that cell with operator[].

It is easy to work around this by checking isNull() before using operator[], but I am pretty sure this is not supposed to segfault.

Carlos


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d


_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to