1 Reply Latest reply on Oct 5, 2011 8:31 PM by "Oracle, Sandra Whitman-Oracle"

    Why get error: BDB0061 PANIC: Invalid argument

    890955
      hello everyone,
      I have met a strange misstake when using BDB put/get record.
      My program runs well on x86 machine, it print out like this:

      dbp->put:
      dbp->get:
      get from db: hello,world
      dbp closed

      But on ARM machine, it goes wrong:

      dbp->put:
      dbp->get:
      BDB0058 page 87122432: illegal page type or format
      BDB0061 PANIC: Invalid argument
      get from db: (null)
      BDB0060 PANIC: fatal region error detected; run recovery
      dbp closed

      My program is:
      #include <stdio.h>
      #include <string.h>

      #include "db.h"

      int main()
      {
      DB *dbp = NULL;
      int ret = 0;
      DBT key, data;
      char my_key[] = {"1001"};
      char my_data[] = {"hello,world"};

      ret = db_create(&dbp, NULL, 0);
      ret = dbp->open(dbp, NULL, "local.db", NULL, DB_BTREE, DB_CREATE, 0);

      memset(&key, 0, sizeof(DBT));
      memset(&data, 0, sizeof(DBT));

      key.data = (char *)my_key;
      key.size = strlen(my_key) + 1;
      data.data = (char *)my_data;
      data.size = strlen(my_data) + 1;

      printf("dbp->put:\n");
      ret = dbp->put(dbp, NULL, &key, &data, DB_NOOVERWRITE);
      dbp->sync(dbp, 0);

      memset(&data, 0, sizeof(DBT));
      printf("dbp->get:\n");
      dbp->get(dbp, NULL, &key, &data, 0);
      printf("get from db: %s\n", (char *)data.data);

      if (ret < 0)
      {
      printf("######### error #########\n");
      }

      dbp->close(dbp, 0);
      printf("dbp closed\n");
      }

      Can you tell me what is wrong in my program or something else?