MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ndb_thd_ndb.h
1 /*
2  Copyright (c) 2011, 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 NDB_THD_NDB_H
19 #define NDB_THD_NDB_H
20 
21 #include <my_global.h>
22 #include <my_base.h> // ha_rows
23 #include <sql_list.h> // List<>
24 #include <hash.h> // HASH
25 
26 #include "ndb_share.h"
27 
28 #include <kernel/ndb_limits.h> // MAX_NDB_NODES
29 
30 /*
31  Place holder for ha_ndbcluster thread specific data
32 */
33 
34 enum THD_NDB_OPTIONS
35 {
36  TNO_NO_LOG_SCHEMA_OP= 1 << 0,
37  /*
38  In participating mysqld, do not try to acquire global schema
39  lock, as one other mysqld already has the lock.
40  */
41  TNO_NO_LOCK_SCHEMA_OP= 1 << 1
42  /*
43  Skip drop of ndb table in delete_table. Used when calling
44  mysql_rm_table_part2 in "show tables", as we do not want to
45  remove ndb tables "by mistake". The table should not exist
46  in ndb in the first place.
47  */
48  ,TNO_NO_NDB_DROP_TABLE= 1 << 2
49 };
50 
51 enum THD_NDB_TRANS_OPTIONS
52 {
53  TNTO_INJECTED_APPLY_STATUS= 1 << 0
54  ,TNTO_NO_LOGGING= 1 << 1
55  ,TNTO_TRANSACTIONS_OFF= 1 << 2
56 };
57 
58 class Thd_ndb
59 {
60  THD* m_thd;
61 
62  Thd_ndb(THD*);
63  ~Thd_ndb();
64 public:
65  static Thd_ndb* seize(THD*);
66  static void release(Thd_ndb* thd_ndb);
67 
68  void init_open_tables();
69 
70  class Ndb_cluster_connection *connection;
71  class Ndb *ndb;
72  class ha_ndbcluster *m_handler;
73  ulong count;
74  uint lock_count;
75  uint start_stmt_count;
76  uint save_point_count;
77  class NdbTransaction *trans;
78  bool m_error;
79  bool m_slow_path;
80  bool m_force_send;
81 
82  uint32 options;
83  uint32 trans_options;
84  List<NDB_SHARE> changed_tables;
86  /*
87  This is a memroot used to buffer rows for batched execution.
88  It is reset after every execute().
89  */
90  MEM_ROOT m_batch_mem_root;
91  /*
92  Estimated pending batched execution bytes, once this is > BATCH_FLUSH_SIZE
93  we execute() to flush the rows buffered in m_batch_mem_root.
94  */
95  uint m_unsent_bytes;
96  uint m_batch_size;
97 
98  uint m_execute_count;
99 
100  uint m_scan_count;
101  uint m_pruned_scan_count;
102 
105 
127 
128  uint m_transaction_no_hint_count[MAX_NDB_NODES];
129  uint m_transaction_hint_count[MAX_NDB_NODES];
130 
131  NdbTransaction *global_schema_lock_trans;
132  uint global_schema_lock_count;
133  uint global_schema_lock_error;
134  uint schema_locks_count; // Number of global schema locks taken by thread
135  bool has_required_global_schema_lock(const char* func);
136 
137  unsigned m_connect_count;
138  bool valid_ndb(void);
139  bool recycle_ndb(THD* thd);
140 };
141 
142 #endif