Search in sources :

Example 31 with ScanController

use of org.apache.derby.iapi.store.access.ScanController in project derby by apache.

the class GenericRIChecker method close.

/**
 * Clean up all scan controllers
 *
 * @exception StandardException on error
 */
void close() throws StandardException {
    Enumeration<ScanController> e = scanControllers.elements();
    while (e.hasMoreElements()) {
        ScanController scan = e.nextElement();
        scan.close();
    }
    scanControllers.clear();
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController)

Example 32 with ScanController

use of org.apache.derby.iapi.store.access.ScanController in project derby by apache.

the class T_ConsistencyChecker method nullFirstHeapRow.

/**
 * Set all of the columns in the first row from
 * the heap to null, without
 * updating the indexes on the table.
 *
 * @param schemaName	The schema name.
 * @param tableName		The table name.
 *
 * @exception StandardException		Thrown on error
 */
public static void nullFirstHeapRow(String schemaName, String tableName) throws StandardException {
    T_ConsistencyChecker t_cc = new T_ConsistencyChecker(schemaName, tableName, null);
    t_cc.getContexts();
    t_cc.getDescriptors();
    /* Open a scan on the heap */
    ScanController heapScan = t_cc.openUnqualifiedHeapScan();
    // Move to the 1st row in the heap
    heapScan.next();
    // Get the RowLocation
    RowLocation baseRL = heapScan.newRowLocationTemplate();
    heapScan.fetchLocation(baseRL);
    // Replace the current row with nulls
    heapScan.replace(t_cc.getHeapRowOfNulls().getRowArray(), (FormatableBitSet) null);
    heapScan.close();
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) RowLocation(org.apache.derby.iapi.types.RowLocation)

Example 33 with ScanController

use of org.apache.derby.iapi.store.access.ScanController in project derby by apache.

the class T_ConsistencyChecker method insertBadRowLocation.

/**
 * Get the first row from the heap and insert it into
 * the specified index, with a bad row location, without
 * inserting it into the heap or the other indexes on the table.
 *
 * @param schemaName	The schema name.
 * @param tableName		The table name.
 * @param indexName		The specified index.
 *
 * @exception StandardException		Thrown on error
 */
public static void insertBadRowLocation(String schemaName, String tableName, String indexName) throws StandardException {
    T_ConsistencyChecker t_cc = new T_ConsistencyChecker(schemaName, tableName, indexName);
    t_cc.getContexts();
    t_cc.getDescriptors();
    /* Open a scan on the heap */
    ScanController heapScan = t_cc.openUnqualifiedHeapScan();
    // Get the RowLocation
    RowLocation baseRL = heapScan.newRowLocationTemplate();
    RowLocation badRL = heapScan.newRowLocationTemplate();
    heapScan.close();
    /* Open a scan on the index */
    ExecRow indexRow = t_cc.getIndexTemplateRow(baseRL);
    ScanController indexScan = t_cc.openUnqualifiedIndexScan();
    // Move to the 1st row in the index
    indexScan.next();
    // Fetch the 1st row
    indexScan.fetch(indexRow.getRowArray());
    indexScan.close();
    // Insert another copy of the 1st row into the index with a bad row location
    int keyLength = t_cc.getIndexDescriptor().getIndexDescriptor().baseColumnPositions().length;
    indexRow.setColumn(keyLength + 1, badRL);
    ConglomerateController indexCC = t_cc.openIndexCC();
    indexCC.insert(indexRow.getRowArray());
    indexCC.close();
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow) RowLocation(org.apache.derby.iapi.types.RowLocation)

Example 34 with ScanController

use of org.apache.derby.iapi.store.access.ScanController in project derby by apache.

the class T_ConsistencyChecker method openUnqualifiedIndexScan.

/* Open an unqualified scan on the index for update */
private ScanController openUnqualifiedIndexScan() throws StandardException {
    ScanController indexScan;
    indexScan = tc.openScan(id.getConglomerateNumber(), // hold
    false, // forUpdate
    TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_TABLE, TransactionController.ISOLATION_SERIALIZABLE, (FormatableBitSet) null, // startKeyValue
    null, // not used with null start posn.
    0, // qualifier
    null, // stopKeyValue
    null, // not used with null stop posn.
    0);
    return indexScan;
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet)

Example 35 with ScanController

use of org.apache.derby.iapi.store.access.ScanController in project derby by apache.

the class T_ConsistencyChecker method reinsertFirstHeapRow.

/**
 * Get the first row from the heap and insert it into
 * the heap again, without
 * inserting it from the indexes on the table.
 *
 * @param schemaName	The schema name.
 * @param tableName		The table name.
 *
 * @exception StandardException		Thrown on error
 */
public static void reinsertFirstHeapRow(String schemaName, String tableName) throws StandardException {
    T_ConsistencyChecker t_cc = new T_ConsistencyChecker(schemaName, tableName, null);
    t_cc.getContexts();
    t_cc.getDescriptors();
    /* Open a scan on the heap */
    ScanController heapScan = t_cc.openUnqualifiedHeapScan();
    // Move to the 1st row in the heap
    heapScan.next();
    // Fetch the 1st row
    ExecRow firstRow = t_cc.getHeapRowOfNulls();
    heapScan.fetch(firstRow.getRowArray());
    heapScan.close();
    // Insert another copy of the 1st row into the heap
    ConglomerateController heapCC = t_cc.openHeapCC();
    heapCC.insert(firstRow.getRowArray());
    heapCC.close();
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) ExecRow(org.apache.derby.iapi.sql.execute.ExecRow)

Aggregations

ScanController (org.apache.derby.iapi.store.access.ScanController)61 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)35 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)32 RowLocation (org.apache.derby.iapi.types.RowLocation)29 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)24 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)22 SQLLongint (org.apache.derby.iapi.types.SQLLongint)20 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)9 StandardException (org.apache.derby.shared.common.error.StandardException)9 TransactionController (org.apache.derby.iapi.store.access.TransactionController)8 Properties (java.util.Properties)7 GroupFetchScanController (org.apache.derby.iapi.store.access.GroupFetchScanController)7 SQLChar (org.apache.derby.iapi.types.SQLChar)6 UUID (org.apache.derby.catalog.UUID)5 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)5 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)5 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)4 HashSet (java.util.HashSet)3 Hashtable (java.util.Hashtable)3 ReferencedKeyConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ReferencedKeyConstraintDescriptor)3