Class GenericPreparedStatement
- java.lang.Object
-
- org.apache.derby.impl.sql.GenericPreparedStatement
-
- All Implemented Interfaces:
Dependable
,Dependent
,ExecPreparedStatement
,PreparedStatement
- Direct Known Subclasses:
GenericStorablePreparedStatement
public class GenericPreparedStatement extends java.lang.Object implements ExecPreparedStatement
Basic implementation of prepared statement. relies on implementation of ResultDescription and Statement that are also in this package.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
GenericPreparedStatement.RowCountStatistics
This class holds information about stale plan check interval, execution count and row count statistics for a GenericPreparedStatement.
-
Field Summary
Fields Modifier and Type Field 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
-
Fields inherited from interface org.apache.derby.catalog.Dependable
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 Summary
Constructors Constructor Description GenericPreparedStatement()
GenericPreparedStatement(Statement st)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 compilationlong
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 compilationlong
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 cursorint
getUpdateMode()
the update mode of the cursorlong
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 forupToDate()
andupToDate(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 textvoid
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.
-
-
-
Field Detail
-
statement
public Statement statement
-
activationClass
protected GeneratedClass activationClass
-
resultDesc
protected ResultDescription resultDesc
-
paramTypeDescriptors
protected DataTypeDescriptor[] paramTypeDescriptors
-
spsName
private java.lang.String spsName
-
warnings
private java.sql.SQLWarning warnings
-
referencesSessionSchema
private boolean referencesSessionSchema
-
targetTable
protected ExecCursorTableReference targetTable
-
updateColumns
protected java.util.List<java.lang.String> updateColumns
-
updateMode
protected int updateMode
-
executionConstants
protected ConstantAction executionConstants
-
savedObjects
protected java.lang.Object[] savedObjects
-
requiredPermissionsList
protected java.util.List<StatementPermission> requiredPermissionsList
-
UUIDString
protected java.lang.String UUIDString
-
UUIDValue
protected UUID UUIDValue
-
needsSavepoint
private boolean needsSavepoint
-
execStmtName
private java.lang.String execStmtName
-
execSchemaName
private java.lang.String execSchemaName
-
isAtomic
protected boolean isAtomic
-
sourceTxt
protected java.lang.String sourceTxt
-
inUseCount
private int inUseCount
-
compilingStatement
private boolean compilingStatement
-
invalidatedWhileCompiling
boolean invalidatedWhileCompiling
True if the statement was invalidated while it was being compiled.
-
parseTime
protected long parseTime
-
bindTime
protected long bindTime
-
optimizeTime
protected long optimizeTime
-
generateTime
protected long generateTime
-
compileTime
protected long compileTime
-
beginCompileTimestamp
protected java.sql.Timestamp beginCompileTimestamp
-
endCompileTimestamp
protected java.sql.Timestamp endCompileTimestamp
-
isValid
protected boolean isValid
-
spsAction
protected boolean spsAction
-
cacheHolder
private Cacheable cacheHolder
If non-null then this object is the cacheable that holds us in the cache.
-
versionCounter
private long versionCounter
Incremented for each (re)compile.
-
rowCountStats
private GenericPreparedStatement.RowCountStatistics rowCountStats
Holder for row counts and execution count. Used for determining whether the statement should be recompiled.
-
-
Constructor Detail
-
GenericPreparedStatement
GenericPreparedStatement()
-
GenericPreparedStatement
public GenericPreparedStatement(Statement st)
-
-
Method Detail
-
upToDate
public boolean upToDate() throws StandardException
Description copied from interface:PreparedStatement
Checks whether this PreparedStatement is up to date. A PreparedStatement can become out of date if any of several things happen: A schema used by the statement is dropped A table used by the statement is dropped A table used by the statement, or a column in such a table, is altered in one of several ways: a column is dropped, a privilege is dropped, a constraint is added or dropped, an index is dropped. A view used by the statement is dropped. In general, anything that happened since the plan was generated that might cause the plan to fail, or to generate incorrect results, will cause this method to return FALSE.- Specified by:
upToDate
in interfacePreparedStatement
- Returns:
- TRUE if the PreparedStatement is up to date, FALSE if it is not up to date
- Throws:
StandardException
-
upToDate
public boolean upToDate(GeneratedClass gc)
Check whether this statement is up to date and its generated class is identical to the supplied class object.- Specified by:
upToDate
in interfaceExecPreparedStatement
- Parameters:
gc
- a generated class that must be identical togetActivationClass()
for this method to returntrue
- Returns:
true
if this statement is up to date and its activation class is identical togc
,false
otherwise- See Also:
ExecPreparedStatement.upToDate(GeneratedClass)
-
isUpToDate
private boolean isUpToDate()
Unsynchronized helper method forupToDate()
andupToDate(GeneratedClass)
. Checks whether this statement is up to date.- Returns:
true
if this statement is up to date,false
otherwise
-
isCompiling
final boolean isCompiling()
Check if this statement is currently being compiled.
-
beginCompiling
final void beginCompiling()
Signal that the statement is about to be compiled. This will block others from attempting to compile it.
-
endCompiling
final void endCompiling()
Signal that we're done compiling the statement and unblock others that are waiting for the compilation to finish.
-
rePrepare
public void rePrepare(LanguageConnectionContext lcc) throws StandardException
Description copied from interface:PreparedStatement
Re-prepare the statement if it is not up to date or, if requested, simply not optimal. If there are open cursors using this prepared statement, then we will not be able to recompile the statement.- Specified by:
rePrepare
in interfacePreparedStatement
- Parameters:
lcc
- The LanguageConnectionContext.- Throws:
StandardException
- thrown if unable to perform
-
rePrepare
public void rePrepare(LanguageConnectionContext lcc, boolean forMetaData) throws StandardException
- Throws:
StandardException
-
getActivation
public Activation getActivation(LanguageConnectionContext lcc, boolean scrollable) throws StandardException
Get a new activation instance.- Specified by:
getActivation
in interfacePreparedStatement
- Parameters:
lcc
- The LanguageConnectionContext.- Returns:
- The new activation.
- Throws:
StandardException
- thrown if finished.
-
executeSubStatement
public ResultSet executeSubStatement(LanguageConnectionContext lcc, boolean rollbackParentContext, long timeoutMillis) throws StandardException
Description copied from interface:PreparedStatement
Execute a statement as part of another statement (without a nested connection) and return results.Creates a new single use activation and executes it, but also passes rollbackParentContext parameter.
- Specified by:
executeSubStatement
in interfacePreparedStatement
- Parameters:
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.- Throws:
StandardException
- See Also:
PreparedStatement.executeSubStatement(LanguageConnectionContext, boolean, long)
-
executeSubStatement
public ResultSet executeSubStatement(Activation parent, Activation activation, boolean rollbackParentContext, long timeoutMillis) throws StandardException
Description copied from interface:PreparedStatement
Execute a statement as part of another statement (ithout a nested connection) and return results.There is no executeQuery() or executeUpdate(); a method is provided in ResultSet to tell whether to expect rows to be returned.
- Specified by:
executeSubStatement
in interfacePreparedStatement
- Parameters:
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.- Returns:
- A ResultSet for a statement. A ResultSet represents the results returned from the statement, if any. Will return NULL if the plan for the PreparedStatement has aged out of cache, or the plan is out of date.
- Throws:
StandardException
- Thrown on failure- See Also:
PreparedStatement.executeSubStatement(Activation, Activation, boolean, long)
-
execute
public ResultSet execute(Activation activation, boolean forMetaData, long timeoutMillis) throws StandardException
Description copied from interface:PreparedStatement
Execute the PreparedStatement and return results, used for top level statements (not substatements) in a connection.There is no executeQuery() or executeUpdate(); a method is provided in ResultSet to tell whether to expect rows to be returned.
- Specified by:
execute
in interfacePreparedStatement
- Parameters:
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.- Returns:
- A ResultSet for a statement. A ResultSet represents the results returned from the statement, if any. Will return NULL if the plan for the PreparedStatement has aged out of cache, or the plan is out of date.
- Throws:
StandardException
- Thrown on failure- See Also:
PreparedStatement.execute(org.apache.derby.iapi.sql.Activation, boolean, long)
-
executeStmt
private ResultSet executeStmt(Activation activation, boolean rollbackParentContext, boolean forMetaData, long timeoutMillis) throws StandardException
The guts of execution.- Parameters:
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.- Returns:
- the result set to be pawed through
- Throws:
StandardException
- thrown on error
-
getResultDescription
public ResultDescription getResultDescription()
Description copied from interface:PreparedStatement
Get the ResultDescription for the statement. The ResultDescription describes what the results look like: what are the rows and columns?This is available here and on the ResultSet so that users can see the shape of the result before they execute.
- Specified by:
getResultDescription
in interfacePreparedStatement
- Returns:
- A ResultDescription describing the results.
-
getParameterTypes
public DataTypeDescriptor[] getParameterTypes()
Description copied from interface:PreparedStatement
Get an array of DataTypeDescriptors describing the types of the parameters of this PreparedStatement. The Nth element of the array describes the Nth parameter.- Specified by:
getParameterTypes
in interfacePreparedStatement
- Returns:
- An array of DataTypeDescriptors telling the type, length, precision, scale, etc. of each parameter of this PreparedStatement.
-
getParameterType
public DataTypeDescriptor getParameterType(int idx) throws StandardException
Return the type of the parameter (0-based indexing)- Specified by:
getParameterType
in interfacePreparedStatement
- Throws:
StandardException
-
getSource
public java.lang.String getSource()
Description copied from interface:PreparedStatement
Return the SQL string that this statement is for.- Specified by:
getSource
in interfacePreparedStatement
- Returns:
- the SQL string this statement is for.
-
setSource
public void setSource(java.lang.String text)
Description copied from interface:ExecPreparedStatement
set the statement text- Specified by:
setSource
in interfaceExecPreparedStatement
- Parameters:
text
- the source text
-
setSPSName
public final void setSPSName(java.lang.String name)
-
getSPSName
public java.lang.String getSPSName()
Description copied from interface:PreparedStatement
Return the SPS Name for this statement.- Specified by:
getSPSName
in interfacePreparedStatement
- Returns:
- the SPS Name for this statement
-
getCompileTimeInMillis
public long getCompileTimeInMillis()
Get the total compile time for the associated query in milliseconds. Compile time can be divided into parse, bind, optimize and generate times.- Specified by:
getCompileTimeInMillis
in interfacePreparedStatement
- Returns:
- long The total compile time for the associated query in milliseconds.
-
getParseTimeInMillis
public long getParseTimeInMillis()
Get the parse time for the associated query in milliseconds.- Specified by:
getParseTimeInMillis
in interfacePreparedStatement
- Returns:
- long The parse time for the associated query in milliseconds.
-
getBindTimeInMillis
public long getBindTimeInMillis()
Get the bind time for the associated query in milliseconds.- Specified by:
getBindTimeInMillis
in interfacePreparedStatement
- Returns:
- long The bind time for the associated query in milliseconds.
-
getOptimizeTimeInMillis
public long getOptimizeTimeInMillis()
Get the optimize time for the associated query in milliseconds.- Specified by:
getOptimizeTimeInMillis
in interfacePreparedStatement
- Returns:
- long The optimize time for the associated query in milliseconds.
-
getGenerateTimeInMillis
public long getGenerateTimeInMillis()
Get the generate time for the associated query in milliseconds.- Specified by:
getGenerateTimeInMillis
in interfacePreparedStatement
- Returns:
- long The generate time for the associated query in milliseconds.
-
getBeginCompileTimestamp
public java.sql.Timestamp getBeginCompileTimestamp()
Get the timestamp for the beginning of compilation- Specified by:
getBeginCompileTimestamp
in interfacePreparedStatement
- Returns:
- Timestamp The timestamp for the beginning of compilation.
-
getEndCompileTimestamp
public java.sql.Timestamp getEndCompileTimestamp()
Get the timestamp for the end of compilation- Specified by:
getEndCompileTimestamp
in interfacePreparedStatement
- Returns:
- Timestamp The timestamp for the end of compilation.
-
setCompileTimeWarnings
void setCompileTimeWarnings(java.sql.SQLWarning warnings)
-
getCompileTimeWarnings
public final java.sql.SQLWarning getCompileTimeWarnings()
Description copied from interface:PreparedStatement
Return any compile time warnings. Null if no warnings exist.- Specified by:
getCompileTimeWarnings
in interfacePreparedStatement
-
setCompileTimeMillis
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.- Parameters:
compileTime
- The compile time
-
finish
public void finish(LanguageConnectionContext lcc)
Finish marks a statement as totally unusable.- Specified by:
finish
in interfaceExecPreparedStatement
-
setConstantAction
final void setConstantAction(ConstantAction constantAction)
Set the Execution constants. This routine is called as we Prepare the statement.- Parameters:
constantAction
- The big structure enclosing the Execution constants.
-
getConstantAction
public final ConstantAction getConstantAction()
Get the Execution constants. This routine is called at Execution time.- Specified by:
getConstantAction
in interfaceExecPreparedStatement
- Returns:
- ConstantAction The big structure enclosing the Execution constants.
-
setSavedObjects
final void setSavedObjects(java.lang.Object[] objects)
Set the saved objects. Called when compilation completes.- Parameters:
objects
- The objects to save from compilation
-
getSavedObject
public final java.lang.Object getSavedObject(int objectNum)
Get the specified saved object.- Specified by:
getSavedObject
in interfaceExecPreparedStatement
- Parameters:
objectNum
- The object to get.- Returns:
- the requested saved object.
-
getSavedObjects
public final java.util.List<java.lang.Object> getSavedObjects()
Get the saved objects.- Specified by:
getSavedObjects
in interfaceExecPreparedStatement
- Returns:
- all the saved objects
-
isValid
public boolean isValid()
Check that all of the dependent's dependencies are valid.
-
setValid
public void setValid()
set this prepared statement to be valid, currently used by GenericTriggerExecutor.- Specified by:
setValid
in interfaceExecPreparedStatement
-
setSPSAction
public void setSPSAction()
Indicate this prepared statement is an SPS action, currently used by GenericTriggerExecutor.- Specified by:
setSPSAction
in interfaceExecPreparedStatement
-
prepareToInvalidate
public void prepareToInvalidate(Provider p, int action, LanguageConnectionContext lcc) throws StandardException
Prepare to mark the dependent as invalid (due to at least one of its dependencies being invalid).- Specified by:
prepareToInvalidate
in interfaceDependent
- Parameters:
action
- The action causing the invalidationp
- the providerlcc
- The LanguageConnectionContext- Throws:
StandardException
- thrown if unable to make it invalid
-
makeInvalid
public void makeInvalid(int action, LanguageConnectionContext lcc) throws StandardException
Mark the dependent as invalid (due to at least one of its dependencies being invalid).- Specified by:
makeInvalid
in interfaceDependent
- Parameters:
action
- The action causing the invalidationlcc
- The LanguageConnectionContext- Throws:
StandardException
- Standard Derby error policy.
-
isPersistent
public boolean isPersistent()
Is this dependent persistent? A stored dependency will be required if both the dependent and provider are persistent.- Specified by:
isPersistent
in interfaceDependable
- Returns:
- boolean Whether or not this dependent is persistent.
-
getDependableFinder
public DependableFinder getDependableFinder()
Description copied from interface:Dependable
Get an object which can be written to disk and which, when read from disk, will find or reconstruct this in-memory Dependable.- Specified by:
getDependableFinder
in interfaceDependable
- Returns:
- the stored form of this Dependable
- See Also:
Dependable.getDependableFinder()
-
getObjectName
public java.lang.String getObjectName()
Return the name of this Dependable. (Useful for errors.)- Specified by:
getObjectName
in interfaceDependable
- Returns:
- String The name of this Dependable..
-
getObjectID
public UUID getObjectID()
Get the Dependable's UUID String.- Specified by:
getObjectID
in interfaceDependable
- Returns:
- String The Dependable's UUID String.
-
getClassType
public java.lang.String getClassType()
Get the Dependable's class type.- Specified by:
getClassType
in interfaceDependable
- Returns:
- String Classname that this Dependable belongs to.
-
referencesSessionSchema
public boolean referencesSessionSchema()
Return true if the query node for this statement references SESSION schema tables/views. This method gets called at the very beginning of the compile phase of any statement. If the statement which needs to be compiled is already found in cache, then there is no need to compile it again except the case when the statement is referencing SESSION schema objects. There is a small window where such a statement might get cached temporarily (a statement referencing SESSION schema object will be removed from the cache after the bind phase is over because that is when we know for sure that the statement is referencing SESSION schema objects.)- Specified by:
referencesSessionSchema
in interfacePreparedStatement
- Returns:
- true if references SESSION schema tables, else false
-
referencesSessionSchema
public boolean referencesSessionSchema(StatementNode qt) throws StandardException
Return true if the QueryTreeNode references SESSION schema tables/views. The return value is also saved in the local field because it will be used by referencesSessionSchema() method. This method gets called when the statement is not found in cache and hence it is getting compiled. At the beginning of compilation for any statement, first we check if the statement's plan already exist in the cache. If not, then we add the statement to the cache and continue with the parsing and binding. At the end of the binding, this method gets called to see if the QueryTreeNode references a SESSION schema object. If it does, then we want to remove it from the cache, since any statements referencing SESSION schema objects should never get cached.- Returns:
- true if references SESSION schema tables/views, else false
- Throws:
StandardException
-
completeCompile
void completeCompile(StatementNode qt) throws StandardException
Makes the prepared statement valid, assigning values for its query tree, generated class, and associated information.- Parameters:
qt
- the query tree for this statement- Throws:
StandardException
- thrown on failure.
-
getActivationClass
public GeneratedClass getActivationClass() throws StandardException
Description copied from interface:ExecPreparedStatement
Get the class generated for this prepared statement. Used to confirm compatability with auxilary structures.- Specified by:
getActivationClass
in interfaceExecPreparedStatement
- Throws:
StandardException
- on error obtaining class (probably when a stored prepared statement is loading)
-
setActivationClass
void setActivationClass(GeneratedClass ac)
-
getUpdateMode
public int getUpdateMode()
the update mode of the cursor- Specified by:
getUpdateMode
in interfaceExecPreparedStatement
- Returns:
- The update mode of the cursor
-
getTargetTable
public ExecCursorTableReference getTargetTable()
the target table of the cursor- Specified by:
getTargetTable
in interfaceExecPreparedStatement
- Returns:
- target table of the cursor
-
hasUpdateColumns
public boolean hasUpdateColumns()
Description copied from interface:ExecPreparedStatement
Check if this prepared statement has a cursor with columns that can be updated.- Specified by:
hasUpdateColumns
in interfaceExecPreparedStatement
-
isUpdateColumn
public boolean isUpdateColumn(java.lang.String columnName)
Description copied from interface:ExecPreparedStatement
Check if the specified column name is one of the update columns.- Specified by:
isUpdateColumn
in interfaceExecPreparedStatement
-
getCursorInfo
public java.lang.Object getCursorInfo()
Return the cursor info in a single chunk. Used by StrorablePreparedStatement- Specified by:
getCursorInfo
in interfaceExecPreparedStatement
- Returns:
- Object the cursor info
-
setCursorInfo
void setCursorInfo(CursorInfo cursorInfo)
-
getByteCodeSaver
ByteArray getByteCodeSaver()
Get the byte code saver for this statement. Overridden for StorablePreparedStatement. We don't want to save anything- Returns:
- a byte code saver (null for us)
-
needsSavepoint
public boolean needsSavepoint()
Does this statement need a savepoint?- Specified by:
needsSavepoint
in interfaceExecPreparedStatement
- Returns:
- true if this statement needs a savepoint.
-
setNeedsSavepoint
void setNeedsSavepoint(boolean needsSavepoint)
Set the stmts 'needsSavepoint' state. Used by an SPS to convey whether the underlying stmt needs a savepoint or not.- Parameters:
needsSavepoint
- true if this statement needs a savepoint.
-
setIsAtomic
void setIsAtomic(boolean isAtomic)
Set the stmts 'isAtomic' state.- Parameters:
isAtomic
- true if this statement must be atomic (i.e. it is not ok to do a commit/rollback in the middle)
-
isAtomic
public 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.- Specified by:
isAtomic
in interfacePreparedStatement
- Returns:
- boolean Whether or not this Statement is atomic
-
setExecuteStatementNameAndSchema
void setExecuteStatementNameAndSchema(java.lang.String execStmtName, java.lang.String execSchemaName)
Set the name of the statement and schema for an "execute statement" command.
-
getClone
public ExecPreparedStatement getClone() throws StandardException
Get a new prepared statement that is a shallow copy of the current one.- Specified by:
getClone
in interfaceExecPreparedStatement
- Returns:
- a new prepared statement
- Throws:
StandardException
- on error
-
setCacheHolder
public void setCacheHolder(Cacheable cacheHolder)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isStorable
public boolean isStorable()
-
setRequiredPermissionsList
public void setRequiredPermissionsList(java.util.List<StatementPermission> requiredPermissionsList)
-
getRequiredPermissionsList
public java.util.List<StatementPermission> getRequiredPermissionsList()
- Specified by:
getRequiredPermissionsList
in interfaceExecPreparedStatement
- Returns:
- the list of permissions required to execute this statement. May be null if the database does not use SQL standard authorization
-
getVersionCounter
public final long getVersionCounter()
Description copied from interface:PreparedStatement
Get the version counter. A change in the value indicates a recompile has happened.- Specified by:
getVersionCounter
in interfacePreparedStatement
- Returns:
- version counter
-
incrementVersionCounter
public final void incrementVersionCounter()
-
incrementExecutionCount
public int incrementExecutionCount()
Description copied from interface:ExecPreparedStatement
Increment and return the execution count for this statement.- Specified by:
incrementExecutionCount
in interfaceExecPreparedStatement
- Returns:
- execution count for this statement after the last compilation
- See Also:
ExecPreparedStatement.incrementExecutionCount()
-
setStalePlanCheckInterval
public void setStalePlanCheckInterval(int interval)
Description copied from interface:ExecPreparedStatement
Set the stale plan check interval.- Specified by:
setStalePlanCheckInterval
in interfaceExecPreparedStatement
- Parameters:
interval
- the stale plan check interval- See Also:
ExecPreparedStatement.setStalePlanCheckInterval(int)
-
getStalePlanCheckInterval
public int getStalePlanCheckInterval()
Description copied from interface:ExecPreparedStatement
Get the stale plan check interval.- Specified by:
getStalePlanCheckInterval
in interfaceExecPreparedStatement
- Returns:
- the stale plan check interval, or zero if it has not been initialized yet
- See Also:
ExecPreparedStatement.getStalePlanCheckInterval()
-
getInitialRowCount
public long getInitialRowCount(int rsNum, long currentRowCount)
Description copied from interface:ExecPreparedStatement
Get the initial row count of the specified result set. If the initial row count has not yet been set, initialize it with the value of the current row count.- Specified by:
getInitialRowCount
in interfaceExecPreparedStatement
- Parameters:
rsNum
- the result set to get the initial row count forcurrentRowCount
- the current row count for the result set- Returns:
- the row count from the first execution of the result set
- See Also:
ExecPreparedStatement.getInitialRowCount(int, long)
-
getContextService
private static ContextService getContextService()
Privileged lookup of the ContextService. Must be private so that user code can't call this entry point.
-
getMonitor
private static ModuleFactory getMonitor()
Privileged Monitor lookup. Must be private so that user code can't call this entry point.
-
-