MySQL 8.4.0
Source Code Documentation
Prepared_statement_map Class Reference

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_statementfind_by_name (const LEX_CSTRING &name)
 Find prepared statement by name. More...
Prepared_statementfind (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

Detailed Description

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.

Constructor & Destructor Documentation

◆ Prepared_statement_map()

Prepared_statement_map::Prepared_statement_map ( )

◆ ~Prepared_statement_map()

Prepared_statement_map::~Prepared_statement_map ( )

Member Function Documentation

◆ claim_memory_ownership()

void Prepared_statement_map::claim_memory_ownership ( bool  claim)

◆ erase()

void Prepared_statement_map::erase ( Prepared_statement statement)

Erase all prepared statements (calls Prepared_statement destructor).

◆ find()

Prepared_statement * Prepared_statement_map::find ( ulong  id)

Find prepared statement by ID.

◆ find_by_name()

Prepared_statement * Prepared_statement_map::find_by_name ( const LEX_CSTRING name)

Find prepared statement by name.

◆ insert()

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

Return values
1error: out of resources or max_prepared_stmt_count limit has been reached. An error is sent to the client, the statement is deleted.

◆ reset()

void Prepared_statement_map::reset ( void  )

Member Data Documentation

◆ m_last_found_statement

Prepared_statement* Prepared_statement_map::m_last_found_statement

◆ names_hash

collation_unordered_map<std::string, Prepared_statement *> Prepared_statement_map::names_hash

◆ st_hash

malloc_unordered_map<ulong, std::unique_ptr<Prepared_statement> > Prepared_statement_map::st_hash

The documentation for this class was generated from the following files: