org.apache.derby.impl.sql.conn
Class GenericLanguageConnectionContext

java.lang.Object
  extended byorg.apache.derby.iapi.services.context.ContextImpl
      extended byorg.apache.derby.impl.sql.conn.GenericLanguageConnectionContext
All Implemented Interfaces:
Context, LanguageConnectionContext

public class GenericLanguageConnectionContext
extends ContextImpl
implements LanguageConnectionContext

LanguageConnectionContext keeps the pool of prepared statements, activations, and cursors in use by the current connection.

The generic impl does not provide statement caching.

Author:
ames

Field Summary
private  java.util.Vector acts
           
protected  AccessFactory af
           
private  java.util.ArrayList allDeclaredGlobalTempTables
           
protected  Authorizer authorizer
           
private  java.util.Hashtable autoincrementCacheHashtable
           
private  java.util.Hashtable autoincrementHT
          To support lastAutoincrementValue: This is a hashtable which maps schemaName,tableName,columnName to a Long value.
private  boolean autoincrementUpdate
          whether to allow updates or not.
protected  int bindCount
           
protected  TransactionController childTransaction
          If non-null indicates that a nested user transaction is in progress.
protected  LanguageConnectionFactory connFactory
           
private  int currentSavepointLevel
           
protected  DataValueFactory dataFactory
           
private  Database db
           
private  java.lang.String dbname
           
private  boolean ddWriteMode
           
private  int defaultIsolationLevel
           
private  java.lang.String drdaID
           
private  int identifierCasing
           
private  boolean identityNotNull
           
private  long identityVal
           
private  int instanceNumber
           
protected  int isolationLevel
           
private  boolean isolationLevelExplicitlySet
           
private  HeaderPrintWriter istream
           
protected  LanguageFactory langFactory
           
private  java.lang.String lastOptimizerTraceOutput
           
private  int lockEscalationThreshold
           
private  boolean logQueryPlan
           
private  boolean logStatementText
           
protected  long nextCursorId
           
protected  int nextSavepointId
           
private static int NON_XA
           
protected  OptimizerFactory of
           
private  boolean optimizerTrace
           
private  boolean optimizerTraceHtml
           
private  java.lang.String optimizerTraceOutput
           
protected  int outermostTrigger
           
protected  int prepareIsolationLevel
           
protected  int queryNestingDepth
          queryNestingDepth is a counter used to keep track of how many calls have been made to begin nested transactions.
private  RunTimeStatistics runTimeStatisticsObject
           
private  boolean runTimeStatisticsSetting
           
private  java.lang.StringBuffer sb
           
protected  SchemaDescriptor sd
           
 CacheManager statementCache
           
protected  StatementContext[] statementContexts
           
protected  int statementDepth
           
private  boolean statisticsTiming
           
private  java.util.Vector stmtValidators
           
protected  TypeCompilerFactory tcf
           
protected  TransactionController tran
          The transaction to use within this language connection context.
private  java.util.Vector triggerExecutionContexts
           
private  java.util.Vector triggerTables
           
protected  java.lang.String userName
           
private static int XA_ONE_PHASE
           
private static int XA_TWO_PHASE
           
 
Fields inherited from class org.apache.derby.iapi.services.context.ContextImpl
 
Fields inherited from interface org.apache.derby.iapi.sql.conn.LanguageConnectionContext
ANSI_CASING, ANTI_ANSI_CASING, CONTEXT_ID, dbnameStr, drdaStr, lccStr, MULTI_TRANSACTION_LOCK, NO_SCHEMAS, OUTERMOST_STATEMENT, SINGLE_TRANSACTION_LOCK, SQL92_SCHEMAS, UNKNOWN_CASING, USER_NAME_SCHEMA, xidStr
 
Constructor Summary
GenericLanguageConnectionContext(ContextManager cm, TransactionController tranCtrl, LanguageFactory lf, LanguageConnectionFactory lcf, Database db, java.lang.String userName, int instanceNumber, java.lang.String drdaID, java.lang.String dbname)
           
 
Method Summary
 void addActivation(Activation a)
          Add the activation to those known about by this connection.
 void addDeclaredGlobalTempTable(TableDescriptor td)
          Add the declared global temporary table to the list of temporary tables known by this connection.
 boolean anyoneBlocked()
          Return true if any transaction is blocked, even if not by this one
 java.lang.StringBuffer appendErrorInfo()
           
 void appendOptimizerTraceOutput(java.lang.String output)
          Append the latest output to the optimizer trace output.
 void autoincrementCreateCounter(java.lang.String s, java.lang.String t, java.lang.String c, java.lang.Long initialValue, long increment, int position)
          Create an autoincrement counter to be used on behalf of a SQL-J statement.
 void autoincrementFlushCache(UUID tableUUID)
          Flush the cache of autoincrement values being kept by the lcc.
 void beginNestedTransaction(boolean readOnly)
          Start a Nested User Transaction (NUT) with the store.
private  boolean checkIfAnyActivationHasHoldCursor(java.lang.String tableName)
          check if there are any activations that reference this temporary table
 boolean checkIfAnyDeclaredGlobalTempTablesForThisConnection()
          Check if there are any global temporary tables declared for this connection.
 void cleanupOnError(java.lang.Throwable error)
          If worse than a transaction error, everything goes; we rely on other contexts to kill the context manager for this session.
private  TableDescriptor cleanupTempTableOnCommitOrRollback(TableDescriptor td, boolean dropAndRedeclare)
          If dropAndRedeclare is true, that means we have come here for temp tables with on commit delete rows and no held curosr open on them.
 void commitNestedTransaction()
          commit a nested transaction.
 java.lang.String convertIdentifierCase(java.lang.String id)
          Convert an identifier to the proper case for this connection.
 void copyHashtableToAIHT(java.util.Hashtable from)
          Copies an existing hashtable of autoincrement mappings into autoincrementHT, the cache of autoincrement values kept in the languageconnectioncontext.
 boolean dataDictionaryInWriteMode()
          Return true if the data dictionary is in write mode (that is, this context was informed that is is in write mode by the method call setDataDictionaryWriteMode().
 int decrementBindCount()
          Decrement the DataDictionary bind count.
private  void decrementStatementDepth()
          Decrements the statement depth
protected  void doCommit(boolean commitStore, boolean sync, int commitflag, boolean requestedByUser)
          This is where the work on internalCommit(), userCOmmit() and internalCommitNoSync() actually takes place.
private  void doRollback(boolean xa, boolean requestedByUser)
          When a rollback happens, the language connection context will close all open activations and invalidate their prepared statements.
 void dropAllDeclaredGlobalTempTables()
          Drop all the declared global temporary tables associated with this connection.
 boolean dropDeclaredGlobalTempTable(java.lang.String tableName)
          Drop (mark the declared global temporary table for dropping) from the list of temporary tables known by this connection.
 void emptyCache()
          Empty as much of the cache as possible.
private  TempTableInfo findDeclaredGlobalTempTable(java.lang.String tableName)
          Find the declared global temporary table in the list of temporary tables known by this connection.
private  void finishDDTransaction()
          Finish the data dictionary transaction, if any.
 AccessFactory getAccessFactory()
          Get the AccessFactory cached in this LanguageConnectionContext
 int getActivationCount()
          Return the number of activations known for this connection.
 java.lang.String getAuthorizationId()
          Get the Authorization Id
protected  java.lang.String getAuthorizationId(java.lang.String userName)
          Set the authorization identifier for this user.
 Authorizer getAuthorizer()
          Get an Authorizer for this connection.
 boolean getAutoincrementUpdate()
          Returns the current value of autoincrementUpdate.
 int getBindCount()
          Get the DataDictionary bind count.
 int getCacheSize()
           
 int getCurrentIsolationLevel()
          Get the current isolation level.
 java.lang.String getCurrentIsolationLevelStr()
          Get the current isolation level in DB2 format.
 java.lang.String getCurrentSchemaName()
          Get the current schema name
 Database getDatabase()
          Returns the Database of this connection.
 DataDictionary getDataDictionary()
          Get the data dictionary
 DataValueFactory getDataValueFactory()
          Get the data value factory to use with this language connection context.
 java.lang.String getDbname()
          Get the database name of this LCC.
 java.lang.String getDeclaredGlobalTemporaryTablesSchemaName()
          Get the declared global temporary tables schema name.
 SchemaDescriptor getDefaultSchema()
          Get the default schema
 java.lang.String getDrdaID()
          Get the DRDA ID of this LCC.
 ExecutionContext getExecutionContext()
          Get the current ExecutionContext.
 int getIdentifierCasing()
          Get casing for delimited identifiers.
 java.math.BigDecimal getIdentityValue()
          Get the identity column value most recently generated.
 int getInstanceNumber()
          Get the instance number of this LCC.
 LanguageConnectionFactory getLanguageConnectionFactory()
          Get the language connection factory to use with this language connection context.
 LanguageFactory getLanguageFactory()
          Get the language factory to use with this language connection context.
 Activation getLastActivation()
          Return the last activation added This is used to find the drop activation in dropViewCascade so we can add warning messages to the activation
 int getLockEscalationThreshold()
          get the lock escalation threshold.
 java.lang.Object getLockObject(int lockScope)
          Get the lock handle for the current transaction.
 boolean getLogQueryPlan()
          Get value of logQueryPlan.
 boolean getLogStatementText()
          Get value of logStatementText.
private  java.lang.String getNameString(java.lang.String prefix, long number)
          Build a String for a statement name.
 OptimizerFactory getOptimizerFactory()
          get the optimizer factory to use with this language connection context.
 boolean getOptimizerTrace()
          Get whether or not optimizer trace is on.
 boolean getOptimizerTraceHtml()
          Get whether or not optimizer trace html is on.
 java.lang.String getOptimizerTraceOutput()
          Get the optimizer trace output for the last optimized query as a String.
 int getPrepareIsolationLevel()
          Get the prepare isolation level.
 boolean getRunTimeStatisticsMode()
          Get the RUNTIMESTATISTICS mode.
 RunTimeStatistics getRunTimeStatisticsObject()
          Get the RUNTIMESTATISTICS object.
 StatementContext getStatementContext()
          Get the current StatementContext.
 int getStatementDepth()
          Reports how many statement levels deep we are.
 boolean getStatisticsTiming()
          Get the STATISTICS TIMING mode.
 java.lang.String getSysIBMSchemaName()
          Get the name of the SYSIBM schema.
 java.lang.String getSystemDiagSchemaName()
          Get the name of the SYSCS_DIAG schema.
 java.lang.String getSystemSchemaName()
          Get the name of the system schema.
 java.lang.String getSystemUtilSchemaName()
          Get the name of the SYSCS_UTIL schema.
 TableDescriptor getTableDescriptorForDeclaredGlobalTempTable(java.lang.String tableName)
          Get table descriptor for the declared global temporary table from the list of temporary tables known by this connection.
 TransactionController getTransactionCompile()
          Get the transaction controller to use at compile time with this language connection context.
 TransactionController getTransactionExecute()
          Get the transaction controller to use with this language connection context during execute time.
 TriggerExecutionContext getTriggerExecutionContext()
          Get the topmost tec.
 TableDescriptor getTriggerTable()
          Get the topmost trigger table descriptor
 java.lang.String getUniqueCursorName()
          Get a connection unique system generated name for a cursor.
 int getUniqueSavepointID()
          Get a connection unique system generated id for an unnamed savepoint.
 java.lang.String getUniqueSavepointName()
          Get a connection unique system generated name for an unnamed savepoint.
 int incrementBindCount()
          Increment the DataDictionary bind count.
private  void incrementStatementDepth()
          Increments the statement depth.
protected  SchemaDescriptor initDefaultSchemaDescriptor()
           
 void initialize(boolean sqlConnection)
          Initialize.
 void internalCommit(boolean commitStore)
          Do a commit as appropriate for an internally generated commit (e.g. as needed by sync, or autocommit).
 void internalCommitNoSync(int commitflag)
          Commit the language transaction by doing a commitNoSync() on the store's TransactionController.
 void internalRollback()
          Do a rollback as appropriate for an internally generated rollback (e.g. as needed by sync, or autocommit).
 void internalRollbackToSavepoint(java.lang.String savepointName, boolean refreshStyle, java.lang.Object kindOfSavepoint)
          Let the context deal with a rollback to savepoint
 boolean isLastHandler(int severity)
          Return whether or not this context is the "last" handler for a the specified severity level.
 boolean isReadOnly()
          Get the readOnly status for the current connection.
 boolean isTransactionPristine()
          Reports whether there is any outstanding work in the transaction.
 void languageSetSavePoint(java.lang.String savepointName, java.lang.Object kindOfSavepoint)
          Sets a savepoint.
 java.lang.Long lastAutoincrementValue(java.lang.String schemaName, java.lang.String tableName, java.lang.String columnName)
          Implements ConnectionInfo.lastAutoincrementValue.
 CursorActivation lookupCursorActivation(java.lang.String cursorName)
          See if a given cursor is available for use.
 PreparedStatement lookupStatement(GenericStatement statement)
          See if a given statement has already been compiled for this user, and if so use its prepared statement.
 void markTempTableAsModifiedInUnitOfWork(java.lang.String tableName)
          Mark the passed temporary table as modified in the current unit of work.
 long nextAutoincrementValue(java.lang.String schemaName, java.lang.String tableName, java.lang.String columnName)
          returns the next value to be inserted into an autoincrement col.
 void popCompilerContext(CompilerContext cc)
          Pop a CompilerContext off the context stack.
 void popExecutionStmtValidator(ExecutionStmtValidator validator)
          Remove the validator.
 void popStatementContext(StatementContext statementContext, java.lang.Throwable error)
          Pop a StatementContext of the context stack.
 void popTriggerExecutionContext(TriggerExecutionContext tec)
          Remove the tec.
 void popTriggerTable(TableDescriptor td)
          Remove the trigger table descriptor.
 PreparedStatement prepareInternalStatement(SchemaDescriptor compilationSchema, java.lang.String sqlText)
           
 PreparedStatement prepareInternalStatement(java.lang.String sqlText)
          Return a Statement object to compile a Statement.
 CompilerContext pushCompilerContext()
          Push a CompilerContext on the context stack with the current default schema as the default schema which we compile against.
 CompilerContext pushCompilerContext(SchemaDescriptor sd)
          Push a CompilerContext on the context stack with the passed in default schema as the default schema we compile against.
 void pushExecutionStmtValidator(ExecutionStmtValidator validator)
          Push a new execution statement validator.
 StatementContext pushStatementContext(boolean isAtomic, java.lang.String stmtText, ParameterValueSet pvs, boolean rollbackParentContext)
          Push a StatementContext on the context stack.
 void pushTriggerExecutionContext(TriggerExecutionContext tec)
          Push a new trigger execution context.
 void pushTriggerTable(TableDescriptor td)
          Set the trigger table descriptor.
 void releaseSavePoint(java.lang.String savepointName, java.lang.Object kindOfSavepoint)
          Let the context deal with a release of a savepoint
 void removeActivation(Activation a)
          Remove the activation to those known about by this connection.
 void removeStatement(Statement statement)
          This method will get called if the statement is referencing tables in SESSION schema.
private  void replaceDeclaredGlobalTempTable(java.lang.String tableName, TableDescriptor td)
          This is called at the commit time for temporary tables with ON COMMIT DELETE ROWS If a temp table with ON COMMIT DELETE ROWS doesn't have any held cursor open on them, we delete the data from them by dropping the conglomerate and recreating the conglomerate.
private  void resetActivations(boolean andClose)
          resets all open activations, to close their result sets.
private  void resetSavepoints(StatementContext statementContext)
           
protected  void resetStatementDepth()
          Resets the statementDepth.
 void setAutoincrementUpdate(boolean flag)
          Sets autoincrementUpdate-- this variable allows updates to autoincrement columns if it is set to true.
 void setDataDictionaryWriteMode()
          Remember that the DataDictionary is in write mode, so we can take it out of write mode at the end of the transaction.
 void setDefaultSchema(SchemaDescriptor sd)
          Set the default schema -- used by SET SCHEMA.
 void setDrdaID(java.lang.String drdaID)
          Set the DRDA ID of this LCC.
 void setIdentityValue(long val)
          Set the field of most recently generated identity column value.
 void setIsolationLevel(int isolationLevel)
          Set current isolation level.
 void setLogStatementText(boolean logStatementText)
          Set value of logStatementText (Whether or not to write info on currently executing statement to error log.)
 boolean setOptimizerTrace(boolean onOrOff)
          Control whether or not optimizer trace is on.
 boolean setOptimizerTraceHtml(boolean onOrOff)
          Control whether or not optimizer trace is generated in html.
 void setOptimizerTraceOutput(java.lang.String startingText)
          Set the optimizer trace output to the specified String.
 void setPrepareIsolationLevel(int level)
           
 void setReadOnly(boolean on)
          Set the readOnly status for the current connection.
 void setRunTimeStatisticsMode(boolean onOrOff)
          Turn RUNTIMESTATISTICS on or off.
 void setRunTimeStatisticsObject(RunTimeStatistics runTimeStatisticsObject)
          Set the RUNTIMESTATISTICS object.
 void setStatisticsTiming(boolean onOrOff)
          Turn STATISTICS TIMING on or off.
 void setTransaction(TransactionController tran)
          Sets the transaction controller to use with this language connection context.
private  void tempTablesAndCommit()
          do the necessary work at commit time for temporary tables 1)If a temporary table was marked as dropped in this transaction, then remove it from the list of temp tables for this connection 2)If a temporary table was not dropped in this transaction, then mark it's declared savepoint level and modified savepoint level as -1
private  void tempTablesAndRollback()
          do the necessary work at rollback time for temporary tables 1)If a temp table was declared in the UOW, then drop it and remove it from list of temporary tables. 2)If a temp table was declared and dropped in the UOW, then remove it from list of temporary tables. 3)If an existing temp table was dropped in the UOW, then recreate it with no data. 4)If an existing temp table was modified in the UOW, then get rid of all the rows from the table.
private  void tempTablesReleaseSavepointLevels()
          After a release of a savepoint, we need to go through our temp tables list.
 void userCommit()
          Do a commmit as is appropriate for a user requested commit (e.g. a java.sql.Connection.commit() or a language 'COMMIT' statement.
 void userRollback()
          Do a rollback as is appropriate for a user requested rollback (e.g. a java.sql.Connection.rollback() or a language 'ROLLBACk' statement.
 void validateStmtExecution(ConstantAction constantAction)
          Validate a statement.
 boolean verifyAllHeldResultSetsAreClosed()
          Verify that there are no activations with open held result sets.
 boolean verifyNoOpenResultSets(PreparedStatement pStmt, Provider provider, int action)
          Verify that there are no activations with open result sets on the specified prepared statement.
 void xaCommit(boolean onePhase)
          Same as userCommit except commit a distributed transaction.
 void xaRollback()
          Same as userRollback() except rolls back a distrubuted transaction.
 
Methods inherited from class org.apache.derby.iapi.services.context.ContextImpl
getContextManager, getIdName, popMe, pushMe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.derby.iapi.services.context.Context
getContextManager, getIdName, popMe, pushMe
 

Field Detail

NON_XA

private static final int NON_XA
See Also:
Constant Field Values

XA_ONE_PHASE

private static final int XA_ONE_PHASE
See Also:
Constant Field Values

XA_TWO_PHASE

private static final int XA_TWO_PHASE
See Also:
Constant Field Values

acts

private final java.util.Vector acts

bindCount

protected int bindCount

ddWriteMode

private boolean ddWriteMode

runTimeStatisticsSetting

private boolean runTimeStatisticsSetting

statisticsTiming

private boolean statisticsTiming

allDeclaredGlobalTempTables

private java.util.ArrayList allDeclaredGlobalTempTables

currentSavepointLevel

private int currentSavepointLevel

nextCursorId

protected long nextCursorId

nextSavepointId

protected int nextSavepointId

runTimeStatisticsObject

private RunTimeStatistics runTimeStatisticsObject

sb

private java.lang.StringBuffer sb

db

private Database db

instanceNumber

private final int instanceNumber

drdaID

private java.lang.String drdaID

dbname

private java.lang.String dbname

identifierCasing

private int identifierCasing

tran

protected TransactionController tran
The transaction to use within this language connection context. It may be more appropriate to have it in a separate context (LanguageTransactionContext?). REVISIT (nat): I shoehorned the transaction context that the language uses into this class. The main purpose is so that the various language code can find out what its transaction is.


childTransaction

protected TransactionController childTransaction
If non-null indicates that a nested user transaction is in progress.


queryNestingDepth

protected int queryNestingDepth
queryNestingDepth is a counter used to keep track of how many calls have been made to begin nested transactions. Only the first call actually starts a Nested User Transaction with the store. Subsequent calls simply increment this counter. commitNestedTransaction only decrements the counter and when it drops to 0 actually commits the nested user transaction.


dataFactory

protected DataValueFactory dataFactory

langFactory

protected LanguageFactory langFactory

tcf

protected TypeCompilerFactory tcf

of

protected OptimizerFactory of

connFactory

protected LanguageConnectionFactory connFactory

statementContexts

protected StatementContext[] statementContexts

statementDepth

protected int statementDepth

outermostTrigger

protected int outermostTrigger

authorizer

protected Authorizer authorizer

userName

protected java.lang.String userName

sd

protected SchemaDescriptor sd

defaultIsolationLevel

private int defaultIsolationLevel

isolationLevel

protected int isolationLevel

isolationLevelExplicitlySet

private boolean isolationLevelExplicitlySet

prepareIsolationLevel

protected int prepareIsolationLevel

logStatementText

private boolean logStatementText

logQueryPlan

private boolean logQueryPlan

istream

private HeaderPrintWriter istream

lockEscalationThreshold

private int lockEscalationThreshold

stmtValidators

private java.util.Vector stmtValidators

triggerExecutionContexts

private java.util.Vector triggerExecutionContexts

triggerTables

private java.util.Vector triggerTables

af

protected AccessFactory af

optimizerTrace

private boolean optimizerTrace

optimizerTraceHtml

private boolean optimizerTraceHtml

lastOptimizerTraceOutput

private java.lang.String lastOptimizerTraceOutput

optimizerTraceOutput

private java.lang.String optimizerTraceOutput

autoincrementHT

private java.util.Hashtable autoincrementHT
To support lastAutoincrementValue: This is a hashtable which maps schemaName,tableName,columnName to a Long value.


autoincrementUpdate

private boolean autoincrementUpdate
whether to allow updates or not.


identityVal

private long identityVal

identityNotNull

private boolean identityNotNull

autoincrementCacheHashtable

private java.util.Hashtable autoincrementCacheHashtable

statementCache

public CacheManager statementCache
Constructor Detail

GenericLanguageConnectionContext

public GenericLanguageConnectionContext(ContextManager cm,
                                        TransactionController tranCtrl,
                                        LanguageFactory lf,
                                        LanguageConnectionFactory lcf,
                                        Database db,
                                        java.lang.String userName,
                                        int instanceNumber,
                                        java.lang.String drdaID,
                                        java.lang.String dbname)
                                 throws StandardException
Method Detail

initialize

public void initialize(boolean sqlConnection)
                throws StandardException
Description copied from interface: LanguageConnectionContext
Initialize. For use after pushing the contexts that initialization needs.

Specified by:
initialize in interface LanguageConnectionContext
Parameters:
sqlConnection - Whether or not this is called from a sql connection.
Throws:
StandardException - thrown if something goes wrong

initDefaultSchemaDescriptor

protected SchemaDescriptor initDefaultSchemaDescriptor()
                                                throws StandardException
Throws:
StandardException

getLogStatementText

public boolean getLogStatementText()
Description copied from interface: LanguageConnectionContext
Get value of logStatementText. (Whether or not to write info on currently executing statement to error log.)

Specified by:
getLogStatementText in interface LanguageConnectionContext
Returns:
value of logStatementText
See Also:
LanguageConnectionContext.getLogStatementText()

setLogStatementText

public void setLogStatementText(boolean logStatementText)
Description copied from interface: LanguageConnectionContext
Set value of logStatementText (Whether or not to write info on currently executing statement to error log.)

Specified by:
setLogStatementText in interface LanguageConnectionContext
Parameters:
logStatementText - Whether or not logStatementText property is set.
Returns:
Nothing.
See Also:
LanguageConnectionContext.setLogStatementText(boolean)

getLogQueryPlan

public boolean getLogQueryPlan()
Description copied from interface: LanguageConnectionContext
Get value of logQueryPlan. (Whether or not to write query plan info on currently executing statement to error log.)

Specified by:
getLogQueryPlan in interface LanguageConnectionContext
Returns:
value of logQueryPlan
See Also:
LanguageConnectionContext.getLogQueryPlan()

getLockEscalationThreshold

public int getLockEscalationThreshold()
get the lock escalation threshold.

Specified by:
getLockEscalationThreshold in interface LanguageConnectionContext

getCacheSize

public int getCacheSize()

addActivation

public void addActivation(Activation a)
Add the activation to those known about by this connection.

Specified by:
addActivation in interface LanguageConnectionContext

checkIfAnyDeclaredGlobalTempTablesForThisConnection

public boolean checkIfAnyDeclaredGlobalTempTablesForThisConnection()
Description copied from interface: LanguageConnectionContext
Check if there are any global temporary tables declared for this connection.

Specified by:
checkIfAnyDeclaredGlobalTempTablesForThisConnection in interface LanguageConnectionContext
Returns:
true if there are declared temp tables for this connectoin else false
See Also:
LanguageConnectionContext.checkIfAnyDeclaredGlobalTempTablesForThisConnection()

addDeclaredGlobalTempTable

public void addDeclaredGlobalTempTable(TableDescriptor td)
                                throws StandardException
Description copied from interface: LanguageConnectionContext
Add the declared global temporary table to the list of temporary tables known by this connection.

Specified by:
addDeclaredGlobalTempTable in interface LanguageConnectionContext
Throws:
StandardException
See Also:
LanguageConnectionContext.addDeclaredGlobalTempTable(org.apache.derby.iapi.sql.dictionary.TableDescriptor)

dropDeclaredGlobalTempTable

public boolean dropDeclaredGlobalTempTable(java.lang.String tableName)
Description copied from interface: LanguageConnectionContext
Drop (mark the declared global temporary table for dropping) from the list of temporary tables known by this connection.

Specified by:
dropDeclaredGlobalTempTable in interface LanguageConnectionContext
Returns:
true if dropped the temporary table. False if no such temporary table exists.
See Also:
LanguageConnectionContext.dropDeclaredGlobalTempTable(java.lang.String)

tempTablesReleaseSavepointLevels

private void tempTablesReleaseSavepointLevels()
After a release of a savepoint, we need to go through our temp tables list. If there are tables with their declare or drop or modified in savepoint levels set to savepoint levels higher than the current savepoint level, then we should change them to the current savepoint level


tempTablesAndCommit

private void tempTablesAndCommit()
do the necessary work at commit time for temporary tables 1)If a temporary table was marked as dropped in this transaction, then remove it from the list of temp tables for this connection 2)If a temporary table was not dropped in this transaction, then mark it's declared savepoint level and modified savepoint level as -1


dropAllDeclaredGlobalTempTables

public void dropAllDeclaredGlobalTempTables()
                                     throws StandardException
Description copied from interface: LanguageConnectionContext
Drop all the declared global temporary tables associated with this connection. This gets called when a getConnection() is done on a PooledConnection. This will ensure all the temporary tables declared on earlier connection handle associated with this physical database connection are dropped before a new connection handle is issued on that same physical database connection.

Specified by:
dropAllDeclaredGlobalTempTables in interface LanguageConnectionContext
Throws:
StandardException
See Also:
LanguageConnectionContext.dropAllDeclaredGlobalTempTables()

tempTablesAndRollback

private void tempTablesAndRollback()
                            throws StandardException
do the necessary work at rollback time for temporary tables 1)If a temp table was declared in the UOW, then drop it and remove it from list of temporary tables. 2)If a temp table was declared and dropped in the UOW, then remove it from list of temporary tables. 3)If an existing temp table was dropped in the UOW, then recreate it with no data. 4)If an existing temp table was modified in the UOW, then get rid of all the rows from the table.

Throws:
StandardException

replaceDeclaredGlobalTempTable

private void replaceDeclaredGlobalTempTable(java.lang.String tableName,
                                            TableDescriptor td)
This is called at the commit time for temporary tables with ON COMMIT DELETE ROWS If a temp table with ON COMMIT DELETE ROWS doesn't have any held cursor open on them, we delete the data from them by dropping the conglomerate and recreating the conglomerate. In order to store the new conglomerate information for the temp table, we need to replace the existing table descriptor with the new table descriptor which has the new conglomerate information


getTableDescriptorForDeclaredGlobalTempTable

public TableDescriptor getTableDescriptorForDeclaredGlobalTempTable(java.lang.String tableName)
Description copied from interface: LanguageConnectionContext
Get table descriptor for the declared global temporary table from the list of temporary tables known by this connection.

Specified by:
getTableDescriptorForDeclaredGlobalTempTable in interface LanguageConnectionContext
Returns:
TableDescriptor if found the temporary table. Else return null
See Also:
LanguageConnectionContext.getTableDescriptorForDeclaredGlobalTempTable(java.lang.String)

findDeclaredGlobalTempTable

private TempTableInfo findDeclaredGlobalTempTable(java.lang.String tableName)
Find the declared global temporary table in the list of temporary tables known by this connection.

Returns:
data structure defining the temporary table if found. Else, return null

markTempTableAsModifiedInUnitOfWork

public void markTempTableAsModifiedInUnitOfWork(java.lang.String tableName)
Description copied from interface: LanguageConnectionContext
Mark the passed temporary table as modified in the current unit of work. That information will be used at rollback time The compile phase will generate code to call this method if the DML is on a temporary table

Specified by:
markTempTableAsModifiedInUnitOfWork in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.markTempTableAsModifiedInUnitOfWork(java.lang.String)

prepareInternalStatement

public PreparedStatement prepareInternalStatement(java.lang.String sqlText)
                                           throws StandardException
Return a Statement object to compile a Statement. The schema setting fo the returned statement are that of this connection.

Specified by:
prepareInternalStatement in interface LanguageConnectionContext
Throws:
StandardException

prepareInternalStatement

public PreparedStatement prepareInternalStatement(SchemaDescriptor compilationSchema,
                                                  java.lang.String sqlText)
                                           throws StandardException
Specified by:
prepareInternalStatement in interface LanguageConnectionContext
Throws:
StandardException

removeActivation

public void removeActivation(Activation a)
Remove the activation to those known about by this connection.

Specified by:
removeActivation in interface LanguageConnectionContext

getActivationCount

public int getActivationCount()
Return the number of activations known for this connection. Note that some of these activations may not be in use (when a prepared statement is finalized, its activations are marked as unused and later closed and removed on the next commit/rollback).

Specified by:
getActivationCount in interface LanguageConnectionContext

lookupCursorActivation

public CursorActivation lookupCursorActivation(java.lang.String cursorName)
See if a given cursor is available for use. if so return its activation. Returns null if not found. For use in execution.

Specified by:
lookupCursorActivation in interface LanguageConnectionContext
Returns:
the activation for the given cursor, null if none was found.

removeStatement

public void removeStatement(Statement statement)
                     throws StandardException
This method will get called if the statement is referencing tables in SESSION schema. We do not want to cache such statements because multiple connections can have different definition of the same table name and hence compiled plan for one connection may not make sense for some other connection. Because of this, remove the statement from the cache

Throws:
StandardException - thrown if lookup goes wrong.

lookupStatement

public PreparedStatement lookupStatement(GenericStatement statement)
                                  throws StandardException
See if a given statement has already been compiled for this user, and if so use its prepared statement. Returns null if not found.

Returns:
the prepared statement for the given string, null if none was found.
Throws:
StandardException - thrown if lookup goes wrong.

getUniqueCursorName

public java.lang.String getUniqueCursorName()
Get a connection unique system generated name for a cursor.

Specified by:
getUniqueCursorName in interface LanguageConnectionContext

getUniqueSavepointName

public java.lang.String getUniqueSavepointName()
Get a connection unique system generated name for an unnamed savepoint.

Specified by:
getUniqueSavepointName in interface LanguageConnectionContext

getUniqueSavepointID

public int getUniqueSavepointID()
Get a connection unique system generated id for an unnamed savepoint.

Specified by:
getUniqueSavepointID in interface LanguageConnectionContext

getNameString

private java.lang.String getNameString(java.lang.String prefix,
                                       long number)
Build a String for a statement name.

Parameters:
prefix - The prefix for the statement name.
number - The number to append for uniqueness
Returns:
A unique String for a statement name.

internalCommit

public void internalCommit(boolean commitStore)
                    throws StandardException
Do a commit as appropriate for an internally generated commit (e.g. as needed by sync, or autocommit).

Specified by:
internalCommit in interface LanguageConnectionContext
Parameters:
commitStore - true if we should commit the Store transaction
Returns:
the commit instant
Throws:
StandardException - thrown on failure

userCommit

public void userCommit()
                throws StandardException
Do a commmit as is appropriate for a user requested commit (e.g. a java.sql.Connection.commit() or a language 'COMMIT' statement. Does some extra checking to make sure that users aren't doing anything bad.

Specified by:
userCommit in interface LanguageConnectionContext
Returns:
the commit instant
Throws:
StandardException - thrown on failure

internalCommitNoSync

public final void internalCommitNoSync(int commitflag)
                                throws StandardException
Commit the language transaction by doing a commitNoSync() on the store's TransactionController.

Do *NOT* tell the data dictionary that the transaction is finished. The reason is that this would allow other transactions to see comitted DDL that could be undone in the event of a system crash.

Specified by:
internalCommitNoSync in interface LanguageConnectionContext
Parameters:
commitflag - the flags to pass to commitNoSync in the store's TransactionController
Returns:
the commit instant
Throws:
StandardException - thrown on failure

xaCommit

public final void xaCommit(boolean onePhase)
                    throws StandardException
Same as userCommit except commit a distributed transaction. This commit always commit store and sync the commit.

Specified by:
xaCommit in interface LanguageConnectionContext
Parameters:
onePhase - if true, allow it to commit without first going thru a prepared state.
Returns:
the commit instant
Throws:
StandardException - thrown if something goes wrong

doCommit

protected void doCommit(boolean commitStore,
                        boolean sync,
                        int commitflag,
                        boolean requestedByUser)
                 throws StandardException
This is where the work on internalCommit(), userCOmmit() and internalCommitNoSync() actually takes place.

When a commit happens, the language connection context will close all open activations/cursors and commit the Store transaction.

REVISIT: we talked about having a LanguageTransactionContext, but since store transaction management is currently in flux and our context might want to delegate to that context, for now all commit/rollback actions are handled directly by the language connection context. REVISIT: this may need additional alterations when RELEASE SAVEPOINT/ROLLBACK TO SAVEPOINT show up.

Since the access manager's own context takes care of its own resources on commit, and the transaction stays open, there is nothing that this context has to do with the transaction controller.

Also, tell the data dictionary that the transaction is finished, if necessary (that is, if the data dictionary was put into DDL mode in this transaction.

Parameters:
commitStore - true if we should commit the Store transaction
sync - true means do a synchronized commit, false means do an unsynchronized commit
commitflag - if this is an unsynchronized commit, the flags to pass to commitNoSync in the store's TransactionController. If this is a synchronized commit, this flag is overloaded for xacommit.
requestedByUser - False iff the commit is for internal use and we should ignore the check to prevent commits in an atomic statement.
Throws:
StandardException - Thrown on error

cleanupTempTableOnCommitOrRollback

private TableDescriptor cleanupTempTableOnCommitOrRollback(TableDescriptor td,
                                                           boolean dropAndRedeclare)
                                                    throws StandardException
If dropAndRedeclare is true, that means we have come here for temp tables with on commit delete rows and no held curosr open on them. We will drop the existing conglomerate and redeclare a new conglomerate similar to old conglomerate. This is a more efficient way of deleting all rows from the table. If dropAndRedeclare is false, that means we have come here for the rollback cleanup work. We are trying to restore old definition of the temp table (because the drop on it is being rolled back).

Throws:
StandardException

internalRollback

public void internalRollback()
                      throws StandardException
Do a rollback as appropriate for an internally generated rollback (e.g. as needed by sync, or autocommit). When a rollback happens, we close all open activations and invalidate their prepared statements. We then tell the cache to age out everything else, which effectively invalidates them. Thus, all prepared statements will be compiled anew on their 1st execution after a rollback.

The invalidated statements can revalidate themselves without a full recompile if they verify their dependencies' providers still exist unchanged. REVISIT when invalidation types are created.

REVISIT: this may need additional alterations when RELEASE SAVEPOINT/ROLLBACK TO SAVEPOINT show up.

Also, tell the data dictionary that the transaction is finished, if necessary (that is, if the data dictionary was put into DDL mode in this transaction.

Specified by:
internalRollback in interface LanguageConnectionContext
Throws:
StandardException - thrown on failure

userRollback

public void userRollback()
                  throws StandardException
Do a rollback as is appropriate for a user requested rollback (e.g. a java.sql.Connection.rollback() or a language 'ROLLBACk' statement. Does some extra checking to make sure that users aren't doing anything bad.

Specified by:
userRollback in interface LanguageConnectionContext
Throws:
StandardException - thrown on failure

xaRollback

public void xaRollback()
                throws StandardException
Same as userRollback() except rolls back a distrubuted transaction.

Specified by:
xaRollback in interface LanguageConnectionContext
Throws:
StandardException - thrown if something goes wrong

doRollback

private void doRollback(boolean xa,
                        boolean requestedByUser)
                 throws StandardException
When a rollback happens, the language connection context will close all open activations and invalidate their prepared statements. Then the language will abort the Store transaction.

The invalidated statements can revalidate themselves without a full recompile if they verify their dependencies' providers still exist unchanged. REVISIT when invalidation types are created.

REVISIT: this may need additional alterations when RELEASE SAVEPOINT/ROLLBACK TO SAVEPOINT show up.

Also, tell the data dictionary that the transaction is finished, if necessary (that is, if the data dictionary was put into DDL mode in this transaction.

Parameters:
xa - true if this is an xa rollback
requestedByUser - true if requested by user
Throws:
StandardException - thrown on failure

resetSavepoints

private void resetSavepoints(StatementContext statementContext)
                      throws StandardException
Throws:
StandardException

internalRollbackToSavepoint

public void internalRollbackToSavepoint(java.lang.String savepointName,
                                        boolean refreshStyle,
                                        java.lang.Object kindOfSavepoint)
                                 throws StandardException
Let the context deal with a rollback to savepoint

Specified by:
internalRollbackToSavepoint in interface LanguageConnectionContext
Parameters:
savepointName - Name of the savepoint that needs to be rolled back
refreshStyle - boolean indicating whether or not the controller should close open conglomerates and scans. Also used to determine if language should close open activations.
kindOfSavepoint - A NULL value means it is an internal savepoint (ie not a user defined savepoint) Non NULL value means it is a user defined savepoint which can be a SQL savepoint or a JDBC savepoint A String value for kindOfSavepoint would mean it is SQL savepoint A JDBC Savepoint object value for kindOfSavepoint would mean it is JDBC savepoint
Throws:
StandardException - thrown if something goes wrong

releaseSavePoint

public void releaseSavePoint(java.lang.String savepointName,
                             java.lang.Object kindOfSavepoint)
                      throws StandardException
Let the context deal with a release of a savepoint

Specified by:
releaseSavePoint in interface LanguageConnectionContext
Parameters:
savepointName - Name of the savepoint that needs to be released
kindOfSavepoint - A NULL value means it is an internal savepoint (ie not a user defined savepoint) Non NULL value means it is a user defined savepoint which can be a SQL savepoint or a JDBC savepoint A String value for kindOfSavepoint would mean it is SQL savepoint A JDBC Savepoint object value for kindOfSavepoint would mean it is JDBC savepoint
Throws:
StandardException - thrown if something goes wrong

languageSetSavePoint

public void languageSetSavePoint(java.lang.String savepointName,
                                 java.lang.Object kindOfSavepoint)
                          throws StandardException
Sets a savepoint. Causes the Store to set a savepoint.

Specified by:
languageSetSavePoint in interface LanguageConnectionContext
Parameters:
savepointName - name of savepoint
kindOfSavepoint - A NULL value means it is an internal savepoint (ie not a user defined savepoint) Non NULL value means it is a user defined savepoint which can be a SQL savepoint or a JDBC savepoint A String value for kindOfSavepoint would mean it is SQL savepoint A JDBC Savepoint object value for kindOfSavepoint would mean it is JDBC savepoint
Throws:
StandardException - thrown if something goes wrong

anyoneBlocked

public boolean anyoneBlocked()
Return true if any transaction is blocked, even if not by this one

Specified by:
anyoneBlocked in interface LanguageConnectionContext

setTransaction

public void setTransaction(TransactionController tran)
Sets the transaction controller to use with this language connection context.

Specified by:
setTransaction in interface LanguageConnectionContext
Parameters:
tran - the transaction to use with this language connection context

beginNestedTransaction

public void beginNestedTransaction(boolean readOnly)
                            throws StandardException
Start a Nested User Transaction (NUT) with the store. If a NUT is already active simply increment a counter, queryNestingDepth, to keep track of how many times we have tried to start a NUT.

Specified by:
beginNestedTransaction in interface LanguageConnectionContext
Parameters:
readOnly - The nested transaction would be read only if param value true
Throws:
StandardException - on error.
See Also:
TransactionController.startNestedUserTransaction(boolean)

commitNestedTransaction

public void commitNestedTransaction()
                             throws StandardException
Description copied from interface: LanguageConnectionContext
commit a nested transaction. We do not provide a abortNestedTransaction. If a nested xaction is aborted, then this results in the parent xaction also being aborted. This is not what we need for releasing compile time locks or autoincrement-- hence we do not provide abortNestedTransaction.

Specified by:
commitNestedTransaction in interface LanguageConnectionContext
Throws:
StandardException - thrown on erro
See Also:
TransactionController.startNestedUserTransaction(boolean)

getTransactionCompile

public TransactionController getTransactionCompile()
Get the transaction controller to use at compile time with this language connection context. If a NUT is active then return NUT else return parent transaction.

Specified by:
getTransactionCompile in interface LanguageConnectionContext

getTransactionExecute

public TransactionController getTransactionExecute()
Description copied from interface: LanguageConnectionContext
Get the transaction controller to use with this language connection context during execute time.

Specified by:
getTransactionExecute in interface LanguageConnectionContext

getDataValueFactory

public DataValueFactory getDataValueFactory()
Get the data value factory to use with this language connection context.

Specified by:
getDataValueFactory in interface LanguageConnectionContext

getLanguageFactory

public LanguageFactory getLanguageFactory()
Get the language factory to use with this language connection context.

Specified by:
getLanguageFactory in interface LanguageConnectionContext

getOptimizerFactory

public OptimizerFactory getOptimizerFactory()
Description copied from interface: LanguageConnectionContext
get the optimizer factory to use with this language connection context.

Specified by:
getOptimizerFactory in interface LanguageConnectionContext

getLanguageConnectionFactory

public LanguageConnectionFactory getLanguageConnectionFactory()
Get the language connection factory to use with this language connection context.

Specified by:
getLanguageConnectionFactory in interface LanguageConnectionContext

checkIfAnyActivationHasHoldCursor

private boolean checkIfAnyActivationHasHoldCursor(java.lang.String tableName)
                                           throws StandardException
check if there are any activations that reference this temporary table

Returns:
boolean false if found no activations
Throws:
StandardException

verifyAllHeldResultSetsAreClosed

public boolean verifyAllHeldResultSetsAreClosed()
                                         throws StandardException
Verify that there are no activations with open held result sets.

Specified by:
verifyAllHeldResultSetsAreClosed in interface LanguageConnectionContext
Returns:
boolean Found no open (held) resultsets.
Throws:
StandardException - thrown on failure

verifyNoOpenResultSets

public boolean verifyNoOpenResultSets(PreparedStatement pStmt,
                                      Provider provider,
                                      int action)
                               throws StandardException
Verify that there are no activations with open result sets on the specified prepared statement.

Specified by:
verifyNoOpenResultSets in interface LanguageConnectionContext
Parameters:
pStmt - The prepared Statement
provider - The object precipitating a possible invalidation
action - The action causing the possible invalidation
Returns:
Nothing.
Throws:
StandardException - thrown on failure

getAuthorizationId

public java.lang.String getAuthorizationId()
Get the Authorization Id

Specified by:
getAuthorizationId in interface LanguageConnectionContext
Returns:
String the authorization id

getDefaultSchema

public SchemaDescriptor getDefaultSchema()
Get the default schema

Specified by:
getDefaultSchema in interface LanguageConnectionContext
Returns:
SchemaDescriptor the default schema

getCurrentSchemaName

public java.lang.String getCurrentSchemaName()
Get the current schema name

Specified by:
getCurrentSchemaName in interface LanguageConnectionContext
Returns:
current schema name

setDefaultSchema

public void setDefaultSchema(SchemaDescriptor sd)
                      throws StandardException
Set the default schema -- used by SET SCHEMA.

Specified by:
setDefaultSchema in interface LanguageConnectionContext
Throws:
StandardException - thrown on failure

getIdentityValue

public java.math.BigDecimal getIdentityValue()
Get the identity column value most recently generated.

Specified by:
getIdentityValue in interface LanguageConnectionContext
Returns:
the generated identity column value

setIdentityValue

public void setIdentityValue(long val)
Set the field of most recently generated identity column value.

Specified by:
setIdentityValue in interface LanguageConnectionContext

emptyCache

public void emptyCache()
Empty as much of the cache as possible. It is not guaranteed that the cache is empty after this call, as statements may be kept by currently executing queries, activations that are about to be garbage collected.


pushCompilerContext

public final CompilerContext pushCompilerContext()
Push a CompilerContext on the context stack with the current default schema as the default schema which we compile against.

Specified by:
pushCompilerContext in interface LanguageConnectionContext
Returns:
the compiler context
Throws:
StandardException - thrown on failure

pushCompilerContext

public CompilerContext pushCompilerContext(SchemaDescriptor sd)
Push a CompilerContext on the context stack with the passed in default schema as the default schema we compile against.

Specified by:
pushCompilerContext in interface LanguageConnectionContext
Parameters:
sd - the default schema
Returns:
the compiler context

popCompilerContext

public void popCompilerContext(CompilerContext cc)
Pop a CompilerContext off the context stack.

Specified by:
popCompilerContext in interface LanguageConnectionContext
Parameters:
cc - The compiler context.
Returns:
Nothing.

pushStatementContext

public StatementContext pushStatementContext(boolean isAtomic,
                                             java.lang.String stmtText,
                                             ParameterValueSet pvs,
                                             boolean rollbackParentContext)
Push a StatementContext on the context stack.

Specified by:
pushStatementContext in interface LanguageConnectionContext
Parameters:
isAtomic - whether this statement is atomic or not
stmtText - the text of the statement. Needed for any language statement (currently, for any statement that can cause a trigger to fire). Please set this unless you are some funky jdbc setXXX method or something.
pvs - parameter value set, if it has one
rollbackParentContext - True if 1) the statement context is NOT a top-level context, AND 2) in the event of a statement-level exception, the parent context needs to be rolled back, too.
Returns:
StatementContext The statement context.

popStatementContext

public void popStatementContext(StatementContext statementContext,
                                java.lang.Throwable error)
Pop a StatementContext of the context stack.

Specified by:
popStatementContext in interface LanguageConnectionContext
Parameters:
statementContext - The statement context.
error - The error, if any (Only relevant for DEBUG)
Returns:
Nothing.

pushExecutionStmtValidator

public void pushExecutionStmtValidator(ExecutionStmtValidator validator)
Push a new execution statement validator. An execution statement validator is an object that validates the current statement to ensure that it is permitted given the current execution context. An example of a validator a trigger ExecutionStmtValidator that doesn't allow ddl on the trigger target table.

Multiple ExecutionStmtValidators may be active at any given time. This mirrors the way there can be multiple connection nestings at a single time. The validation is performed by calling each validator's validateStatement() method. This yields the union of all validations.

Specified by:
pushExecutionStmtValidator in interface LanguageConnectionContext
Parameters:
validator - the validator to add

popExecutionStmtValidator

public void popExecutionStmtValidator(ExecutionStmtValidator validator)
                               throws StandardException
Remove the validator. Does an object identity (validator == validator) comparison. Asserts that the validator is found.

Specified by:
popExecutionStmtValidator in interface LanguageConnectionContext
Parameters:
validator - the validator to remove
Throws:
StandardException - on error

pushTriggerExecutionContext

public void pushTriggerExecutionContext(TriggerExecutionContext tec)
                                 throws StandardException
Push a new trigger execution context.

Multiple TriggerExecutionContexts may be active at any given time.

Specified by:
pushTriggerExecutionContext in interface LanguageConnectionContext
Parameters:
tec - the trigger execution context
Throws:
StandardException - on trigger recursion error

popTriggerExecutionContext

public void popTriggerExecutionContext(TriggerExecutionContext tec)
                                throws StandardException
Remove the tec. Does an object identity (tec == tec) comparison. Asserts that the tec is found.

Specified by:
popTriggerExecutionContext in interface LanguageConnectionContext
Parameters:
tec - the tec to remove
Throws:
StandardException - on error

getTriggerExecutionContext

public TriggerExecutionContext getTriggerExecutionContext()
Get the topmost tec.

Specified by:
getTriggerExecutionContext in interface LanguageConnectionContext
Returns:
the tec

validateStmtExecution

public void validateStmtExecution(ConstantAction constantAction)
                           throws StandardException
Validate a statement. Does so by stepping through all the validators and executing them. If a validator throws and exception, then the checking is stopped and the exception is passed up.

Specified by:
validateStmtExecution in interface LanguageConnectionContext
Parameters:
constantAction - the constantAction that is about to be executed (and should be validated
Throws:
StandardException - on validation failure

pushTriggerTable

public void pushTriggerTable(TableDescriptor td)
Set the trigger table descriptor. Used to compile statements that may special trigger pseudo tables.

Specified by:
pushTriggerTable in interface LanguageConnectionContext
Parameters:
td - the table that the trigger is defined upon

popTriggerTable

public void popTriggerTable(TableDescriptor td)
Remove the trigger table descriptor.

Specified by:
popTriggerTable in interface LanguageConnectionContext
Parameters:
td - the table to remove from the stack.

getTriggerTable

public TableDescriptor getTriggerTable()
Get the topmost trigger table descriptor

Specified by:
getTriggerTable in interface LanguageConnectionContext
Returns:
the table descriptor, or null if we aren't in the middle of compiling a create trigger.

getDatabase

public Database getDatabase()
Description copied from interface: LanguageConnectionContext
Returns the Database of this connection.

Specified by:
getDatabase in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.getDatabase()

incrementBindCount

public int incrementBindCount()
Description copied from interface: LanguageConnectionContext
Increment the DataDictionary bind count. This is for keeping track of nested binding, which can happen if SQL statements are bound from within static initializers.

Specified by:
incrementBindCount in interface LanguageConnectionContext
Returns:
The new bind count
See Also:
LanguageConnectionContext.incrementBindCount()

decrementBindCount

public int decrementBindCount()
Description copied from interface: LanguageConnectionContext
Decrement the DataDictionary bind count.

Specified by:
decrementBindCount in interface LanguageConnectionContext
Returns:
The new bind count
See Also:
LanguageConnectionContext.decrementBindCount()

getBindCount

public int getBindCount()
Description copied from interface: LanguageConnectionContext
Get the DataDictionary bind count.

Specified by:
getBindCount in interface LanguageConnectionContext
Returns:
The current bind count.
See Also:
LanguageConnectionContext.getBindCount()

setDataDictionaryWriteMode

public final void setDataDictionaryWriteMode()
Description copied from interface: LanguageConnectionContext
Remember that the DataDictionary is in write mode, so we can take it out of write mode at the end of the transaction.

Specified by:
setDataDictionaryWriteMode in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.setDataDictionaryWriteMode()

dataDictionaryInWriteMode

public final boolean dataDictionaryInWriteMode()
Description copied from interface: LanguageConnectionContext
Return true if the data dictionary is in write mode (that is, this context was informed that is is in write mode by the method call setDataDictionaryWriteMode().

Specified by:
dataDictionaryInWriteMode in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.dataDictionaryInWriteMode()

setRunTimeStatisticsMode

public void setRunTimeStatisticsMode(boolean onOrOff)
Description copied from interface: LanguageConnectionContext
Turn RUNTIMESTATISTICS on or off.

Specified by:
setRunTimeStatisticsMode in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.setRunTimeStatisticsMode(boolean)

getRunTimeStatisticsMode

public boolean getRunTimeStatisticsMode()
Description copied from interface: LanguageConnectionContext
Get the RUNTIMESTATISTICS mode.

Specified by:
getRunTimeStatisticsMode in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.getRunTimeStatisticsMode()

setStatisticsTiming

public void setStatisticsTiming(boolean onOrOff)
Description copied from interface: LanguageConnectionContext
Turn STATISTICS TIMING on or off.

Specified by:
setStatisticsTiming in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.setStatisticsTiming(boolean)

getStatisticsTiming

public boolean getStatisticsTiming()
Description copied from interface: LanguageConnectionContext
Get the STATISTICS TIMING mode.

Specified by:
getStatisticsTiming in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.getStatisticsTiming()

setRunTimeStatisticsObject

public void setRunTimeStatisticsObject(RunTimeStatistics runTimeStatisticsObject)
Description copied from interface: LanguageConnectionContext
Set the RUNTIMESTATISTICS object.

Specified by:
setRunTimeStatisticsObject in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.setRunTimeStatisticsObject(org.apache.derby.iapi.sql.execute.RunTimeStatistics)

getRunTimeStatisticsObject

public RunTimeStatistics getRunTimeStatisticsObject()
Description copied from interface: LanguageConnectionContext
Get the RUNTIMESTATISTICS object.

Specified by:
getRunTimeStatisticsObject in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.getRunTimeStatisticsObject()

getStatementDepth

public int getStatementDepth()
Reports how many statement levels deep we are.

Specified by:
getStatementDepth in interface LanguageConnectionContext
Returns:
a statement level >= OUTERMOST_STATEMENT

setIsolationLevel

public void setIsolationLevel(int isolationLevel)
                       throws StandardException
Description copied from interface: LanguageConnectionContext
Set current isolation level.

Specified by:
setIsolationLevel in interface LanguageConnectionContext
Parameters:
isolationLevel - The new isolationLevel.
Returns:
Nothing.
Throws:
StandardException
See Also:
LanguageConnectionContext.setIsolationLevel(int)

getCurrentIsolationLevel

public int getCurrentIsolationLevel()
Description copied from interface: LanguageConnectionContext
Get the current isolation level.

Specified by:
getCurrentIsolationLevel in interface LanguageConnectionContext
Returns:
The current isolation level.
See Also:
LanguageConnectionContext.getCurrentIsolationLevel()

getCurrentIsolationLevelStr

public java.lang.String getCurrentIsolationLevelStr()
Description copied from interface: LanguageConnectionContext
Get the current isolation level in DB2 format.

Specified by:
getCurrentIsolationLevelStr in interface LanguageConnectionContext
Returns:
The current isolation level as a 2 character string.
See Also:
LanguageConnectionContext.getCurrentIsolationLevel()

setPrepareIsolationLevel

public void setPrepareIsolationLevel(int level)
Specified by:
setPrepareIsolationLevel in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.setPrepareIsolationLevel(int)

getPrepareIsolationLevel

public int getPrepareIsolationLevel()
Description copied from interface: LanguageConnectionContext
Get the prepare isolation level. If the isolation level has been explicitly set with a SQL statement or embedded call to setTransactionIsolation, this will return ExecutionContext.UNSPECIFIED_ISOLATION_LEVEL SET ISOLATION always takes priority.

Specified by:
getPrepareIsolationLevel in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.getPrepareIsolationLevel()

getExecutionContext

public ExecutionContext getExecutionContext()
Description copied from interface: LanguageConnectionContext
Get the current ExecutionContext.

Specified by:
getExecutionContext in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.getExecutionContext()

getStatementContext

public StatementContext getStatementContext()
Description copied from interface: LanguageConnectionContext
Get the current StatementContext.

Specified by:
getStatementContext in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.getStatementContext()

setOptimizerTrace

public boolean setOptimizerTrace(boolean onOrOff)
Description copied from interface: LanguageConnectionContext
Control whether or not optimizer trace is on.

Specified by:
setOptimizerTrace in interface LanguageConnectionContext
Parameters:
onOrOff - Whether to turn optimizer trace on (true) or off (false).
Returns:
Whether or not the call was successful. (false will be returned when optimizer tracing is not supported.)
See Also:
LanguageConnectionContext.setOptimizerTrace(boolean)

getOptimizerTrace

public boolean getOptimizerTrace()
Description copied from interface: LanguageConnectionContext
Get whether or not optimizer trace is on.

Specified by:
getOptimizerTrace in interface LanguageConnectionContext
Returns:
Whether or not optimizer trace is on.
See Also:
LanguageConnectionContext.getOptimizerTrace()

setOptimizerTraceHtml

public boolean setOptimizerTraceHtml(boolean onOrOff)
Description copied from interface: LanguageConnectionContext
Control whether or not optimizer trace is generated in html.

Specified by:
setOptimizerTraceHtml in interface LanguageConnectionContext
Parameters:
onOrOff - Whether or not optimizer trace will be in html (true) or not (false).
Returns:
Whether or not the call was successful. (false will be returned when optimizer tracing is not supported.)
See Also:
LanguageConnectionContext.setOptimizerTraceHtml(boolean)

getOptimizerTraceHtml

public boolean getOptimizerTraceHtml()
Description copied from interface: LanguageConnectionContext
Get whether or not optimizer trace html is on.

Specified by:
getOptimizerTraceHtml in interface LanguageConnectionContext
Returns:
Whether or not optimizer trace html is on.
See Also:
LanguageConnectionContext.getOptimizerTraceHtml()

setOptimizerTraceOutput

public void setOptimizerTraceOutput(java.lang.String startingText)
Description copied from interface: LanguageConnectionContext
Set the optimizer trace output to the specified String. (Done at the beginning of each statement.)

Specified by:
setOptimizerTraceOutput in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.setOptimizerTraceOutput(java.lang.String)

appendOptimizerTraceOutput

public void appendOptimizerTraceOutput(java.lang.String output)
Description copied from interface: LanguageConnectionContext
Append the latest output to the optimizer trace output.

Specified by:
appendOptimizerTraceOutput in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.appendOptimizerTraceOutput(java.lang.String)

getOptimizerTraceOutput

public java.lang.String getOptimizerTraceOutput()
Description copied from interface: LanguageConnectionContext
Get the optimizer trace output for the last optimized query as a String. If optimizer trace html is on, then the String will contain the html tags.

Specified by:
getOptimizerTraceOutput in interface LanguageConnectionContext
Returns:
The optimizer trace output for the last optimized query as a String. Null will be returned if optimizer trace output is off or not supported or no trace output was found or an exception occurred.
See Also:
LanguageConnectionContext.getOptimizerTraceOutput()

isTransactionPristine

public boolean isTransactionPristine()
Reports whether there is any outstanding work in the transaction.

Specified by:
isTransactionPristine in interface LanguageConnectionContext
Returns:
true if there is outstanding work in the transaction false otherwise

getLockObject

public java.lang.Object getLockObject(int lockScope)
                               throws StandardException
Get the lock handle for the current transaction.

Specified by:
getLockObject in interface LanguageConnectionContext
Parameters:
lockScope - SINGLE_TRANSACTION_LOCK or MULTI_TRANSACTION_LOCK
Returns:
the current lock handle
Throws:
StandardException - thrown if something goes wrong

convertIdentifierCase

public java.lang.String convertIdentifierCase(java.lang.String id)
                                       throws StandardException
Convert an identifier to the proper case for this connection. This method is here to support the Plugin.

Specified by:
convertIdentifierCase in interface LanguageConnectionContext
Returns:
the string converted to upper or lower case, as appropriate
Throws:
StandardException - thrown if something goes wrong

getIdentifierCasing

public int getIdentifierCasing()
                        throws StandardException
Get casing for delimited identifiers. This feature is here to support the Plugin.

Specified by:
getIdentifierCasing in interface LanguageConnectionContext
Returns:
ANSI_CASING or ANTI_ANSI_CASING.
Throws:
StandardException - thrown if something goes wrong

cleanupOnError

public void cleanupOnError(java.lang.Throwable error)
                    throws StandardException
If worse than a transaction error, everything goes; we rely on other contexts to kill the context manager for this session.

If a transaction error, act like we saw a rollback.

If more severe or a java error, the outer cleanup will shutdown the connection, so we don't have to clean up.

REMIND: connection should throw out all contexts and start over when the connection is closed... perhaps by throwing out the context manager?

REVISIT: If statement error, should we do anything?

Since the access manager's own context takes care of its own resources on errors, there is nothing that this context has to do with the transaction controller.

Specified by:
cleanupOnError in interface Context
Throws:
StandardException - thrown on error. REVISIT: don't want cleanupOnError's to throw exceptions.

isLastHandler

public boolean isLastHandler(int severity)
Description copied from interface: Context
Return whether or not this context is the "last" handler for a the specified severity level. Previously, the context manager would march through all of the contexts in cleanupOnError() and call each of their cleanupOnError() methods. That did not work with server side JDBC, especially for a StatementException, because outer contexts could get cleaned up incorrectly. This functionality is specific to the Language system. Any non-language system contexts should return ExceptionSeverity.NOT_APPLICABLE_SEVERITY. NOTE: Both the LanguageConnectionContext and the JDBC Connection Context are interested in session level errors because they both have clean up to do. This method allows both of them to return false so that all such handlers under them can do their clean up.

Specified by:
isLastHandler in interface Context
Overrides:
isLastHandler in class ContextImpl
See Also:
Context.isLastHandler(int)

resetActivations

private void resetActivations(boolean andClose)
                       throws StandardException
resets all open activations, to close their result sets. Also cleans up (close()) activations that have been marked as unused during statement finalization.

Throws:
StandardException - thrown on failure

finishDDTransaction

private void finishDDTransaction()
                          throws StandardException
Finish the data dictionary transaction, if any.

Throws:
StandardException - Thrown on error

incrementStatementDepth

private void incrementStatementDepth()
Increments the statement depth.


decrementStatementDepth

private void decrementStatementDepth()
Decrements the statement depth


resetStatementDepth

protected void resetStatementDepth()
Resets the statementDepth.


getSystemSchemaName

public java.lang.String getSystemSchemaName()
                                     throws StandardException
Get the name of the system schema.

Specified by:
getSystemSchemaName in interface LanguageConnectionContext
Returns:
A String containing the name of the system schema.
Throws:
StandardException

getSysIBMSchemaName

public java.lang.String getSysIBMSchemaName()
                                     throws StandardException
Get the name of the SYSIBM schema.

Specified by:
getSysIBMSchemaName in interface LanguageConnectionContext
Returns:
A String containing the name of the SYSIBM schema.
Throws:
StandardException

getSystemDiagSchemaName

public java.lang.String getSystemDiagSchemaName()
                                         throws StandardException
Get the name of the SYSCS_DIAG schema.

Specified by:
getSystemDiagSchemaName in interface LanguageConnectionContext
Returns:
A String containing the name of the SYSIBM schema.
Throws:
StandardException

getSystemUtilSchemaName

public java.lang.String getSystemUtilSchemaName()
                                         throws StandardException
Get the name of the SYSCS_UTIL schema.

Specified by:
getSystemUtilSchemaName in interface LanguageConnectionContext
Returns:
A String containing the name of the SYSIBM schema.
Throws:
StandardException

getDeclaredGlobalTemporaryTablesSchemaName

public java.lang.String getDeclaredGlobalTemporaryTablesSchemaName()
                                                            throws StandardException
Get the declared global temporary tables schema name.

Specified by:
getDeclaredGlobalTemporaryTablesSchemaName in interface LanguageConnectionContext
Returns:
a String containing the declared global temporary tables schema name.
Throws:
StandardException

getDataDictionary

public DataDictionary getDataDictionary()
Description copied from interface: LanguageConnectionContext
Get the data dictionary

Specified by:
getDataDictionary in interface LanguageConnectionContext
Returns:
the data dictionary

setReadOnly

public void setReadOnly(boolean on)
                 throws StandardException
Description copied from interface: LanguageConnectionContext
Set the readOnly status for the current connection. This can only be called when the current transaction has not done any work.

Specified by:
setReadOnly in interface LanguageConnectionContext
Parameters:
on - true sets the connection to be readOnly and false sets it to readWrite.
Throws:
StandardException - The operation is disallowed.
See Also:
LanguageConnectionContext.setReadOnly(boolean)

isReadOnly

public boolean isReadOnly()
Description copied from interface: LanguageConnectionContext
Get the readOnly status for the current connection.

Specified by:
isReadOnly in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.isReadOnly()

getAuthorizer

public Authorizer getAuthorizer()
Description copied from interface: LanguageConnectionContext
Get an Authorizer for this connection.

Specified by:
getAuthorizer in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.getAuthorizer()

getAccessFactory

public AccessFactory getAccessFactory()
Description copied from interface: LanguageConnectionContext
Get the AccessFactory cached in this LanguageConnectionContext

Specified by:
getAccessFactory in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.getAccessFactory()

lastAutoincrementValue

public java.lang.Long lastAutoincrementValue(java.lang.String schemaName,
                                             java.lang.String tableName,
                                             java.lang.String columnName)
Implements ConnectionInfo.lastAutoincrementValue. lastAutoincrementValue searches for the last autoincrement value inserted into a column specified by the user. The search for the "last" value supports nesting levels caused by triggers (Only triggers cause nesting, not server side JDBC). If lastAutoincrementValue is called from within a trigger, the search space for ai-values are those values that are inserted by this trigger as well as previous triggers; i.e if a SQL statement fires trigger T1, which in turn does something that fires trigger t2, and if lastAutoincrementValue is called from within t2, then autoincrement values genereated by t1 are visible to it. By the same logic, if it is called from within t1, then it does not see values inserted by t2.

Specified by:
lastAutoincrementValue in interface LanguageConnectionContext
Parameters:
schemaName -
tableName -
columnName -
See Also:
LanguageConnectionContext.lastAutoincrementValue(java.lang.String, java.lang.String, java.lang.String), ConnectionInfo.lastAutoincrementValue(java.lang.String, java.lang.String, java.lang.String)

setAutoincrementUpdate

public void setAutoincrementUpdate(boolean flag)
Description copied from interface: LanguageConnectionContext
Sets autoincrementUpdate-- this variable allows updates to autoincrement columns if it is set to true. The default is ofcourse false; i.e ai columns cannot be directly modified by the user. This is set to true by AlterTableConstantAction, when a new ai column is being added to an existing table.

Specified by:
setAutoincrementUpdate in interface LanguageConnectionContext
Parameters:
flag - the value for autoincrementUpdate (TRUE or FALSE)
See Also:
LanguageConnectionContext.setAutoincrementUpdate(boolean)

getAutoincrementUpdate

public boolean getAutoincrementUpdate()
Description copied from interface: LanguageConnectionContext
Returns the current value of autoincrementUpdate.

Specified by:
getAutoincrementUpdate in interface LanguageConnectionContext
Returns:
true if updates to autoincrement columns is permitted.
See Also:
LanguageConnectionContext.getAutoincrementUpdate()

autoincrementCreateCounter

public void autoincrementCreateCounter(java.lang.String s,
                                       java.lang.String t,
                                       java.lang.String c,
                                       java.lang.Long initialValue,
                                       long increment,
                                       int position)
Description copied from interface: LanguageConnectionContext
Create an autoincrement counter to be used on behalf of a SQL-J statement. The counter is identified by (schemaName, tableName, columnName). The counter must be freed up by calling autoincrementFlushCache at the end of the statement. It is expected that a ai-counter with the same signaure doesn't exist when the method is called.

Specified by:
autoincrementCreateCounter in interface LanguageConnectionContext
Parameters:
s - SchemaName
t - TableName
c - ColumnName
initialValue - initial value of the counter.
increment - increment for the counter.
position - column position (1-based).
See Also:
LanguageConnectionContext.autoincrementCreateCounter(java.lang.String, java.lang.String, java.lang.String, java.lang.Long, long, int)

nextAutoincrementValue

public long nextAutoincrementValue(java.lang.String schemaName,
                                   java.lang.String tableName,
                                   java.lang.String columnName)
                            throws StandardException
returns the next value to be inserted into an autoincrement col. This is used internally by the system to generate autoincrement values which are going to be inserted into a autoincrement column. This is used when as autoincrement column is added to a table by an alter table statemenet and during bulk insert.

Specified by:
nextAutoincrementValue in interface LanguageConnectionContext
Parameters:
schemaName -
tableName -
columnName - identify the column uniquely in the system.
Throws:
StandardException - on error.

autoincrementFlushCache

public void autoincrementFlushCache(UUID tableUUID)
                             throws StandardException
Flush the cache of autoincrement values being kept by the lcc. This will result in the autoincrement values being written to the SYSCOLUMNS table as well as the mapping used by lastAutoincrementValue

Specified by:
autoincrementFlushCache in interface LanguageConnectionContext
Parameters:
tableUUID - the table which is being flushed; we need this value to identify the table for which the autoincrement counter is being maintained.
Throws:
StandardException - thrown on error.
See Also:
LanguageConnectionContext.lastAutoincrementValue(java.lang.String, java.lang.String, java.lang.String), lastAutoincrementValue(java.lang.String, java.lang.String, java.lang.String), ConnectionInfo.lastAutoincrementValue(java.lang.String, java.lang.String, java.lang.String)

copyHashtableToAIHT

public void copyHashtableToAIHT(java.util.Hashtable from)
Copies an existing hashtable of autoincrement mappings into autoincrementHT, the cache of autoincrement values kept in the languageconnectioncontext.

Specified by:
copyHashtableToAIHT in interface LanguageConnectionContext

getInstanceNumber

public int getInstanceNumber()
Description copied from interface: LanguageConnectionContext
Get the instance number of this LCC.

Specified by:
getInstanceNumber in interface LanguageConnectionContext
Returns:
instance number of this LCC.
See Also:
LanguageConnectionContext.getInstanceNumber()

getDrdaID

public java.lang.String getDrdaID()
Description copied from interface: LanguageConnectionContext
Get the DRDA ID of this LCC.

Specified by:
getDrdaID in interface LanguageConnectionContext
Returns:
DRDA ID this LCC.
See Also:
LanguageConnectionContext.getDrdaID()

setDrdaID

public void setDrdaID(java.lang.String drdaID)
Description copied from interface: LanguageConnectionContext
Set the DRDA ID of this LCC.

Specified by:
setDrdaID in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.setDrdaID(java.lang.String)

getDbname

public java.lang.String getDbname()
Description copied from interface: LanguageConnectionContext
Get the database name of this LCC.

Specified by:
getDbname in interface LanguageConnectionContext
Returns:
database name of this LCC.
See Also:
LanguageConnectionContext.getDbname()

getLastActivation

public Activation getLastActivation()
Description copied from interface: LanguageConnectionContext
Return the last activation added This is used to find the drop activation in dropViewCascade so we can add warning messages to the activation

Specified by:
getLastActivation in interface LanguageConnectionContext
See Also:
LanguageConnectionContext.getLastActivation()

getAuthorizationId

protected java.lang.String getAuthorizationId(java.lang.String userName)
                                       throws StandardException
Set the authorization identifier for this user.

Throws:
StandardException

appendErrorInfo

public java.lang.StringBuffer appendErrorInfo()
Overrides:
appendErrorInfo in class ContextImpl


Apache Derby V10.0 Engine Documentation - Copyright © 1997,2004 The Apache Software Foundation or its licensors, as applicable.