Class SPSDescriptor
- All Implemented Interfaces:
Dependable
,Dependent
,Provider
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Timestamp
private final UUID
private final boolean
private static final int
private boolean
private final String
private Object[]
Old code - never used.private DataTypeDescriptor[]
private ExecPreparedStatement
private static final int
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 final SchemaDescriptor
static final char
static final char
static final char
Statement types.private String
private final char
private final String
private final UUID
private UUIDFactory
private boolean
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
ConstructorsConstructorDescriptionSPSDescriptor
(DataDictionary dataDictionary, String name, UUID uuid, UUID suuid, UUID compSchemaUUID, char type, boolean valid, String text, boolean initiallyCompilable) Constructor for a SPS DescriptorSPSDescriptor
(DataDictionary dataDictionary, String name, UUID uuid, UUID suuid, UUID compSchemaUUID, char type, boolean valid, String text, String usingText, Timestamp compileTime, ExecPreparedStatement preparedStatement, boolean initiallyCompilable) Constructor for a SPS Descriptor. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
compileStatement
(LanguageConnectionContext lcc, TableDescriptor triggerTable, TransactionController tc) Compiles this SPS.final String
Get the provider's type.final Timestamp
The time this prepared statement was compiledfinal UUID
Get the compilation type schema id when this view was first bound.private static ContextService
Privileged lookup of the ContextService.final DependableFinder
Return the stored form of this providerEach descriptor must identify itself with its type; i.e index, check constraint whatever.final String
getName()
Gets the name of the sps.final UUID
Get the provider's UUIDfinal String
Return the name of this Provider.final Object[]
Get the default parameter values for this statement.final DataTypeDescriptor[]
Get the array of date type descriptors for this statement.final ExecPreparedStatement
Get the preparedStatement for this statement.final ExecPreparedStatement
getPreparedStatement
(boolean recompIfInvalid) Get the preparedStatement for this statement.final String
Gets the full, qualified name of the statement.final SchemaDescriptor
Gets the SchemaDescriptor for this SPS Descriptor.final String
getText()
Get the text used to create this statement.final char
getType()
Gets an identifier telling what type of table this is.final String
Simple little helper function to convert your type to a string, which is easier to use.final String
Get the text of the USING clause used on CREATE or ALTER statement.final UUID
getUUID()
Gets the UUID of the SPS.boolean
Is the statement initially compilable?final boolean
isValid()
Check that all of the dependent's dependencies are valid.void
Load the underlying generatd class.final void
makeInvalid
(int action, LanguageConnectionContext lcc) Mark the dependent as invalid (due to at least one of its dependencies being invalid).final void
Generate the class for this SPS and immediately release it.final void
prepareAndRelease
(LanguageConnectionContext lcc, TableDescriptor triggerTable) FOR TRIGGERS ONLYfinal void
prepareAndRelease
(LanguageConnectionContext lcc, TableDescriptor triggerTable, TransactionController tc) FOR TRIGGERS ONLYfinal 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
(String idString) Get the UUID for the given stringfinal void
Invalidate and revalidate.final void
Set the compile time to nowfinal void
setParameterDefaults
(Object[] values) Set the parameter defaults for this statement.final void
setParams
(DataTypeDescriptor[] params) Set the list of parameters for this statementfinal void
It is possible that when a trigger is invalidated, the generated trigger action sql associated with it needs to be regenerated.final String
toString()
Prints the contents of the TableDescriptorprivate void
updateSYSSTATEMENTS
(LanguageConnectionContext lcc, int mode, TransactionController tc) static boolean
validType
(char type) Validate the type.Methods inherited from class org.apache.derby.iapi.sql.dictionary.TupleDescriptor
getColumnDependableFinder, getDataDictionary, getDependableFinder, isPersistent, setDataDictionary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.derby.catalog.Dependable
isPersistent
-
Field Details
-
SPS_TYPE_TRIGGER
public static final char SPS_TYPE_TRIGGERStatement types.- SPS_TYPE_TRIGGER - trigger
- SPS_TYPE_EXPLAIN - explain (NOT IMPLEMENTED)
- SPS_TYPE_REGULAR - catchall
- See Also:
-
SPS_TYPE_REGULAR
public static final char SPS_TYPE_REGULAR- See Also:
-
SPS_TYPE_EXPLAIN
public static final char SPS_TYPE_EXPLAIN- See Also:
-
RECOMPILE
private static final int RECOMPILEinterface 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:
-
INVALIDATE
private static final int INVALIDATE- See Also:
-
sd
-
name
-
compSchemaId
-
type
private final char type -
text
-
usingText
-
uuid
-
valid
private boolean valid -
preparedStatement
-
params
-
compileTime
-
paramDefaults
Old code - never used. -
initiallyCompilable
private final boolean initiallyCompilable -
lookedUpParams
private boolean lookedUpParams -
uuidFactory
-
-
Constructor Details
-
SPSDescriptor
public SPSDescriptor(DataDictionary dataDictionary, String name, UUID uuid, UUID suuid, UUID compSchemaUUID, char type, boolean valid, String text, 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 timetype
- typevalid
- is the sps validtext
- the text for this statementinitiallyCompilable
- is the statement initially compilable?- Throws:
StandardException
- on error
-
SPSDescriptor
public SPSDescriptor(DataDictionary dataDictionary, String name, UUID uuid, UUID suuid, UUID compSchemaUUID, char type, boolean valid, String text, String usingText, 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 timetype
- typevalid
- 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
-
-
Method Details
-
prepareAndRelease
public final void prepareAndRelease(LanguageConnectionContext lcc, TableDescriptor triggerTable, TransactionController tc) throws StandardException FOR TRIGGERS ONLYGenerate 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.tc
- the transaction controller- Throws:
StandardException
- on error
-
prepareAndRelease
public final void prepareAndRelease(LanguageConnectionContext lcc, TableDescriptor triggerTable) throws StandardException FOR TRIGGERS ONLYGenerate 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
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, TransactionController tc) throws StandardException Compiles this SPS.Note: This SPS may still be marked as invalid after this method has completed, because an invalidation request may have been received while compiling.
- Parameters:
lcc
- connectiontriggerTable
- subject table (may benull
)tc
- transaction controller to use (may benull
)- Throws:
StandardException
- if something fails
-
getName
Gets the name of the sps.- Specified by:
getName
in classUniqueSQLObjectDescriptor
- Returns:
- A String containing the name of the statement.
-
getQualifiedName
Gets the full, qualified name of the statement.- Returns:
- A String containing the name of the statement.
-
getSchemaDescriptor
Gets the SchemaDescriptor for this SPS Descriptor.- Specified by:
getSchemaDescriptor
in classUniqueSQLObjectDescriptor
- 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
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 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
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
Get the text used to create this statement. Returns original text in a cleartext string.- Returns:
- The text
-
setText
It is possible that when a trigger is invalidated, the generated trigger action sql associated with it needs to be regenerated. One example of such a case would be when ALTER TABLE on the trigger table changes the length of a column. The need for this code was found as part of DERBY-4874 where the Alter table had changed the length of a varchar column from varchar(30) to varchar(64) but the generated trigger action plan continued to use varchar(30). To fix varchar(30) in in trigger action sql to varchar(64), we need to regenerate the trigger action sql which is saved as stored prepared statement. This new trigger action sql will then get updated into SYSSTATEMENTS table. DERBY-4874- Parameters:
newText
-
-
getUsingText
Get the text of the USING clause used on CREATE or ALTER statement.- Returns:
- The text
-
getUUID
Gets the UUID of the SPS.- Specified by:
getUUID
in classUniqueTupleDescriptor
- Returns:
- The UUID.
-
getParams
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
Set the list of parameters for this statement- Parameters:
params
- the parameter list
-
getParameterDefaults
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
Set the parameter defaults for this statement.- Parameters:
values
- the parameter defaults
-
getPreparedStatement
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
Get the compilation type schema id when this view was first bound.- Returns:
- the schema UUID
-
toString
Prints the contents of the TableDescriptor -
getDependableFinder
Return the stored form of this provider- Specified by:
getDependableFinder
in interfaceDependable
- 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:
-
getObjectName
Return the name of this Provider. (Useful for errors.)- Specified by:
getObjectName
in interfaceDependable
- Returns:
- String The name of this provider.
-
getObjectID
Get the provider's UUID- Specified by:
getObjectID
in interfaceDependable
- Returns:
- String The provider's UUID
-
getClassType
Get the provider's type.- Specified by:
getClassType
in interfaceDependable
- Returns:
- String The provider's type.
-
isValid
public final boolean isValid()Check that all of the dependent's dependencies are 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 interfaceDependent
- Parameters:
p
- the provideraction
- The action causing the invalidationlcc
- The LanguageConnectionContext- Throws:
StandardException
- thrown if unable to make it invalid
-
makeInvalid
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
- thrown if unable to make it invalid
-
revalidate
Invalidate and revalidate. The functional equivalent of calling makeInvalid() and makeValid(), except it is optimized.- Throws:
StandardException
- on error
-
loadGeneratedClass
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
Get the UUID for the given string- Parameters:
idString
- the string- Returns:
- the UUID
-
getDescriptorType
Description copied from class:TupleDescriptor
Each descriptor must identify itself with its type; i.e index, check constraint whatever.- Overrides:
getDescriptorType
in classTupleDescriptor
- See Also:
-
getDescriptorName
- Overrides:
getDescriptorName
in classTupleDescriptor
- See Also:
-
getContextService
Privileged lookup of the ContextService. Must be private so that user code can't call this entry point.
-