MySQL 8.4.3
Source Code Documentation
|
Container for all prepared statements created/used in a connection. More...
#include <sql_class.h>
Public Member Functions | |
Prepared_statement_map () | |
int | insert (Prepared_statement *statement) |
Insert a new statement to the thread-local prepared statement map. More... | |
Prepared_statement * | find_by_name (const LEX_CSTRING &name) |
Find prepared statement by name. More... | |
Prepared_statement * | find (ulong id) |
Find prepared statement by ID. More... | |
void | erase (Prepared_statement *statement) |
Erase all prepared statements (calls Prepared_statement destructor). More... | |
void | claim_memory_ownership (bool claim) |
void | reset () |
~Prepared_statement_map () | |
Private Attributes | |
malloc_unordered_map< ulong, std::unique_ptr< Prepared_statement > > | st_hash |
collation_unordered_map< std::string, Prepared_statement * > | names_hash |
Prepared_statement * | m_last_found_statement |
Container for all prepared statements created/used in a connection.
Prepared statements in Prepared_statement_map have unique id (guaranteed by id assignment in Prepared_statement::Prepared_statement).
Non-empty statement names are unique too: attempt to insert a new statement with duplicate name causes older statement to be deleted.
Prepared statements are auto-deleted when they are removed from the map and when the map is deleted.
Prepared_statement_map::Prepared_statement_map | ( | ) |
Prepared_statement_map::~Prepared_statement_map | ( | ) |
void Prepared_statement_map::claim_memory_ownership | ( | bool | claim | ) |
void Prepared_statement_map::erase | ( | Prepared_statement * | statement | ) |
Erase all prepared statements (calls Prepared_statement destructor).
Prepared_statement * Prepared_statement_map::find | ( | ulong | id | ) |
Find prepared statement by ID.
Prepared_statement * Prepared_statement_map::find_by_name | ( | const LEX_CSTRING & | name | ) |
Find prepared statement by name.
int Prepared_statement_map::insert | ( | Prepared_statement * | statement | ) |
Insert a new statement to the thread-local prepared statement map.
If there was an old statement with the same name, replace it with the new one. Otherwise, check if max_prepared_stmt_count is not reached yet, increase prepared_stmt_count, and insert the new statement. It's okay to delete an old statement and fail to insert the new one.
All named prepared statements are also present in names_hash. Prepared statement names in names_hash are unique. The statement is added only if prepared_stmt_count < max_prepard_stmt_count m_last_found_statement always points to a valid statement or is 0
0 | success |
1 | error: out of resources or max_prepared_stmt_count limit has been reached. An error is sent to the client, the statement is deleted. |
void Prepared_statement_map::reset | ( | void | ) |
|
private |
|
private |
|
private |