use of org.apache.derby.iapi.sql.Activation in project derby by apache.
the class GenericResultSetFactory method getUpdateVTIResultSet.
/**
* @see ResultSetFactory#getUpdateVTIResultSet
* @exception StandardException thrown on error
*/
public ResultSet getUpdateVTIResultSet(NoPutResultSet source) throws StandardException {
Activation activation = source.getActivation();
getAuthorizer(activation).authorize(activation, Authorizer.SQL_WRITE_OP);
return new UpdateVTIResultSet(source, activation);
}
use of org.apache.derby.iapi.sql.Activation in project derby by apache.
the class GenericResultSetFactory method getDeleteVTIResultSet.
/**
* @see ResultSetFactory#getDeleteVTIResultSet
* @exception StandardException thrown on error
*/
public ResultSet getDeleteVTIResultSet(NoPutResultSet source) throws StandardException {
Activation activation = source.getActivation();
getAuthorizer(activation).authorize(activation, Authorizer.SQL_WRITE_OP);
return new DeleteVTIResultSet(source, activation);
}
use of org.apache.derby.iapi.sql.Activation in project derby by apache.
the class TabInfoImpl method getRowChanger.
/**
* Gets a row changer for this catalog.
*
* @param tc transaction controller
* @param changedCols the columns to change (1 based), may be null
* @param baseRow used to detemine column types at creation time
* only. The row changer does ***Not*** keep a referance to
* this row or change it in any way.
*
* @return a row changer for this catalog.
* @exception StandardException Thrown on failure
*/
private RowChanger getRowChanger(TransactionController tc, int[] changedCols, ExecRow baseRow) throws StandardException {
RowChanger rc;
int indexCount = crf.getNumIndexes();
IndexRowGenerator[] irgs = new IndexRowGenerator[indexCount];
long[] cids = new long[indexCount];
if (SanityManager.DEBUG) {
if (changedCols != null) {
for (int i = changedCols.length - 1; i >= 0; i--) {
SanityManager.ASSERT(changedCols[i] != 0, "Column id is 0, but should be 1 based");
}
}
}
for (int ictr = 0; ictr < indexCount; ictr++) {
irgs[ictr] = getIndexRowGenerator(ictr);
cids[ictr] = getIndexConglomerate(ictr);
}
rc = crf.getExecutionFactory().getRowChanger(getHeapConglomerate(), (StaticCompiledOpenConglomInfo) null, (DynamicCompiledOpenConglomInfo) null, irgs, cids, (StaticCompiledOpenConglomInfo[]) null, (DynamicCompiledOpenConglomInfo[]) null, crf.getHeapColumnCount(), tc, changedCols, getStreamStorableHeapColIds(baseRow), (Activation) null);
return rc;
}
use of org.apache.derby.iapi.sql.Activation in project derby by apache.
the class MatchingClauseConstantAction method executeConstantAction.
public void executeConstantAction(Activation activation, TemporaryRowHolderImpl thenRows) throws StandardException {
// nothing to do if no rows qualified
if (thenRows == null) {
return;
}
CursorResultSet sourceRS = thenRows.getResultSet();
GeneratedMethod actionGM = ((BaseActivation) activation).getMethod(_actionMethodName);
//
try {
activation.pushConstantAction(_thenAction);
try {
//
// Poke the temporary table into the variable which will be pushed as
// an argument to the INSERT/UPDATE/DELETE action.
//
Field resultSetField = activation.getClass().getField(_resultSetFieldName);
resultSetField.set(activation, sourceRS);
Activation cursorActivation = sourceRS.getActivation();
//
// Now execute the generated method which creates an InsertResultSet,
// UpdateResultSet, or DeleteResultSet.
//
Method actionMethod = activation.getClass().getMethod(_actionMethodName);
_actionRS = (ResultSet) actionMethod.invoke(activation, null);
} catch (Exception e) {
throw StandardException.plainWrapException(e);
}
// this is where the INSERT/UPDATE/DELETE is processed
_actionRS.open();
} finally {
activation.popConstantAction();
}
}
use of org.apache.derby.iapi.sql.Activation in project derby by apache.
the class EmbedStatement method execute.
/**
* Execute a SQL statement that may return multiple results.
* Under some (uncommon) situations a single SQL statement may return
* multiple result sets and/or update counts. Normally you can ignore
* this, unless you're executing a stored procedure that you know may
* return multiple results, or unless you're dynamically executing an
* unknown SQL string. The "execute", "getMoreResults", "getResultSet"
* and "getUpdateCount" methods let you navigate through multiple results.
*
* The "execute" method executes a SQL statement and indicates the
* form of the first result. You can then use getResultSet or
* getUpdateCount to retrieve the result, and getMoreResults to
* move to any subsequent result(s).
*
* @param sql any SQL statement
* @param executeQuery caller is executeQuery()
* @param executeUpdate caller is executeUpdate()
* @param autoGeneratedKeys
* @param columnIndexes
* @param columnNames
*
* @return true if the first result is a ResultSet; false if it is an integer
* @see #getResultSet
* @see #getUpdateCount
* @see #getMoreResults
* @exception SQLException thrown on failure
*/
private boolean execute(String sql, boolean executeQuery, boolean executeUpdate, int autoGeneratedKeys, int[] columnIndexes, String[] columnNames) throws SQLException {
synchronized (getConnectionSynchronization()) {
checkExecStatus();
if (sql == null) {
throw newSQLException(SQLState.NULL_SQL_TEXT);
}
checkIfInMiddleOfBatch();
// release the last statement executed, if any.
clearResultSets();
// make sure there's context
setupContextStack();
// try to remember the SQL statement in case anybody asks for it
SQLText = sql;
try {
Activation activation;
try {
PreparedStatement preparedStatement = lcc.prepareInternalStatement(lcc.getDefaultSchema(), sql, resultSetConcurrency == java.sql.ResultSet.CONCUR_READ_ONLY, false);
activation = preparedStatement.getActivation(lcc, resultSetType == java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE);
checkRequiresCallableStatement(activation);
InterruptStatus.restoreIntrFlagIfSeen(lcc);
} catch (Throwable t) {
throw handleException(t);
}
// this is for a Statement execution
activation.setSingleExecution();
// information in lcc will not work work it can be tampered by a nested trasaction
if (autoGeneratedKeys == Statement.RETURN_GENERATED_KEYS) {
activation.setAutoGeneratedKeysResultsetInfo(columnIndexes, columnNames);
}
return executeStatement(activation, executeQuery, executeUpdate);
} finally {
restoreContextStack();
}
}
}
Aggregations