* We assume the System boot process has created a context
* manager already, but not that contexts we need are there.
*/
ContextService csf = ContextService.getFactory();
ContextManager cm = csf.getCurrentContextManager();
if (SanityManager.DEBUG)
SanityManager.ASSERT((cm != null), "Failed to get current ContextManager");
// RESOLVE other non-StandardException errors.
bootingTC = null;
try
{
// Get a transaction controller. This has the side effect of
// creating a transaction context if there isn't one already.
bootingTC = af.getTransaction(cm);
/*
We need an execution context so that we can generate rows
REMIND: maybe only for create case?
*/
exFactory.newExecutionContext(cm);
DataDescriptorGenerator ddg = getDataDescriptorGenerator();
//We should set the user schema collation type here now because
//later on, we are going to create user schema APP. By the time any
//user schema gets created, we should have the correct collation
//type set for such schemas to use. For this reason, don't remove
//the following if else statement and don't move it later in this
//method.
String userDefinedCollation;
if (create) {
//Get the collation attribute from the JDBC url. It can only
//have one of 2 possible values - UCS_BASIC or TERRITORY_BASED
//This attribute can only be specified at database create time.
//The attribute value has already been verified in DVF.boot and
//hence we can be assured that the attribute value if provided
//is either UCS_BASIC or TERRITORY_BASED. If none provided,
//then we will take it to be the default which is UCS_BASIC.
userDefinedCollation = startParams.getProperty(
Attribute.COLLATION, Property.UCS_BASIC_COLLATION);
bootingTC.setProperty(Property.COLLATION,userDefinedCollation,true);
} else {
userDefinedCollation = startParams.getProperty(
Property.COLLATION, Property.UCS_BASIC_COLLATION);
}
//Initialize the collation type of user schemas after looking at
//collation property/attribute.
if (userDefinedCollation.equalsIgnoreCase(Property.UCS_BASIC_COLLATION))
collationTypeOfUserSchemas = StringDataValue.COLLATION_TYPE_UCS_BASIC;
else
collationTypeOfUserSchemas = StringDataValue.COLLATION_TYPE_TERRITORY_BASED;
//Now is also a good time to create schema descriptor for global
//temporary tables. Since this is a user schema, it should use the
//collation type associated with user schemas. Since we just
//finished setting up the collation type of user schema, it is
//safe to create user SchemaDescriptor(s) now.
declaredGlobalTemporaryTablesSchemaDesc =
newDeclaredGlobalTemporaryTablesSchemaDesc(
SchemaDescriptor.STD_DECLARED_GLOBAL_TEMPORARY_TABLES_SCHEMA_NAME);
if (create) {
String userName = IdUtil.getUserNameFromURLProps(startParams);
authorizationDatabaseOwner = IdUtil.getUserAuthorizationId(userName);
// create any required tables.
createDictionaryTables(startParams, bootingTC, ddg);
//create procedures for network server metadata
create_SYSIBM_procedures(bootingTC);
//create metadata sps statement required for network server
createSystemSps(bootingTC);
// create the SYSCS_UTIL system procedures)
create_SYSCS_procedures(bootingTC);
// log the current dictionary version
dictionaryVersion = softwareVersion;
/* Set properties for current and create time
* DataDictionary versions.
*/
bootingTC.setProperty(
DataDictionary.CORE_DATA_DICTIONARY_VERSION,
dictionaryVersion, true);
bootingTC.setProperty(
DataDictionary.CREATE_DATA_DICTIONARY_VERSION,
dictionaryVersion, true);
// If SqlAuthorization is set as system property during database
// creation, set it as database property also, so it gets persisted.
if (PropertyUtil.getSystemBoolean(Property.SQL_AUTHORIZATION_PROPERTY))
{
bootingTC.setProperty(Property.SQL_AUTHORIZATION_PROPERTY,"true",true);
usesSqlAuthorization=true;
}
} else {
// Get the ids for non-core tables
loadDictionaryTables(bootingTC, ddg, startParams);
SchemaDescriptor sd = locateSchemaRow(SchemaDescriptor.IBM_SYSTEM_SCHEMA_NAME,
bootingTC);
authorizationDatabaseOwner = sd.getAuthorizationId();
String sqlAuth = PropertyUtil.getDatabaseProperty(bootingTC,
Property.SQL_AUTHORIZATION_PROPERTY);
// Feature compatibility check.
if (Boolean.valueOf
(startParams.getProperty(
Attribute.SOFT_UPGRADE_NO_FEATURE_CHECK))
.booleanValue()) {
// Do not perform check if this boot is the first
// phase (soft upgrade boot) of a hard upgrade,
// which happens in two phases beginning with
// DERBY-2264. In this case, we need to always be
// able to boot to authenticate, notwithstanding
// any feature properties set
// (e.g. derby.database.sqlAuthorization) which
// may not yet be supported until that hard
// upgrade has happened, normally causing an error
// below.
//
// Feature sqlAuthorization is a special case:
// Since database ownership checking only happens
// when sqlAuthorization is true, we can't afford
// to *not* use it for upgrades from 10.2 or
// later, lest we lose the database owner check.
// For upgrades from 10.1 and earlier there is no
// database owner check at a hard upgrade.
if (dictionaryVersion.majorVersionNumber >=
DataDictionary.DD_VERSION_DERBY_10_2) {
usesSqlAuthorization = Boolean.valueOf(sqlAuth).
booleanValue();
}
} else {
if (Boolean.valueOf(sqlAuth).booleanValue()) {
// SQL authorization requires 10.2 or higher database
checkVersion(DataDictionary.DD_VERSION_DERBY_10_2,
"sqlAuthorization");
usesSqlAuthorization=true;
}
}
}
if (SanityManager.DEBUG)
SanityManager.ASSERT((authorizationDatabaseOwner != null), "Failed to get Database Owner authorization");
/* Commit & destroy the create database */
bootingTC.commit();
cm.getContext(ExecutionContext.CONTEXT_ID).popMe(); // done with ctx
} finally {
if (bootingTC != null) {
bootingTC.destroy(); // gets rid of the transaction context
bootingTC = null;