MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ndbinfo.hpp
1 /*
2  Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
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 as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef KERNEL_NDBINFO_HPP
19 #define KERNEL_NDBINFO_HPP
20 
21 #include <signaldata/DbinfoScan.hpp>
22 
23 class Ndbinfo {
24 public:
25 
26  enum ColumnType {
27  String = 1,
28  Number = 2,
29  Number64 = 3
30  };
31 
32  struct Column {
33  const char* name;
34  ColumnType coltype;
35  const char* comment;
36  };
37 
38  enum TableId {
39  TABLES_TABLEID = 0,
40  COLUMNS_TABLEID = 1,
41  TEST_TABLEID = 2,
42  POOLS_TABLEID = 3,
43  TRANSPORTERS_TABLEID = 4,
44  LOGSPACES_TABLEID = 5,
45  LOGBUFFERS_TABLEID = 6,
46  RESOURCES_TABLEID = 7,
47  COUNTERS_TABLEID = 8,
48  NODES_TABLEID = 9,
49  DISKPAGEBUFFER_TABLEID = 10
50  };
51 
52  struct Table {
53  struct Members {
54  const char* name;
55  int ncols;
56  int flags;
57  const char* comment;
58  } m;
59  Column col[1];
60 
61  int columns(void) const {
62  return m.ncols;
63  }
64  };
65  static int getNumTables();
66  static const Table& getTable(int i);
67  static const Table& getTable(Uint32 i);
68 
69  class Row {
70  friend class SimulatedBlock;
71  Uint32* start; // Start of row buffer
72  Uint32* curr; // Current position in row buffer
73  Uint32* end; // End of buffer
74  int col_counter; // Current column counter
75  DbinfoScan& m_req; // The scan parameters
76  Row(); // Not impl
77  Row(const Row&); // Not impl
78  public:
79 
80  Row(class Signal* signal, DbinfoScanReq& req);
81 
82  Uint32 getLength(void) const {
83  return (Uint32)(curr - start);
84  }
85 
86  Uint32* getDataPtr() const {
87  return start;
88  }
89 
90  void write_string(const char* col);
91  void write_uint32(Uint32 value);
92  void write_uint64(Uint64 value);
93 
94  int columns(void) const {
95  return col_counter;
96  }
97 
98  private:
99  bool check_buffer_space(class AttributeHeader& ah) const;
100  void check_attribute_type(class AttributeHeader& ah, ColumnType) const;
101  };
102 
103  struct ScanCursor
104  {
105  Uint32 senderRef;
106  Uint32 saveSenderRef;
107  Uint32 currRef; // The current node, block and instance
108  Uint32 saveCurrRef;
118  Uint32 flags;
119  Uint32 data[4]; // Cursor data
120 
121  Uint32 totalRows;
122  Uint32 totalBytes;
123  STATIC_CONST( Length = 10 );
124 
125  STATIC_CONST( MOREDATA_SHIFT = 0 );
126  STATIC_CONST( MOREDATA_MASK = 1 );
127 
128  static bool getHasMoreData(const UintR & flags){
129  return (bool)((flags >> MOREDATA_SHIFT) & MOREDATA_MASK);
130  }
131  static void setHasMoreData(UintR & flags, bool value){
132  flags = (flags & ~(MOREDATA_MASK << MOREDATA_SHIFT)) |
133  ((value & MOREDATA_MASK) << MOREDATA_SHIFT);
134  }
135  };
136 
137  class Ratelimit {
138  friend class SimulatedBlock;
139  Uint32 rows;
140  Uint32 bytes;
141  Ratelimit(const Ratelimit&);// Not impl
142  public:
143  Ratelimit() :
144  rows(0),
145  bytes(0){
146  }
147 
148  bool need_break(const DbinfoScan& scan) const
149  {
150  const Uint32 MAX_ROWS = 256;
151 
152  // Upgrade zero to MAX_ROWS
153  Uint32 maxRows = scan.maxRows ? scan.maxRows : MAX_ROWS;
154 
155  // Limit maxRows to MAX_ROWS
156  if (maxRows > MAX_ROWS)
157  maxRows = MAX_ROWS;
158 
159  if (maxRows != 0 && rows >= maxRows)
160  return true; // More than max rows already sent
161  if (scan.maxBytes != 0 && bytes >= scan.maxBytes)
162  return true; // More than max bytes already sent
163  return false;
164  }
165  };
166 
167  struct pool_entry {
168  const char* poolname;
169  Uint64 used;
170  Uint64 total;
171  Uint64 entry_size;
172  Uint64 used_hi;
173  Uint32 config_params[4];
174  };
175 
176  enum counter_id {
177  ATTRINFO_COUNTER = 1,
178  TRANSACTIONS_COUNTER = 2,
179  COMMITS_COUNTER = 3,
180  READS_COUNTER = 4,
181  SIMPLE_READS_COUNTER = 5,
182  WRITES_COUNTER = 6,
183  ABORTS_COUNTER = 7,
184  TABLE_SCANS_COUNTER = 8,
185  RANGE_SCANS_COUNTER = 9,
186  OPERATIONS_COUNTER = 10,
187  /* Counters fetched from the SPJ block.*/
188  SPJ_READS_RECEIVED_COUNTER = 11,
189  SPJ_LOCAL_READS_SENT_COUNTER = 12,
190  SPJ_REMOTE_READS_SENT_COUNTER = 13,
191  SPJ_READS_NOT_FOUND_COUNTER = 14,
192  SPJ_TABLE_SCANS_RECEIVED_COUNTER = 15,
193  SPJ_LOCAL_TABLE_SCANS_SENT_COUNTER = 16,
194  SPJ_RANGE_SCANS_RECEIVED_COUNTER = 17,
195  SPJ_LOCAL_RANGE_SCANS_SENT_COUNTER = 18,
196  SPJ_REMOTE_RANGE_SCANS_SENT_COUNTER = 19,
197  SPJ_SCAN_BATCHES_RETURNED_COUNTER = 20,
198  SPJ_SCAN_ROWS_RETURNED_COUNTER = 21,
199  SPJ_PRUNED_RANGE_SCANS_RECEIVED_COUNTER = 22,
200  SPJ_CONST_PRUNED_RANGE_SCANS_RECEIVED_COUNTER = 23
201  };
202 
203  struct counter_entry {
204  counter_id id;
205  Uint64 val;
206  };
207 };
208 
209 #endif