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

Function copy_on_update_columns_list

sql/sql_trigger.cc:1646–1691  ·  view source on GitHub ↗

Deep copy of on update columns list created on parsing a trigger definition. The destination list and its elements are allocated on table's memory root. @param table_mem_root table mem_root from where a memory is allocated. @param [out] dst_col_names destination list where to copy an original one @param src_col_names source list that has to be copied @return false on success, true

Source from the content-addressed store, hash-verified

1644 @return false on success, true on OOM error
1645*/
1646static bool
1647copy_on_update_columns_list(MEM_ROOT *table_mem_root,
1648 List<LEX_CSTRING> **dst_col_names,
1649 List<LEX_CSTRING> *src_col_names)
1650{
1651 if (!src_col_names)
1652 {
1653 *dst_col_names= nullptr;
1654 return false;
1655 }
1656
1657 /*
1658 In case the clause <OF column_list> is present in definition of a trigger,
1659 the list lex.trg_chistics.on_update_col_names mustn't be empty.
1660 For the case where this clause is missed, the pointer
1661 lex.trg_chistics.on_update_col_names
1662 itself has nullptr value. So, do assert check here that the list is not
1663 empty.
1664 */
1665 DBUG_ASSERT(!src_col_names->is_empty());
1666
1667 List<LEX_CSTRING> *result= new (table_mem_root) List<LEX_CSTRING>();
1668 if (!result)
1669 return true; // OOM
1670
1671 List_iterator_fast<LEX_CSTRING> columns_it(*src_col_names);
1672 LEX_CSTRING *column_name;
1673
1674 while ((column_name= columns_it++))
1675 {
1676 LEX_CSTRING *cname= (LEX_CSTRING*)alloc_root(table_mem_root,
1677 sizeof(LEX_CSTRING));
1678
1679 if (!cname)
1680 return true; // OOM
1681
1682 *cname= safe_lexcstrdup_root(table_mem_root, *column_name);
1683
1684 if (!cname->str ||
1685 result->push_back(cname, table_mem_root))
1686 return true; // OOM
1687 }
1688
1689 *dst_col_names= result;
1690 return false;
1691}
1692
1693
1694/**

Callers 1

check_n_loadMethod · 0.85

Calls 4

alloc_rootFunction · 0.85
safe_lexcstrdup_rootFunction · 0.85
is_emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected