[odb-users] Odd behavior with 'results not cached' exception with mysql

Stroud, Sean T ststrou at sandia.gov
Thu Sep 27 14:27:24 EDT 2012


Hi,

I am seeing some odd behavior, which the code below illustrates:

    bool make_it_fail = true;   // set this to "false" to make the exception occur

    odb::result<My_Class> r( db->query<My_Class>(false) );

    r.cache();

    if ( make_it_fail )
      for ( odb::result<My_Class>::iterator iter(r.begin()); iter != r.end(); ++iter );

    // If the for-loop above is executed, then this line will throw a "results not cached" exception.
    // Otherwise no exception will be thrown
    cout << r.size() << endl;

Is this the intended behavior?  Seems odd that merely iterating over the result set would cause it to become no longer cached.  The example class "My_Class" is very simple - just a couple of ints and std::strings (no pointers, containters, inheritance, etc).

I am using ODB 2.1.0 on RHEL 5.8 with mysql 5.5.27.

Sean




More information about the odb-users mailing list