if (definersRights) {
SanityManager.ASSERT(push);
}
}
SQLSessionContext sc = a.setupSQLSessionContextForChildren(push);
if (definersRights) {
sc.setUser(definer);
} else {
// A priori: invoker's rights: Current user
sc.setUser(getCurrentUserId(a));
}
if (definersRights) {
// No role a priori. Cf. SQL 2008, section 10.4 <routine
// invocation>, GR 5 j) i) 1) B) "If the external security
// characteristic of R is DEFINER, then the top cell of the
// authorization stack of RSC is set to contain only the routine
// authorization identifier of R.
sc.setRole(null);
} else {
// Semantics for roles dictate (SQL 4.34.1.1 and 4.27.3.) that the
// role is initially inherited from the current session context
// when we run with INVOKER security characteristic.
sc.setRole(getCurrentRoleId(a));
}
if (definersRights) {
SchemaDescriptor sd = getDataDictionary().getSchemaDescriptor(
definer,
getTransactionExecute(),
false);
if (sd == null) {
sd = new SchemaDescriptor(
getDataDictionary(), definer, definer, (UUID) null, false);
}
sc.setDefaultSchema(sd);
} else {
// Inherit current default schema. The initial value of the
// default schema is implementation defined. In Derby we
// inherit it when we invoke stored procedures and functions.
sc.setDefaultSchema(getDefaultSchema(a));
}
final SQLSessionContext ssc = getCurrentSQLSessionContext(a);
sc.setDeferredAll(ssc.getDeferredAll());
sc.setConstraintModes(ssc.getConstraintModes());
StatementContext stmctx = getStatementContext();
// Since the statement is an invocation (iff push=true), it will now be
// associated with the pushed SQLSessionContext (and no longer just