Synchronization
Stored prepared statements may be cached. Thus they may be shared by multiple threads. It is very hard for two threads to try to muck with an sps simultaeously because all ddl (including sps recompilation) clears out the sps cache and invalidates whatever statement held a cached sps. But it is possible for two statements to do a prepare execute statment 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.
| Modifier and Type | Field and Description |
|---|---|
| private Timestamp | |
| private final UUID | |
| private final boolean | |
| private static final int | |
| private boolean | |
| private final String | |
| private Object[] | paramDefaults
Old code - never used. |
| private DataTypeDescriptor[] | |
| private ExecPreparedStatement | |
| private static final int | RECOMPILE
interface to this class is:
|
| private final SchemaDescriptor | |
| public static final char | |
| public static final char | |
| public static final char | SPS_TYPE_TRIGGER
Statement types. |
| private String | |
| private final char | |
| private final String | |
| private final UUID | |
| private UUIDFactory | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | SPSDescriptor(DataDictionary
The data dictionary that this descriptor lives in dataDictionary, String the SPS name name, UUID the UUID uuid, UUID the schema UUID suuid, UUID the schema UUID at compilation time compSchemaUUID, char type type, boolean is the sps valid valid, String the text for this statement text, boolean is the statement initially compilable? initiallyCompilable)Constructor for a SPS Descriptor |
| public | SPSDescriptor(DataDictionary
The data dictionary that this descriptor lives in dataDictionary, String the SPS name name, UUID the UUID uuid, UUID the schema UUID suuid, UUID the schema UUID at compilation time compSchemaUUID, char type type, boolean is the sps valid valid, String the text for this statement text, String the text for the USING clause supplied to
CREATE or ALTER STATEMENT usingText, Timestamp the time this was compiled compileTime, ExecPreparedStatement the PreparedStatement preparedStatement, boolean is the statement initially compilable? initiallyCompilable)Constructor for a SPS Descriptor. |
| Modifier and Type | Method and Description |
|---|---|
| private void | compileStatement(LanguageConnectionContext
connection lcc, TableDescriptor subject table (may be triggerTable, TransactionController null)transaction controller to use (may be tc)null)Compiles this SPS. |
| public final String | Returns: String The provider's type.Implements org. Get the provider's type. |
| public final synchronized Timestamp | Returns: the time this class was last compiledThe time this prepared statement was compiled |
| public final UUID | Returns: the schema UUIDGet the compilation type schema id when this view was first bound. |
| private static ContextService | |
| public final DependableFinder | getDependableFinder()
Implements org. Return the stored form of this provider |
| public String | |
| public String | getDescriptorType()
Overrides org. Each descriptor must identify itself with its type; i.e index, check constraint whatever. |
| public final String | Returns: A String containing the name of the statement.Implements abstract org. Gets the name of the sps. |
| public final UUID | Returns: String The provider's UUIDImplements org. Get the provider's UUID |
| public final String | Returns: String The name of this provider.Implements org. Return the name of this Provider. |
| public final synchronized Object[] | Returns: the default parameter valuesGet the default parameter values for this statement. |
| public final synchronized DataTypeDescriptor[] | Returns: the array of data type descriptorsGet the array of date type descriptors for this statement. |
| public final ExecPreparedStatement | |
| public final synchronized ExecPreparedStatement | Returns: the preparedStatementif false, never recompile even
if statement is invalid recompIfInvalid)Get the preparedStatement for this statement. |
| public final String | Returns: A String containing the name of the statement.Gets the full, qualified name of the statement. |
| public final SchemaDescriptor | Returns: SchemaDescriptor The SchemaDescriptor.Implements abstract org. Gets the SchemaDescriptor for this SPS Descriptor. |
| public final synchronized String | |
| public final char | Returns: An identifier telling what type of statement we are.Gets an identifier telling what type of table this is. |
| public final String | Returns: type as a stringSimple little helper function to convert your type to a string, which is easier to use. |
| public final String | |
| public final UUID | Returns: The UUID.Implements abstract org. Gets the UUID of the SPS. |
| public boolean | Returns: false if statement was created with the NOCOMPILE flag true otherwiseIs the statement initially compilable? |
| public final synchronized boolean | Returns: true if the dependent is currently validImplements org. Check that all of the dependent's dependencies are valid. |
| public void | |
| public final synchronized void | makeInvalid(int
The action causing the invalidation action, LanguageConnectionContext The LanguageConnectionContext lcc)Implements org. Mark the dependent as invalid (due to at least one of its dependencies being invalid). |
| public final synchronized void | prepareAndRelease(LanguageConnectionContext
the language connection context lcc, TableDescriptor the table descriptor to bind against. Had
better be null if this isn't a trigger sps. triggerTable, TransactionController the transaction controller tc)FOR TRIGGERS ONLY Generate the class for this SPS and immediately release it. |
| public final synchronized void | prepareAndRelease(LanguageConnectionContext
the language connection context lcc, TableDescriptor the table descriptor to bind against. Had
better be null if this isn't a trigger sps. triggerTable)FOR TRIGGERS ONLY Generate the class for this SPS and immediately release it. |
| public final synchronized void | prepareAndRelease(LanguageConnectionContext
the language connection context lcc)Generate the class for this SPS and immediately release it. |
| public final void | prepareToInvalidate(Provider
the provider p, int The action causing the invalidation action, LanguageConnectionContext The LanguageConnectionContext lcc)Implements org. Prepare to mark the dependent as invalid (due to at least one of its dependencies being invalid). |
| private UUID | |
| public final synchronized void | |
| public final synchronized void | |
| public final synchronized void | setParameterDefaults(Object[]
the parameter defaults values)Set the parameter defaults for this statement. |
| public final synchronized void | setParams(DataTypeDescriptor[]
the parameter list params)Set the list of parameters for this statement |
| public final synchronized void | |
| public final String | Returns: The contents as a StringOverrides java. Prints the contents of the TableDescriptor |
| private void | |
| public static boolean | Returns: true/falsethe type type)Validate the type Note Only SPS_TYPE_REGULAR and SPS_TYPE_TRIGGER are currently valid. |
| compileTime | back to summary |
|---|---|
| private Timestamp compileTime | |
| compSchemaId | back to summary |
|---|---|
| private final UUID compSchemaId | |
| initiallyCompilable | back to summary |
|---|---|
| private final boolean initiallyCompilable | |
| INVALIDATE | back to summary |
|---|---|
| private static final int INVALIDATE | |
| lookedUpParams | back to summary |
|---|---|
| private boolean lookedUpParams | |
| name | back to summary |
|---|---|
| private final String name | |
| paramDefaults | back to summary |
|---|---|
| private Object[] paramDefaults Old code - never used. | |
| params | back to summary |
|---|---|
| private DataTypeDescriptor[] params | |
| preparedStatement | back to summary |
|---|---|
| private ExecPreparedStatement preparedStatement | |
| RECOMPILE | back to summary |
|---|---|
| private static final int RECOMPILE interface to this class is:
| |
| sd | back to summary |
|---|---|
| private final SchemaDescriptor sd | |
| SPS_TYPE_EXPLAIN | back to summary |
|---|---|
| public static final char SPS_TYPE_EXPLAIN | |
| SPS_TYPE_REGULAR | back to summary |
|---|---|
| public static final char SPS_TYPE_REGULAR | |
| SPS_TYPE_TRIGGER | back to summary |
|---|---|
| public static final char SPS_TYPE_TRIGGER Statement types.
| |
| text | back to summary |
|---|---|
| private String text | |
| type | back to summary |
|---|---|
| private final char type | |
| usingText | back to summary |
|---|---|
| private final String usingText | |
| uuid | back to summary |
|---|---|
| private final UUID uuid | |
| uuidFactory | back to summary |
|---|---|
| private UUIDFactory uuidFactory | |
| valid | back to summary |
|---|---|
| private boolean valid | |
| SPSDescriptor | back to summary |
|---|---|
| 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
| |
| SPSDescriptor | back to summary |
|---|---|
| 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.
| |
| compileStatement | back to summary |
|---|---|
| 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.
| |
| getClassType | back to summary |
|---|---|
| public final String getClassType() Implements org. Get the provider's type.
| |
| getCompileTime | back to summary |
|---|---|
| public final synchronized Timestamp getCompileTime() The time this prepared statement was compiled
| |
| getCompSchemaId | back to summary |
|---|---|
| public final UUID getCompSchemaId() Get the compilation type schema id when this view was first bound.
| |
| getContextService | back to summary |
|---|---|
| private static ContextService getContextService() Must be private so that user code can't call this entry point. | |
| getDependableFinder | back to summary |
|---|---|
| public final DependableFinder getDependableFinder() Implements org. Return the stored form of this provider
| |
| getDescriptorName | back to summary |
|---|---|
| public String getDescriptorName() Overrides org.
| |
| getDescriptorType | back to summary |
|---|---|
| public String getDescriptorType() Overrides org. Doc from org. Each descriptor must identify itself with its type; i.e index, check constraint whatever.
| |
| getName | back to summary |
|---|---|
| public final String getName() Implements abstract org. Gets the name of the sps.
| |
| getObjectID | back to summary |
|---|---|
| public final UUID getObjectID() Implements org. Get the provider's UUID
| |
| getObjectName | back to summary |
|---|---|
| public final String getObjectName() Implements org. Return the name of this Provider. (Useful for errors.)
| |
| getParameterDefaults | back to summary |
|---|---|
| public final synchronized 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.
| |
| getParams | back to summary |
|---|---|
| public final synchronized 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.
| |
| getPreparedStatement | back to summary |
|---|---|
| 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.
| |
| getPreparedStatement | back to summary |
|---|---|
| public final synchronized 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.
| |
| getQualifiedName | back to summary |
|---|---|
| public final String getQualifiedName() Gets the full, qualified name of the statement.
| |
| getSchemaDescriptor | back to summary |
|---|---|
| public final SchemaDescriptor getSchemaDescriptor() Implements abstract org. Gets the SchemaDescriptor for this SPS Descriptor.
| |
| getText | back to summary |
|---|---|
| public final synchronized String getText() Get the text used to create this statement. Returns original text in a cleartext string.
| |
| getType | back to summary |
|---|---|
| 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.
| |
| getTypeAsString | back to summary |
|---|---|
| public final String getTypeAsString() Simple little helper function to convert your type to a string, which is easier to use.
| |
| getUsingText | back to summary |
|---|---|
| public final String getUsingText() Get the text of the USING clause used on CREATE or ALTER statement.
| |
| getUUID | back to summary |
|---|---|
| public final UUID getUUID() Implements abstract org. Gets the UUID of the SPS.
| |
| initiallyCompilable | back to summary |
|---|---|
| public boolean initiallyCompilable() Is the statement initially compilable?
| |
| isValid | back to summary |
|---|---|
| public final synchronized boolean isValid() Implements org. Check that all of the dependent's dependencies are valid.
| |
| loadGeneratedClass | back to summary |
|---|---|
| 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.
| |
| makeInvalid | back to summary |
|---|---|
| public final synchronized void makeInvalid(int action, LanguageConnectionContext lcc) throws StandardException Implements org. Mark the dependent as invalid (due to at least one of its dependencies being invalid).
| |
| prepareAndRelease | back to summary |
|---|---|
| public final synchronized void prepareAndRelease(LanguageConnectionContext lcc, TableDescriptor triggerTable, TransactionController tc) 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.
| |
| prepareAndRelease | back to summary |
|---|---|
| public final synchronized 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.
| |
| prepareAndRelease | back to summary |
|---|---|
| public final synchronized 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.
| |
| prepareToInvalidate | back to summary |
|---|---|
| public final void prepareToInvalidate(Provider p, int action, LanguageConnectionContext lcc) throws StandardException Implements org. Prepare to mark the dependent as invalid (due to at least one of its dependencies being invalid).
| |
| recreateUUID | back to summary |
|---|---|
| private UUID recreateUUID(String idString) Get the UUID for the given string | |
| revalidate | back to summary |
|---|---|
| public final synchronized void revalidate(LanguageConnectionContext lcc) throws StandardException Invalidate and revalidate. The functional equivalent of calling makeInvalid() and makeValid(), except it is optimized.
| |
| setCompileTime | back to summary |
|---|---|
| public final synchronized void setCompileTime() Set the compile time to now | |
| setParameterDefaults | back to summary |
|---|---|
| public final synchronized void setParameterDefaults(Object[] values) Set the parameter defaults for this statement.
| |
| setParams | back to summary |
|---|---|
| public final synchronized void setParams(DataTypeDescriptor[] params) Set the list of parameters for this statement
| |
| setText | back to summary |
|---|---|
| public final synchronized void setText(String newText) 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 | |
| toString | back to summary |
|---|---|
| public final String toString() Overrides java. Prints the contents of the TableDescriptor | |
| updateSYSSTATEMENTS | back to summary |
|---|---|
| private void updateSYSSTATEMENTS(LanguageConnectionContext lcc, int mode, TransactionController tc) throws StandardException | |
| validType | back to summary |
|---|---|
| public static boolean validType(char type) Validate the type Note Only SPS_TYPE_REGULAR and SPS_TYPE_TRIGGER are currently valid.
| |