1 Reply Latest reply: Feb 21, 2013 11:02 AM by Bogdan Coman-Oracle RSS

    need help: when using c_get on secondary DB

    user12835292
      Dear experts,

      I am using BDB 4.7 on Linux.

      My DB configuration was created as shown below.

      primary : btree with my own key-comparison callback
      secondary btree associated to the primary DB with my own comparison callback.

      Codes caused error looks like as following

      ret = db_create(&primarydb, dbenv, 0)
      primarydb->set_bt_compare(primarydb, primarydb_compare);
      ret = db_create(&secondarydb, dbenv, 0)
      secondarydb->set_bt_compare(secondarydb, secondarydb_compare);
      ...
      ...
      ret = secondarydb->cursor(secondarydb,NULL, &cursor);
      key.flags = DB_DBT_MALLOC;
      data.flags = DB_DBT_MALLOC;

      while (...) {
      /* sorted scanning with NULL key */
      ret = cursor->c_get(cursor, &key, &data, DB_NEXT);
      ...
      }

      My problem is, in some case, when calling "cursor->c_get(...)" ,
      the primary db's compare function was called with NULL key data
      even if I use the cursor on the secondary indices.

      Any hint would be highly appreciated.

      Best regards,

      Tawan Won