1 /*
2    Copyright (c) 2009, 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
22    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
23  */
24 
25 #ifndef NDBINFO_SCAN_NODES_H
26 #define NDBINFO_SCAN_NODES_H
27 
28 #include "NdbInfoScanOperation.hpp"
29 
30 #include "kernel/NodeBitmask.hpp"
31 
32 /*
33   Scan implementation for retrieving rows from the NDB
34   data nodes.
35 */
36 class NdbInfoScanNodes : public NdbInfoScanOperation {
37 public:
38   virtual int readTuples();
39   virtual const class NdbInfoRecAttr* getValue(const char * anAttrName);
40   virtual const class NdbInfoRecAttr* getValue(Uint32 anAttrId);
41   virtual int execute();
42   virtual int nextResult();
43 
44   NdbInfoScanNodes(const NdbInfo&,
45                    class Ndb_cluster_connection*,
46                    const NdbInfo::Table*,
47                    Uint32 max_rows, Uint32 max_bytes,
48                    Uint32 max_nodes);
49   int init(Uint32 id);
50 
51   virtual ~NdbInfoScanNodes();
52 private:
53   bool execDBINFO_TRANSID_AI(const struct SimpleSignal * signal);
54   bool execDBINFO_SCANCONF(const struct SimpleSignal * signal);
55   bool execDBINFO_SCANREF(const struct SimpleSignal * signal, int& error_code);
56   int sendDBINFO_SCANREQ();
57 
58   int receive(void);
59   bool find_next_node();
60 
61   const NdbInfo& m_info;
62   enum State { Undefined, Initial, Prepared,
63                MoreData, End, Error } m_state;
64   class Ndb_cluster_connection* m_connection;
65   class SignalSender*           m_signal_sender;
66   const NdbInfo::Table*     m_table;
67   NdbInfoRecAttrCollection m_recAttrs;
68   Vector<Uint32>                m_cursor;
69   Uint32 m_node_id;
70   Uint32 m_transid0;
71   Uint32 m_transid1;
72   Uint32 m_result_ref;
73   Uint32 m_max_rows;
74   Uint32 m_max_bytes;
75   Uint32 m_result_data;
76   Uint32 m_rows_received;
77   Uint32 m_rows_confirmed;
78   Uint32 m_nodes; // Number of nodes scanned
79   const Uint32 m_max_nodes; // Max number of nodes to scan
80   NodeBitmask m_nodes_to_scan;
81 };
82 
83 
84 #endif
85