MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NDBT_Table.hpp
1 /*
2  Copyright (c) 2003, 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 NDBT_TABLE_HPP
19 #define NDBT_TABLE_HPP
20 
21 #include <ndb_global.h>
22 
23 #include <NdbApi.hpp>
24 #include <NdbOut.hpp>
25 
27 public:
28  NDBT_Attribute(const char* _name,
30  int _length = 1,
31  bool _pk = false,
32  bool _nullable = false,
33  CHARSET_INFO *cs= 0,
34  NdbDictionary::Column::StorageType storage = NdbDictionary::Column::StorageTypeMemory,
35  bool dynamic = false,
36  const void* defaultVal = NULL,
37  Uint32 defaultValBytes = 0):
39  {
40  assert(_name != 0);
41 
42  setType(_type);
43  setLength(_length);
44  setNullable(_nullable);
45  setPrimaryKey(_pk);
46  if (cs)
47  {
48  setCharset(cs);
49  }
50  setStorageType(storage);
51  setDynamic(dynamic);
52  setDefaultValue(defaultVal, defaultValBytes);
53  }
54 };
55 
61  friend class NdbOut& operator <<(class NdbOut&, const NDBT_Table &);
62 public:
63 
64  NDBT_Table(const char* name,
65  int noOfAttributes,
66  const NdbDictionary::Column attributes[])
67  : NdbDictionary::Table(name)
68  {
69  assert(name != 0);
70 
71  //setStoredTable(stored);
72  for(int i = 0; i<noOfAttributes; i++)
73  addColumn(attributes[i]);
74 
75  // validate() might cause initialization order problem with charset
76  NdbError error;
77  int ret = aggregate(error);
78  (void)ret;
79  assert(ret == 0);
80  }
81 
82  NDBT_Table(const char* name,
83  int noOfAttributes,
84  NdbDictionary::Column* attributePtrs[])
85  : NdbDictionary::Table(name)
86  {
87  assert(name != 0);
88 
89  //setStoredTable(stored);
90  for(int i = 0; i<noOfAttributes; i++)
91  addColumn(*attributePtrs[i]);
92 
93  // validate() might cause initialization order problem with charset
94  NdbError error;
95  int ret = aggregate(error);
96  assert(ret == 0);
97  }
98 
99  static const NdbDictionary::Table * discoverTableFromDb(Ndb* ndb,
100  const char * name);
101 };
102 
103 inline
104 const NdbDictionary::Table *
105 NDBT_Table::discoverTableFromDb(Ndb* ndb, const char * name){
106  return ndb->getDictionary()->getTable(name);
107 }
108 
109 
114 class NdbOut& operator <<(class NdbOut&, const NdbDictionary::Index &);
115 
116 
117 
118 #endif