use of org.apache.derby.iapi.store.access.ConglomerateController 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();
}
use of org.apache.derby.iapi.store.access.ConglomerateController in project derby by apache.
the class T_ConsistencyChecker method getHeapRowOfNulls.
/* Get a heap row full of nulls */
private ExecRow getHeapRowOfNulls() throws StandardException {
ConglomerateController baseCC;
ExecRow baseRow;
/* Open the heap for reading */
baseCC = tc.openConglomerate(td.getHeapConglomerateId(), false, 0, TransactionController.MODE_TABLE, TransactionController.ISOLATION_SERIALIZABLE);
/* Get a row template for the base table */
baseRow = lcc.getLanguageConnectionFactory().getExecutionFactory().getValueRow(td.getNumberOfColumns());
/* Fill the row with nulls of the correct type */
ColumnDescriptorList cdl = td.getColumnDescriptorList();
int cdlSize = cdl.size();
for (int index = 0; index < cdlSize; index++) {
ColumnDescriptor cd = (ColumnDescriptor) cdl.elementAt(index);
DataTypeDescriptor dts = cd.getType();
baseRow.setColumn(cd.getPosition(), dts.getNull());
}
baseCC.close();
return baseRow;
}
use of org.apache.derby.iapi.store.access.ConglomerateController 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();
}
use of org.apache.derby.iapi.store.access.ConglomerateController in project derby by apache.
the class T_ConsistencyChecker method openHeapCC.
/* Open the heap conglomerate for update */
private ConglomerateController openHeapCC() throws StandardException {
ConglomerateController heapCC;
heapCC = tc.openConglomerate(td.getHeapConglomerateId(), false, // forUpdate
TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_TABLE, TransactionController.ISOLATION_SERIALIZABLE);
return heapCC;
}
use of org.apache.derby.iapi.store.access.ConglomerateController in project derby by apache.
the class TestPropertyInfo method getConglomerateProperties.
private static Properties getConglomerateProperties(String schemaName, String conglomerateName, boolean isIndex) throws java.sql.SQLException {
ConglomerateController cc;
ConglomerateDescriptor cd;
DataDictionary dd;
Properties properties;
SchemaDescriptor sd;
TableDescriptor td;
TransactionController tc;
long conglomerateNumber;
// find the language context.
LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
// Get the current transaction controller
tc = lcc.getTransactionExecute();
try {
// find the DataDictionary
dd = lcc.getDataDictionary();
// get the SchemaDescriptor
sd = dd.getSchemaDescriptor(schemaName, tc, true);
if (!isIndex) {
// get the TableDescriptor for the table
td = dd.getTableDescriptor(conglomerateName, sd, tc);
// Return an empty Properties if table does not exist or if it is for a view.
if ((td == null) || td.getTableType() == TableDescriptor.VIEW_TYPE) {
return new Properties();
}
conglomerateNumber = td.getHeapConglomerateId();
} else {
// get the ConglomerateDescriptor for the index
cd = dd.getConglomerateDescriptor(conglomerateName, sd, false);
// Return an empty Properties if index does not exist
if (cd == null) {
return new Properties();
}
conglomerateNumber = cd.getConglomerateNumber();
}
cc = tc.openConglomerate(conglomerateNumber, false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE);
properties = cc.getInternalTablePropertySet(new Properties());
cc.close();
} catch (StandardException se) {
throw PublicAPI.wrapStandardException(se);
}
return properties;
}
Aggregations