2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1996-2009 Oracle. All rights reserved.
12 #include "dbinc/db_page.h"
13 #include "dbinc/db_upgrade.h"
14 #include "dbinc/btree.h"
17 * __bam_30_btreemeta --
18 * Upgrade the metadata pages from version 6 to version 7.
20 * PUBLIC: int __bam_30_btreemeta __P((DB *, char *, u_int8_t *));
23 __bam_30_btreemeta(dbp, real_name, buf)
35 newmeta = (BTMETA30 *)buf;
36 oldmeta = (BTMETA2X *)buf;
39 * Move things from the end up, so we do not overwrite things.
40 * We are going to create a new uid, so we can move the stuff
41 * at the end of the structure first, overwriting the uid.
44 newmeta->re_pad = oldmeta->re_pad;
45 newmeta->re_len = oldmeta->re_len;
46 newmeta->minkey = oldmeta->minkey;
47 newmeta->maxkey = oldmeta->maxkey;
48 newmeta->dbmeta.free = oldmeta->free;
49 newmeta->dbmeta.flags = oldmeta->flags;
50 newmeta->dbmeta.type = P_BTREEMETA;
52 newmeta->dbmeta.version = 7;
53 /* Replace the unique ID. */
54 if ((ret = __os_fileid(env, real_name, 1, buf + 36)) != 0)
63 * __bam_31_btreemeta --
64 * Upgrade the database from version 7 to version 8.
66 * PUBLIC: int __bam_31_btreemeta
67 * PUBLIC: __P((DB *, char *, u_int32_t, DB_FH *, PAGE *, int *));
70 __bam_31_btreemeta(dbp, real_name, flags, fhp, h, dirtyp)
82 COMPQUIET(real_name, NULL);
85 newmeta = (BTMETA31 *)h;
86 oldmeta = (BTMETA30 *)h;
89 * Copy the effected fields down the page.
90 * The fields may overlap each other so we
91 * start at the bottom and use memmove.
93 newmeta->root = oldmeta->root;
94 newmeta->re_pad = oldmeta->re_pad;
95 newmeta->re_len = oldmeta->re_len;
96 newmeta->minkey = oldmeta->minkey;
97 newmeta->maxkey = oldmeta->maxkey;
98 memmove(newmeta->dbmeta.uid,
99 oldmeta->dbmeta.uid, sizeof(oldmeta->dbmeta.uid));
100 newmeta->dbmeta.flags = oldmeta->dbmeta.flags;
101 newmeta->dbmeta.record_count = 0;
102 newmeta->dbmeta.key_count = 0;
103 ZERO_LSN(newmeta->dbmeta.unused3);
105 /* Set the version number. */
106 newmeta->dbmeta.version = 8;
108 /* Upgrade the flags. */
109 if (LF_ISSET(DB_DUPSORT))
110 F_SET(&newmeta->dbmeta, BTM_DUPSORT);
118 * Upgrade the database btree leaf pages.
120 * PUBLIC: int __bam_31_lbtree
121 * PUBLIC: __P((DB *, char *, u_int32_t, DB_FH *, PAGE *, int *));
124 __bam_31_lbtree(dbp, real_name, flags, fhp, h, dirtyp)
138 for (indx = O_INDX; indx < NUM_ENT(h); indx += P_INDX) {
139 bk = GET_BKEYDATA(dbp, h, indx);
140 if (B_TYPE(bk->type) == B_DUPLICATE) {
141 pgno = GET_BOVERFLOW(dbp, h, indx)->pgno;
142 if ((ret = __db_31_offdup(dbp, real_name, fhp,
143 LF_ISSET(DB_DUPSORT) ? 1 : 0, &pgno)) != 0)
145 if (pgno != GET_BOVERFLOW(dbp, h, indx)->pgno) {
147 GET_BOVERFLOW(dbp, h, indx)->pgno = pgno;