1 /* Copyright (c) 2008, 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 NDB_DBTUP_PROXY
24 #define NDB_DBTUP_PROXY
25 
26 #include <LocalProxy.hpp>
27 #include <signaldata/CreateTab.hpp>
28 #include <signaldata/DropTab.hpp>
29 #include <signaldata/BuildIndxImpl.hpp>
30 
31 #define JAM_FILE_ID 403
32 
33 
34 class DbtupProxy : public LocalProxy {
35 public:
36   DbtupProxy(Block_context& ctx);
37   virtual ~DbtupProxy();
38   BLOCK_DEFINES(DbtupProxy);
39 
40 protected:
41   virtual SimulatedBlock* newWorker(Uint32 instanceNo);
42 
43   class Pgman* c_pgman; // PGMAN proxy
44 
45   Uint32 c_tableRecSize;
46   Uint8* c_tableRec;    // bool => table exists
47 
48   // GSN_READ_CONFIG_REQ
49   virtual void callREAD_CONFIG_REQ(Signal*);
50 
51   // GSN_STTOR
52   virtual void callSTTOR(Signal*);
53 
54   // GSN_CREATE_TAB_REQ
55   void execCREATE_TAB_REQ(Signal*);
56   // GSN_DROP_TAB_REQ
57   void execDROP_TAB_REQ(Signal*);
58 
59   // GSN_BUILD_INDX_IMPL_REQ
60   struct Ss_BUILD_INDX_IMPL_REQ : SsParallel {
61     BuildIndxImplReq m_req;
Ss_BUILD_INDX_IMPL_REQDbtupProxy::Ss_BUILD_INDX_IMPL_REQ62     Ss_BUILD_INDX_IMPL_REQ() {
63       m_sendREQ = (SsFUNCREQ)&DbtupProxy::sendBUILD_INDX_IMPL_REQ;
64       m_sendCONF = (SsFUNCREP)&DbtupProxy::sendBUILD_INDX_IMPL_CONF;
65     }
66     enum { poolSize = 1 };
poolDbtupProxy::Ss_BUILD_INDX_IMPL_REQ67     static SsPool<Ss_BUILD_INDX_IMPL_REQ>& pool(LocalProxy* proxy) {
68       return ((DbtupProxy*)proxy)->c_ss_BUILD_INDX_IMPL_REQ;
69     }
70   };
71   SsPool<Ss_BUILD_INDX_IMPL_REQ> c_ss_BUILD_INDX_IMPL_REQ;
72   void execBUILD_INDX_IMPL_REQ(Signal*);
73   void sendBUILD_INDX_IMPL_REQ(Signal*, Uint32 ssId, SectionHandle*);
74   void execBUILD_INDX_IMPL_CONF(Signal*);
75   void execBUILD_INDX_IMPL_REF(Signal*);
76   void sendBUILD_INDX_IMPL_CONF(Signal*, Uint32 ssId);
77 
78   // client methods
79   friend class Dbtup_client;
80 
81   // LGMAN
82 
83   struct Proxy_undo {
84     enum { MaxData = 20 + MAX_TUPLE_SIZE_IN_WORDS };
85     Uint32 m_type;
86     Uint32 m_len;
87     const Uint32* m_ptr;
88     Uint32 m_data[MaxData]; // copied from m_ptr at once
89     Uint64 m_lsn;
90     // from undo entry and page
91     Local_key m_key;
92     Uint32 m_page_id;
93     Uint32 m_table_id;
94     Uint32 m_fragment_id;
95     Uint32 m_instance_no;
96     enum {
97       SendToAll = 1,
98       ReadTupPage = 2,
99       GetInstance = 4,
100       NoExecute = 8,
101       SendUndoNext = 16
102     };
103     Uint32 m_actions;
104     bool m_in_use;
105     Proxy_undo();
106   };
107   Proxy_undo c_proxy_undo;
108 
109   void disk_restart_undo(Signal*, Uint64 lsn,
110                          Uint32 type, const Uint32 * ptr, Uint32 len);
111 
112   // next 3 are helper methods
113   void disk_restart_undo_callback(Signal*, Uint32, Uint32 page_id);
114 
115   void disk_restart_undo_finish(Signal*);
116 
117   void disk_restart_undo_send(Signal*, Uint32 i);
118 
119   // TSMAN
120 
121   int disk_restart_alloc_extent(Uint32 tableId, Uint32 fragId,
122 				const Local_key* key, Uint32 pages);
123   void disk_restart_page_bits(Uint32 tableId, Uint32 fragId,
124 			      const Local_key* key, Uint32 bits);
125 };
126 
127 
128 #undef JAM_FILE_ID
129 
130 #endif
131