Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Implementation Details: ParseInfo Cache

As it is expensive to parse commands again each time the parse infos are cached for each connection.

An existing parse info can be used for a command if:

A parse info is in shared use by several SQL statements, and must be therefore guarded against concurrent access.

Inserting a ParseInfo into the Cache
A parse info is create by preparing a statement. Here, it is checked whether there is a parse info available, and if not the statement is parsed. Then, the parse info is inserted into the cache - hereby setting its flags appropriately.

During this process the parse info is locked by the creator.

Attaching to a ParseInfo
When a matching parse info is found on prepare, the statement simply attaches to it. This means that the reference count of the parse info is increased. Attaching to a parse info also propagates the parse info also to the top of the LRU list.

Detaching from a ParseInfo
When a statement is destroyed, it detaches from the parse info. If the parse info is cached, the reference count is simply decremented by one.

If it is not cached, it is checked whether this was the last referencee, and if yes, the resources are freed.

Displacement of ParseInfo
On the insertion of a new ParseInfo into the cache, the cache size is checked. If the cache is full, the ParseInfo at the end of the LRU list is displaced, hereby setting its 'cached' flag to false. If its reference count is 0, it is deleted, otherwise that task is done by the last statement that detaches from the ParseInfo.