MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NdbSchemaOp.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 NdbSchemaOp_H
19 #define NdbSchemaOp_H
20 
21 #include <NdbDictionary.hpp>
22 
23 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
24 
30  enum AttrType {
31  Signed,
32 
33 
34 
35 
36  UnSigned,
37 
38 
39 
40 
41  Float,
42 
43 
44  String,
45 
46 
47  NoAttrTypeDef
48  };
49 
50 
54  enum NullAttributeType {
55  NoNullTypeDefined = -1,
56  NotNullAttribute,
57  NullAttribute,
58  AttributeDefined
59  };
63  enum KeyType {
64  Undefined = -1,
65  NoKey,
66 
67  TupleKey,
68  TupleId
69 
70 
71 
72  };
77  enum StorageMode {
78  MMBased = NDB_STORAGETYPE_MEMORY,
79  DiskBased = NDB_STORAGETYPE_DISK
80  };
81 
85  enum FragmentType {
86  Default = 0,
87  Single = 1,
88  All = 2,
89  DistributionGroup = 3,
90 
91  DistributionKey = 4,
92 
93  AllLarge = 5,
94  DGroupLarge = 6,
95 
96  DKeyLarge = 7
97 
98  };
99 
103  enum TableType {
104  UndefTableType = 0,
105  SystemTable = 1,
106  UserTable = 2,
107  UniqueHashIndex = 3,
108  HashIndex = 4,
109  UniqueOrderedIndex = 5,
110  OrderedIndex = 6
111  };
112 
113 
114 class NdbSchemaCon;
115 class Ndb;
116 
117 
131 {
132  friend class Ndb;
133  friend class NdbSchemaCon;
134 
135 public:
136 
137 
268  int createTable( const char* aTableName,
269  Uint32 aTableSize = 8,
270  KeyType aTupleKey = TupleKey,
271  int aNrOfPages = 2,
272  FragmentType aFragmentType = All,
273  int aKValue = 6,
274  int aMinLoadFactor = 78,
275  int aMaxLoadFactor = 80,
276  int aMemoryType = 1,
277  bool aStoredTable = true);
278 
284 #ifndef NDB_WIN32
285  inline int createTable( const char* aTableName,
286  Uint32 aTableSize,
287  KeyType aTupleKey,
288  int aNrOfPages,
289  FragmentType aFragmentType,
290  int aKValue,
291  int aMinLoadFactor,
292  int aMaxLoadFactor,
293  int aMemoryType,
294  int aStoredTable){
295  return createTable(aTableName,
296  aTableSize,
297  aTupleKey,
298  aNrOfPages,
299  aFragmentType,
300  aKValue,
301  aMinLoadFactor,
302  aMaxLoadFactor,
303  aMemoryType,
304  (aStoredTable == 1 ? true : false));
305  }
306 #endif
307 
428  int createAttribute(const char* aAttrName,
429  KeyType aTupleKey = NoKey,
430  int aAttrSize = 32,
431  int aArraySize = 1,
432  AttrType aAttrType = UnSigned,
433  StorageMode aStorageMode = MMBased,
434  bool nullable = false,
435  int aStType= 0, // obsolete
436  int aDistributionKey = 0,
437  int aDistributionGroup = 0,
438  int aDistributionGroupNoOfBits = 16,
439  bool aAutoIncrement = false,
440  const char* aDefaultValue = 0);
441 
445  int createAttribute(const char* aAttrName,
446  KeyType aTupleKey,
447  int aAttrSize,
448  int aArraySize,
449  AttrType aAttrType,
450  StorageMode aStorageMode,
451  NullAttributeType aNullAttr,
452  int aStType, // obsolete
453  int aDistributionKey = 0,
454  int aDistributionGroup = 0,
455  int aDistributionGroupNoOfBits = 16){
456  return createAttribute(aAttrName,
457  aTupleKey,
458  aAttrSize,
459  aArraySize,
460  aAttrType,
461  aStorageMode,
462  aNullAttr == NullAttribute,
463  aStType,
464  aDistributionKey,
465  aDistributionGroup,
466  aDistributionGroupNoOfBits);
467  }
468 
469  const NdbError & getNdbError() const;
470 
471 protected:
472 
473 /*****************************************************************************
474  * These are the methods used to create and delete the NdbOperation objects.
475  ****************************************************************************/
476  NdbSchemaOp(Ndb* aNdb);
477 
478  ~NdbSchemaOp();
479 
480 /******************************************************************************
481  * These methods are service routines used by the other NDBAPI classes.
482  *****************************************************************************/
483 
484  void release(); // Release all memory connected
485  // to the operations object.
486 
487 /****************************************************************************
488  * The methods below is the execution part of the NdbSchemaOp class.
489  *****************************************************************************/
490 
491  int sendRec();
492  int sendSignals(Uint32 aNodeId, bool HaveMutex);
493 
494  int init(NdbSchemaCon* aSchemaCon);
495 
496  /**************************************************************************
497  * These are the private variables that are defined in the operation
498  * objects.
499  **************************************************************************/
500  Ndb* theNdb; // Point back to the Ndb object.
501  NdbSchemaCon* theSchemaCon; // Point back to the connection object.
502 
503 
504  class NdbDictionary::Table * m_currentTable;
505 };
506 
507 
515 inline
516 AttrType
517 convertColumnTypeToAttrType(NdbDictionary::Column::Type _type)
518 {
519 
520  switch(_type){
523  return Signed;
526  return UnSigned;
529  case NdbDictionary::Column::Olddecimalunsigned:
531  case NdbDictionary::Column::Decimalunsigned:
533  return Float;
538  return String;
539  default:
540  return NoAttrTypeDef;
541  }
542 }
543 #endif
544 
545 #endif
546 
547