|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.impl.sql.GenericPreparedStatement
public class GenericPreparedStatement
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
Field Summary | |
---|---|
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
|
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
|
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 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 | |
---|---|
GenericPreparedStatement()
|
|
GenericPreparedStatement(Statement st)
|
Method Summary | |
---|---|
(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,
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,
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. |
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. |
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 |
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. |
(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 |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
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
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
Constructor Detail |
---|
GenericPreparedStatement()
public GenericPreparedStatement(Statement st)
Method Detail |
---|
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
otherwisepublic void rePrepare(LanguageConnectionContext lcc) throws StandardException
PreparedStatement
rePrepare
in interface PreparedStatement
lcc
- The LanguageConnectionContext.
StandardException
- thrown if unable to performpublic 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, 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.timeoutMillis
- timeout value in milliseconds.
StandardException
- Thrown on failurePreparedStatement.execute(org.apache.derby.iapi.sql.Activation, long)
private ResultSet executeStmt(Activation activation, boolean rollbackParentContext, 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.timeoutMillis
- 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 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.lang.Object[] getSavedObjects()
getSavedObjects
in interface ExecPreparedStatement
public boolean isValid()
isValid
in interface Dependent
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 LanguageConnectionContext
StandardException
- 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 LanguageConnectionContext
StandardException
- 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 statement
StandardException
- 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 ResultColumnDescriptor[] getTargetColumns()
getTargetColumns
in interface ExecPreparedStatement
public java.lang.String[] getUpdateColumns()
getUpdateColumns
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 requiredPermissionsList)
public java.util.List getRequiredPermissionsList()
getRequiredPermissionsList
in interface ExecPreparedStatement
|
Built on Thu 2010-12-23 20:49:13+0000, from revision ??? | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |