// if we are shutting down don't attempt to boot or create the database
boolean shutdown = isTrue(info, Attribute.SHUTDOWN_ATTR);
// see if database is already booted
Database database = (Database) Monitor.findService(Property.DATABASE_MODULE, tr.getDBName());
// encryption, re-encryption and decryption are not allowed on an already booted database.
// see DERBY-5969.
if ( (database != null) && isCryptoBoot( info ) )
{
addWarning( SQLWarningFactory.newSQLWarning( SQLState.AUTH_ENCRYPT_ALREADY_BOOTED ) );
}
// See if user wants to create a new database.
boolean createBoot = createBoot(info);
// DERBY-2264: keeps track of whether we do a plain boot before an
// (re)encryption or hard upgrade boot to (possibly) authenticate
// first. We can not authenticate before we have booted, so in
// order to enforce data base owner powers over encryption or
// upgrade, we need a plain boot, then authenticate, then, if all
// is well, boot with (re)encryption or upgrade. Encryption at
// create time is not checked.
boolean isTwoPhaseCryptoBoot = (!createBoot && isCryptoBoot(info));
boolean isTwoPhaseUpgradeBoot = (!createBoot &&
isHardUpgradeBoot(info));
boolean isStartSlaveBoot = isStartReplicationSlaveBoot(info);
// Set to true if startSlave command is attempted on an
// already booted database. Will raise an exception when
// credentials have been verified
boolean slaveDBAlreadyBooted = false;
boolean isFailoverMasterBoot = false;
boolean isFailoverSlaveBoot = false;
final boolean dropDatabase = isDropDatabase(info);
// Don't allow both the shutdown and the drop attribute.
if (shutdown && dropDatabase) {
throw newSQLException(
SQLState.CONFLICTING_BOOT_ATTRIBUTES,
Attribute.SHUTDOWN_ATTR + ", " + Attribute.DROP_ATTR);
}
// Don't allow conflicting attributes wrt cryptographic operations.
if (isTwoPhaseCryptoBoot) {
checkConflictingCryptoAttributes(info);
}
// check that a replication operation is not combined with
// other operations
String replicationOp = getReplicationOperation(info);
if (replicationOp!= null) {
if (createBoot ||
shutdown ||
dropDatabase ||
isTwoPhaseCryptoBoot ||
isTwoPhaseUpgradeBoot) {
throw StandardException.
newException(SQLState.
REPLICATION_CONFLICTING_ATTRIBUTES,
replicationOp);
}
}
if (isReplicationFailover(info)) {
// Check that the database has been booted - otherwise throw
// exception.
checkDatabaseBooted(database,
Attribute.REPLICATION_FAILOVER,
tr.getDBName());
// The failover command is the same for master and slave
// databases. If the db is not in slave replication mode, we
// assume that it is in master mode. If not in any replication
// mode, the connection attempt will fail with an exception
if (database.isInSlaveMode()) {
isFailoverSlaveBoot = true;
} else {
isFailoverMasterBoot = true;
}
}