| 1 | #ifndef ITEM_UTILS_H |
| 2 | #define ITEM_UTILS_H |
| 3 | |
| 4 | /* Copyright (c) 2020, 2026, Oracle and/or its affiliates. |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License, version 2.0, |
| 8 | as published by the Free Software Foundation. |
| 9 | |
| 10 | This program is designed to work with certain software (including |
| 11 | but not limited to OpenSSL) that is licensed under separate terms, |
| 12 | as designated in a particular file or component or in included license |
| 13 | documentation. The authors of MySQL hereby grant you an additional |
| 14 | permission to link the program and your derivative works with the |
| 15 | separately licensed software that they have either included with |
| 16 | the program or referenced in the documentation. |
| 17 | |
| 18 | This program is distributed in the hope that it will be useful, |
| 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | GNU General Public License, version 2.0, for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License |
| 24 | along with this program; if not, write to the Free Software |
| 25 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
| 26 | |
| 27 | #include "sql/parse_tree_nodes.h" |
| 28 | #include "sql/sql_class.h" // THD |
| 29 | #include "unittest/gunit/mock_parse_tree.h" // Mock_pt_item_list |
| 30 | |
| 31 | using my_testing::Mock_pt_item_list; |
| 32 | |
| 33 | /// @file Utilities for creating Item objects. |
| 34 | |
| 35 | /// Creates and resolves an Item. |
| 36 | template <typename Func_item, typename... Arg_type> |
| 37 | static Item *make_resolved(THD *thd, Arg_type... args) { |
| 38 | auto arglist = new (thd->mem_root) Mock_pt_item_list(args...); |
| 39 | Parse_context pc(thd, thd->lex->query_block); |
| 40 | POS pos; // We expect this object to be copied. |
| 41 | Item *item = new (thd->mem_root) Func_item(pos, arglist); |
| 42 | item->itemize(&pc, &item); |
| 43 | item->fix_fields(thd, nullptr); |
| 44 | return item; |
| 45 | } |
| 46 | |
| 47 | #endif // ITEM_UTILS_H |