Search in sources :

Example 16 with ExecIndexRow

use of org.apache.derby.iapi.sql.execute.ExecIndexRow 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);
}
Also used : TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) SQLChar(org.apache.derby.iapi.types.SQLChar) ScanQualifier(org.apache.derby.iapi.sql.execute.ScanQualifier) ColumnDescriptorList(org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList) ConglomerateDescriptorList(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptorList) ArrayList(java.util.ArrayList) TriggerDescriptorList(org.apache.derby.iapi.sql.dictionary.TriggerDescriptorList) List(java.util.List) ConstraintDescriptorList(org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList) LinkedList(java.util.LinkedList) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor)

Example 17 with ExecIndexRow

use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.

the class DataDictionaryImpl method getAliasDescriptor.

/**
 * Get a AliasDescriptor given its UUID.
 *
 * @param uuid	The UUID
 *
 * @return The AliasDescriptor for the alias.
 *
 * @exception StandardException		Thrown on failure
 */
public AliasDescriptor getAliasDescriptor(UUID uuid) throws StandardException {
    DataValueDescriptor UUIDStringOrderable;
    TabInfoImpl ti = getNonCoreTI(SYSALIASES_CATALOG_NUM);
    /* Use UUIDStringOrderable in both start and stop positions for scan */
    UUIDStringOrderable = getIDValueAsCHAR(uuid);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(1);
    keyRow.setColumn(1, UUIDStringOrderable);
    return getDescriptorViaIndex(SYSALIASESRowFactory.SYSALIASES_INDEX2_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, AliasDescriptor.class, false);
}
Also used : TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 18 with ExecIndexRow

use of org.apache.derby.iapi.sql.execute.ExecIndexRow 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);
}
Also used : TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) SQLChar(org.apache.derby.iapi.types.SQLChar) ScanQualifier(org.apache.derby.iapi.sql.execute.ScanQualifier) ColumnDescriptorList(org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList) ConglomerateDescriptorList(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptorList) ArrayList(java.util.ArrayList) TriggerDescriptorList(org.apache.derby.iapi.sql.dictionary.TriggerDescriptorList) List(java.util.List) ConstraintDescriptorList(org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList) LinkedList(java.util.LinkedList) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor)

Example 19 with ExecIndexRow

use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.

the class DataDictionaryImpl method getStatisticsDescriptors.

/**
 * Returns all the statistics descriptors for the given table.
 * <p>
 * NOTE: As opposed to most other data dictionary lookups, this operation is
 * performed with isolation level READ_UNCOMMITTED. The reason is to avoid
 * deadlocks with inserts into the statistics system table.
 *
 * @param td {@code TableDescriptor} for which I need statistics
 * @return A list of tuple descriptors, possibly empty.
 */
public List<StatisticsDescriptor> getStatisticsDescriptors(TableDescriptor td) throws StandardException {
    TabInfoImpl ti = getNonCoreTI(SYSSTATISTICS_CATALOG_NUM);
    List<StatisticsDescriptor> statDescriptorList = newSList();
    DataValueDescriptor UUIDStringOrderable;
    /* set up the start/stop position for the scan */
    UUIDStringOrderable = getIDValueAsCHAR(td.getUUID());
    ExecIndexRow keyRow = exFactory.getIndexableRow(1);
    keyRow.setColumn(1, UUIDStringOrderable);
    getDescriptorViaIndex(SYSSTATISTICSRowFactory.SYSSTATISTICS_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, statDescriptorList, StatisticsDescriptor.class, false, TransactionController.ISOLATION_READ_UNCOMMITTED, getTransactionCompile());
    return statDescriptorList;
}
Also used : StatisticsDescriptor(org.apache.derby.iapi.sql.dictionary.StatisticsDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 20 with ExecIndexRow

use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.

the class DataDictionaryImpl method getSubKeyConstraint.

/**
 * Get a SubKeyConstraintDescriptor from syskeys or sysforeignkeys for
 * the specified constraint id.  For primary foreign and and unique
 * key constraints.
 *
 * @param constraintId	The UUID for the constraint.
 * @param type	The type of the constraint
 *		(e.g. DataDictionary.FOREIGNKEY_CONSTRAINT)
 *
 * @return SubKeyConstraintDescriptor	The Sub descriptor for the constraint.
 *
 * @exception StandardException		Thrown on failure
 */
public SubKeyConstraintDescriptor getSubKeyConstraint(UUID constraintId, int type) throws StandardException {
    DataValueDescriptor constraintIDOrderable = null;
    TabInfoImpl ti;
    int indexNum;
    int baseNum;
    if (type == DataDictionary.FOREIGNKEY_CONSTRAINT) {
        baseNum = SYSFOREIGNKEYS_CATALOG_NUM;
        indexNum = SYSFOREIGNKEYSRowFactory.SYSFOREIGNKEYS_INDEX1_ID;
    } else {
        baseNum = SYSKEYS_CATALOG_NUM;
        indexNum = SYSKEYSRowFactory.SYSKEYS_INDEX1_ID;
    }
    ti = getNonCoreTI(baseNum);
    /* 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(indexNum, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, SubKeyConstraintDescriptor.class, false);
}
Also used : TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow) SQLLongint(org.apache.derby.iapi.types.SQLLongint)

Aggregations

ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)110 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)72 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)34 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)30 TupleDescriptor (org.apache.derby.iapi.sql.dictionary.TupleDescriptor)27 SQLChar (org.apache.derby.iapi.types.SQLChar)22 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)14 SQLLongint (org.apache.derby.iapi.types.SQLLongint)13 RowLocation (org.apache.derby.iapi.types.RowLocation)12 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)10 ScanController (org.apache.derby.iapi.store.access.ScanController)9 UUID (org.apache.derby.catalog.UUID)8 ArrayList (java.util.ArrayList)7 ColumnDescriptorList (org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList)6 ConglomerateDescriptorList (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptorList)6 ConstraintDescriptorList (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList)6 TransactionController (org.apache.derby.iapi.store.access.TransactionController)6 Properties (java.util.Properties)5 PermissionsDescriptor (org.apache.derby.iapi.sql.dictionary.PermissionsDescriptor)5 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)5