qam_auto.c

Go to the documentation of this file.
00001 /* Do not edit: automatically built by gen_rec.awk. */
00002 #include "config.h"
00003 
00004 #ifndef NO_SYSTEM_INCLUDES
00005 #include <sys/types.h>
00006 
00007 #include <ctype.h>
00008 #include <errno.h>
00009 #include <string.h>
00010 #endif
00011 
00012 #include "db_int.h"
00013 #include "db_page.h"
00014 #include "db_dispatch.h"
00015 #include "db_am.h"
00016 #include "qam.h"
00017 #include "txn.h"
00018 
00019 int CDB___qam_inc_log(dbenv, txnid, ret_lsnp, flags,
00020         fileid, lsn)
00021         DB_ENV *dbenv;
00022         DB_TXN *txnid;
00023         DB_LSN *ret_lsnp;
00024         u_int32_t flags;
00025         int32_t fileid;
00026         DB_LSN * lsn;
00027 {
00028         DBT logrec;
00029         DB_LSN *lsnp, null_lsn;
00030         u_int32_t rectype, txn_num;
00031         int ret;
00032         u_int8_t *bp;
00033 
00034         if (txnid != NULL &&
00035             TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00036                 return (CDB___db_child_active_err(dbenv));
00037         rectype = DB_qam_inc;
00038         txn_num = txnid == NULL ? 0 : txnid->txnid;
00039         if (txnid == NULL) {
00040                 ZERO_LSN(null_lsn);
00041                 lsnp = &null_lsn;
00042         } else
00043                 lsnp = &txnid->last_lsn;
00044         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00045             + sizeof(fileid)
00046             + sizeof(*lsn);
00047         if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00048                 return (ret);
00049 
00050         bp = logrec.data;
00051         memcpy(bp, &rectype, sizeof(rectype));
00052         bp += sizeof(rectype);
00053         memcpy(bp, &txn_num, sizeof(txn_num));
00054         bp += sizeof(txn_num);
00055         memcpy(bp, lsnp, sizeof(DB_LSN));
00056         bp += sizeof(DB_LSN);
00057         memcpy(bp, &fileid, sizeof(fileid));
00058         bp += sizeof(fileid);
00059         if (lsn != NULL)
00060                 memcpy(bp, lsn, sizeof(*lsn));
00061         else
00062                 memset(bp, 0, sizeof(*lsn));
00063         bp += sizeof(*lsn);
00064         DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00065         ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00066         if (txnid != NULL)
00067                 txnid->last_lsn = *ret_lsnp;
00068         CDB___os_free(logrec.data, logrec.size);
00069         return (ret);
00070 }
00071 
00072 int
00073 CDB___qam_inc_print(dbenv, dbtp, lsnp, notused2, notused3)
00074         DB_ENV *dbenv;
00075         DBT *dbtp;
00076         DB_LSN *lsnp;
00077         db_recops notused2;
00078         void *notused3;
00079 {
00080         __qam_inc_args *argp;
00081         u_int32_t i;
00082         u_int ch;
00083         int ret;
00084 
00085         i = 0;
00086         ch = 0;
00087         notused2 = 0;
00088         notused3 = NULL;
00089 
00090         if ((ret = CDB___qam_inc_read(dbenv, dbtp->data, &argp)) != 0)
00091                 return (ret);
00092         printf("[%lu][%lu]qam_inc: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00093             (u_long)lsnp->file,
00094             (u_long)lsnp->offset,
00095             (u_long)argp->type,
00096             (u_long)argp->txnid->txnid,
00097             (u_long)argp->prev_lsn.file,
00098             (u_long)argp->prev_lsn.offset);
00099         printf("\tfileid: %ld\n", (long)argp->fileid);
00100         printf("\tlsn: [%lu][%lu]\n",
00101             (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
00102         printf("\n");
00103         CDB___os_free(argp, 0);
00104         return (0);
00105 }
00106 
00107 int
00108 CDB___qam_inc_read(dbenv, recbuf, argpp)
00109         DB_ENV *dbenv;
00110         void *recbuf;
00111         __qam_inc_args **argpp;
00112 {
00113         __qam_inc_args *argp;
00114         u_int8_t *bp;
00115         int ret;
00116 
00117         ret = CDB___os_malloc(dbenv, sizeof(__qam_inc_args) +
00118             sizeof(DB_TXN), NULL, &argp);
00119         if (ret != 0)
00120                 return (ret);
00121         argp->txnid = (DB_TXN *)&argp[1];
00122         bp = recbuf;
00123         memcpy(&argp->type, bp, sizeof(argp->type));
00124         bp += sizeof(argp->type);
00125         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
00126         bp += sizeof(argp->txnid->txnid);
00127         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00128         bp += sizeof(DB_LSN);
00129         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00130         bp += sizeof(argp->fileid);
00131         memcpy(&argp->lsn, bp,  sizeof(argp->lsn));
00132         bp += sizeof(argp->lsn);
00133         *argpp = argp;
00134         return (0);
00135 }
00136 
00137 int CDB___qam_incfirst_log(dbenv, txnid, ret_lsnp, flags,
00138         fileid, recno)
00139         DB_ENV *dbenv;
00140         DB_TXN *txnid;
00141         DB_LSN *ret_lsnp;
00142         u_int32_t flags;
00143         int32_t fileid;
00144         db_recno_t recno;
00145 {
00146         DBT logrec;
00147         DB_LSN *lsnp, null_lsn;
00148         u_int32_t rectype, txn_num;
00149         int ret;
00150         u_int8_t *bp;
00151 
00152         if (txnid != NULL &&
00153             TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00154                 return (CDB___db_child_active_err(dbenv));
00155         rectype = DB_qam_incfirst;
00156         txn_num = txnid == NULL ? 0 : txnid->txnid;
00157         if (txnid == NULL) {
00158                 ZERO_LSN(null_lsn);
00159                 lsnp = &null_lsn;
00160         } else
00161                 lsnp = &txnid->last_lsn;
00162         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00163             + sizeof(fileid)
00164             + sizeof(recno);
00165         if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00166                 return (ret);
00167 
00168         bp = logrec.data;
00169         memcpy(bp, &rectype, sizeof(rectype));
00170         bp += sizeof(rectype);
00171         memcpy(bp, &txn_num, sizeof(txn_num));
00172         bp += sizeof(txn_num);
00173         memcpy(bp, lsnp, sizeof(DB_LSN));
00174         bp += sizeof(DB_LSN);
00175         memcpy(bp, &fileid, sizeof(fileid));
00176         bp += sizeof(fileid);
00177         memcpy(bp, &recno, sizeof(recno));
00178         bp += sizeof(recno);
00179         DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00180         ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00181         if (txnid != NULL)
00182                 txnid->last_lsn = *ret_lsnp;
00183         CDB___os_free(logrec.data, logrec.size);
00184         return (ret);
00185 }
00186 
00187 int
00188 CDB___qam_incfirst_print(dbenv, dbtp, lsnp, notused2, notused3)
00189         DB_ENV *dbenv;
00190         DBT *dbtp;
00191         DB_LSN *lsnp;
00192         db_recops notused2;
00193         void *notused3;
00194 {
00195         __qam_incfirst_args *argp;
00196         u_int32_t i;
00197         u_int ch;
00198         int ret;
00199 
00200         i = 0;
00201         ch = 0;
00202         notused2 = 0;
00203         notused3 = NULL;
00204 
00205         if ((ret = CDB___qam_incfirst_read(dbenv, dbtp->data, &argp)) != 0)
00206                 return (ret);
00207         printf("[%lu][%lu]qam_incfirst: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00208             (u_long)lsnp->file,
00209             (u_long)lsnp->offset,
00210             (u_long)argp->type,
00211             (u_long)argp->txnid->txnid,
00212             (u_long)argp->prev_lsn.file,
00213             (u_long)argp->prev_lsn.offset);
00214         printf("\tfileid: %ld\n", (long)argp->fileid);
00215         printf("\trecno: %lu\n", (u_long)argp->recno);
00216         printf("\n");
00217         CDB___os_free(argp, 0);
00218         return (0);
00219 }
00220 
00221 int
00222 CDB___qam_incfirst_read(dbenv, recbuf, argpp)
00223         DB_ENV *dbenv;
00224         void *recbuf;
00225         __qam_incfirst_args **argpp;
00226 {
00227         __qam_incfirst_args *argp;
00228         u_int8_t *bp;
00229         int ret;
00230 
00231         ret = CDB___os_malloc(dbenv, sizeof(__qam_incfirst_args) +
00232             sizeof(DB_TXN), NULL, &argp);
00233         if (ret != 0)
00234                 return (ret);
00235         argp->txnid = (DB_TXN *)&argp[1];
00236         bp = recbuf;
00237         memcpy(&argp->type, bp, sizeof(argp->type));
00238         bp += sizeof(argp->type);
00239         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
00240         bp += sizeof(argp->txnid->txnid);
00241         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00242         bp += sizeof(DB_LSN);
00243         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00244         bp += sizeof(argp->fileid);
00245         memcpy(&argp->recno, bp, sizeof(argp->recno));
00246         bp += sizeof(argp->recno);
00247         *argpp = argp;
00248         return (0);
00249 }
00250 
00251 int CDB___qam_mvptr_log(dbenv, txnid, ret_lsnp, flags,
00252         opcode, fileid, old_first, new_first, old_cur, new_cur,
00253         metalsn)
00254         DB_ENV *dbenv;
00255         DB_TXN *txnid;
00256         DB_LSN *ret_lsnp;
00257         u_int32_t flags;
00258         u_int32_t opcode;
00259         int32_t fileid;
00260         db_recno_t old_first;
00261         db_recno_t new_first;
00262         db_recno_t old_cur;
00263         db_recno_t new_cur;
00264         DB_LSN * metalsn;
00265 {
00266         DBT logrec;
00267         DB_LSN *lsnp, null_lsn;
00268         u_int32_t rectype, txn_num;
00269         int ret;
00270         u_int8_t *bp;
00271 
00272         if (txnid != NULL &&
00273             TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00274                 return (CDB___db_child_active_err(dbenv));
00275         rectype = DB_qam_mvptr;
00276         txn_num = txnid == NULL ? 0 : txnid->txnid;
00277         if (txnid == NULL) {
00278                 ZERO_LSN(null_lsn);
00279                 lsnp = &null_lsn;
00280         } else
00281                 lsnp = &txnid->last_lsn;
00282         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00283             + sizeof(opcode)
00284             + sizeof(fileid)
00285             + sizeof(old_first)
00286             + sizeof(new_first)
00287             + sizeof(old_cur)
00288             + sizeof(new_cur)
00289             + sizeof(*metalsn);
00290         if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00291                 return (ret);
00292 
00293         bp = logrec.data;
00294         memcpy(bp, &rectype, sizeof(rectype));
00295         bp += sizeof(rectype);
00296         memcpy(bp, &txn_num, sizeof(txn_num));
00297         bp += sizeof(txn_num);
00298         memcpy(bp, lsnp, sizeof(DB_LSN));
00299         bp += sizeof(DB_LSN);
00300         memcpy(bp, &opcode, sizeof(opcode));
00301         bp += sizeof(opcode);
00302         memcpy(bp, &fileid, sizeof(fileid));
00303         bp += sizeof(fileid);
00304         memcpy(bp, &old_first, sizeof(old_first));
00305         bp += sizeof(old_first);
00306         memcpy(bp, &new_first, sizeof(new_first));
00307         bp += sizeof(new_first);
00308         memcpy(bp, &old_cur, sizeof(old_cur));
00309         bp += sizeof(old_cur);
00310         memcpy(bp, &new_cur, sizeof(new_cur));
00311         bp += sizeof(new_cur);
00312         if (metalsn != NULL)
00313                 memcpy(bp, metalsn, sizeof(*metalsn));
00314         else
00315                 memset(bp, 0, sizeof(*metalsn));
00316         bp += sizeof(*metalsn);
00317         DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00318         ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00319         if (txnid != NULL)
00320                 txnid->last_lsn = *ret_lsnp;
00321         CDB___os_free(logrec.data, logrec.size);
00322         return (ret);
00323 }
00324 
00325 int
00326 CDB___qam_mvptr_print(dbenv, dbtp, lsnp, notused2, notused3)
00327         DB_ENV *dbenv;
00328         DBT *dbtp;
00329         DB_LSN *lsnp;
00330         db_recops notused2;
00331         void *notused3;
00332 {
00333         __qam_mvptr_args *argp;
00334         u_int32_t i;
00335         u_int ch;
00336         int ret;
00337 
00338         i = 0;
00339         ch = 0;
00340         notused2 = 0;
00341         notused3 = NULL;
00342 
00343         if ((ret = CDB___qam_mvptr_read(dbenv, dbtp->data, &argp)) != 0)
00344                 return (ret);
00345         printf("[%lu][%lu]qam_mvptr: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00346             (u_long)lsnp->file,
00347             (u_long)lsnp->offset,
00348             (u_long)argp->type,
00349             (u_long)argp->txnid->txnid,
00350             (u_long)argp->prev_lsn.file,
00351             (u_long)argp->prev_lsn.offset);
00352         printf("\topcode: %lu\n", (u_long)argp->opcode);
00353         printf("\tfileid: %ld\n", (long)argp->fileid);
00354         printf("\told_first: %lu\n", (u_long)argp->old_first);
00355         printf("\tnew_first: %lu\n", (u_long)argp->new_first);
00356         printf("\told_cur: %lu\n", (u_long)argp->old_cur);
00357         printf("\tnew_cur: %lu\n", (u_long)argp->new_cur);
00358         printf("\tmetalsn: [%lu][%lu]\n",
00359             (u_long)argp->metalsn.file, (u_long)argp->metalsn.offset);
00360         printf("\n");
00361         CDB___os_free(argp, 0);
00362         return (0);
00363 }
00364 
00365 int
00366 CDB___qam_mvptr_read(dbenv, recbuf, argpp)
00367         DB_ENV *dbenv;
00368         void *recbuf;
00369         __qam_mvptr_args **argpp;
00370 {
00371         __qam_mvptr_args *argp;
00372         u_int8_t *bp;
00373         int ret;
00374 
00375         ret = CDB___os_malloc(dbenv, sizeof(__qam_mvptr_args) +
00376             sizeof(DB_TXN), NULL, &argp);
00377         if (ret != 0)
00378                 return (ret);
00379         argp->txnid = (DB_TXN *)&argp[1];
00380         bp = recbuf;
00381         memcpy(&argp->type, bp, sizeof(argp->type));
00382         bp += sizeof(argp->type);
00383         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
00384         bp += sizeof(argp->txnid->txnid);
00385         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00386         bp += sizeof(DB_LSN);
00387         memcpy(&argp->opcode, bp, sizeof(argp->opcode));
00388         bp += sizeof(argp->opcode);
00389         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00390         bp += sizeof(argp->fileid);
00391         memcpy(&argp->old_first, bp, sizeof(argp->old_first));
00392         bp += sizeof(argp->old_first);
00393         memcpy(&argp->new_first, bp, sizeof(argp->new_first));
00394         bp += sizeof(argp->new_first);
00395         memcpy(&argp->old_cur, bp, sizeof(argp->old_cur));
00396         bp += sizeof(argp->old_cur);
00397         memcpy(&argp->new_cur, bp, sizeof(argp->new_cur));
00398         bp += sizeof(argp->new_cur);
00399         memcpy(&argp->metalsn, bp,  sizeof(argp->metalsn));
00400         bp += sizeof(argp->metalsn);
00401         *argpp = argp;
00402         return (0);
00403 }
00404 
00405 int CDB___qam_del_log(dbenv, txnid, ret_lsnp, flags,
00406         fileid, lsn, pgno, indx, recno)
00407         DB_ENV *dbenv;
00408         DB_TXN *txnid;
00409         DB_LSN *ret_lsnp;
00410         u_int32_t flags;
00411         int32_t fileid;
00412         DB_LSN * lsn;
00413         db_pgno_t pgno;
00414         u_int32_t indx;
00415         db_recno_t recno;
00416 {
00417         DBT logrec;
00418         DB_LSN *lsnp, null_lsn;
00419         u_int32_t rectype, txn_num;
00420         int ret;
00421         u_int8_t *bp;
00422 
00423         if (txnid != NULL &&
00424             TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00425                 return (CDB___db_child_active_err(dbenv));
00426         rectype = DB_qam_del;
00427         txn_num = txnid == NULL ? 0 : txnid->txnid;
00428         if (txnid == NULL) {
00429                 ZERO_LSN(null_lsn);
00430                 lsnp = &null_lsn;
00431         } else
00432                 lsnp = &txnid->last_lsn;
00433         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00434             + sizeof(fileid)
00435             + sizeof(*lsn)
00436             + sizeof(pgno)
00437             + sizeof(indx)
00438             + sizeof(recno);
00439         if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00440                 return (ret);
00441 
00442         bp = logrec.data;
00443         memcpy(bp, &rectype, sizeof(rectype));
00444         bp += sizeof(rectype);
00445         memcpy(bp, &txn_num, sizeof(txn_num));
00446         bp += sizeof(txn_num);
00447         memcpy(bp, lsnp, sizeof(DB_LSN));
00448         bp += sizeof(DB_LSN);
00449         memcpy(bp, &fileid, sizeof(fileid));
00450         bp += sizeof(fileid);
00451         if (lsn != NULL)
00452                 memcpy(bp, lsn, sizeof(*lsn));
00453         else
00454                 memset(bp, 0, sizeof(*lsn));
00455         bp += sizeof(*lsn);
00456         memcpy(bp, &pgno, sizeof(pgno));
00457         bp += sizeof(pgno);
00458         memcpy(bp, &indx, sizeof(indx));
00459         bp += sizeof(indx);
00460         memcpy(bp, &recno, sizeof(recno));
00461         bp += sizeof(recno);
00462         DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00463         ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00464         if (txnid != NULL)
00465                 txnid->last_lsn = *ret_lsnp;
00466         CDB___os_free(logrec.data, logrec.size);
00467         return (ret);
00468 }
00469 
00470 int
00471 CDB___qam_del_print(dbenv, dbtp, lsnp, notused2, notused3)
00472         DB_ENV *dbenv;
00473         DBT *dbtp;
00474         DB_LSN *lsnp;
00475         db_recops notused2;
00476         void *notused3;
00477 {
00478         __qam_del_args *argp;
00479         u_int32_t i;
00480         u_int ch;
00481         int ret;
00482 
00483         i = 0;
00484         ch = 0;
00485         notused2 = 0;
00486         notused3 = NULL;
00487 
00488         if ((ret = CDB___qam_del_read(dbenv, dbtp->data, &argp)) != 0)
00489                 return (ret);
00490         printf("[%lu][%lu]qam_del: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00491             (u_long)lsnp->file,
00492             (u_long)lsnp->offset,
00493             (u_long)argp->type,
00494             (u_long)argp->txnid->txnid,
00495             (u_long)argp->prev_lsn.file,
00496             (u_long)argp->prev_lsn.offset);
00497         printf("\tfileid: %ld\n", (long)argp->fileid);
00498         printf("\tlsn: [%lu][%lu]\n",
00499             (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
00500         printf("\tpgno: %lu\n", (u_long)argp->pgno);
00501         printf("\tindx: %lu\n", (u_long)argp->indx);
00502         printf("\trecno: %lu\n", (u_long)argp->recno);
00503         printf("\n");
00504         CDB___os_free(argp, 0);
00505         return (0);
00506 }
00507 
00508 int
00509 CDB___qam_del_read(dbenv, recbuf, argpp)
00510         DB_ENV *dbenv;
00511         void *recbuf;
00512         __qam_del_args **argpp;
00513 {
00514         __qam_del_args *argp;
00515         u_int8_t *bp;
00516         int ret;
00517 
00518         ret = CDB___os_malloc(dbenv, sizeof(__qam_del_args) +
00519             sizeof(DB_TXN), NULL, &argp);
00520         if (ret != 0)
00521                 return (ret);
00522         argp->txnid = (DB_TXN *)&argp[1];
00523         bp = recbuf;
00524         memcpy(&argp->type, bp, sizeof(argp->type));
00525         bp += sizeof(argp->type);
00526         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
00527         bp += sizeof(argp->txnid->txnid);
00528         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00529         bp += sizeof(DB_LSN);
00530         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00531         bp += sizeof(argp->fileid);
00532         memcpy(&argp->lsn, bp,  sizeof(argp->lsn));
00533         bp += sizeof(argp->lsn);
00534         memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00535         bp += sizeof(argp->pgno);
00536         memcpy(&argp->indx, bp, sizeof(argp->indx));
00537         bp += sizeof(argp->indx);
00538         memcpy(&argp->recno, bp, sizeof(argp->recno));
00539         bp += sizeof(argp->recno);
00540         *argpp = argp;
00541         return (0);
00542 }
00543 
00544 int CDB___qam_add_log(dbenv, txnid, ret_lsnp, flags,
00545         fileid, lsn, pgno, indx, recno, data,
00546         vflag, olddata)
00547         DB_ENV *dbenv;
00548         DB_TXN *txnid;
00549         DB_LSN *ret_lsnp;
00550         u_int32_t flags;
00551         int32_t fileid;
00552         DB_LSN * lsn;
00553         db_pgno_t pgno;
00554         u_int32_t indx;
00555         db_recno_t recno;
00556         const DBT *data;
00557         u_int32_t vflag;
00558         const DBT *olddata;
00559 {
00560         DBT logrec;
00561         DB_LSN *lsnp, null_lsn;
00562         u_int32_t zero;
00563         u_int32_t rectype, txn_num;
00564         int ret;
00565         u_int8_t *bp;
00566 
00567         if (txnid != NULL &&
00568             TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00569                 return (CDB___db_child_active_err(dbenv));
00570         rectype = DB_qam_add;
00571         txn_num = txnid == NULL ? 0 : txnid->txnid;
00572         if (txnid == NULL) {
00573                 ZERO_LSN(null_lsn);
00574                 lsnp = &null_lsn;
00575         } else
00576                 lsnp = &txnid->last_lsn;
00577         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00578             + sizeof(fileid)
00579             + sizeof(*lsn)
00580             + sizeof(pgno)
00581             + sizeof(indx)
00582             + sizeof(recno)
00583             + sizeof(u_int32_t) + (data == NULL ? 0 : data->size)
00584             + sizeof(vflag)
00585             + sizeof(u_int32_t) + (olddata == NULL ? 0 : olddata->size);
00586         if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00587                 return (ret);
00588 
00589         bp = logrec.data;
00590         memcpy(bp, &rectype, sizeof(rectype));
00591         bp += sizeof(rectype);
00592         memcpy(bp, &txn_num, sizeof(txn_num));
00593         bp += sizeof(txn_num);
00594         memcpy(bp, lsnp, sizeof(DB_LSN));
00595         bp += sizeof(DB_LSN);
00596         memcpy(bp, &fileid, sizeof(fileid));
00597         bp += sizeof(fileid);
00598         if (lsn != NULL)
00599                 memcpy(bp, lsn, sizeof(*lsn));
00600         else
00601                 memset(bp, 0, sizeof(*lsn));
00602         bp += sizeof(*lsn);
00603         memcpy(bp, &pgno, sizeof(pgno));
00604         bp += sizeof(pgno);
00605         memcpy(bp, &indx, sizeof(indx));
00606         bp += sizeof(indx);
00607         memcpy(bp, &recno, sizeof(recno));
00608         bp += sizeof(recno);
00609         if (data == NULL) {
00610                 zero = 0;
00611                 memcpy(bp, &zero, sizeof(u_int32_t));
00612                 bp += sizeof(u_int32_t);
00613         } else {
00614                 memcpy(bp, &data->size, sizeof(data->size));
00615                 bp += sizeof(data->size);
00616                 memcpy(bp, data->data, data->size);
00617                 bp += data->size;
00618         }
00619         memcpy(bp, &vflag, sizeof(vflag));
00620         bp += sizeof(vflag);
00621         if (olddata == NULL) {
00622                 zero = 0;
00623                 memcpy(bp, &zero, sizeof(u_int32_t));
00624                 bp += sizeof(u_int32_t);
00625         } else {
00626                 memcpy(bp, &olddata->size, sizeof(olddata->size));
00627                 bp += sizeof(olddata->size);
00628                 memcpy(bp, olddata->data, olddata->size);
00629                 bp += olddata->size;
00630         }
00631         DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00632         ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00633         if (txnid != NULL)
00634                 txnid->last_lsn = *ret_lsnp;
00635         CDB___os_free(logrec.data, logrec.size);
00636         return (ret);
00637 }
00638 
00639 int
00640 CDB___qam_add_print(dbenv, dbtp, lsnp, notused2, notused3)
00641         DB_ENV *dbenv;
00642         DBT *dbtp;
00643         DB_LSN *lsnp;
00644         db_recops notused2;
00645         void *notused3;
00646 {
00647         __qam_add_args *argp;
00648         u_int32_t i;
00649         u_int ch;
00650         int ret;
00651 
00652         i = 0;
00653         ch = 0;
00654         notused2 = 0;
00655         notused3 = NULL;
00656 
00657         if ((ret = CDB___qam_add_read(dbenv, dbtp->data, &argp)) != 0)
00658                 return (ret);
00659         printf("[%lu][%lu]qam_add: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00660             (u_long)lsnp->file,
00661             (u_long)lsnp->offset,
00662             (u_long)argp->type,
00663             (u_long)argp->txnid->txnid,
00664             (u_long)argp->prev_lsn.file,
00665             (u_long)argp->prev_lsn.offset);
00666         printf("\tfileid: %ld\n", (long)argp->fileid);
00667         printf("\tlsn: [%lu][%lu]\n",
00668             (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
00669         printf("\tpgno: %lu\n", (u_long)argp->pgno);
00670         printf("\tindx: %lu\n", (u_long)argp->indx);
00671         printf("\trecno: %lu\n", (u_long)argp->recno);
00672         printf("\tdata: ");
00673         for (i = 0; i < argp->data.size; i++) {
00674                 ch = ((u_int8_t *)argp->data.data)[i];
00675                 if (isprint(ch) || ch == 0xa)
00676                         putchar(ch);
00677                 else
00678                         printf("%#x ", ch);
00679         }
00680         printf("\n");
00681         printf("\tvflag: %lu\n", (u_long)argp->vflag);
00682         printf("\tolddata: ");
00683         for (i = 0; i < argp->olddata.size; i++) {
00684                 ch = ((u_int8_t *)argp->olddata.data)[i];
00685                 if (isprint(ch) || ch == 0xa)
00686                         putchar(ch);
00687                 else
00688                         printf("%#x ", ch);
00689         }
00690         printf("\n");
00691         printf("\n");
00692         CDB___os_free(argp, 0);
00693         return (0);
00694 }
00695 
00696 int
00697 CDB___qam_add_read(dbenv, recbuf, argpp)
00698         DB_ENV *dbenv;
00699         void *recbuf;
00700         __qam_add_args **argpp;
00701 {
00702         __qam_add_args *argp;
00703         u_int8_t *bp;
00704         int ret;
00705 
00706         ret = CDB___os_malloc(dbenv, sizeof(__qam_add_args) +
00707             sizeof(DB_TXN), NULL, &argp);
00708         if (ret != 0)
00709                 return (ret);
00710         argp->txnid = (DB_TXN *)&argp[1];
00711         bp = recbuf;
00712         memcpy(&argp->type, bp, sizeof(argp->type));
00713         bp += sizeof(argp->type);
00714         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
00715         bp += sizeof(argp->txnid->txnid);
00716         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00717         bp += sizeof(DB_LSN);
00718         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00719         bp += sizeof(argp->fileid);
00720         memcpy(&argp->lsn, bp,  sizeof(argp->lsn));
00721         bp += sizeof(argp->lsn);
00722         memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00723         bp += sizeof(argp->pgno);
00724         memcpy(&argp->indx, bp, sizeof(argp->indx));
00725         bp += sizeof(argp->indx);
00726         memcpy(&argp->recno, bp, sizeof(argp->recno));
00727         bp += sizeof(argp->recno);
00728         memset(&argp->data, 0, sizeof(argp->data));
00729         memcpy(&argp->data.size, bp, sizeof(u_int32_t));
00730         bp += sizeof(u_int32_t);
00731         argp->data.data = bp;
00732         bp += argp->data.size;
00733         memcpy(&argp->vflag, bp, sizeof(argp->vflag));
00734         bp += sizeof(argp->vflag);
00735         memset(&argp->olddata, 0, sizeof(argp->olddata));
00736         memcpy(&argp->olddata.size, bp, sizeof(u_int32_t));
00737         bp += sizeof(u_int32_t);
00738         argp->olddata.data = bp;
00739         bp += argp->olddata.size;
00740         *argpp = argp;
00741         return (0);
00742 }
00743 
00744 int
00745 CDB___qam_init_print(dbenv)
00746         DB_ENV *dbenv;
00747 {
00748         int ret;
00749 
00750         if ((ret = CDB___db_add_recovery(dbenv,
00751             CDB___qam_inc_print, DB_qam_inc)) != 0)
00752                 return (ret);
00753         if ((ret = CDB___db_add_recovery(dbenv,
00754             CDB___qam_incfirst_print, DB_qam_incfirst)) != 0)
00755                 return (ret);
00756         if ((ret = CDB___db_add_recovery(dbenv,
00757             CDB___qam_mvptr_print, DB_qam_mvptr)) != 0)
00758                 return (ret);
00759         if ((ret = CDB___db_add_recovery(dbenv,
00760             CDB___qam_del_print, DB_qam_del)) != 0)
00761                 return (ret);
00762         if ((ret = CDB___db_add_recovery(dbenv,
00763             CDB___qam_add_print, DB_qam_add)) != 0)
00764                 return (ret);
00765         return (0);
00766 }
00767 
00768 int
00769 CDB___qam_init_recover(dbenv)
00770         DB_ENV *dbenv;
00771 {
00772         int ret;
00773 
00774         if ((ret = CDB___db_add_recovery(dbenv,
00775             CDB___qam_inc_recover, DB_qam_inc)) != 0)
00776                 return (ret);
00777         if ((ret = CDB___db_add_recovery(dbenv,
00778             CDB___qam_incfirst_recover, DB_qam_incfirst)) != 0)
00779                 return (ret);
00780         if ((ret = CDB___db_add_recovery(dbenv,
00781             CDB___qam_mvptr_recover, DB_qam_mvptr)) != 0)
00782                 return (ret);
00783         if ((ret = CDB___db_add_recovery(dbenv,
00784             CDB___qam_del_recover, DB_qam_del)) != 0)
00785                 return (ret);
00786         if ((ret = CDB___db_add_recovery(dbenv,
00787             CDB___qam_add_recover, DB_qam_add)) != 0)
00788                 return (ret);
00789         return (0);
00790 }
00791 

Generated on Sun Jun 8 10:56:39 2008 for GNUmifluz by  doxygen 1.5.5