use of org.apache.derby.catalog.UUID in project derby by apache.
the class DataDictionaryImpl method computeRowLocation.
/**
* Computes the RowLocation in SYSCOLUMNS for a particular
* autoincrement column.
*
* @param tc Transaction Controller to use.
* @param td Table Descriptor.
* @param columnName Name of column which has autoincrement column.
*
* @exception StandardException thrown on failure.
*/
private RowLocation computeRowLocation(TransactionController tc, TableDescriptor td, String columnName) throws StandardException {
TabInfoImpl ti = coreInfo[SYSCOLUMNS_CORE_NUM];
ExecIndexRow keyRow = null;
UUID tableUUID = td.getUUID();
keyRow = (ExecIndexRow) exFactory.getIndexableRow(2);
keyRow.setColumn(1, getIDValueAsCHAR(tableUUID));
keyRow.setColumn(2, new SQLChar(columnName));
return ti.getRowLocation(tc, keyRow, SYSCOLUMNSRowFactory.SYSCOLUMNS_INDEX1_ID);
}
use of org.apache.derby.catalog.UUID in project derby by apache.
the class DropDependencyFilter method execute.
/**
* Pump a SYSDEPENDS row through the Filter. If the providerID of the
* row matches our providerID, we return true. Otherwise we return false.
*
* @param currentRow SYSDEPENDS row
*
* @return True if the row has our providerID. False otherwise.
*
* @exception StandardException Thrown on error
*/
public BooleanDataValue execute(ExecRow currentRow) throws StandardException {
/* 3rd column is PROVIDERID (UUID - char(36)) */
DataValueDescriptor col = currentRow.getColumn(SYSDEPENDSRowFactory.SYSDEPENDS_PROVIDERID);
String providerIDstring = col.getString();
UUID providerUUID = getUUIDFactory().recreateUUID(providerIDstring);
if (providerID.equals(providerUUID)) {
return getTrueValue();
} else {
return getFalseValue();
}
}
use of org.apache.derby.catalog.UUID in project derby by apache.
the class DataDictionaryImpl method addSPSParams.
/**
* Add a column in SYS.SYSCOLUMNS for each parameter in the
* parameter list.
*/
private void addSPSParams(SPSDescriptor spsd, TransactionController tc) throws StandardException {
UUID uuid = spsd.getUUID();
DataTypeDescriptor[] params = spsd.getParams();
Object[] parameterDefaults = spsd.getParameterDefaults();
if (params == null)
return;
/* Create the columns */
int pdlSize = params.length;
for (int index = 0; index < pdlSize; index++) {
int parameterId = index + 1;
// RESOLVEAUTOINCREMENT
ColumnDescriptor cd = new ColumnDescriptor("PARAM" + parameterId, // position
parameterId, params[index], (// default
(parameterDefaults == null) || (index >= parameterDefaults.length)) ? (DataValueDescriptor) null : (DataValueDescriptor) parameterDefaults[index], (DefaultInfo) null, uuid, (UUID) null, 0, 0, 0, false);
addDescriptor(cd, null, SYSCOLUMNS_CATALOG_NUM, // no chance of duplicates here
false, tc);
}
}
use of org.apache.derby.catalog.UUID in project derby by apache.
the class DataDictionaryImpl method getConstraints.
/**
* Return an List which of the relevant column matching
* the indexed criteria. If nothing matches, returns an
* empty List (never returns null).
*
* @param uuid The id of the constraint
* @param indexId The index id in SYS.SYSCONSTRAINTS
* @param columnNum The column to retrieve
*
* @return a list of UUIDs in an List.
*
* @exception StandardException Thrown on error
*/
public List<UUID> getConstraints(UUID uuid, int indexId, int columnNum) throws StandardException {
ExecIndexRow indexRow1;
ExecRow outRow;
RowLocation baseRowLocation;
ConglomerateController heapCC = null;
ScanController scanController = null;
TransactionController tc;
TabInfoImpl ti = getNonCoreTI(SYSCONSTRAINTS_CATALOG_NUM);
SYSCONSTRAINTSRowFactory rf = (SYSCONSTRAINTSRowFactory) ti.getCatalogRowFactory();
TableDescriptor td = null;
List<UUID> slist = new ArrayList<UUID>();
if (SanityManager.DEBUG) {
SanityManager.ASSERT(indexId == SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_INDEX1_ID || indexId == SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_INDEX3_ID, "bad index id, must be one of the indexes on a uuid");
SanityManager.ASSERT(columnNum > 0 && columnNum <= SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_COLUMN_COUNT, "invalid column number for column to be retrieved");
}
try {
/* Use tableIDOrderable in both start and stop positions for scan */
DataValueDescriptor orderable = getIDValueAsCHAR(uuid);
/* Set up the start/stop position for the scan */
ExecIndexRow keyRow = (ExecIndexRow) exFactory.getIndexableRow(1);
keyRow.setColumn(1, orderable);
// Get the current transaction controller
tc = getTransactionCompile();
outRow = rf.makeEmptyRow();
heapCC = tc.openConglomerate(ti.getHeapConglomerate(), false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ);
// create an index row template
indexRow1 = getIndexRowFromHeapRow(ti.getIndexRowGenerator(indexId), heapCC.newRowLocationTemplate(), outRow);
// just interested in one column
DataValueDescriptor[] rowTemplate = new DataValueDescriptor[SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_COLUMN_COUNT];
FormatableBitSet columnToGetSet = new FormatableBitSet(SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_COLUMN_COUNT);
columnToGetSet.set(columnNum - 1);
rowTemplate[columnNum - 1] = new SQLChar();
// Scan the index and go to the data pages for qualifying rows
scanController = tc.openScan(// conglomerate to open
ti.getIndexConglomerate(indexId), // don't hold open across commit
false, // for read
0, TransactionController.MODE_RECORD, // RESOLVE: should be level 2
TransactionController.ISOLATION_REPEATABLE_READ, // all fields as objects
(FormatableBitSet) null, // start position - exact key match.
keyRow.getRowArray(), // startSearchOperation
ScanController.GE, // scanQualifier (none)
null, // stop position - exact key match.
keyRow.getRowArray(), // stopSearchOperation
ScanController.GT);
while (scanController.fetchNext(indexRow1.getRowArray())) {
baseRowLocation = (RowLocation) indexRow1.getColumn(indexRow1.nColumns());
// get the row and grab the uuid
boolean base_row_exists = heapCC.fetch(baseRowLocation, rowTemplate, columnToGetSet);
if (SanityManager.DEBUG) {
// it can not be possible for heap row to disappear while
// holding scan cursor on index at ISOLATION_REPEATABLE_READ.
SanityManager.ASSERT(base_row_exists, "base row not found");
}
slist.add(uuidFactory.recreateUUID((String) ((DataValueDescriptor) rowTemplate[columnNum - 1]).getObject()));
}
} finally {
if (heapCC != null) {
heapCC.close();
}
if (scanController != null) {
scanController.close();
}
}
return slist;
}
use of org.apache.derby.catalog.UUID in project derby by apache.
the class SYSALIASESRowFactory method buildDescriptor.
// /////////////////////////////////////////////////////////////////////////
//
// ABSTRACT METHODS TO BE IMPLEMENTED BY CHILDREN OF CatalogRowFactory
//
// /////////////////////////////////////////////////////////////////////////
/**
* Make a AliasDescriptor out of a SYSALIASES row
*
* @param row a SYSALIASES row
* @param parentTupleDescriptor Null for this kind of descriptor.
* @param dd dataDictionary
*
* @exception StandardException thrown on failure
*/
public TupleDescriptor buildDescriptor(ExecRow row, TupleDescriptor parentTupleDescriptor, DataDictionary dd) throws StandardException {
if (SanityManager.DEBUG) {
SanityManager.ASSERT(row.nColumns() == SYSALIASES_COLUMN_COUNT, "Wrong number of columns for a SYSALIASES row");
}
char cAliasType;
char cNameSpace;
DataValueDescriptor col;
String aliasID;
UUID aliasUUID;
String aliasName;
String javaClassName;
String sAliasType;
String sNameSpace;
String typeStr;
boolean systemAlias = false;
AliasInfo aliasInfo = null;
/* 1st column is ALIASID (UUID - char(36)) */
col = row.getColumn(SYSALIASES_ALIASID);
aliasID = col.getString();
aliasUUID = getUUIDFactory().recreateUUID(aliasID);
/* 2nd column is ALIAS (varchar(128)) */
col = row.getColumn(SYSALIASES_ALIAS);
aliasName = col.getString();
/* 3rd column is SCHEMAID (UUID - char(36)) */
col = row.getColumn(SYSALIASES_SCHEMAID);
UUID schemaUUID = col.isNull() ? null : getUUIDFactory().recreateUUID(col.getString());
/* 4th column is JAVACLASSNAME (longvarchar) */
col = row.getColumn(SYSALIASES_JAVACLASSNAME);
javaClassName = col.getString();
/* 5th column is ALIASTYPE (char(1)) */
col = row.getColumn(SYSALIASES_ALIASTYPE);
sAliasType = col.getString();
if (SanityManager.DEBUG) {
SanityManager.ASSERT(sAliasType.length() == 1, "Fifth column (aliastype) type incorrect");
switch(sAliasType.charAt(0)) {
case AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR:
case AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR:
case AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR:
case AliasInfo.ALIAS_TYPE_UDT_AS_CHAR:
case AliasInfo.ALIAS_TYPE_AGGREGATE_AS_CHAR:
break;
default:
SanityManager.THROWASSERT("Invalid type value '" + sAliasType + "' for alias");
}
}
cAliasType = sAliasType.charAt(0);
/* 6th column is NAMESPACE (char(1)) */
col = row.getColumn(SYSALIASES_NAMESPACE);
sNameSpace = col.getString();
if (SanityManager.DEBUG) {
SanityManager.ASSERT(sNameSpace.length() == 1, "Sixth column (namespace) type incorrect");
switch(sNameSpace.charAt(0)) {
case AliasInfo.ALIAS_NAME_SPACE_PROCEDURE_AS_CHAR:
case AliasInfo.ALIAS_NAME_SPACE_FUNCTION_AS_CHAR:
case AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR:
case AliasInfo.ALIAS_TYPE_UDT_AS_CHAR:
case AliasInfo.ALIAS_TYPE_AGGREGATE_AS_CHAR:
break;
default:
SanityManager.THROWASSERT("Invalid type value '" + sNameSpace + "' for alias");
}
}
cNameSpace = sNameSpace.charAt(0);
/* 7th column is SYSTEMALIAS (boolean) */
col = row.getColumn(SYSALIASES_SYSTEMALIAS);
systemAlias = col.getBoolean();
/* 8th column is ALIASINFO (org.apache.derby.catalog.AliasInfo) */
col = row.getColumn(SYSALIASES_ALIASINFO);
aliasInfo = (AliasInfo) col.getObject();
/* 9th column is specific name */
col = row.getColumn(SYSALIASES_SPECIFIC_NAME);
String specificName = col.getString();
/* now build and return the descriptor */
return new AliasDescriptor(dd, aliasUUID, aliasName, schemaUUID, javaClassName, cAliasType, cNameSpace, systemAlias, aliasInfo, specificName);
}
Aggregations