public class GenericPreparedStatement extends java.lang.Object implements ExecPreparedStatement
These are both dependents (of the schema objects and prepared statements they depend on) and providers. Prepared statements that are providers are cursors that end up being used in positioned delete and update statements (at present).
This is impl with the regular prepared statements; they will never have the cursor info fields set.
Stored prepared statements extend this implementation
| Modifier and Type | Class and Description |
|---|---|
private static class |
GenericPreparedStatement.RowCountStatistics
This class holds information about stale plan check interval,
execution count and row count statistics for a GenericPreparedStatement.
|
| Modifier and Type | Field and Description |
|---|---|
protected GeneratedClass |
activationClass |
protected java.sql.Timestamp |
beginCompileTimestamp |
protected long |
bindTime |
private Cacheable |
cacheHolder
If non-null then this object is the cacheable
that holds us in the cache.
|
protected long |
compileTime |
(package private) boolean |
compilingStatement |
protected java.sql.Timestamp |
endCompileTimestamp |
private java.lang.String |
execSchemaName |
private java.lang.String |
execStmtName |
protected ConstantAction |
executionConstants |
protected long |
generateTime |
private int |
inUseCount |
(package private) boolean |
invalidatedWhileCompiling
True if the statement was invalidated while it was being compiled.
|
protected boolean |
isAtomic |
protected boolean |
isValid |
private boolean |
needsSavepoint |
protected long |
optimizeTime |
protected DataTypeDescriptor[] |
paramTypeDescriptors |
protected long |
parseTime |
private boolean |
referencesSessionSchema |
protected java.util.List |
requiredPermissionsList |
protected ResultDescription |
resultDesc |
private GenericPreparedStatement.RowCountStatistics |
rowCountStats
Holder for row counts and execution count.
|
protected java.lang.Object[] |
savedObjects |
protected java.lang.String |
sourceTxt |
protected boolean |
spsAction |
private java.lang.String |
spsName |
Statement |
statement |
protected ResultColumnDescriptor[] |
targetColumns |
protected ExecCursorTableReference |
targetTable |
protected java.lang.String[] |
updateColumns |
protected int |
updateMode |
protected java.lang.String |
UUIDString |
protected UUID |
UUIDValue |
private long |
versionCounter
Incremented for each (re)compile.
|
private java.sql.SQLWarning |
warnings |
ACTIVATION, ALIAS, COLUMNS_IN_TABLE, COLUMNS_PERMISSION, CONGLOMERATE, CONSTRAINT, DEFAULT, FILE, HEAP, INDEX, PERM, PREPARED_STATEMENT, ROLE_GRANT, ROUTINE_PERMISSION, SCHEMA, SEQUENCE, STORED_PREPARED_STATEMENT, TABLE, TABLE_PERMISSION, TRIGGER, VIEW| Constructor and Description |
|---|
GenericPreparedStatement() |
GenericPreparedStatement(Statement st) |
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
completeCompile(StatementNode qt)
Makes the prepared statement valid, assigning
values for its query tree, generated class,
and associated information.
|
ResultSet |
execute(Activation activation,
boolean forMetaData,
long timeoutMillis)
Execute the PreparedStatement and return results, used for top level
statements (not substatements) in a connection.
|
private ResultSet |
executeStmt(Activation activation,
boolean rollbackParentContext,
boolean forMetaData,
long timeoutMillis)
The guts of execution.
|
ResultSet |
executeSubStatement(Activation parent,
Activation activation,
boolean rollbackParentContext,
long timeoutMillis)
Execute a statement as part of another statement (ithout a nested
connection) and return results.
|
ResultSet |
executeSubStatement(LanguageConnectionContext lcc,
boolean rollbackParentContext,
long timeoutMillis)
Execute a statement as part of another statement (without a nested
connection) and return results.
|
void |
finish(LanguageConnectionContext lcc)
Finish marks a statement as totally unusable.
|
Activation |
getActivation(LanguageConnectionContext lcc,
boolean scrollable)
Get a new activation instance.
|
GeneratedClass |
getActivationClass()
Get the class generated for this prepared statement.
|
java.sql.Timestamp |
getBeginCompileTimestamp()
Get the timestamp for the beginning of compilation
|
long |
getBindTimeInMillis()
Get the bind time for the associated query in milliseconds.
|
(package private) ByteArray |
getByteCodeSaver()
Get the byte code saver for this statement.
|
java.lang.String |
getClassType()
Get the Dependable's class type.
|
ExecPreparedStatement |
getClone()
Get a new prepared statement that is a shallow copy
of the current one.
|
long |
getCompileTimeInMillis()
Get the total compile time for the associated query in milliseconds.
|
java.sql.SQLWarning |
getCompileTimeWarnings()
Return any compile time warnings.
|
ConstantAction |
getConstantAction()
Get the Execution constants.
|
java.lang.Object |
getCursorInfo()
Return the cursor info in a single chunk.
|
DependableFinder |
getDependableFinder()
Get an object which can be written to disk and which,
when read from disk, will find or reconstruct this in-memory
Dependable.
|
java.sql.Timestamp |
getEndCompileTimestamp()
Get the timestamp for the end of compilation
|
long |
getGenerateTimeInMillis()
Get the generate time for the associated query in milliseconds.
|
long |
getInitialRowCount(int rsNum,
long currentRowCount)
Get the initial row count of the specified result set.
|
UUID |
getObjectID()
Get the Dependable's UUID String.
|
java.lang.String |
getObjectName()
Return the name of this Dependable.
|
long |
getOptimizeTimeInMillis()
Get the optimize time for the associated query in milliseconds.
|
DataTypeDescriptor[] |
getParameterTypes()
Get an array of DataTypeDescriptors describing the types of the
parameters of this PreparedStatement.
|
long |
getParseTimeInMillis()
Get the parse time for the associated query in milliseconds.
|
java.util.List |
getRequiredPermissionsList() |
ResultDescription |
getResultDescription()
Get the ResultDescription for the statement.
|
java.lang.Object |
getSavedObject(int objectNum)
Get the specified saved object.
|
java.lang.Object[] |
getSavedObjects()
Get the saved objects.
|
java.lang.String |
getSource()
Return the SQL string that this statement is for.
|
java.lang.String |
getSPSName()
Return the SPS Name for this statement.
|
int |
getStalePlanCheckInterval()
Get the stale plan check interval.
|
ResultColumnDescriptor[] |
getTargetColumns()
the target columns of the cursor as a result column list
|
ExecCursorTableReference |
getTargetTable()
the target table of the cursor
|
java.lang.String[] |
getUpdateColumns()
the update columns of the cursor as a update column list
|
int |
getUpdateMode()
the update mode of the cursor
|
long |
getVersionCounter()
Get the version counter.
|
int |
incrementExecutionCount()
Increment and return the execution count for this statement.
|
void |
incrementVersionCounter() |
boolean |
isAtomic()
Returns whether or not this Statement requires should
behave atomically -- i.e. whether a user is permitted
to do a commit/rollback during the execution of this
statement.
|
boolean |
isPersistent()
Is this dependent persistent?
|
boolean |
isStorable() |
private boolean |
isUpToDate()
Unsynchronized helper method for
upToDate() and upToDate(GeneratedClass). |
boolean |
isValid()
Check that all of the dependent's dependencies are valid.
|
void |
makeInvalid(int action,
LanguageConnectionContext lcc)
Mark the dependent as invalid (due to at least one of
its dependencies being invalid).
|
boolean |
needsSavepoint()
Does this statement need a savepoint?
|
void |
prepareToInvalidate(Provider p,
int action,
LanguageConnectionContext lcc)
Prepare to mark the dependent as invalid (due to at least one of
its dependencies being invalid).
|
boolean |
referencesSessionSchema()
Return true if the query node for this statement references SESSION schema
tables/views.
|
boolean |
referencesSessionSchema(StatementNode qt)
Return true if the QueryTreeNode references SESSION schema tables/views.
|
void |
rePrepare(LanguageConnectionContext lcc)
Re-prepare the statement if it is not up to date or,
if requested, simply not optimal.
|
void |
rePrepare(LanguageConnectionContext lcc,
boolean forMetaData) |
(package private) void |
setActivationClass(GeneratedClass ac) |
void |
setCacheHolder(Cacheable cacheHolder) |
protected void |
setCompileTimeMillis(long parseTime,
long bindTime,
long optimizeTime,
long generateTime,
long compileTime,
java.sql.Timestamp beginCompileTimestamp,
java.sql.Timestamp endCompileTimestamp)
Set the compile time for this prepared statement.
|
(package private) void |
setCompileTimeWarnings(java.sql.SQLWarning warnings) |
(package private) void |
setConstantAction(ConstantAction constantAction)
Set the Execution constants.
|
(package private) void |
setCursorInfo(CursorInfo cursorInfo) |
(package private) void |
setExecuteStatementNameAndSchema(java.lang.String execStmtName,
java.lang.String execSchemaName)
Set the name of the statement and schema for an "execute statement"
command.
|
(package private) void |
setIsAtomic(boolean isAtomic)
Set the stmts 'isAtomic' state.
|
(package private) void |
setNeedsSavepoint(boolean needsSavepoint)
Set the stmts 'needsSavepoint' state.
|
void |
setRequiredPermissionsList(java.util.List requiredPermissionsList) |
(package private) void |
setSavedObjects(java.lang.Object[] objects)
Set the saved objects.
|
void |
setSource(java.lang.String text)
set the statement text
|
void |
setSPSAction()
Indicate this prepared statement is an SPS action, currently used
by GenericTriggerExecutor.
|
void |
setSPSName(java.lang.String name) |
void |
setStalePlanCheckInterval(int interval)
Set the stale plan check interval.
|
void |
setValid()
set this prepared statement to be valid, currently used by
GenericTriggerExecutor.
|
java.lang.String |
toString() |
boolean |
upToDate()
Checks whether this PreparedStatement is up to date.
|
boolean |
upToDate(GeneratedClass gc)
Check whether this statement is up to date and its generated class is
identical to the supplied class object.
|
public Statement statement
protected GeneratedClass activationClass
protected ResultDescription resultDesc
protected DataTypeDescriptor[] paramTypeDescriptors
private java.lang.String spsName
private java.sql.SQLWarning warnings
private boolean referencesSessionSchema
protected ExecCursorTableReference targetTable
protected ResultColumnDescriptor[] targetColumns
protected java.lang.String[] updateColumns
protected int updateMode
protected ConstantAction executionConstants
protected java.lang.Object[] savedObjects
protected java.util.List requiredPermissionsList
protected java.lang.String UUIDString
protected UUID UUIDValue
private boolean needsSavepoint
private java.lang.String execStmtName
private java.lang.String execSchemaName
protected boolean isAtomic
protected java.lang.String sourceTxt
private int inUseCount
boolean compilingStatement
boolean invalidatedWhileCompiling
protected long parseTime
protected long bindTime
protected long optimizeTime
protected long generateTime
protected long compileTime
protected java.sql.Timestamp beginCompileTimestamp
protected java.sql.Timestamp endCompileTimestamp
protected boolean isValid
protected boolean spsAction
private Cacheable cacheHolder
private long versionCounter
private GenericPreparedStatement.RowCountStatistics rowCountStats
GenericPreparedStatement()
public GenericPreparedStatement(Statement st)
public boolean upToDate()
throws StandardException
PreparedStatementupToDate in interface PreparedStatementStandardExceptionpublic boolean upToDate(GeneratedClass gc)
upToDate in interface ExecPreparedStatementgc - a generated class that must be identical to getActivationClass() for this method to return truetrue if this statement is up to date and its activation
class is identical to gc, false otherwiseExecPreparedStatement.upToDate(GeneratedClass)private boolean isUpToDate()
upToDate() and upToDate(GeneratedClass). Checks whether this statement is up to date.true if this statement is up to date, false
otherwisepublic void rePrepare(LanguageConnectionContext lcc) throws StandardException
PreparedStatementrePrepare in interface PreparedStatementlcc - The LanguageConnectionContext.StandardException - thrown if unable to performpublic void rePrepare(LanguageConnectionContext lcc, boolean forMetaData) throws StandardException
StandardExceptionpublic Activation getActivation(LanguageConnectionContext lcc, boolean scrollable) throws StandardException
getActivation in interface PreparedStatementlcc - The LanguageConnectionContext.StandardException - thrown if finished.public ResultSet executeSubStatement(LanguageConnectionContext lcc, boolean rollbackParentContext, long timeoutMillis) throws StandardException
PreparedStatementCreates a new single use activation and executes it, but also passes rollbackParentContext parameter.
executeSubStatement in interface PreparedStatementlcc - language connection contextrollbackParentContext - True if in the event of a statement-level
exception, the parent context needs to be rolled back, too.timeoutMillis - timeout value in milliseconds.StandardExceptionPreparedStatement.executeSubStatement(LanguageConnectionContext, boolean, long)public ResultSet executeSubStatement(Activation parent, Activation activation, boolean rollbackParentContext, long timeoutMillis) throws StandardException
PreparedStatementThere is no executeQuery() or executeUpdate(); a method is provided in ResultSet to tell whether to expect rows to be returned.
executeSubStatement in interface PreparedStatementparent - The activation of the superstatementactivation - The activation containing all the local state
to execute the plan for substatementrollbackParentContext - True if in the event of a statement-level
exception, the parent context needs to be rolled back, too.timeoutMillis - timeout value in milliseconds.StandardException - Thrown on failurePreparedStatement.executeSubStatement(Activation, Activation, boolean, long)public ResultSet execute(Activation activation, boolean forMetaData, long timeoutMillis) throws StandardException
PreparedStatementThere is no executeQuery() or executeUpdate(); a method is provided in ResultSet to tell whether to expect rows to be returned.
execute in interface PreparedStatementactivation - The activation containing all the local state
to execute the plan.forMetaData - true if this is a meta-data querytimeoutMillis - timeout value in milliseconds.StandardException - Thrown on failurePreparedStatement.execute(org.apache.derby.iapi.sql.Activation, boolean, long)private ResultSet executeStmt(Activation activation, boolean rollbackParentContext, boolean forMetaData, long timeoutMillis) throws StandardException
activation - the activation to run.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.forMetaData - true if this is a meta-data querytimeoutMillis - timeout value in milliseconds.StandardException - thrown on errorpublic ResultDescription getResultDescription()
PreparedStatementThis is available here and on the ResultSet so that users can see the shape of the result before they execute.
getResultDescription in interface PreparedStatementpublic DataTypeDescriptor[] getParameterTypes()
PreparedStatementgetParameterTypes in interface PreparedStatementpublic java.lang.String getSource()
PreparedStatementgetSource in interface PreparedStatementpublic void setSource(java.lang.String text)
ExecPreparedStatementsetSource in interface ExecPreparedStatementtext - the source textpublic final void setSPSName(java.lang.String name)
public java.lang.String getSPSName()
PreparedStatementgetSPSName in interface PreparedStatementpublic long getCompileTimeInMillis()
getCompileTimeInMillis in interface PreparedStatementpublic long getParseTimeInMillis()
getParseTimeInMillis in interface PreparedStatementpublic long getBindTimeInMillis()
getBindTimeInMillis in interface PreparedStatementpublic long getOptimizeTimeInMillis()
getOptimizeTimeInMillis in interface PreparedStatementpublic long getGenerateTimeInMillis()
getGenerateTimeInMillis in interface PreparedStatementpublic java.sql.Timestamp getBeginCompileTimestamp()
getBeginCompileTimestamp in interface PreparedStatementpublic java.sql.Timestamp getEndCompileTimestamp()
getEndCompileTimestamp in interface PreparedStatementvoid setCompileTimeWarnings(java.sql.SQLWarning warnings)
public final java.sql.SQLWarning getCompileTimeWarnings()
PreparedStatementgetCompileTimeWarnings in interface PreparedStatementprotected void setCompileTimeMillis(long parseTime,
long bindTime,
long optimizeTime,
long generateTime,
long compileTime,
java.sql.Timestamp beginCompileTimestamp,
java.sql.Timestamp endCompileTimestamp)
compileTime - The compile timepublic void finish(LanguageConnectionContext lcc)
finish in interface ExecPreparedStatementfinal void setConstantAction(ConstantAction constantAction)
constantAction - The big structure enclosing the Execution constants.public final ConstantAction getConstantAction()
getConstantAction in interface ExecPreparedStatementfinal void setSavedObjects(java.lang.Object[] objects)
objects - The objects to save from compilationpublic final java.lang.Object getSavedObject(int objectNum)
getSavedObject in interface ExecPreparedStatementobjectNum - The object to get.public final java.lang.Object[] getSavedObjects()
getSavedObjects in interface ExecPreparedStatementpublic boolean isValid()
public void setValid()
setValid in interface ExecPreparedStatementpublic void setSPSAction()
setSPSAction in interface ExecPreparedStatementpublic void prepareToInvalidate(Provider p, int action, LanguageConnectionContext lcc) throws StandardException
prepareToInvalidate in interface Dependentaction - The action causing the invalidationp - the providerlcc - The LanguageConnectionContextStandardException - thrown if unable to make it invalidpublic void makeInvalid(int action,
LanguageConnectionContext lcc)
throws StandardException
makeInvalid in interface Dependentaction - The action causing the invalidationlcc - The LanguageConnectionContextStandardException - Standard Derby error policy.public boolean isPersistent()
isPersistent in interface Dependablepublic DependableFinder getDependableFinder()
DependablegetDependableFinder in interface DependableDependable.getDependableFinder()public java.lang.String getObjectName()
getObjectName in interface Dependablepublic UUID getObjectID()
getObjectID in interface Dependablepublic java.lang.String getClassType()
getClassType in interface Dependablepublic boolean referencesSessionSchema()
referencesSessionSchema in interface PreparedStatementpublic boolean referencesSessionSchema(StatementNode qt) throws StandardException
StandardExceptionvoid completeCompile(StatementNode qt) throws StandardException
qt - the query tree for this statementStandardException - thrown on failure.public GeneratedClass getActivationClass() throws StandardException
ExecPreparedStatementgetActivationClass in interface ExecPreparedStatementStandardException - on error obtaining class
(probably when a stored prepared statement is loading)void setActivationClass(GeneratedClass ac)
public int getUpdateMode()
getUpdateMode in interface ExecPreparedStatementpublic ExecCursorTableReference getTargetTable()
getTargetTable in interface ExecPreparedStatementpublic ResultColumnDescriptor[] getTargetColumns()
getTargetColumns in interface ExecPreparedStatementpublic java.lang.String[] getUpdateColumns()
getUpdateColumns in interface ExecPreparedStatementpublic java.lang.Object getCursorInfo()
getCursorInfo in interface ExecPreparedStatementvoid setCursorInfo(CursorInfo cursorInfo)
ByteArray getByteCodeSaver()
public boolean needsSavepoint()
needsSavepoint in interface ExecPreparedStatementvoid setNeedsSavepoint(boolean needsSavepoint)
needsSavepoint - true if this statement needs a savepoint.void setIsAtomic(boolean isAtomic)
isAtomic - true if this statement must be atomic
(i.e. it is not ok to do a commit/rollback in the middle)public boolean isAtomic()
isAtomic in interface PreparedStatementvoid setExecuteStatementNameAndSchema(java.lang.String execStmtName,
java.lang.String execSchemaName)
public ExecPreparedStatement getClone() throws StandardException
getClone in interface ExecPreparedStatementStandardException - on errorpublic void setCacheHolder(Cacheable cacheHolder)
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean isStorable()
public void setRequiredPermissionsList(java.util.List requiredPermissionsList)
public java.util.List getRequiredPermissionsList()
getRequiredPermissionsList in interface ExecPreparedStatementpublic final long getVersionCounter()
PreparedStatementgetVersionCounter in interface PreparedStatementpublic final void incrementVersionCounter()
public int incrementExecutionCount()
ExecPreparedStatementincrementExecutionCount in interface ExecPreparedStatementExecPreparedStatement.incrementExecutionCount()public void setStalePlanCheckInterval(int interval)
ExecPreparedStatementsetStalePlanCheckInterval in interface ExecPreparedStatementinterval - the stale plan check intervalExecPreparedStatement.setStalePlanCheckInterval(int)public int getStalePlanCheckInterval()
ExecPreparedStatementgetStalePlanCheckInterval in interface ExecPreparedStatementExecPreparedStatement.getStalePlanCheckInterval()public long getInitialRowCount(int rsNum,
long currentRowCount)
ExecPreparedStatementgetInitialRowCount in interface ExecPreparedStatementrsNum - the result set to get the initial row count forcurrentRowCount - the current row count for the result setExecPreparedStatement.getInitialRowCount(int, long)Apache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.