MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NDBT_Tables.hpp
1 /*
2  Copyright (C) 2003-2006, 2008 MySQL AB
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef NDBT_TABLES_HPP
20 #define NDBT_TABLES_HPP
21 
22 
23 #include <NDBT.hpp>
24 #include <Ndb.hpp>
25 #include <NdbDictionary.hpp>
26 #include <NDBT_Table.hpp>
27 
28 typedef int (* NDBT_CreateTableHook)(Ndb*, NdbDictionary::Table&, int when,
29  void* arg);
30 
31 class NDBT_Tables {
32 public:
33  /* Some constants for the maximum sizes of keys and attributes
34  * in various cases
35  */
36  STATIC_CONST(MaxRowBytes= NDB_MAX_TUPLE_SIZE_IN_WORDS * 4);
37  STATIC_CONST(MaxKeyBytes= NDB_MAX_KEYSIZE_IN_WORDS * 4);
38  STATIC_CONST(MinKeyBytes= 4); // Single Unsigned key
39 
40  STATIC_CONST(MaxVarTypeKeyBytes= MaxKeyBytes - 2); // 2 length bytes
41 
42  STATIC_CONST(MaxKeyMaxAttrBytes= MaxRowBytes - MaxKeyBytes);
43  STATIC_CONST(MaxKeyMaxVarTypeAttrBytes= MaxKeyMaxAttrBytes - 2);
44 
45  STATIC_CONST(MinKeyMaxAttrBytes= MaxRowBytes - MinKeyBytes);
46  STATIC_CONST(MinKeyMaxVarTypeAttrBytes= MinKeyMaxAttrBytes - 2);
47 
48  STATIC_CONST(UniqueIndexOverheadBytes= 4); // For FragId
49 
50  // Note that since we'll put an unique index on this...it can't be bigger
51  // than MaxKeyBytes
52  STATIC_CONST(MaxKeyMaxVarTypeAttrBytesIndex =
53  ((MaxKeyMaxVarTypeAttrBytes <= MaxKeyBytes) ?
54  MaxKeyMaxVarTypeAttrBytes : MaxKeyBytes) - UniqueIndexOverheadBytes);
55 
56  /* Hugo requires 2 unsigned int columns somewhere in the table
57  * and these also counts towards #attributes relation
58  */
59  STATIC_CONST(HugoOverheadBytes= 2 * (4 + 4));
60 
61  static int createTable(Ndb* pNdb, const char* _name, bool _temp = false,
62  bool existsOK = false, NDBT_CreateTableHook = 0,
63  void* arg = 0);
64  static int createAllTables(Ndb* pNdb, bool _temp, bool existsOK = false);
65  static int createAllTables(Ndb* pNdb);
66 
67  static int dropAllTables(Ndb* pNdb);
68 
69  static int print(const char * name);
70  static int printAll();
71 
72  static const NdbDictionary::Table* getTable(const char* _nam);
73  static const NdbDictionary::Table* getTable(int _num);
74  static int getNumTables();
75 
76  static const char** getIndexes(const char* table);
77 
78  static int create_default_tablespace(Ndb* pNdb);
79 
80 private:
81  static const NdbDictionary::Table* tableWithPkSize(const char* _nam, Uint32 pkSize);
82 };
83 #endif
84 
85