1 /*
2    Copyright (c) 2014, 2021, Oracle and/or its affiliates.
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License, version 2.0,
6    as published by the Free Software Foundation.
7 
8    This program is also distributed with certain software (including
9    but not limited to OpenSSL) that is licensed under separate terms,
10    as designated in a particular file or component or in included license
11    documentation.  The authors of MySQL hereby grant you an additional
12    permission to link the program and your derivative works with the
13    separately licensed software that they have included with MySQL.
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 Foundation,
22    51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
23 
24 #ifndef TRIGGER_CREATION_CTX_H_INCLUDED
25 #define TRIGGER_CREATION_CTX_H_INCLUDED
26 
27 ///////////////////////////////////////////////////////////////////////////
28 
29 #include "sp_head.h" // Stored_program_creation_ctx
30 
31 /**
32   Trigger_creation_ctx -- creation context of triggers.
33 */
34 
35 class Trigger_creation_ctx : public Stored_program_creation_ctx,
36                              public Sql_alloc
37 {
38 public:
39   static Trigger_creation_ctx *create(THD *thd,
40                                       const LEX_CSTRING &db_name,
41                                       const LEX_CSTRING &table_name,
42                                       const LEX_STRING &client_cs_name,
43                                       const LEX_STRING &connection_cl_name,
44                                       const LEX_STRING &db_cl_name);
45 
46 public:
clone(MEM_ROOT * mem_root)47   virtual Stored_program_creation_ctx *clone(MEM_ROOT *mem_root)
48   {
49     return new (mem_root) Trigger_creation_ctx(m_client_cs,
50                                                m_connection_cl,
51                                                m_db_cl);
52   }
53 
54 protected:
create_backup_ctx(THD * thd)55   virtual Object_creation_ctx *create_backup_ctx(THD *thd) const
56   {
57     return new Trigger_creation_ctx(thd);
58   }
59 
60 private:
Trigger_creation_ctx(THD * thd)61   Trigger_creation_ctx(THD *thd)
62     :Stored_program_creation_ctx(thd)
63   { }
64 
Trigger_creation_ctx(const CHARSET_INFO * client_cs,const CHARSET_INFO * connection_cl,const CHARSET_INFO * db_cl)65   Trigger_creation_ctx(const CHARSET_INFO *client_cs,
66                        const CHARSET_INFO *connection_cl,
67                        const CHARSET_INFO *db_cl)
68     :Stored_program_creation_ctx(client_cs, connection_cl, db_cl)
69   { }
70 };
71 
72 ///////////////////////////////////////////////////////////////////////////
73 
74 #endif // TRIGGER_CREATION_CTX_H_INCLUDED
75