A compiled statement is registered by a session to be managed.
The sql statement text distinguishes different compiled statements and acts as lookup key when a session initially looks for an existing instance of the compiled sql statement.
The unique compiled statement id for the sql statement is used to access the statement.
Changes to database structure via DDL statements, will result in all registered Statement objects to become invalidated. This is done by comparing the schema change and compile timestamps. When a session subsequently attempts to use an invalidated Statement via its id, it will recompiles the Statement using its sql statement still held by this class. failure to recompile invalidates and removes the Statement.
This class keeps count of the number of time each registered compiled statement is linked to a session. It unregisters a compiled statement when it is not in use.
Modified by fredt@users from the original by campbell-burnet@users to simplify, support multiple identical prepared statements per session, and avoid memory leaks. Changed implementation to a session object for optimised access.
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private LongKeyHashMap | csidMap
Map: Statement id (int) maps to: wrapper for Statement object. |
| private Database | database
The Database for which this is managing Statement objects. |
| private long | next_cs_id
Monotonically increasing counter used to assign unique ids to Statement objects. |
| private Session | session
The Session for which this is managing Statement objects |
| private HashSet | statementSet
Set of wrappers for Statement object. |
| Access | Constructor and Description |
|---|---|
| pack-priv | StatementManager(Session
the session instance for which this object is to
manage Statement objects. session)Constructs a new instance of |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv Statement | |
| pack-priv void | freeStatement(long
the Statement identifier csid)Removes a link between a PreparedStatement and a Statement. |
| public Statement | Returns: the requested Statement objectthe identifier of the requested Statement object csid)Used by JDBC for a previously prepared statement. |
| private Statement | |
| public Statement | Returns: the requested Statement objectthe old expired statement statement)Recompiles an existing statement. |
| private long | Returns: the next Statement identifier in the sequence.Retrieves the next Statement identifier in the sequence. |
| private Statement | Returns: the new Statement objectthe old expired statement cs)Returns an up-to-date Statement using the SQL and settings of the original. |
| private long | Returns: The statement id assigned to the Statement objectthe wrapper for the Statement to add wrapperRegisters a Statement to be managed. |
| private void | |
| pack-priv void |
| csidMap | back to summary |
|---|---|
| private LongKeyHashMap<StatementManager. Map: Statement id (int) maps to: wrapper for Statement object. | |
| database | back to summary |
|---|---|
| private Database database The Database for which this is managing Statement objects. | |
| next_cs_id | back to summary |
|---|---|
| private long next_cs_id Monotonically increasing counter used to assign unique ids to Statement objects. | |
| session | back to summary |
|---|---|
| private Session session The Session for which this is managing Statement objects | |
| statementSet | back to summary |
|---|---|
| private HashSet<StatementManager. Set of wrappers for Statement object. | |
| StatementManager | back to summary |
|---|---|
| pack-priv StatementManager(Session session) Constructs a new instance of
| |
| compile | back to summary |
|---|---|
| pack-priv Statement compile(Result cmd) Compiles an SQL statement and returns a Statement Object | |
| freeStatement | back to summary |
|---|---|
| pack-priv void freeStatement(long csid) Removes a link between a PreparedStatement and a Statement. If the statement is not linked with any other PreparedStatement, it is removed from management.
| |
| getStatement | back to summary |
|---|---|
| public Statement getStatement(long csid) Used by JDBC for a previously prepared statement. Returns an existing Statement object with the given statement identifier. Returns null if the Statement object has expired and cannot be recompiled
| |
| getStatement | back to summary |
|---|---|
| private Statement getStatement(StatementManager. | |
| getStatement | back to summary |
|---|---|
| public Statement getStatement(Statement statement) Recompiles an existing statement. Used by transaction manager for all statements, prepared or not prepred. | |
| nextID | back to summary |
|---|---|
| private long nextID() Retrieves the next Statement identifier in the sequence.
| |
| recompileStatement | back to summary |
|---|---|
| private Statement recompileStatement(Statement cs) Returns an up-to-date Statement using the SQL and settings of the original. Returns null if the SQL cannot be compiled. | |
| registerStatement | back to summary |
|---|---|
| private long registerStatement(StatementManager. Registers a Statement to be managed.
| |
| removeStatement | back to summary |
|---|---|
| private void removeStatement(long csid) Removes an invalidated Statement.
| |
| reset | back to summary |
|---|---|
| pack-priv void reset() Clears all internal data structures, removing any references to Statements. | |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public int | |
| public long |
| StatementComparator | back to summary |
|---|---|
| private StatementComparator() | |
| equals | back to summary |
|---|---|
| public boolean equals(StatementManager. Implements org. | |
| hashCode | back to summary |
|---|---|
| public int hashCode(StatementManager. Implements org. | |
| longKey | back to summary |
|---|---|
| public long longKey(StatementManager. Implements org. | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int | |
| pack-priv ResultMetaData | |
| pack-priv int | |
| pack-priv HsqlNameManager. | |
| pack-priv String | |
| pack-priv Statement | |
| pack-priv long |
| Access | Constructor and Description |
|---|---|
| private |
| cursorProps | back to summary |
|---|---|
| pack-priv int cursorProps | |
| generatedMetaData | back to summary |
|---|---|
| pack-priv ResultMetaData generatedMetaData | |
| generatedType | back to summary |
|---|---|
| pack-priv int generatedType | |
| schemaName | back to summary |
|---|---|
| pack-priv HsqlNameManager. | |
| sql | back to summary |
|---|---|
| pack-priv String sql | |
| statement | back to summary |
|---|---|
| pack-priv Statement statement | |
| usageCount | back to summary |
|---|---|
| pack-priv long usageCount | |
| StatementWrapper | back to summary |
|---|---|
| private StatementWrapper() | |