[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Issue with mdb_cursor_del in MDB_DUPSORT databases

Mark Zealey wrote:
Hi Howard,

I've now switched the database to use MDB_DUPSORT and found what seems
to be another issue to do with invalid data being returned after
mdb_cursor_del. The following code shows the behaviour against a
database that I can provide you with if you need:

It would help if you actually checked the return code from mdb_cursor_get.

          rc = mdb_cursor_open(txn, dbi, &cursor);
          char seek[] = "ku.oc.repmulp\t";
          key.mv_size = sizeof(seek);
          key.mv_data = &seek;
          mdb_cursor_get(cursor, &key, &data, MDB_SET_RANGE);
          for( i = 0; i < 15; i++ ) {
              mdb_cursor_del( cursor, MDB_NODUPDATA );
              data.mv_size = 0;
              key.mv_size = 0;
              mdb_cursor_get( cursor, &key, &data,

              if( key.mv_size == 0 )
                  printf("WARNING 0 SIZE KEY\n");
                  printf("KEY OK: %d: %.*s\n", key.mv_size, key.mv_size,
              if( data.mv_size == 0 )
                  printf("WARNING 0 SIZE DATA\n");
                  printf("DATA OK: %d: %.*s\n", data.mv_size,
data.mv_size, data.mv_data);

  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/