use of org.apache.derby.iapi.sql.dictionary.SchemaDescriptor in project derby by apache.
the class BasicDatabase method validate.
/**
* @see PropertySetCallback#validate
* @exception StandardException Thrown on error.
*/
public boolean validate(String key, Serializable value, Dictionary p) throws StandardException {
// Disallow setting static creation time only configuration properties
if (key.equals(EngineType.PROPERTY))
throw StandardException.newException(SQLState.PROPERTY_UNSUPPORTED_CHANGE, key, value);
// only interested in the classpath
if (!key.equals(Property.DATABASE_CLASSPATH))
return false;
String newClasspath = (String) value;
// The parsed dbclasspath
String[][] dbcp = null;
if (newClasspath != null) {
// parse it when it is set to ensure only valid values
// are written to the actual conglomerate.
dbcp = IdUtil.parseDbClassPath(newClasspath);
}
// Verify that all jar files on the database classpath are in the data dictionary.
if (dbcp != null) {
for (int ix = 0; ix < dbcp.length; ix++) {
SchemaDescriptor sd = dd.getSchemaDescriptor(dbcp[ix][IdUtil.DBCP_SCHEMA_NAME], null, false);
FileInfoDescriptor fid = null;
if (sd != null)
fid = dd.getFileInfoDescriptor(sd, dbcp[ix][IdUtil.DBCP_SQL_JAR_NAME]);
if (fid == null) {
throw StandardException.newException(SQLState.LANG_DB_CLASS_PATH_HAS_MISSING_JAR, IdUtil.mkQualifiedName(dbcp[ix]));
}
}
}
return true;
}
use of org.apache.derby.iapi.sql.dictionary.SchemaDescriptor in project derby by apache.
the class DataDictionaryImpl method upgrade_addColumns.
/**
* Upgrade an existing catalog by adding columns.
*
* @param rowFactory Associated with this catalog.
* @param newColumnIDs Array of 1-based column ids.
* @param tc Transaction controller
*
* @exception StandardException Standard Derby error policy
*/
public void upgrade_addColumns(CatalogRowFactory rowFactory, int[] newColumnIDs, TransactionController tc) throws StandardException {
int columnID;
SystemColumn currentColumn;
SystemColumn[] columns = rowFactory.buildColumnList();
ExecRow templateRow = rowFactory.makeEmptyRowForCurrentVersion();
int columnCount = newColumnIDs.length;
SchemaDescriptor sd = getSystemSchemaDescriptor();
TableDescriptor td;
long conglomID;
// table/column descriptor until after we add and populate the new column.
if (rowFactory instanceof SYSTABLESRowFactory) {
td = dataDescriptorGenerator.newTableDescriptor("SYSTABLES", sd, TableDescriptor.BASE_TABLE_TYPE, TableDescriptor.ROW_LOCK_GRANULARITY);
td.setUUID(getUUIDForCoreTable("SYSTABLES", sd.getUUID().toString(), tc));
conglomID = coreInfo[SYSTABLES_CORE_NUM].getHeapConglomerate();
} else if (rowFactory instanceof SYSCOLUMNSRowFactory) {
td = dataDescriptorGenerator.newTableDescriptor("SYSCOLUMNS", sd, TableDescriptor.BASE_TABLE_TYPE, TableDescriptor.ROW_LOCK_GRANULARITY);
td.setUUID(getUUIDForCoreTable("SYSCOLUMNS", sd.getUUID().toString(), tc));
conglomID = coreInfo[SYSCOLUMNS_CORE_NUM].getHeapConglomerate();
} else {
td = getTableDescriptor(rowFactory.getCatalogName(), sd, tc);
conglomID = td.getHeapConglomerateId();
}
widenConglomerate(templateRow, newColumnIDs, conglomID, tc);
ColumnDescriptor[] cdArray = new ColumnDescriptor[columnCount];
for (int ix = 0; ix < columnCount; ix++) {
columnID = newColumnIDs[ix];
// from 1 to 0 based
currentColumn = columns[columnID - 1];
cdArray[ix] = makeColumnDescriptor(currentColumn, columnID, td);
}
addDescriptorArray(cdArray, td, SYSCOLUMNS_CATALOG_NUM, false, tc);
}
use of org.apache.derby.iapi.sql.dictionary.SchemaDescriptor in project derby by apache.
the class DataDictionaryImpl method resetDatabaseOwner.
/**
* Reset the database owner according to what is stored in the catalogs.
* This can change at upgrade time so we have factored this logic into
* a separately callable method.
*
* @param tc TransactionController
*
* @exception StandardException Thrown on error
*/
public void resetDatabaseOwner(TransactionController tc) throws StandardException {
SchemaDescriptor sd = locateSchemaRow(SchemaDescriptor.IBM_SYSTEM_SCHEMA_NAME, tc);
authorizationDatabaseOwner = sd.getAuthorizationId();
systemSchemaDesc.setAuthorizationId(authorizationDatabaseOwner);
sysIBMSchemaDesc.setAuthorizationId(authorizationDatabaseOwner);
systemUtilSchemaDesc.setAuthorizationId(authorizationDatabaseOwner);
}
use of org.apache.derby.iapi.sql.dictionary.SchemaDescriptor in project derby by apache.
the class DataDictionaryImpl method getAliasDescriptorForUDT.
/**
* Get the alias descriptor for an ANSI UDT.
*
* @param tc The transaction to use: if null, use the compilation transaction
* @param dtd The UDT's type descriptor
*
* @return The UDT's alias descriptor if it is an ANSI UDT; null otherwise.
*/
public AliasDescriptor getAliasDescriptorForUDT(TransactionController tc, DataTypeDescriptor dtd) throws StandardException {
if (tc == null) {
tc = getTransactionCompile();
}
if (dtd == null) {
return null;
}
BaseTypeIdImpl btii = dtd.getTypeId().getBaseTypeId();
if (!btii.isAnsiUDT()) {
return null;
}
SchemaDescriptor sd = getSchemaDescriptor(btii.getSchemaName(), tc, true);
AliasDescriptor ad = getAliasDescriptor(sd.getUUID().toString(), btii.getUnqualifiedName(), AliasInfo.ALIAS_NAME_SPACE_UDT_AS_CHAR);
return ad;
}
use of org.apache.derby.iapi.sql.dictionary.SchemaDescriptor in project derby by apache.
the class DataDictionaryImpl method putSequenceID.
/**
* Map ( schemaName, sequenceName ) to sequenceID
*/
private void putSequenceID(SequenceDescriptor sd) throws StandardException {
if (sd == null) {
return;
}
SchemaDescriptor schema = sd.getSchemaDescriptor();
String schemaName = schema.getSchemaName();
String sequenceName = sd.getSequenceName();
String uuid = sd.getUUID().toString();
HashMap<String, String> sequencesInSchema = sequenceIDs.get(schemaName);
if (sequencesInSchema == null) {
sequencesInSchema = new HashMap<String, String>();
sequenceIDs.put(schemaName, sequencesInSchema);
}
if (sequencesInSchema.get(sequenceName) == null) {
sequencesInSchema.put(sequenceName, uuid);
}
}
Aggregations