Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

qam_upgrade.c

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1996-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: qam_upgrade.c,v 12.1 2005/06/16 20:23:33 bostic Exp $
00008  */
00009 
00010 #include "db_config.h"
00011 
00012 #ifndef NO_SYSTEM_INCLUDES
00013 #include <sys/types.h>
00014 
00015 #include <string.h>
00016 #endif
00017 
00018 #include "db_int.h"
00019 #include "dbinc/db_upgrade.h"
00020 #include "dbinc/db_page.h"
00021 #include "dbinc/qam.h"
00022 
00023 /*
00024  * __qam_31_qammeta --
00025  *      Upgrade the database from version 1 to version 2.
00026  *
00027  * PUBLIC: int __qam_31_qammeta __P((DB *, char *, u_int8_t *));
00028  */
00029 int
00030 __qam_31_qammeta(dbp, real_name, buf)
00031         DB *dbp;
00032         char *real_name;
00033         u_int8_t *buf;
00034 {
00035         QMETA31 *newmeta;
00036         QMETA30 *oldmeta;
00037 
00038         COMPQUIET(dbp, NULL);
00039         COMPQUIET(real_name, NULL);
00040 
00041         newmeta = (QMETA31 *)buf;
00042         oldmeta = (QMETA30 *)buf;
00043 
00044         /*
00045          * Copy the fields to their new locations.
00046          * They may overlap so start at the bottom and use memmove().
00047          */
00048         newmeta->rec_page = oldmeta->rec_page;
00049         newmeta->re_pad = oldmeta->re_pad;
00050         newmeta->re_len = oldmeta->re_len;
00051         newmeta->cur_recno = oldmeta->cur_recno;
00052         newmeta->first_recno = oldmeta->first_recno;
00053         newmeta->start = oldmeta->start;
00054         memmove(newmeta->dbmeta.uid,
00055             oldmeta->dbmeta.uid, sizeof(oldmeta->dbmeta.uid));
00056         newmeta->dbmeta.flags = oldmeta->dbmeta.flags;
00057         newmeta->dbmeta.record_count = 0;
00058         newmeta->dbmeta.key_count = 0;
00059         ZERO_LSN(newmeta->dbmeta.unused3);
00060 
00061         /* Update the version. */
00062         newmeta->dbmeta.version = 2;
00063 
00064         return (0);
00065 }
00066 
00067 /*
00068  * __qam_32_qammeta --
00069  *      Upgrade the database from version 2 to version 3.
00070  *
00071  * PUBLIC: int __qam_32_qammeta __P((DB *, char *, u_int8_t *));
00072  */
00073 int
00074 __qam_32_qammeta(dbp, real_name, buf)
00075         DB *dbp;
00076         char *real_name;
00077         u_int8_t *buf;
00078 {
00079         QMETA32 *newmeta;
00080         QMETA31 *oldmeta;
00081 
00082         COMPQUIET(dbp, NULL);
00083         COMPQUIET(real_name, NULL);
00084 
00085         newmeta = (QMETA32 *)buf;
00086         oldmeta = (QMETA31 *)buf;
00087 
00088         /*
00089          * Copy the fields to their new locations.
00090          * We are dropping the first field so move
00091          * from the top.
00092          */
00093         newmeta->first_recno = oldmeta->first_recno;
00094         newmeta->cur_recno = oldmeta->cur_recno;
00095         newmeta->re_len = oldmeta->re_len;
00096         newmeta->re_pad = oldmeta->re_pad;
00097         newmeta->rec_page = oldmeta->rec_page;
00098         newmeta->page_ext = 0;
00099         /* cur_recno now points to the first free slot. */
00100         newmeta->cur_recno++;
00101         if (newmeta->first_recno == 0)
00102                 newmeta->first_recno = 1;
00103 
00104         /* Update the version. */
00105         newmeta->dbmeta.version = 3;
00106 
00107         return (0);
00108 }

Generated on Sun Dec 25 12:14:44 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2