C++ Interface Release Notes

Chapter 4

Migrating to Release 6.0

If you are upgrading from an earlier release of ObjectStore to Release 6.0, you must perform the following steps:

  1. If you have not already done so, upgrade to the latest Service Pack of ObjectStore Release 5.1. You must be at Release 5.1 to perform the remaining steps in this procedure. For information about upgrading from pre-5.1 to Release 5.1, see the ObjectStore 5.1 Release Notes.

  2. Edit the source code of your application to remove or replace all incompatibile features of the ObjectStore API, and recompile under Release 6.0. For more information about performing this step, see Migrating Application Source Code.

  3. Use the ObjectStore dump/load facility to migrate a 5.1 database to Release 6.0. See Migrating a 5.1 Database to Release 6.0 for how to use the ObjectStore dump/load facility to perform this step.

All three steps might require you to run different releases of ObjectStore concurrently. For information about using the OS_MAJOR_RELEASE macro for managing different releases of ObjectStore, see Running Different Releases of ObjectStore.

Migrating Application Source Code

As you can see from looking over Chapter 3, Changes to the API, the changes for Release 6.0 have been extensive. However, for the user who is migrating to Release 6.0, there are two kinds of changes that are of most interest:

In addition to these mandatory changes, you might also consider making source-level changes to allow your application to take advantage of the benefits of Release 6.0. The following sections discuss all three types of changes.

Removing and Replacing Incompatible APIs

This section discusses incompatible features of the ObjectStore API; that is, ObjectStore classes and members that are not supported in Release 6.0. The simplest way to locate incompatible features in your application is to recompile under Release 6.0 and examine the error messages for unresolved references. Also, see Chapter 3, Changes to the API, which documents all changes to the ObjectStore API.

The following list of incompatible features is not exhaustive, but concentrates on those that are most likely to occur in user applications:

Obsolete APIs
In addition to these features, there are a number of obsolete features that continue to be supported but will be removed from the API at the next major release; see Obsolete Functions and Classes.

Changes to the collections API
If your application uses the collections facility, refer to the changes for Release 6.0 described in Collections. In particular, note the following changes to the collections API:

Run-Time Differences

Differences in the run-time behavior of ObjectStore between Release 6.0 and Release 5.1 are less numerous than those described in Removing and Replacing Incompatible APIs, but no less significant. These are incompatibilities that might not be caught at compile time but that can result in run-time exceptions or unexpected behavior.

Nested opens
The most important of the run-time differences is that ObjectStore no longer supports nested opens. This change affects the semantics of os_database::open() and os_database::close(). If your application uses a nested open, you will not notice any differences unless you change the open mode in the successive opens - for example, from update to read-only. In this case, the nested open will cause a run-time exception.

To make your program run correctly, make the open modes consistent in the nested calls to open(). If you are changing the open mode to protect the database, consider making the transaction read-only.

The Release 6.0 semantics of close() are compatible with its 5.1 semantics. For more information, see Opening and Closing Databases. For descriptions of Release 6.0 versions of open() and close(), see os_database::open() and os_database::close().

Managing lifetimes of ObjectStore objects
In Release 5.1, when you called a method that returned a pointer to an ObjectStore object (for example, os_database), the objects slowly leaked. Users could call os_database::decache() to perform limited cleanup. This is not the case in Release 6.0. If you call a method that returns a pointer to an ObjectStore object, you are responsible for deleting it when it is no longer needed. The following classes of ObjectStore objects are most likely to result in a memory leak unless their lifetimes are carefully managed:

There are other classes that fall in the same category, but these are the classes that are most likely to proliferate in a program, resulting in a memory leak. (The new class os_cluster also falls in this category; however, because it is new, it cannot occur in 5.1 programs.)

For more information, see Managing ObjectStore Objects.

Dump/load facility
The dump/load facility has changed for Release 6.0. The format of the ASCII dump produced by osdump has changed. Also, the 5.1 version of osdump cannot be used to dump Release 6.0 databases.

For detailed information about the dump/load facility, see osdump: Dumping Databases in Chapter 4 of Managing ObjectStore and Chapter 7, Dump/Load Facility of Advanced C++ API User Guide. For information about using the dump/load facility as a migration tool, see Migrating a 5.1 Database to Release 6.0.

Note
By far the most significant change in terms of the number of ObjectStore methods affected is that a number of methods are now declared with the const qualifier. However, this change should have no effect on user code. Refer to Chapter 3 for the methods that have changed to const in Release 6.0.

Changes that can Improve Performance and Functionality

This section briefly describes changes to your application to take advantage of Release 6.0 features that can improve your application's performance and functionality. Although adding these features to your application is not strictly required for successful migration to Release 6.0, your application may not get the full benefit of Release 6.0 if you do not take advantage of them.

The following are the most significant Release 6.0 features that you might want to use in your application:

Migrating a 5.1 Database to Release 6.0

This section outlines a procedure for migrating a database to Release 6.0. It assumes that you have installed both the latest Service Pack of Release 5.1 and Release 6.0 of ObjectStore. For the purpose of illustration, the procedure uses a database named notes.db as an example. This database can be created with the example application described in Example of a Lexical Transaction in Chapter 5 of C++ API User Guide. The source files for the application are available on line; see %OS_ROOTDIR%\examples\doc_demos\ug5 (Windows) and $OS_ROOTDIR/examples/doc_demos/ug5 (UNIX).

The class of objects stored in notes.db is simple and requires only the steps outlined in this procedure to migrate to Release 6.0. If your database stores more complicated objects (for example, unions, hash tables, or other data structures that rely on actual addresses or offsets to locate data stored in the database), refer to the discussion of the dump/load facility in Chapter 7, Dump/Load Facility of Advanced C++ API User Guide. For a description of osdump, see osdump: Dumping Databases in Chapter 4 of Managing ObjectStore.

Following is the migration procedure:

  1. Run the 5.1 version of osverifydb to ensure that the database has no errors.

  2. Run the 5.1 version of osdump to dump your database to an ASCII file:

    osdump notes.db

  3. Generate a Release 6.0 schema for your database by running ossg against your application's schema source file.

    Windows: ossg -asof schema.obj -asdb schema.adb /GX /MD /DWIN32 schema.cpp

    UNIX: ossg -assf dschema.cc -asdb dschema.adb schema.cc

  4. Make a copy of the source file provided by ObjectStore for loading the 6.0 database that uses the schema for your application:

    Windows: copy $OS_ROOTDIR\etc\dumpload\dummy.cc
    create_db6.cpp

    UNIX: cp $OS_ROOTDIR/etc/dumpload/dummy.cc \
    create_db6.cc

  5. Compile this C++ source file and the application schema source file output by ossg to produce the executable file that will generate the schema for the new Release 6.0 database:

    Windows: cl /Fecreate_db6.exe /nologo /GX /MD /DWIN32
    create_db6.cpp schema.obj %OS_ROOTDIR%\lib\ostore.lib

    UNIX: CC -o create_db6 create_db6.cc dschema.cc \
    -I$OS_ROOTDIR/include -los -loscol -losthr

  6. Run the executable produced in the previous step, specifying the name of the new database as an argument:

    create_db6 database6.db

  7. Generate source files for the loader by running the 6.0 version of osdump, specifying the -emit option and the name of the database you created in the previous step as arguments:

    osdump -emit database6.db

  8. Make a copy of your application's header file, which contains the declarations of all the persistently stored classes, renaming the copy ldrhdr.h:

    Windows: copy note.hh ldrhdr.h .

    UNIX: cp note.hh ldrhdr.h .

    If your application has more than one header file that contains declarations of persistent classes, either copy them all to ldrhdr.h or use the include directive to include them.

  9. Produce the executable osload by running make, specifying the name of the makefile generated in the previous step:

    Windows: nmake -f makefile.w32

    UNIX: make -f makefile.unx

  10. Generate the Release 6.0 version of your database (in this example, notes.db) by running the executable (osload) generated in the previous step. In this example, osload is specified with the -cwd option so that 6.0 database written to the current working directory rather than to the directory in which the 5.1 database was originally created:

    osload -cwd db_table.dmp notes.dmp

After you have successfully loaded the database, removed and replaced incompatible features of previous releases of Objectstore from your application, and compiled the application to run under Release 6.0, you have completed the migration process.

Running Different Releases of ObjectStore

When migrating to Release 6.0, you might find it useful to have both releases running concurrently, especially when checking a 5.1 application program for incompatibilities.

To help you manage different releases, we define the C preprocessor macro OS_MAJOR_RELEASE. This macro is an integer and is defined in the header file osreleas.hh. ObjectStore sets the value of OS_MAJOR_RELEASE to a value that represents the major release number. You can use this variable in C preprocessor directives to check for which release of ObjectStore is currently running and to determine whether the compiler should emit code that performs a Release 6.0 operation or a Release 5.1 operation, as in the following:

#if (OS_MAJOR_RELEASE == 6) 
      // do it the Release 6.0 way 
#else 
      // do it the 5.1 way 
You can also perform a similar conditionalization at run time by calling objectstore::release_major().



[previous] [next]

Copyright © 1999 Object Design, Inc. All rights reserved.

Updated: 03/11/99 12:17:56