Top Description Methods
org.apache.derby.iapi.sql.conn

public Interface SQLSessionContext

Known Direct Implementers
org.apache.derby.impl.sql.conn.SQLSessionContextImpl
Imports
java.lang.String, java.util.HashMap, org.apache.derby.catalog.UUID, org.apache.derby.iapi.sql.dictionary.SchemaDescriptor

An implementation of this interface encapsulates some of the SQL session context's state variables, cf. SQL 2003, section 4.37.3, notably those which we need to save and restore when entering a stored procedure or function (which can contain SQL and thus a nested connection), cf. 4.37.3, 4.27.3 and 4.34.1.1.

Presently this set contains the following properties:

The standard specifies that the authorization stack be copied onto the new SQL session context before it is pushed (and possibly modifed) with a new cell for the authorization ids (user, role). In our implementation we merge these two stacks for now. Also, the authorization id of current user is not represented yet, since it can not be modified in a session; Derby can not run routines with definer's rights yet.

SQL session context is implemented as follows: Statements at root connection level use the instance held by the the lcc, nested connections maintain instances of SQLSessionContext, held by the activation of the calling statement. This forms a logical stack as required by the standard. The statement context also holds a reference to the current SQLSessionContext.

When a dynamic result set references e.g. current role, the value retrieved will always be that of the current role when the statement is logically executed (inside procedure/function), not the current value when the result set is accessed outside the stored procedure/function. This works since the nested SQL session context is kept by the caller activation, so even though the statement context of the call has been popped, we can get at the final state of the nested SQL session context since the caller's activation is alive as long as dynamic result sets need it).

If more than one nested connection is used inside a shared procedure, they will share the same nested SQL session context. Since the same dynamic call context is involved, this seems correct.

See Also
LanguageConnectionContext#pushNestedSessionContext

Method Summary

Modifier and TypeMethod and Description
public HashMap<UUID, Boolean>

Returns:

constraint modes map
getConstraintModes
()

Get a handle to the session's constraint modes.

public String
getCurrentUser()

Get the SQL current user of this SQL connection context

public SchemaDescriptor
getDefaultSchema()

Get the schema of this SQL connection context

public Boolean

Returns:

True is deferred all constraint mode has been set for this session context. False is deferred immediate has been set for this session context. null means no ALL setting has been made for this context
getDeferredAll
()

Get state of DEFERRED ALL setting.

public String
getRole()

Get the SQL role of this SQL connection context

public Boolean

Returns:

Boolean.TRUE if the constraint mode for this constraint/index has been set to deferred, Boolean.FALSE if it has been set to immediate.
isDeferred
(UUID
the constraint id
constraintId
)

Return Boolean.TRUE if the constraint mode for this constraint/index has been set to deferred, Boolean.FALSE if it has been set to immediate.

public void
resetConstraintModes()

Clear deferred information for this transaction.

public void
setConstraintModes(HashMap<UUID, Boolean>
constraint mode map
hm
)

Initialize a inferior session context with the constraint mode map of the parent session context.

public void
setDefaultSchema(SchemaDescriptor sd)

Set the schema of this SQL connection context

public void
setDeferred(UUID
The constraint id
constraintId
,
boolean
The new constraint mode
deferred
)

Set the constraint mode for this constraint to deferred.

public void
setDeferredAll(Boolean
the mode to set
deferred
)

Set the constraint mode for all deferrable constraints to deferred.

public void
setRole(String role)

Set the SQL role of this SQL connection context

public void
setUser(String user)

Set the SQL current user of this SQL connection context

Method Detail

getConstraintModesback to summary
public HashMap<UUID, Boolean> getConstraintModes()

Get a handle to the session's constraint modes. The caller is responsible for any cloning needed.

Returns:HashMap<UUID, Boolean>

constraint modes map

getCurrentUserback to summary
public String getCurrentUser()

Get the SQL current user of this SQL connection context

getDefaultSchemaback to summary
public SchemaDescriptor getDefaultSchema()

Get the schema of this SQL connection context

getDeferredAllback to summary
public Boolean getDeferredAll()

Get state of DEFERRED ALL setting.

Returns:Boolean

True is deferred all constraint mode has been set for this session context. False is deferred immediate has been set for this session context. null means no ALL setting has been made for this context

getRoleback to summary
public String getRole()

Get the SQL role of this SQL connection context

isDeferredback to summary
public Boolean isDeferred(UUID constraintId)

Return Boolean.TRUE if the constraint mode for this constraint/index has been set to deferred, Boolean.FALSE if it has been set to immediate. Any ALL setting is considered also. If the constraint mode hasn't been set for this constraint, return null. The constraint mode is the effectively the initial constraint mode in this case.

Parameters
constraintId:UUID

the constraint id

Returns:Boolean

Boolean.TRUE if the constraint mode for this constraint/index has been set to deferred, Boolean.FALSE if it has been set to immediate.

resetConstraintModesback to summary
public void resetConstraintModes()

Clear deferred information for this transaction.

setConstraintModesback to summary
public void setConstraintModes(HashMap<UUID, Boolean> hm)

Initialize a inferior session context with the constraint mode map of the parent session context.

Parameters
hm:HashMap<UUID, Boolean>

constraint mode map

setDefaultSchemaback to summary
public void setDefaultSchema(SchemaDescriptor sd)

Set the schema of this SQL connection context

setDeferredback to summary
public void setDeferred(UUID constraintId, boolean deferred)

Set the constraint mode for this constraint to deferred. If deferred is false, to immediate checking, if true to deferred checking.

Parameters
constraintId:UUID

The constraint id

deferred:boolean

The new constraint mode

setDeferredAllback to summary
public void setDeferredAll(Boolean deferred)

Set the constraint mode for all deferrable constraints to deferred. If deferred is false, set to immediate checking, if true to deferred checking. null is allowed: it means no ALL setting exists.

Parameters
deferred:Boolean

the mode to set

setRoleback to summary
public void setRole(String role)

Set the SQL role of this SQL connection context

setUserback to summary
public void setUser(String user)

Set the SQL current user of this SQL connection context