use of org.apache.derby.iapi.types.SQLChar in project derby by apache.
the class DataDictionaryImpl method getUUIDForCoreTable.
/**
* Get the UUID for the specified system table. Prior
* to Plato, system tables did not have canonical UUIDs, so
* we need to scan systables to get the UUID when we
* are updating the core tables.
*
* @param tableName Name of the table
* @param schemaUUID UUID of schema
* @param tc TransactionController to user
*
* @return UUID The UUID of the core table.
*
* @exception StandardException Thrown on failure
*/
private UUID getUUIDForCoreTable(String tableName, String schemaUUID, TransactionController tc) throws StandardException {
ConglomerateController heapCC;
ExecRow row;
DataValueDescriptor schemaIDOrderable;
DataValueDescriptor tableNameOrderable;
ScanController scanController;
TabInfoImpl ti = coreInfo[SYSTABLES_CORE_NUM];
SYSTABLESRowFactory rf = (SYSTABLESRowFactory) ti.getCatalogRowFactory();
// We only want the 1st column from the heap
row = exFactory.getValueRow(1);
/* 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);
heapCC = tc.openConglomerate(ti.getHeapConglomerate(), false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ);
ExecRow indexTemplateRow = rf.buildEmptyIndexRow(SYSTABLESRowFactory.SYSTABLES_INDEX1_ID, heapCC.newRowLocationTemplate());
/* Scan the index and go to the data pages for qualifying rows to
* build the column descriptor.
*/
scanController = tc.openScan(// conglomerate to open
ti.getIndexConglomerate(SYSTABLESRowFactory.SYSTABLES_INDEX1_ID), // don't hold open across commit
false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ, // all fields as objects
(FormatableBitSet) null, // start position - first row
keyRow.getRowArray(), // startSearchOperation
ScanController.GE, // scanQualifier,
(ScanQualifier[][]) null, // stop position - through last row
keyRow.getRowArray(), // stopSearchOperation
ScanController.GT);
/* OK to fetch into the template row,
* since we won't be doing a next.
*/
if (scanController.fetchNext(indexTemplateRow.getRowArray())) {
RowLocation baseRowLocation;
baseRowLocation = (RowLocation) indexTemplateRow.getColumn(indexTemplateRow.nColumns());
/* 1st column is TABLEID (UUID - char(36)) */
row.setColumn(SYSTABLESRowFactory.SYSTABLES_TABLEID, new SQLChar());
FormatableBitSet bi = new FormatableBitSet(1);
bi.set(0);
boolean base_row_exists = heapCC.fetch(baseRowLocation, row.getRowArray(), (FormatableBitSet) null);
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");
}
}
scanController.close();
heapCC.close();
return uuidFactory.recreateUUID(row.getColumn(1).toString());
}
use of org.apache.derby.iapi.types.SQLChar in project derby by apache.
the class DataDictionaryImpl method getTableDescriptorIndex2Scan.
/**
* Scan systables_index2 (tableid) for a match.
*
* @return TableDescriptor The matching descriptor, if any.
*
* @exception StandardException Thrown on failure
*/
private TableDescriptor getTableDescriptorIndex2Scan(String tableUUID) throws StandardException {
DataValueDescriptor tableIDOrderable;
TableDescriptor td;
TabInfoImpl ti = coreInfo[SYSTABLES_CORE_NUM];
/* Use tableIDOrderable in both start and stop position for scan.
*/
tableIDOrderable = new SQLChar(tableUUID);
/* Set up the start/stop position for the scan */
ExecIndexRow keyRow = exFactory.getIndexableRow(1);
keyRow.setColumn(1, tableIDOrderable);
td = getDescriptorViaIndex(SYSTABLESRowFactory.SYSTABLES_INDEX2_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, TableDescriptor.class, false);
return finishTableDescriptor(td);
}
use of org.apache.derby.iapi.types.SQLChar 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.SQLChar in project derby by apache.
the class DataDictionaryImpl method getSPSDescriptorIndex2Scan.
/**
* Scan sysstatements_index2 (stmtid) for a match.
* Note that we do not do a lookup of parameter info.
*
* @return SPSDescriptor The matching descriptor, if any.
*
* @exception StandardException Thrown on failure
*/
private SPSDescriptor getSPSDescriptorIndex2Scan(String stmtUUID) throws StandardException {
DataValueDescriptor stmtIDOrderable;
TabInfoImpl ti = getNonCoreTI(SYSSTATEMENTS_CATALOG_NUM);
/* Use stmtIdOrderable in both start
* and stop position for scan.
*/
stmtIDOrderable = new SQLChar(stmtUUID);
/* Set up the start/stop position for the scan */
ExecIndexRow keyRow = exFactory.getIndexableRow(1);
keyRow.setColumn(1, stmtIDOrderable);
SPSDescriptor spsd = getDescriptorViaIndex(SYSSTATEMENTSRowFactory.SYSSTATEMENTS_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, SPSDescriptor.class, false);
return spsd;
}
use of org.apache.derby.iapi.types.SQLChar in project derby by apache.
the class SYSTABLEPERMSRowFactory method buildIndexKeyRow.
/**
* builds a key row given for a given index number.
*/
public ExecIndexRow buildIndexKeyRow(int indexNumber, PermissionsDescriptor perm) throws StandardException {
ExecIndexRow row = null;
switch(indexNumber) {
case GRANTEE_TABLE_GRANTOR_INDEX_NUM:
// RESOLVE We do not support the FOR GRANT OPTION, so table permission rows are unique on the
// grantee and table UUID columns. The grantor column will always have the name of the owner of the
// table. So the index key, used for searching the index, only has grantee and table UUID columns.
// It does not have a grantor column.
//
// If we support FOR GRANT OPTION then there may be multiple table permissions rows for a
// (grantee, tableID) combination. We must either handle the multiple rows, which is necessary for
// checking permissions, or add a grantor column to the key, which is necessary for granting or revoking
// permissions.
row = getExecutionFactory().getIndexableRow(2);
row.setColumn(1, getAuthorizationID(perm.getGrantee()));
String tableUUIDStr = ((TablePermsDescriptor) perm).getTableUUID().toString();
row.setColumn(2, new SQLChar(tableUUIDStr));
break;
case TABLEPERMSID_INDEX_NUM:
row = getExecutionFactory().getIndexableRow(1);
String tablePermsUUIDStr = perm.getObjectID().toString();
row.setColumn(1, new SQLChar(tablePermsUUIDStr));
break;
case TABLEID_INDEX_NUM:
row = getExecutionFactory().getIndexableRow(1);
tableUUIDStr = ((TablePermsDescriptor) perm).getTableUUID().toString();
row.setColumn(1, new SQLChar(tableUUIDStr));
break;
}
return row;
}
Aggregations