summaryrefslogtreecommitdiff
path: root/ndb/src/old_files/newtonapi
diff options
context:
space:
mode:
Diffstat (limited to 'ndb/src/old_files/newtonapi')
-rw-r--r--ndb/src/old_files/newtonapi/Makefile27
-rw-r--r--ndb/src/old_files/newtonapi/dba_binding.cpp439
-rw-r--r--ndb/src/old_files/newtonapi/dba_bulkread.cpp267
-rw-r--r--ndb/src/old_files/newtonapi/dba_config.cpp115
-rw-r--r--ndb/src/old_files/newtonapi/dba_dac.cpp842
-rw-r--r--ndb/src/old_files/newtonapi/dba_error.cpp118
-rw-r--r--ndb/src/old_files/newtonapi/dba_init.cpp86
-rw-r--r--ndb/src/old_files/newtonapi/dba_internal.hpp122
-rw-r--r--ndb/src/old_files/newtonapi/dba_process.cpp123
-rw-r--r--ndb/src/old_files/newtonapi/dba_process.hpp56
-rw-r--r--ndb/src/old_files/newtonapi/dba_schema.cpp150
11 files changed, 0 insertions, 2345 deletions
diff --git a/ndb/src/old_files/newtonapi/Makefile b/ndb/src/old_files/newtonapi/Makefile
deleted file mode 100644
index bed179046a5..00000000000
--- a/ndb/src/old_files/newtonapi/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-include .defs.mk
-
-TYPE := ndbapiclient
-
-PIC_ARCHIVE := Y
-ARCHIVE_TARGET := newtonapi
-
-A_LIB := Y
-SO_LIB := Y
-PIC_LIB := Y
-
-LIB_TARGET := NEWTON_API
-LIB_TARGET_ARCHIVES := $(ARCHIVE_TARGET) NDB_API
-
-SOURCES = \
- dba_binding.cpp \
- dba_process.cpp \
- dba_dac.cpp \
- dba_init.cpp \
- dba_schema.cpp \
- dba_bulkread.cpp \
- dba_error.cpp \
- dba_config.cpp
-
-CCFLAGS_LOC += -I../include -I$(call fixpath,$(NDB_TOP)/include/portlib) -I$(call fixpath,$(NDB_TOP)/include/util) -I$(call fixpath,$(NDB_TOP)/include/newtonapi) -DDEBUG
-
-include $(NDB_TOP)/Epilogue.mk
diff --git a/ndb/src/old_files/newtonapi/dba_binding.cpp b/ndb/src/old_files/newtonapi/dba_binding.cpp
deleted file mode 100644
index 63e48110b1d..00000000000
--- a/ndb/src/old_files/newtonapi/dba_binding.cpp
+++ /dev/null
@@ -1,439 +0,0 @@
-/* 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 */
-
-
-#include "dba_internal.hpp"
-
-static bool matchType(NdbDictionary::Column::Type, DBA_DataTypes_t);
-static bool matchSize(NdbDictionary::Column::Type, unsigned, Size_t);
-static int computeChecksum(const DBA_Binding_t * bindings);
-
-struct DBA__Array {
- int count;
- int data[1];
-
- bool exists(int value) const {
- for(int i = 0; i<count; i++)
- if(data[i] == value)
- return true;
- return false;
- }
-
- void insert(int value){
- data[count] = value;
- count++;
- }
-};
-
-/**
- * createBindings
- */
-static
-DBA_Binding_t *
-createBinding(const char* TableName,
- int NbCol,
- const DBA_ColumnBinding_t ColsBindings[],
- Size_t StructSz,
- const NdbDictionary::Table * theTable,
- struct DBA__Array * keys,
- struct DBA__Array * columns);
-
-extern "C"
-DBA_Binding_t *
-DBA_CreateBinding( const char* TableName,
- int NbCol,
- const DBA_ColumnBinding_t ColsBindings[],
- Size_t StructSz ){
-
- NdbDictionary::Dictionary * dict = DBA__TheNdb->getDictionary();
- if(dict == 0){
- DBA__SetLatestError(DBA_NDB_ERROR, 0,
- "Internal NDB error: No dictionary");
- return 0;
- }
-
- const NdbDictionary::Table * table = dict->getTable(TableName);
- if(table == 0){
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0,
- "No such table: %s", TableName);
- return 0;
- }
-
- /**
- * Keys/Columns in table
- */
- const int tabColumns = table->getNoOfColumns();
- const int tabKeys = table->getNoOfPrimaryKeys();
-
- /**
- * Ok, ok... I alloc four bytes extra so what...
- */
- struct DBA__Array * keys = (struct DBA__Array *)malloc
- (sizeof(struct DBA__Array)+tabKeys*sizeof(int));
-
- if(keys == 0){
- DBA__SetLatestError(DBA_ERROR, 0,
- "malloc(%d) failed",
- sizeof(struct DBA__Array)+tabKeys*sizeof(int));
- return 0;
- }
-
- struct DBA__Array * columns = (struct DBA__Array *)malloc
- (sizeof(struct DBA__Array)+tabColumns*sizeof(int));
-
- if(columns == 0){
- DBA__SetLatestError(DBA_ERROR, 0,
- "malloc(%d) failed",
- sizeof(struct DBA__Array)+tabColumns*sizeof(int));
- free(keys);
- return 0;
- }
-
- columns->count = 0;
- keys->count = 0;
-
- DBA_Binding_t * bindings = createBinding(TableName,
- NbCol,
- ColsBindings,
- StructSz,
- table,
- keys,
- columns);
-
- for(int i = 0; i<tabColumns; i++){
- const NdbDictionary::Column * col = table->getColumn(i);
- if(col->getPrimaryKey()){
- if(!keys->exists(i)){
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0,
- "Key column: %s not specified in binding",
- col->getName());
-
- free(keys); free(columns);
- DBA_DestroyBinding(bindings);
- return 0;
- }
- }
- }
-
- free(keys); free(columns);
-
- DBA__ValidBinding(bindings);
-
- return bindings;
-}
-
-DBA_Binding_t *
-createBinding(const char* TableName,
- int NbCol,
- const DBA_ColumnBinding_t ColsBindings[],
- Size_t StructSz,
- const NdbDictionary::Table * table,
- struct DBA__Array * keys,
- struct DBA__Array * columns){
- /**
- * Counters for this part of binding
- */
- int noOfKeys = 0;
- int noOfColumns = 0;
- int noOfSubBindings = 0;
-
- /**
- * Check names and types and sizes
- */
- for(int i = 0; i<NbCol; i++){
- if(ColsBindings[i].Ptr){
- /**
- * Pointer binding
- */
- noOfSubBindings ++;
-
- DBA_Binding_t * tmp = createBinding(TableName,
- ColsBindings[i].Size,
- ColsBindings[i].SubBinding,
- StructSz,
- table,
- keys,
- columns);
- DBA__ValidBinding(tmp);
-
- if(tmp == 0){
- // createBindings have already set latestError
- return 0;
- }
-
- DBA_DestroyBinding(tmp);
- } else {
- const NdbDictionary::Column * col =
- table->getColumn(ColsBindings[i].Name);
- const Uint32 attrId = col->getColumnNo();
-
- if(col == 0){
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0,
- "Unknown column: %s", ColsBindings[i].Name);
- return 0;
- }
- const NdbDictionary::Column::Type type = col->getType();
- if(!matchType(type, ColsBindings[i].DataType)){
- DBA_DEBUG("Incorrect type for: " << ColsBindings[i].Name);
- DBA_DEBUG("type: " << type);
- DBA_DEBUG("ColsBindings[i].DataType: " << ColsBindings[i].DataType);
-
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0,
- "Incorrect type for column: %s",
- ColsBindings[i].Name);
-
- return 0;
- }
-
- if(!matchSize(type, col->getLength(), ColsBindings[i].Size)){
- DBA_DEBUG("Incorrect size for: " << ColsBindings[i].Name);
- DBA_DEBUG("type: " << type);
- DBA_DEBUG("length: " << col->getLength());
- DBA_DEBUG("ColsBindings[i].Size" << (Uint64)ColsBindings[i].Size);
-
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0,
- "Incorrect size for column: %s",
- ColsBindings[i].Name);
- return 0;
- }
-
- if(col->getPrimaryKey()){
- noOfKeys++;
- } else {
- noOfColumns++;
- }
-
- /**
- * Check only in "validate" phase
- */
- if(columns != 0 && keys != 0){
- if(columns->exists(attrId) || keys->exists(attrId)){
- DBA_DEBUG("Column bound multiple times: " << ColsBindings[i].Name);
-
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0,
- "Column bound multiple times: %s",
- ColsBindings[i].Name);
- return 0;
- }
-
- if(col->getPrimaryKey()){
- keys->insert(attrId);
- } else {
- columns->insert(attrId);
- }
- }
- }
- }
-
- /**
- * Validation is all set
- */
-
- /**
- * Allocate memory
- */
- const int szOfStruct =
- sizeof(DBA_Binding_t)
- + strlen(TableName) + 4
- + (2 * sizeof(int) * noOfKeys)
- + (2 * sizeof(int) * noOfColumns)
- + ((sizeof(struct DBA_Binding *) + sizeof(int)) * noOfSubBindings)
- - 4;
-
- DBA_Binding * ret = (DBA_Binding *)malloc(szOfStruct);
- if(ret == 0){
- DBA__SetLatestError(DBA_ERROR, 0,
- "malloc(%d) failed", szOfStruct);
- return 0;
- }
-
- for(int i = 0; i<DBA__MagicLength; i++)
- ret->magic[i] = DBA__TheMagic[i];
-
- ret->noOfKeys = noOfKeys;
- ret->noOfColumns = noOfColumns;
- ret->noOfSubBindings = noOfSubBindings;
-
- ret->keyIds = (int *)&(ret->data[0]);
- ret->keyOffsets = ret->keyIds + noOfKeys;
-
- ret->columnIds = ret->keyOffsets + noOfKeys;
- ret->columnOffsets = ret->columnIds + noOfColumns;
-
- ret->subBindingOffsets = ret->columnOffsets + noOfColumns;
- ret->subBindings = (DBA_Binding **)
- (ret->subBindingOffsets + noOfSubBindings);
-
- ret->tableName = (char *)(ret->subBindings + noOfSubBindings);
- ret->structSz = StructSz;
- ret->checkSum = computeChecksum(ret);
-
- /**
- * Populate arrays
- */
- strcpy(ret->tableName, TableName);
-
- int k = 0;
- int c = 0;
- int p = 0;
-
- for(int i = 0; i<NbCol; i++){
- if(ColsBindings[i].Ptr){
- ret->subBindings[p] = createBinding(TableName,
- ColsBindings[i].Size,
- ColsBindings[i].SubBinding,
- StructSz,
- table,
- 0,
- 0);
-
- DBA__ValidBinding(ret->subBindings[p]);
-
- ret->subBindingOffsets[p] = ColsBindings[i].Offset;
- p++;
- } else {
- const NdbDictionary::Column * col =
- table->getColumn(ColsBindings[i].Name);
-
- if(col->getPrimaryKey()){
- ret->keyIds[k] = col->getColumnNo();
- ret->keyOffsets[k] = ColsBindings[i].Offset;
- k++;
- } else {
- ret->columnIds[c] = col->getColumnNo();
- ret->columnOffsets[c] = ColsBindings[i].Offset;
- c++;
- }
- }
- }
-
- return ret;
-}
-
-
-extern "C"
-DBA_Error_t
-DBA_DestroyBinding( DBA_Binding_t* Binding ){
-
- for(int i = 0; i<Binding->noOfSubBindings; i++)
- DBA_DestroyBinding(Binding->subBindings[i]);
-
- free(Binding);
-
- return DBA_NO_ERROR;
-}
-
-static
-bool
-matchType(NdbDictionary::Column::Type t1, DBA_DataTypes_t t2){
- for(int i = 0; i<DBA__NoOfMappings; i++)
- if(DBA__DataTypesMappings[i].newtonType == t2 &&
- DBA__DataTypesMappings[i].ndbType == t1)
- return true;
- return false;
-}
-
-static
-bool
-matchSize(NdbDictionary::Column::Type t, unsigned b, Size_t s) {
- switch(t){
- case NdbDictionary::Column::Int:
- case NdbDictionary::Column::Unsigned:
- case NdbDictionary::Column::Float:
- return (4 * b) == s;
- case NdbDictionary::Column::Bigint:
- case NdbDictionary::Column::Bigunsigned:
- case NdbDictionary::Column::Double:
- return (8 * b) == s;
- case NdbDictionary::Column::Decimal:
- case NdbDictionary::Column::Char:
- case NdbDictionary::Column::Binary:
- return (1 * b) == s;
- case NdbDictionary::Column::Varchar:
- case NdbDictionary::Column::Varbinary:
- case NdbDictionary::Column::Datetime:
- case NdbDictionary::Column::Timespec:
- case NdbDictionary::Column::Blob:
- case NdbDictionary::Column::Tinyint:
- case NdbDictionary::Column::Tinyunsigned:
- case NdbDictionary::Column::Smallint:
- case NdbDictionary::Column::Smallunsigned:
- case NdbDictionary::Column::Mediumint:
- case NdbDictionary::Column::Mediumunsigned:
- case NdbDictionary::Column::Undefined:
- return false;
- }
- return false;
-}
-
-bool
-DBA__ValidBinding(const DBA_Binding_t * bindings){
- if(bindings == 0){
- DBA_DEBUG("Null pointer passed to validBinding");
- return false;
- }
-
- for(int i = 0; i<DBA__MagicLength; i++)
- if(bindings->magic[i] != DBA__TheMagic[i]){
- DBA_DEBUG("Invalid magic in validBinding");
- return false;
- }
-
- const int cs = computeChecksum(bindings);
- if(cs != bindings->checkSum){
- DBA_DEBUG("Invalid checksum in validBinding");
- DBA_DEBUG("cs = " << cs << " b->cs= " << bindings->checkSum);
- return false;
- }
-
- return true;
-}
-
-bool
-DBA__ValidBindings(const DBA_Binding_t * const * pBindings, int n){
- for(int i = 0; i<n; i++)
- if(!DBA__ValidBinding(pBindings[i]))
- return false;
- return true;
-}
-
-/**
- * Note: currently only checksum "static" part of struct
- */
-static
-int
-computeChecksum(const DBA_Binding_t * bindings){
- int sum = 0;
- int pos = 0;
- const char * ptr = ((const char *)bindings)+DBA__MagicLength+sizeof(int);
- const int sz = sizeof(DBA_Binding_t) - DBA__MagicLength - sizeof(int) - 4;
-
- for(int i = 0; i<sz; i++){
- sum += ((int)ptr[i]) << pos;
- pos += 8;
- if(pos == 32)
- pos = 0;
- }
-
- return sum;
-}
-
-int
-DBA__GetStructSize(const DBA_Binding_t * bind){
- if(!DBA__ValidBinding(bind))
- return 0;
- return bind->structSz;
-}
diff --git a/ndb/src/old_files/newtonapi/dba_bulkread.cpp b/ndb/src/old_files/newtonapi/dba_bulkread.cpp
deleted file mode 100644
index 1f75037046b..00000000000
--- a/ndb/src/old_files/newtonapi/dba_bulkread.cpp
+++ /dev/null
@@ -1,267 +0,0 @@
-/* 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 */
-
-
-#include "dba_internal.hpp"
-
-struct DBA__BulkReadData {
- const DBA_Binding_t * const * pBindings; // The bindings
- DBA_BulkReadResultSet_t * pData; // The data
-
- int NbRows; // NbRows per binding
- int NbBindings; // NbBindings
- int TotalRows; // Total rows (NbRows*NbBindings)
-
- DBA_AsyncCallbackFn_t CbFunc; // Users callback
- DBA_ReqId_t RequestId; // Users request id
- DBA_Error_t Status; // Request status
- DBA_ErrorCode_t ErrorCode; /**< Request error
- Only valid if request is
- aborted */
-
- int RowsSubmitted; // No of read sent to NDB
- int RowsAcknowledged; // No of read responses
- int OpPerTrans; // Operations per transaction
-
- struct Index {
- int binding;
- int row;
- int datarow;
-
- void init() { row = binding = datarow = 0;}
- void next(int rows) {
- datarow++; row++;
- if(row == rows){ row = 0; binding++; }
- }
- };
- Index lastSend;
- Index nextSend;
-
- /**
- * If "simple" bulkread
- * use this storage
- */
- const DBA_Binding_t * bindings[1];
-
- DBA__BulkReadData() {
- RequestId = DBA_INVALID_REQID;
- }
- void ProcessBulkRead();
- bool ProcessCallback(int errorCode, NdbConnection * connection);
-};
-
-static
-void
-NewtonCallback(int errorCode,
- NdbConnection * connection,
- void * anyObject){
-
- DBA__BulkReadData * brd = (DBA__BulkReadData*)anyObject;
-
- brd->ProcessCallback(errorCode, connection);
-
- DBA__TheNdb->closeTransaction(connection);
-
- if(brd->RowsSubmitted == brd->TotalRows){
-
- /**
- * The entire bulk read is finished,
- * call users callback
- */
- DBA_ReqId_t reqId = brd->RequestId;
-
- // Invalidate BulkReadData
- brd->RequestId = DBA_INVALID_REQID;
-
- brd->CbFunc(reqId, brd->Status, brd->ErrorCode);
- return;
- }
-
- brd->ProcessBulkRead();
-}
-
-/**
- * A BulkReadData structure
- */
-static DBA__BulkReadData theBRD;
-
-#define CHECK_BINDINGS(Bindings) \
- if(!DBA__ValidBinding(Bindings)){ \
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0, "Invalid bindings"); \
- return DBA_INVALID_REQID; \
- }
-
-#define CHECK_BINDINGS2(Bindings, NbBindings) \
- if(!DBA__ValidBindings(Bindings, NbBindings)){ \
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0, "Invalid bindings"); \
- return DBA_INVALID_REQID; \
- }
-
-DBA_ReqId_t
-DBA_BulkReadRows(const DBA_Binding_t * pBindings,
- DBA_BulkReadResultSet_t pData[],
- int NbRows,
- DBA_AsyncCallbackFn_t CbFunc ){
-
- CHECK_BINDINGS(pBindings);
-
- DBA__BulkReadData * brd = &theBRD;
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
-
- if(brd->RequestId != DBA_INVALID_REQID){
- DBA__SetLatestError(DBA_ERROR, 0,
- "DBA only permits 1 concurrent bulkread");
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return DBA_ERROR;
- }
-
- theBRD.RequestId = 1;
-
- /**
- *
- */
- brd->bindings[0] = pBindings;
- brd->pBindings = brd->bindings;
- brd->pData = pData;
-
- /**
- * Control data
- */
- brd->NbRows = NbRows;
- brd->NbBindings = 1;
- brd->TotalRows = NbRows;
- brd->CbFunc = CbFunc;
- brd->Status = DBA_NO_ERROR;
- brd->ErrorCode = 0;
- brd->OpPerTrans = DBA__BulkReadCount;
-
- brd->RowsSubmitted = 0;
- brd->RowsAcknowledged = 0;
-
- brd->lastSend.init();
- brd->nextSend.init();
-
- brd->ProcessBulkRead();
- NdbMutex_Unlock(DBA__TheNewtonMutex);
-
- return brd->RequestId;
-}
-
-DBA_ReqId_t
-DBA_BulkMultiReadRows(const DBA_Binding_t * const * pBindings,
- DBA_BulkReadResultSet_t pData[],
- int NbBindings,
- int NbRows,
- DBA_AsyncCallbackFn_t CbFunc ){
-
- CHECK_BINDINGS2(pBindings, NbBindings);
-
- DBA__BulkReadData * brd = &theBRD;
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
-
- if(brd->RequestId != DBA_INVALID_REQID){
- DBA__SetLatestError(DBA_ERROR, 0,
- "DBA only permits 1 concurrent bulkread");
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return DBA_ERROR;
- }
-
- brd->RequestId = 1;
-
- /**
- *
- */
- brd->pBindings = pBindings;
- brd->pData = pData;
-
- /**
- * Control data
- */
- brd->NbRows = NbRows;
- brd->NbBindings = NbBindings;
- brd->TotalRows = (NbRows * NbBindings);
- brd->CbFunc = CbFunc;
- brd->Status = DBA_NO_ERROR;
- brd->ErrorCode = 0;
- brd->OpPerTrans = DBA__BulkReadCount;
-
- brd->RowsSubmitted = 0;
- brd->RowsAcknowledged = 0;
-
- brd->lastSend.init();
- brd->nextSend.init();
-
- brd->ProcessBulkRead();
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
-
- return brd->RequestId;
-}
-
-bool
-DBA__BulkReadData::ProcessCallback(int errorCode, NdbConnection * con){
-
- Index tmp = lastSend;
- const NdbOperation * op = con->getNextCompletedOperation(0);
-
- for(int i = 0; i<OpPerTrans && RowsAcknowledged < RowsSubmitted; i++){
- require(op != 0);
- if(op->getNdbError().code == 0)
- pData[tmp.datarow].RowFoundIndicator = 1;
- else
- pData[tmp.datarow].RowFoundIndicator = 0;
-
- RowsAcknowledged++;
- tmp.next(NbRows);
- op = con->getNextCompletedOperation(op);
- }
- return true;
-}
-
-void
-DBA__BulkReadData::ProcessBulkRead(){
-
- NdbConnection * con = DBA__TheNdb->startTransaction();
-
- Index tmp = nextSend;
-
- for(int i = 0; i<OpPerTrans && RowsSubmitted < TotalRows; i++){
-
- const DBA_Binding_t * binding = pBindings[tmp.binding];
- void * data = pData[tmp.datarow].DataPtr;
-
- NdbOperation * op = con->getNdbOperation(binding->tableName);
-
- op->simpleRead();
-
- require(DBA__EqualGetValue(op, binding, data));
-
- RowsSubmitted++;
- tmp.next(NbRows);
- }
-
- con->executeAsynchPrepare(Commit,
- NewtonCallback,
- (void*)this,
- CommitAsMuchAsPossible);
-
- lastSend = nextSend;
- nextSend = tmp;
-}
diff --git a/ndb/src/old_files/newtonapi/dba_config.cpp b/ndb/src/old_files/newtonapi/dba_config.cpp
deleted file mode 100644
index d84386a9438..00000000000
--- a/ndb/src/old_files/newtonapi/dba_config.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/* 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 */
-
-
-#include "dba_internal.hpp"
-
-int DBA__NBP_Intervall = 10;
-int DBA__BulkReadCount = 1000;
-int DBA__StartTransactionTimout = 0;
-int DBA__NBP_Force = 1;
-
-struct DBA__Config {
- int ParamId;
- int * Param;
- int min;
- int max;
- const char * Description;
-};
-
-static
-DBA__Config Parameters[] = {
- { 0, &DBA__NBP_Intervall, 4, INT_MAX,
- "Newton Batch Process Interval(ms)" },
- { 1, &DBA__BulkReadCount, 1, 5000,
- "Operations per transaction during bulkread" },
- { 2, &DBA__StartTransactionTimout, 0, INT_MAX,
- "Start transaction timeout(ms)" },
- { 3, &DBA__NBP_Force, 0, 2,
- "Newton Batch Process Force send algorithm" }
-};
-
-static const int Params = sizeof(Parameters)/sizeof(DBA__Config);
-
-static
-DBA__Config *
-getParam(int id){
- for(int i = 0; i<Params; i++)
- if(Parameters[i].ParamId == id)
- return &Parameters[i];
- return 0;
-}
-
-
-extern "C"
-DBA_Error_t
-DBA_SetParameter(int ParameterId, int Value){
- if(Value == -1){
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0, "Node id is not modifyable");
- return DBA_APPLICATION_ERROR;
- }
-
- DBA__Config * p = getParam(ParameterId);
-
- if(p == 0){
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0, "Invalid parameter id: %d",
- ParameterId);
- return DBA_APPLICATION_ERROR;
- }
-
- if(Value < p->min){
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0,
- "Value too small for parameter %d (min = %d)",
- Value, p->min);
- return DBA_APPLICATION_ERROR;
- }
-
- if(Value > p->max){
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0,
- "Value too big for parameter %d (max = %d)",
- Value, p->max);
- return DBA_APPLICATION_ERROR;
- }
-
- * p->Param = Value;
- return DBA_NO_ERROR;
-}
-
-extern "C"
-DBA_Error_t
-DBA_GetParameter(int ParameterId, int * Value){
- if(ParameterId == -1){
- if(DBA__TheNdb == 0){
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0, "DBA_Open() is not called"
- );
- return DBA_APPLICATION_ERROR;
- }
- * Value = DBA__TheNdb->getNodeId();
- return DBA_NO_ERROR;
- }
-
- DBA__Config * p = getParam(ParameterId);
- if(p == 0){
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0, "Invalid parameter id: %d",
- ParameterId);
- return DBA_APPLICATION_ERROR;
- }
-
- * Value = * p->Param;
-
- return DBA_NO_ERROR;
-}
-
diff --git a/ndb/src/old_files/newtonapi/dba_dac.cpp b/ndb/src/old_files/newtonapi/dba_dac.cpp
deleted file mode 100644
index fcb4e676e46..00000000000
--- a/ndb/src/old_files/newtonapi/dba_dac.cpp
+++ /dev/null
@@ -1,842 +0,0 @@
-/* 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 */
-
-
-#include "dba_internal.hpp"
-#include <NdbSleep.h>
-
-static void
-DBA__ErrorMapping(const NdbError & err, DBA_Error_t * status){
- switch(err.classification){
- case NdbError::ConstraintViolation:
- * status = DBA_CONSTRAINT_VIOLATION;
- break;
-
- case NdbError::NoDataFound:
- * status = DBA_NO_DATA;
- break;
-
- case NdbError::TemporaryResourceError:
- case NdbError::NodeRecoveryError:
- * status = DBA_TEMPORARY_ERROR;
- break;
-
- case NdbError::InsufficientSpace:
- * status = DBA_INSUFFICIENT_SPACE;
- break;
-
- case NdbError::UnknownResultError:
- * status = DBA_UNKNOWN_RESULT;
- break;
-
- case NdbError::OverloadError:
- * status = DBA_OVERLOAD;
- break;
-
- case NdbError::TimeoutExpired:
- * status = DBA_TIMEOUT;
- break;
-
- case NdbError::SchemaError:
- * status = DBA_SCHEMA_ERROR;
- break;
-
- case NdbError::ApplicationError:
- * status = DBA_APPLICATION_ERROR;
- break;
-
- case NdbError::InternalError:
- default:
- * status = DBA_NDB_ERROR;
- break;
- }
-}
-
-/**
- * Map between NDB error codes and DBA error codes
- */
-static
-void
-DBA__CallbackErrorCodeMapping(int errorCode,
- NdbConnection * connection,
- DBA_Error_t * status,
- DBA_ErrorCode_t * errCode) {
- if(errorCode == 0){
- * status = DBA_NO_ERROR;
- * errCode = 0;
- return;
- }
- const NdbError & err = connection->getNdbError();
- DBA__ErrorMapping(err, status);
- * errCode = err.code;
-}
-
-/**
- * When startTransaction fails
- */
-static
-void
-DBA__ConnectionErrorMapping(Ndb * theNdb){
- const NdbError & err = theNdb->getNdbError();
-
- DBA_Error_t status;
- DBA__ErrorMapping(err, &status);
-
- DBA__SetLatestError(status, err.code,
- err.message);
-}
-
-/**
- * When getNdbOperation fails
- */
-static
-void
-DBA__OperationErrorMapping(Ndb * theNdb, NdbConnection * con){
- const NdbError & err = theNdb->getNdbError();
-
- DBA_Error_t status;
- DBA__ErrorMapping(err, &status);
-
- DBA__SetLatestError(status, err.code,
- err.message);
-}
-
-/**
- * When equal/get/set value fails
- */
-static
-void
-DBA__EqualErrorMapping(Ndb * theNdb, NdbConnection * con, NdbOperation * op){
- const NdbError & err = theNdb->getNdbError();
-
- DBA_Error_t status;
- DBA__ErrorMapping(err, &status);
-
- DBA__SetLatestError(status, err.code,
- err.message);
-}
-
-static
-void
-NewtonCallback(int errorCode,
- NdbConnection * connection,
- void * anyObject){
-
- DBA_AsyncCallbackFn_t CbFunc = (DBA_AsyncCallbackFn_t)anyObject;
- DBA_ReqId_t ReqId = (DBA_ReqId_t) connection;
-
- DBA_Error_t Status = (DBA_Error_t) errorCode;
- DBA_ErrorCode_t Impl_Status ;
-
- DBA__CallbackErrorCodeMapping(errorCode, connection, &Status, &Impl_Status);
-
- DBA__TheNdb->closeTransaction(connection);
-
- DBA__RecvTransactions++;
-
- CbFunc(ReqId, Status, Impl_Status);
-}
-
-/**
- * Start transaction
- */
-NdbConnection *
-startTransaction(){
- NdbConnection * con = DBA__TheNdb->startTransaction();
- if(con != 0)
- return con;
-
- const int _t = (DBA__SentTransactions - DBA__RecvTransactions);
- const int t = (_t>0?_t:-_t);
-
- if(!(DBA__TheNdb->getNdbError().code == 4006 && t > 1000)){
- DBA_DEBUG("DBA__TheNdb->getNdbError() = " <<
- DBA__TheNdb->getNdbError());
- }
-
- int sum = 0;
- int sleepTime = 10;
- for(; con == 0 && sum < DBA__StartTransactionTimout; ){
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- NdbSleep_MilliSleep(sleepTime);
- NdbMutex_Lock(DBA__TheNewtonMutex);
- con = DBA__TheNdb->startTransaction();
-
- sum += sleepTime;
- sleepTime += 10;
- }
-
- return con;
-}
-
-#define CHECK_BINDINGS(Bindings) \
- if(!DBA__ValidBinding(Bindings)){ \
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0, "Invalid bindings"); \
- return DBA_INVALID_REQID; \
- }
-
-#define CHECK_BINDINGS2(Bindings, NbBindings) \
- if(!DBA__ValidBindings(Bindings, NbBindings)){ \
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0, "Invalid bindings"); \
- return DBA_INVALID_REQID; \
- }
-
-#define CHECK_CONNECTION(Connection) \
- if(Connection == 0){ \
- DBA__ConnectionErrorMapping(DBA__TheNdb); \
- NdbMutex_Unlock(DBA__TheNewtonMutex); \
- return DBA_INVALID_REQID; \
- }
-
-#define CHECK_OPERATION(Connection, Operation) \
- if(Operation == 0){ \
- DBA__OperationErrorMapping(DBA__TheNdb, Connection); \
- DBA__TheNdb->closeTransaction(Connection); \
- NdbMutex_Unlock(DBA__TheNewtonMutex); \
- return DBA_INVALID_REQID; \
- }
-
-#define EQUAL_ERROR(Connection, Operation) { \
- DBA__EqualErrorMapping(DBA__TheNdb, Connection, Operation); \
- DBA__TheNdb->closeTransaction(Connection); \
- NdbMutex_Unlock(DBA__TheNewtonMutex); \
- return DBA_INVALID_REQID; \
- }
-
-/****** THIS LINE IS 80 CHARACTERS WIDE - DO *NOT* EXCEED 80 CHARACTERS! ****/
-
-extern "C"
-DBA_ReqId_t
-DBA_ReadRows( const DBA_Binding_t* pBindings, void* const * _pData,
- int NbRows,
- DBA_AsyncCallbackFn_t CbFunc ) {
-
- CHECK_BINDINGS(pBindings);
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
- NdbConnection * con = startTransaction();
-
- CHECK_CONNECTION(con);
-
- for(int i = 0; i<NbRows; i++){
- NdbOperation * op = con->getNdbOperation(pBindings->tableName);
-
- CHECK_OPERATION(con, op);
-
- op->simpleRead();
-
- void * pData = _pData[i];
-
- if(!DBA__EqualGetValue(op, pBindings, pData)){
- EQUAL_ERROR(con, op);
- }
- }
-
- con->executeAsynchPrepare(Commit,
- NewtonCallback,
- (void*)CbFunc);
-
- DBA__SentTransactions++;
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return (DBA_ReqId_t) con;
-}
-
-extern "C"
-DBA_ReqId_t
-DBA_ArrayReadRows( const DBA_Binding_t* pBindings, void * pData,
- int NbRows,
- DBA_AsyncCallbackFn_t CbFunc ){
- CHECK_BINDINGS(pBindings);
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
- NdbConnection * con = startTransaction();
-
- CHECK_CONNECTION(con);
-
- for(int i = 0; i<NbRows; i++){
- NdbOperation * op = con->getNdbOperation(pBindings->tableName);
-
- CHECK_OPERATION(con, op);
-
- op->simpleRead();
-
- if(!DBA__EqualGetValue(op, pBindings,
- ((char*)pData)+i*pBindings->structSz)){
- EQUAL_ERROR(con, op);
- }
- }
-
- con->executeAsynchPrepare(Commit,
- NewtonCallback,
- (void*)CbFunc);
-
- DBA__SentTransactions++;
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return (DBA_ReqId_t) con;
-}
-
-extern "C"
-DBA_ReqId_t
-DBA_MultiReadRow(const DBA_Binding_t * const * pBindings,
- void * const * pData,
- int NbBindings,
- DBA_AsyncCallbackFn_t CbFunc ) {
- CHECK_BINDINGS2(pBindings, NbBindings);
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
- NdbConnection * con = startTransaction();
-
- CHECK_CONNECTION(con);
-
- for(int i = 0; i<NbBindings; i++){
- NdbOperation * op = con->getNdbOperation(pBindings[i]->tableName);
-
- CHECK_OPERATION(con, op);
-
- op->simpleRead();
-
- if(!DBA__EqualGetValue(op, pBindings[i], pData[i])){
- EQUAL_ERROR(con, op);
- }
- }
-
- con->executeAsynchPrepare(Commit,
- NewtonCallback,
- (void*)CbFunc);
-
- DBA__SentTransactions++;
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return (DBA_ReqId_t) con;
-}
-
-/****** THIS LINE IS 80 CHARACTERS WIDE - DO *NOT* EXCEED 80 CHARACTERS! ****/
-
-extern "C"
-DBA_ReqId_t
-DBA_InsertRows( const DBA_Binding_t* pBindings, const void * const * _pData,
- int NbRows,
- DBA_AsyncCallbackFn_t CbFunc ) {
- CHECK_BINDINGS(pBindings);
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
- NdbConnection * con = startTransaction();
-
- CHECK_CONNECTION(con);
-
- for(int i = 0; i<NbRows; i++){
- NdbOperation * op = con->getNdbOperation(pBindings->tableName);
-
- CHECK_OPERATION(con, op);
-
- op->insertTuple();
-
- const void * pData = _pData[i];
-
- if(!DBA__EqualSetValue(op, pBindings, pData)){
- EQUAL_ERROR(con, op);
- }
- }
-
- con->executeAsynchPrepare(Commit,
- NewtonCallback,
- (void*)CbFunc);
-
-
- DBA__SentTransactions++;
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return (DBA_ReqId_t) con;
-}
-
-extern "C"
-DBA_ReqId_t
-DBA_ArrayInsertRows( const DBA_Binding_t* pBindings, const void * pData,
- int NbRows,
- DBA_AsyncCallbackFn_t CbFunc ){
- CHECK_BINDINGS(pBindings);
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
- NdbConnection * con = startTransaction();
-
- CHECK_CONNECTION(con);
-
- for(int i = 0; i<NbRows; i++){
- NdbOperation * op = con->getNdbOperation(pBindings->tableName);
-
- CHECK_OPERATION(con, op);
-
- op->insertTuple();
-
- if(!DBA__EqualSetValue(op, pBindings,
- ((char*)pData)+i*pBindings->structSz)){
- EQUAL_ERROR(con, op);
- }
- }
-
- con->executeAsynchPrepare(Commit,
- NewtonCallback,
- (void*)CbFunc);
-
- DBA__SentTransactions++;
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return (DBA_ReqId_t) con;
-}
-
-extern "C"
-DBA_ReqId_t
-DBA_MultiInsertRow(const DBA_Binding_t * const * pBindings,
- const void * const * pData,
- int NbBindings,
- DBA_AsyncCallbackFn_t CbFunc ) {
- CHECK_BINDINGS2(pBindings, NbBindings);
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
- NdbConnection * con = startTransaction();
-
- CHECK_CONNECTION(con);
-
- for(int i = 0; i<NbBindings; i++){
- NdbOperation * op = con->getNdbOperation(pBindings[i]->tableName);
-
- CHECK_OPERATION(con, op);
-
- op->insertTuple();
-
- if(!DBA__EqualSetValue(op, pBindings[i], pData[i])){
- EQUAL_ERROR(con, op);
- }
- }
-
- con->executeAsynchPrepare(Commit,
- NewtonCallback,
- (void*)CbFunc);
-
- DBA__SentTransactions++;
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return (DBA_ReqId_t) con;
-}
-
-/****** THIS LINE IS 80 CHARACTERS WIDE - DO *NOT* EXCEED 80 CHARACTERS! ****/
-
-extern "C"
-DBA_ReqId_t
-DBA_UpdateRows( const DBA_Binding_t* pBindings, const void * const * _pData,
- int NbRows,
- DBA_AsyncCallbackFn_t CbFunc ) {
- CHECK_BINDINGS(pBindings);
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
- NdbConnection * con = startTransaction();
-
- CHECK_CONNECTION(con);
-
- for(int i = 0; i<NbRows; i++){
- NdbOperation * op = con->getNdbOperation(pBindings->tableName);
-
- CHECK_OPERATION(con, op);
-
- op->updateTuple();
-
- const void * pData = _pData[i];
-
- if(!DBA__EqualSetValue(op, pBindings, pData)){
- EQUAL_ERROR(con, op);
- }
- }
-
- con->executeAsynchPrepare(Commit,
- NewtonCallback,
- (void*)CbFunc);
-
-
- DBA__SentTransactions++;
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return (DBA_ReqId_t) con;
-}
-
-extern "C"
-DBA_ReqId_t
-DBA_ArrayUpdateRows( const DBA_Binding_t* pBindings, const void * pData,
- int NbRows,
- DBA_AsyncCallbackFn_t CbFunc ){
- CHECK_BINDINGS(pBindings);
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
- NdbConnection * con = startTransaction();
-
- CHECK_CONNECTION(con);
-
- for(int i = 0; i<NbRows; i++){
- NdbOperation * op = con->getNdbOperation(pBindings->tableName);
-
- CHECK_OPERATION(con, op);
-
- op->updateTuple();
-
- if(!DBA__EqualSetValue(op, pBindings,
- ((char*)pData)+i*pBindings->structSz)){
- EQUAL_ERROR(con, op);
- }
- }
-
- con->executeAsynchPrepare(Commit,
- NewtonCallback,
- (void*)CbFunc);
-
- DBA__SentTransactions++;
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return (DBA_ReqId_t) con;
-}
-
-extern "C"
-DBA_ReqId_t
-DBA_MultiUpdateRow(const DBA_Binding_t * const * pBindings,
- const void * const * pData,
- int NbBindings,
- DBA_AsyncCallbackFn_t CbFunc ) {
- CHECK_BINDINGS2(pBindings, NbBindings);
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
- NdbConnection * con = startTransaction();
-
- CHECK_CONNECTION(con);
-
- for(int i = 0; i<NbBindings; i++){
- NdbOperation * op = con->getNdbOperation(pBindings[i]->tableName);
-
- CHECK_OPERATION(con, op);
-
- op->updateTuple();
-
- if(!DBA__EqualSetValue(op, pBindings[i], pData[i])){
- EQUAL_ERROR(con, op);
- }
- }
-
- con->executeAsynchPrepare(Commit,
- NewtonCallback,
- (void*)CbFunc);
-
- DBA__SentTransactions++;
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return (DBA_ReqId_t) con;
-}
-
-/****** THIS LINE IS 80 CHARACTERS WIDE - DO *NOT* EXCEED 80 CHARACTERS! ****/
-
-extern "C"
-DBA_ReqId_t
-DBA_WriteRows( const DBA_Binding_t* pBindings, const void * const * _pData,
- int NbRows,
- DBA_AsyncCallbackFn_t CbFunc ) {
- CHECK_BINDINGS(pBindings);
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
- NdbConnection * con = startTransaction();
-
- CHECK_CONNECTION(con);
-
- for(int i = 0; i<NbRows; i++){
- NdbOperation * op = con->getNdbOperation(pBindings->tableName);
-
- CHECK_OPERATION(con, op);
-
- op->writeTuple();
-
- const void * pData = _pData[i];
-
- if(!DBA__EqualSetValue(op, pBindings, pData)){
- EQUAL_ERROR(con, op);
- }
- }
-
- con->executeAsynchPrepare(Commit,
- NewtonCallback,
- (void*)CbFunc);
-
-
- DBA__SentTransactions++;
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return (DBA_ReqId_t) con;
-}
-
-extern "C"
-DBA_ReqId_t
-DBA_ArrayWriteRows( const DBA_Binding_t* pBindings, const void * pData,
- int NbRows,
- DBA_AsyncCallbackFn_t CbFunc ){
- CHECK_BINDINGS(pBindings);
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
- NdbConnection * con = startTransaction();
-
- CHECK_CONNECTION(con);
-
- for(int i = 0; i<NbRows; i++){
- NdbOperation * op = con->getNdbOperation(pBindings->tableName);
-
- CHECK_OPERATION(con, op);
-
- op->writeTuple();
-
- if(!DBA__EqualSetValue(op, pBindings,
- ((char*)pData)+i*pBindings->structSz)){
- EQUAL_ERROR(con, op);
- }
- }
-
- con->executeAsynchPrepare(Commit,
- NewtonCallback,
- (void*)CbFunc);
-
- DBA__SentTransactions++;
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return (DBA_ReqId_t) con;
-}
-
-extern "C"
-DBA_ReqId_t
-DBA_MultiWriteRow(const DBA_Binding_t * const * pBindings,
- const void * const * pData,
- int NbBindings,
- DBA_AsyncCallbackFn_t CbFunc ) {
- CHECK_BINDINGS2(pBindings, NbBindings);
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
- NdbConnection * con = startTransaction();
-
- CHECK_CONNECTION(con);
-
- for(int i = 0; i<NbBindings; i++){
- NdbOperation * op = con->getNdbOperation(pBindings[i]->tableName);
-
- CHECK_OPERATION(con, op);
-
- op->writeTuple();
-
- if(!DBA__EqualSetValue(op, pBindings[i], pData[i])){
- EQUAL_ERROR(con, op);
- }
- }
-
- con->executeAsynchPrepare(Commit,
- NewtonCallback,
- (void*)CbFunc);
-
- DBA__SentTransactions++;
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return (DBA_ReqId_t) con;
-}
-
-/****** THIS LINE IS 80 CHARACTERS WIDE - DO *NOT* EXCEED 80 CHARACTERS! ****/
-
-extern "C"
-DBA_ReqId_t
-DBA_DeleteRows( const DBA_Binding_t* pBindings, const void * const * _pData,
- int NbRows,
- DBA_AsyncCallbackFn_t CbFunc ) {
- CHECK_BINDINGS(pBindings);
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
- NdbConnection * con = startTransaction();
-
- CHECK_CONNECTION(con);
-
- for(int i = 0; i<NbRows; i++){
- NdbOperation * op = con->getNdbOperation(pBindings->tableName);
-
- CHECK_OPERATION(con, op);
-
- op->deleteTuple();
-
- const void * pData = _pData[i];
-
- if(!DBA__Equal(op, pBindings, pData)){
- EQUAL_ERROR(con, op);
- }
- }
-
- con->executeAsynchPrepare(Commit,
- NewtonCallback,
- (void*)CbFunc);
-
- DBA__SentTransactions++;
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return (DBA_ReqId_t) con;
-}
-
-extern "C"
-DBA_ReqId_t
-DBA_ArrayDeleteRows( const DBA_Binding_t* pBindings, const void * pData,
- int NbRows,
- DBA_AsyncCallbackFn_t CbFunc ){
- CHECK_BINDINGS(pBindings);
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
- NdbConnection * con = startTransaction();
-
- CHECK_CONNECTION(con);
-
- for(int i = 0; i<NbRows; i++){
- NdbOperation * op = con->getNdbOperation(pBindings->tableName);
-
- CHECK_OPERATION(con, op);
-
- op->deleteTuple();
-
- if(!DBA__Equal(op, pBindings,
- ((char*)pData)+i*pBindings->structSz)){
- EQUAL_ERROR(con, op);
- }
- }
-
- con->executeAsynchPrepare(Commit,
- NewtonCallback,
- (void*)CbFunc);
-
- DBA__SentTransactions++;
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return (DBA_ReqId_t) con;
-}
-
-extern "C"
-DBA_ReqId_t
-DBA_MultiDeleteRow(const DBA_Binding_t * const * pBindings,
- const void * const * pData,
- int NbBindings,
- DBA_AsyncCallbackFn_t CbFunc ) {
- CHECK_BINDINGS2(pBindings, NbBindings);
-
- NdbMutex_Lock(DBA__TheNewtonMutex);
- NdbConnection * con = startTransaction();
-
- CHECK_CONNECTION(con);
-
- for(int i = 0; i<NbBindings; i++){
- NdbOperation * op = con->getNdbOperation(pBindings[i]->tableName);
-
- CHECK_OPERATION(con, op);
-
- op->deleteTuple();
-
- if(!DBA__Equal(op, pBindings[i], pData[i])){
- EQUAL_ERROR(con, op);
- }
- }
-
- con->executeAsynchPrepare(Commit,
- NewtonCallback,
- (void*)CbFunc);
-
- DBA__SentTransactions++;
-
- NdbMutex_Unlock(DBA__TheNewtonMutex);
- return (DBA_ReqId_t) con;
-}
-
-/****** THIS LINE IS 80 CHARACTERS WIDE - DO *NOT* EXCEED 80 CHARACTERS! ****/
-
-bool
-DBA__EqualGetValue(NdbOperation * op,
- const DBA_Binding_t* pBindings,
- void * pData){
- for(int i = 0; i<pBindings->noOfKeys; i++){
- if(op->equal(pBindings->keyIds[i],
- (const char*)pData+pBindings->keyOffsets[i]) == -1){
- return false;
- }
- }
-
- for(int i = 0; i<pBindings->noOfColumns; i++){
- if(op->getValue(pBindings->columnIds[i],
- (char*)pData+pBindings->columnOffsets[i]) == 0){
- return false;
- }
- }
-
- for(int i = 0; i<pBindings->noOfSubBindings; i++){
- void * tData = *(void**)((char *)pData+pBindings->subBindingOffsets[i]);
- const DBA_Binding_t * tBinding = pBindings->subBindings[i];
- if(!DBA__EqualGetValue(op, tBinding, tData))
- return false;
- }
-
- return true;
-}
-
-bool
-DBA__EqualSetValue(NdbOperation * op,
- const DBA_Binding_t* pBindings,
- const void * pData){
-
- for(int i = 0; i<pBindings->noOfKeys; i++){
- if(op->equal(pBindings->keyIds[i],
- (const char*)pData+pBindings->keyOffsets[i]) == -1){
- return false;
- }
- }
-
- for(int i = 0; i<pBindings->noOfColumns; i++){
- if(op->setValue(pBindings->columnIds[i],
- (char*)pData+pBindings->columnOffsets[i]) == -1){
- return false;
- }
- }
-
- for(int i = 0; i<pBindings->noOfSubBindings; i++){
- void * tData = * (void**)((char *)pData+pBindings->subBindingOffsets[i]);
- const DBA_Binding_t * tBinding = pBindings->subBindings[i];
- if(!DBA__EqualSetValue(op, tBinding, tData))
- return false;
- }
-
- return true;
-}
-
-bool
-DBA__Equal(NdbOperation * op,
- const DBA_Binding_t* pBindings,
- const void * pData){
-
- for(int i = 0; i<pBindings->noOfKeys; i++)
- if(op->equal(pBindings->keyIds[i],
- (const char*)pData+pBindings->keyOffsets[i]) == -1){
- return false;
- }
-
- for(int i = 0; i<pBindings->noOfSubBindings; i++){
- void * tData = *(void**)((char *)pData+pBindings->subBindingOffsets[i]);
- const DBA_Binding_t * tBinding = pBindings->subBindings[i];
- if(!DBA__Equal(op, tBinding, tData))
- return false;
- }
-
- return true;
-}
-
diff --git a/ndb/src/old_files/newtonapi/dba_error.cpp b/ndb/src/old_files/newtonapi/dba_error.cpp
deleted file mode 100644
index f05446522b0..00000000000
--- a/ndb/src/old_files/newtonapi/dba_error.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/* 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 */
-
-
-#include <ndb_global.h>
-
-#include "dba_internal.hpp"
-
-static DBA_Error_t latestError = DBA_NO_ERROR;
-static DBA_ErrorCode_t latestNdbError = 0;
-static char latestMsg[1024];
-
-/**
- * Private
- */
-void
-DBA__SetLatestError(DBA_Error_t le,
- DBA_ErrorCode_t lnb,
- const char * msg, ...){
-
- require(msg != 0);
-
- latestError = le;
- latestNdbError = lnb;
-
- va_list ap;
-
- va_start(ap, msg);
- vsnprintf(latestMsg, sizeof(latestMsg)-1, msg, ap);
- va_end(ap);
-}
-
-/**
- * Get latest DBA error
- */
-extern "C"
-DBA_Error_t
-DBA_GetLatestError(){
- return latestError;
-}
-
-/**
- * Get latest error string associated with GetLatestError
- *
- * String must not be free by caller of this method
- */
-extern "C"
-const char *
-DBA_GetLatestErrorMsg(){
- return latestMsg;
-}
-
-/**
- * Get the latest NDB error
- *
- * Note only applicable to synchronous methods
- */
-extern "C"
-DBA_ErrorCode_t
-DBA_GetLatestNdbError(){
- return latestNdbError;
-}
-
-extern "C"
-const
-char *
-DBA_GetNdbErrorMsg(DBA_ErrorCode_t code){
- return DBA__TheNdb->getNdbError(code).message;
-}
-
-struct DBA_ErrorTxtMap {
- DBA_Error_t Error;
- const char * Msg;
-};
-
-static
-const DBA_ErrorTxtMap errMap[] = {
- { DBA_NO_ERROR, "No error" },
- { DBA_NOT_IMPLEMENTED, "Function Not Implemented" },
- { DBA_NDB_ERROR, "Uncategorised NDB error" },
- { DBA_ERROR, "Uncategorised DBA implementation error" },
- { DBA_APPLICATION_ERROR,
- "Function called with invalid argument(s)/invalid sequence(s)" },
- { DBA_NO_DATA, "No row with specified PK existed" },
- { DBA_CONSTRAINT_VIOLATION, "There already existed a row with that PK" },
-
- { DBA_TEMPORARY_ERROR, "Request failed due to temporary reasons" },
- { DBA_INSUFFICIENT_SPACE,
- "The DB is full" },
- { DBA_OVERLOAD, "Request was rejected in NDB due to high load situation" },
- { DBA_TIMEOUT, "The request timed out, probably due to dead-lock" }
-};
-
-static const int ErrMsgs = sizeof(errMap)/sizeof(DBA_ErrorTxtMap);
-
-extern "C"
-const
-char *
-DBA_GetErrorMsg(DBA_Error_t e){
- for(int i = 0; i<ErrMsgs; i++)
- if(errMap[i].Error == e)
- return errMap[i].Msg;
- return "Invalid error code";
-}
-
diff --git a/ndb/src/old_files/newtonapi/dba_init.cpp b/ndb/src/old_files/newtonapi/dba_init.cpp
deleted file mode 100644
index aa5fef1171c..00000000000
--- a/ndb/src/old_files/newtonapi/dba_init.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/* 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 */
-
-
-#include "dba_internal.hpp"
-#include "dba_process.hpp"
-#include <NdbOut.hpp>
-
-
-#ifdef NDB_WIN32
-static NdbMutex & DBA__InitMutex = * NdbMutex_Create();
-#else
-static NdbMutex DBA__InitMutex = NDB_MUTEX_INITIALIZER;
-#endif
-
-Ndb * DBA__TheNdb = 0;
-NdbMutex * DBA__TheNewtonMutex = 0;
-unsigned DBA__SentTransactions = 0;
-unsigned DBA__RecvTransactions = 0;
-NewtonBatchProcess * DBA__TheNBP = 0;
-
-extern "C"
-DBA_Error_t
-DBA_Open( ) {
- NdbMutex_Lock(&DBA__InitMutex);
-
- if(DBA__TheNdb != 0){
- NdbMutex_Unlock(&DBA__InitMutex);
- return DBA_NO_ERROR;
- }
-
- DBA__TheNdb = new Ndb("Newton");
- DBA__TheNdb->init(1024);
- if(DBA__TheNdb->waitUntilReady() != 0){
- delete DBA__TheNdb; DBA__TheNdb = 0;
- NdbMutex_Unlock(&DBA__InitMutex);
- return DBA_NDB_ERROR;
- }
- DBA__TheNewtonMutex = NdbMutex_Create();
- DBA__TheNBP = new NewtonBatchProcess(* DBA__TheNdb, * DBA__TheNewtonMutex);
- DBA__TheNBP->doStart();
- NdbMutex_Unlock(&DBA__InitMutex);
- return DBA_NO_ERROR;
-}
-
-
-/**
- * Closes the database.
- *
- * @return Error status
- */
-extern "C"
-DBA_Error_t
-DBA_Close(void){
-
- NdbMutex_Lock(&DBA__InitMutex);
-
- if(DBA__TheNBP != 0)
- DBA__TheNBP->doStop(true);
- delete DBA__TheNBP;
- DBA__TheNBP = 0;
-
- if(DBA__TheNdb != 0)
- delete DBA__TheNdb;
- DBA__TheNdb = 0;
-
- if(DBA__TheNewtonMutex != 0)
- NdbMutex_Destroy(DBA__TheNewtonMutex);
- DBA__TheNewtonMutex = 0;
-
- NdbMutex_Unlock(&DBA__InitMutex);
- return DBA_NO_ERROR;
-}
diff --git a/ndb/src/old_files/newtonapi/dba_internal.hpp b/ndb/src/old_files/newtonapi/dba_internal.hpp
deleted file mode 100644
index 84ae7ba222b..00000000000
--- a/ndb/src/old_files/newtonapi/dba_internal.hpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/* 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 */
-
-#ifndef DBA_INTERNAL_HPP
-#define DBA_INTERNAL_HPP
-
-#include <ndb_global.h>
-
-extern "C" {
-#include "dba.h"
-}
-
-#include <NdbApi.hpp>
-#include <NdbMutex.h>
-#include <NdbOut.hpp>
-
-#ifndef INT_MAX
-#define INT_MAX 2147483647
-#endif
-
-#ifdef DEBUG
-#define DBA_DEBUG(x) ndbout << x << endl
-#else
-#define DBA_DEBUG(x)
-#endif
-
-extern Ndb * DBA__TheNdb;
-extern NdbMutex * DBA__TheNewtonMutex;
-
-extern unsigned DBA__SentTransactions;
-extern unsigned DBA__RecvTransactions;
-
-/**
- * Configuration
- */
-extern int DBA__NBP_Intervall; // Param 0
-extern int DBA__BulkReadCount; // Param 1
-extern int DBA__StartTransactionTimout; // Param 2
-extern int DBA__NBP_Force; // Param 3
-
-/**
- * Error handling
- */
-void DBA__SetLatestError(DBA_Error_t, DBA_ErrorCode_t, const char *, ...);
-
-/**
- * Magic string
- *
- * Used to make sure that user passes correct pointers
- */
-const int DBA__MagicLength = 4;
-const char DBA__TheMagic[DBA__MagicLength] = { 'K', 'E', 'S', 'O' };
-
-struct DBA_Binding {
- char magic[DBA__MagicLength];
- int checkSum;
-
- char * tableName;
- int structSz;
-
- int noOfKeys;
- int *keyIds;
- int *keyOffsets;
-
- int noOfColumns;
- int *columnIds;
- int *columnOffsets;
-
- int noOfSubBindings;
- struct DBA_Binding **subBindings;
- int * subBindingOffsets;
-
- int data[1];
-};
-
-struct DBA__DataTypesMapping {
- DBA_DataTypes_t newtonType;
- NdbDictionary::Column::Type ndbType;
-};
-
-const DBA__DataTypesMapping DBA__DataTypesMappings[] = {
- { DBA_CHAR, NdbDictionary::Column::Char },
- { DBA_INT, NdbDictionary::Column::Int }
-};
-
-const int DBA__NoOfMappings = sizeof(DBA__DataTypesMappings)/
- sizeof(DBA__DataTypesMapping);
-
-/**
- * Validate magic string and checksum of a binding
- */
-bool DBA__ValidBinding(const DBA_Binding_t * bindings);
-bool DBA__ValidBindings(const DBA_Binding_t * const * pBindings, int n);
-
-/**
- * Recursive equalGetValue (used for read)
- * equalSetValue (used for write)
- * equal (used for delete)
- */
-bool DBA__EqualGetValue(NdbOperation *, const DBA_Binding_t *, void *);
-bool DBA__EqualSetValue(NdbOperation *, const DBA_Binding_t *, const void *);
-bool DBA__Equal (NdbOperation *, const DBA_Binding_t *, const void *);
-
-inline void require(bool test){
- if(!test)
- abort();
-}
-
-#endif
diff --git a/ndb/src/old_files/newtonapi/dba_process.cpp b/ndb/src/old_files/newtonapi/dba_process.cpp
deleted file mode 100644
index ddb6e62f180..00000000000
--- a/ndb/src/old_files/newtonapi/dba_process.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/* 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 */
-
-
-#include "dba_process.hpp"
-
-NewtonBatchProcess::NewtonBatchProcess(Ndb & ndb, NdbMutex & mutex) :
- theNdb(ndb),
- theMutex(mutex)
-{
- theThread = 0;
- startStopMutex = NdbMutex_Create();
-
- _running = false;
- _stop = false;
-}
-
-NewtonBatchProcess::~NewtonBatchProcess(){
- doStop(true);
-
- if(theThread != 0)
- NdbThread_Destroy(&theThread);
-
- if(startStopMutex != 0)
- NdbMutex_Destroy(startStopMutex);
- startStopMutex = 0;
-}
-
-extern "C"
-void*
-runNDB_C(void * _nbp){
- NewtonBatchProcess * nbp = (NewtonBatchProcess*)_nbp;
- nbp->_running = true;
- nbp->run();
- nbp->_running = false;
-
- /**
- * This sleep is to make sure that the transporter
- * send thread will come in and send any
- * signal buffers that this thread may have allocated.
- * If that doesn't happen an error will occur in OSE
- * when trying to restore a signal buffer allocated by a thread
- * that have been killed.
- */
- NdbSleep_MilliSleep(50);
- NdbThread_Exit(0);
- return 0;
-}
-
-void
-NewtonBatchProcess::doStart(){
- NdbMutex_Lock(startStopMutex);
- if(_running && !_stop){
- NdbMutex_Unlock(startStopMutex);
- return ;
- }
-
- while(_running){
- NdbMutex_Unlock(startStopMutex);
- NdbSleep_MilliSleep(200);
- NdbMutex_Lock(startStopMutex);
- }
-
- require(!_running);
- _stop = false;
-
- if(theThread != 0)
- NdbThread_Destroy(&theThread);
-
- theThread = NdbThread_Create(runNDB_C,
- (void**)this,
- 65535,
- "Newton_BP",
- NDB_THREAD_PRIO_LOWEST);
-
- NdbMutex_Unlock(startStopMutex);
-}
-
-void
-NewtonBatchProcess::doStop(bool wait){
- NdbMutex_Lock(startStopMutex);
- _stop = true;
-
- if(wait){
- while(_running){
- NdbSleep_MilliSleep(200);
- }
- }
- NdbMutex_Unlock(startStopMutex);
-}
-
-bool
-NewtonBatchProcess::isRunning() const {
- return _running;
-}
-
-bool
-NewtonBatchProcess::isStopping() const {
- return _stop;
-}
-
-void
-NewtonBatchProcess::run(){
- while(!_stop){
- NdbMutex_Lock(&theMutex);
- theNdb.sendPollNdb(0, 1, DBA__NBP_Force);
- NdbMutex_Unlock(&theMutex);
- NdbSleep_MilliSleep(DBA__NBP_Intervall);
- }
-}
diff --git a/ndb/src/old_files/newtonapi/dba_process.hpp b/ndb/src/old_files/newtonapi/dba_process.hpp
deleted file mode 100644
index ef24fbd9142..00000000000
--- a/ndb/src/old_files/newtonapi/dba_process.hpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/* 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 */
-
-#ifndef NEWTON_BP_HPP
-#define NEWTON_BP_HPP
-
-#include "dba_internal.hpp"
-
-#include <NdbThread.h>
-#include <NdbMutex.h>
-#include <NdbSleep.h>
-
-extern "C" void* runNDB_C(void * nbp);
-
-/**
- * This class implements the NewtonBatchProcess
- */
-class NewtonBatchProcess {
- friend void* runNDB_C(void * nbp);
-public:
- NewtonBatchProcess(Ndb &, NdbMutex &);
- ~NewtonBatchProcess();
-
- void doStart();
- void doStop(bool wait);
-
- bool isRunning() const ;
- bool isStopping() const ;
-
-private:
- void run();
-
- bool _running;
- bool _stop;
-
- Ndb & theNdb;
- NdbMutex & theMutex;
-
- NdbThread * theThread;
- NdbMutex * startStopMutex;
-};
-
-#endif
diff --git a/ndb/src/old_files/newtonapi/dba_schema.cpp b/ndb/src/old_files/newtonapi/dba_schema.cpp
deleted file mode 100644
index 1bf21f1fe80..00000000000
--- a/ndb/src/old_files/newtonapi/dba_schema.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/* 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 */
-
-#include "dba_internal.hpp"
-#include "NdbSchemaCon.hpp"
-
-static bool getNdbAttr(DBA_DataTypes_t,
- Size_t,
- int * attrSize,
- int * arraySize,
- AttrType * attrType);
-
-extern "C"
-DBA_Error_t
-DBA_CreateTable(const char* TableName,
- int NbColumns,
- const DBA_ColumnDesc_t Columns[] ){
-
- if(DBA_TableExists(TableName))
- return DBA_NO_ERROR;
-
- NdbSchemaCon * schemaCon = NdbSchemaCon::startSchemaTrans(DBA__TheNdb);
- if(schemaCon == 0){
- DBA__SetLatestError(DBA_NDB_ERROR, 0,
- "Internal NDB error: No schema transaction");
- return DBA_NDB_ERROR;
- }
-
- NdbSchemaOp * schemaOp = schemaCon->getNdbSchemaOp();
- if(schemaOp == 0){
- NdbSchemaCon::closeSchemaTrans(schemaCon);
- DBA__SetLatestError(DBA_NDB_ERROR, 0,
- "Internal NDB error: No schema op");
- return DBA_NDB_ERROR;
- }
-
- if(schemaOp->createTable( TableName,
- 8, // Data Size
- TupleKey,
- 2, // Index size
- All,
- 6,
- 78,
- 80,
- 1,
- false) == -1){
- NdbSchemaCon::closeSchemaTrans(schemaCon);
- DBA__SetLatestError(DBA_NDB_ERROR, 0,
- "Internal NDB error: Create table failed");
- return DBA_NDB_ERROR;
- }
-
- for (int i = 0; i < NbColumns; i++){
- int attrSize;
- int arraySize;
- AttrType attrType;
-
- if(!getNdbAttr(Columns[i].DataType, Columns[i].Size,
- &attrSize,
- &arraySize,
- &attrType)){
- NdbSchemaCon::closeSchemaTrans(schemaCon);
- DBA__SetLatestError(DBA_APPLICATION_ERROR, 0,
- "Invalid datatype/size combination");
- return DBA_APPLICATION_ERROR;
- }
-
- if(schemaOp->createAttribute( Columns[i].Name,
- Columns[i].IsKey ? TupleKey : NoKey,
- attrSize,
- arraySize,
- attrType) == -1){
- NdbSchemaCon::closeSchemaTrans(schemaCon);
- DBA__SetLatestError(DBA_NDB_ERROR, 0,
- "Internal NDB error: Create attribute failed");
- return DBA_NDB_ERROR;
- }
- }
-
- if(schemaCon->execute() == -1){
- NdbSchemaCon::closeSchemaTrans(schemaCon);
- DBA__SetLatestError(DBA_NDB_ERROR, 0,
- "Internal NDB error: Execute schema failed");
- return DBA_NDB_ERROR;
- }
-
- NdbSchemaCon::closeSchemaTrans(schemaCon);
-
- return DBA_NO_ERROR;
-}
-
-DBA_Error_t
-DBA_DropTable( char* TableName ){
- return DBA_NOT_IMPLEMENTED;
-}
-
-Boolean_t
-DBA_TableExists( const char* TableName ){
- NdbDictionary::Dictionary * dict = DBA__TheNdb->getDictionary();
- if(dict == 0){
- return 0;
- }
-
- const NdbDictionary::Table * tab = dict->getTable(TableName);
- if(tab == 0){
- return 0;
- }
- return 1;
-}
-
-static
-bool
-getNdbAttr(DBA_DataTypes_t type,
- Size_t size,
- int * attrSize,
- int * arraySize,
- AttrType * attrType) {
-
- if(type == DBA_CHAR){
- * attrType = String;
- * attrSize = 8;
- * arraySize = size;
- return true;
- }
-
- * attrType = Signed;
- if((size % 4) == 0){
- * attrSize = 32;
- * arraySize = size / 4;
- return true;
- }
-
- * attrSize = 8;
- * arraySize = size;
-
- return true;
-}