1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 1996-2009 Oracle. All rights reserved. 5 * 6 * $Id$ 7 */ 8 9DBPRIVATE 10PREFIX __bam 11 12INCLUDE #include "db_int.h" 13INCLUDE #include "dbinc/crypto.h" 14INCLUDE #include "dbinc/db_page.h" 15INCLUDE #include "dbinc/db_am.h" 16INCLUDE #include "dbinc/btree.h" 17INCLUDE #include "dbinc/log.h" 18INCLUDE #include "dbinc/txn.h" 19INCLUDE 20 21/* 22 * BTREE-split: used to log a page split. 23 * 24 * left: the page number for the low-order contents. 25 * llsn: the left page's original LSN. 26 * right: the page number for the high-order contents. 27 * rlsn: the right page's original LSN. 28 * indx: the number of entries that went to the left page. 29 * npgno: the next page number 30 * nlsn: the next page's original LSN (or 0 if no next page). 31 * pgno: the parent page number 32 * plsn: the parent page's original LSN. 33 * pg: the split page's contents before the split. 34 * opflags: SPL_NRECS: if splitting a tree that maintains a record count. 35 * pindx: index of new record in parent page. 36 */ 37BEGIN split 48 62 38DB fileid int32_t ld 39ARG left db_pgno_t lu 40POINTER llsn DB_LSN * lu 41ARG right db_pgno_t lu 42POINTER rlsn DB_LSN * lu 43ARG indx u_int32_t lu 44ARG npgno db_pgno_t lu 45POINTER nlsn DB_LSN * lu 46ARG ppgno db_pgno_t lu 47POINTER plsn DB_LSN * lu 48ARG pindx u_int32_t lu 49PGDBT pg DBT s 50DBT pentry DBT s 51DBT rentry DBT s 52ARG opflags u_int32_t lu 53END 54 55BEGIN_COMPAT split 42 62 56DB fileid int32_t ld 57ARG left db_pgno_t lu 58POINTER llsn DB_LSN * lu 59ARG right db_pgno_t lu 60POINTER rlsn DB_LSN * lu 61ARG indx u_int32_t lu 62ARG npgno db_pgno_t lu 63POINTER nlsn DB_LSN * lu 64ARG root_pgno db_pgno_t lu 65PGDBT pg DBT s 66ARG opflags u_int32_t lu 67END 68 69/* 70 * BTREE-rsplit: used to log a reverse-split 71 * 72 * pgno: the page number of the page copied over the root. 73 * pgdbt: the page being copied on the root page. 74 * root_pgno: the root page number. 75 * nrec: the tree's record count. 76 * rootent: last entry on the root page. 77 * rootlsn: the root page's original lsn. 78 */ 79BEGIN rsplit 42 63 80DB fileid int32_t ld 81ARG pgno db_pgno_t lu 82PGDBT pgdbt DBT s 83ARG root_pgno db_pgno_t lu 84ARG nrec db_pgno_t lu 85DBT rootent DBT s 86POINTER rootlsn DB_LSN * lu 87END 88 89/* 90 * BTREE-adj: used to log the adjustment of an index. 91 * 92 * pgno: the page modified. 93 * lsn: the page's original lsn. 94 * indx: the index adjusted. 95 * indx_copy: the index to copy if inserting. 96 * is_insert: 0 if a delete, 1 if an insert. 97 */ 98BEGIN adj 42 55 99DB fileid int32_t ld 100ARG pgno db_pgno_t lu 101POINTER lsn DB_LSN * lu 102ARG indx u_int32_t lu 103ARG indx_copy u_int32_t lu 104ARG is_insert u_int32_t lu 105END 106 107/* 108 * BTREE-cadjust: used to adjust the count change in an internal page. 109 * 110 * pgno: the page modified. 111 * lsn: the page's original lsn. 112 * indx: the index to be adjusted. 113 * adjust: the signed adjustment. 114 * opflags: CAD_UPDATEROOT: if root page count was adjusted. 115 */ 116BEGIN cadjust 42 56 117DB fileid int32_t ld 118ARG pgno db_pgno_t lu 119POINTER lsn DB_LSN * lu 120ARG indx u_int32_t lu 121ARG adjust int32_t ld 122ARG opflags u_int32_t lu 123END 124 125/* 126 * BTREE-cdel: used to log the intent-to-delete of a cursor record. 127 * 128 * pgno: the page modified. 129 * lsn: the page's original lsn. 130 * indx: the index to be deleted. 131 */ 132BEGIN cdel 42 57 133DB fileid int32_t ld 134ARG pgno db_pgno_t lu 135POINTER lsn DB_LSN * lu 136ARG indx u_int32_t lu 137END 138 139/* 140 * BTREE-repl: used to log the replacement of an item. 141 * 142 * pgno: the page modified. 143 * lsn: the page's original lsn. 144 * indx: the index to be replaced. 145 * isdeleted: set if the record was previously deleted. 146 * orig: the original data. 147 * repl: the replacement data. 148 * prefix: the prefix of the replacement that matches the original. 149 * suffix: the suffix of the replacement that matches the original. 150 */ 151BEGIN repl 42 58 152DB fileid int32_t ld 153ARG pgno db_pgno_t lu 154POINTER lsn DB_LSN * lu 155ARG indx u_int32_t lu 156ARG isdeleted u_int32_t lu 157DBT orig DBT s 158DBT repl DBT s 159ARG prefix u_int32_t lu 160ARG suffix u_int32_t lu 161END 162 163/* 164 * BTREE-root: log the assignment of a root btree page. 165 */ 166BEGIN root 42 59 167DB fileid int32_t ld 168ARG meta_pgno db_pgno_t lu 169ARG root_pgno db_pgno_t lu 170POINTER meta_lsn DB_LSN * lu 171END 172 173/* 174 * BTREE-curadj: undo cursor adjustments on txn abort. 175 * Should only be processed during DB_TXN_ABORT. 176 * NOTE: the first_indx field gets used to hold 177 * signed index adjustment in one case. 178 * care should be taken if its size is changed. 179 */ 180BEGIN curadj 42 64 181/* Fileid of db affected. */ 182DB fileid int32_t ld 183/* Which adjustment. */ 184ARG mode db_ca_mode ld 185/* Page entry is from. */ 186ARG from_pgno db_pgno_t lu 187/* Page entry went to. */ 188ARG to_pgno db_pgno_t lu 189/* Left page of root split. */ 190ARG left_pgno db_pgno_t lu 191/* First index of dup set. Also used as adjustment. */ 192ARG first_indx u_int32_t lu 193/* Index entry is from. */ 194ARG from_indx u_int32_t lu 195/* Index where entry went. */ 196ARG to_indx u_int32_t lu 197END 198 199/* 200 * BTREE-rcuradj: undo cursor adjustments on txn abort in 201 * renumbering recno trees. 202 * Should only be processed during DB_TXN_ABORT. 203 */ 204BEGIN rcuradj 42 65 205/* Fileid of db affected. */ 206DB fileid int32_t ld 207/* Which adjustment. */ 208ARG mode ca_recno_arg ld 209/* Root page number. */ 210ARG root db_pgno_t ld 211/* Recno of the adjustment. */ 212ARG recno db_recno_t ld 213/* Order number of the adjustment. */ 214ARG order u_int32_t lu 215END 216 217/* 218 * BTREE-relink -- Handles relinking around a deleted leaf page. 219 * 220 */ 221BEGIN_COMPAT relink 43 147 222/* Fileid of db affected. */ 223DB fileid int32_t ld 224/* The page being removed. */ 225ARG pgno db_pgno_t lu 226/* The page's original lsn. */ 227POINTER lsn DB_LSN * lu 228/* The previous page. */ 229ARG prev db_pgno_t lu 230/* The previous page's original lsn. */ 231POINTER lsn_prev DB_LSN * lu 232/* The next page. */ 233ARG next db_pgno_t lu 234/* The previous page's original lsn. */ 235POINTER lsn_next DB_LSN * lu 236END 237 238BEGIN relink 44 147 239/* Fileid of db affected. */ 240DB fileid int32_t ld 241/* The page being removed. */ 242ARG pgno db_pgno_t lu 243/* The new page number, if any. */ 244ARG new_pgno db_pgno_t lu 245/* The previous page. */ 246ARG prev db_pgno_t lu 247/* The previous page's original lsn. */ 248POINTER lsn_prev DB_LSN * lu 249/* The next page. */ 250ARG next db_pgno_t lu 251/* The previous page's original lsn. */ 252POINTER lsn_next DB_LSN * lu 253END 254 255/* 256 * BTREE-merge -- Handles merging of pages during a compaction. 257 */ 258BEGIN_COMPAT merge 44 148 259DB fileid int32_t ld 260ARG pgno db_pgno_t lu 261POINTER lsn DB_LSN * lu 262ARG npgno db_pgno_t lu 263POINTER nlsn DB_LSN * lu 264DBT hdr DBT s 265DBT data DBT s 266DBT ind DBT s 267END 268 269BEGIN merge 47 148 270DB fileid int32_t ld 271ARG pgno db_pgno_t lu 272POINTER lsn DB_LSN * lu 273ARG npgno db_pgno_t lu 274POINTER nlsn DB_LSN * lu 275PGDBT hdr DBT s 276PGDDBT data DBT s 277ARG pg_copy int32_t lu 278END 279 280/* 281 * BTREE-pgno -- Handles replacing a page number in the record 282 * reference on pgno by indx. 283 */ 284BEGIN pgno 44 149 285DB fileid int32_t ld 286ARG pgno db_pgno_t lu 287POINTER lsn DB_LSN * lu 288ARG indx u_int32_t lu 289ARG opgno db_pgno_t lu 290ARG npgno db_pgno_t lu 291END 292