at the exact
same time, so both try to do an sps.prepare() at the
same time during code generation, so we synchronize
most everything except getters on immutable objects
just to be on the safe side.
- Author:
- jamie
Field Summary |
private java.sql.Timestamp |
compileTime
|
private UUID |
compSchemaId
|
private boolean |
initiallyCompilable
|
private static int |
INVALIDATE
|
private boolean |
lookedUpParams
|
private java.lang.String |
name
|
private java.lang.Object[] |
paramDefaults
|
private DataTypeDescriptor[] |
params
|
private ExecPreparedStatement |
preparedStatement
|
private static int |
RECOMPILE
interface to this class is:
public void prepare() throws StandardException;
public void prepareAndRelease(LanguageConnectionContext lcc)
throws StandardException;
public void prepareAndRelease(...);
public String getQualifiedName();
public char getType();
public String getTypeAsString();
public boolean isValid();
public boolean initiallyCompilable();
public java.sql.Timestamp getCompileTime();
public void setCompileTime();
public String getText();
public String getUsingText();
public void setUsingText(String usingText);
public void setUUID(UUID uuid);
public DataTypeDescriptor[] getParams() throws StandardException;
public void setParams(DataTypeDescriptor[] params);
Object[] getParameterDefaults() throws StandardException;
void setParameterDefaults(Object[] values);
public UUID getCompSchemaId();
public ExecPreparedStatement getPreparedStatement()
throws StandardException;
public ExecPreparedStatement getPreparedStatement(boolean recompIfInvalid)
throws StandardException;
public void revalidate(LanguageConnectionContext lcc)
throws StandardException;
|
private SchemaDescriptor |
sd
|
static char |
SPS_TYPE_EXPLAIN
|
static char |
SPS_TYPE_REGULAR
|
static char |
SPS_TYPE_TRIGGER
Statement types.
|
private java.lang.String |
text
|
private char |
type
|
private java.lang.String |
usingText
|
private UUID |
uuid
|
private UUIDFactory |
uuidFactory
|
private boolean |
valid
|
Fields inherited from interface org.apache.derby.catalog.Dependable |
ALIAS, COLUMNS_IN_TABLE, CONGLOMERATE, CONSTRAINT, DEFAULT, FILE, HEAP, INDEX, PREPARED_STATEMENT, SCHEMA, STORED_PREPARED_STATEMENT, TABLE, TRIGGER, VIEW |
Constructor Summary |
SPSDescriptor(DataDictionary dataDictionary,
java.lang.String name,
UUID uuid,
UUID suuid,
UUID compSchemaUUID,
char type,
boolean valid,
java.lang.String text,
java.lang.String usingText,
java.lang.Object[] paramDefaults,
boolean initiallyCompilable)
Constructor for a SPS Descriptor |
SPSDescriptor(DataDictionary dataDictionary,
java.lang.String name,
UUID uuid,
UUID suuid,
UUID compSchemaUUID,
char type,
boolean valid,
java.lang.String text,
java.lang.String usingText,
java.sql.Timestamp compileTime,
ExecPreparedStatement preparedStatement,
boolean initiallyCompilable)
Constructor for a SPS Descriptor. |
Method Summary |
private void |
compileStatement(LanguageConnectionContext lcc,
TableDescriptor triggerTable)
|
java.lang.String |
getClassType()
Get the provider's type. |
java.sql.Timestamp |
getCompileTime()
The time this prepared statement was compiled |
UUID |
getCompSchemaId()
Get the compilation type schema id when this view
was first bound. |
DependableFinder |
getDependableFinder()
Return the stored form of this provider |
java.lang.String |
getDescriptorName()
|
java.lang.String |
getDescriptorType()
Each descriptor must identify itself with its type; i.e index, check
constraint whatever. |
java.lang.String |
getName()
Gets the name of the sps. |
UUID |
getObjectID()
Get the provider's UUID |
java.lang.String |
getObjectName()
Return the name of this Provider. |
java.lang.Object[] |
getParameterDefaults()
Get the default parameter values for this
statement. |
DataTypeDescriptor[] |
getParams()
Get the array of date type descriptors for
this statement. |
ExecPreparedStatement |
getPreparedStatement()
Get the preparedStatement for this statement.
|
ExecPreparedStatement |
getPreparedStatement(boolean recompIfInvalid)
Get the preparedStatement for this statement.
|
java.lang.String |
getQualifiedName()
Gets the full, qualified name of the statement. |
SchemaDescriptor |
getSchemaDescriptor()
Gets the SchemaDescriptor for this SPS Descriptor. |
java.lang.String |
getText()
Get the text used to create this statement.
|
char |
getType()
Gets an identifier telling what type of table this is.
|
java.lang.String |
getTypeAsString()
Simple little helper function to convert your type
to a string, which is easier to use. |
java.lang.String |
getUsingText()
Get the text of the USING clause used on CREATE
or ALTER statement. |
UUID |
getUUID()
Gets the UUID of the SPS. |
boolean |
initiallyCompilable()
Is the statement initially compilable? |
boolean |
isValid()
Check that all of the dependent's dependencies are valid. |
void |
loadGeneratedClass()
Load the underlying generatd class. |
void |
makeInvalid(int action,
LanguageConnectionContext lcc)
Mark the dependent as invalid (due to at least one of
its dependencies being invalid). |
void |
makeValid(LanguageConnectionContext lcc)
Attempt to revalidate the dependent. |
void |
prepareAndRelease(LanguageConnectionContext lcc)
Generate the class for this SPS and immediately
release it. |
void |
prepareAndRelease(LanguageConnectionContext lcc,
TableDescriptor triggerTable)
FOR TRIGGERS ONLY
Generate the class for this SPS and immediately
release it. |
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). |
private UUID |
recreateUUID(java.lang.String idString)
Get the UUID for the given string |
void |
revalidate(LanguageConnectionContext lcc)
Invalidate and revalidate. |
void |
setCompileTime()
Set the compile time to now |
void |
setParameterDefaults(java.lang.Object[] values)
Set the parameter defaults for this statement. |
void |
setParams(DataTypeDescriptor[] params)
Set the list of parameters for this statement |
void |
setUsingText(java.lang.String usingText)
Set the text of the USING clause. |
void |
setUUID(UUID uuid)
Sets the UUID of the SPS. |
java.lang.String |
toString()
Prints the contents of the TableDescriptor |
private void |
updateSYSSTATEMENTS(LanguageConnectionContext lcc,
int mode,
TransactionController tc)
|
static boolean |
validType(char type)
Validate the type. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
SPS_TYPE_TRIGGER
public static final char SPS_TYPE_TRIGGER
- Statement types.
- SPS_TYPE_TRIGGER - trigger (NOT IMPLEMENTED)
- SPS_TYPE_EXPLAIN - explain (NOT IMPLEMENTED)
- SPS_TYPE_REGULAR - catchall
- See Also:
- Constant Field Values
SPS_TYPE_REGULAR
public static final char SPS_TYPE_REGULAR
- See Also:
- Constant Field Values
SPS_TYPE_EXPLAIN
public static final char SPS_TYPE_EXPLAIN
- See Also:
- Constant Field Values
RECOMPILE
private static final int RECOMPILE
- interface to this class is:
- public void prepare() throws StandardException;
- public void prepareAndRelease(LanguageConnectionContext lcc)
throws StandardException;
- public void prepareAndRelease(...);
- public String getQualifiedName();
- public char getType();
- public String getTypeAsString();
- public boolean isValid();
- public boolean initiallyCompilable();
- public java.sql.Timestamp getCompileTime();
- public void setCompileTime();
- public String getText();
- public String getUsingText();
- public void setUsingText(String usingText);
- public void setUUID(UUID uuid);
- public DataTypeDescriptor[] getParams() throws StandardException;
- public void setParams(DataTypeDescriptor[] params);
- Object[] getParameterDefaults() throws StandardException;
- void setParameterDefaults(Object[] values);
- public UUID getCompSchemaId();
- public ExecPreparedStatement getPreparedStatement()
throws StandardException;
- public ExecPreparedStatement getPreparedStatement(boolean recompIfInvalid)
throws StandardException;
- public void revalidate(LanguageConnectionContext lcc)
throws StandardException;
- See Also:
- Constant Field Values
INVALIDATE
private static final int INVALIDATE
- See Also:
- Constant Field Values
sd
private SchemaDescriptor sd
name
private java.lang.String name
uuid
private UUID uuid
compSchemaId
private UUID compSchemaId
type
private char type
valid
private boolean valid
text
private java.lang.String text
usingText
private java.lang.String usingText
preparedStatement
private ExecPreparedStatement preparedStatement
params
private DataTypeDescriptor[] params
compileTime
private java.sql.Timestamp compileTime
paramDefaults
private java.lang.Object[] paramDefaults
initiallyCompilable
private boolean initiallyCompilable
lookedUpParams
private boolean lookedUpParams
uuidFactory
private UUIDFactory uuidFactory
SPSDescriptor
public SPSDescriptor(DataDictionary dataDictionary,
java.lang.String name,
UUID uuid,
UUID suuid,
UUID compSchemaUUID,
char type,
boolean valid,
java.lang.String text,
java.lang.String usingText,
java.lang.Object[] paramDefaults,
boolean initiallyCompilable)
throws StandardException
- Constructor for a SPS Descriptor
- Parameters:
dataDictionary
- The data dictionary that this descriptor lives inname
- the SPS nameuuid
- the UUIDsuuid
- the schema UUIDcompSchemaUUID
- the schema UUID at compilation timevalid
- is the sps validtext
- the text for this statementusingText
- the text for the USING clause supplied to
CREATE or ALTER STATEMENTparamDefaults
- default values for the parameters (if
any) in this statement. Generated by a USING
clause, for use by the optimizer.initiallyCompilable
- is the statement initially compilable?
- Throws:
StandardException
- on error
SPSDescriptor
public SPSDescriptor(DataDictionary dataDictionary,
java.lang.String name,
UUID uuid,
UUID suuid,
UUID compSchemaUUID,
char type,
boolean valid,
java.lang.String text,
java.lang.String usingText,
java.sql.Timestamp compileTime,
ExecPreparedStatement preparedStatement,
boolean initiallyCompilable)
throws StandardException
- Constructor for a SPS Descriptor. Used when
constructing an SPS descriptor from a row
in SYSSTATEMENTS.
- Parameters:
dataDictionary
- The data dictionary that this descriptor lives inname
- the SPS nameuuid
- the UUIDsuuid
- the schema UUIDcompSchemaUUID
- the schema UUID at compilation timevalid
- is the sps validtext
- the text for this statementusingText
- the text for the USING clause supplied to
CREATE or ALTER STATEMENTcompileTime
- the time this was compiledpreparedStatement
- the PreparedStatementinitiallyCompilable
- is the statement initially compilable?
- Throws:
StandardException
- on error
prepareAndRelease
public final void prepareAndRelease(LanguageConnectionContext lcc,
TableDescriptor triggerTable)
throws StandardException
- FOR TRIGGERS ONLY
Generate the class for this SPS and immediately
release it. This is useful for cases where we
don't want to immediately execute the statement
corresponding to this sps (e.g. CREATE STATEMENT).
SIDE EFFECTS: will update and SYSDEPENDS
with the prepared statement dependency info.
- Parameters:
lcc
- the language connection contexttriggerTable
- the table descriptor to bind against. Had
better be null if this isn't a trigger sps.
- Throws:
StandardException
- on error
prepareAndRelease
public final void prepareAndRelease(LanguageConnectionContext lcc)
throws StandardException
- Generate the class for this SPS and immediately
release it. This is useful for cases where we
don't want to immediately execute the statement
corresponding to this sps (e.g. CREATE STATEMENT).
SIDE EFFECTS: will update and SYSDEPENDS
with the prepared statement dependency info.
- Parameters:
lcc
- the language connection context
- Throws:
StandardException
- on error
compileStatement
private void compileStatement(LanguageConnectionContext lcc,
TableDescriptor triggerTable)
throws StandardException
- Throws:
StandardException
getName
public final java.lang.String getName()
- Gets the name of the sps.
- Specified by:
getName
in interface UniqueSQLObjectDescriptor
- Returns:
- A String containing the name of the statement.
getQualifiedName
public final java.lang.String getQualifiedName()
- Gets the full, qualified name of the statement.
- Returns:
- A String containing the name of the statement.
getSchemaDescriptor
public final SchemaDescriptor getSchemaDescriptor()
- Gets the SchemaDescriptor for this SPS Descriptor.
- Specified by:
getSchemaDescriptor
in interface UniqueSQLObjectDescriptor
- Returns:
- SchemaDescriptor The SchemaDescriptor.
getType
public final char getType()
- Gets an identifier telling what type of table this is.
Types match final ints in this interface. Currently
returns SPS_TYPE_REGULAR or SPS_TYPE_TRIGGER.
- Returns:
- An identifier telling what type of statement
we are.
getTypeAsString
public final java.lang.String getTypeAsString()
- Simple little helper function to convert your type
to a string, which is easier to use.
- Returns:
- type as a string
initiallyCompilable
public boolean initiallyCompilable()
- Is the statement initially compilable?
- Returns:
- false if statement was created with the NOCOMPILE flag
true otherwise
validType
public static final boolean validType(char type)
- Validate the type. NOTE: Only SPS_TYPE_REGULAR
and SPS_TYPE_TRIGGER are currently valid.
- Parameters:
type
- the type
- Returns:
- true/false
getCompileTime
public final java.sql.Timestamp getCompileTime()
- The time this prepared statement was compiled
- Returns:
- the time this class was last compiled
setCompileTime
public final void setCompileTime()
- Set the compile time to now
getText
public final java.lang.String getText()
- Get the text used to create this statement.
Returns original text in a cleartext string.
- Returns:
- The text
getUsingText
public final java.lang.String getUsingText()
- Get the text of the USING clause used on CREATE
or ALTER statement.
- Returns:
- The text
setUsingText
public final void setUsingText(java.lang.String usingText)
- Set the text of the USING clause. Used by
ALTER statement.
- Parameters:
usingText
- the new value for the USING text
setUUID
public final void setUUID(UUID uuid)
- Sets the UUID of the SPS.
- Parameters:
uuid
- The UUID of the SPS to be set in the descriptor
getUUID
public final UUID getUUID()
- Gets the UUID of the SPS.
- Specified by:
getUUID
in interface UniqueTupleDescriptor
- Returns:
- the uuid
getParams
public final DataTypeDescriptor[] getParams()
throws StandardException
- Get the array of date type descriptors for
this statement. Currently, we do a lookup
if we don't already have the parameters saved.
When SPSes are cached, the parameters should
be set up when the sps is constructed.
- Returns:
- the array of data type descriptors
- Throws:
StandardException
- on error
setParams
public final void setParams(DataTypeDescriptor[] params)
- Set the list of parameters for this statement
- Parameters:
params
- the parameter list
getParameterDefaults
public final java.lang.Object[] getParameterDefaults()
throws StandardException
- Get the default parameter values for this
statement. Default parameter values are
supplied by a USING clause on either a
CREATE or ALTER STATEMENT statement.
- Returns:
- the default parameter values
- Throws:
StandardException
- on error
setParameterDefaults
public final void setParameterDefaults(java.lang.Object[] values)
- Set the parameter defaults for this statement.
getPreparedStatement
public final ExecPreparedStatement getPreparedStatement()
throws StandardException
- Get the preparedStatement for this statement.
If stmt is invalid or hasn't been compiled yet,
it will be recompiled.
- Returns:
- the preparedStatement
- Throws:
StandardException
- on error
getPreparedStatement
public final ExecPreparedStatement getPreparedStatement(boolean recompIfInvalid)
throws StandardException
- Get the preparedStatement for this statement.
Expects the prepared statement to have already
been added to SYS.SYSSTATEMENTS.
Side Effects: will update SYS.SYSSTATEMENTS with
the new plan if it needs to be recompiled.
- Parameters:
recompIfInvalid
- if false, never recompile even
if statement is invalid
- Returns:
- the preparedStatement
- Throws:
StandardException
- on error
getCompSchemaId
public final UUID getCompSchemaId()
- Get the compilation type schema id when this view
was first bound.
- Returns:
- the schema UUID
toString
public final java.lang.String toString()
- Prints the contents of the TableDescriptor
- Returns:
- The contents as a String
getDependableFinder
public final DependableFinder getDependableFinder()
- Return the stored form of this provider
- Specified by:
getDependableFinder
in interface Dependable
- Returns:
- A Finder object that can be written to disk if this is a
Persistent Dependable.
Null if this is not a persistent dependable.
- See Also:
Dependable.getDependableFinder()
getObjectName
public final java.lang.String getObjectName()
- Return the name of this Provider. (Useful for errors.)
- Specified by:
getObjectName
in interface Dependable
- Returns:
- String The name of this provider.
getObjectID
public final UUID getObjectID()
- Get the provider's UUID
- Specified by:
getObjectID
in interface Dependable
- Returns:
- String The provider's UUID
getClassType
public final java.lang.String getClassType()
- Get the provider's type.
- Specified by:
getClassType
in interface Dependable
- Returns:
- String The provider's type.
isValid
public final boolean isValid()
- Check that all of the dependent's dependencies are valid.
- Specified by:
isValid
in interface Dependent
- Returns:
- true if the dependent is currently valid
prepareToInvalidate
public final 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 interface Dependent
- Parameters:
action
- The action causing the invalidationp
- the providerlcc
- The LanguageConnectionContext
- Throws:
StandardException
- thrown if unable to make it invalid
makeInvalid
public final 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 interface Dependent
- Parameters:
action
- The action causing the invalidationlcc
- The LanguageConnectionContext
- Throws:
StandardException
- thrown if unable to make it invalid
makeValid
public final void makeValid(LanguageConnectionContext lcc)
throws StandardException
- Attempt to revalidate the dependent. For prepared statements,
this could go through its dependencies and check that they
are up to date; if not, it would recompile the statement.
Any failure during this attempt should throw
StandardException.unableToRevalidate().
- Specified by:
makeValid
in interface Dependent
- Parameters:
lcc
- The LanguageConnectionContext
- Throws:
StandardException
- thrown if unable to make it valid
revalidate
public final void revalidate(LanguageConnectionContext lcc)
throws StandardException
- Invalidate and revalidate. The functional equivalent
of calling makeInvalid() and makeValid(), except it
is optimized.
- Throws:
StandardException
- on error
loadGeneratedClass
public void loadGeneratedClass()
throws StandardException
- Load the underlying generatd class. This is not expected
to be used outside of the datadictionary package. It
is used for optimizing class loading for sps
cacheing.
- Throws:
StandardException
- on error
updateSYSSTATEMENTS
private void updateSYSSTATEMENTS(LanguageConnectionContext lcc,
int mode,
TransactionController tc)
throws StandardException
- Throws:
StandardException
recreateUUID
private UUID recreateUUID(java.lang.String idString)
- Get the UUID for the given string
- Returns:
- the UUID
getDescriptorType
public java.lang.String getDescriptorType()
- Description copied from class:
TupleDescriptor
- Each descriptor must identify itself with its type; i.e index, check
constraint whatever.
- Overrides:
getDescriptorType
in class TupleDescriptor
- See Also:
TupleDescriptor.getDescriptorType()
getDescriptorName
public java.lang.String getDescriptorName()
- Overrides:
getDescriptorName
in class TupleDescriptor
- See Also:
TupleDescriptor.getDescriptorName()
Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.