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 |
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<StatementPermission> |
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 ExecCursorTableReference |
targetTable |
protected java.util.List<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 |
beginCompiling()
Signal that the statement is about to be compiled.
|
(package private) void |
completeCompile(StatementNode qt)
Makes the prepared statement valid, assigning
values for its query tree, generated class,
and associated information.
|
(package private) void |
endCompiling()
Signal that we're done compiling the statement and unblock others
that are waiting for the compilation to finish.
|
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.
|
private static ContextService |
getContextService()
Privileged lookup of the ContextService.
|
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.
|
private static ModuleFactory |
getMonitor()
Privileged Monitor lookup.
|
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 |
getParameterType(int idx)
Return the type of the parameter (0-based indexing)
|
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<StatementPermission> |
getRequiredPermissionsList() |
ResultDescription |
getResultDescription()
Get the ResultDescription for the statement.
|
java.lang.Object |
getSavedObject(int objectNum)
Get the specified saved object.
|
java.util.List<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.
|
ExecCursorTableReference |
getTargetTable()
the target table of the cursor
|
int |
getUpdateMode()
the update mode of the cursor
|
long |
getVersionCounter()
Get the version counter.
|
boolean |
hasUpdateColumns()
Check if this prepared statement has a cursor with columns that
can be updated.
|
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.
|
(package private) boolean |
isCompiling()
Check if this statement is currently being compiled.
|
boolean |
isPersistent()
Is this dependent persistent?
|
boolean |
isStorable() |
boolean |
isUpdateColumn(java.lang.String columnName)
Check if the specified column name is one of the update columns.
|
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<StatementPermission> 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 java.util.List<java.lang.String> updateColumns
protected int updateMode
protected ConstantAction executionConstants
protected java.lang.Object[] savedObjects
protected java.util.List<StatementPermission> 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
private 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
PreparedStatement
upToDate
in interface PreparedStatement
StandardException
public boolean upToDate(GeneratedClass gc)
upToDate
in interface ExecPreparedStatement
gc
- a generated class that must be identical to getActivationClass()
for this method to return true
true
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
otherwisefinal boolean isCompiling()
final void beginCompiling()
final void endCompiling()
public void rePrepare(LanguageConnectionContext lcc) throws StandardException
PreparedStatement
rePrepare
in interface PreparedStatement
lcc
- The LanguageConnectionContext.StandardException
- thrown if unable to performpublic void rePrepare(LanguageConnectionContext lcc, boolean forMetaData) throws StandardException
StandardException
public Activation getActivation(LanguageConnectionContext lcc, boolean scrollable) throws StandardException
getActivation
in interface PreparedStatement
lcc
- The LanguageConnectionContext.StandardException
- thrown if finished.public ResultSet executeSubStatement(LanguageConnectionContext lcc, boolean rollbackParentContext, long timeoutMillis) throws StandardException
PreparedStatement
Creates a new single use activation and executes it, but also passes rollbackParentContext parameter.
executeSubStatement
in interface PreparedStatement
lcc
- 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.StandardException
PreparedStatement.executeSubStatement(LanguageConnectionContext, boolean, long)
public ResultSet executeSubStatement(Activation parent, Activation activation, boolean rollbackParentContext, long timeoutMillis) throws StandardException
PreparedStatement
There is no executeQuery() or executeUpdate(); a method is provided in ResultSet to tell whether to expect rows to be returned.
executeSubStatement
in interface PreparedStatement
parent
- 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
PreparedStatement
There is no executeQuery() or executeUpdate(); a method is provided in ResultSet to tell whether to expect rows to be returned.
execute
in interface PreparedStatement
activation
- 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()
PreparedStatement
This is available here and on the ResultSet so that users can see the shape of the result before they execute.
getResultDescription
in interface PreparedStatement
public DataTypeDescriptor[] getParameterTypes()
PreparedStatement
getParameterTypes
in interface PreparedStatement
public DataTypeDescriptor getParameterType(int idx) throws StandardException
getParameterType
in interface PreparedStatement
StandardException
public java.lang.String getSource()
PreparedStatement
getSource
in interface PreparedStatement
public void setSource(java.lang.String text)
ExecPreparedStatement
setSource
in interface ExecPreparedStatement
text
- the source textpublic final void setSPSName(java.lang.String name)
public java.lang.String getSPSName()
PreparedStatement
getSPSName
in interface PreparedStatement
public long getCompileTimeInMillis()
getCompileTimeInMillis
in interface PreparedStatement
public long getParseTimeInMillis()
getParseTimeInMillis
in interface PreparedStatement
public long getBindTimeInMillis()
getBindTimeInMillis
in interface PreparedStatement
public long getOptimizeTimeInMillis()
getOptimizeTimeInMillis
in interface PreparedStatement
public long getGenerateTimeInMillis()
getGenerateTimeInMillis
in interface PreparedStatement
public java.sql.Timestamp getBeginCompileTimestamp()
getBeginCompileTimestamp
in interface PreparedStatement
public java.sql.Timestamp getEndCompileTimestamp()
getEndCompileTimestamp
in interface PreparedStatement
void setCompileTimeWarnings(java.sql.SQLWarning warnings)
public final java.sql.SQLWarning getCompileTimeWarnings()
PreparedStatement
getCompileTimeWarnings
in interface PreparedStatement
protected 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 ExecPreparedStatement
final void setConstantAction(ConstantAction constantAction)
constantAction
- The big structure enclosing the Execution constants.public final ConstantAction getConstantAction()
getConstantAction
in interface ExecPreparedStatement
final void setSavedObjects(java.lang.Object[] objects)
objects
- The objects to save from compilationpublic final java.lang.Object getSavedObject(int objectNum)
getSavedObject
in interface ExecPreparedStatement
objectNum
- The object to get.public final java.util.List<java.lang.Object> getSavedObjects()
getSavedObjects
in interface ExecPreparedStatement
public boolean isValid()
public void setValid()
setValid
in interface ExecPreparedStatement
public void setSPSAction()
setSPSAction
in interface ExecPreparedStatement
public void prepareToInvalidate(Provider p, int action, LanguageConnectionContext lcc) throws StandardException
prepareToInvalidate
in interface Dependent
action
- 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 Dependent
action
- The action causing the invalidationlcc
- The LanguageConnectionContextStandardException
- Standard Derby error policy.public boolean isPersistent()
isPersistent
in interface Dependable
public DependableFinder getDependableFinder()
Dependable
getDependableFinder
in interface Dependable
Dependable.getDependableFinder()
public java.lang.String getObjectName()
getObjectName
in interface Dependable
public UUID getObjectID()
getObjectID
in interface Dependable
public java.lang.String getClassType()
getClassType
in interface Dependable
public boolean referencesSessionSchema()
referencesSessionSchema
in interface PreparedStatement
public boolean referencesSessionSchema(StatementNode qt) throws StandardException
StandardException
void completeCompile(StatementNode qt) throws StandardException
qt
- the query tree for this statementStandardException
- thrown on failure.public GeneratedClass getActivationClass() throws StandardException
ExecPreparedStatement
getActivationClass
in interface ExecPreparedStatement
StandardException
- on error obtaining class
(probably when a stored prepared statement is loading)void setActivationClass(GeneratedClass ac)
public int getUpdateMode()
getUpdateMode
in interface ExecPreparedStatement
public ExecCursorTableReference getTargetTable()
getTargetTable
in interface ExecPreparedStatement
public boolean hasUpdateColumns()
ExecPreparedStatement
hasUpdateColumns
in interface ExecPreparedStatement
public boolean isUpdateColumn(java.lang.String columnName)
ExecPreparedStatement
isUpdateColumn
in interface ExecPreparedStatement
public java.lang.Object getCursorInfo()
getCursorInfo
in interface ExecPreparedStatement
void setCursorInfo(CursorInfo cursorInfo)
ByteArray getByteCodeSaver()
public boolean needsSavepoint()
needsSavepoint
in interface ExecPreparedStatement
void 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 PreparedStatement
void setExecuteStatementNameAndSchema(java.lang.String execStmtName, java.lang.String execSchemaName)
public ExecPreparedStatement getClone() throws StandardException
getClone
in interface ExecPreparedStatement
StandardException
- on errorpublic void setCacheHolder(Cacheable cacheHolder)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isStorable()
public void setRequiredPermissionsList(java.util.List<StatementPermission> requiredPermissionsList)
public java.util.List<StatementPermission> getRequiredPermissionsList()
getRequiredPermissionsList
in interface ExecPreparedStatement
public final long getVersionCounter()
PreparedStatement
getVersionCounter
in interface PreparedStatement
public final void incrementVersionCounter()
public int incrementExecutionCount()
ExecPreparedStatement
incrementExecutionCount
in interface ExecPreparedStatement
ExecPreparedStatement.incrementExecutionCount()
public void setStalePlanCheckInterval(int interval)
ExecPreparedStatement
setStalePlanCheckInterval
in interface ExecPreparedStatement
interval
- the stale plan check intervalExecPreparedStatement.setStalePlanCheckInterval(int)
public int getStalePlanCheckInterval()
ExecPreparedStatement
getStalePlanCheckInterval
in interface ExecPreparedStatement
ExecPreparedStatement.getStalePlanCheckInterval()
public long getInitialRowCount(int rsNum, long currentRowCount)
ExecPreparedStatement
getInitialRowCount
in interface ExecPreparedStatement
rsNum
- the result set to get the initial row count forcurrentRowCount
- the current row count for the result setExecPreparedStatement.getInitialRowCount(int, long)
private static ContextService getContextService()
private static ModuleFactory getMonitor()
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.