MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / create_set_null_trg

Function create_set_null_trg

src/gpre/cmd.cpp:1036–1122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1034//
1035
1036static void create_set_null_trg(gpre_req* request,
1037 const act* action,
1038 cnstrt* constraint,
1039 bool on_upd_trg)
1040{
1041 gpre_lls* for_key_fld = constraint->cnstrt_fields;
1042 const gpre_rel* relation = (gpre_rel*) action->act_object;
1043
1044 // no trigger name. It is generated by the engine
1045 put_string(request, isc_dyn_def_trigger, "", (USHORT) 0);
1046
1047 put_numeric(request, isc_dyn_trg_type,
1048 (SSHORT) (on_upd_trg ? POST_MODIFY_TRIGGER : POST_ERASE_TRIGGER));
1049
1050 request->add_byte(isc_dyn_sql_object);
1051 put_numeric(request, isc_dyn_trg_sequence, (SSHORT) 1);
1052 put_numeric(request, isc_dyn_trg_inactive, (SSHORT) 0);
1053 put_cstring(request, isc_dyn_rel_name, constraint->cnstrt_referred_rel->str_string);
1054
1055 // the trigger blr
1056
1057 request->add_byte(isc_dyn_trg_blr);
1058 const USHORT offset = request->req_blr - request->req_base;
1059
1060 request->add_word(0);
1061 if (request->req_flags & REQ_blr_version4)
1062 request->add_byte(blr_version4);
1063 else
1064 request->add_byte(blr_version5);
1065
1066 // for ON UPDATE TRIGGER only: generate the trigger firing condition:
1067 // if prim_key.old_value != prim_key.new value.
1068 // Note that the key could consist of multiple columns
1069
1070 if (on_upd_trg)
1071 {
1072 create_trg_firing_cond(request, constraint);
1073 request->add_byte(blr_begin);
1074 request->add_byte(blr_begin);
1075 }
1076
1077 request->add_byte(blr_for);
1078 request->add_byte(blr_rse);
1079
1080 // the context for the prim. key relation
1081 request->add_byte(1);
1082
1083 request->add_byte(blr_relation);
1084 put_cstring(request, 0, relation->rel_symbol->sym_string);
1085 // the context for the foreign key relation
1086 request->add_byte(2);
1087
1088 create_matching_blr(request, constraint);
1089
1090 request->add_byte(blr_modify);
1091 request->add_byte((SSHORT) 2);
1092 request->add_byte((SSHORT) 2);
1093 request->add_byte(blr_begin);

Callers 1

create_constraintFunction · 0.85

Calls 7

put_stringFunction · 0.85
put_cstringFunction · 0.85
create_trg_firing_condFunction · 0.85
create_matching_blrFunction · 0.85
put_numericFunction · 0.70
add_byteMethod · 0.45
add_wordMethod · 0.45

Tested by

no test coverage detected