| 1 | /* Copyright (c) 2011, 2026, Oracle and/or its affiliates. |
| 2 | |
| 3 | This program is free software; you can redistribute it and/or modify |
| 4 | it under the terms of the GNU General Public License, version 2.0, |
| 5 | as published by the Free Software Foundation. |
| 6 | |
| 7 | This program is designed to work with certain software (including |
| 8 | but not limited to OpenSSL) that is licensed under separate terms, |
| 9 | as designated in a particular file or component or in included license |
| 10 | documentation. The authors of MySQL hereby grant you an additional |
| 11 | permission to link the program and your derivative works with the |
| 12 | separately licensed software that they have either included with |
| 13 | the program or referenced in the documentation. |
| 14 | |
| 15 | This program is distributed in the hope that it will be useful, |
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | GNU General Public License, version 2.0, for more details. |
| 19 | |
| 20 | You should have received a copy of the GNU General Public License |
| 21 | along with this program; if not, write to the Free Software |
| 22 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
| 23 | |
| 24 | #ifndef MOCK_CREATE_FIELD_H |
| 25 | #define MOCK_CREATE_FIELD_H |
| 26 | |
| 27 | #include <assert.h> |
| 28 | |
| 29 | #include <optional> |
| 30 | |
| 31 | #include "sql/create_field.h" |
| 32 | #include "sql/dd/types/column.h" |
| 33 | |
| 34 | class Mock_create_field : public Create_field { |
| 35 | LEX_CSTRING m_lex_string{nullptr, 0}; |
| 36 | |
| 37 | public: |
| 38 | Mock_create_field(enum_field_types field_type, Item *insert_default, |
| 39 | Item *update_default) { |
| 40 | /* |
| 41 | Only TIMESTAMP is implemented for now. |
| 42 | Other types would need different parameters (fld_length, etc). |
| 43 | */ |
| 44 | assert(field_type == MYSQL_TYPE_TIMESTAMP || |
| 45 | field_type == MYSQL_TYPE_TIMESTAMP2); |
| 46 | init(nullptr, // THD *thd |
| 47 | nullptr, // char *fld_name |
| 48 | field_type, |
| 49 | nullptr, // char *fld_length |
| 50 | nullptr, // char *fld_decimals, |
| 51 | 0, // uint fld_type_modifier |
| 52 | insert_default, // Item *fld_default_value, |
| 53 | update_default, // Item *fld_on_update_value, |
| 54 | /* |
| 55 | Pointer can't be NULL, or Create_field::init() will |
| 56 | core dump. This is undocumented, of |
| 57 | course. </sarcasm> |
| 58 | */ |
| 59 | &m_lex_string, // LEX_CSTRING *fld_comment, |
| 60 | nullptr, // char *fld_change, |
| 61 | nullptr, // List<String> *fld_interval_list, |
| 62 | nullptr, // const CHARSET_INFO *fld_charset, |
| 63 | false, // bool has_explicit_collation, |
| 64 | 0, // uint fld_geom_type |
| 65 | nullptr, // gcol info |
| 66 | nullptr, // gen default val |
| 67 | {}, // std::optional<gis::srid_t> srid |
| 68 | dd::Column::enum_hidden_type::HT_VISIBLE); // Visible |
| 69 | } |
| 70 | }; |
| 71 | |
| 72 | #endif // MOCK_CREATE_FIELD_H |