use of org.apache.derby.iapi.sql.dictionary.SchemaDescriptor in project derby by apache.
the class DataDictionaryImpl method dropJDBCMetadataSPSes.
/**
* Remove metadata stored prepared statements.
* @param tc the xact
*/
private void dropJDBCMetadataSPSes(TransactionController tc) throws StandardException {
for (SPSDescriptor spsd : getAllSPSDescriptors()) {
SchemaDescriptor sd = spsd.getSchemaDescriptor();
// don't drop statements in non-system schemas
if (!sd.isSystemSchema()) {
continue;
}
dropSPSDescriptor(spsd, tc);
dropDependentsStoredDependencies(spsd.getUUID(), tc);
}
}
use of org.apache.derby.iapi.sql.dictionary.SchemaDescriptor in project derby by apache.
the class DataDictionaryImpl method addSystemSchema.
/**
* Add a system schema to the database.
* <p>
*
* @param schema_name name of the schema to add.
*
* @exception StandardException Standard exception policy.
*/
private SchemaDescriptor addSystemSchema(String schema_name, String schema_uuid, TransactionController tc) throws StandardException {
// create the descriptor
SchemaDescriptor schema_desc = new SchemaDescriptor(this, schema_name, authorizationDatabaseOwner, uuidFactory.recreateUUID(schema_uuid), true);
// add it to the catalog.
addDescriptor(schema_desc, null, SYSSCHEMAS_CATALOG_NUM, false, tc);
return (schema_desc);
}
use of org.apache.derby.iapi.sql.dictionary.SchemaDescriptor in project derby by apache.
the class DataDictionaryImpl method getVTIClass.
/**
* @see DataDictionary#getVTIClass(TableDescriptor, boolean)
*/
public String getVTIClass(TableDescriptor td, boolean asTableFunction) throws StandardException {
if (SchemaDescriptor.STD_SYSTEM_DIAG_SCHEMA_NAME.equals(td.getSchemaName())) {
return getBuiltinVTIClass(td, asTableFunction);
} else // see if it's a user-defined table function
{
String schemaName = td.getSchemaName();
String functionName = td.getDescriptorName();
SchemaDescriptor sd = getSchemaDescriptor(td.getSchemaName(), null, true);
if (sd != null) {
AliasDescriptor ad = getAliasDescriptor(sd.getUUID().toString(), functionName, AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR);
if ((ad != null) && ad.isTableFunction()) {
return ad.getJavaClassName();
}
throw StandardException.newException(SQLState.LANG_NOT_TABLE_FUNCTION, schemaName, functionName);
}
}
return null;
}
use of org.apache.derby.iapi.sql.dictionary.SchemaDescriptor in project derby by apache.
the class DataDictionaryImpl method createIdentitySequence.
/**
* Create a sequence generator for an identity column on upgrade to 10.11.
*/
private void createIdentitySequence(TableDescriptor td, // the identity column
ColumnDescriptor cd, TransactionController tc) throws StandardException {
DataTypeDescriptor dtd = cd.getType();
long[] bounds = dtd.getNumericBounds();
long currentValue = cd.getAutoincValue();
long initialValue = cd.getAutoincStart();
long minValue = bounds[DataTypeDescriptor.MIN_VALUE_IDX];
long maxValue = bounds[DataTypeDescriptor.MAX_VALUE_IDX];
long stepValue = cd.getAutoincInc();
SchemaDescriptor sd = getSystemSchemaDescriptor();
SequenceDescriptor seqDef = getDataDescriptorGenerator().newSequenceDescriptor(sd, getUUIDFactory().createUUID(), TableDescriptor.makeSequenceName(td.getUUID()), dtd, currentValue, initialValue, minValue, maxValue, stepValue, // whether the sequence can wrap-around
false);
addDescriptor(seqDef, // parent
null, DataDictionary.SYSSEQUENCES_CATALOG_NUM, // duplicatesAllowed
false, tc);
}
use of org.apache.derby.iapi.sql.dictionary.SchemaDescriptor in project derby by apache.
the class DataDictionaryImpl method upgradeFixSystemColumnDefinition.
/**
* Upgrade an existing system catalog column's definition
* by setting it to the value it would have in a newly
* created database. This is only used to for a couple
* of columns that had incorrectly nullability. Other
* uses (e.g. changing column type) might require more work.
*
* @param columnNumber The column to change
* @param tc Transaction controller
*
* @exception StandardException Standard Derby error policy
*/
public void upgradeFixSystemColumnDefinition(CatalogRowFactory rowFactory, int columnNumber, TransactionController tc) throws StandardException {
SystemColumn theColumn;
SystemColumn[] columns = rowFactory.buildColumnList();
SchemaDescriptor sd = getSystemSchemaDescriptor();
TableDescriptor td = getTableDescriptor(rowFactory.getCatalogName(), sd, tc);
// from 1 to 0 based
theColumn = columns[columnNumber - 1];
ColumnDescriptor cd = makeColumnDescriptor(theColumn, columnNumber, td);
String columnName = cd.getColumnName();
int[] columnNameColArray = new int[1];
columnNameColArray[0] = SYSCOLUMNSRowFactory.SYSCOLUMNS_COLUMNDATATYPE;
updateColumnDescriptor(cd, td.getUUID(), columnName, columnNameColArray, tc);
}
Aggregations