1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 1996-2009 Oracle. All rights reserved. 5 * 6 * $Id$ 7 */ 8 9#include "db_config.h" 10 11#include "db_int.h" 12#include "dbinc/db_upgrade.h" 13#include "dbinc/db_page.h" 14#include "dbinc/qam.h" 15 16/* 17 * __qam_31_qammeta -- 18 * Upgrade the database from version 1 to version 2. 19 * 20 * PUBLIC: int __qam_31_qammeta __P((DB *, char *, u_int8_t *)); 21 */ 22int 23__qam_31_qammeta(dbp, real_name, buf) 24 DB *dbp; 25 char *real_name; 26 u_int8_t *buf; 27{ 28 QMETA30 *oldmeta; 29 QMETA31 *newmeta; 30 31 COMPQUIET(dbp, NULL); 32 COMPQUIET(real_name, NULL); 33 34 newmeta = (QMETA31 *)buf; 35 oldmeta = (QMETA30 *)buf; 36 37 /* 38 * Copy the fields to their new locations. 39 * They may overlap so start at the bottom and use memmove(). 40 */ 41 newmeta->rec_page = oldmeta->rec_page; 42 newmeta->re_pad = oldmeta->re_pad; 43 newmeta->re_len = oldmeta->re_len; 44 newmeta->cur_recno = oldmeta->cur_recno; 45 newmeta->first_recno = oldmeta->first_recno; 46 newmeta->start = oldmeta->start; 47 memmove(newmeta->dbmeta.uid, 48 oldmeta->dbmeta.uid, sizeof(oldmeta->dbmeta.uid)); 49 newmeta->dbmeta.flags = oldmeta->dbmeta.flags; 50 newmeta->dbmeta.record_count = 0; 51 newmeta->dbmeta.key_count = 0; 52 ZERO_LSN(newmeta->dbmeta.unused3); 53 54 /* Update the version. */ 55 newmeta->dbmeta.version = 2; 56 57 return (0); 58} 59 60/* 61 * __qam_32_qammeta -- 62 * Upgrade the database from version 2 to version 3. 63 * 64 * PUBLIC: int __qam_32_qammeta __P((DB *, char *, u_int8_t *)); 65 */ 66int 67__qam_32_qammeta(dbp, real_name, buf) 68 DB *dbp; 69 char *real_name; 70 u_int8_t *buf; 71{ 72 QMETA31 *oldmeta; 73 QMETA32 *newmeta; 74 75 COMPQUIET(dbp, NULL); 76 COMPQUIET(real_name, NULL); 77 78 newmeta = (QMETA32 *)buf; 79 oldmeta = (QMETA31 *)buf; 80 81 /* 82 * Copy the fields to their new locations. 83 * We are dropping the first field so move 84 * from the top. 85 */ 86 newmeta->first_recno = oldmeta->first_recno; 87 newmeta->cur_recno = oldmeta->cur_recno; 88 newmeta->re_len = oldmeta->re_len; 89 newmeta->re_pad = oldmeta->re_pad; 90 newmeta->rec_page = oldmeta->rec_page; 91 newmeta->page_ext = 0; 92 /* cur_recno now points to the first free slot. */ 93 newmeta->cur_recno++; 94 if (newmeta->first_recno == 0) 95 newmeta->first_recno = 1; 96 97 /* Update the version. */ 98 newmeta->dbmeta.version = 3; 99 100 return (0); 101} 102