Top Description Fields Constructors Methods
org.apache.derby.impl.sql.catalog

public Class DD_Version

extends Object
implements Formatable
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.services.io.Formatable, org.apache.derby.iapi.services.io.TypedFormat, java.io.Externalizable, java.io.Serializable
Imports
org.apache.derby.iapi.services.monitor.Monitor, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.services.io.Formatable, .StoredFormatIds, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.sql.dictionary.CatalogRowFactory, .ConglomerateDescriptor, .DataDictionary, .SchemaDescriptor, .TableDescriptor, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.store.access.TransactionController, org.apache.derby.shared.common.info.ProductVersionHolder, org.apache.derby.iapi.util.IdUtil, java.io.IOException, .ObjectInput, .ObjectOutput, java.util.HashSet, .Properties

Generic code for upgrading data dictionaries. Currently has all minor version upgrade logic.

A word about minor vs. major upgraded. Minor upgrades must be backwards/forwards compatible. So they cannot version classes or introduce new classes. Major releases are only backwards compatible; they will run against an old database, but not the other way around. So they can introduce new classes, etc.

Field Summary

Modifier and TypeField and Description
private transient DataDictionaryImpl
pack-priv int
private int

Constructor Summary

AccessConstructor and Description
public
DD_Version()

Public niladic constructor needed for Formatable interface.

pack-priv
DD_Version(DataDictionaryImpl
The booting dictionary that needs to be upgraded.
bootingDictionary
,
int majorVersionNumber)

Construct a Version for the currently booting data dictionary.

Method Summary

Modifier and TypeMethod and Description
private void
applySafeChanges(TransactionController
transaction controller
tc
,
int
version of the on-disk database
fromMajorVersionNumber
,
int
last engine to perform a soft upgrade that made changes.
lastSoftUpgradeVersion
)

Apply changes that can safely be made in soft upgrade.

pack-priv boolean

Returns:

True if the database has been upgraded to the required level, false otherwise.
checkVersion
(int
Data Dictionary major version
requiredMajorVersion
,
String
Non-null to throw an error, null to return the state of the version match.
feature
)

Check to see if a database has been upgraded to the required level in order to use a language feature.

private void
doFullUpgrade(TransactionController
transaction controller
tc
,
int
version of the on-disk database
fromMajorVersionNumber
,
String
AuthorizationID of current user to be made Database Owner
aid
)

Do full upgrade.

protected void
dropSystemCatalog(TransactionController
TransactionController
tc
,
CatalogRowFactory
CatalogRowFactory for the catalog to drop.
crf
)

Drop a System catalog.

protected void
dropSystemCatalogDescription(TransactionController
TransactionController
tc
,
TableDescriptor
Table descriptor for the catalog to drop.
td
)

Remove the description of a System table from the data dictionary.

private int

Returns:

the minor version For 5.0 and 5.1 the minor number was calculated as jbmsVersion.getMinorVersion()*100 +jbmsVersion.getMaintVersion() + (jbmsVersion.isBeta() ? 0 : 1) + 2 5.0.22 => (0*100) + 22 + 2 = 24 - (5.0 has a unique major number) 5.1.2 => (1*100) + 2 + 2 = 104 - (5.1 has a unique major number) With the switch to the four part scheme in 5.2, the maint number now is in increments of one million, thus the above scheme could lead to duplicate numbers. Note that the major number may not change when the minor external release changes, e.g. 5.2 and 5.3 could share a DD_Version major number. 5.2.1.100 => (2*100) + 1000100 + 2 = 1000302 5.3.1.0 => (3*100) + 1000000 + 2 = 1000302
getJBMSMinorVersionNumber
()

Get the minor version from the JBMS product minor version/maint version.

public int

Returns:

the formatID of this class
getTypeFormatId
()

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Get the formatID which corresponds to this class.

private void
handleMinorRevisionChange(TransactionController
the xact
tc
,
DD_Version fromVersion, boolean softUpgradeRun)

Do any work needed for a minor revision change.

private static boolean
isFullUpgrade(final Properties startParams, final String oldVersionInfo)

Must be private so that user code can't call this entry point.

private static String
majorToString(int majorVersionNumber)

private void
modifySysTableNullability(TransactionController
TransactionController.
tc
,
int
The catalog number corresponding to the table for which we will modify the nullability. OLD Cloudscape 5.1 upgrade code If this corresponds to SYSALIASES, then the nullability of the SYSALIASES.ALIASINFO column will be changed to true (Beetle 4430). If this corresponds to SYSSTATEMENTS, the nullability of the SYSSTATEMENTS.LASTCOMPILED column will be changed to true. Derby upgrade code If this corresponds to SYSSTATEMENTS, then the nullability of the SYSSTATEMENTS.COMPILATION_SCHEMAID column will be changed to true. If this corresponds to SYSVIEWS, the nullability of the SYSVIEWS.COMPILATION_SCHEMAID column will be changed to true.
catalogNum
)

Modifies the nullability of the system table corresponding to the received catalog number.

public final void
readExternal(ObjectInput
read this.
in
)

Implements java.io.Externalizable.readExternal.

Read this object from a stream of stored objects.

public String

Returns:

String representation of this Version.
toString
()

Overrides java.lang.Object.toString.

Stringify this Version.

pack-priv void
upgradeIfNeeded(DD_Version
the version of the data dictionary tables.
dictionaryVersion
,
TransactionController tc, Properties startParams)

Upgrade the data dictionary catalogs to the version represented by this DD_Version.

public final void
writeExternal(ObjectOutput
write bytes here.
out
)

Implements java.io.Externalizable.writeExternal.

Write this object to a stream of stored objects.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

bootingDictionaryback to summary
private transient DataDictionaryImpl bootingDictionary
majorVersionNumberback to summary
pack-priv int majorVersionNumber
minorVersionNumberback to summary
private int minorVersionNumber

Constructor Detail

DD_Versionback to summary
public DD_Version()

Public niladic constructor needed for Formatable interface.

DD_Versionback to summary
pack-priv DD_Version(DataDictionaryImpl bootingDictionary, int majorVersionNumber)

Construct a Version for the currently booting data dictionary. The minor version is set by the subclass.

Parameters
bootingDictionary:DataDictionaryImpl

The booting dictionary that needs to be upgraded.

Method Detail

applySafeChangesback to summary
private void applySafeChanges(TransactionController tc, int fromMajorVersionNumber, int lastSoftUpgradeVersion) throws StandardException

Apply changes that can safely be made in soft upgrade. Any changes must not prevent the database from being re-booted by the a Derby engine at the older version fromMajorVersionNumber.
Examples are fixes to catalog meta data, e.g. fix nullability of a system column.
Upgrade items for 10.1

  • None.
Parameters
tc:TransactionController

transaction controller

fromMajorVersionNumber:int

version of the on-disk database

lastSoftUpgradeVersion:int

last engine to perform a soft upgrade that made changes.

Exceptions
StandardException:
Standard Derby error policy.
checkVersionback to summary
pack-priv boolean checkVersion(int requiredMajorVersion, String feature) throws StandardException

Check to see if a database has been upgraded to the required level in order to use a language feature.

Parameters
requiredMajorVersion:int

Data Dictionary major version

feature:String

Non-null to throw an error, null to return the state of the version match.

Returns:boolean

True if the database has been upgraded to the required level, false otherwise.

doFullUpgradeback to summary
private void doFullUpgrade(TransactionController tc, int fromMajorVersionNumber, String aid) throws StandardException

Do full upgrade. Apply changes that can NOT be safely made in soft upgrade.
Upgrade items for every new release

  • Drop and recreate the stored versions of the JDBC database metadata queries

Upgrade items for 10.1
  • None.
Parameters
tc:TransactionController

transaction controller

fromMajorVersionNumber:int

version of the on-disk database

aid:String

AuthorizationID of current user to be made Database Owner

Exceptions
StandardException:
Standard Derby error policy.
dropSystemCatalogback to summary
protected void dropSystemCatalog(TransactionController tc, CatalogRowFactory crf) throws StandardException

Drop a System catalog.

Parameters
tc:TransactionController

TransactionController

crf:CatalogRowFactory

CatalogRowFactory for the catalog to drop.

Exceptions
StandardException:
Standard Derby error policy.
dropSystemCatalogDescriptionback to summary
protected void dropSystemCatalogDescription(TransactionController tc, TableDescriptor td) throws StandardException

Remove the description of a System table from the data dictionary. This does not delete the conglomerates that hold the catalog or its indexes.

Parameters
tc:TransactionController

TransactionController

td:TableDescriptor

Table descriptor for the catalog to drop.

Exceptions
StandardException:
Standard Derby error policy.
getJBMSMinorVersionNumberback to summary
private int getJBMSMinorVersionNumber()

Get the minor version from the JBMS product minor version/maint version. Bumps it up by 1 if production, or 0 if beta to ensure minor upgrade across beta. Starts at 2 because of an old convention. We use this starting at 2 to allow soft upgrade to write a version of 1 with the old major number to ensure a minor upgrade when reverting to an old version afer a soft upgrade. E.g run with 5.0.2, then 5.2.1.1, then 5.0.2. Want to ensure 5.0.2 does the minor upgrade.

Returns:int

the minor version For 5.0 and 5.1 the minor number was calculated as jbmsVersion.getMinorVersion()*100 +jbmsVersion.getMaintVersion() + (jbmsVersion.isBeta() ? 0 : 1) + 2 5.0.22 => (0*100) + 22 + 2 = 24 - (5.0 has a unique major number) 5.1.2 => (1*100) + 2 + 2 = 104 - (5.1 has a unique major number) With the switch to the four part scheme in 5.2, the maint number now is in increments of one million, thus the above scheme could lead to duplicate numbers. Note that the major number may not change when the minor external release changes, e.g. 5.2 and 5.3 could share a DD_Version major number. 5.2.1.100 => (2*100) + 1000100 + 2 = 1000302 5.3.1.0 => (3*100) + 1000000 + 2 = 1000302

getTypeFormatIdback to summary
public int getTypeFormatId()

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Get the formatID which corresponds to this class. Map to the 5.0 version identifier so that 5.0 will understand this object when we write it out in soft upgrade mode. CS 5.0 will de-serialize it correctly. When we are writing out a 5.1 version number we write out the 5.1 version just to ensure no problems.

Returns:int

the formatID of this class

handleMinorRevisionChangeback to summary
private void handleMinorRevisionChange(TransactionController tc, DD_Version fromVersion, boolean softUpgradeRun) throws StandardException

Do any work needed for a minor revision change. For the data dictionary this is always invalidating stored prepared statements. When we are done with the upgrade, we always recompile all SPSes so the customer doesn't have to (and isn't going to get deadlocks because of the recomp).

Parameters
tc:TransactionController

the xact

Exceptions
StandardException:
Standard Derby error policy.
isFullUpgradeback to summary
private static boolean isFullUpgrade(final Properties startParams, final String oldVersionInfo) throws StandardException

Must be private so that user code can't call this entry point.

majorToStringback to summary
private static String majorToString(int majorVersionNumber)
modifySysTableNullabilityback to summary
private void modifySysTableNullability(TransactionController tc, int catalogNum) throws StandardException

Modifies the nullability of the system table corresponding to the received catalog number.

Parameters
tc:TransactionController

TransactionController.

catalogNum:int

The catalog number corresponding to the table for which we will modify the nullability. OLD Cloudscape 5.1 upgrade code If this corresponds to SYSALIASES, then the nullability of the SYSALIASES.ALIASINFO column will be changed to true (Beetle 4430). If this corresponds to SYSSTATEMENTS, the nullability of the SYSSTATEMENTS.LASTCOMPILED column will be changed to true. Derby upgrade code If this corresponds to SYSSTATEMENTS, then the nullability of the SYSSTATEMENTS.COMPILATION_SCHEMAID column will be changed to true. If this corresponds to SYSVIEWS, the nullability of the SYSVIEWS.COMPILATION_SCHEMAID column will be changed to true.

Exceptions
StandardException:
Thrown on error
readExternalback to summary
public final void readExternal(ObjectInput in) throws IOException

Implements java.io.Externalizable.readExternal.

Read this object from a stream of stored objects. Set the minor version. Ignore the major version.

Parameters
in:ObjectInput

read this.

Exceptions
IOException:
on error
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Stringify this Version.

Returns:String

String representation of this Version.

upgradeIfNeededback to summary
pack-priv void upgradeIfNeeded(DD_Version dictionaryVersion, TransactionController tc, Properties startParams) throws StandardException

Upgrade the data dictionary catalogs to the version represented by this DD_Version.

Parameters
dictionaryVersion:DD_Version

the version of the data dictionary tables.

Exceptions
StandardException:
Ooops
writeExternalback to summary
public final void writeExternal(ObjectOutput out) throws IOException

Implements java.io.Externalizable.writeExternal.

Write this object to a stream of stored objects. Write out the minor version which is bumped across minor release. Just to be safe, write out the major version too. This will allow us to do versioning of a specific Version impl in the future.

Parameters
out:ObjectOutput

write bytes here.

Exceptions
IOException:
on error