1/*- 2 * Copyright (c) 1996, 2020 Oracle and/or its affiliates. All rights reserved. 3 * 4 * See the file LICENSE for license information. 5 * 6 * $Id$ 7 */ 8 9DBPRIVATE 10PREFIX __db 11 12INCLUDE #include "db_int.h" 13INCLUDE #include "dbinc/crypto.h" 14INCLUDE #include "dbinc/db_page.h" 15INCLUDE #include "dbinc/db_dispatch.h" 16INCLUDE #include "dbinc/db_am.h" 17INCLUDE #include "dbinc/txn.h" 18INCLUDE 19 20/* 21 * addrem -- Add or remove an entry from a duplicate page. 22 * 23 * opcode: identifies if this is an add or delete. 24 * fileid: file identifier of the file being modified. 25 * pgno: duplicate page number. 26 * indx: location at which to insert or delete. 27 * nbytes: number of bytes added/removed to/from the page. 28 * hdr: header for the data item. 29 * dbt: data that is deleted or is to be added. 30 * pagelsn: former lsn of the page. 31 * 32 * If the hdr was NULL then, the dbt is a regular B_KEYDATA. 33 * If the dbt was NULL then the hdr is a complete item to be 34 * pasted on the page. 35 */ 36BEGIN addrem 50 41 37OP opcode u_int32_t lu 38DB fileid int32_t ld 39ARG pgno db_pgno_t lu 40ARG indx u_int32_t lu 41ARG nbytes u_int32_t lu 42HDR hdr DBT s 43DBT dbt DBT s 44POINTER pagelsn DB_LSN * lu 45END 46 47BEGIN_COMPAT addrem 42 41 48ARG opcode u_int32_t lu 49DB fileid int32_t ld 50ARG pgno db_pgno_t lu 51ARG indx u_int32_t lu 52ARG nbytes u_int32_t lu 53DBT hdr DBT s 54DBT dbt DBT s 55POINTER pagelsn DB_LSN * lu 56END 57 58/* 59 * big -- Handles addition and deletion of big key/data items. 60 * 61 * opcode: identifies get/put. 62 * fileid: file identifier of the file being modified. 63 * pgno: page onto which data is being added/removed. 64 * prev_pgno: the page before the one we are logging. 65 * next_pgno: the page after the one we are logging. 66 * dbt: data being written onto the page. 67 * pagelsn: former lsn of the orig_page. 68 * prevlsn: former lsn of the prev_pgno. 69 * nextlsn: former lsn of the next_pgno. This is not currently used, but 70 * may be used later if we actually do overwrites of big key/ 71 * data items in place. 72 */ 73BEGIN big 50 43 74OP opcode u_int32_t lu 75DB fileid int32_t ld 76ARG pgno db_pgno_t lu 77ARG prev_pgno db_pgno_t lu 78ARG next_pgno db_pgno_t lu 79HDR dbt DBT s 80POINTER pagelsn DB_LSN * lu 81POINTER prevlsn DB_LSN * lu 82POINTER nextlsn DB_LSN * lu 83END 84 85BEGIN_COMPAT big 42 43 86ARG opcode u_int32_t lu 87DB fileid int32_t ld 88ARG pgno db_pgno_t lu 89ARG prev_pgno db_pgno_t lu 90ARG next_pgno db_pgno_t lu 91DBT dbt DBT s 92POINTER pagelsn DB_LSN * lu 93POINTER prevlsn DB_LSN * lu 94POINTER nextlsn DB_LSN * lu 95END 96 97/* 98 * ovref -- Handles increment/decrement of overflow page reference count. 99 * 100 * fileid: identifies the file being modified. 101 * pgno: page number whose ref count is being incremented/decremented. 102 * adjust: the adjustment being made. 103 * lsn: the page's original lsn. 104 */ 105BEGIN ovref 42 44 106DB fileid int32_t ld 107ARG pgno db_pgno_t lu 108ARG adjust int32_t ld 109POINTER lsn DB_LSN * lu 110END 111 112/* 113 * relink -- Handles relinking around a page. 114 * 115 * opcode: indicates if this is an addpage or delete page 116 * pgno: the page being changed. 117 * lsn the page's original lsn. 118 * prev: the previous page. 119 * lsn_prev: the previous page's original lsn. 120 * next: the next page. 121 * lsn_next: the previous page's original lsn. 122 */ 123BEGIN_COMPAT relink 42 45 124ARG opcode u_int32_t lu 125DB fileid int32_t ld 126ARG pgno db_pgno_t lu 127POINTER lsn DB_LSN * lu 128ARG prev db_pgno_t lu 129POINTER lsn_prev DB_LSN * lu 130ARG next db_pgno_t lu 131POINTER lsn_next DB_LSN * lu 132END 133 134/* 135 * Debug -- log an operation upon entering an access method. 136 * op: Operation (cursor, c_close, c_get, c_put, c_del, 137 * get, put, delete). 138 * fileid: identifies the file being acted upon. 139 * key: key paramater 140 * data: data parameter 141 * flags: flags parameter 142 */ 143BEGIN debug 42 47 144DBT op DBT s 145ARG fileid int32_t ld 146DBT key DBT s 147DBT data DBT s 148ARG arg_flags u_int32_t lu 149END 150 151/* 152 * noop -- do nothing, but get an LSN. 153 */ 154BEGIN noop 42 48 155DB fileid int32_t ld 156ARG pgno db_pgno_t lu 157POINTER prevlsn DB_LSN * lu 158END 159 160/* 161 * pg_alloc: used to record allocating a new page. 162 * 163 * meta_lsn: the original lsn of the page reference by meta_pgno. 164 * meta_pgno the page pointing at the allocated page in the free list. 165 * If the list is unsorted this is the metadata page. 166 * page_lsn: the allocated page's original lsn. 167 * pgno: the page allocated. 168 * ptype: the type of the page allocated. 169 * next: the next page on the free list. 170 * last_pgno: the last page in the file after this op (4.3+). 171 */ 172BEGIN_COMPAT pg_alloc 42 49 173DB fileid int32_t ld 174POINTER meta_lsn DB_LSN * lu 175ARG meta_pgno db_pgno_t lu 176POINTER page_lsn DB_LSN * lu 177ARG pgno db_pgno_t lu 178ARG ptype u_int32_t lu 179ARG next db_pgno_t lu 180END 181 182BEGIN pg_alloc 43 49 183DB fileid int32_t ld 184POINTER meta_lsn DB_LSN * lu 185ARG meta_pgno db_pgno_t lu 186POINTER page_lsn DB_LSN * lu 187ARG pgno db_pgno_t lu 188ARG ptype u_int32_t lu 189ARG next db_pgno_t lu 190ARG last_pgno db_pgno_t lu 191END 192 193/* 194 * pg_free: used to record freeing a page. 195 * If we are maintaining a sorted free list (during compact) meta_pgno 196 * will be non-zero and refer to the page that preceeds the one we are freeing 197 * in the free list. Meta_lsn will then be the lsn of that page. 198 * 199 * pgno: the page being freed. 200 * meta_lsn: the meta-data page's original lsn. 201 * meta_pgno: the meta-data page number. 202 * header: the header from the free'd page. 203 * next: the previous next pointer on the metadata page. 204 * last_pgno: the last page in the file before this op (4.3+). 205 */ 206BEGIN_COMPAT pg_free 42 50 207DB fileid int32_t ld 208ARG pgno db_pgno_t lu 209POINTER meta_lsn DB_LSN * lu 210ARG meta_pgno db_pgno_t lu 211PGDBT header DBT s 212ARG next db_pgno_t lu 213END 214 215BEGIN pg_free 43 50 216DB fileid int32_t ld 217ARG pgno db_pgno_t lu 218POINTER meta_lsn DB_LSN * lu 219ARG meta_pgno db_pgno_t lu 220PGDBT header DBT s 221ARG next db_pgno_t lu 222ARG last_pgno db_pgno_t lu 223END 224 225/* 226 * cksum -- 227 * This log record is written when we're unable to checksum a page, 228 * before returning DB_RUNRECOVERY. This log record causes normal 229 * recovery to itself return DB_RUNRECOVERY, as only catastrophic 230 * recovery can fix things. 231 */ 232BEGIN cksum 42 51 233END 234 235/* 236 * pg_freedata: used to record freeing a page with data on it. 237 * 238 * pgno: the page being freed. 239 * meta_lsn: the meta-data page's original lsn. 240 * meta_pgno: the meta-data page number. 241 * header: the header and index entries from the free'd page. 242 * data: the data from the free'd page. 243 * next: the previous next pointer on the metadata page. 244 * last_pgno: the last page in the file before this op (4.3+). 245 */ 246BEGIN_COMPAT pg_freedata 42 52 247DB fileid int32_t ld 248ARG pgno db_pgno_t lu 249POINTER meta_lsn DB_LSN * lu 250ARG meta_pgno db_pgno_t lu 251PGDBT header DBT s 252ARG next db_pgno_t lu 253PGDDBT data DBT s 254END 255 256BEGIN pg_freedata 43 52 257DB fileid int32_t ld 258ARG pgno db_pgno_t lu 259POINTER meta_lsn DB_LSN * lu 260ARG meta_pgno db_pgno_t lu 261PGDBT header DBT s 262ARG next db_pgno_t lu 263ARG last_pgno db_pgno_t lu 264PGDDBT data DBT s 265END 266 267/* 268 * pg_prepare: used to record an aborted page in a prepared transaction. 269 * 270 * pgno: the page being freed. 271 */ 272X BEGIN pg_prepare 42 53 273X DB fileid int32_t ld 274X ARG pgno db_pgno_t lu 275X END 276 277/* 278 * pg_new: used to record a new page put on the free list. 279 * 280 * pgno: the page being freed. 281 * meta_lsn: the meta-data page's original lsn. 282 * meta_pgno: the meta-data page number. 283 * header: the header from the free'd page. 284 * next: the previous next pointer on the metadata page. 285 */ 286X BEGIN pg_new 42 54 287X DB fileid int32_t ld 288X ARG pgno db_pgno_t lu 289X POINTER meta_lsn DB_LSN * lu 290X ARG meta_pgno db_pgno_t lu 291X PGDBT header DBT s 292X ARG next db_pgno_t lu 293X END 294 295/* 296 * pg_init: used to reinitialize a page during truncate. 297 * 298 * pgno: the page being initialized. 299 * header: the header from the page. 300 * data: data that used to be on the page. 301 */ 302BEGIN pg_init 43 60 303DB fileid int32_t ld 304ARG pgno db_pgno_t lu 305PGDBT header DBT s 306PGDDBT data DBT s 307END 308 309/* 310 * pg_sort: sort the free list 311 * 312 * meta: meta page number 313 * meta_lsn: lsn on meta page. 314 * last_free: page number of new last free page. 315 * last_lsn; lsn of last free page. 316 * last_pgno: current last page number. 317 * list: list of pages and lsns to sort. 318 */ 319BEGIN_COMPAT pg_sort 44 61 320DB fileid int32_t ld 321ARG meta db_pgno_t lu 322POINTER meta_lsn DB_LSN * lu 323ARG last_free db_pgno_t lu 324POINTER last_lsn DB_LSN * lu 325ARG last_pgno db_pgno_t lu 326DBT list DBT s 327END 328 329/* 330 * pg_truc: truncate the free list 331 * 332 * meta: meta page number 333 * meta_lsn: lsn on meta page. 334 * last_free: page number of new last free page. 335 * last_lsn; lsn of last free page. 336 * last_pgno: current last page number. 337 * list: list of pages and lsns on free list. 338 */ 339BEGIN pg_trunc 50 66 340DB fileid int32_t ld 341ARG meta db_pgno_t lu 342POINTER meta_lsn DB_LSN * lu 343ARG last_free db_pgno_t lu 344POINTER last_lsn DB_LSN * lu 345ARG next_free db_pgno_t lu 346ARG last_pgno db_pgno_t lu 347PGLIST list DBT s 348END 349 350/* 351 * realloc: allocate a range of pages from the free list 352 * prev_pgno: page number of the page preceeding the set of pages to 353 * be allocated 354 * prev_lsn LSN from the prev_pgno page 355 * next_free page number of the page immediately following the set 356 * of pages to be allocated 357 * ptype The type of page being allocated 358 * list: pairs of page numbers and LSNs corresponding to the pages on 359 * the free list that are being reallocated 360 */ 361BEGIN realloc 50 36 362DB fileid int32_t ld 363ARG prev_pgno db_pgno_t lu 364POINTER page_lsn DB_LSN * lu 365ARG next_free db_pgno_t lu 366ARG ptype u_int32_t lu 367PGLIST list DBT s 368END 369 370/* 371 * relink: relink next and previous page pointers 372 * NOTE: moved from btree so its number is from that range. 373 * pgno: The page being removed. 374 * new_pgno: The new page number, if any. 375 * prev_pgno: The previous page, if any. 376 * lsn_prev: The previous page's original lsn. 377 * next_pgno: The next page, if any. 378 * lsn_next: The previous page's original lsn. 379 */ 380BEGIN relink 44 147 381DB fileid int32_t ld 382ARG pgno db_pgno_t lu 383ARG new_pgno db_pgno_t lu 384ARG prev_pgno db_pgno_t lu 385POINTER lsn_prev DB_LSN * lu 386ARG next_pgno db_pgno_t lu 387POINTER lsn_next DB_LSN * lu 388END 389 390/* 391 * Merge: merge two pages. 392 * NOTE: moved from btree so its number is from that range. 393 * pgno: The page number of the target page. 394 * lsn: Orignial LSN of the page. 395 * npgno: The page number of the next, or merged, page. 396 * nlsn: The LSN of hte next page. 397 * hdr: The page header of the next page. 398 * data: The data from the next page. 399 * pg_copy: If 1, then the whole page was copied. 400 */ 401BEGIN merge 47 148 402DB fileid int32_t ld 403ARG pgno db_pgno_t lu 404POINTER lsn DB_LSN * lu 405ARG npgno db_pgno_t lu 406POINTER nlsn DB_LSN * lu 407PGDBT hdr DBT s 408PGDDBT data DBT s 409ARG pg_copy int32_t lu 410END 411 412/* 413 * pgno -- Handles replacing a page number in a record 414 * reference on pgno by indx. 415 * NOTE: moved from btree so its number is from that range. 416 * pgno: The page that is being updated. 417 * lsn: The LSN of the page. 418 * indx: The index of the record being updated. 419 * opgno: Old page number. 420 * npgno: New page number. 421 */ 422BEGIN pgno 44 149 423DB fileid int32_t ld 424ARG pgno db_pgno_t lu 425POINTER lsn DB_LSN * lu 426ARG indx u_int32_t lu 427ARG opgno db_pgno_t lu 428ARG npgno db_pgno_t lu 429END 430