1 /* Copyright (c) 2011, 2021, 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 also distributed 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 included with MySQL.
13 
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License, version 2.0, for more details.
18 
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
22 
23 #ifndef MOCK_CREATE_FIELD_H
24 #define MOCK_CREATE_FIELD_H
25 
26 #include "field.h"
27 
28 class Mock_create_field : public Create_field
29 {
30   LEX_STRING m_lex_string;
31 public:
Mock_create_field(enum_field_types field_type,Item * insert_default,Item * update_default)32   Mock_create_field(enum_field_types field_type,
33                     Item* insert_default, Item* update_default)
34   {
35     /*
36       Only TIMESTAMP is implemented for now.
37       Other types would need different parameters (fld_length, etc).
38     */
39     assert(field_type == MYSQL_TYPE_TIMESTAMP ||
40            field_type == MYSQL_TYPE_TIMESTAMP2);
41     init(NULL, // THD *thd
42          NULL, // char *fld_name
43          field_type,
44          NULL, // char *fld_length
45          NULL, // char *fld_decimals,
46          0, // uint fld_type_modifier
47          insert_default, // Item *fld_default_value,
48          update_default, // Item *fld_on_update_value,
49          /*
50             Pointer can't be NULL, or Create_field::init() will
51             core dump. This is undocumented, of
52             course. </sarcasm>
53          */
54          &m_lex_string, // LEX_STRING *fld_comment,
55          NULL, // char *fld_change,
56          NULL, // List<String> *fld_interval_list,
57          NULL, // const CHARSET_INFO *fld_charset,
58          0 // uint fld_geom_type
59          );
60   }
61 };
62 
63 #endif // MOCK_CREATE_FIELD_H
64