MCPcopy Create free account
hub / github.com/MariaDB/server / show_create_trigger_impl

Function show_create_trigger_impl

sql/sql_show.cc:11236–11362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11234*/
11235
11236static bool show_create_trigger_impl(THD *thd, Trigger *trigger)
11237{
11238 int ret_code;
11239 Protocol *p= thd->protocol;
11240 List<Item> fields;
11241 LEX_CSTRING trg_sql_mode_str, trg_body;
11242 LEX_CSTRING trg_sql_original_stmt;
11243 LEX_STRING trg_definer;
11244 CHARSET_INFO *trg_client_cs;
11245 MEM_ROOT *mem_root= thd->mem_root;
11246 char definer_holder[USER_HOST_BUFF_SIZE];
11247 trg_definer.str= definer_holder;
11248
11249 /*
11250 TODO: Check privileges here. This functionality will be added by
11251 implementation of the following WL items:
11252 - WL#2227: New privileges for new objects
11253 - WL#3482: Protect SHOW CREATE PROCEDURE | FUNCTION | VIEW | TRIGGER
11254 properly
11255
11256 SHOW TRIGGERS and I_S.TRIGGERS will be affected too.
11257 */
11258
11259 /* Prepare trigger "object". */
11260
11261 trigger->get_trigger_info(&trg_sql_original_stmt, &trg_body, &trg_definer);
11262 sql_mode_string_representation(thd, trigger->sql_mode, &trg_sql_mode_str);
11263
11264 /* Resolve trigger client character set. */
11265 myf utf8_flag= thd->get_utf8_flag();
11266 if (resolve_charset(trigger->client_cs_name.str, NULL, &trg_client_cs,
11267 MYF(utf8_flag)))
11268 return TRUE;
11269
11270 /* Send header. */
11271
11272 fields.push_back(new (mem_root) Item_empty_string(thd, "Trigger", NAME_LEN),
11273 mem_root);
11274 fields.push_back(new (mem_root)
11275 Item_empty_string(thd, "sql_mode", (uint)trg_sql_mode_str.length),
11276 mem_root);
11277
11278 {
11279 /*
11280 NOTE: SQL statement field must be not less than 1024 in order not to
11281 confuse old clients.
11282 */
11283
11284 Item_empty_string *stmt_fld=
11285 new (mem_root) Item_empty_string(thd, "SQL Original Statement",
11286 (uint)MY_MAX(trg_sql_original_stmt.length,
11287 1024));
11288
11289 stmt_fld->set_maybe_null();
11290
11291 fields.push_back(stmt_fld, mem_root);
11292 }
11293

Callers 1

show_create_triggerFunction · 0.85

Calls 15

resolve_charsetFunction · 0.85
Lex_cstringClass · 0.85
my_eofFunction · 0.85
get_trigger_infoMethod · 0.80
get_utf8_flagMethod · 0.80
set_maybe_nullMethod · 0.80
gmt_sec_to_TIMEMethod · 0.80
push_backMethod · 0.45
set_nameMethod · 0.45
prepare_for_resendMethod · 0.45

Tested by

no test coverage detected