summaryrefslogtreecommitdiff
path: root/ndb/test/src/NdbSchemaOp.cpp
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.ndb.mysql.com>2004-06-07 17:31:32 +0000
committerunknown <tomas@poseidon.ndb.mysql.com>2004-06-07 17:31:32 +0000
commitdfa8ee365f677449a1f9e6f6ec2d42b973081916 (patch)
tree165fe5548627081d1b00d52cee447bfb4cf31e12 /ndb/test/src/NdbSchemaOp.cpp
parent7942677020d36bd5baafd8d765968921f348cdc2 (diff)
downloadmariadb-git-dfa8ee365f677449a1f9e6f6ec2d42b973081916.tar.gz
ndb source tree cleanup, see respective file
BitKeeper/deleted/.del-BinDist.sh~8ea6fee0be3de36: Delete: ndb/old_files/BinDist.sh BitKeeper/deleted/.del-Defs.mk~fab44ad996ed5499: Delete: ndb/old_files/Defs.mk BitKeeper/deleted/.del-Makefile~726e96331d4343ce: Delete: ndb/old_files/Makefile BitKeeper/deleted/.del-SrcDist.sh~ad4f1cd7aae4265b: Delete: ndb/old_files/SrcDist.sh BitKeeper/deleted/.del-configure~501239931f8bb1: Delete: ndb/old_files/configure BitKeeper/deleted/.del-Epilogue.mk~60f7edf886726154: Delete: ndb/old_files/Epilogue.mk BitKeeper/deleted/.del-README~b619a580720ec3d8: Delete: ndb/old_files/README BitKeeper/deleted/.del-env.sh~91075f1664ce8292: Delete: ndb/old_files/env.sh BitKeeper/deleted/.del-mysqlclusterenv.sh~f0d8a63e844255f5: Delete: ndb/old_files/mysqlclusterenv.sh BitKeeper/deleted/.del-Defs.DEBUG.mk~8ed7bb195181c74a: Delete: ndb/config/old_files/Defs.DEBUG.mk BitKeeper/deleted/.del-acinclude.m4~b1472f9faac0c71: Delete: ndb/config/old_files/acinclude.m4 BitKeeper/deleted/.del-Defs.HPUX.HPPA.GCC.mk~b50ab324c3ce07ce: Delete: ndb/config/old_files/Defs.HPUX.HPPA.GCC.mk BitKeeper/deleted/.del-Defs.IBMAIX.POWERPC.GCC.mk~76bea6928ca7b8f0: Delete: ndb/config/old_files/Defs.IBMAIX.POWERPC.GCC.mk BitKeeper/deleted/.del-Defs.LINUX.x86.GCC.mk~15f3c82665d141a0: Delete: ndb/config/old_files/Defs.LINUX.x86.GCC.mk BitKeeper/deleted/.del-Defs.LINUX.x86.ICC.mk~e51a6e19daeb353: Delete: ndb/config/old_files/Defs.LINUX.x86.ICC.mk BitKeeper/deleted/.del-Defs.LINUX.x86_64.GCC.mk~9e853e7e1142b2d7: Delete: ndb/config/old_files/Defs.LINUX.x86_64.GCC.mk BitKeeper/deleted/.del-Defs.MACOSX.POWERPC.GCC.mk~d661574b758ac911: Delete: ndb/config/old_files/Defs.MACOSX.POWERPC.GCC.mk BitKeeper/deleted/.del-Defs.OSE.PPC750.DIAB.mk~d5d7116c512290bc: Delete: ndb/config/old_files/Defs.OSE.PPC750.DIAB.mk BitKeeper/deleted/.del-Defs.RELEASE.mk~6c195617d8e1c8ec: Delete: ndb/config/old_files/Defs.RELEASE.mk BitKeeper/deleted/.del-Defs.RELEASE_TRACE.mk~e367d147bd3ad0bf: Delete: ndb/config/old_files/Defs.RELEASE_TRACE.mk BitKeeper/deleted/.del-Defs.SIMCELLO.SOFTOSE.GCC.mk~5acee8046e3dfd21: Delete: ndb/config/old_files/Defs.SIMCELLO.SOFTOSE.GCC.mk BitKeeper/deleted/.del-Defs.WIN32.x86.VC7.mk~582038c28dd89391: Delete: ndb/config/old_files/Defs.WIN32.x86.VC7.mk BitKeeper/deleted/.del-Defs.SOFTOSE.SPARC.GCC.mk~ebd0c4aab56c1202: Delete: ndb/config/old_files/Defs.SOFTOSE.SPARC.GCC.mk BitKeeper/deleted/.del-Defs.SOLARIS.SPARC.FORTE6.mk~4367e18b8246761e: Delete: ndb/config/old_files/Defs.SOLARIS.SPARC.FORTE6.mk BitKeeper/deleted/.del-Defs.SOLARIS.SPARC.GCC.mk~d781a20b8235525c: Delete: ndb/config/old_files/Defs.SOLARIS.SPARC.GCC.mk BitKeeper/deleted/.del-Defs.SOLARIS.SPARC_64.GCC.mk~76626f56dcd0e8e9: Delete: ndb/config/old_files/Defs.SOLARIS.SPARC_64.GCC.mk BitKeeper/deleted/.del-Defs.SOLARIS6.SPARC.GCC.mk~2b05903f79ce771: Delete: ndb/config/old_files/Defs.SOLARIS6.SPARC.GCC.mk BitKeeper/deleted/.del-Defs.TRU64X.ALPHA.GCC.mk~6ba3fc0cfaa37cb2: Delete: ndb/config/old_files/Defs.TRU64X.ALPHA.GCC.mk BitKeeper/deleted/.del-GuessConfig.sh~ebdb504ed6b7ab68: Delete: ndb/config/old_files/GuessConfig.sh BitKeeper/deleted/.del-Makefile.am~c28d15539f926269: Delete: ndb/config/old_files/Makefile.am BitKeeper/deleted/.del-configure.in~3e0ef32c155b79bc: Delete: ndb/config/old_files/configure.in BitKeeper/deleted/.del-config.h.in~b9209994763e30f8: Delete: ndb/config/old_files/config.h.in BitKeeper/deleted/.del-Makefile~71ad5c694da8711: Delete: ndb/src/old_files/Makefile BitKeeper/deleted/.del-Makefile~261cfb7897aa2259: Delete: ndb/test/newtonapi/Makefile BitKeeper/deleted/.del-Makefile~d46bb4a49ae611f9: Delete: ndb/test/odbc/Makefile BitKeeper/deleted/.del-Makefile_old~5ce89facf68772b: Delete: ndb/test/Makefile_old ndb/test/include/NdbSchemaCon.hpp: Rename: ndb/include/ndbapi/NdbSchemaCon.hpp -> ndb/test/include/NdbSchemaCon.hpp ndb/test/include/NdbSchemaOp.hpp: Rename: ndb/include/ndbapi/NdbSchemaOp.hpp -> ndb/test/include/NdbSchemaOp.hpp ndb/include/Makefile.am: removed NdbSchema from ndbapi ndb/include/ndbapi/NdbDictionary.hpp: added Column::getSize() and print function for Column::Type ndb/include/ndbapi/NdbRecAttr.hpp: made an operator<< friend to NdbRecAttr ndb/src/kernel/blocks/backup/restore/Restore.cpp: Rewritten restore to remove NdbSchema ndb/src/kernel/blocks/backup/restore/Restore.hpp: Rewritten restore to remove NdbSchema ndb/src/kernel/blocks/backup/restore/main.cpp: Rewritten restore to remove NdbSchema ndb/src/ndbapi/Makefile.am: removed NdbSchema from ndbapi ndb/src/ndbapi/NdbDictionary.cpp: added operator << for Column::Type ndb/src/ndbapi/NdbRecAttr.cpp: updated operator<< for NdbRecAttr ndb/src/ndbapi/Ndberr.cpp: removed NdbSchema from ndbapi ndb/test/src/Makefile.am: moved NdbSchema to test ndb/test/src/NDBT_ResultRow.cpp: use common print method for NDBT_ResultRow ndb/test/src/NdbBackup.cpp: fixed bug in testBackup ndb/test/src/NdbSchemaCon.cpp: moved NdbError NdbSchema ndb/test/src/NdbSchemaOp.cpp: updated include file list
Diffstat (limited to 'ndb/test/src/NdbSchemaOp.cpp')
-rw-r--r--ndb/test/src/NdbSchemaOp.cpp220
1 files changed, 220 insertions, 0 deletions
diff --git a/ndb/test/src/NdbSchemaOp.cpp b/ndb/test/src/NdbSchemaOp.cpp
new file mode 100644
index 00000000000..a296094ea9d
--- /dev/null
+++ b/ndb/test/src/NdbSchemaOp.cpp
@@ -0,0 +1,220 @@
+/* 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.cpp
+Include:
+Link:
+Author: UABMNST Mona Natterkvist UAB/B/SD
+ EMIKRON Mikael Ronstrom
+Date: 040524
+Version: 3.0
+Description: Interface between application and NDB
+Documentation: Handles createTable and createAttribute calls
+
+Adjust: 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: None
+Parameters: aNdb: Pointers to the Ndb object.
+ aTable: Pointers to the Table object
+Remark: 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 )
+*****************************************************************************/
+int
+NdbSchemaOp::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,
+ StorageAttributeType 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.setDistributionGroup(aDistributionGroupFlag,aDistributionGroupNoOfBits);
+ 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.
+******************************************************************************/
+void
+NdbSchemaOp::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
+******************************************************************************/
+int
+NdbSchemaOp::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.
+******************************************************************************/
+int
+NdbSchemaOp::init(NdbSchemaCon* aSchemaCon)
+{
+ theSchemaCon = aSchemaCon;
+ return 0;
+}//NdbSchemaOp::init()
+
+
+const NdbError &
+NdbSchemaOp::getNdbError() const
+{
+ return theSchemaCon->getNdbError();
+}
+