db4

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

db4

Anton Maksimenkov
???????????, openbsd.

??? ???, ???????, ?????? ????????????, ?? ????? ??? ???? db4 API,
??????????, ? ?? ? ????? ??? ??????. ? ??????, ?? ?????????? c_put().
??? ????? ????? ???????:
..func(...)
{
 DBC *curp;
 DBT key, val, v;
 int ret, c;

 if ((ret = user->dbp->cursor(user->dbp, NULL, &curp, 0)) != 0) {
    syslog(LOG_ERR, "DB->cursor(): %s", db_strerror(ret));
    return -1;
 }
 
 bzero(&key, sizeof(DBT));
 bzero(&val, sizeof(DBT));

 key.data = "1"; /* ????? ?????? ??? ???????/????? */
 key.size = strlen("1");
 val.data = user->info;
 val.size = sizeof(struct user_info);

 if ((ret = curp->c_get(curp, &key, &val, DB_SET)) != 0) {
    syslog(LOG_ERR, "DBC->c_get(): %s", db_strerror(ret));
    return -1;
 }
       
 printf("pre c_put()\n");
 /* ?????, ????????, user->info->changed = 'y'. ? ???????? */
       
 if ((ret = curp->c_put(curp, &key, &val, DB_CURRENT)) != 0) {
    syslog(LOG_ERR, "DBC->c_put(): %s", db_strerror(ret));
    return -1;
 }
..
?? ?? ?????? ?????????

# logd
pre c_put()
logd[19832]: DBC->c_put(): Invalid argument

?? ?????? ???? ??????? ???? (user->dbp) ???????, ???????? get() ?
put() ?????????. ???????? c_get().

????????? ????? ????????, ????? ??? ????-?? ?? ?? ?????, ???? ?????
(/usr/local/share/doc/db4/ref/toc.html,
/usr/local/share/doc/db4/ref/am/cursor.html). ?? ????????.
--
engineer