Search in sources :

Example 11 with ExecIndexRow

use of org.apache.derby.iapi.sql.execute.ExecIndexRow 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);
}
Also used : TupleDescriptor(org.apache.derby.iapi.sql.dictionary.TupleDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) SQLVarchar(org.apache.derby.iapi.types.SQLVarchar) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 12 with ExecIndexRow

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

the class DataDictionaryImpl method getColumnDescriptorsScan.

/**
 * Populate the ColumnDescriptorList for the specified TableDescriptor.
 *
 * MT synchronization: it is assumed that the caller has synchronized
 * on the CDL in the given TD.
 *
 * @param uuid				The referencing UUID
 * @param cdl			The column descriptor list
 * @param td				The parent tuple descriptor
 *
 * @exception StandardException		Thrown on failure
 */
private void getColumnDescriptorsScan(UUID uuid, ColumnDescriptorList cdl, TupleDescriptor td) throws StandardException {
    ColumnDescriptor cd;
    ColumnDescriptorList cdlCopy = new ColumnDescriptorList();
    DataValueDescriptor refIDOrderable = null;
    TabInfoImpl ti = coreInfo[SYSCOLUMNS_CORE_NUM];
    /* Use refIDOrderable in both start and stop position for scan. */
    refIDOrderable = getIDValueAsCHAR(uuid);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(1);
    keyRow.setColumn(1, refIDOrderable);
    getDescriptorViaIndex(SYSCOLUMNSRowFactory.SYSCOLUMNS_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, td, cdl, ColumnDescriptor.class, false);
    /* The TableDescriptor's column descriptor list must be ordered by
		 * columnNumber.  (It is probably not ordered correctly at this point due
		 * to the index on syscolumns being on (tableId, columnName).)  The
		 * cheapest way to reorder the list appears to be to copy it (above), and then
		 * walk the copy and put the elements back into the original in the
		 * expected locations.
		 */
    int cdlSize = cdl.size();
    for (int index = 0; index < cdlSize; index++) {
        cdlCopy.add(cdl.get(index));
    }
    for (int index = 0; index < cdlSize; index++) {
        cd = (ColumnDescriptor) cdlCopy.elementAt(index);
        cdl.set(cd.getPosition() - 1, cd);
    }
}
Also used : ColumnDescriptorList(org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList) ColumnDescriptor(org.apache.derby.iapi.sql.dictionary.ColumnDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow) SQLLongint(org.apache.derby.iapi.types.SQLLongint)

Example 13 with ExecIndexRow

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

the class DataDictionaryImpl method getIndexRowFromHeapRow.

/**
 * Get an index row based on a row from the heap.
 *
 * @param irg		IndexRowGenerator to use
 * @param rl		RowLocation for heap
 * @param heapRow	Row from the heap
 *
 * @return ExecIndexRow	Index row.
 *
 * @exception StandardException		Thrown on error
 */
public static ExecIndexRow getIndexRowFromHeapRow(IndexRowGenerator irg, RowLocation rl, ExecRow heapRow) throws StandardException {
    ExecIndexRow indexRow;
    indexRow = irg.getIndexRowTemplate();
    // Get an index row based on the base row
    irg.getIndexRow(heapRow, rl, indexRow, (FormatableBitSet) null);
    return indexRow;
}
Also used : ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 14 with ExecIndexRow

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

the class DataDictionaryImpl method dropSPSDescriptor.

/**
 * Drops the given SPSDescriptor.
 *
 * @param uuid	the statement uuid
 * @param tc	The TransactionController.
 *
 * @exception StandardException		Thrown on failure
 */
public void dropSPSDescriptor(UUID uuid, TransactionController tc) throws StandardException {
    DataValueDescriptor stmtIdOrderable;
    TabInfoImpl ti = getNonCoreTI(SYSSTATEMENTS_CATALOG_NUM);
    stmtIdOrderable = getIDValueAsCHAR(uuid);
    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = (ExecIndexRow) exFactory.getIndexableRow(1);
    keyRow.setColumn(1, stmtIdOrderable);
    ti.deleteRow(tc, keyRow, SYSSTATEMENTSRowFactory.SYSSTATEMENTS_INDEX1_ID);
    /* drop all columns in SYSCOLUMNS */
    dropAllColumnDescriptors(uuid, tc);
}
Also used : DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow)

Example 15 with ExecIndexRow

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

the class DataDictionaryImpl method dropStoredDependency.

/**
 * Drop a single dependency from the data dictionary.
 *
 * @param dd	The DependencyDescriptor.
 * @param tc	TransactionController for the transaction
 *
 * @exception StandardException		Thrown on failure
 */
public void dropStoredDependency(DependencyDescriptor dd, TransactionController tc) throws StandardException {
    ExecIndexRow keyRow1 = null;
    UUID dependentID = dd.getUUID();
    UUID providerID = dd.getProviderID();
    DataValueDescriptor dependentIDOrderable = getIDValueAsCHAR(dependentID);
    TabInfoImpl ti = getNonCoreTI(SYSDEPENDS_CATALOG_NUM);
    /* Use dependentIDOrderable in both start 
		 * and stop position for index 1 scan. 
		 */
    keyRow1 = (ExecIndexRow) exFactory.getIndexableRow(1);
    keyRow1.setColumn(1, dependentIDOrderable);
    // only drop the rows which have this providerID
    TupleFilter filter = new DropDependencyFilter(providerID);
    ti.deleteRows(tc, // start row
    keyRow1, ScanController.GE, // qualifier
    null, // filter on base row
    filter, // stop row
    keyRow1, ScanController.GT, SYSDEPENDSRowFactory.SYSDEPENDS_INDEX1_ID);
}
Also used : DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UUID(org.apache.derby.catalog.UUID) ExecIndexRow(org.apache.derby.iapi.sql.execute.ExecIndexRow) TupleFilter(org.apache.derby.iapi.sql.execute.TupleFilter)

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