use of org.apache.derby.iapi.types.SQLVarchar in project derby by apache.
the class DataDictionaryImpl method getTriggerDescriptor.
/**
* Get the stored prepared statement descriptor given
* a sps name.
*
* @param name The sps name.
* @param sd The schema descriptor.
*
* @return The TriggerDescriptor for the constraint.
*
* @exception StandardException Thrown on failure
*/
public TriggerDescriptor getTriggerDescriptor(String name, SchemaDescriptor sd) throws StandardException {
DataValueDescriptor schemaIDOrderable;
DataValueDescriptor triggerNameOrderable;
TabInfoImpl ti = getNonCoreTI(SYSTRIGGERS_CATALOG_NUM);
/* Use triggerNameOrderable and schemaIdOrderable in both start
* and stop position for scan.
*/
triggerNameOrderable = new SQLVarchar(name);
schemaIDOrderable = getIDValueAsCHAR(sd.getUUID());
/* Set up the start/stop position for the scan */
ExecIndexRow keyRow = exFactory.getIndexableRow(2);
keyRow.setColumn(1, triggerNameOrderable);
keyRow.setColumn(2, schemaIDOrderable);
return getDescriptorViaIndex(SYSTRIGGERSRowFactory.SYSTRIGGERS_INDEX2_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, TriggerDescriptor.class, false);
}
use of org.apache.derby.iapi.types.SQLVarchar in project derby by apache.
the class DataDictionaryImpl method getTableDescriptorIndex1Scan.
/**
* Scan systables_index1 (tablename, schemaid) for a match.
*
* @return TableDescriptor The matching descriptor, if any.
*
* @exception StandardException Thrown on failure
*/
private TableDescriptor getTableDescriptorIndex1Scan(String tableName, String schemaUUID) throws StandardException {
DataValueDescriptor schemaIDOrderable;
DataValueDescriptor tableNameOrderable;
TableDescriptor td;
TabInfoImpl ti = coreInfo[SYSTABLES_CORE_NUM];
/* Use tableNameOrderable and schemaIdOrderable in both start
* and stop position for scan.
*/
tableNameOrderable = new SQLVarchar(tableName);
schemaIDOrderable = new SQLChar(schemaUUID);
/* Set up the start/stop position for the scan */
ExecIndexRow keyRow = exFactory.getIndexableRow(2);
keyRow.setColumn(1, tableNameOrderable);
keyRow.setColumn(2, schemaIDOrderable);
td = getDescriptorViaIndex(SYSTABLESRowFactory.SYSTABLES_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, TableDescriptor.class, false);
return finishTableDescriptor(td);
}
use of org.apache.derby.iapi.types.SQLVarchar in project derby by apache.
the class DataDictionaryImpl method existsSchemaOwnedBy.
/**
* Return true of there exists a schema whose authorizationId equals
* authid, i.e. SYS.SYSSCHEMAS contains a row whose column
* (AUTHORIZATIONID) equals authid.
*
* @param authid authorizationId
* @param tc TransactionController
* @return true iff there is a matching schema
* @exception StandardException
*/
public boolean existsSchemaOwnedBy(String authid, TransactionController tc) throws StandardException {
TabInfoImpl ti = coreInfo[SYSSCHEMAS_CORE_NUM];
SYSSCHEMASRowFactory rf = (SYSSCHEMASRowFactory) ti.getCatalogRowFactory();
ConglomerateController heapCC = tc.openConglomerate(ti.getHeapConglomerate(), false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ);
DataValueDescriptor authIdOrderable = new SQLVarchar(authid);
ScanQualifier[][] scanQualifier = exFactory.getScanQualifier(1);
scanQualifier[0][0].setQualifier(SYSSCHEMASRowFactory.SYSSCHEMAS_SCHEMAAID - 1, /* to zero-based */
authIdOrderable, Orderable.ORDER_OP_EQUALS, false, false, false);
ScanController sc = tc.openScan(ti.getHeapConglomerate(), // don't hold open across commit
false, // for update
0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ, // all fields as objects
(FormatableBitSet) null, // start position -
(DataValueDescriptor[]) null, // startSearchOperation - none
0, //
scanQualifier, // stop position -through last row
(DataValueDescriptor[]) null, // stopSearchOperation - none
0);
boolean result = false;
try {
ExecRow outRow = rf.makeEmptyRow();
if (sc.fetchNext(outRow.getRowArray())) {
result = true;
}
} finally {
if (sc != null) {
sc.close();
}
if (heapCC != null) {
heapCC.close();
}
}
return result;
}
use of org.apache.derby.iapi.types.SQLVarchar in project derby by apache.
the class DataDictionaryImpl method getRoleDefinitionDescriptor.
/**
* Get the target role definition by searching for a matching row
* in SYSROLES by rolename where isDef==true. Read only scan.
* Uses index on (rolename, isDef) columns.
*
* @param roleName The name of the role we're interested in.
*
* @return The descriptor (row) for the role
* @exception StandardException Thrown on error
*
* @see DataDictionary#getRoleDefinitionDescriptor
*/
public RoleGrantDescriptor getRoleDefinitionDescriptor(String roleName) throws StandardException {
DataValueDescriptor roleNameOrderable;
DataValueDescriptor isDefOrderable;
TabInfoImpl ti = getNonCoreTI(SYSROLES_CATALOG_NUM);
/* Use aliasNameOrderable , isDefOrderable in both start
* and stop position for scan.
*/
roleNameOrderable = new SQLVarchar(roleName);
isDefOrderable = new SQLVarchar("Y");
/* Set up the start/stop position for the scan */
ExecIndexRow keyRow = exFactory.getIndexableRow(2);
keyRow.setColumn(1, roleNameOrderable);
keyRow.setColumn(2, isDefOrderable);
return getDescriptorViaIndex(SYSROLESRowFactory.SYSROLES_INDEX_ID_DEF_IDX, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, RoleGrantDescriptor.class, false);
}
use of org.apache.derby.iapi.types.SQLVarchar in project derby by apache.
the class DataDictionaryImpl method getConglomerateDescriptor.
/**
* Gets a conglomerate descriptor for the named index in the given schema,
* getting an exclusive row lock on the matching row in
* sys.sysconglomerates (for DDL concurrency) if requested.
*
* @param indexName The name of the index we're looking for
* @param sd The schema descriptor
* @param forUpdate Whether or not to get an exclusive row
* lock on the row in sys.sysconglomerates.
*
* @return A ConglomerateDescriptor describing the requested
* conglomerate. Returns NULL if no such conglomerate.
*
* @exception StandardException Thrown on failure
*/
public ConglomerateDescriptor getConglomerateDescriptor(String indexName, SchemaDescriptor sd, boolean forUpdate) throws StandardException {
ExecIndexRow keyRow2 = null;
DataValueDescriptor nameOrderable;
DataValueDescriptor schemaIDOrderable = null;
TabInfoImpl ti = coreInfo[SYSCONGLOMERATES_CORE_NUM];
nameOrderable = new SQLVarchar(indexName);
schemaIDOrderable = getIDValueAsCHAR(sd.getUUID());
/* Set up the start/stop position for the scan */
keyRow2 = exFactory.getIndexableRow(2);
keyRow2.setColumn(1, nameOrderable);
keyRow2.setColumn(2, schemaIDOrderable);
return getDescriptorViaIndex(SYSCONGLOMERATESRowFactory.SYSCONGLOMERATES_INDEX2_ID, keyRow2, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, ConglomerateDescriptor.class, forUpdate);
}
Aggregations