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

Method check_n_load

sql/sql_trigger.cc:1716–2066  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1714*/
1715
1716bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db,
1717 const LEX_CSTRING *table_name,
1718 TABLE *table,
1719 bool names_only)
1720{
1721 char path_buff[FN_REFLEN];
1722 LEX_CSTRING path;
1723 File_parser *parser;
1724 LEX_CSTRING save_db;
1725 DBUG_ENTER("Table_triggers_list::check_n_load");
1726
1727 path.length= build_table_filename(path_buff, FN_REFLEN - 1,
1728 db->str, table_name->str, TRG_EXT, 0);
1729 path.str= path_buff;
1730
1731 // QQ: should we analyze errno somehow ?
1732 if (access(path_buff, F_OK))
1733 DBUG_RETURN(0);
1734
1735 /* File exists so we got to load triggers */
1736
1737 if ((parser= sql_parse_prepare(&path, &table->mem_root, 1)))
1738 {
1739 if (is_equal(&triggers_file_type, parser->type()))
1740 {
1741 Handle_old_incorrect_sql_modes_hook sql_modes_hook(path.str);
1742 LEX_CSTRING *trg_create_str, *trg_sql_path;
1743 ulonglong *trg_sql_mode, *trg_create_time;
1744 Trigger *trigger;
1745 Table_triggers_list *trigger_list=
1746 new (&table->mem_root) Table_triggers_list(table);
1747 if (unlikely(!trigger_list))
1748 goto error;
1749
1750 if (parser->parse((uchar*)trigger_list, &table->mem_root,
1751 triggers_file_parameters,
1752 TRG_NUM_REQUIRED_PARAMETERS,
1753 &sql_modes_hook))
1754 goto error;
1755
1756 List_iterator_fast<LEX_CSTRING> it(trigger_list->definitions_list);
1757
1758 if (!trigger_list->definitions_list.is_empty() &&
1759 (trigger_list->client_cs_names.is_empty() ||
1760 trigger_list->connection_cl_names.is_empty() ||
1761 trigger_list->db_cl_names.is_empty()))
1762 {
1763 /* We will later use the current character sets */
1764 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
1765 ER_TRG_NO_CREATION_CTX,
1766 ER_THD(thd, ER_TRG_NO_CREATION_CTX),
1767 db->str,
1768 table_name->str);
1769 }
1770
1771 table->triggers= trigger_list;
1772 status_var_increment(thd->status_var.feature_trigger);
1773

Callers

nothing calls this directly

Calls 15

build_table_filenameFunction · 0.85
sql_parse_prepareFunction · 0.85
is_equalFunction · 0.85
push_warning_printfFunction · 0.85
createFunction · 0.85
lex_startFunction · 0.85
parse_sqlFunction · 0.85
Lex_ident_triggerClass · 0.85
lex_endFunction · 0.85
safe_lexcstrdup_rootFunction · 0.85

Tested by

no test coverage detected