⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ndbschemaop.cpp

📁 mysql-5.0.22.tar.gz源码包
💻 CPP
字号:
/* Copyright (C) 2003 MySQL AB   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *//*****************************************************************************Name:          NdbSchemaOp.cppInclude:Link:Author:        UABMNST Mona Natterkvist UAB/B/SD               EMIKRON Mikael Ronstrom                         Date:          040524Version:       3.0Description:   Interface between application and NDBDocumentation: Handles createTable and createAttribute callsAdjust:  980125  UABMNST   First version.         020826  EMIKRON   New version for new DICT         040524  Magnus Svensson - Adapted to not be included in public NdbApi                                   unless the user wants to use it.  NOTE: This file is only used as a compatibility layer for old test programs,        New programs should use NdbDictionary.hpp*****************************************************************************/#include <ndb_global.h>#include <NdbApi.hpp>#include <NdbSchemaOp.hpp>#include <NdbSchemaCon.hpp>/*****************************************************************************NdbSchemaOp(Ndb* aNdb, Table* aTable);Return Value:  NoneParameters:    aNdb: Pointers to the Ndb object.               aTable: Pointers to the Table objectRemark:        Creat an object of NdbSchemaOp. *****************************************************************************/NdbSchemaOp::NdbSchemaOp(Ndb* aNdb) :   theNdb(aNdb),  theSchemaCon(NULL),  m_currentTable(NULL){}//NdbSchemaOp::NdbSchemaOp()/*****************************************************************************~NdbSchemaOp();Remark:         Delete tables for connection pointers (id).*****************************************************************************/NdbSchemaOp::~NdbSchemaOp( ){}//~NdbSchemaOp::NdbSchemaOp()     /*****************************************************************************int createTable( const char* tableName )*****************************************************************************/intNdbSchemaOp::createTable(const char* aTableName,                          Uint32 aTableSize,                          KeyType aTupleKey,                         int aNrOfPages,                          FragmentType aFragmentType,                          int aKValue,                         int aMinLoadFactor,                         int aMaxLoadFactor,                         int aMemoryType,                         bool aStoredTable){  if(m_currentTable != 0){    return -1;  }  m_currentTable = new NdbDictionary::Table(aTableName);  m_currentTable->setKValue(aKValue);  m_currentTable->setMinLoadFactor(aMinLoadFactor);  m_currentTable->setMaxLoadFactor(aMaxLoadFactor);  m_currentTable->setLogging(aStoredTable);  m_currentTable->setFragmentType(NdbDictionary::Object::FragAllMedium);  return 0;}//NdbSchemaOp::createTable()/******************************************************************************int createAttribute( const char* anAttrName,                                     KeyType aTupleyKey,                                         int anAttrSize,                                                 int anArraySize,                                                   AttrType anAttrType,                        SafeType aSafeType,                                  StorageMode aStorageMode,                             int aNullAttr,                             int aStorageAttr );******************************************************************************/int     NdbSchemaOp::createAttribute( const char* anAttrName,                                                 KeyType aTupleKey,                                                      int anAttrSize,                                                 int anArraySize,                                                        AttrType anAttrType,                                    StorageMode aStorageMode,                              bool nullable,                              int aStorageAttr,			      int aDistributionKeyFlag,			      int aDistributionGroupFlag,			      int aDistributionGroupNoOfBits,                              bool aAutoIncrement,                              const char* aDefaultValue){  if (m_currentTable == 0){    return -1;  }//if    NdbDictionary::Column col(anAttrName);  switch(anAttrType){  case Signed:    if(anAttrSize == 64)      col.setType(NdbDictionary::Column::Bigint);    else      col.setType(NdbDictionary::Column::Int);    break;  case UnSigned:    if(anAttrSize == 64)      col.setType(NdbDictionary::Column::Bigunsigned);    else      col.setType(NdbDictionary::Column::Unsigned);    break;  case Float:    if(anAttrSize == 64)      col.setType(NdbDictionary::Column::Double);    else      col.setType(NdbDictionary::Column::Float);    break;  case String:    col.setType(NdbDictionary::Column::Char);    break;  case NoAttrTypeDef:    abort();  }  col.setLength(anArraySize);  col.setNullable(nullable);  if(aTupleKey != NoKey)    col.setPrimaryKey(true);  else    col.setPrimaryKey(false);  col.setDistributionKey(aDistributionKeyFlag);  col.setAutoIncrement(aAutoIncrement);  col.setDefaultValue(aDefaultValue != 0 ? aDefaultValue : "");    m_currentTable->addColumn(col);  return 0;      }/******************************************************************************void release();Remark:        Release all objects connected to the schemaop object.******************************************************************************/voidNdbSchemaOp::release(){}//NdbSchemaOp::release()/******************************************************************************int sendRec()Return Value:   Return 0 : send was succesful.                Return -1: In all other case.   Parameters:Remark:         Send and receive signals for schema transaction based on state******************************************************************************/intNdbSchemaOp::sendRec(){  int retVal = 0;  if(m_currentTable == 0){    retVal = -1;  } else {    retVal = theNdb->getDictionary()->createTable(* m_currentTable);    delete m_currentTable;    theSchemaCon->theError.code = theNdb->getDictionary()->getNdbError().code;  }    return retVal;}//NdbSchemaOp::sendRec()/******************************************************************************int init();Return Value:  Return 0 : init was successful.               Return -1: In all other case.  Remark:        Initiates SchemaOp record after allocation.******************************************************************************/intNdbSchemaOp::init(NdbSchemaCon* aSchemaCon){  theSchemaCon = aSchemaCon;  return 0;}//NdbSchemaOp::init()const NdbError &NdbSchemaOp::getNdbError() const{   return theSchemaCon->getNdbError();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -