CUBRID Engine  latest
trigger_manager.c File Reference
#include <assert.h>
#include "config.h"
#include "misc_string.h"
#include "memory_alloc.h"
#include "error_manager.h"
#include "dbtype.h"
#include "trigger_manager.h"
#include "memory_hash.h"
#include "work_space.h"
#include "schema_manager.h"
#include "object_accessor.h"
#include "object_primitive.h"
#include "object_print.h"
#include "set_object.h"
#include "authenticate.h"
#include "db.h"
#include "parser.h"
#include "system_parameter.h"
#include "locator_cl.h"
#include "transaction_cl.h"

Go to the source code of this file.

Macros

#define TR_EXECUTION_ENABLED   (tr_Execution_enabled == true)
 
#define UNIQUE_SAVEPOINT_RENAME_TRIGGER   "rENAMEtRIGGER"
 
#define UNIQUE_SAVEPOINT_DROP_TRIGGER   "dROPtRIGGER"
 
#define UNIQUE_SAVEPOINT_CREATE_TRIGGER   "cREATEtRIGGER"
 
#define IS_USER_EVENT(event)
 
#define IS_CLASS_EVENT(event)   (!IS_USER_EVENT(event))
 
#define COMPARE_TRIGGER_NAMES   intl_identifier_casecmp
 
#define MAX_ERROR_STRING   2048
 

Functions

static const char * time_as_string (DB_TRIGGER_TIME tr_time)
 
static char * tr_process_name (const char *name_string)
 
static TR_ACTIVITYmake_activity (void)
 
static void free_activity (TR_ACTIVITY *act)
 
static TR_TRIGGERtr_make_trigger (void)
 
static void tr_clear_trigger (TR_TRIGGER *trigger)
 
static void free_trigger (TR_TRIGGER *trigger)
 
static int insert_trigger_list (TR_TRIGLIST **list, TR_TRIGGER *trigger)
 
static int merge_trigger_list (TR_TRIGLIST **list, TR_TRIGLIST *more, int destructive)
 
static void remove_trigger_list_element (TR_TRIGLIST **list, TR_TRIGLIST *element)
 
static void remove_trigger_list (TR_TRIGLIST **list, TR_TRIGGER *trigger)
 
static void reinsert_trigger_list (TR_TRIGLIST **list, TR_TRIGGER *trigger)
 
static TR_DEFERRED_CONTEXTadd_deferred_activity_context (void)
 
static int add_deferred_activities (TR_TRIGLIST *triggers, MOP current)
 
static void flush_deferred_activities (void)
 
static void remove_deferred_activity (TR_DEFERRED_CONTEXT *context, TR_TRIGLIST *element)
 
static void remove_deferred_context (TR_DEFERRED_CONTEXT *c)
 
static TR_STATEmake_state (void)
 
static void free_state (TR_STATE *state)
 
static DB_OBJECTtrigger_to_object (TR_TRIGGER *trigger)
 
static int object_to_trigger (DB_OBJECT *object, TR_TRIGGER *trigger)
 
static void get_reference_names (TR_TRIGGER *trigger, TR_ACTIVITY *activity, const char **curname, const char **tempname)
 
static int compile_trigger_activity (TR_TRIGGER *trigger, TR_ACTIVITY *activity, int with_evaluate)
 
static int validate_trigger (TR_TRIGGER *trigger)
 
static int register_user_trigger (DB_OBJECT *object)
 
static int unregister_user_trigger (TR_TRIGGER *trigger, int rollback)
 
static int get_user_trigger_objects (DB_TRIGGER_EVENT event, bool active_filter, DB_OBJLIST **trigger_list)
 
static void reorder_schema_caches (TR_TRIGGER *trigger)
 
static int trigger_table_add (const char *name, DB_OBJECT *trigger)
 
static int trigger_table_find (const char *name, DB_OBJECT **trigger_p)
 
static int trigger_table_rename (DB_OBJECT *trigger_object, const char *newname)
 
static int trigger_table_drop (const char *name)
 
static bool check_authorization (TR_TRIGGER *trigger, bool alter_flag)
 
static int find_all_triggers (bool active_filter, bool alter_filter, DB_OBJLIST **list)
 
static int get_schema_trigger_objects (DB_OBJECT *class_mop, const char *attribute, DB_TRIGGER_EVENT event, bool active_flag, DB_OBJLIST **objlist)
 
static int find_event_triggers (DB_TRIGGER_EVENT event, DB_OBJECT *class_mop, const char *attribute, bool active_filter, DB_OBJLIST **list)
 
static bool check_target (DB_TRIGGER_EVENT event, DB_OBJECT *class_mop, const char *attribute)
 
static int check_semantics (TR_TRIGGER *trigger)
 
static PT_NODEtr_check_correlation (PARSER_CONTEXT *parser, PT_NODE *node, void *arg, int *walk_on)
 
static int tr_drop_trigger_internal (TR_TRIGGER *trigger, int rollback, bool need_savepoint)
 
static bool value_as_boolean (DB_VALUE *value)
 
static int signal_evaluation_error (TR_TRIGGER *trigger, int error)
 
static int eval_condition (TR_TRIGGER *trigger, DB_OBJECT *current, DB_OBJECT *temp, bool *status)
 
static int eval_action (TR_TRIGGER *trigger, DB_OBJECT *current, DB_OBJECT *temp, bool *reject)
 
static int execute_activity (TR_TRIGGER *trigger, DB_TRIGGER_TIME tr_time, DB_OBJECT *current, DB_OBJECT *temp, bool *rejected)
 
static int tr_execute_activities (TR_STATE *state, DB_TRIGGER_TIME tr_time, DB_OBJECT *current, DB_OBJECT *temp)
 
static int run_user_triggers (DB_TRIGGER_EVENT event, DB_TRIGGER_TIME time)
 
static int compare_recursion_levels (int rl_1, int rl_2)
 
static TR_STATEstart_state (TR_STATE **current, const char *name)
 
static void tr_finish (TR_STATE *state)
 
static int its_deleted (DB_OBJECT *object)
 
static int map_flush_helper (const void *key, void *data, void *args)
 
static int define_trigger_classes (void)
 
static TR_RECURSION_DECISION tr_check_recursivity (OID oid, OID stack[], int stack_size, bool is_statement)
 
void tr_free_trigger_list (TR_TRIGLIST *list)
 
TR_TRIGGERtr_map_trigger (DB_OBJECT *object, int fetch)
 
int tr_unmap_trigger (TR_TRIGGER *trigger)
 
int tr_update_user_cache (void)
 
TR_SCHEMA_CACHEtr_make_schema_cache (TR_CACHE_TYPE type, DB_OBJLIST *objects)
 
TR_SCHEMA_CACHEtr_copy_schema_cache (TR_SCHEMA_CACHE *cache, MOP filter_class)
 
int tr_merge_schema_cache (TR_SCHEMA_CACHE *destination, TR_SCHEMA_CACHE *source)
 
int tr_empty_schema_cache (TR_SCHEMA_CACHE *cache)
 
void tr_free_schema_cache (TR_SCHEMA_CACHE *cache)
 
int tr_add_cache_trigger (TR_SCHEMA_CACHE *cache, DB_OBJECT *trigger_object)
 
int tr_drop_cache_trigger (TR_SCHEMA_CACHE *cache, DB_OBJECT *trigger_object)
 
int tr_get_cache_objects (TR_SCHEMA_CACHE *cache, DB_OBJLIST **list)
 
int tr_validate_schema_cache (TR_SCHEMA_CACHE *cache, MOP class_mop)
 
int tr_active_schema_cache (MOP class_mop, TR_SCHEMA_CACHE *cache, DB_TRIGGER_EVENT event_type, bool *has_event_type_triggers)
 
int tr_delete_schema_cache (TR_SCHEMA_CACHE *cache, DB_OBJECT *class_object)
 
int tr_delete_triggers_for_class (TR_SCHEMA_CACHE **cache, DB_OBJECT *class_object)
 
DB_OBJECTtr_create_trigger (const char *name, DB_TRIGGER_STATUS status, double priority, DB_TRIGGER_EVENT event, DB_OBJECT *class_mop, const char *attribute, DB_TRIGGER_TIME cond_time, const char *cond_source, DB_TRIGGER_TIME action_time, DB_TRIGGER_ACTION action_type, const char *action_source, const char *comment)
 
int tr_find_all_triggers (DB_OBJLIST **list)
 
DB_OBJECTtr_find_trigger (const char *name)
 
int tr_find_event_triggers (DB_TRIGGER_EVENT event, DB_OBJECT *class_mop, const char *attribute, bool active, DB_OBJLIST **list)
 
int tr_check_authorization (DB_OBJECT *trigger_object, int alter_flag)
 
int tr_drop_trigger (DB_OBJECT *obj, bool call_from_api)
 
int tr_prepare_statement (TR_STATE **state_p, DB_TRIGGER_EVENT event, DB_OBJECT *class_mop, int attcount, const char **attnames)
 
int tr_prepare_class (TR_STATE **state_p, TR_SCHEMA_CACHE *cache, MOP class_mop, DB_TRIGGER_EVENT event)
 
void tr_abort (TR_STATE *state)
 
int tr_before_object (TR_STATE *state, DB_OBJECT *current, DB_OBJECT *temp)
 
int tr_before (TR_STATE *state)
 
int tr_after_object (TR_STATE *state, DB_OBJECT *current, DB_OBJECT *temp)
 
int tr_after (TR_STATE *state)
 
int tr_has_user_trigger (bool *has_user_trigger)
 
int tr_check_commit_triggers (DB_TRIGGER_TIME time)
 
void tr_check_rollback_triggers (DB_TRIGGER_TIME time)
 
void tr_check_abort_triggers (void)
 
int tr_execute_deferred_activities (DB_OBJECT *trigger_object, DB_OBJECT *target)
 
int tr_drop_deferred_activities (DB_OBJECT *trigger_object, DB_OBJECT *target)
 
int tr_trigger_name (DB_OBJECT *trigger_object, char **name)
 
int tr_trigger_status (DB_OBJECT *trigger_object, DB_TRIGGER_STATUS *status)
 
int tr_trigger_priority (DB_OBJECT *trigger_object, double *priority)
 
int tr_trigger_event (DB_OBJECT *trigger_object, DB_TRIGGER_EVENT *event)
 
int tr_trigger_class (DB_OBJECT *trigger_object, DB_OBJECT **class_mop_p)
 
int tr_trigger_attribute (DB_OBJECT *trigger_object, char **attribute)
 
int tr_trigger_condition (DB_OBJECT *trigger_object, char **condition)
 
int tr_trigger_condition_time (DB_OBJECT *trigger_object, DB_TRIGGER_TIME *tr_time)
 
int tr_trigger_action (DB_OBJECT *trigger_object, char **action)
 
int tr_trigger_action_time (DB_OBJECT *trigger_object, DB_TRIGGER_TIME *tr_time)
 
int tr_trigger_action_type (DB_OBJECT *trigger_object, DB_TRIGGER_ACTION *type)
 
int tr_trigger_comment (DB_OBJECT *trigger_object, char **comment)
 
int tr_is_trigger (DB_OBJECT *trigger_object, int *status)
 
const char * tr_time_as_string (DB_TRIGGER_TIME time)
 
const char * tr_event_as_string (DB_TRIGGER_EVENT event)
 
const char * tr_status_as_string (DB_TRIGGER_STATUS status)
 
int tr_rename_trigger (DB_OBJECT *trigger_object, const char *name, bool call_from_api)
 
int tr_set_status (DB_OBJECT *trigger_object, DB_TRIGGER_STATUS status, bool call_from_api)
 
int tr_set_priority (DB_OBJECT *trigger_object, double priority, bool call_from_api)
 
int tr_set_comment (DB_OBJECT *trigger_object, const char *comment, bool call_from_api)
 
int tr_get_depth (void)
 
int tr_set_depth (int depth)
 
int tr_get_trace (void)
 
int tr_set_trace (bool trace)
 
void tr_init (void)
 
void tr_final (void)
 
void tr_dump (FILE *fpp)
 
int tr_install (void)
 
bool tr_get_execution_state (void)
 
bool tr_set_execution_state (bool new_state)
 
const char * tr_get_class_name (void)
 

Variables

static const int TR_RETURN_ERROR = -1
 
static const int TR_RETURN_FALSE = 0
 
static const int TR_RETURN_TRUE = 1
 
static const int TR_EST_MAP_SIZE = 1024
 
static const char * OBJ_REFERENCE_NAME = "obj"
 
static const char * NEW_REFERENCE_NAME = "new"
 
static const char * OLD_REFERENCE_NAME = "old"
 
static const char * EVAL_PREFIX = "EVALUATE ( "
 
static const char * EVAL_SUFFIX = " ) "
 
const char * TR_CLASS_NAME = "db_trigger"
 
const char * TR_ATT_NAME = "name"
 
const char * TR_ATT_OWNER = "owner"
 
const char * TR_ATT_EVENT = "event"
 
const char * TR_ATT_STATUS = "status"
 
const char * TR_ATT_PRIORITY = "priority"
 
const char * TR_ATT_CLASS = "target_class"
 
const char * TR_ATT_ATTRIBUTE = "target_attribute"
 
const char * TR_ATT_CLASS_ATTRIBUTE = "target_class_attribute"
 
const char * TR_ATT_CONDITION_TYPE = "condition_type"
 
const char * TR_ATT_CONDITION_TIME = "condition_time"
 
const char * TR_ATT_CONDITION = "condition"
 
const char * TR_ATT_ACTION_TYPE = "action_type"
 
const char * TR_ATT_ACTION_TIME = "action_time"
 
const char * TR_ATT_ACTION = "action_definition"
 
const char * TR_ATT_ACTION_OLD = "action"
 
const char * TR_ATT_PROPERTIES = "properties"
 
const char * TR_ATT_COMMENT = "comment"
 
int tr_Current_depth = 0
 
int tr_Maximum_depth = TR_MAX_RECURSION_LEVEL
 
OID tr_Stack [TR_MAX_RECURSION_LEVEL+1]
 
bool tr_Invalid_transaction = false
 
char tr_Invalid_transaction_trigger [SM_MAX_IDENTIFIER_LENGTH+2]
 
bool tr_Trace = true
 
TR_DEFERRED_CONTEXTtr_Deferred_activities = NULL
 
TR_DEFERRED_CONTEXTtr_Deferred_activities_tail = NULL
 
static int tr_User_triggers_valid = 0
 
static int tr_User_triggers_modified = 0
 
static TR_TRIGLISTtr_User_triggers = NULL
 
static TR_TRIGLISTtr_Uncommitted_triggers = NULL
 
static TR_SCHEMA_CACHEtr_Schema_caches = NULL
 
static bool tr_Execution_enabled = true
 
static MHT_TABLEtr_object_map = NULL
 

Macro Definition Documentation

#define COMPARE_TRIGGER_NAMES   intl_identifier_casecmp

Definition at line 82 of file trigger_manager.c.

Referenced by trigger_table_drop(), and trigger_table_find().

#define IS_CLASS_EVENT (   event)    (!IS_USER_EVENT(event))

Definition at line 75 of file trigger_manager.c.

Referenced by check_authorization(), and check_target().

#define IS_USER_EVENT (   event)
Value:

Definition at line 68 of file trigger_manager.c.

#define MAX_ERROR_STRING   2048

Definition at line 86 of file trigger_manager.c.

Referenced by signal_evaluation_error().

#define UNIQUE_SAVEPOINT_CREATE_TRIGGER   "cREATEtRIGGER"

Definition at line 56 of file trigger_manager.c.

Referenced by tr_create_trigger().

#define UNIQUE_SAVEPOINT_DROP_TRIGGER   "dROPtRIGGER"

Definition at line 55 of file trigger_manager.c.

Referenced by tr_drop_trigger_internal().

#define UNIQUE_SAVEPOINT_RENAME_TRIGGER   "rENAMEtRIGGER"

Definition at line 54 of file trigger_manager.c.

Referenced by tr_rename_trigger().

Function Documentation

static int add_deferred_activities ( TR_TRIGLIST triggers,
MOP  current 
)
static
static int compare_recursion_levels ( int  rl_1,
int  rl_2 
)
static

Definition at line 5198 of file trigger_manager.c.

Referenced by start_state().

Here is the caller graph for this function:

static int execute_activity ( TR_TRIGGER trigger,
DB_TRIGGER_TIME  tr_time,
DB_OBJECT current,
DB_OBJECT temp,
bool rejected 
)
static
static int find_all_triggers ( bool  active_filter,
bool  alter_filter,
DB_OBJLIST **  list 
)
static
static int find_event_triggers ( DB_TRIGGER_EVENT  event,
DB_OBJECT class_mop,
const char *  attribute,
bool  active_filter,
DB_OBJLIST **  list 
)
static

Definition at line 3649 of file trigger_manager.c.

References error(), get_schema_trigger_objects(), get_user_trigger_objects(), NO_ERROR, and NULL.

Referenced by tr_find_event_triggers().

Here is the caller graph for this function:

static void flush_deferred_activities ( void  )
static

Definition at line 823 of file trigger_manager.c.

References free_and_init, tr_deferred_context::head, tr_deferred_context::next, NULL, and tr_free_trigger_list().

Referenced by tr_check_abort_triggers(), tr_check_rollback_triggers(), and tr_final().

Here is the caller graph for this function:

static void free_activity ( TR_ACTIVITY act)
static

Definition at line 355 of file trigger_manager.c.

References free_and_init, NULL, tr_activity::parser, parser_free_parser(), parser_free_tree(), tr_activity::source, and tr_activity::statement.

Referenced by tr_clear_trigger().

Here is the caller graph for this function:

static void free_state ( TR_STATE state)
static

Definition at line 976 of file trigger_manager.c.

References free_and_init, tr_free_trigger_list(), and tr_state::triggers.

Referenced by tr_finish().

Here is the caller graph for this function:

static void free_trigger ( TR_TRIGGER trigger)
static

Definition at line 472 of file trigger_manager.c.

References free_and_init, and tr_clear_trigger().

Referenced by map_flush_helper(), tr_create_trigger(), tr_drop_trigger_internal(), and tr_map_trigger().

Here is the caller graph for this function:

static void get_reference_names ( TR_TRIGGER trigger,
TR_ACTIVITY activity,
const char **  curname,
const char **  tempname 
)
static
static int get_schema_trigger_objects ( DB_OBJECT class_mop,
const char *  attribute,
DB_TRIGGER_EVENT  event,
bool  active_flag,
DB_OBJLIST **  objlist 
)
static
static int get_user_trigger_objects ( DB_TRIGGER_EVENT  event,
bool  active_filter,
DB_OBJLIST **  trigger_list 
)
static
static int insert_trigger_list ( TR_TRIGLIST **  list,
TR_TRIGGER trigger 
)
static
static int its_deleted ( DB_OBJECT object)
static

Definition at line 5901 of file trigger_manager.c.

References au_fetch_instance_force(), AU_FETCH_READ, db_object::decached, ER_HEAP_UNKNOWN_OBJECT, error(), NULL, TM_TRAN_READ_FETCH_VERSION, and WS_IS_DELETED.

Referenced by tr_execute_deferred_activities().

Here is the caller graph for this function:

static TR_STATE * make_state ( void  )
static

Definition at line 952 of file trigger_manager.c.

References ARG_FILE_LINE, ER_ERROR_SEVERITY, ER_OUT_OF_VIRTUAL_MEMORY, er_set(), NULL, and tr_state::triggers.

Referenced by start_state().

Here is the caller graph for this function:

static int map_flush_helper ( const void *  key,
void *  data,
void *  args 
)
static

Definition at line 7191 of file trigger_manager.c.

References free_trigger(), NO_ERROR, and NULL.

Referenced by tr_final().

Here is the caller graph for this function:

static int merge_trigger_list ( TR_TRIGLIST **  list,
TR_TRIGLIST more,
int  destructive 
)
static
static int register_user_trigger ( DB_OBJECT object)
static
static void reinsert_trigger_list ( TR_TRIGLIST **  list,
TR_TRIGGER trigger 
)
static

Definition at line 704 of file trigger_manager.c.

References insert_trigger_list(), tr_triglist::next, NULL, remove_trigger_list_element(), and tr_triglist::trigger.

Referenced by reorder_schema_caches().

Here is the caller graph for this function:

static void remove_deferred_activity ( TR_DEFERRED_CONTEXT context,
TR_TRIGLIST element 
)
static

Definition at line 846 of file trigger_manager.c.

References tr_deferred_context::head, tr_triglist::prev, remove_trigger_list_element(), and tr_deferred_context::tail.

Referenced by tr_drop_deferred_activities(), and tr_execute_deferred_activities().

Here is the caller graph for this function:

static void remove_trigger_list ( TR_TRIGLIST **  list,
TR_TRIGGER trigger 
)
static

Definition at line 678 of file trigger_manager.c.

References tr_triglist::next, NULL, remove_trigger_list_element(), and tr_triglist::trigger.

Referenced by tr_create_trigger(), tr_drop_cache_trigger(), tr_drop_trigger_internal(), and unregister_user_trigger().

Here is the caller graph for this function:

static void remove_trigger_list_element ( TR_TRIGLIST **  list,
TR_TRIGLIST element 
)
static

Definition at line 650 of file trigger_manager.c.

References tr_triglist::next, NULL, tr_triglist::prev, and tr_free_trigger_list().

Referenced by reinsert_trigger_list(), remove_deferred_activity(), remove_trigger_list(), and tr_execute_activities().

Here is the caller graph for this function:

static void reorder_schema_caches ( TR_TRIGGER trigger)
static

Definition at line 2756 of file trigger_manager.c.

References tr_schema_cache::array_length, tr_schema_cache::compiled, i, tr_schema_cache::next, NULL, reinsert_trigger_list(), and tr_schema_cache::triggers.

Referenced by tr_set_priority().

Here is the caller graph for this function:

static int signal_evaluation_error ( TR_TRIGGER trigger,
int  error 
)
static
static TR_STATE * start_state ( TR_STATE **  current,
const char *  name 
)
static
static const char * time_as_string ( DB_TRIGGER_TIME  tr_time)
static

Definition at line 264 of file trigger_manager.c.

References TR_TIME_AFTER, TR_TIME_BEFORE, TR_TIME_DEFERRED, and TR_TIME_NULL.

Referenced by check_semantics(), and double_to_string().

Here is the caller graph for this function:

void tr_abort ( TR_STATE state)

Definition at line 5536 of file trigger_manager.c.

References tr_finish().

Referenced by check_merge_trigger(), check_trigger(), obt_apply_assignments(), tr_after_object(), and tr_before_object().

Here is the caller graph for this function:

int tr_active_schema_cache ( MOP  class_mop,
TR_SCHEMA_CACHE cache,
DB_TRIGGER_EVENT  event_type,
bool has_event_type_triggers 
)
int tr_add_cache_trigger ( TR_SCHEMA_CACHE cache,
DB_OBJECT trigger_object 
)
int tr_after ( TR_STATE state)

Definition at line 5651 of file trigger_manager.c.

References NULL, and tr_after_object().

Referenced by check_merge_trigger(), and check_trigger().

Here is the caller graph for this function:

int tr_after_object ( TR_STATE state,
DB_OBJECT current,
DB_OBJECT temp 
)
int tr_before ( TR_STATE state)

Definition at line 5593 of file trigger_manager.c.

References NULL, and tr_before_object().

Referenced by check_merge_trigger(), and check_trigger().

Here is the caller graph for this function:

int tr_before_object ( TR_STATE state,
DB_OBJECT current,
DB_OBJECT temp 
)

Definition at line 5561 of file trigger_manager.c.

References error(), NO_ERROR, tr_abort(), tr_execute_activities(), TR_EXECUTION_ENABLED, and TR_TIME_BEFORE.

Referenced by obj_delete(), obt_apply_assignments(), and tr_before().

Here is the caller graph for this function:

void tr_check_abort_triggers ( void  )

Definition at line 5865 of file trigger_manager.c.

References flush_deferred_activities(), run_user_triggers(), TR_EVENT_ABORT, TR_EXECUTION_ENABLED, tr_Invalid_transaction, and TR_TIME_AFTER.

Referenced by tran_abort_only_client(), and tran_unilaterally_abort().

Here is the caller graph for this function:

int tr_check_authorization ( DB_OBJECT trigger_object,
int  alter_flag 
)

Definition at line 4302 of file trigger_manager.c.

References ASSERT_ERROR_AND_SET, AU_DISABLE, AU_ENABLE, check_authorization(), error(), NO_ERROR, NULL, and tr_map_trigger().

Referenced by do_alter_trigger(), and do_drop_trigger().

Here is the caller graph for this function:

static PT_NODE * tr_check_correlation ( PARSER_CONTEXT parser,
PT_NODE node,
void *  arg,
int *  walk_on 
)
static
static TR_RECURSION_DECISION tr_check_recursivity ( OID  oid,
OID  stack[],
int  stack_size,
bool  is_statement 
)
static

Definition at line 4738 of file trigger_manager.c.

References assert, i, min, oid_compare(), TR_DECISION_CONTINUE, TR_DECISION_DO_NOT_CONTINUE, and TR_MAX_RECURSION_LEVEL.

Referenced by eval_action().

Here is the caller graph for this function:

static void tr_clear_trigger ( TR_TRIGGER trigger)
static
DB_OBJECT* tr_create_trigger ( const char *  name,
DB_TRIGGER_STATUS  status,
double  priority,
DB_TRIGGER_EVENT  event,
DB_OBJECT class_mop,
const char *  attribute,
DB_TRIGGER_TIME  cond_time,
const char *  cond_source,
DB_TRIGGER_TIME  action_time,
DB_TRIGGER_ACTION  action_type,
const char *  action_source,
const char *  comment 
)
int tr_delete_schema_cache ( TR_SCHEMA_CACHE cache,
DB_OBJECT class_object 
)
int tr_delete_triggers_for_class ( TR_SCHEMA_CACHE **  cache,
DB_OBJECT class_object 
)
int tr_drop_cache_trigger ( TR_SCHEMA_CACHE cache,
DB_OBJECT trigger_object 
)
void tr_dump ( FILE *  fpp)

Definition at line 7240 of file trigger_manager.c.

References tr_deferred_context::head, tr_trigger::name, tr_triglist::next, tr_deferred_context::next, NULL, TR_EXECUTION_ENABLED, and tr_triglist::trigger.

Referenced by help_print_info().

Here is the caller graph for this function:

int tr_empty_schema_cache ( TR_SCHEMA_CACHE cache)

Definition at line 2405 of file trigger_manager.c.

References NULL, and tr_schema_cache::objects.

Referenced by flatten_trigger_cache().

Here is the caller graph for this function:

static int tr_execute_activities ( TR_STATE state,
DB_TRIGGER_TIME  tr_time,
DB_OBJECT current,
DB_OBJECT temp 
)
static
void tr_final ( void  )
int tr_find_all_triggers ( DB_OBJLIST **  list)

Definition at line 4186 of file trigger_manager.c.

References AU_DISABLE, AU_ENABLE, error(), and find_all_triggers().

Referenced by convert_speclist_to_objlist(), db_find_all_triggers(), and help_trigger_names().

Here is the caller graph for this function:

int tr_find_event_triggers ( DB_TRIGGER_EVENT  event,
DB_OBJECT class_mop,
const char *  attribute,
bool  active,
DB_OBJLIST **  list 
)

Definition at line 4264 of file trigger_manager.c.

References ASSERT_ERROR_AND_SET, AU_DISABLE, AU_ENABLE, check_target(), error(), find_event_triggers(), and NO_ERROR.

Referenced by convert_speclist_to_objlist(), and db_find_event_triggers().

Here is the caller graph for this function:

static void tr_finish ( TR_STATE state)
static

Definition at line 5517 of file trigger_manager.c.

References free_state(), and tr_Current_depth.

Referenced by run_user_triggers(), tr_abort(), tr_after_object(), and tr_execute_deferred_activities().

Here is the caller graph for this function:

int tr_get_depth ( void  )

Definition at line 7106 of file trigger_manager.c.

References tr_Maximum_depth.

Referenced by do_get_trigger().

Here is the caller graph for this function:

bool tr_get_execution_state ( void  )

Definition at line 7416 of file trigger_manager.c.

References tr_Execution_enabled.

Referenced by check_merge_trigger(), check_trigger(), do_run_update_query_for_class(), and sm_active_triggers().

Here is the caller graph for this function:

int tr_get_trace ( void  )

Definition at line 7138 of file trigger_manager.c.

References tr_Trace.

Referenced by do_get_trigger().

Here is the caller graph for this function:

int tr_has_user_trigger ( bool has_user_trigger)
int tr_install ( void  )

Definition at line 7406 of file trigger_manager.c.

References define_trigger_classes().

Referenced by boot_initialize_client().

Here is the caller graph for this function:

int tr_is_trigger ( DB_OBJECT trigger_object,
int *  status 
)

Definition at line 6555 of file trigger_manager.c.

References error(), NO_ERROR, sm_find_class(), sm_get_class(), and TR_CLASS_NAME.

Referenced by help_print_obj().

Here is the caller graph for this function:

int tr_merge_schema_cache ( TR_SCHEMA_CACHE destination,
TR_SCHEMA_CACHE source 
)

Definition at line 2382 of file trigger_manager.c.

References error(), ml_add(), db_objlist::next, NO_ERROR, NULL, tr_schema_cache::objects, and db_objlist::op.

Referenced by flatten_trigger_cache().

Here is the caller graph for this function:

int tr_prepare_class ( TR_STATE **  state_p,
TR_SCHEMA_CACHE cache,
MOP  class_mop,
DB_TRIGGER_EVENT  event 
)
static char * tr_process_name ( const char *  name_string)
static

Definition at line 307 of file trigger_manager.c.

References NULL, sm_check_name(), sm_downcase_name(), SM_MAX_IDENTIFIER_LENGTH, and strdup().

Referenced by tr_create_trigger(), and tr_rename_trigger().

Here is the caller graph for this function:

int tr_set_depth ( int  depth)

Definition at line 7117 of file trigger_manager.c.

References ARG_FILE_LINE, ER_ERROR_SEVERITY, er_set(), ER_TR_MAX_DEPTH_TOO_BIG, NO_ERROR, TR_MAX_RECURSION_LEVEL, and tr_Maximum_depth.

Referenced by do_set_trigger().

Here is the caller graph for this function:

bool tr_set_execution_state ( bool  new_state)

Definition at line 7430 of file trigger_manager.c.

References tr_Execution_enabled.

Referenced by db_disable_trigger(), db_enable_trigger(), do_run_update_query_for_class(), and sm_truncate_using_delete().

Here is the caller graph for this function:

int tr_set_trace ( bool  trace)

Definition at line 7149 of file trigger_manager.c.

References NO_ERROR, and tr_Trace.

Referenced by do_set_trigger().

Here is the caller graph for this function:

const char* tr_time_as_string ( DB_TRIGGER_TIME  time)

Definition at line 6583 of file trigger_manager.c.

References TR_TIME_AFTER, TR_TIME_BEFORE, and TR_TIME_DEFERRED.

Referenced by object_printer::describe_trigger_action_time(), object_printer::describe_trigger_condition_time(), and tr_dump_trigger().

Here is the caller graph for this function:

int tr_trigger_action ( DB_OBJECT trigger_object,
char **  action 
)
int tr_trigger_action_time ( DB_OBJECT trigger_object,
DB_TRIGGER_TIME tr_time 
)

Definition at line 6456 of file trigger_manager.c.

References tr_trigger::action, ASSERT_ERROR_AND_SET, AU_DISABLE, AU_ENABLE, error(), NO_ERROR, NULL, tr_activity::time, tr_map_trigger(), and TR_TIME_NULL.

Referenced by db_trigger_action_time().

Here is the caller graph for this function:

int tr_trigger_action_type ( DB_OBJECT trigger_object,
DB_TRIGGER_ACTION type 
)

Definition at line 6490 of file trigger_manager.c.

References tr_trigger::action, ASSERT_ERROR_AND_SET, AU_DISABLE, AU_ENABLE, error(), NO_ERROR, NULL, TR_ACT_NULL, tr_map_trigger(), and tr_activity::type.

Referenced by db_trigger_action_type().

Here is the caller graph for this function:

int tr_trigger_attribute ( DB_OBJECT trigger_object,
char **  attribute 
)

Definition at line 6286 of file trigger_manager.c.

References ASSERT_ERROR_AND_SET, tr_trigger::attribute, AU_DISABLE, AU_ENABLE, error(), NO_ERROR, NULL, tr_map_trigger(), and ws_copy_string().

Referenced by db_trigger_attribute().

Here is the caller graph for this function:

int tr_trigger_class ( DB_OBJECT trigger_object,
DB_OBJECT **  class_mop_p 
)

Definition at line 6250 of file trigger_manager.c.

References ASSERT_ERROR_AND_SET, AU_DISABLE, AU_ENABLE, tr_trigger::class_mop, error(), NO_ERROR, NULL, and tr_map_trigger().

Referenced by db_trigger_class().

Here is the caller graph for this function:

int tr_trigger_comment ( DB_OBJECT trigger_object,
char **  comment 
)

Definition at line 6525 of file trigger_manager.c.

References ASSERT_ERROR_AND_SET, AU_DISABLE, AU_ENABLE, tr_trigger::comment, error(), NO_ERROR, NULL, tr_map_trigger(), and ws_copy_string().

Referenced by db_trigger_comment().

Here is the caller graph for this function:

int tr_trigger_condition ( DB_OBJECT trigger_object,
char **  condition 
)
int tr_trigger_condition_time ( DB_OBJECT trigger_object,
DB_TRIGGER_TIME tr_time 
)

Definition at line 6358 of file trigger_manager.c.

References ASSERT_ERROR_AND_SET, AU_DISABLE, AU_ENABLE, tr_trigger::condition, error(), NO_ERROR, NULL, tr_activity::time, tr_map_trigger(), and TR_TIME_NULL.

Referenced by db_trigger_condition_time().

Here is the caller graph for this function:

int tr_trigger_event ( DB_OBJECT trigger_object,
DB_TRIGGER_EVENT event 
)

Definition at line 6214 of file trigger_manager.c.

References ASSERT_ERROR_AND_SET, AU_DISABLE, AU_ENABLE, error(), tr_trigger::event, NO_ERROR, NULL, TR_EVENT_NULL, and tr_map_trigger().

Referenced by db_trigger_event(), and get_user_trigger_objects().

Here is the caller graph for this function:

int tr_trigger_name ( DB_OBJECT trigger_object,
char **  name 
)

Definition at line 6109 of file trigger_manager.c.

References ASSERT_ERROR_AND_SET, AU_DISABLE, AU_ENABLE, error(), tr_trigger::name, NO_ERROR, NULL, tr_map_trigger(), and ws_copy_string().

Referenced by db_trigger_name(), and help_trigger_names().

Here is the caller graph for this function:

int tr_trigger_priority ( DB_OBJECT trigger_object,
double *  priority 
)

Definition at line 6179 of file trigger_manager.c.

References ASSERT_ERROR_AND_SET, AU_DISABLE, AU_ENABLE, error(), NO_ERROR, NULL, tr_trigger::priority, TR_LOWEST_PRIORITY, and tr_map_trigger().

Referenced by db_trigger_priority().

Here is the caller graph for this function:

int tr_trigger_status ( DB_OBJECT trigger_object,
DB_TRIGGER_STATUS status 
)

Definition at line 6144 of file trigger_manager.c.

References ASSERT_ERROR_AND_SET, AU_DISABLE, AU_ENABLE, error(), NO_ERROR, NULL, tr_trigger::status, tr_map_trigger(), and TR_STATUS_INACTIVE.

Referenced by db_trigger_status().

Here is the caller graph for this function:

int tr_unmap_trigger ( TR_TRIGGER trigger)

Definition at line 1879 of file trigger_manager.c.

References ASSERT_ERROR_AND_SET, error(), mht_rem(), NO_ERROR, NULL, and tr_trigger::object.

Referenced by tr_drop_trigger_internal().

Here is the caller graph for this function:

static int trigger_table_find ( const char *  name,
DB_OBJECT **  trigger_p 
)
static
static int unregister_user_trigger ( TR_TRIGGER trigger,
int  rollback 
)
static

Variable Documentation

const char* EVAL_PREFIX = "EVALUATE ( "
static

Definition at line 127 of file trigger_manager.c.

Referenced by compile_trigger_activity().

const char* EVAL_SUFFIX = " ) "
static

Definition at line 128 of file trigger_manager.c.

Referenced by compile_trigger_activity().

const char* NEW_REFERENCE_NAME = "new"
static

Definition at line 118 of file trigger_manager.c.

Referenced by get_reference_names(), and tr_check_correlation().

const char* OBJ_REFERENCE_NAME = "obj"
static

Definition at line 117 of file trigger_manager.c.

Referenced by get_reference_names().

const char* OLD_REFERENCE_NAME = "old"
static

Definition at line 119 of file trigger_manager.c.

Referenced by get_reference_names().

const char* TR_ATT_ACTION = "action_definition"

Definition at line 144 of file trigger_manager.c.

Referenced by define_trigger_classes(), object_to_trigger(), and trigger_to_object().

const char* TR_ATT_ACTION_OLD = "action"

Definition at line 145 of file trigger_manager.c.

Referenced by object_to_trigger(), and trigger_to_object().

const char* TR_ATT_ACTION_TIME = "action_time"

Definition at line 143 of file trigger_manager.c.

Referenced by define_trigger_classes(), object_to_trigger(), and trigger_to_object().

const char* TR_ATT_ACTION_TYPE = "action_type"

Definition at line 142 of file trigger_manager.c.

Referenced by define_trigger_classes(), object_to_trigger(), and trigger_to_object().

const char* TR_ATT_ATTRIBUTE = "target_attribute"

Definition at line 137 of file trigger_manager.c.

Referenced by define_trigger_classes(), object_to_trigger(), and trigger_to_object().

const char* TR_ATT_CLASS = "target_class"

Definition at line 136 of file trigger_manager.c.

Referenced by define_trigger_classes(), object_to_trigger(), and trigger_to_object().

const char* TR_ATT_CLASS_ATTRIBUTE = "target_class_attribute"

Definition at line 138 of file trigger_manager.c.

Referenced by define_trigger_classes(), object_to_trigger(), and trigger_to_object().

const char* TR_ATT_COMMENT = "comment"
const char* TR_ATT_CONDITION = "condition"

Definition at line 141 of file trigger_manager.c.

Referenced by define_trigger_classes(), object_to_trigger(), and trigger_to_object().

const char* TR_ATT_CONDITION_TIME = "condition_time"

Definition at line 140 of file trigger_manager.c.

Referenced by define_trigger_classes(), object_to_trigger(), and trigger_to_object().

const char* TR_ATT_CONDITION_TYPE = "condition_type"

Definition at line 139 of file trigger_manager.c.

Referenced by define_trigger_classes(), object_to_trigger(), and trigger_to_object().

const char* TR_ATT_EVENT = "event"

Definition at line 133 of file trigger_manager.c.

Referenced by define_trigger_classes(), object_to_trigger(), and trigger_to_object().

const char* TR_ATT_NAME = "name"
const char* TR_ATT_OWNER = "owner"
const char* TR_ATT_PRIORITY = "priority"
const char* TR_ATT_PROPERTIES = "properties"

Definition at line 146 of file trigger_manager.c.

const char* TR_ATT_STATUS = "status"
const char* TR_CLASS_NAME = "db_trigger"
int tr_Current_depth = 0
TR_DEFERRED_CONTEXT* tr_Deferred_activities = NULL

Definition at line 158 of file trigger_manager.c.

TR_DEFERRED_CONTEXT* tr_Deferred_activities_tail = NULL
const int TR_EST_MAP_SIZE = 1024
static

Definition at line 115 of file trigger_manager.c.

Referenced by tr_init().

bool tr_Execution_enabled = true
static

Definition at line 172 of file trigger_manager.c.

Referenced by tr_get_execution_state(), and tr_set_execution_state().

bool tr_Invalid_transaction = false
char tr_Invalid_transaction_trigger[SM_MAX_IDENTIFIER_LENGTH+2]

Definition at line 154 of file trigger_manager.c.

Referenced by eval_action(), tr_check_commit_triggers(), and tr_init().

int tr_Maximum_depth = TR_MAX_RECURSION_LEVEL

Definition at line 150 of file trigger_manager.c.

Referenced by start_state(), tr_get_depth(), tr_init(), and tr_set_depth().

MHT_TABLE* tr_object_map = NULL
static

Definition at line 184 of file trigger_manager.c.

const int TR_RETURN_ERROR = -1
static
const int TR_RETURN_FALSE = 0
static

Definition at line 104 of file trigger_manager.c.

Referenced by execute_activity().

const int TR_RETURN_TRUE = 1
static
TR_SCHEMA_CACHE* tr_Schema_caches = NULL
static

Definition at line 166 of file trigger_manager.c.

Referenced by tr_make_schema_cache().

Definition at line 151 of file trigger_manager.c.

bool tr_Trace = true

Definition at line 156 of file trigger_manager.c.

Referenced by eval_action(), eval_condition(), tr_get_trace(), tr_init(), and tr_set_trace().

TR_TRIGLIST* tr_Uncommitted_triggers = NULL
static

Definition at line 165 of file trigger_manager.c.

TR_TRIGLIST* tr_User_triggers = NULL
static

Definition at line 163 of file trigger_manager.c.

int tr_User_triggers_modified = 0
static
int tr_User_triggers_valid = 0
static