1 /* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
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 St, 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   class Tsman *c_tsman;
45 
46   Uint32 c_tableRecSize;
47   Uint32* c_tableRec;    // bool => table exists
48 
49   // GSN_READ_CONFIG_REQ
50   virtual void callREAD_CONFIG_REQ(Signal*);
51 
52   // GSN_STTOR
53   virtual void callSTTOR(Signal*);
54 
55   // GSN_CREATE_TAB_REQ
56   void execCREATE_TAB_REQ(Signal*);
57   // GSN_DROP_TAB_REQ
58   void execDROP_TAB_REQ(Signal*);
59 
60   // GSN_BUILD_INDX_IMPL_REQ
61   struct Ss_BUILD_INDX_IMPL_REQ : SsParallel {
62     BuildIndxImplReq m_req;
Ss_BUILD_INDX_IMPL_REQDbtupProxy::Ss_BUILD_INDX_IMPL_REQ63     Ss_BUILD_INDX_IMPL_REQ() {
64       m_sendREQ = (SsFUNCREQ)&DbtupProxy::sendBUILD_INDX_IMPL_REQ;
65       m_sendCONF = (SsFUNCREP)&DbtupProxy::sendBUILD_INDX_IMPL_CONF;
66     }
67     enum { poolSize = 1 };
poolDbtupProxy::Ss_BUILD_INDX_IMPL_REQ68     static SsPool<Ss_BUILD_INDX_IMPL_REQ>& pool(LocalProxy* proxy) {
69       return ((DbtupProxy*)proxy)->c_ss_BUILD_INDX_IMPL_REQ;
70     }
71   };
72   SsPool<Ss_BUILD_INDX_IMPL_REQ> c_ss_BUILD_INDX_IMPL_REQ;
73   void execBUILD_INDX_IMPL_REQ(Signal*);
74   void sendBUILD_INDX_IMPL_REQ(Signal*, Uint32 ssId, SectionHandle*);
75   void execBUILD_INDX_IMPL_CONF(Signal*);
76   void execBUILD_INDX_IMPL_REF(Signal*);
77   void sendBUILD_INDX_IMPL_CONF(Signal*, Uint32 ssId);
78 
79   // client methods
80   friend class Dbtup_client;
81 
82   // LGMAN
83 
84   struct Proxy_undo {
85     Uint32 m_type;
86     Uint32 m_len;
87     const Uint32* m_ptr;
88     Uint32 m_data[MAX_UNDO_DATA]; // 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_create_table_version;
96     Uint32 m_instance_no;
97     enum {
98       SendToAll = 1,
99       ReadTupPage = 2,
100       GetInstance = 4,
101       NoExecute = 8,
102       SendUndoNext = 16
103     };
104     Uint32 m_actions;
105     bool m_in_use;
106     Proxy_undo();
107   };
108   Proxy_undo c_proxy_undo;
109 
110   void disk_restart_undo(Signal*, Uint64 lsn,
111                          Uint32 type, const Uint32 * ptr, Uint32 len);
112 
113   // next 3 are helper methods
114   void disk_restart_undo_callback(Signal*, Uint32, Uint32 page_id);
115 
116   void disk_restart_undo_finish(Signal*);
117 
118   void disk_restart_undo_send_next(Signal*, Uint32);
119 
120   void disk_restart_undo_send(Signal*, Uint32 i);
121 
122   // TSMAN
123 
124   int disk_restart_alloc_extent(EmulatedJamBuffer* jamBuf,
125                                 Uint32 tableId,
126                                 Uint32 fragId,
127                                 Uint32 create_table_version,
128 				const Local_key* key,
129                                 Uint32 pages);
130   void disk_restart_page_bits(Uint32 tableId,
131                               Uint32 fragId,
132                               Uint32 create_table_version,
133 			      const Local_key* key,
134                               Uint32 bits);
135 };
136 
137 
138 #undef JAM_FILE_ID
139 
140 #endif
141