Top Description Inners Fields Constructors Methods
org.apache.derby.impl.sql

public Class GenericPreparedStatement

extends Object
implements ExecPreparedStatement
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.sql.execute.ExecPreparedStatement, org.apache.derby.iapi.sql.PreparedStatement, org.apache.derby.iapi.sql.depend.Dependent, org.apache.derby.catalog.Dependable
Known Direct Subclasses
org.apache.derby.impl.sql.GenericStorablePreparedStatement
Imports
java.sql.SQLWarning, .Timestamp, java.util.ArrayList, .Collections, .List, org.apache.derby.catalog.Dependable, .DependableFinder, .UUID, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.cache.Cacheable, org.apache.derby.iapi.services.context.ContextManager, .ContextService, org.apache.derby.shared.common.util.ArrayUtil, org.apache.derby.iapi.services.loader.GeneratedClass, org.apache.derby.iapi.services.monitor.ModuleFactory, .Monitor, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.shared.common.stream.HeaderPrintWriter, org.apache.derby.iapi.services.uuid.UUIDFactory, org.apache.derby.iapi.sql.Activation, .ParameterValueSet, .PreparedStatement, .ResultDescription, .ResultSet, .Statement, org.apache.derby.iapi.sql.conn.LanguageConnectionContext, .StatementContext, org.apache.derby.iapi.sql.depend.DependencyManager, .Provider, org.apache.derby.iapi.sql.dictionary.DataDictionary, .SPSDescriptor, .SchemaDescriptor, .StatementPermission, org.apache.derby.iapi.sql.execute.ConstantAction, .ExecCursorTableReference, .ExecPreparedStatement, org.apache.derby.iapi.types.DataTypeDescriptor, .DataTypeUtilities, org.apache.derby.iapi.util.ByteArray, org.apache.derby.impl.sql.compile.CursorNode, .StatementNode

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 and Inner Type Summary

Modifier and TypeClass 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.

Field Summary

Modifier and TypeField and Description
protected GeneratedClass
protected Timestamp
protected long
private Cacheable
cacheHolder

If non-null then this object is the cacheable that holds us in the cache.

protected long
private boolean
protected Timestamp
private String
private String
protected ConstantAction
protected long
private int
pack-priv boolean
invalidatedWhileCompiling

True if the statement was invalidated while it was being compiled.

protected boolean
protected boolean
private boolean
protected long
protected DataTypeDescriptor[]
protected long
private boolean
protected List<StatementPermission>
protected ResultDescription
private GenericPreparedStatement.RowCountStatistics
rowCountStats

Holder for row counts and execution count.

protected Object[]
protected String
protected boolean
private String
public Statement
protected ExecCursorTableReference
protected List<String>
protected int
protected String
protected UUID
private long
versionCounter

Incremented for each (re)compile.

private SQLWarning

Constructor Summary

AccessConstructor and Description
pack-priv
public

Method Summary

Modifier and TypeMethod and Description
pack-priv final synchronized void
beginCompiling()

Signal that the statement is about to be compiled.

pack-priv void
completeCompile(StatementNode
the query tree for this statement
qt
)

Makes the prepared statement valid, assigning values for its query tree, generated class, and associated information.

pack-priv final synchronized void
endCompiling()

Signal that we're done compiling the statement and unblock others that are waiting for the compilation to finish.

public ResultSet
execute(Activation
The activation containing all the local state to execute the plan.
activation
,
boolean
true if this is a meta-data query
forMetaData
,
long
timeout value in milliseconds.
timeoutMillis
)

Implements org.apache.derby.iapi.sql.PreparedStatement.execute.

Execute the PreparedStatement and return results, used for top level statements (not substatements) in a connection.

private ResultSet

Returns:

the result set to be pawed through
executeStmt
(Activation
the activation to run.
activation
,
boolean
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.
rollbackParentContext
,
boolean
true if this is a meta-data query
forMetaData
,
long
timeout value in milliseconds.
timeoutMillis
)

The guts of execution.

public ResultSet
executeSubStatement(LanguageConnectionContext
language connection context
lcc
,
boolean
True if in the event of a statement-level exception, the parent context needs to be rolled back, too.
rollbackParentContext
,
long
timeout value in milliseconds.
timeoutMillis
)

Implements org.apache.derby.iapi.sql.PreparedStatement.executeSubStatement.

Execute a statement as part of another statement (without a nested connection) and return results.

public ResultSet
executeSubStatement(Activation
The activation of the superstatement
parent
,
Activation
The activation containing all the local state to execute the plan for substatement
activation
,
boolean
True if in the event of a statement-level exception, the parent context needs to be rolled back, too.
rollbackParentContext
,
long
timeout value in milliseconds.
timeoutMillis
)

Implements org.apache.derby.iapi.sql.PreparedStatement.executeSubStatement.

Execute a statement as part of another statement (ithout a nested connection) and return results.

public void
finish(LanguageConnectionContext lcc)

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.finish.

Finish marks a statement as totally unusable.

public Activation
getActivation(LanguageConnectionContext
The LanguageConnectionContext.
lcc
,
boolean
Scrollability
scrollable
)

Implements org.apache.derby.iapi.sql.PreparedStatement.getActivation.

Get a new activation instance.

public GeneratedClass
getActivationClass()

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.getActivationClass.

Get the class generated for this prepared statement.

public Timestamp

Returns:

Timestamp The timestamp for the beginning of compilation.
getBeginCompileTimestamp
()

Implements org.apache.derby.iapi.sql.PreparedStatement.getBeginCompileTimestamp.

Get the timestamp for the beginning of compilation

public long

Returns:

long The bind time for the associated query in milliseconds.
getBindTimeInMillis
()

Implements org.apache.derby.iapi.sql.PreparedStatement.getBindTimeInMillis.

Get the bind time for the associated query in milliseconds.

pack-priv ByteArray

Returns:

a byte code saver (null for us)
getByteCodeSaver
()

Get the byte code saver for this statement.

public String

Returns:

String Classname that this Dependable belongs to.
getClassType
()

Implements org.apache.derby.catalog.Dependable.getClassType.

Get the Dependable's class type.

public ExecPreparedStatement

Returns:

a new prepared statement
getClone
()

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.getClone.

Get a new prepared statement that is a shallow copy of the current one.

public long

Returns:

long The total compile time for the associated query in milliseconds.
getCompileTimeInMillis
()

Implements org.apache.derby.iapi.sql.PreparedStatement.getCompileTimeInMillis.

Get the total compile time for the associated query in milliseconds.

public final SQLWarning
public final ConstantAction

Returns:

ConstantAction The big structure enclosing the Execution constants.
getConstantAction
()

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.getConstantAction.

Get the Execution constants.

private static ContextService
getContextService()

Must be private so that user code can't call this entry point.

public Object
getCursorInfo()

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.getCursorInfo.

Return the cursor info in a single chunk.

public DependableFinder

Returns:

the stored form of this Dependable
getDependableFinder
()

Implements org.apache.derby.catalog.Dependable.getDependableFinder.

Get an object which can be written to disk and which, when read from disk, will find or reconstruct this in-memory Dependable.

public Timestamp

Returns:

Timestamp The timestamp for the end of compilation.
getEndCompileTimestamp
()

Implements org.apache.derby.iapi.sql.PreparedStatement.getEndCompileTimestamp.

Get the timestamp for the end of compilation

public long

Returns:

long The generate time for the associated query in milliseconds.
getGenerateTimeInMillis
()

Implements org.apache.derby.iapi.sql.PreparedStatement.getGenerateTimeInMillis.

Get the generate time for the associated query in milliseconds.

public long
getInitialRowCount(int
the result set to get the initial row count for
rsNum
,
long
the current row count for the result set
currentRowCount
)

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.getInitialRowCount.

Get the initial row count of the specified result set.

private static ModuleFactory
getMonitor()

Must be private so that user code can't call this entry point.

public UUID

Returns:

String The Dependable's UUID String.
getObjectID
()

Implements org.apache.derby.catalog.Dependable.getObjectID.

Get the Dependable's UUID String.

public String

Returns:

String The name of this Dependable..
getObjectName
()

Implements org.apache.derby.catalog.Dependable.getObjectName.

Return the name of this Dependable.

public long

Returns:

long The optimize time for the associated query in milliseconds.
getOptimizeTimeInMillis
()

Implements org.apache.derby.iapi.sql.PreparedStatement.getOptimizeTimeInMillis.

Get the optimize time for the associated query in milliseconds.

public DataTypeDescriptor
getParameterType(int
The 0-based index of the parameter
idx
)

Implements org.apache.derby.iapi.sql.PreparedStatement.getParameterType.

Return the type of the parameter (0-based indexing)

public DataTypeDescriptor[]
getParameterTypes()

Implements org.apache.derby.iapi.sql.PreparedStatement.getParameterTypes.

Get an array of DataTypeDescriptors describing the types of the parameters of this PreparedStatement.

public long

Returns:

long The parse time for the associated query in milliseconds.
getParseTimeInMillis
()

Implements org.apache.derby.iapi.sql.PreparedStatement.getParseTimeInMillis.

Get the parse time for the associated query in milliseconds.

public List<StatementPermission>
public ResultDescription
getResultDescription()

Implements org.apache.derby.iapi.sql.PreparedStatement.getResultDescription.

Get the ResultDescription for the statement.

public final Object

Returns:

the requested saved object.
getSavedObject
(int
The object to get.
objectNum
)

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.getSavedObject.

Get the specified saved object.

public final List<Object>

Returns:

all the saved objects
getSavedObjects
()

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.getSavedObjects.

Get the saved objects.

public String
getSource()

Implements org.apache.derby.iapi.sql.PreparedStatement.getSource.

Return the SQL string that this statement is for.

public String
getSPSName()

Implements org.apache.derby.iapi.sql.PreparedStatement.getSPSName.

Return the SPS Name for this statement.

public int
public ExecCursorTableReference

Returns:

target table of the cursor
getTargetTable
()

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.getTargetTable.

the target table of the cursor

public int

Returns:

The update mode of the cursor
getUpdateMode
()

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.getUpdateMode.

the update mode of the cursor

public final long
public boolean
hasUpdateColumns()

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.hasUpdateColumns.

Check if this prepared statement has a cursor with columns that can be updated.

public int
incrementExecutionCount()

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.incrementExecutionCount.

Increment and return the execution count for this statement.

public final void
public boolean

Returns:

boolean Whether or not this Statement is atomic
isAtomic
()

Implements org.apache.derby.iapi.sql.PreparedStatement.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.

pack-priv final synchronized boolean
isCompiling()

Check if this statement is currently being compiled.

public boolean

Returns:

boolean Whether or not this dependent is persistent.
isPersistent
()

Implements org.apache.derby.catalog.Dependable.isPersistent.

Is this dependent persistent?

public boolean
public boolean
isUpdateColumn(String columnName)

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.isUpdateColumn.

Check if the specified column name is one of the update columns.

private boolean

Returns:

true if this statement is up to date, false otherwise
isUpToDate
()

Unsynchronized helper method for upToDate() and upToDate(GeneratedClass).

public boolean

Returns:

true if the dependent is currently valid
isValid
()

Implements org.apache.derby.iapi.sql.depend.Dependent.isValid.

Check that all of the dependent's dependencies are valid.

public void
makeInvalid(int
The action causing the invalidation
action
,
LanguageConnectionContext
The LanguageConnectionContext
lcc
)

Implements org.apache.derby.iapi.sql.depend.Dependent.makeInvalid.

Mark the dependent as invalid (due to at least one of its dependencies being invalid).

public boolean

Returns:

true if this statement needs a savepoint.
needsSavepoint
()

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.needsSavepoint.

Does this statement need a savepoint?

public void
prepareToInvalidate(Provider
the provider
p
,
int
The action causing the invalidation
action
,
LanguageConnectionContext
The LanguageConnectionContext
lcc
)

Implements org.apache.derby.iapi.sql.depend.Dependent.prepareToInvalidate.

Prepare to mark the dependent as invalid (due to at least one of its dependencies being invalid).

public boolean

Returns:

true if references SESSION schema tables, else false
referencesSessionSchema
()

Implements org.apache.derby.iapi.sql.PreparedStatement.referencesSessionSchema.

Return true if the query node for this statement references SESSION schema tables/views.

public boolean

Returns:

true if references SESSION schema tables/views, else false
referencesSessionSchema
(StatementNode qt)

Return true if the QueryTreeNode references SESSION schema tables/views.

public void
rePrepare(LanguageConnectionContext
The LanguageConnectionContext.
lcc
)

Implements org.apache.derby.iapi.sql.PreparedStatement.rePrepare.

Re-prepare the statement if it is not up to date or, if requested, simply not optimal.

public void
rePrepare(LanguageConnectionContext lcc, boolean forMetaData)

pack-priv void
public void
protected void
setCompileTimeMillis(long parseTime, long bindTime, long optimizeTime, long generateTime, long
The compile time
compileTime
,
Timestamp beginCompileTimestamp, Timestamp endCompileTimestamp)

Set the compile time for this prepared statement.

pack-priv void
pack-priv final void
setConstantAction(ConstantAction
The big structure enclosing the Execution constants.
constantAction
)

Set the Execution constants.

pack-priv void
pack-priv void
setExecuteStatementNameAndSchema(String execStmtName, String execSchemaName)

Set the name of the statement and schema for an "execute statement" command.

pack-priv void
setIsAtomic(boolean
true if this statement must be atomic (i.e. it is not ok to do a commit/rollback in the middle)
isAtomic
)

Set the stmts 'isAtomic' state.

pack-priv void
setNeedsSavepoint(boolean
true if this statement needs a savepoint.
needsSavepoint
)

Set the stmts 'needsSavepoint' state.

public void
pack-priv final void
setSavedObjects(Object[]
The objects to save from compilation
objects
)

Set the saved objects.

public void
setSource(String
the source text
text
)

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.setSource.

set the statement text

public void
setSPSAction()

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.setSPSAction.

Indicate this prepared statement is an SPS action, currently used by GenericTriggerExecutor.

public final void
public void
setStalePlanCheckInterval(int
the stale plan check interval
interval
)

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.setStalePlanCheckInterval.

Set the stale plan check interval.

public void
setValid()

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.setValid.

set this prepared statement to be valid, currently used by GenericTriggerExecutor.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public synchronized boolean
upToDate()

Implements org.apache.derby.iapi.sql.PreparedStatement.upToDate.

Checks whether this PreparedStatement is up to date.

public synchronized boolean
upToDate(GeneratedClass
a generated class that must be identical to getActivationClass() for this method to return true
gc
)

Implements org.apache.derby.iapi.sql.execute.ExecPreparedStatement.upToDate.

Check whether this statement is up to date and its generated class is identical to the supplied class object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait