MySQL  8.0.20
Source Code Documentation
trigger.cc File Reference
#include "sql/trigger.h"
#include <stdio.h>
#include <atomic>
#include "lex_string.h"
#include "m_ctype.h"
#include "m_string.h"
#include "my_dbug.h"
#include "my_psi_config.h"
#include "mysql/components/services/psi_statement_bits.h"
#include "mysql/psi/mysql_sp.h"
#include "mysqld_error.h"
#include "mysys_err.h"
#include "sql/derror.h"
#include "sql/error_handler.h"
#include "sql/sp.h"
#include "sql/sp_head.h"
#include "sql/sql_class.h"
#include "sql/sql_db.h"
#include "sql/sql_digest_stream.h"
#include "sql/sql_error.h"
#include "sql/sql_lex.h"
#include "sql/sql_parse.h"
#include "sql/sql_show.h"
#include "sql/strfunc.h"
#include "sql/system_variables.h"
#include "sql/trigger_creation_ctx.h"
#include "sql_string.h"

Classes

class  Deprecated_trigger_syntax_handler
 An error handler that catches all non-OOM errors which can occur during parsing of trigger body. More...
 

Functions

static bool construct_definer_value (MEM_ROOT *mem_root, LEX_CSTRING *definer, const LEX_CSTRING &definer_user, const LEX_CSTRING &definer_host)
 Create a definer value from its user and host parts. More...
 
static bool construct_create_trigger_stmt_with_definer (THD *thd, String *binlog_query, const LEX_CSTRING &def_user, const LEX_CSTRING &def_host)
 Constructs CREATE TRIGGER statement taking into account a value of the DEFINER clause. More...
 

Variables

static const LEX_CSTRING trg_action_time_type_names []
 
static const LEX_CSTRING trg_event_type_names []
 

Function Documentation

◆ construct_create_trigger_stmt_with_definer()

static bool construct_create_trigger_stmt_with_definer ( THD thd,
String binlog_query,
const LEX_CSTRING def_user,
const LEX_CSTRING def_host 
)
static

Constructs CREATE TRIGGER statement taking into account a value of the DEFINER clause.

The point of this method is to create canonical forms of CREATE TRIGGER statement for writing into the binlog.

Note
A statement for the binlog form must preserve FOLLOWS/PRECEDES clause if it was in the original statement. The reason for that difference is this:
  • the Data Dictionary preserves the trigger execution order (action_order), thus FOLLOWS/PRECEDES clause is not needed.
  • moreover, FOLLOWS/PRECEDES clause usually makes problem in mysqldump, because CREATE TRIGGER statement will have a reference to non-yet-existing trigger (which is about to be created right after this one).
  • thus, FOLLOWS/PRECEDES must not be stored in the Data Dictionary.
  • on the other hand, the binlog contains statements in the user order (as the user executes them). Thus, it is important to preserve FOLLOWS/PRECEDES clause if the user has specified it so that the trigger execution order on master and slave will be the same.
Parameters
thdthread context
[out]binlog_querywell-formed CREATE TRIGGER statement for putting into binlog (after successful execution)
def_useruser part of a definer value
def_hosthost part of a definer value
Returns
Operation status.
Return values
falseSuccess
trueFailure

◆ construct_definer_value()

static bool construct_definer_value ( MEM_ROOT mem_root,
LEX_CSTRING definer,
const LEX_CSTRING definer_user,
const LEX_CSTRING definer_host 
)
static

Create a definer value from its user and host parts.

Parameters
mem_rootmem-root where needed strings will be allocated
[out]definerpointer to LEX_CSTRING holder where to store a constructed value of definer
definer_useruser part of a definer value
definer_hosthost part of a definer value
Returns
Operation status.
Return values
falseSuccess
trueFailure

Variable Documentation

◆ trg_action_time_type_names

const LEX_CSTRING trg_action_time_type_names[]
static
Initial value:
= {
{STRING_WITH_LEN("BEFORE")}, {STRING_WITH_LEN("AFTER")}}
#define STRING_WITH_LEN(X)
Definition: m_string.h:315

◆ trg_event_type_names

const LEX_CSTRING trg_event_type_names[]
static
Initial value:
= {{STRING_WITH_LEN("INSERT")},
{STRING_WITH_LEN("UPDATE")},
{STRING_WITH_LEN("DELETE")}}
#define STRING_WITH_LEN(X)
Definition: m_string.h:315