use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.
the class DataDictionaryImpl method dropAllColumnDescriptors.
/**
* Drops all column descriptors from the given table. Useful for
* DROP TABLE.
*
* @param tableID The UUID of the table from which to drop
* all the column descriptors
* @param tc TransactionController for the transaction
*
* @exception StandardException Thrown on error
*/
public void dropAllColumnDescriptors(UUID tableID, TransactionController tc) throws StandardException {
DataValueDescriptor tableIdOrderable;
/* Use tableIDOrderable in both start and stop position for scan. */
tableIdOrderable = getIDValueAsCHAR(tableID);
/* Set up the start/stop position for the scan */
ExecIndexRow keyRow = exFactory.getIndexableRow(1);
keyRow.setColumn(1, tableIdOrderable);
dropColumnDescriptorCore(tc, keyRow);
}
use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.
the class DataDictionaryImpl method dropColumnPermDescriptor.
/**
* Delete the appropriate rows from syscolperms when
* dropping a table
*
* @param tc The TransactionController
* @param keyRow Start/stop position.
*
* @exception StandardException Thrown on failure
*/
private void dropColumnPermDescriptor(TransactionController tc, ExecIndexRow keyRow) throws StandardException {
ExecRow curRow;
PermissionsDescriptor perm;
TabInfoImpl ti = getNonCoreTI(SYSCOLPERMS_CATALOG_NUM);
SYSCOLPERMSRowFactory rf = (SYSCOLPERMSRowFactory) ti.getCatalogRowFactory();
while ((curRow = ti.getRow(tc, keyRow, rf.TABLEID_INDEX_NUM)) != null) {
perm = (PermissionsDescriptor) rf.buildDescriptor(curRow, (TupleDescriptor) null, this);
removePermEntryInCache(perm);
// Build key on UUID and drop the entry as we want to drop only this row
ExecIndexRow uuidKey;
uuidKey = rf.buildIndexKeyRow(rf.COLPERMSID_INDEX_NUM, perm);
ti.deleteRow(tc, uuidKey, rf.COLPERMSID_INDEX_NUM);
}
}
use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.
the class DataDictionaryImpl method updateSPS.
/**
* Updates SYS.SYSSTATEMENTS with the info from the
* SPSD.
*
* @param spsd The descriptor to add
* @param tc The transaction controller
* @param recompile Whether to recompile or invalidate
*
* @exception StandardException Thrown on error
*/
@Override
public void updateSPS(SPSDescriptor spsd, TransactionController tc, boolean recompile) throws StandardException {
ExecIndexRow keyRow1 = null;
ExecRow row;
DataValueDescriptor idOrderable;
TabInfoImpl ti = getNonCoreTI(SYSSTATEMENTS_CATALOG_NUM);
SYSSTATEMENTSRowFactory rf = (SYSSTATEMENTSRowFactory) ti.getCatalogRowFactory();
int[] updCols;
if (recompile) {
updCols = new int[] { SYSSTATEMENTSRowFactory.SYSSTATEMENTS_VALID, SYSSTATEMENTSRowFactory.SYSSTATEMENTS_TEXT, SYSSTATEMENTSRowFactory.SYSSTATEMENTS_LASTCOMPILED, SYSSTATEMENTSRowFactory.SYSSTATEMENTS_USINGTEXT, SYSSTATEMENTSRowFactory.SYSSTATEMENTS_CONSTANTSTATE };
} else {
// This is an invalidation request. Update the VALID column (to
// false) and clear the plan stored in the CONSTANTSTATE column.
updCols = new int[] { SYSSTATEMENTSRowFactory.SYSSTATEMENTS_VALID, SYSSTATEMENTSRowFactory.SYSSTATEMENTS_CONSTANTSTATE };
}
idOrderable = getIDValueAsCHAR(spsd.getUUID());
/* Set up the start/stop position for the scan */
keyRow1 = (ExecIndexRow) exFactory.getIndexableRow(1);
keyRow1.setColumn(1, idOrderable);
row = // don't compile
rf.makeSYSSTATEMENTSrow(// don't compile
false, spsd);
/*
** Not updating any indexes
*/
boolean[] bArray = new boolean[2];
/*
** Partial update
*/
ti.updateRow(keyRow1, row, SYSSTATEMENTSRowFactory.SYSSTATEMENTS_INDEX1_ID, bArray, updCols, tc);
// parameter descriptors, so we are done.
if (!recompile) {
return;
}
/*
** Set the defaults and datatypes for the parameters, if
** there are parameters.
*/
DataTypeDescriptor[] params = spsd.getParams();
if (params == null) {
return;
}
// Update the parameter descriptors by dropping the existing ones
// and recreating them. If this is the first time the SPS is being
// compiled, the drop operation will be a no-op.
dropAllColumnDescriptors(spsd.getUUID(), tc);
addSPSParams(spsd, tc);
}
use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.
the class DataDictionaryImpl method dropConglomerateDescriptor.
/**
* Drops a conglomerate descriptor
*
* @param conglomerate The ConglomerateDescriptor for the conglomerate
* @param tc TransactionController for the transaction
*
* @exception StandardException Thrown on failure
*/
public void dropConglomerateDescriptor(ConglomerateDescriptor conglomerate, TransactionController tc) throws StandardException {
ExecIndexRow keyRow2 = null;
DataValueDescriptor nameOrderable;
DataValueDescriptor schemaIDOrderable = null;
TabInfoImpl ti = coreInfo[SYSCONGLOMERATES_CORE_NUM];
nameOrderable = new SQLVarchar(conglomerate.getConglomerateName());
schemaIDOrderable = getIDValueAsCHAR(conglomerate.getSchemaID());
/* Set up the start/stop position for the scan */
keyRow2 = (ExecIndexRow) exFactory.getIndexableRow(2);
keyRow2.setColumn(1, nameOrderable);
keyRow2.setColumn(2, schemaIDOrderable);
ti.deleteRow(tc, keyRow2, SYSCONGLOMERATESRowFactory.SYSCONGLOMERATES_INDEX2_ID);
}
use of org.apache.derby.iapi.sql.execute.ExecIndexRow in project derby by apache.
the class DataDictionaryImpl method getAliasDescriptor.
/**
* Get a AliasDescriptor by alias name and name space.
* NOTE: caller responsible for handling no match.
*
* @param schemaId schema identifier
* @param aliasName The alias name.
* @param nameSpace The alias type.
*
* @return AliasDescriptor AliasDescriptor for the alias name and name space
*
* @exception StandardException Thrown on failure
*/
public AliasDescriptor getAliasDescriptor(String schemaId, String aliasName, char nameSpace) throws StandardException {
DataValueDescriptor aliasNameOrderable;
DataValueDescriptor nameSpaceOrderable;
TabInfoImpl ti = getNonCoreTI(SYSALIASES_CATALOG_NUM);
/* Use aliasNameOrderable and aliasTypeOrderable in both start
* and stop position for scan.
*/
aliasNameOrderable = new SQLVarchar(aliasName);
char[] charArray = new char[1];
charArray[0] = nameSpace;
nameSpaceOrderable = new SQLChar(new String(charArray));
/* Set up the start/stop position for the scan */
ExecIndexRow keyRow = exFactory.getIndexableRow(3);
keyRow.setColumn(1, new SQLChar(schemaId));
keyRow.setColumn(2, aliasNameOrderable);
keyRow.setColumn(3, nameSpaceOrderable);
return getDescriptorViaIndex(SYSALIASESRowFactory.SYSALIASES_INDEX1_ID, keyRow, (ScanQualifier[][]) null, ti, (TupleDescriptor) null, (List<TupleDescriptor>) null, AliasDescriptor.class, false);
}
Aggregations