use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.
the class DataDictionaryImpl method getSubCheckConstraint.
/**
* Get a SubCheckConstraintDescriptor from syschecks for
* the specified constraint id. (Useful for check constraints.)
*
* @param constraintId The UUID for the constraint.
*
* @return SubCheckConstraintDescriptor The Sub descriptor for the constraint.
*
* @exception StandardException Thrown on failure
*/
private SubCheckConstraintDescriptor getSubCheckConstraint(UUID constraintId) throws StandardException {
DataValueDescriptor constraintIDOrderable = null;
TabInfoImpl ti = getNonCoreTI(SYSCHECKS_CATALOG_NUM);
/* Use constraintIDOrderable in both start and stop positions for scan */
constraintIDOrderable = getIDValueAsCHAR(constraintId);
/* Set up the start/stop position for the scan */
ExecIndexRow keyRow = (ExecIndexRow) exFactory.getIndexableRow(1);
keyRow.setColumn(1, constraintIDOrderable);
return getDescriptorViaIndex(SYSCHECKSRowFactory.SYSCHECKS_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, SubCheckConstraintDescriptor.class, false);
}
use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.
the class DataDictionaryImpl method dropConstraintDescriptor.
/**
* Drops the given ConstraintDescriptor from the data dictionary.
*
* @param descriptor The descriptor to drop
* @param tc The TransactionController
*
* @exception StandardException Thrown on error
*/
public void dropConstraintDescriptor(ConstraintDescriptor descriptor, TransactionController tc) throws StandardException {
ExecIndexRow keyRow = null;
DataValueDescriptor schemaIDOrderable;
DataValueDescriptor constraintNameOrderable;
TabInfoImpl ti = getNonCoreTI(SYSCONSTRAINTS_CATALOG_NUM);
switch(descriptor.getConstraintType()) {
case DataDictionary.PRIMARYKEY_CONSTRAINT:
case DataDictionary.FOREIGNKEY_CONSTRAINT:
case DataDictionary.UNIQUE_CONSTRAINT:
dropSubKeyConstraint(descriptor, tc);
break;
case DataDictionary.CHECK_CONSTRAINT:
dropSubCheckConstraint(descriptor.getUUID(), tc);
break;
}
/* Use constraintNameOrderable and schemaIdOrderable in both start
* and stop position for index 2 scan.
*/
constraintNameOrderable = new SQLVarchar(descriptor.getConstraintName());
schemaIDOrderable = getIDValueAsCHAR(descriptor.getSchemaDescriptor().getUUID());
/* Set up the start/stop position for the scan */
keyRow = (ExecIndexRow) exFactory.getIndexableRow(2);
keyRow.setColumn(1, constraintNameOrderable);
keyRow.setColumn(2, schemaIDOrderable);
ti.deleteRow(tc, keyRow, SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_INDEX2_ID);
}
use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.
the class DataDictionaryImpl method updateLockGranularity.
/**
* Update the lockGranularity for the specified table.
*
* @param td The TableDescriptor for the table
* @param schema The SchemaDescriptor for the table
* @param lockGranularity The new lockGranularity
* @param tc The TransactionController to use.
*
* @exception StandardException Thrown on error
*/
public void updateLockGranularity(TableDescriptor td, SchemaDescriptor schema, char lockGranularity, TransactionController tc) throws StandardException {
ExecRow row;
DataValueDescriptor schemaIDOrderable;
DataValueDescriptor tableNameOrderable;
TabInfoImpl ti = coreInfo[SYSTABLES_CORE_NUM];
SYSTABLESRowFactory rf = (SYSTABLESRowFactory) ti.getCatalogRowFactory();
/* Use tableIdOrderable and schemaIdOrderable in both start
* and stop position for index 1 scan.
*/
tableNameOrderable = new SQLVarchar(td.getName());
schemaIDOrderable = getIDValueAsCHAR(schema.getUUID());
/* Set up the start/stop position for the scan */
ExecIndexRow keyRow1 = exFactory.getIndexableRow(2);
keyRow1.setColumn(1, tableNameOrderable);
keyRow1.setColumn(2, schemaIDOrderable);
// build the row to be stuffed into SYSTABLES.
row = rf.makeRow(td, schema);
// update row in catalog (no indexes)
boolean[] bArray = new boolean[2];
for (int index = 0; index < 2; index++) {
bArray[index] = false;
}
ti.updateRow(keyRow1, row, SYSTABLESRowFactory.SYSTABLES_INDEX1_ID, bArray, (int[]) null, tc);
}
use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.
the class DataDictionaryImpl method getViewDescriptorScan.
/**
* Get the information for the view from sys.sysviews.
*
* @param tdi The TableDescriptor for the view.
*
* @return ViewDescriptor The ViewDescriptor for the view.
*
* @exception StandardException Thrown on error
*/
private ViewDescriptor getViewDescriptorScan(TableDescriptor tdi) throws StandardException {
ViewDescriptor vd;
DataValueDescriptor viewIdOrderable;
TabInfoImpl ti = getNonCoreTI(SYSVIEWS_CATALOG_NUM);
UUID viewID = tdi.getUUID();
/* Use viewIdOrderable in both start
* and stop position for scan.
*/
viewIdOrderable = getIDValueAsCHAR(viewID);
/* Set up the start/stop position for the scan */
ExecIndexRow keyRow = exFactory.getIndexableRow(1);
keyRow.setColumn(1, viewIdOrderable);
vd = getDescriptorViaIndex(SYSVIEWSRowFactory.SYSVIEWS_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, ViewDescriptor.class, false);
if (vd != null) {
vd.setViewName(tdi.getName());
}
return vd;
}
use of org.apache.derby.iapi.types.DataValueDescriptor in project derby by apache.
the class DataDictionaryImpl method getFileInfoDescriptorIndex1Scan.
/**
* Scan sysfiles_index1 (schemaid,name) for a match.
* @return The matching descriptor or null.
* @exception StandardException Thrown on failure
*/
private FileInfoDescriptor getFileInfoDescriptorIndex1Scan(UUID schemaId, String name) throws StandardException {
DataValueDescriptor schemaIDOrderable;
DataValueDescriptor nameOrderable;
TabInfoImpl ti = getNonCoreTI(SYSFILES_CATALOG_NUM);
nameOrderable = new SQLVarchar(name);
schemaIDOrderable = getIDValueAsCHAR(schemaId);
/* Set up the start/stop position for the scan */
ExecIndexRow keyRow = exFactory.getIndexableRow(2);
keyRow.setColumn(1, nameOrderable);
keyRow.setColumn(2, schemaIDOrderable);
FileInfoDescriptor r = getDescriptorViaIndex(SYSFILESRowFactory.SYSFILES_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, FileInfoDescriptor.class, false);
return r;
}
Aggregations