Commit ad959d35 authored by unknown's avatar unknown

Removed AttrType.hpp and moved the "internal" datatypes to their corresponding class.

Moved NdbSchemaCon and NdbSchemaOp out of the public NdbApi, it can however still be used by old test programs.
Added print oof indexes to desc.


ndb/BinDist.sh:
  Removed AttrType.hpp from BinDist.sh
ndb/include/ndbapi/Ndb.hpp:
  Removed NdbSchemaCon and NdbSchemaOp includes from public NdbApi
  Removed AttrType.hpp
ndb/include/ndbapi/NdbApi.hpp:
  Removed NdbSchemaCon and NdbSchemaOp includes from public NdbApi
  Removed AttrType.hpp
ndb/include/ndbapi/NdbConnection.hpp:
  Removed NdbSchemaCon and NdbSchemaOp includes from public NdbApi
  Removed AttrType.hpp
  Moved internal types to the class where they are used
ndb/include/ndbapi/NdbIndexOperation.hpp:
  Use limit from ndbapi_limit.h
ndb/include/ndbapi/NdbOperation.hpp:
  Removed NdbSchemaCon and NdbSchemaOp includes from public NdbApi
  Removed AttrType.hpp
  Remove faulty comment about how many attributes a key is allowed to consist of
  Removed unused member variables
ndb/include/ndbapi/NdbRecAttr.hpp:
  Removed NdbSchemaCon and NdbSchemaOp includes from public NdbApi
  Removed AttrType.hpp
ndb/include/ndbapi/NdbSchemaCon.hpp:
  Removed NdbSchemaCon and NdbSchemaOp includes from public NdbApi
  Removed AttrType.hpp
ndb/include/ndbapi/NdbSchemaOp.hpp:
  Removed NdbSchemaCon and NdbSchemaOp includes from public NdbApi
  Removed AttrType.hpp
  Moved all "old" datatypes here, so if a test program is still using old type, include NdbSchemaCon.hpp
ndb/include/ndbapi/ndbapi_limits.h:
  Corrected limitations, added some from AttrTyp.hpp
ndb/src/Makefile:
  Remove newtonapi from Makefile
ndb/src/kernel/blocks/backup/restore/Restore.hpp:
  Removed AttrType
  Include NdbSchemaCon since restore uses old types
ndb/src/kernel/blocks/backup/restore/main.cpp:
  Include NdbOut
ndb/src/mgmsrv/MgmtSrvr.cpp:
  Remov AttrType.hpp
ndb/src/ndbapi/ClusterMgr.cpp:
  Remov AttrType.hpp
ndb/src/ndbapi/Ndb.cpp:
  Removed NdbSchemaCon and NdbSchemaOp includes from public NdbApi
  Removed AttrType.hpp
  Moved internal types to the class where they are used
ndb/src/ndbapi/NdbApiSignal.cpp:
  Removed AttrType.hpp
ndb/src/ndbapi/NdbApiSignal.hpp:
  Removed AttrType.hpp
ndb/src/ndbapi/NdbConnection.cpp:
  Moved internal type s to the class where they belong
ndb/src/ndbapi/NdbDictionaryImpl.cpp:
  RemovedAttrType.hpp
  Use limits from ndbapi_limits.h
ndb/src/ndbapi/NdbEventOperationImpl.cpp:
  Removed AttrType.hpp
  Moved printRecAttr to end since it depends on old types and need to include "NdbSchemaCon", function will be rewritten and moved to NdbRecAttr. It's also useful from other places where an attribute has been read into an NdbRecAttr.
ndb/src/ndbapi/NdbIndexOperation.cpp:
  Use limitations from ndbapi_limits.h
  Moved internal tyeps to the class where they belongs
ndb/src/ndbapi/NdbOperation.cpp:
  Use limits from ndbapi_limits.h
ndb/src/ndbapi/NdbOperationDefine.cpp:
  Remove AttrType.hpp
ndb/src/ndbapi/NdbOperationExec.cpp:
  Moved internal tyeps to the class where they belongs
ndb/src/ndbapi/NdbOperationInt.cpp:
  RemovedAttrType.hpp
  Use limits from ndbapi_limits.h
ndb/src/ndbapi/NdbOperationScan.cpp:
  RemovedAttrType.hpp
  Use limits from ndbapi_limits.h
ndb/src/ndbapi/NdbOperationSearch.cpp:
  Removed AttrType.hpp
  Use limits from ndbapi_limits.h
ndb/src/ndbapi/NdbResultSet.cpp:
  Moved the "internal" types to corresponding class
ndb/src/ndbapi/NdbSchemaCon.cpp:
  Updated not to be included in public NdbApi
ndb/src/ndbapi/NdbSchemaOp.cpp:
  Updated not to be included in public NdbApi
ndb/src/ndbapi/NdbUtil.hpp:
  Removed AttrType.hpp
ndb/src/ndbapi/Ndbif.cpp:
  Removed AttrType.hpp
  Removed NdbSchemaCon and NdbSchemaOp from public NdbApi
  Moved "interal" types to their corresponding class
ndb/src/ndbapi/Ndbinit.cpp:
  Removed NdbSchemaCon and NdbSchemaOp from public NdbApi
ndb/src/ndbapi/Ndblist.cpp:
  Removed NdbSchemaCon and NdbSchemaOp from public NdbApi
  Moved "internal" types to their corresponding class
ndb/src/ndbapi/TransporterFacade.cpp:
  Removed AttrType.hpp
ndb/src/ndbapi/TransporterFacade.hpp:
  Removed AttrType.hpp
  Moved internal definition of how many Ndb objects to create to here
ndb/test/include/NDBT_Table.hpp:
  Removed old NdbSchema*
  Added function to print information about an index
ndb/test/ndbapi/acid/acid.cpp:
  This test program uses old NdbScheaCon.hpp
ndb/test/ndbapi/flexAsynch/flexAsynch.cpp:
  This test program uses old NdbScheaCon.hpp
ndb/test/ndbapi/flexScan/flexScan.cpp:
  This test program uses old NdbScheaCon.hpp
ndb/test/ndbapi/interpreterInTup/interpreterInTup.cpp:
  This test program uses old NdbScheaCon.hpp
ndb/test/ndbapi/lmc-bench/src/user/userInterface.cpp:
  This test program uses old NdbScheaCon.hpp
ndb/test/ndbapi/ronja/initronja/initronja.cpp:
  This test program uses old NdbScheaCon.hpp
ndb/test/ndbapi/telco/msa.cpp:
  This test program uses old NdbScheaCon.hpp
ndb/test/ndbapi/testDataBuffers/testDataBuffers.cpp:
  This test program uses old NdbScheaCon.hpp
ndb/test/ndbapi/testNdbApi/testNdbApi.cpp:
  Remove AttrType.hpp
  Define max number of Ndb objects test should "try" to create.
ndb/test/ndbapi/testRestartGci/testRestartGci.cpp:
  Moved "internal" datatypes to corresponding class, in this case Ndb class
ndb/test/src/NDBT_ResultRow.cpp:
  This test program uses old NdbScheaCon.hpp
  But should soon use "printer" from NdbRecAttr
ndb/test/src/NDBT_Table.cpp:
  Print table info more SQL like
ndb/test/src/UtilTransactions.cpp:
  When AttrType.hpp, this hidden bug was discovered. Using wrong enum types in switch.
ndb/tools/desc/desc.cpp:
  Alos print info about indexes for a table
parent c7bd561c
...@@ -50,7 +50,6 @@ include/mgmapi/mgmapi.h ...@@ -50,7 +50,6 @@ include/mgmapi/mgmapi.h
include/mgmapi/mgmapi_debug.h include/mgmapi/mgmapi_debug.h
include/ndbapi/ include/ndbapi/
include/ndbapi/ndbapi_limits.h include/ndbapi/ndbapi_limits.h
include/ndbapi/AttrType.hpp
include/ndbapi/Ndb.hpp include/ndbapi/Ndb.hpp
include/ndbapi/NdbApi.hpp include/ndbapi/NdbApi.hpp
include/ndbapi/NdbConnection.hpp include/ndbapi/NdbConnection.hpp
......
...@@ -860,7 +860,6 @@ ...@@ -860,7 +860,6 @@
#include <ndb_types.h> #include <ndb_types.h>
#include <ndbapi_limits.h> #include <ndbapi_limits.h>
#include <AttrType.hpp>
#include <NdbError.hpp> #include <NdbError.hpp>
#include <NdbDictionary.hpp> #include <NdbDictionary.hpp>
...@@ -870,8 +869,6 @@ class NdbEventOperationImpl; ...@@ -870,8 +869,6 @@ class NdbEventOperationImpl;
class NdbScanOperation; class NdbScanOperation;
class NdbIndexOperation; class NdbIndexOperation;
class NdbConnection; class NdbConnection;
class NdbSchemaOp;
class NdbSchemaCon;
class NdbApiSignal; class NdbApiSignal;
class NdbRecAttr; class NdbRecAttr;
class NdbLabel; class NdbLabel;
...@@ -961,8 +958,6 @@ class Ndb ...@@ -961,8 +958,6 @@ class Ndb
friend class NdbOperation; friend class NdbOperation;
friend class NdbEventOperationImpl; friend class NdbEventOperationImpl;
friend class NdbConnection; friend class NdbConnection;
friend class NdbSchemaOp;
friend class NdbSchemaCon;
friend class Table; friend class Table;
friend class NdbApiSignal; friend class NdbApiSignal;
friend class NdbScanReceiver; friend class NdbScanReceiver;
...@@ -1064,8 +1059,6 @@ public: ...@@ -1064,8 +1059,6 @@ public:
* A value larger than 1024 will be downgraded to 1024. * A value larger than 1024 will be downgraded to 1024.
* This means that one Ndb object can handle at most 1024 parallel * This means that one Ndb object can handle at most 1024 parallel
* transactions. * transactions.
* There is a maximum of 128 simultaneous
* Ndb object within one application process.
* @return 0 if successful, -1 otherwise. * @return 0 if successful, -1 otherwise.
* *
* @note The internal implementation multiplies this value * @note The internal implementation multiplies this value
...@@ -1245,22 +1238,6 @@ public: ...@@ -1245,22 +1238,6 @@ public:
*/ */
void closeTransaction(NdbConnection* aConnection); void closeTransaction(NdbConnection* aConnection);
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
/**
* To create a table it is necessary to obtain a schema transaction
* object.
* All schema transactions need to closed when they are
* completed.
*
* @return NdbSchemaCon
*/
NdbSchemaCon* startSchemaTransaction();
/**
* Close schema transaction when finished.
*/
void closeSchemaTransaction(NdbSchemaCon* aSchemaCon);
#endif
/** @} *********************************************************************/ /** @} *********************************************************************/
...@@ -1391,6 +1368,20 @@ public: ...@@ -1391,6 +1368,20 @@ public:
/** @} *********************************************************************/ /** @} *********************************************************************/
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
/**
* Different types of tampering with the NDB Cluster.
* <b>Only for debugging purposes only.</b>
*/
enum TamperType {
LockGlbChp = 1, ///< Lock GCP
UnlockGlbChp, ///< Unlock GCP
CrashNode, ///< Crash an NDB node
ReadRestartGCI, ///< Request the restart GCI id from NDB Cluster
InsertError ///< Execute an error in NDB Cluster
///< (may crash system)
};
/** /**
* For testing purposes it is possible to tamper with the NDB Cluster * For testing purposes it is possible to tamper with the NDB Cluster
* (i.e. send a special signal to DBDIH, the NDB distribution handler). * (i.e. send a special signal to DBDIH, the NDB distribution handler).
...@@ -1398,14 +1389,7 @@ public: ...@@ -1398,14 +1389,7 @@ public:
* In a release versions of NDB Cluster, * In a release versions of NDB Cluster,
* this call always return -1 and does nothing. * this call always return -1 and does nothing.
* *
* @param aAction Action to be taken * @param aAction Action to be taken according to TamperType above
* - 1: Lock global checkpointing
* (Can only be sent to master DIH,
* Parameter aNode ignored).
* - 2: UnLock global checkpointing
* (Can only be sent to master DIH,
* Parameter aNode ignored).
* - 3: Crash node.
* *
* @param aNode Which node the action will be taken * @param aNode Which node the action will be taken
* -1: Master DIH. * -1: Master DIH.
...@@ -1616,9 +1600,6 @@ private: ...@@ -1616,9 +1600,6 @@ private:
NdbScanOperation* theScanOpIdleList; // First scan operation in the idle list. NdbScanOperation* theScanOpIdleList; // First scan operation in the idle list.
NdbIndexOperation* theIndexOpIdleList; // First index operation in the idle list. NdbIndexOperation* theIndexOpIdleList; // First index operation in the idle list.
NdbSchemaCon* theSchemaConIdleList; // First schemaCon in idle list.
NdbSchemaCon* theSchemaConToNdbList; // Connected schemaCon object.
NdbConnection* theTransactionList; NdbConnection* theTransactionList;
NdbConnection** theConnectionArray; NdbConnection** theConnectionArray;
NdbRecAttr* theRecAttrIdleList; NdbRecAttr* theRecAttrIdleList;
...@@ -1649,7 +1630,14 @@ private: ...@@ -1649,7 +1630,14 @@ private:
NdbError theError; NdbError theError;
Int32 theNdbBlockNumber; Int32 theNdbBlockNumber;
InitType theInitState;
enum InitType {
NotConstructed,
NotInitialised,
StartingInit,
Initialised,
InitConfigError
} theInitState;
// Ensure good distribution of connects // Ensure good distribution of connects
Uint32 theCurrentConnectIndex; Uint32 theCurrentConnectIndex;
......
...@@ -17,14 +17,12 @@ ...@@ -17,14 +17,12 @@
#ifndef NdbApi_H #ifndef NdbApi_H
#define NdbApi_H #define NdbApi_H
#include "ndbapi_limits.h"
#include "Ndb.hpp" #include "Ndb.hpp"
#include "AttrType.hpp"
#include "NdbConnection.hpp" #include "NdbConnection.hpp"
#include "NdbOperation.hpp" #include "NdbOperation.hpp"
#include "NdbScanOperation.hpp" #include "NdbScanOperation.hpp"
#include "NdbIndexOperation.hpp" #include "NdbIndexOperation.hpp"
#include "NdbSchemaCon.hpp"
#include "NdbSchemaOp.hpp"
#include "NdbRecAttr.hpp" #include "NdbRecAttr.hpp"
#include "NdbResultSet.hpp" #include "NdbResultSet.hpp"
#include "NdbDictionary.hpp" #include "NdbDictionary.hpp"
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#define NdbConnection_H #define NdbConnection_H
#include <ndb_types.h> #include <ndb_types.h>
#include <AttrType.hpp>
#include <NdbError.hpp> #include <NdbError.hpp>
class NdbConnection; class NdbConnection;
...@@ -40,6 +39,35 @@ class NdbScanReceiver; ...@@ -40,6 +39,35 @@ class NdbScanReceiver;
*/ */
typedef void (* NdbAsynchCallback)(int, NdbConnection*, void*); typedef void (* NdbAsynchCallback)(int, NdbConnection*, void*);
/**
* Commit type of transaction
*/
enum AbortOption {
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
CommitIfFailFree = 0,
CommitAsMuchAsPossible = 2, ///< Commit transaction with as many
TryCommit = 0, ///< <i>Missing explanation</i>
#endif
AbortOnError = 0, ///< Abort transaction on failed operation
IgnoreError = 2 ///< Transaction continues on failed operation
};
typedef AbortOption CommitType;
/**
* Execution type of transaction
*/
enum ExecType {
NoExecTypeDef = -1, ///< Erroneous type (Used for debugging only)
Prepare, ///< <i>Missing explanation</i>
NoCommit, ///< Execute the transaction as far as it has
///< been defined, but do not yet commit it
Commit, ///< Execute and try to commit the transaction
Rollback ///< Rollback transaction
};
/** /**
* @class NdbConnection * @class NdbConnection
* @brief Represents a transaction. * @brief Represents a transaction.
...@@ -419,6 +447,14 @@ public: ...@@ -419,6 +447,14 @@ public:
* @return The commit status of the transaction, i.e. one of * @return The commit status of the transaction, i.e. one of
* { NotStarted, Started, TimeOut, Committed, Aborted, NeedAbort } * { NotStarted, Started, TimeOut, Committed, Aborted, NeedAbort }
*/ */
enum CommitStatusType {
NotStarted, ///< Transaction not yet started
Started, ///< <i>Missing explanation</i>
Committed, ///< Transaction has been committed
Aborted, ///< Transaction has been aborted
NeedAbort ///< <i>Missing explanation</i>
};
CommitStatusType commitStatus(); CommitStatusType commitStatus();
/** @} *********************************************************************/ /** @} *********************************************************************/
...@@ -515,8 +551,17 @@ private: ...@@ -515,8 +551,17 @@ private:
Uint32 getBuddyConPtr(); // Gets Buddy Con Ptr Uint32 getBuddyConPtr(); // Gets Buddy Con Ptr
NdbConnection* next(); // Returns the next pointer NdbConnection* next(); // Returns the next pointer
void next(NdbConnection*); // Sets the next pointer void next(NdbConnection*); // Sets the next pointer
enum ConStatusType {
NotConnected,
Connecting,
Connected,
DisConnecting,
ConnectFailure
};
ConStatusType Status(); // Read the status information ConStatusType Status(); // Read the status information
void Status(ConStatusType); // Set the status information void Status(ConStatusType); // Set the status information
Uint32 get_send_size(); // Get size to send Uint32 get_send_size(); // Get size to send
void set_send_size(Uint32); // Set size to send; void set_send_size(Uint32); // Set size to send;
...@@ -595,6 +640,18 @@ private: ...@@ -595,6 +640,18 @@ private:
Uint32 theId; Uint32 theId;
// Keeps track of what the send method should do. // Keeps track of what the send method should do.
enum SendStatusType {
NotInit,
InitState,
sendOperations,
sendCompleted,
sendCOMMITstate,
sendABORT,
sendABORTfail,
sendTC_ROLLBACK,
sendTC_COMMIT,
sendTC_OP
};
SendStatusType theSendStatus; SendStatusType theSendStatus;
NdbAsynchCallback theCallbackFunction; // Pointer to the callback function NdbAsynchCallback theCallbackFunction; // Pointer to the callback function
void* theCallbackObject; // The callback object pointer void* theCallbackObject; // The callback object pointer
...@@ -628,12 +685,18 @@ private: ...@@ -628,12 +685,18 @@ private:
Uint64 theTransactionId; // theTransactionId of the transaction Uint64 theTransactionId; // theTransactionId of the transaction
Uint32 theGlobalCheckpointId; // The gloabl checkpoint identity of the transaction Uint32 theGlobalCheckpointId; // The gloabl checkpoint identity of the transaction
ConStatusType theStatus; // The status of the connection ConStatusType theStatus; // The status of the connection
enum CompletionStatus {
CompletionStatus theCompletionStatus; // The Completion status of the transaction NotCompleted,
CompletedSuccess,
CompletedFailure,
DefinitionFailure
} theCompletionStatus; // The Completion status of the transaction
CommitStatusType theCommitStatus; // The commit status of the transaction CommitStatusType theCommitStatus; // The commit status of the transaction
Uint32 theMagicNumber; // Magic Number to verify correct object Uint32 theMagicNumber; // Magic Number to verify correct object
Uint32 thePriority; // Transaction Priority Uint32 thePriority; // Transaction Priority
enum ReturnType { ReturnSuccess, ReturnFailure };
ReturnType theReturnStatus; // Did we have any read/update/delete failing ReturnType theReturnStatus; // Did we have any read/update/delete failing
// to find the tuple. // to find the tuple.
bool theTransactionIsStarted; bool theTransactionIsStarted;
...@@ -641,7 +704,12 @@ private: ...@@ -641,7 +704,12 @@ private:
bool theSimpleState; bool theSimpleState;
Uint8 m_abortOption; // Type of commit Uint8 m_abortOption; // Type of commit
ListState theListState; enum ListState {
NotInList,
InPreparedList,
InSendList,
InCompletedList
} theListState;
Uint32 theDBnode; // The database node we are connected to Uint32 theDBnode; // The database node we are connected to
Uint32 theNodeSequence; // The sequence no of the db node Uint32 theNodeSequence; // The sequence no of the db node
...@@ -830,7 +898,7 @@ Parameters: aStatus: The status. ...@@ -830,7 +898,7 @@ Parameters: aStatus: The status.
Remark: Sets Connect status. Remark: Sets Connect status.
******************************************************************************/ ******************************************************************************/
inline inline
ConStatusType NdbConnection::ConStatusType
NdbConnection::Status() NdbConnection::Status()
{ {
return theStatus; return theStatus;
...@@ -849,6 +917,7 @@ NdbConnection::Status( ConStatusType aStatus ) ...@@ -849,6 +917,7 @@ NdbConnection::Status( ConStatusType aStatus )
theStatus = aStatus; theStatus = aStatus;
} }
/****************************************************************************** /******************************************************************************
void setGCI(); void setGCI();
......
...@@ -184,7 +184,7 @@ private: ...@@ -184,7 +184,7 @@ private:
// Private attributes // Private attributes
NdbIndexImpl* m_theIndex; NdbIndexImpl* m_theIndex;
Uint32 m_theIndexDefined[MAXNROFTUPLEKEY][3]; Uint32 m_theIndexDefined[NDB_MAX_ATTRIBUTES_IN_INDEX][3];
Uint32 m_theIndexLen; // Length of the index in words Uint32 m_theIndexLen; // Length of the index in words
Uint32 m_theNoOfIndexDefined; // The number of index attributes Uint32 m_theNoOfIndexDefined; // The number of index attributes
}; };
......
...@@ -18,10 +18,9 @@ ...@@ -18,10 +18,9 @@
#define NdbOperation_H #define NdbOperation_H
#include <ndb_types.h> #include <ndb_types.h>
#include "ndbapi_limits.h"
#include <AttrType.hpp> #include "NdbError.hpp"
#include <NdbError.hpp> #include "NdbReceiver.hpp"
#include <NdbReceiver.hpp>
class Ndb; class Ndb;
class NdbApiSignal; class NdbApiSignal;
...@@ -835,6 +834,22 @@ public: ...@@ -835,6 +834,22 @@ public:
/** @} *********************************************************************/ /** @} *********************************************************************/
/**
* Type of operation
*/
enum OperationType {
ReadRequest = 0, ///< Read operation
UpdateRequest = 1, ///< Update Operation
InsertRequest = 2, ///< Insert Operation
DeleteRequest = 3, ///< Delete Operation
WriteRequest = 4, ///< Write Operation
ReadExclusive = 5, ///< Read exclusive
OpenScanRequest, ///< Scan Operation
OpenRangeScanRequest, ///< Range scan operation
NotDefined2, ///< Internal for debugging
NotDefined ///< Internal for debugging
};
protected: protected:
/****************************************************************************** /******************************************************************************
* These are the methods used to create and delete the NdbOperation objects. * These are the methods used to create and delete the NdbOperation objects.
...@@ -865,12 +880,28 @@ protected: ...@@ -865,12 +880,28 @@ protected:
NdbOperation* next(); // Get next pointer NdbOperation* next(); // Get next pointer
enum OperationStatus{
Init,
OperationDefined,
TupleKeyDefined,
GetValue,
SetValue,
ExecInterpretedValue,
SetValueInterpreted,
FinalGetValue,
SubroutineExec,
SubroutineEnd,
SetBound,
WaitResponse,
WaitCommitResponse,
Finished,
ReceiveFinished
};
OperationStatus Status(); // Read the status information OperationStatus Status(); // Read the status information
void Status(OperationStatus); // Set the status information void Status(OperationStatus); // Set the status information
OperationType RequestType();
void NdbCon(NdbConnection*); // Set reference to connection void NdbCon(NdbConnection*); // Set reference to connection
// object. // object.
...@@ -879,8 +910,6 @@ protected: ...@@ -879,8 +910,6 @@ protected:
// the operations object. // the operations object.
void setStartIndicator(); void setStartIndicator();
void setCommitIndicator(CommitType aCommitType);
/****************************************************************************** /******************************************************************************
* The methods below is the execution part of the NdbOperation * The methods below is the execution part of the NdbOperation
* class. This is where the NDB signals are sent and received. The * class. This is where the NDB signals are sent and received. The
...@@ -1013,16 +1042,11 @@ protected: ...@@ -1013,16 +1042,11 @@ protected:
Uint32 theCurrRecAI_Len; // The currently received length Uint32 theCurrRecAI_Len; // The currently received length
Uint32 theAI_ElementLen; // How many words long is this element Uint32 theAI_ElementLen; // How many words long is this element
Uint32* theCurrElemPtr; // The current pointer to the element Uint32* theCurrElemPtr; // The current pointer to the element
//Uint32 theTableId; // Table id.
//Uint32 theAccessTableId; // The id of table for initial access,
// changed by NdbIndexOperation
//Uint32 theSchemaVersion; // The schema version on the table.
class NdbTableImpl* m_currentTable; // The current table class NdbTableImpl* m_currentTable; // The current table
class NdbTableImpl* m_accessTable; class NdbTableImpl* m_accessTable;
// Set to TRUE when a tuple key attribute has been defined. // Set to TRUE when a tuple key attribute has been defined.
// A tuple key is allowed to consist of 64 attributes. Uint32 theTupleKeyDefined[NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY][3];
Uint32 theTupleKeyDefined[MAXNROFTUPLEKEY][3];
Uint32 theTotalNrOfKeyWordInSignal; // The total number of Uint32 theTotalNrOfKeyWordInSignal; // The total number of
// keyword in signal. // keyword in signal.
...@@ -1094,16 +1118,6 @@ NdbOperation::setStartIndicator() ...@@ -1094,16 +1118,6 @@ NdbOperation::setStartIndicator()
theStartIndicator = 1; theStartIndicator = 1;
} }
#if 0
inline
void
NdbOperation::setCommitIndicator(CommitType aTypeOfCommit)
{
theCommitIndicator = 1;
theCommitType = (Uint8)aTypeOfCommit;
}
#endif
inline inline
int int
NdbOperation::getNdbErrorLine() NdbOperation::getNdbErrorLine()
...@@ -1145,7 +1159,7 @@ Parameters: aStatus: The status. ...@@ -1145,7 +1159,7 @@ Parameters: aStatus: The status.
Remark: Sets Operation status. Remark: Sets Operation status.
******************************************************************************/ ******************************************************************************/
inline inline
OperationStatus NdbOperation::OperationStatus
NdbOperation::Status() NdbOperation::Status()
{ {
return theStatus; return theStatus;
...@@ -1178,18 +1192,6 @@ NdbOperation::NdbCon(NdbConnection* aNdbCon) ...@@ -1178,18 +1192,6 @@ NdbOperation::NdbCon(NdbConnection* aNdbCon)
theNdbCon = aNdbCon; theNdbCon = aNdbCon;
} }
/******************************************************************************
OperationType RequestType();
Remark: Return the request typ of the operation..
******************************************************************************/
inline
OperationType
NdbOperation::RequestType()
{
return theOperationType;
}
inline inline
int int
NdbOperation::equal(const char* anAttrName, Int32 aPar) NdbOperation::equal(const char* anAttrName, Int32 aPar)
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#define NdbRecAttr_H #define NdbRecAttr_H
#include <NdbDictionary.hpp> #include <NdbDictionary.hpp>
#include "AttrType.hpp"
class NdbOperation; class NdbOperation;
class AttrInfo; class AttrInfo;
...@@ -87,11 +86,9 @@ public: ...@@ -87,11 +86,9 @@ public:
const NdbDictionary::Column * getColumn() const; const NdbDictionary::Column * getColumn() const;
/** /**
* Get attribute type. * Get type of column
* * @return Data type of the column
* @return Type of attribute: { Signed, UnSigned, Float, String }
*/ */
AttrType attrType() const ;
NdbDictionary::Column::Type getType() const; NdbDictionary::Column::Type getType() const;
/** /**
...@@ -316,33 +313,6 @@ NdbRecAttr::attrSize() const { ...@@ -316,33 +313,6 @@ NdbRecAttr::attrSize() const {
} }
} }
inline
AttrType
NdbRecAttr::attrType() const {
switch(getType()){
case NdbDictionary::Column::Bigint:
case NdbDictionary::Column::Int:
return Signed;
case NdbDictionary::Column::Bigunsigned:
case NdbDictionary::Column::Unsigned:
return UnSigned;
case NdbDictionary::Column::Float:
case NdbDictionary::Column::Decimal:
case NdbDictionary::Column::Double:
return Float;
case NdbDictionary::Column::Char:
case NdbDictionary::Column::Varchar:
case NdbDictionary::Column::Binary:
case NdbDictionary::Column::Varbinary:
return String;
case NdbDictionary::Column::Datetime:
case NdbDictionary::Column::Timespec:
case NdbDictionary::Column::Undefined:
default:
return NoAttrTypeDef;
}
}
inline inline
Uint32 Uint32
NdbRecAttr::arraySize() const NdbRecAttr::arraySize() const
......
...@@ -16,15 +16,16 @@ ...@@ -16,15 +16,16 @@
#ifndef NdbSchemaCon_H #ifndef NdbSchemaCon_H
#define NdbSchemaCon_H #define NdbSchemaCon_H
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
#include <ndb_types.h> #include <ndb_types.h>
#include "AttrType.hpp"
#include "NdbError.hpp" #include "NdbError.hpp"
#include <NdbSchemaOp.hpp>
class NdbSchemaOp; class NdbSchemaOp;
class NdbApiSignal;
class Ndb; class Ndb;
class NdbApiSignal;
/** /**
* @class NdbSchemaCon * @class NdbSchemaCon
...@@ -44,6 +45,7 @@ class Ndb; ...@@ -44,6 +45,7 @@ class Ndb;
* into the database. * into the database.
* *
* @note Currently only one table can be added per transaction. * @note Currently only one table can be added per transaction.
* @note Depricated, use NdbDictionary
*/ */
class NdbSchemaCon class NdbSchemaCon
{ {
...@@ -51,6 +53,18 @@ friend class Ndb; ...@@ -51,6 +53,18 @@ friend class Ndb;
friend class NdbSchemaOp; friend class NdbSchemaOp;
public: public:
static
NdbSchemaCon* startSchemaTrans(Ndb* pNdb){
return new NdbSchemaCon(pNdb);
}
static
void closeSchemaTrans(NdbSchemaCon* pSchCon){
delete pSchCon;
}
/** /**
* Execute a schema transaction. * Execute a schema transaction.
* *
...@@ -75,6 +89,7 @@ public: ...@@ -75,6 +89,7 @@ public:
const NdbError & getNdbError() const; const NdbError & getNdbError() const;
private: private:
/****************************************************************************** /******************************************************************************
* These are the create and delete methods of this class. * These are the create and delete methods of this class.
*****************************************************************************/ *****************************************************************************/
...@@ -85,8 +100,6 @@ private: ...@@ -85,8 +100,6 @@ private:
/****************************************************************************** /******************************************************************************
* These are the private methods of this class. * These are the private methods of this class.
*****************************************************************************/ *****************************************************************************/
void init(); // Initialise connection object for new
// transaction.
void release(); // Release all schemaop in schemaCon void release(); // Release all schemaop in schemaCon
...@@ -105,7 +118,6 @@ private: ...@@ -105,7 +118,6 @@ private:
int receiveDROP_INDX_REF(NdbApiSignal*); int receiveDROP_INDX_REF(NdbApiSignal*);
/***************************************************************************** /*****************************************************************************
* These are the private variables of this class. * These are the private variables of this class.
*****************************************************************************/ *****************************************************************************/
...@@ -126,6 +138,9 @@ NdbSchemaCon::checkMagicNumber() ...@@ -126,6 +138,9 @@ NdbSchemaCon::checkMagicNumber()
return -1; return -1;
return 0; return 0;
}//NdbSchemaCon::checkMagicNumber() }//NdbSchemaCon::checkMagicNumber()
#endif #endif
#endif #endif
......
...@@ -16,15 +16,127 @@ ...@@ -16,15 +16,127 @@
#ifndef NdbSchemaOp_H #ifndef NdbSchemaOp_H
#define NdbSchemaOp_H #define NdbSchemaOp_H
#include <NdbDictionary.hpp>
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
#include "NdbDictionary.hpp" /**
#include "AttrType.hpp" * Type of attribute
#include "NdbSchemaCon.hpp" *
* NOTE! AttrType is deprecated, use NdbDictionary::Column::Type instead!
*/
enum AttrType {
Signed, ///< Attributes of this type can be read with:
///< NdbRecAttr::int64_value,
///< NdbRecAttr::int32_value,
///< NdbRecAttr::short_value,
///< NdbRecAttr::char_value
UnSigned, ///< Attributes of this type can be read with:
///< NdbRecAttr::u_64_value,
///< NdbRecAttr::u_32_value,
///< NdbRecAttr::u_short_value,
///< NdbRecAttr::u_char_value
Float, ///< Attributes of this type can be read with:
///< NdbRecAttr::float_value and
///< NdbRecAttr::double_value
String, ///< Attributes of this type can be read with:
///< NdbRecAttr::aRef,
///< NdbRecAttr::getAttributeObject
NoAttrTypeDef ///< Used for debugging only
};
/**
* @deprecated
*/
enum NullAttributeType {
NoNullTypeDefined = -1,
NotNullAttribute,
NullAttribute,
AttributeDefined
};
/**
* Indicates whether the attribute is part of a primary key or not
*/
enum KeyType {
Undefined = -1, ///< Used for debugging only
NoKey, ///< Attribute is not part of primary key
///< or tuple identity
TupleKey, ///< Attribute is part of primary key
TupleId ///< Attribute is part of tuple identity
///< (This type of attribute is created
///< internally, and should not be
///< manually created.)
};
/**
* Indicate whether the attribute should be stored on disk or not
*/
enum StorageMode {
MMBased = 0, ///< Main memory
DiskBased = 1, ///< Disk (Not yet supported.)
NoStorageTypeDef ///< Used for debugging only
};
/**
* Where attribute is stored.
*
* This is used to indicate whether a primary key
* should only be stored in the index storage and not in the data storage
* or if it should be stored in both places.
* The first alternative makes the attribute take less space,
* but makes it impossible to scan using attribute.
*
* @note Use NormalStorageAttribute for most cases.
* (IndexStorageAttribute should only be used on primary key
* attributes and only if you do not want to scan using the attribute.)
*/
enum StorageAttributeType {
NoStorageAttributeTypeDefined = -1, ///< <i>Missing explanation</i>
IndexStorageAttribute, ///< Attribute is only stored in
///< index storage (ACC)
NormalStorageAttribute ///< Attribute values are stored
///< both in the index (ACC) and
///< in the data storage (TUP)
};
/**
* Type of fragmentation used for a table
*/
enum FragmentType {
Default = 0, ///< (All is default!)
Single = 1, ///< Only one fragment
All = 2, ///< Default value. One fragment per node group
DistributionGroup = 3, ///< Distribution Group used for fragmentation.
///< One fragment per node group
DistributionKey = 4, ///< Distribution Key used for fragmentation.
///< One fragment per node group.
AllLarge = 5, ///< Sixten fragments per node group.
DGroupLarge = 6, ///< Distribution Group used for fragmentation.
///< Sixten fragments per node group
DKeyLarge = 7 ///< Distribution Key used for fragmentation.
///< Sixten fragments per node group
};
class NdbApiSignal; /**
* Type of table or index.
*/
enum TableType {
UndefTableType = 0,
SystemTable = 1, ///< Internal.Table cannot be updated by user
UserTable = 2, ///< Normal application table
UniqueHashIndex = 3, ///< Unique un-ordered hash index
HashIndex = 4, ///< Non-unique un-ordered hash index
UniqueOrderedIndex = 5, ///< Unique ordered index
OrderedIndex = 6 ///< Non-unique ordered index
};
class NdbSchemaCon;
class Ndb; class Ndb;
/** /**
* @class NdbSchemaOp * @class NdbSchemaOp
* @brief Represents various operations for use in schema transactions * @brief Represents various operations for use in schema transactions
...@@ -43,6 +155,8 @@ class NdbSchemaOp ...@@ -43,6 +155,8 @@ class NdbSchemaOp
friend class NdbSchemaCon; friend class NdbSchemaCon;
public: public:
/** /**
* Create a new table in the database. * Create a new table in the database.
* *
...@@ -184,7 +298,6 @@ public: ...@@ -184,7 +298,6 @@ public:
int aMemoryType = 1, int aMemoryType = 1,
bool aStoredTable = true); bool aStoredTable = true);
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
/** /**
* This is the old function declaration, don't use. * This is the old function declaration, don't use.
* *
...@@ -211,7 +324,6 @@ public: ...@@ -211,7 +324,6 @@ public:
aMemoryType, aMemoryType,
(aStoredTable == 1 ? true : false)); (aStoredTable == 1 ? true : false));
} }
#endif
/** /**
* Add a new attribute to a database table. * Add a new attribute to a database table.
...@@ -367,7 +479,6 @@ public: ...@@ -367,7 +479,6 @@ public:
bool aAutoIncrement = false, bool aAutoIncrement = false,
const char* aDefaultValue = 0); const char* aDefaultValue = 0);
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
/** /**
* @deprecated do not use! * @deprecated do not use!
*/ */
...@@ -394,18 +505,7 @@ public: ...@@ -394,18 +505,7 @@ public:
aDistributionGroup, aDistributionGroup,
aDistributionGroupNoOfBits); aDistributionGroupNoOfBits);
} }
#endif
/**
* Get the last error which occurred during the transaction.
*
* If an error occured (NdbSchemaCon::execute returned -1 or
* NdbSchemaCon::getNdbSchemaOp returned NULL), then this method
* retrieves the error object containing information about
* the error.
*
* @return Error object containing information about last error.
*/
const NdbError & getNdbError() const; const NdbError & getNdbError() const;
protected: protected:
...@@ -440,17 +540,48 @@ protected: ...@@ -440,17 +540,48 @@ protected:
Ndb* theNdb; // Point back to the Ndb object. Ndb* theNdb; // Point back to the Ndb object.
NdbSchemaCon* theSchemaCon; // Point back to the connection object. NdbSchemaCon* theSchemaCon; // Point back to the connection object.
class NdbDictionary::Table * m_currentTable; class NdbDictionary::Table * m_currentTable;
}; };
/**
* Get old attribute type from new type
*
* NOTE! attrType is deprecated, use getType instead!
*
* @return Type of attribute: { Signed, UnSigned, Float,a String }
*/
inline inline
const NdbError & AttrType
NdbSchemaOp::getNdbError() const convertColumnTypeToAttrType(NdbDictionary::Column::Type _type)
{ {
return theSchemaCon->getNdbError();
}
switch(_type){
case NdbDictionary::Column::Bigint:
case NdbDictionary::Column::Int:
return Signed;
case NdbDictionary::Column::Bigunsigned:
case NdbDictionary::Column::Unsigned:
return UnSigned;
case NdbDictionary::Column::Float:
case NdbDictionary::Column::Decimal:
case NdbDictionary::Column::Double:
return Float;
case NdbDictionary::Column::Char:
case NdbDictionary::Column::Varchar:
case NdbDictionary::Column::Binary:
case NdbDictionary::Column::Varbinary:
return String;
case NdbDictionary::Column::Datetime:
case NdbDictionary::Column::Timespec:
case NdbDictionary::Column::Undefined:
default:
return NoAttrTypeDef;
}
}
#endif #endif
#endif #endif
...@@ -18,29 +18,16 @@ ...@@ -18,29 +18,16 @@
#define NDBAPI_LIMITS_H #define NDBAPI_LIMITS_H
#define NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY 32 #define NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY 32
#define NDB_MAX_TABLES 1600 #define NDB_MAX_ATTRIBUTES_IN_INDEX NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY
#define NDB_MAX_DATABASE_NAME_SIZE 128 #define NDB_MAX_DATABASE_NAME_SIZE 128
#define NDB_MAX_SCHEMA_NAME_SIZE 128 #define NDB_MAX_SCHEMA_NAME_SIZE 128
#define NDB_MAX_TAB_NAME_SIZE 128 #define NDB_MAX_TAB_NAME_SIZE 128
#define NDB_MAX_ATTR_NAME_SIZE 32
#define NDB_MAX_ATTR_DEFAULT_VALUE_SIZE 128
#define NDB_MAX_ATTRIBUTES_IN_TABLE 91 #define NDB_MAX_ATTRIBUTES_IN_TABLE 91
#define NDB_MAX_ATTRIBUTES_IN_INDEX NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY
#define NDB_MAX_TUPLE_SIZE_IN_WORDS 1023 #define NDB_MAX_TUPLE_SIZE_IN_WORDS 1023
#define NDB_MAX_FIXED_KEY_LENGTH_IN_WORDS 8
#define NDB_MAX_KEYSIZE_IN_WORDS 1023 #define NDB_MAX_KEYSIZE_IN_WORDS 1023
#define NDB_MAX_KEY_SIZE NDB_MAX_KEYSIZE_IN_WORDS*sizeof(Uint32) #define NDB_MAX_KEY_SIZE NDB_MAX_KEYSIZE_IN_WORDS*sizeof(Uint32)
#define NDB_MAX_TUPLE_SIZE 8191 #define NDB_MAX_TUPLE_SIZE NDB_MAX_TUPLE_SIZE_IN_WORDS*sizeof(uint32)
#define NDB_MAX_TRANSACTIONS 1024
#define NDB_MAX_PARALLEL_SCANS 12
#define NDB_MAX_ACTIVE_EVENTS 100 #define NDB_MAX_ACTIVE_EVENTS 100
#ifndef MIN
#define MIN(x,y) (((x)<(y))?(x):(y))
#endif
#ifndef MAX
#define MAX(x,y) (((x)>(y))?(x):(y))
#endif
#endif #endif
...@@ -10,7 +10,6 @@ DIRS := \ ...@@ -10,7 +10,6 @@ DIRS := \
rep \ rep \
mgmclient \ mgmclient \
cw \ cw \
newtonapi \
ndbbaseclient ndbbaseclient
ifneq ($(NDB_ODBC),N) ifneq ($(NDB_ODBC),N)
DIRS += ndbclient DIRS += ndbclient
......
...@@ -20,9 +20,7 @@ ...@@ -20,9 +20,7 @@
#include <ndb_global.h> #include <ndb_global.h>
#include <BackupFormat.hpp> #include <BackupFormat.hpp>
#include <NdbApi.hpp> #include <NdbApi.hpp>
#include <AttrType.hpp> #include <NdbSchemaCon.hpp>
#include <NdbOut.hpp>
#include "myVector.hpp" #include "myVector.hpp"
#include <ndb_version.h> #include <ndb_version.h>
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
#ifdef USE_MYSQL #ifdef USE_MYSQL
#include <mysql.h> #include <mysql.h>
#endif #endif
#include <NdbOut.hpp>
NdbOut& operator<<(NdbOut& ndbout, const TupleS& tuple); NdbOut& operator<<(NdbOut& ndbout, const TupleS& tuple);
NdbOut& operator<<(NdbOut& ndbout, const LogEntry& logEntry); NdbOut& operator<<(NdbOut& ndbout, const LogEntry& logEntry);
NdbOut& operator<<(NdbOut& ndbout, const RestoreMetaData &); NdbOut& operator<<(NdbOut& ndbout, const RestoreMetaData &);
...@@ -606,7 +609,7 @@ operator<<(NdbOut& ndbout, const AttributeS& attr){ ...@@ -606,7 +609,7 @@ operator<<(NdbOut& ndbout, const AttributeS& attr){
break; break;
} // switch size } // switch size
break; break;
case (String): case String:
if (desc.size == 8){ if (desc.size == 8){
NdbDictionary::Column::Type type = desc.m_table->m_dictTable->getColumn(desc.attrId)->getType(); NdbDictionary::Column::Type type = desc.m_table->m_dictTable->getColumn(desc.attrId)->getType();
if(type == NdbDictionary::Column::Varchar){ if(type == NdbDictionary::Column::Varchar){
...@@ -622,7 +625,7 @@ operator<<(NdbOut& ndbout, const AttributeS& attr){ ...@@ -622,7 +625,7 @@ operator<<(NdbOut& ndbout, const AttributeS& attr){
} }
j = desc.arraySize; j = desc.arraySize;
break; break;
case (Float): case Float:
// Not yet supported to print float // Not yet supported to print float
ndbout << "float"; ndbout << "float";
break; break;
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "MgmtErrorReporter.hpp" #include "MgmtErrorReporter.hpp"
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include <AttrType.hpp>
#include <NdbApiSignal.hpp> #include <NdbApiSignal.hpp>
#include <kernel_types.h> #include <kernel_types.h>
#include <RefConvert.hpp> #include <RefConvert.hpp>
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "TransporterFacade.hpp" #include "TransporterFacade.hpp"
#include "ClusterMgr.hpp" #include "ClusterMgr.hpp"
#include <IPCConfig.hpp> #include <IPCConfig.hpp>
#include "AttrType.hpp"
#include "NdbApiSignal.hpp" #include "NdbApiSignal.hpp"
#include "API.hpp" #include "API.hpp"
#include <NdbSleep.h> #include <NdbSleep.h>
......
...@@ -26,8 +26,6 @@ Name: Ndb.cpp ...@@ -26,8 +26,6 @@ Name: Ndb.cpp
#include "NdbApiSignal.hpp" #include "NdbApiSignal.hpp"
#include "NdbImpl.hpp" #include "NdbImpl.hpp"
#include "NdbSchemaOp.hpp"
#include "NdbSchemaCon.hpp"
#include <NdbOperation.hpp> #include <NdbOperation.hpp>
#include <NdbConnection.hpp> #include <NdbConnection.hpp>
#include <NdbEventOperation.hpp> #include <NdbEventOperation.hpp>
...@@ -155,7 +153,7 @@ Ndb::NDB_connect(Uint32 tNode) ...@@ -155,7 +153,7 @@ Ndb::NDB_connect(Uint32 tNode)
// Set connection pointer as NdbConnection object // Set connection pointer as NdbConnection object
//************************************************ //************************************************
tSignal->setData(theMyRef, 2); // Set my block reference tSignal->setData(theMyRef, 2); // Set my block reference
tNdbCon->Status(Connecting); // Set status to connecting tNdbCon->Status(NdbConnection::Connecting); // Set status to connecting
Uint32 nodeSequence; Uint32 nodeSequence;
{ // send and receive signal { // send and receive signal
tp->lock_mutex(); tp->lock_mutex();
...@@ -178,7 +176,7 @@ Ndb::NDB_connect(Uint32 tNode) ...@@ -178,7 +176,7 @@ Ndb::NDB_connect(Uint32 tNode)
}//if }//if
} }
if ((tReturnCode == 0) && (tNdbCon->Status() == Connected)) { if ((tReturnCode == 0) && (tNdbCon->Status() == NdbConnection::Connected)) {
//************************************************ //************************************************
// Send and receive was successful // Send and receive was successful
//************************************************ //************************************************
...@@ -434,7 +432,7 @@ Ndb::startTransactionLocal(Uint32 aPriority, Uint32 nodeId) ...@@ -434,7 +432,7 @@ Ndb::startTransactionLocal(Uint32 aPriority, Uint32 nodeId)
theFirstTransId = tFirstTransId + 1; theFirstTransId = tFirstTransId + 1;
}//if }//if
#ifdef VM_TRACE #ifdef VM_TRACE
if (tConnection->theListState != NotInList) { if (tConnection->theListState != NdbConnection::NotInList) {
printState("startTransactionLocal %x", tConnection); printState("startTransactionLocal %x", tConnection);
abort(); abort();
} }
...@@ -589,7 +587,7 @@ Ndb::NdbTamper(TamperType aAction, int aNode) ...@@ -589,7 +587,7 @@ Ndb::NdbTamper(TamperType aAction, int aNode)
tSignal.setData (tAction, 1); tSignal.setData (tAction, 1);
tSignal.setData(tNdbConn->ptr2int(),2); tSignal.setData(tNdbConn->ptr2int(),2);
tSignal.setData(theMyRef,3); // Set return block reference tSignal.setData(theMyRef,3); // Set return block reference
tNdbConn->Status(Connecting); // Set status to connecting tNdbConn->Status(NdbConnection::Connecting); // Set status to connecting
TransporterFacade *tp = TransporterFacade::instance(); TransporterFacade *tp = TransporterFacade::instance();
if (tAction == 3) { if (tAction == 3) {
tp->lock_mutex(); tp->lock_mutex();
...@@ -622,7 +620,7 @@ Ndb::NdbTamper(TamperType aAction, int aNode) ...@@ -622,7 +620,7 @@ Ndb::NdbTamper(TamperType aAction, int aNode)
}//if }//if
ret_code = sendRecSignal(tNode, WAIT_NDB_TAMPER, &tSignal, 0); ret_code = sendRecSignal(tNode, WAIT_NDB_TAMPER, &tSignal, 0);
if (ret_code == 0) { if (ret_code == 0) {
if (tNdbConn->Status() != Connected) { if (tNdbConn->Status() != NdbConnection::Connected) {
theRestartGCI = 0; theRestartGCI = 0;
}//if }//if
releaseNdbCon(tNdbConn); releaseNdbCon(tNdbConn);
...@@ -637,6 +635,7 @@ Ndb::NdbTamper(TamperType aAction, int aNode) ...@@ -637,6 +635,7 @@ Ndb::NdbTamper(TamperType aAction, int aNode)
return 0; return 0;
#endif #endif
} }
#if 0
/**************************************************************************** /****************************************************************************
NdbSchemaCon* startSchemaTransaction(); NdbSchemaCon* startSchemaTransaction();
...@@ -678,7 +677,7 @@ Ndb::closeSchemaTransaction(NdbSchemaCon* aSchemaCon) ...@@ -678,7 +677,7 @@ Ndb::closeSchemaTransaction(NdbSchemaCon* aSchemaCon)
theSchemaConToNdbList = NULL; theSchemaConToNdbList = NULL;
return; return;
}//Ndb::closeSchemaTransaction() }//Ndb::closeSchemaTransaction()
#endif
/***************************************************************************** /*****************************************************************************
void RestartGCI(int aRestartGCI); void RestartGCI(int aRestartGCI);
......
...@@ -29,7 +29,6 @@ Adjust: 971114 UABMNST First version. ...@@ -29,7 +29,6 @@ Adjust: 971114 UABMNST First version.
******************************************************************************/ ******************************************************************************/
#include "API.hpp" #include "API.hpp"
#include "NdbApiSignal.hpp" #include "NdbApiSignal.hpp"
#include <AttrType.hpp>
/** /**
* The following include includes * The following include includes
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#define NdbApiSignal_H #define NdbApiSignal_H
#include <kernel_types.h> #include <kernel_types.h>
#include "AttrType.hpp"
#include "TransporterFacade.hpp" #include "TransporterFacade.hpp"
#include <TransporterDefinitions.hpp> #include <TransporterDefinitions.hpp>
#include "Ndb.hpp" #include "Ndb.hpp"
......
...@@ -1706,7 +1706,7 @@ NdbConnection::getTransactionId() ...@@ -1706,7 +1706,7 @@ NdbConnection::getTransactionId()
return theTransactionId; return theTransactionId;
}//NdbConnection::getTransactionId() }//NdbConnection::getTransactionId()
CommitStatusType NdbConnection::CommitStatusType
NdbConnection::commitStatus() NdbConnection::commitStatus()
{ {
return theCommitStatus; return theCommitStatus;
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "NdbDictionaryImpl.hpp" #include "NdbDictionaryImpl.hpp"
#include "API.hpp" #include "API.hpp"
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include <AttrType.hpp>
#include "NdbApiSignal.hpp" #include "NdbApiSignal.hpp"
#include "TransporterFacade.hpp" #include "TransporterFacade.hpp"
#include <signaldata/GetTabInfo.hpp> #include <signaldata/GetTabInfo.hpp>
...@@ -1257,7 +1256,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, ...@@ -1257,7 +1256,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
NdbTableImpl & impl, NdbTableImpl & impl,
bool alter) bool alter)
{ {
if((unsigned)impl.getNoOfPrimaryKeys() > MAXNROFTUPLEKEY){ if((unsigned)impl.getNoOfPrimaryKeys() > NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY){
m_error.code = 4317; m_error.code = 4317;
return -1; return -1;
} }
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "NdbDictionaryImpl.hpp" #include "NdbDictionaryImpl.hpp"
#include "API.hpp" #include "API.hpp"
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include <AttrType.hpp>
#include "NdbApiSignal.hpp" #include "NdbApiSignal.hpp"
#include "TransporterFacade.hpp" #include "TransporterFacade.hpp"
#include <signaldata/CreateEvnt.hpp> #include <signaldata/CreateEvnt.hpp>
...@@ -489,52 +488,7 @@ NdbEventOperationImpl::getEventType() ...@@ -489,52 +488,7 @@ NdbEventOperationImpl::getEventType()
} }
} }
void
NdbEventOperationImpl::printRecAttr(NdbRecAttr *p)
{
int size = p->attrSize();
int aSize = p->arraySize();
switch(p->attrType()){
case UnSigned:
switch(size) {
case 8: ndbout << p->u_64_value(); break;
case 4: ndbout << p->u_32_value(); break;
case 2: ndbout << p->u_short_value(); break;
case 1: ndbout << (unsigned) p->u_char_value(); break;
default: ndbout << "Unknown size" << endl;
}
break;
case Signed:
switch(size) {
case 8: ndbout << p->int64_value(); break;
case 4: ndbout << p->int32_value(); break;
case 2: ndbout << p->short_value(); break;
case 1: ndbout << (int) p->char_value(); break;
default: ndbout << "Unknown size" << endl;
}
break;
case String:
{
char* buf = new char[aSize+1];
memcpy(buf, p->aRef(), aSize);
buf[aSize] = 0;
ndbout << buf;
delete [] buf;
}
break;
case Float:
ndbout << p->float_value();
break;
default:
ndbout << "Unknown";
break;
}
}
void void
NdbEventOperationImpl::print() NdbEventOperationImpl::print()
...@@ -1294,3 +1248,60 @@ NdbGlobalEventBuffer::real_wait(NdbGlobalEventBufferHandle *h, ...@@ -1294,3 +1248,60 @@ NdbGlobalEventBuffer::real_wait(NdbGlobalEventBufferHandle *h,
n += hasData(h->m_bufferIds[i]); n += hasData(h->m_bufferIds[i]);
return n; return n;
} }
/**
* TODO Change this function to use the real datatypes
* from NdbDictionary alternatively make a
* "printer" in NdbRecAttr that can be used from all programs
*/
// and remove this include
#include "NdbSchemaOp.hpp"
void
NdbEventOperationImpl::printRecAttr(NdbRecAttr *p)
{
int size = p->attrSize();
int aSize = p->arraySize();
switch(convertColumnTypeToAttrType(p->getType())){
case UnSigned:
switch(size) {
case 8: ndbout << p->u_64_value(); break;
case 4: ndbout << p->u_32_value(); break;
case 2: ndbout << p->u_short_value(); break;
case 1: ndbout << (unsigned) p->u_char_value(); break;
default: ndbout << "Unknown size" << endl;
}
break;
case Signed:
switch(size) {
case 8: ndbout << p->int64_value(); break;
case 4: ndbout << p->int32_value(); break;
case 2: ndbout << p->short_value(); break;
case 1: ndbout << (int) p->char_value(); break;
default: ndbout << "Unknown size" << endl;
}
break;
case String:
{
char* buf = new char[aSize+1];
memcpy(buf, p->aRef(), aSize);
buf[aSize] = 0;
ndbout << buf;
delete [] buf;
}
break;
case Float:
ndbout << p->float_value();
break;
default:
ndbout << "Unknown";
break;
}
}
...@@ -87,7 +87,7 @@ NdbIndexOperation::indxInit(NdbIndexImpl * anIndex, ...@@ -87,7 +87,7 @@ NdbIndexOperation::indxInit(NdbIndexImpl * anIndex,
m_accessTable = anIndex->m_table; m_accessTable = anIndex->m_table;
m_theIndexLen = 0; m_theIndexLen = 0;
m_theNoOfIndexDefined = 0; m_theNoOfIndexDefined = 0;
for (Uint32 i=0; i<MAXNROFTUPLEKEY; i++) for (Uint32 i=0; i<NDB_MAX_ATTRIBUTES_IN_INDEX; i++)
for (int j=0; j<3; j++) for (int j=0; j<3; j++)
m_theIndexDefined[i][j] = false; m_theIndexDefined[i][j] = false;
...@@ -221,7 +221,7 @@ int NdbIndexOperation::equal_impl(const NdbColumnImpl* tAttrInfo, ...@@ -221,7 +221,7 @@ int NdbIndexOperation::equal_impl(const NdbColumnImpl* tAttrInfo,
goto equal_error2; goto equal_error2;
}//if }//if
}//if }//if
} while (i < MAXNROFTUPLEKEY); } while (i < NDB_MAX_ATTRIBUTES_IN_INDEX);
goto equal_error2; goto equal_error2;
} else { } else {
goto equal_error1; goto equal_error1;
...@@ -695,7 +695,7 @@ NdbIndexOperation::receiveTCINDXREF( NdbApiSignal* aSignal) ...@@ -695,7 +695,7 @@ NdbIndexOperation::receiveTCINDXREF( NdbApiSignal* aSignal)
theStatus = Finished; theStatus = Finished;
theNdbCon->theReturnStatus = ReturnFailure; theNdbCon->theReturnStatus = NdbConnection::ReturnFailure;
//--------------------------------------------------------------------------// //--------------------------------------------------------------------------//
// If the transaction this operation belongs to consists only of simple reads // If the transaction this operation belongs to consists only of simple reads
// we set the error code on the transaction object. // we set the error code on the transaction object.
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include "NdbApiSignal.hpp" #include "NdbApiSignal.hpp"
#include "NdbRecAttr.hpp" #include "NdbRecAttr.hpp"
#include "NdbUtil.hpp" #include "NdbUtil.hpp"
#include "ndbapi_limits.h"
#include <signaldata/TcKeyReq.hpp> #include <signaldata/TcKeyReq.hpp>
#include "NdbDictionaryImpl.hpp" #include "NdbDictionaryImpl.hpp"
...@@ -163,7 +163,7 @@ NdbOperation::init(NdbTableImpl* tab, NdbConnection* myConnection){ ...@@ -163,7 +163,7 @@ NdbOperation::init(NdbTableImpl* tab, NdbConnection* myConnection){
m_currentTable = m_accessTable = tab; m_currentTable = m_accessTable = tab;
theNdbCon = myConnection; theNdbCon = myConnection;
for (Uint32 i=0; i<MAXNROFTUPLEKEY; i++) for (Uint32 i=0; i<NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY; i++)
for (int j=0; j<3; j++) for (int j=0; j<3; j++)
theTupleKeyDefined[i][j] = false; theTupleKeyDefined[i][j] = false;
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "NdbConnection.hpp" #include "NdbConnection.hpp"
#include "Ndb.hpp" #include "Ndb.hpp"
#include "NdbRecAttr.hpp" #include "NdbRecAttr.hpp"
#include "AttrType.hpp"
#include "NdbUtil.hpp" #include "NdbUtil.hpp"
#include "NdbOut.hpp" #include "NdbOut.hpp"
#include "NdbImpl.hpp" #include "NdbImpl.hpp"
......
...@@ -757,7 +757,7 @@ NdbOperation::receiveTCKEYREF( NdbApiSignal* aSignal) ...@@ -757,7 +757,7 @@ NdbOperation::receiveTCKEYREF( NdbApiSignal* aSignal)
theStatus = Finished; theStatus = Finished;
theNdbCon->theReturnStatus = ReturnFailure; theNdbCon->theReturnStatus = NdbConnection::ReturnFailure;
//-------------------------------------------------------------------------// //-------------------------------------------------------------------------//
// If the transaction this operation belongs to consists only of simple reads // If the transaction this operation belongs to consists only of simple reads
// we set the error code on the transaction object. // we set the error code on the transaction object.
......
...@@ -31,7 +31,6 @@ Adjust: 991029 UABRONM First version. ...@@ -31,7 +31,6 @@ Adjust: 991029 UABRONM First version.
#include "NdbConnection.hpp" #include "NdbConnection.hpp"
#include "Ndb.hpp" #include "Ndb.hpp"
#include "NdbRecAttr.hpp" #include "NdbRecAttr.hpp"
#include "AttrType.hpp"
#include "NdbUtil.hpp" #include "NdbUtil.hpp"
#include "Interpreter.hpp" #include "Interpreter.hpp"
...@@ -69,7 +68,7 @@ NdbOperation::incCheck(const NdbColumnImpl* tNdbColumnImpl) ...@@ -69,7 +68,7 @@ NdbOperation::incCheck(const NdbColumnImpl* tNdbColumnImpl)
} }
return tNdbColumnImpl->m_attrId; return tNdbColumnImpl->m_attrId;
} else { } else {
if (theNdbCon->theCommitStatus == Started) if (theNdbCon->theCommitStatus == NdbConnection::Started)
setErrorCodeAbort(4200); setErrorCodeAbort(4200);
} }
return -1; return -1;
...@@ -121,7 +120,7 @@ NdbOperation::write_attrCheck(const NdbColumnImpl* tNdbColumnImpl) ...@@ -121,7 +120,7 @@ NdbOperation::write_attrCheck(const NdbColumnImpl* tNdbColumnImpl)
} }
return tNdbColumnImpl->m_attrId; return tNdbColumnImpl->m_attrId;
} else { } else {
if (theNdbCon->theCommitStatus == Started) if (theNdbCon->theCommitStatus == NdbConnection::Started)
setErrorCodeAbort(4200); setErrorCodeAbort(4200);
} }
return -1; return -1;
...@@ -169,7 +168,7 @@ NdbOperation::read_attrCheck(const NdbColumnImpl* tNdbColumnImpl) ...@@ -169,7 +168,7 @@ NdbOperation::read_attrCheck(const NdbColumnImpl* tNdbColumnImpl)
} }
return tNdbColumnImpl->m_attrId; return tNdbColumnImpl->m_attrId;
} else { } else {
if (theNdbCon->theCommitStatus == Started) if (theNdbCon->theCommitStatus == NdbConnection::Started)
setErrorCodeAbort(4200); setErrorCodeAbort(4200);
} }
return -1; return -1;
...@@ -209,7 +208,7 @@ NdbOperation::initial_interpreterCheck() ...@@ -209,7 +208,7 @@ NdbOperation::initial_interpreterCheck()
} }
return 0; return 0;
} else { } else {
if (theNdbCon->theCommitStatus == Started) if (theNdbCon->theCommitStatus == NdbConnection::Started)
setErrorCodeAbort(4200); setErrorCodeAbort(4200);
} }
return -1; return -1;
...@@ -235,7 +234,7 @@ NdbOperation::labelCheck() ...@@ -235,7 +234,7 @@ NdbOperation::labelCheck()
} }
return 0; return 0;
} else { } else {
if (theNdbCon->theCommitStatus == Started) if (theNdbCon->theCommitStatus == NdbConnection::Started)
setErrorCodeAbort(4200); setErrorCodeAbort(4200);
} }
return -1; return -1;
...@@ -255,7 +254,7 @@ NdbOperation::intermediate_interpreterCheck() ...@@ -255,7 +254,7 @@ NdbOperation::intermediate_interpreterCheck()
} }
return 0; return 0;
} else { } else {
if (theNdbCon->theCommitStatus == Started) if (theNdbCon->theCommitStatus == NdbConnection::Started)
setErrorCodeAbort(4200); setErrorCodeAbort(4200);
} }
return -1; return -1;
......
...@@ -31,7 +31,7 @@ NdbOperation::openScanRead(Uint32 aParallelism) ...@@ -31,7 +31,7 @@ NdbOperation::openScanRead(Uint32 aParallelism)
{ {
aParallelism = checkParallelism(aParallelism); aParallelism = checkParallelism(aParallelism);
if ((theNdbCon->theCommitStatus != Started) && if ((theNdbCon->theCommitStatus != NdbConnection::Started) &&
(theStatus != Init) && (theStatus != Init) &&
(aParallelism == 0)) { (aParallelism == 0)) {
setErrorCode(4200); setErrorCode(4200);
...@@ -48,7 +48,7 @@ NdbOperation::openScanExclusive(Uint32 aParallelism) ...@@ -48,7 +48,7 @@ NdbOperation::openScanExclusive(Uint32 aParallelism)
{ {
aParallelism = checkParallelism(aParallelism); aParallelism = checkParallelism(aParallelism);
if ((theNdbCon->theCommitStatus != Started) && if ((theNdbCon->theCommitStatus != NdbConnection::Started) &&
(theStatus != Init) && (theStatus != Init) &&
(aParallelism == 0)) { (aParallelism == 0)) {
setErrorCode(4200); setErrorCode(4200);
...@@ -65,7 +65,7 @@ NdbOperation::openScanReadHoldLock(Uint32 aParallelism) ...@@ -65,7 +65,7 @@ NdbOperation::openScanReadHoldLock(Uint32 aParallelism)
{ {
aParallelism = checkParallelism(aParallelism); aParallelism = checkParallelism(aParallelism);
if ((theNdbCon->theCommitStatus != Started) && if ((theNdbCon->theCommitStatus != NdbConnection::Started) &&
(theStatus != Init) && (theStatus != Init) &&
(aParallelism == 0)) { (aParallelism == 0)) {
setErrorCode(4200); setErrorCode(4200);
...@@ -82,7 +82,7 @@ NdbOperation::openScanReadCommitted(Uint32 aParallelism) ...@@ -82,7 +82,7 @@ NdbOperation::openScanReadCommitted(Uint32 aParallelism)
{ {
aParallelism = checkParallelism(aParallelism); aParallelism = checkParallelism(aParallelism);
if ((theNdbCon->theCommitStatus != Started) && if ((theNdbCon->theCommitStatus != NdbConnection::Started) &&
(theStatus != Init) && (theStatus != Init) &&
(aParallelism == 0)) { (aParallelism == 0)) {
setErrorCode(4200); setErrorCode(4200);
......
...@@ -35,7 +35,6 @@ Adjust: 971022 UABMNST First version. ...@@ -35,7 +35,6 @@ Adjust: 971022 UABMNST First version.
#include <Ndb.hpp> #include <Ndb.hpp>
#include "NdbImpl.hpp" #include "NdbImpl.hpp"
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include "AttrType.hpp"
#include <AttributeHeader.hpp> #include <AttributeHeader.hpp>
#include <signaldata/TcKeyReq.hpp> #include <signaldata/TcKeyReq.hpp>
...@@ -102,7 +101,7 @@ NdbOperation::equal_impl(const NdbColumnImpl* tAttrInfo, ...@@ -102,7 +101,7 @@ NdbOperation::equal_impl(const NdbColumnImpl* tAttrInfo,
goto equal_error2; goto equal_error2;
}//if }//if
}//if }//if
} while (i < MAXNROFTUPLEKEY); } while (i < NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY);
goto equal_error2; goto equal_error2;
} else { } else {
goto equal_error1; goto equal_error1;
......
...@@ -61,7 +61,8 @@ NdbResultSet::updateTuple(){ ...@@ -61,7 +61,8 @@ NdbResultSet::updateTuple(){
} }
NdbScanOperation * op = (NdbScanOperation*)(m_operation); NdbScanOperation * op = (NdbScanOperation*)(m_operation);
return op->takeOverScanOp(UpdateRequest, op->m_transConnection); return op->takeOverScanOp(NdbOperation::UpdateRequest,
op->m_transConnection);
} }
NdbOperation* NdbOperation*
...@@ -71,7 +72,8 @@ NdbResultSet::updateTuple(NdbConnection* takeOverTrans){ ...@@ -71,7 +72,8 @@ NdbResultSet::updateTuple(NdbConnection* takeOverTrans){
return 0; return 0;
} }
return m_operation->takeOverScanOp(UpdateRequest, takeOverTrans); return m_operation->takeOverScanOp(NdbOperation::UpdateRequest,
takeOverTrans);
} }
int int
...@@ -82,7 +84,8 @@ NdbResultSet::deleteTuple(){ ...@@ -82,7 +84,8 @@ NdbResultSet::deleteTuple(){
} }
NdbScanOperation * op = (NdbScanOperation*)(m_operation); NdbScanOperation * op = (NdbScanOperation*)(m_operation);
void * res = op->takeOverScanOp(DeleteRequest, op->m_transConnection); void * res = op->takeOverScanOp(NdbOperation::DeleteRequest,
op->m_transConnection);
if(res == 0) if(res == 0)
return -1; return -1;
return 0; return 0;
...@@ -95,7 +98,8 @@ NdbResultSet::deleteTuple(NdbConnection * takeOverTrans){ ...@@ -95,7 +98,8 @@ NdbResultSet::deleteTuple(NdbConnection * takeOverTrans){
return 0; return 0;
} }
void * res = m_operation->takeOverScanOp(DeleteRequest, takeOverTrans); void * res = m_operation->takeOverScanOp(NdbOperation::DeleteRequest,
takeOverTrans);
if(res == 0) if(res == 0)
return -1; return -1;
return 0; return 0;
......
...@@ -14,28 +14,31 @@ ...@@ -14,28 +14,31 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/********************************************************************* /*********************************************************************
Name: NdbSchemaCon.C Name: NdbSchemaCon.cpp
Include: Include:
Link: Link:
Author: UABMNST Mona Natterkvist UAB/B/SD Author: UABMNST Mona Natterkvist UAB/B/SD
EMIKRON Mikael Ronstrom EMIKRON Mikael Ronstrom
Date: 020826 Date: 020826
Version: 2.0 Version: 3.0
Description: Interface between application and NDB Description: Old Interface between application and NDB
Documentation: Documentation:
Adjust: 980126 UABMNST First version. Adjust: 980126 UABMNST First version.
020826 EMIKRON New version adapted to new DICT version 020826 EMIKRON New version adapted to new DICT version
************************************************************************************************/ 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 "NdbSchemaCon.hpp" #include "NdbSchemaCon.hpp"
#include "NdbSchemaOp.hpp" #include "NdbSchemaOp.hpp"
#include "NdbApiSignal.hpp" #include "NdbApiSignal.hpp"
#include "TransporterFacade.hpp"
#include <RefConvert.hpp>
#include <signaldata/CreateIndx.hpp>
#include <signaldata/DropIndx.hpp>
#include <signaldata/CreateTable.hpp>
#include <NdbOut.hpp>
/********************************************************************* /*********************************************************************
NdbSchemaCon(Ndb* aNdb); NdbSchemaCon(Ndb* aNdb);
......
...@@ -16,24 +16,31 @@ ...@@ -16,24 +16,31 @@
/***************************************************************************** /*****************************************************************************
Name: NdbSchemaOp.C Name: NdbSchemaOp.cpp
Include: Include:
Link: Link:
Author: UABMNST Mona Natterkvist UAB/B/SD Author: UABMNST Mona Natterkvist UAB/B/SD
EMIKRON Mikael Ronstrom EMIKRON Mikael Ronstrom
Date: 020826 Date: 040524
Version: 2.0 Version: 3.0
Description: Interface between application and NDB Description: Interface between application and NDB
Documentation: Handles createTable and createAttribute calls Documentation: Handles createTable and createAttribute calls
Adjust: 980125 UABMNST First version. Adjust: 980125 UABMNST First version.
020826 EMIKRON New version for new DICT 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 <assert.h> #include <assert.h>
#include "NdbSchemaOp.hpp" #include "NdbSchemaOp.hpp"
#include "NdbSchemaCon.hpp" #include "NdbSchemaCon.hpp"
#include "API.hpp" #include "API.hpp"
/***************************************************************************** /*****************************************************************************
NdbSchemaOp(Ndb* aNdb, Table* aTable); NdbSchemaOp(Ndb* aNdb, Table* aTable);
...@@ -203,3 +210,11 @@ NdbSchemaOp::init(NdbSchemaCon* aSchemaCon) ...@@ -203,3 +210,11 @@ NdbSchemaOp::init(NdbSchemaCon* aSchemaCon)
theSchemaCon = aSchemaCon; theSchemaCon = aSchemaCon;
return 0; return 0;
}//NdbSchemaOp::init() }//NdbSchemaOp::init()
const NdbError &
NdbSchemaOp::getNdbError() const
{
return theSchemaCon->getNdbError();
}
...@@ -30,7 +30,6 @@ Comment: ...@@ -30,7 +30,6 @@ Comment:
#define NdbUtil_H #define NdbUtil_H
#include <ndb_global.h> #include <ndb_global.h>
#include "AttrType.hpp"
class NdbApiSignal; class NdbApiSignal;
class NdbOperation; class NdbOperation;
......
This diff is collapsed.
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
#include "NdbApiSignal.hpp" #include "NdbApiSignal.hpp"
#include "NdbImpl.hpp" #include "NdbImpl.hpp"
#include "NdbSchemaOp.hpp" //#include "NdbSchemaOp.hpp"
#include "NdbSchemaCon.hpp" //#include "NdbSchemaCon.hpp"
#include "NdbOperation.hpp" #include "NdbOperation.hpp"
#include "NdbConnection.hpp" #include "NdbConnection.hpp"
#include "NdbRecAttr.hpp" #include "NdbRecAttr.hpp"
...@@ -72,8 +72,8 @@ Ndb::Ndb( const char* aDataBase , const char* aDataBaseSchema) : ...@@ -72,8 +72,8 @@ Ndb::Ndb( const char* aDataBase , const char* aDataBaseSchema) :
theOpIdleList(NULL), theOpIdleList(NULL),
theScanOpIdleList(NULL), theScanOpIdleList(NULL),
theIndexOpIdleList(NULL), theIndexOpIdleList(NULL),
theSchemaConIdleList(NULL), // theSchemaConIdleList(NULL),
theSchemaConToNdbList(NULL), // theSchemaConToNdbList(NULL),
theTransactionList(NULL), theTransactionList(NULL),
theConnectionArray(NULL), theConnectionArray(NULL),
theRecAttrIdleList(NULL), theRecAttrIdleList(NULL),
...@@ -207,8 +207,8 @@ Ndb::~Ndb() ...@@ -207,8 +207,8 @@ Ndb::~Ndb()
NdbMutex_Unlock(&createNdbMutex); NdbMutex_Unlock(&createNdbMutex);
if (theSchemaConToNdbList != NULL) // if (theSchemaConToNdbList != NULL)
closeSchemaTransaction(theSchemaConToNdbList); // closeSchemaTransaction(theSchemaConToNdbList);
while ( theConIdleList != NULL ) while ( theConIdleList != NULL )
freeNdbCon(); freeNdbCon();
while ( theSignalIdleList != NULL ) while ( theSignalIdleList != NULL )
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include "Ndb.hpp" #include "Ndb.hpp"
#include "NdbSchemaOp.hpp" //#include "NdbSchemaOp.hpp"
#include "NdbSchemaCon.hpp" //#include "NdbSchemaCon.hpp"
#include "NdbOperation.hpp" #include "NdbOperation.hpp"
#include "NdbScanOperation.hpp" #include "NdbScanOperation.hpp"
#include "NdbIndexOperation.hpp" #include "NdbIndexOperation.hpp"
...@@ -104,7 +104,7 @@ Ndb::createConIdleList(int aNrOfCon) ...@@ -104,7 +104,7 @@ Ndb::createConIdleList(int aNrOfCon)
tNdbCon->next(theConIdleList); tNdbCon->next(theConIdleList);
theConIdleList = tNdbCon; theConIdleList = tNdbCon;
} }
tNdbCon->Status(NotConnected); tNdbCon->Status(NdbConnection::NotConnected);
} }
theNoOfAllocatedTransactions = aNrOfCon; theNoOfAllocatedTransactions = aNrOfCon;
return aNrOfCon; return aNrOfCon;
...@@ -770,7 +770,7 @@ Ndb::releaseConnectToNdb(NdbConnection* a_con) ...@@ -770,7 +770,7 @@ Ndb::releaseConnectToNdb(NdbConnection* a_con)
tSignal.setData((tConPtr = a_con->getTC_ConnectPtr()), 1); tSignal.setData((tConPtr = a_con->getTC_ConnectPtr()), 1);
tSignal.setData(theMyRef, 2); tSignal.setData(theMyRef, 2);
tSignal.setData(a_con->ptr2int(), 3); tSignal.setData(a_con->ptr2int(), 3);
a_con->Status(DisConnecting); a_con->Status(NdbConnection::DisConnecting);
a_con->theMagicNumber = 0x37412619; a_con->theMagicNumber = 0x37412619;
int ret_code = sendRecSignal(node_id, int ret_code = sendRecSignal(node_id,
WAIT_TC_RELEASE, WAIT_TC_RELEASE,
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <ndb_global.h> #include <ndb_global.h>
#include <ndb_limits.h> #include <ndb_limits.h>
#include <AttrType.hpp>
#include "TransporterFacade.hpp" #include "TransporterFacade.hpp"
#include "ClusterMgr.hpp" #include "ClusterMgr.hpp"
#include <IPCConfig.hpp> #include <IPCConfig.hpp>
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#ifndef TransporterFacade_H #ifndef TransporterFacade_H
#define TransporterFacade_H #define TransporterFacade_H
#include <AttrType.hpp>
#include <kernel_types.h> #include <kernel_types.h>
#include <ndb_limits.h> #include <ndb_limits.h>
#include <NdbThread.h> #include <NdbThread.h>
...@@ -43,6 +42,10 @@ extern "C" { ...@@ -43,6 +42,10 @@ extern "C" {
void atexit_stop_instance(); void atexit_stop_instance();
} }
/**
* Max number of Ndb objects in different threads.
* (Ndb objects should not be shared by different threads.)
*/
class TransporterFacade class TransporterFacade
{ {
public: public:
...@@ -156,6 +159,8 @@ private: ...@@ -156,6 +159,8 @@ private:
/** /**
* Block number handling * Block number handling
*/ */
static const unsigned MAX_NO_THREADS = 4711;
struct ThreadData { struct ThreadData {
static const Uint32 ACTIVE = (1 << 16) | 1; static const Uint32 ACTIVE = (1 << 16) | 1;
static const Uint32 INACTIVE = (1 << 16); static const Uint32 INACTIVE = (1 << 16);
......
...@@ -25,66 +25,6 @@ ...@@ -25,66 +25,6 @@
class NDBT_Attribute : public NdbDictionary::Column { class NDBT_Attribute : public NdbDictionary::Column {
friend class NdbOut& operator <<(class NdbOut&, const NDBT_Attribute &); friend class NdbOut& operator <<(class NdbOut&, const NDBT_Attribute &);
public: public:
NDBT_Attribute(const char* anAttrName,
AttrType type,
int sz = 4,
KeyType key = NoKey,
bool nullable = false,
StorageAttributeType indexOnly = NormalStorageAttribute,
StorageMode _sm = MMBased) :
NdbDictionary::Column(anAttrName)
{
assert(anAttrName != 0);
setNullable(nullable);
setIndexOnlyStorage(indexOnly == IndexStorageAttribute);
setPrimaryKey(key != NoKey);
setTupleKey(key == TupleId);
setLength(1);
switch(type){
case ::Signed:
if(sz == 8)
setType(NdbDictionary::Column::Bigint);
else if (sz == 4)
setType(NdbDictionary::Column::Int);
else {
setType(NdbDictionary::Column::Int);
setLength(sz);
}
break;
case ::UnSigned:
if(sz == 8)
setType(NdbDictionary::Column::Bigunsigned);
else if (sz == 4)
setType(NdbDictionary::Column::Unsigned);
else {
setType(NdbDictionary::Column::Unsigned);
setLength(sz);
}
break;
case ::Float:
if(sz == 8)
setType(NdbDictionary::Column::Double);
else if (sz == 4)
setType(NdbDictionary::Column::Float);
else{
setType(NdbDictionary::Column::Float);
setLength(sz);
}
break;
case ::String:
setType(NdbDictionary::Column::Char);
setLength(sz);
break;
case ::NoAttrTypeDef:
break;
}
}
NDBT_Attribute(const char* _name, NDBT_Attribute(const char* _name,
Column::Type _type, Column::Type _type,
int _length = 1, int _length = 1,
...@@ -132,4 +72,13 @@ NDBT_Table::discoverTableFromDb(Ndb* ndb, const char * name){ ...@@ -132,4 +72,13 @@ NDBT_Table::discoverTableFromDb(Ndb* ndb, const char * name){
return ndb->getDictionary()->getTable(name); return ndb->getDictionary()->getTable(name);
} }
/**
* Print meta information about index
* (information on how it is strored, what the attributes look like etc.)
*/
class NdbOut& operator <<(class NdbOut&, const NdbDictionary::Index &);
#endif #endif
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <NdbApi.hpp> #include <NdbApi.hpp>
#include <NdbSchemaCon.hpp>
#include <NdbMutex.h> #include <NdbMutex.h>
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include <NdbSleep.h> #include <NdbSleep.h>
...@@ -230,7 +231,6 @@ extern "C" void* NdbThreadFuncInsert(void* pArg) ...@@ -230,7 +231,6 @@ extern "C" void* NdbThreadFuncInsert(void* pArg)
VerifyMethodInt(pNdbOperationW, setValue(c_szWarehouseSum, nWarehouseSum)); VerifyMethodInt(pNdbOperationW, setValue(c_szWarehouseSum, nWarehouseSum));
int iExec = pNdbConnection->execute(Commit); int iExec = pNdbConnection->execute(Commit);
int iError = pNdbConnection->getNdbError().code; int iError = pNdbConnection->getNdbError().code;
CommitStatusType cs = pNdbConnection->commitStatus();
if(iExec<0 && iError!=0 && iError!=266 && iError!=630) { if(iExec<0 && iError!=0 && iError!=266 && iError!=630) {
ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__); ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__);
...@@ -285,7 +285,6 @@ extern "C" void* NdbThreadFuncUpdate(void* pArg) ...@@ -285,7 +285,6 @@ extern "C" void* NdbThreadFuncUpdate(void* pArg)
VerifyMethodInt(pNdbOperationW, setValue(c_szWarehouseSum, nWarehouseSum)); VerifyMethodInt(pNdbOperationW, setValue(c_szWarehouseSum, nWarehouseSum));
int iExec = pNdbConnection->execute(Commit); int iExec = pNdbConnection->execute(Commit);
int iError = pNdbConnection->getNdbError().code; int iError = pNdbConnection->getNdbError().code;
CommitStatusType cs = pNdbConnection->commitStatus();
if(iExec<0 && iError!=0 && iError!=266 && iError!=626) { if(iExec<0 && iError!=0 && iError!=266 && iError!=626) {
ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__); ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__);
...@@ -333,7 +332,6 @@ extern "C" void* NdbThreadFuncDelete(void* pArg) ...@@ -333,7 +332,6 @@ extern "C" void* NdbThreadFuncDelete(void* pArg)
} }
int iExec = pNdbConnection->execute(Commit); int iExec = pNdbConnection->execute(Commit);
int iError = pNdbConnection->getNdbError().code; int iError = pNdbConnection->getNdbError().code;
CommitStatusType cs = pNdbConnection->commitStatus();
if(iExec<0 && iError!=0 && iError!=266 && iError!=626) { if(iExec<0 && iError!=0 && iError!=266 && iError!=626) {
ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__); ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__);
...@@ -389,7 +387,7 @@ extern "C" void* NdbThreadFuncRead(void* pArg) ...@@ -389,7 +387,7 @@ extern "C" void* NdbThreadFuncRead(void* pArg)
} }
int iExec = pNdbConnection->execute(Commit); int iExec = pNdbConnection->execute(Commit);
int iError = pNdbConnection->getNdbError().code; int iError = pNdbConnection->getNdbError().code;
CommitStatusType cs = pNdbConnection->commitStatus();
if(iExec<0 && iError!=0 && iError!=266 && iError!=626) { if(iExec<0 && iError!=0 && iError!=266 && iError!=626) {
ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__); ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__);
} }
...@@ -465,8 +463,7 @@ NDB_COMMAND(acid, "acid", "acid", "acid", 65535) ...@@ -465,8 +463,7 @@ NDB_COMMAND(acid, "acid", "acid", "acid", 65535)
VerifyMethodInt(pNdb, init()); VerifyMethodInt(pNdb, init());
VerifyMethodInt(pNdb, waitUntilReady()); VerifyMethodInt(pNdb, waitUntilReady());
NdbSchemaCon* pNdbSchemaCon = NULL ; NdbSchemaCon* pNdbSchemaCon= NdbSchemaCon::startSchemaTrans(pNdb);
VerifyMethodPtr(pNdbSchemaCon, pNdb, startSchemaTransaction());
if(!pNdbSchemaCon){ if(!pNdbSchemaCon){
ndbout <<"startSchemaTransaction failed, exiting now" << endl ; ndbout <<"startSchemaTransaction failed, exiting now" << endl ;
delete pNdb ; delete pNdb ;
...@@ -497,9 +494,9 @@ NDB_COMMAND(acid, "acid", "acid", "acid", 65535) ...@@ -497,9 +494,9 @@ NDB_COMMAND(acid, "acid", "acid", "acid", 65535)
VerifyMethodInt(pNdbSchemaOp, createAttribute(c_szWarehouseSum, NoKey, 32, 1, UnSigned, MMBased, false)); VerifyMethodInt(pNdbSchemaOp, createAttribute(c_szWarehouseSum, NoKey, 32, 1, UnSigned, MMBased, false));
VerifyMethodInt(pNdbSchemaOp, createAttribute(c_szWarehouseCount, NoKey, 32, 1, UnSigned, MMBased, false)); VerifyMethodInt(pNdbSchemaOp, createAttribute(c_szWarehouseCount, NoKey, 32, 1, UnSigned, MMBased, false));
VerifyMethodInt(pNdbSchemaCon, execute()); VerifyMethodInt(pNdbSchemaCon, execute());
VerifyMethodVoid(pNdb, closeSchemaTransaction(pNdbSchemaCon)); NdbSchemaCon::closeSchemaTrans(pNdbSchemaCon);
VerifyMethodPtr(pNdbSchemaCon, pNdb, startSchemaTransaction()); pNdbSchemaCon= NdbSchemaCon::startSchemaTrans(pNdb);
VerifyMethodPtr(pNdbSchemaOp, pNdbSchemaCon, getNdbSchemaOp()); VerifyMethodPtr(pNdbSchemaOp, pNdbSchemaCon, getNdbSchemaOp());
#if defined NDB_OSE || defined NDB_SOFTOSE #if defined NDB_OSE || defined NDB_SOFTOSE
VerifyMethodInt(pNdbSchemaOp, createTable( VerifyMethodInt(pNdbSchemaOp, createTable(
...@@ -526,7 +523,7 @@ NDB_COMMAND(acid, "acid", "acid", "acid", 65535) ...@@ -526,7 +523,7 @@ NDB_COMMAND(acid, "acid", "acid", "acid", 65535)
VerifyMethodInt(pNdbSchemaOp, createAttribute(c_szDistrictSum, NoKey, 32, 1, UnSigned, MMBased, false)); VerifyMethodInt(pNdbSchemaOp, createAttribute(c_szDistrictSum, NoKey, 32, 1, UnSigned, MMBased, false));
VerifyMethodInt(pNdbSchemaOp, createAttribute(c_szDistrictCount, NoKey, 32, 1, UnSigned, MMBased, false)); VerifyMethodInt(pNdbSchemaOp, createAttribute(c_szDistrictCount, NoKey, 32, 1, UnSigned, MMBased, false));
VerifyMethodInt(pNdbSchemaCon, execute()); VerifyMethodInt(pNdbSchemaCon, execute());
VerifyMethodVoid(pNdb, closeSchemaTransaction(pNdbSchemaCon)); NdbSchemaCon::closeSchemaTrans(pNdbSchemaCon);
g_pNdbMutex = NdbMutex_Create(); g_pNdbMutex = NdbMutex_Create();
NdbMutex_Lock(g_pNdbMutex); NdbMutex_Lock(g_pNdbMutex);
......
...@@ -15,7 +15,9 @@ ...@@ -15,7 +15,9 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "NdbApi.hpp" #include "NdbApi.hpp"
#include <NdbSchemaCon.hpp>
#include <NdbMain.h> #include <NdbMain.h>
#include <md5_hash.hpp> #include <md5_hash.hpp>
...@@ -738,7 +740,7 @@ createTables(Ndb* pMyNdb){ ...@@ -738,7 +740,7 @@ createTables(Ndb* pMyNdb){
if (theTableCreateFlag == 0) { if (theTableCreateFlag == 0) {
for(int i=0; i < 1 ;i++) { for(int i=0; i < 1 ;i++) {
ndbout << "Creating " << tableName[i] << "..." << endl; ndbout << "Creating " << tableName[i] << "..." << endl;
MySchemaTransaction = pMyNdb->startSchemaTransaction(); MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pMyNdb);
if(MySchemaTransaction == NULL && if(MySchemaTransaction == NULL &&
(!error_handler(MySchemaTransaction->getNdbError()))) (!error_handler(MySchemaTransaction->getNdbError())))
...@@ -749,6 +751,7 @@ createTables(Ndb* pMyNdb){ ...@@ -749,6 +751,7 @@ createTables(Ndb* pMyNdb){
(!error_handler(MySchemaTransaction->getNdbError()))) (!error_handler(MySchemaTransaction->getNdbError())))
return -1; return -1;
check = MySchemaOp->createTable( tableName[i] check = MySchemaOp->createTable( tableName[i]
,8 // Table Size ,8 // Table Size
,TupleKey // Key Type ,TupleKey // Key Type
...@@ -793,7 +796,7 @@ createTables(Ndb* pMyNdb){ ...@@ -793,7 +796,7 @@ createTables(Ndb* pMyNdb){
(!error_handler(MySchemaTransaction->getNdbError()))) (!error_handler(MySchemaTransaction->getNdbError())))
return -1; return -1;
pMyNdb->closeSchemaTransaction(MySchemaTransaction); NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
} }
} }
......
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
#include <NdbMain.h> #include <NdbMain.h>
#include <NdbTest.hpp> #include <NdbTest.hpp>
#include <NDBT_Error.hpp> #include <NDBT_Error.hpp>
#include <NdbSchemaCon.hpp>
#define PKSIZE 1 #define PKSIZE 1
#define FOREVER 1 #define FOREVER 1
...@@ -151,7 +152,6 @@ static void UpdateArray(int *attrValue) ...@@ -151,7 +152,6 @@ static void UpdateArray(int *attrValue)
int attrCount = 0; int attrCount = 0;
int opCount = 0; int opCount = 0;
int sizeCount = 0; int sizeCount = 0;
int Index = 0;
int* pValue = attrValue; int* pValue = attrValue;
for (tableCount = 0; tableCount < tNoOfTables; tableCount++) { for (tableCount = 0; tableCount < tNoOfTables; tableCount++) {
...@@ -179,7 +179,6 @@ static void Compare(int* attrValue, int* readValue) ...@@ -179,7 +179,6 @@ static void Compare(int* attrValue, int* readValue)
int attrCount = 0; int attrCount = 0;
int OpCount = 0; int OpCount = 0;
int first = 0; int first = 0;
int sizeCount = 0;
for (tableCount = 0; tableCount < tNoOfTables; tableCount++) { for (tableCount = 0; tableCount < tNoOfTables; tableCount++) {
for (attrCount = 0; attrCount < tNoOfAttributes-1; attrCount++) { for (attrCount = 0; attrCount < tNoOfAttributes-1; attrCount++) {
...@@ -592,19 +591,14 @@ flexScanThread(void* ThreadData) ...@@ -592,19 +591,14 @@ flexScanThread(void* ThreadData)
ThreadNdb* pThreadData = (ThreadNdb*)ThreadData; ThreadNdb* pThreadData = (ThreadNdb*)ThreadData;
unsigned int thread_no = pThreadData->ThreadNo; unsigned int thread_no = pThreadData->ThreadNo;
unsigned int thread_base = (thread_no * 2000000) + (tNodeId * 26000); unsigned int thread_base = (thread_no * 2000000) + (tNodeId * 26000);
int NrOfScannedRecords = 0;
int tThreadResult = 0; int tThreadResult = 0;
Ndb* MyNdb = NULL; Ndb* MyNdb = NULL;
NdbConnection *MyTransaction = NULL;
NdbOperation* MyOperation[MAXTABLES];
int check = 0; int check = 0;
StartType tType = stLast; StartType tType = stLast;
int* pkValue = NULL; int* pkValue = NULL;
int* attrValue = NULL; int* attrValue = NULL;
int* readValue = NULL; int* readValue = NULL;
int AllocSize = 0; int AllocSize = 0;
NdbRecAttr* tTmp = NULL;
OperationType opType;
AllocSize = tNoOfTables * (tNoOfAttributes-1) * tNoOfOperations * AllocSize = tNoOfTables * (tNoOfAttributes-1) * tNoOfOperations *
tAttributeSize * sizeof(int); tAttributeSize * sizeof(int);
...@@ -771,14 +765,14 @@ static int createTables(Ndb* pMyNdb) ...@@ -771,14 +765,14 @@ static int createTables(Ndb* pMyNdb)
i++; i++;
ndbout << endl << "Creating " << tableName[i - 1] << "..." << endl; ndbout << endl << "Creating " << tableName[i - 1] << "..." << endl;
MySchemaTransaction = pMyNdb->startSchemaTransaction(); MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pMyNdb);
if( MySchemaTransaction == NULL ) { if( MySchemaTransaction == NULL ) {
return (-1); return (-1);
} // if } // if
MySchemaOp = MySchemaTransaction->getNdbSchemaOp(); MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
if( MySchemaOp == NULL ) { if( MySchemaOp == NULL ) {
pMyNdb->closeSchemaTransaction(MySchemaTransaction); NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return (-1); return (-1);
} // if } // if
...@@ -800,14 +794,14 @@ static int createTables(Ndb* pMyNdb) ...@@ -800,14 +794,14 @@ static int createTables(Ndb* pMyNdb)
,40); // Nr of Pages ,40); // Nr of Pages
#endif #endif
if (check == -1) { if (check == -1) {
pMyNdb->closeSchemaTransaction(MySchemaTransaction); NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return -1; return -1;
} // if } // if
check = MySchemaOp->createAttribute( (char*)attrName[0], TupleKey, 32, PKSIZE, check = MySchemaOp->createAttribute( (char*)attrName[0], TupleKey, 32, PKSIZE,
UnSigned, MMBased, NotNullAttribute ); UnSigned, MMBased, NotNullAttribute );
if (check == -1) { if (check == -1) {
pMyNdb->closeSchemaTransaction(MySchemaTransaction); NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return -1; return -1;
} // if } // if
...@@ -815,7 +809,7 @@ static int createTables(Ndb* pMyNdb) ...@@ -815,7 +809,7 @@ static int createTables(Ndb* pMyNdb)
check = MySchemaOp->createAttribute( (char*)attrName[j], NoKey, 32, tAttributeSize, check = MySchemaOp->createAttribute( (char*)attrName[j], NoKey, 32, tAttributeSize,
UnSigned, MMBased, NotNullAttribute ); UnSigned, MMBased, NotNullAttribute );
if (check == -1) { if (check == -1) {
pMyNdb->closeSchemaTransaction(MySchemaTransaction); NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return -1; return -1;
} // if } // if
} // for } // for
...@@ -825,7 +819,7 @@ static int createTables(Ndb* pMyNdb) ...@@ -825,7 +819,7 @@ static int createTables(Ndb* pMyNdb)
ndbout << "Probably, " << tableName[i - 1] << " already exist" << endl; ndbout << "Probably, " << tableName[i - 1] << " already exist" << endl;
} // if } // if
pMyNdb->closeSchemaTransaction(MySchemaTransaction); NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
} while (tNoOfTables > i); } while (tNoOfTables > i);
} }
...@@ -1058,7 +1052,6 @@ static int insertRows(Ndb* pNdb, // NDB object ...@@ -1058,7 +1052,6 @@ static int insertRows(Ndb* pNdb, // NDB object
int attrCount = 0; int attrCount = 0;
NdbConnection* MyTransaction = NULL; NdbConnection* MyTransaction = NULL;
NdbOperation* MyOperations[MAXTABLES] = {NULL}; NdbOperation* MyOperations[MAXTABLES] = {NULL};
int Index = 0;
int opCount = 0; int opCount = 0;
for (opCount = 0; opCount < tNoOfOperations; opCount++) { for (opCount = 0; opCount < tNoOfOperations; opCount++) {
...@@ -1099,7 +1092,7 @@ static int insertRows(Ndb* pNdb, // NDB object ...@@ -1099,7 +1092,7 @@ static int insertRows(Ndb* pNdb, // NDB object
} // if } // if
for (attrCount = 0; attrCount < tNoOfAttributes - 1; attrCount++) { for (attrCount = 0; attrCount < tNoOfAttributes - 1; attrCount++) {
Index = tableCount * (tNoOfAttributes - 1) * tNoOfOperations * tAttributeSize + int Index = tableCount * (tNoOfAttributes - 1) * tNoOfOperations * tAttributeSize +
attrCount * tNoOfOperations * tAttributeSize + opCount * tAttributeSize; attrCount * tNoOfOperations * tAttributeSize + opCount * tAttributeSize;
check = MyOperations[tableCount]-> check = MyOperations[tableCount]->
setValue((char*)attrName[attrCount + 1], setValue((char*)attrName[attrCount + 1],
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include <NdbThread.h> #include <NdbThread.h>
#include <NdbMutex.h> #include <NdbMutex.h>
#include <NdbApi.hpp> #include <NdbApi.hpp>
#include <NdbSchemaCon.hpp>
#include <NDBT.hpp> #include <NDBT.hpp>
#define MAXATTR 3 #define MAXATTR 3
...@@ -93,8 +94,8 @@ TTYPE t_addReg(int, NdbOperation*); ...@@ -93,8 +94,8 @@ TTYPE t_addReg(int, NdbOperation*);
TTYPE t_subReg(int, NdbOperation*); TTYPE t_subReg(int, NdbOperation*);
TTYPE t_subroutineWithBranchLabel(int, NdbOperation*); TTYPE t_subroutineWithBranchLabel(int, NdbOperation*);
char tableName[MAXTABLES][MAXSTRLEN+1] = {0}; char tableName[MAXSTRLEN+1];
char attrName[MAXATTR][MAXSTRLEN+1] = {0}; char attrName[MAXATTR][MAXSTRLEN+1];
int attrValue[NUMBEROFRECORDS] = {0}; int attrValue[NUMBEROFRECORDS] = {0};
int pkValue[NUMBEROFRECORDS] = {0}; int pkValue[NUMBEROFRECORDS] = {0};
const int tAttributeSize = 1 ; const int tAttributeSize = 1 ;
...@@ -105,11 +106,9 @@ int bTestPassed = 0; ...@@ -105,11 +106,9 @@ int bTestPassed = 0;
int main(int argc, const char** argv) { int main(int argc, const char** argv) {
int tTableId = 0;
int operationType = 0; int operationType = 0;
int tupTest = 0 ; int tupTest = 0;
int scanTest = 0 ; int scanTest = 0;
bool loop = 0 ;
Ndb* pNdb = new Ndb("TEST_DB"); Ndb* pNdb = new Ndb("TEST_DB");
pNdb->init(); pNdb->init();
...@@ -140,7 +139,7 @@ int main(int argc, const char** argv) { ...@@ -140,7 +139,7 @@ int main(int argc, const char** argv) {
setAttrNames() ; setAttrNames() ;
setTableNames() ; setTableNames() ;
const void * p = NDBT_Table::discoverTableFromDb(pNdb, tableName[0]); const void * p = NDBT_Table::discoverTableFromDb(pNdb, tableName);
if (p != 0){ if (p != 0){
create_table(pNdb); create_table(pNdb);
} }
...@@ -252,18 +251,17 @@ void create_table(Ndb* pMyNdb) { ...@@ -252,18 +251,17 @@ void create_table(Ndb* pMyNdb) {
***************************************************************/ ***************************************************************/
int check = -1 ; int check = -1 ;
NdbSchemaCon *MySchemaTransaction = NULL ;
NdbSchemaOp *MySchemaOp = NULL ; NdbSchemaOp *MySchemaOp = NULL ;
ndbout << endl << "Creating " << tableName[0] << " ... " << endl; ndbout << endl << "Creating " << tableName << " ... " << endl;
MySchemaTransaction = pMyNdb->startSchemaTransaction(); NdbSchemaCon* MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pMyNdb);
if(!MySchemaTransaction) error_handler(MySchemaTransaction->getNdbError(), NO_FAIL); if(!MySchemaTransaction) error_handler(MySchemaTransaction->getNdbError(), NO_FAIL);
MySchemaOp = MySchemaTransaction->getNdbSchemaOp(); MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
if( !MySchemaOp ) error_handler(MySchemaTransaction->getNdbError(), NO_FAIL); if( !MySchemaOp ) error_handler(MySchemaTransaction->getNdbError(), NO_FAIL);
// Create table // Create table
check = MySchemaOp->createTable( tableName[0], check = MySchemaOp->createTable( tableName,
8, // Table size 8, // Table size
TupleKey, // Key Type TupleKey, // Key Type
40 // Nr of Pages 40 // Nr of Pages
...@@ -305,7 +303,8 @@ void create_table(Ndb* pMyNdb) { ...@@ -305,7 +303,8 @@ void create_table(Ndb* pMyNdb) {
ndbout << tableName[0] << " created" << endl; ndbout << tableName[0] << " created" << endl;
} }
pMyNdb->closeSchemaTransaction(MySchemaTransaction);
NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return; return;
...@@ -333,7 +332,7 @@ void write_rows (Ndb* pMyNdb) { ...@@ -333,7 +332,7 @@ void write_rows (Ndb* pMyNdb) {
error_handler(pMyNdb->getNdbError(), NO_FAIL); error_handler(pMyNdb->getNdbError(), NO_FAIL);
}//if }//if
MyOperation = MyTransaction->getNdbOperation(tableName[0]); MyOperation = MyTransaction->getNdbOperation(tableName);
if (!MyOperation) { if (!MyOperation) {
error_handler(pMyNdb->getNdbError(), NO_FAIL); error_handler(pMyNdb->getNdbError(), NO_FAIL);
}//if }//if
...@@ -366,9 +365,6 @@ void verify_deleted(Ndb* pMyNdb) { ...@@ -366,9 +365,6 @@ void verify_deleted(Ndb* pMyNdb) {
int check = -1 ; int check = -1 ;
int loop_count_ops = nRecords; int loop_count_ops = nRecords;
NdbRecAttr* tTmp;
int readValue[MAXATTR];
NdbConnection* pMyTransaction = NULL ;
NdbOperation* pMyOperation = NULL ; NdbOperation* pMyOperation = NULL ;
ndbout << "Verifying deleted records..."<< flush; ndbout << "Verifying deleted records..."<< flush;
...@@ -378,7 +374,7 @@ void verify_deleted(Ndb* pMyNdb) { ...@@ -378,7 +374,7 @@ void verify_deleted(Ndb* pMyNdb) {
NdbConnection* pMyTransaction = pMyNdb->startTransaction(); NdbConnection* pMyTransaction = pMyNdb->startTransaction();
if (!pMyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL); if (!pMyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL);
pMyOperation = pMyTransaction->getNdbOperation(tableName[0]); pMyOperation = pMyTransaction->getNdbOperation(tableName);
if (!pMyOperation) error_handler(pMyNdb->getNdbError(), NO_FAIL); if (!pMyOperation) error_handler(pMyNdb->getNdbError(), NO_FAIL);
check = pMyOperation->readTuple(); check = pMyOperation->readTuple();
...@@ -421,7 +417,7 @@ void read_and_verify_rows(Ndb* pMyNdb, bool pre) { ...@@ -421,7 +417,7 @@ void read_and_verify_rows(Ndb* pMyNdb, bool pre) {
pMyTransaction = pMyNdb->startTransaction(); pMyTransaction = pMyNdb->startTransaction();
if (!pMyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL); if (!pMyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL);
MyOp = pMyTransaction->getNdbOperation(tableName[0]); MyOp = pMyTransaction->getNdbOperation(tableName);
if (!MyOp) error_handler( pMyTransaction->getNdbError(), NO_FAIL); if (!MyOp) error_handler( pMyTransaction->getNdbError(), NO_FAIL);
...@@ -1232,14 +1228,13 @@ void scan_rows(Ndb* pMyNdb, int opType, int tupleType, int scanType) { ...@@ -1232,14 +1228,13 @@ void scan_rows(Ndb* pMyNdb, int opType, int tupleType, int scanType) {
int readValue = 0 ; int readValue = 0 ;
int readValue2 = 0 ; int readValue2 = 0 ;
int scanCount = 0 ; int scanCount = 0 ;
NdbRecAttr* tTmp = NULL ;
TTYPE fail = NO_FAIL ; TTYPE fail = NO_FAIL ;
for (int count=0 ; count < loop_count_ops ; count++) { for (int count=0 ; count < loop_count_ops ; count++) {
NdbConnection* MyTransaction = pMyNdb->startTransaction(); NdbConnection* MyTransaction = pMyNdb->startTransaction();
if (!MyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL); if (!MyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL);
NdbOperation* MyOperation = MyTransaction->getNdbOperation(tableName[0]); NdbOperation* MyOperation = MyTransaction->getNdbOperation(tableName);
if (!MyOperation) error_handler(pMyNdb->getNdbError(), NO_FAIL); if (!MyOperation) error_handler(pMyNdb->getNdbError(), NO_FAIL);
if (opType == 1) if (opType == 1)
...@@ -1306,7 +1301,7 @@ void scan_rows(Ndb* pMyNdb, int opType, int tupleType, int scanType) { ...@@ -1306,7 +1301,7 @@ void scan_rows(Ndb* pMyNdb, int opType, int tupleType, int scanType) {
}else{ }else{
// Sends the SCAN_NEXTREQ signal(s) and reads the answer in TRANS_ID signals. // Sends the SCAN_NEXTREQ signal(s) and reads the answer in TRANS_ID signals.
// SCAN_TABCONF or SCAN_TABREF is the confirmation. // SCAN_TABCONF or SCAN_TABREF is the confirmation.
while (eOf = MyTransaction->nextScanResult() == 0) { while ((eOf = MyTransaction->nextScanResult()) == 0) {
ndbout << readValue <<"; "; ndbout << readValue <<"; ";
// Here we call takeOverScanOp for update of the tuple. // Here we call takeOverScanOp for update of the tuple.
} }
...@@ -1348,7 +1343,7 @@ void update_rows(Ndb* pMyNdb, int tupleType, int opType) { ...@@ -1348,7 +1343,7 @@ void update_rows(Ndb* pMyNdb, int tupleType, int opType) {
return; return;
}//if }//if
MyOperation = MyTransaction->getNdbOperation(tableName[0]); MyOperation = MyTransaction->getNdbOperation(tableName);
if (MyOperation == NULL) { if (MyOperation == NULL) {
error_handler(pMyNdb->getNdbError(), NO_FAIL); error_handler(pMyNdb->getNdbError(), NO_FAIL);
return; return;
...@@ -1442,7 +1437,7 @@ void delete_rows(Ndb* pMyNdb, int tupleTest, int opType) { ...@@ -1442,7 +1437,7 @@ void delete_rows(Ndb* pMyNdb, int tupleTest, int opType) {
MyTransaction = pMyNdb->startTransaction(); MyTransaction = pMyNdb->startTransaction();
if (!MyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL) ; if (!MyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL) ;
MyOperation = MyTransaction->getNdbOperation(tableName[0]); MyOperation = MyTransaction->getNdbOperation(tableName);
if (!MyOperation) error_handler(pMyNdb->getNdbError(), NO_FAIL) ; if (!MyOperation) error_handler(pMyNdb->getNdbError(), NO_FAIL) ;
check = MyOperation->interpretedDeleteTuple(); check = MyOperation->interpretedDeleteTuple();
...@@ -1517,8 +1512,6 @@ inline void setAttrNames(){ ...@@ -1517,8 +1512,6 @@ inline void setAttrNames(){
inline void setTableNames(){ inline void setTableNames(){
for (int i = 0; i < MAXTABLES; i++){ snprintf(tableName, MAXSTRLEN, "TAB1");
snprintf(tableName[i], MAXSTRLEN, "TAB%d", i);
}
} }
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <NdbSleep.h> #include <NdbSleep.h>
#include "ndb_schema.hpp" #include "ndb_schema.hpp"
#include <NDBT.hpp> #include <NDBT.hpp>
#include <NdbSchemaCon.hpp>
/*************************************************************** /***************************************************************
* L O C A L C O N S T A N T S * * L O C A L C O N S T A N T S *
...@@ -141,13 +142,11 @@ extern int useIndexTables; ...@@ -141,13 +142,11 @@ extern int useIndexTables;
int int
create_table_server(Ndb * pNDB){ create_table_server(Ndb * pNdb){
int check; int check;
NdbSchemaCon * MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pNdb);
NdbSchemaCon * MySchemaTransaction = pNDB->startSchemaTransaction();
if( MySchemaTransaction == NULL ) if( MySchemaTransaction == NULL )
error_handler("startSchemaTransaction", pNDB->getNdbError(), 0); error_handler("startSchemaTransaction", pNdb->getNdbError(), 0);
NdbSchemaOp * MySchemaOp = MySchemaTransaction->getNdbSchemaOp(); NdbSchemaOp * MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
if( MySchemaOp == NULL ) if( MySchemaOp == NULL )
...@@ -246,17 +245,17 @@ create_table_server(Ndb * pNDB){ ...@@ -246,17 +245,17 @@ create_table_server(Ndb * pNDB){
error_handler("schemaTransaction->execute()", error_handler("schemaTransaction->execute()",
MySchemaTransaction->getNdbError(), 0); MySchemaTransaction->getNdbError(), 0);
} }
pNDB->closeSchemaTransaction(MySchemaTransaction); NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return 0; return 0;
} }
int int
create_table_group(Ndb * pNDB){ create_table_group(Ndb * pNdb){
int check; int check;
NdbSchemaCon * MySchemaTransaction = pNDB->startSchemaTransaction(); NdbSchemaCon * MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pNdb);
if( MySchemaTransaction == NULL ) if( MySchemaTransaction == NULL )
error_handler("startSchemaTransaction", pNDB->getNdbError(), 0); error_handler("startSchemaTransaction", pNdb->getNdbError(), 0);
NdbSchemaOp * MySchemaOp = MySchemaTransaction->getNdbSchemaOp(); NdbSchemaOp * MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
if( MySchemaOp == NULL ) if( MySchemaOp == NULL )
...@@ -340,16 +339,16 @@ create_table_group(Ndb * pNDB){ ...@@ -340,16 +339,16 @@ create_table_group(Ndb * pNDB){
error_handler("schemaTransaction->execute()", error_handler("schemaTransaction->execute()",
MySchemaTransaction->getNdbError(), 0); MySchemaTransaction->getNdbError(), 0);
} }
pNDB->closeSchemaTransaction(MySchemaTransaction); NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return 0; return 0;
} }
int int
create_table_subscriber(Ndb * pNDB){ create_table_subscriber(Ndb * pNdb){
int check; int check;
NdbSchemaCon * MySchemaTransaction = pNDB->startSchemaTransaction(); NdbSchemaCon * MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pNdb);
if( MySchemaTransaction == NULL ) if( MySchemaTransaction == NULL )
error_handler("startSchemaTransaction", pNDB->getNdbError(), 0); error_handler("startSchemaTransaction", pNdb->getNdbError(), 0);
NdbSchemaOp * MySchemaOp = MySchemaTransaction->getNdbSchemaOp(); NdbSchemaOp * MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
if( MySchemaOp == NULL ) if( MySchemaOp == NULL )
...@@ -459,16 +458,16 @@ create_table_subscriber(Ndb * pNDB){ ...@@ -459,16 +458,16 @@ create_table_subscriber(Ndb * pNDB){
error_handler("schemaTransaction->execute()", error_handler("schemaTransaction->execute()",
MySchemaTransaction->getNdbError(), 0); MySchemaTransaction->getNdbError(), 0);
} }
pNDB->closeSchemaTransaction(MySchemaTransaction); NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return 0; return 0;
} }
int int
create_table_session(Ndb * pNDB){ create_table_session(Ndb * pNdb){
int check; int check;
NdbSchemaCon * MySchemaTransaction = pNDB->startSchemaTransaction(); NdbSchemaCon * MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pNdb);
if( MySchemaTransaction == NULL ) if( MySchemaTransaction == NULL )
error_handler("startSchemaTransaction", pNDB->getNdbError(), 0); error_handler("startSchemaTransaction", pNdb->getNdbError(), 0);
NdbSchemaOp * MySchemaOp = MySchemaTransaction->getNdbSchemaOp(); NdbSchemaOp * MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
if( MySchemaOp == NULL ) if( MySchemaOp == NULL )
...@@ -533,29 +532,29 @@ create_table_session(Ndb * pNDB){ ...@@ -533,29 +532,29 @@ create_table_session(Ndb * pNDB){
error_handler("schemaTransaction->execute()", error_handler("schemaTransaction->execute()",
MySchemaTransaction->getNdbError(), 0); MySchemaTransaction->getNdbError(), 0);
} }
pNDB->closeSchemaTransaction(MySchemaTransaction); NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return 0; return 0;
} }
void void
create_table(const char * name, int (* function)(Ndb * pNDB), Ndb* pNDB){ create_table(const char * name, int (* function)(Ndb * pNdb), Ndb* pNdb){
printf("creating table %s...", name); printf("creating table %s...", name);
if(pNDB->getDictionary()->getTable(name) != 0){ if(pNdb->getDictionary()->getTable(name) != 0){
printf(" it already exists\n"); printf(" it already exists\n");
return; return;
} else { } else {
printf("\n"); printf("\n");
} }
function(pNDB); function(pNdb);
printf("creating table %s... done\n", name); printf("creating table %s... done\n", name);
} }
static int dbCreate(Ndb * pNDB) static int dbCreate(Ndb * pNdb)
{ {
create_table(SUBSCRIBER_TABLE, create_table_subscriber, pNDB); create_table(SUBSCRIBER_TABLE, create_table_subscriber, pNdb);
create_table(GROUP_TABLE , create_table_group, pNDB); create_table(GROUP_TABLE , create_table_group, pNdb);
create_table(SESSION_TABLE , create_table_session, pNDB); create_table(SESSION_TABLE , create_table_session, pNdb);
create_table(SERVER_TABLE , create_table_server, pNDB); create_table(SERVER_TABLE , create_table_server, pNdb);
return 0; return 0;
} }
...@@ -570,23 +569,23 @@ userDbConnect(uint32 createDb, char *dbName) ...@@ -570,23 +569,23 @@ userDbConnect(uint32 createDb, char *dbName)
{ {
NdbMutex_Lock(startupMutex); NdbMutex_Lock(startupMutex);
Ndb * pNDB = new Ndb(""); Ndb * pNdb = new Ndb("");
//printf("Initializing...\n"); //printf("Initializing...\n");
pNDB->init(); pNdb->init();
//printf("Waiting..."); //printf("Waiting...");
while(pNDB->waitUntilReady() != 0){ while(pNdb->waitUntilReady() != 0){
//printf("..."); //printf("...");
} }
// printf("done\n"); // printf("done\n");
if( createDb ) if( createDb )
dbCreate(pNDB); dbCreate(pNdb);
UserHandle * uh = new UserHandle; UserHandle * uh = new UserHandle;
uh->pNDB = pNDB; uh->pNDB = pNdb;
uh->pCurrTrans = 0; uh->pCurrTrans = 0;
NdbMutex_Unlock(startupMutex); NdbMutex_Unlock(startupMutex);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
* *************************************************** */ * *************************************************** */
#include "NdbApi.hpp" #include "NdbApi.hpp"
#include "NdbSchemaCon.hpp"
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include <NdbMain.h> #include <NdbMain.h>
#include <NdbTest.hpp> #include <NdbTest.hpp>
...@@ -90,7 +91,7 @@ NDB_COMMAND(initronja, "initronja", "initronja", "initronja", 65535){ ...@@ -90,7 +91,7 @@ NDB_COMMAND(initronja, "initronja", "initronja", "initronja", 65535){
ndbout << endl << "Creating the table SHORT_REC" << "..." << endl; ndbout << endl << "Creating the table SHORT_REC" << "..." << endl;
MySchemaTransaction = pNdb->startSchemaTransaction(); MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pNdb);
if(!MySchemaTransaction) goto error_handler; if(!MySchemaTransaction) goto error_handler;
MySchemaOp = MySchemaTransaction->getNdbSchemaOp(); MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
if(!MySchemaOp) goto error_handler; if(!MySchemaOp) goto error_handler;
...@@ -148,11 +149,11 @@ NDB_COMMAND(initronja, "initronja", "initronja", "initronja", 65535){ ...@@ -148,11 +149,11 @@ NDB_COMMAND(initronja, "initronja", "initronja", "initronja", 65535){
ndbout << "SHORT_REC created " << endl; ndbout << "SHORT_REC created " << endl;
}// if }// if
pNdb->closeSchemaTransaction(MySchemaTransaction); NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
ndbout << endl << "Creating the table LONG_REC..." << endl; ndbout << endl << "Creating the table LONG_REC..." << endl;
MySchemaTransaction = pNdb->startSchemaTransaction(); MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pNdb);
if(!MySchemaTransaction) goto error_handler; if(!MySchemaTransaction) goto error_handler;
MySchemaOp = MySchemaTransaction->getNdbSchemaOp(); MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
...@@ -212,7 +213,7 @@ NDB_COMMAND(initronja, "initronja", "initronja", "initronja", 65535){ ...@@ -212,7 +213,7 @@ NDB_COMMAND(initronja, "initronja", "initronja", "initronja", 65535){
ndbout << "LONG_REC created" << endl; ndbout << "LONG_REC created" << endl;
}// if }// if
pNdb->closeSchemaTransaction(MySchemaTransaction); NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
check = InsertRecords(pNdb, tNoOfRecords); check = InsertRecords(pNdb, tNoOfRecords);
...@@ -234,7 +235,7 @@ NDB_COMMAND(initronja, "initronja", "initronja", "initronja", 65535){ ...@@ -234,7 +235,7 @@ NDB_COMMAND(initronja, "initronja", "initronja", "initronja", 65535){
error_handler: error_handler:
ndbout << "SchemaTransaction returned error:" ; ndbout << "SchemaTransaction returned error:" ;
ndbout << MySchemaTransaction->getNdbError() << endl; ndbout << MySchemaTransaction->getNdbError() << endl;
pNdb->closeSchemaTransaction(MySchemaTransaction); NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
delete pNdb ; delete pNdb ;
NDBT_ProgramExit(NDBT_FAILED) ; NDBT_ProgramExit(NDBT_FAILED) ;
exit(-1); exit(-1);
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <ndb_global.h> #include <ndb_global.h>
#include <NdbApi.hpp> #include <NdbApi.hpp>
#include <NdbSchemaCon.hpp>
#include <NdbCondition.h> #include <NdbCondition.h>
#include <NdbMutex.h> #include <NdbMutex.h>
#include <NdbSleep.h> #include <NdbSleep.h>
...@@ -849,7 +850,7 @@ int CreateCallContextTable(Ndb* pNdb, const char* szTableName, bool bStored) ...@@ -849,7 +850,7 @@ int CreateCallContextTable(Ndb* pNdb, const char* szTableName, bool bStored)
NdbError err; NdbError err;
memset(&err, 0, sizeof(err)); memset(&err, 0, sizeof(err));
NdbSchemaCon* pNdbSchemaCon = pNdb->startSchemaTransaction(); NdbSchemaCon* pNdbSchemaCon = NdbSchemaCon::startSchemaTrans(pNdb);
if(pNdbSchemaCon) if(pNdbSchemaCon)
{ {
NdbSchemaOp* pNdbSchemaOp = pNdbSchemaCon->getNdbSchemaOp(); NdbSchemaOp* pNdbSchemaOp = pNdbSchemaCon->getNdbSchemaOp();
...@@ -874,7 +875,8 @@ int CreateCallContextTable(Ndb* pNdb, const char* szTableName, bool bStored) ...@@ -874,7 +875,8 @@ int CreateCallContextTable(Ndb* pNdb, const char* szTableName, bool bStored)
} }
else else
err = pNdbSchemaCon->getNdbError(); err = pNdbSchemaCon->getNdbError();
pNdb->closeSchemaTransaction(pNdbSchemaCon);
NdbSchemaCon::closeSchemaTrans(pNdbSchemaCon);
} }
else else
err = pNdb->getNdbError(); err = pNdb->getNdbError();
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include <NdbApi.hpp> #include <NdbApi.hpp>
#include <NdbTest.hpp> #include <NdbTest.hpp>
#include <NdbSchemaCon.hpp>
// limits // limits
static int const MaxAttr = 64; static int const MaxAttr = 64;
static int const MaxOper = 1000; static int const MaxOper = 1000;
...@@ -99,7 +99,7 @@ ndberror(char const* fmt, ...) ...@@ -99,7 +99,7 @@ ndberror(char const* fmt, ...)
if (tcon) if (tcon)
ndbout << "tcon: " << tcon->getNdbError() << endl; ndbout << "tcon: " << tcon->getNdbError() << endl;
if (top) if (top)
ndbout << "top : " << top->getNdbError() << endl; ndbout << "top: " << top->getNdbError() << endl;
if (con) if (con)
ndbout << "con : " << con->getNdbError() << endl; ndbout << "con : " << con->getNdbError() << endl;
if (op) if (op)
...@@ -258,7 +258,7 @@ testcase(int flag) ...@@ -258,7 +258,7 @@ testcase(int flag)
if (ndb->waitUntilReady(30) < 0) if (ndb->waitUntilReady(30) < 0)
return ndberror("waitUntilReady"); return ndberror("waitUntilReady");
if ((tcon = ndb->startSchemaTransaction()) == 0) if ((tcon = NdbSchemaCon::startSchemaTrans(ndb)) == 0)
return ndberror("startSchemaTransaction"); return ndberror("startSchemaTransaction");
if ((top = tcon->getNdbSchemaOp()) == 0) if ((top = tcon->getNdbSchemaOp()) == 0)
return ndberror("getNdbSchemaOp"); return ndberror("getNdbSchemaOp");
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
#include <Vector.hpp> #include <Vector.hpp>
#include <random.h> #include <random.h>
#include <NdbTick.h> #include <NdbTick.h>
#include <AttrType.hpp>
#define MAX_NDB_OBJECTS 32678
#define CHECK(b) if (!(b)) { \ #define CHECK(b) if (!(b)) { \
ndbout << "ERR: "<< step->getName() \ ndbout << "ERR: "<< step->getName() \
...@@ -79,7 +79,7 @@ int runTestMaxNdb(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -79,7 +79,7 @@ int runTestMaxNdb(NDBT_Context* ctx, NDBT_Step* step){
ndbout << i << " ndb objects created" << endl; ndbout << i << " ndb objects created" << endl;
if (l > 0 && i != oldi && init != MAX_NO_THREADS){ if (l > 0 && i != oldi && init != MAX_NDB_OBJECTS){
ndbout << l << ": not as manyNdb objects created" << endl ndbout << l << ": not as manyNdb objects created" << endl
<< i << " != " << oldi << endl; << i << " != " << oldi << endl;
result = NDBT_FAILED; result = NDBT_FAILED;
......
...@@ -121,7 +121,7 @@ int runVerifyInserts(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -121,7 +121,7 @@ int runVerifyInserts(NDBT_Context* ctx, NDBT_Step* step){
HugoOperations hugoOps(*ctx->getTab()); HugoOperations hugoOps(*ctx->getTab());
NdbRestarter restarter; NdbRestarter restarter;
int restartGCI = pNdb->NdbTamper(ReadRestartGCI, 0); int restartGCI = pNdb->NdbTamper(Ndb::ReadRestartGCI, 0);
ndbout << "restartGCI = " << restartGCI << endl; ndbout << "restartGCI = " << restartGCI << endl;
int count = 0; int count = 0;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <ndb_global.h> #include <ndb_global.h>
#include "NDBT_ResultRow.hpp" #include "NDBT_ResultRow.hpp"
#include <NdbOut.hpp> #include <NdbOut.hpp>
#include <NdbSchemaCon.hpp>
NDBT_ResultRow::NDBT_ResultRow(const NdbDictionary::Table& tab, NDBT_ResultRow::NDBT_ResultRow(const NdbDictionary::Table& tab,
char attrib_delimiter) char attrib_delimiter)
...@@ -109,6 +110,12 @@ BaseString NDBT_ResultRow::c_str() { ...@@ -109,6 +110,12 @@ BaseString NDBT_ResultRow::c_str() {
return str; return str;
} }
/**
* TODO This could chare the sanme printer function as in
* NdbEventOperationImpl.cpp, using new types of course :)
*/
NdbOut & NdbOut &
operator << (NdbOut& ndbout, const NDBT_ResultRow & res) { operator << (NdbOut& ndbout, const NDBT_ResultRow & res) {
for(int i = 0; i<res.cols; i++){ for(int i = 0; i<res.cols; i++){
...@@ -117,7 +124,7 @@ operator << (NdbOut& ndbout, const NDBT_ResultRow & res) { ...@@ -117,7 +124,7 @@ operator << (NdbOut& ndbout, const NDBT_ResultRow & res) {
else{ else{
const int size = res.data[i]->attrSize(); const int size = res.data[i]->attrSize();
const int aSize = res.data[i]->arraySize(); const int aSize = res.data[i]->arraySize();
switch(res.data[i]->attrType()){ switch(convertColumnTypeToAttrType(res.data[i]->getType())){
case UnSigned: case UnSigned:
switch(size){ switch(size){
case 8: case 8:
...@@ -174,7 +181,8 @@ operator << (NdbOut& ndbout, const NDBT_ResultRow & res) { ...@@ -174,7 +181,8 @@ operator << (NdbOut& ndbout, const NDBT_ResultRow & res) {
break; break;
default: default:
ndbout << "Unknown(" << res.data[i]->attrType() << ")"; ndbout << "Unknown(" <<
convertColumnTypeToAttrType(res.data[i]->getType()) << ")";
break; break;
} }
} }
......
...@@ -26,7 +26,7 @@ operator <<(class NdbOut& ndbout, const NDBT_Attribute & attr){ ...@@ -26,7 +26,7 @@ operator <<(class NdbOut& ndbout, const NDBT_Attribute & attr){
bool key = attr.getPrimaryKey(); bool key = attr.getPrimaryKey();
bool null = attr.getNullable(); bool null = attr.getNullable();
ndbout << attr.getName() << "\t"; ndbout << attr.getName() << " ";
char tmp[100]; char tmp[100];
if(attr.getLength() != 1) if(attr.getLength() != 1)
snprintf(tmp, 100," [%d]", attr.getLength()); snprintf(tmp, 100," [%d]", attr.getLength());
...@@ -103,16 +103,16 @@ operator <<(class NdbOut& ndbout, const NDBT_Attribute & attr){ ...@@ -103,16 +103,16 @@ operator <<(class NdbOut& ndbout, const NDBT_Attribute & attr){
ndbout << "Unknown(" << type << ")"; ndbout << "Unknown(" << type << ")";
} }
ndbout << "\t"; ndbout << " ";
if(null){ if(null){
ndbout << "NULL"; ndbout << "NULL";
} else { } else {
ndbout << "NOT NULL"; ndbout << "NOT NULL";
} }
ndbout << "\t"; ndbout << " ";
if(key) if(key)
ndbout << "\tprimary key"; ndbout << "PRIMARY KEY";
return ndbout; return ndbout;
} }
...@@ -130,6 +130,9 @@ operator <<(class NdbOut& ndbout, const NDBT_Table & tab) ...@@ -130,6 +130,9 @@ operator <<(class NdbOut& ndbout, const NDBT_Table & tab)
ndbout << "Temporary table: " << (tab.getStoredTable() ? "no" : "yes") << endl; ndbout << "Temporary table: " << (tab.getStoredTable() ? "no" : "yes") << endl;
ndbout << "Number of attributes: " << tab.getNoOfColumns() << endl; ndbout << "Number of attributes: " << tab.getNoOfColumns() << endl;
ndbout << "Number of primary keys: " << tab.getNoOfPrimaryKeys() << endl; ndbout << "Number of primary keys: " << tab.getNoOfPrimaryKeys() << endl;
ndbout << "Length of frm data: " << tab.getFrmLength() << endl;
//<< ((tab.getTupleKey() == TupleId) ? " tupleid" : "") <<endl; //<< ((tab.getTupleKey() == TupleId) ? " tupleid" : "") <<endl;
ndbout << "TableStatus: "; ndbout << "TableStatus: ";
switch(tab.getObjectStatus()){ switch(tab.getObjectStatus()){
...@@ -154,3 +157,32 @@ operator <<(class NdbOut& ndbout, const NDBT_Table & tab) ...@@ -154,3 +157,32 @@ operator <<(class NdbOut& ndbout, const NDBT_Table & tab)
return ndbout; return ndbout;
} }
class NdbOut& operator <<(class NdbOut&, const NdbDictionary::Index & idx)
{
ndbout << idx.getName();
ndbout << "(";
for (unsigned i=0; i < idx.getNoOfColumns(); i++)
{
const NdbDictionary::Column *col = idx.getColumn(i);
ndbout << col->getName();
if (i < idx.getNoOfColumns()-1)
ndbout << ", ";
}
ndbout << ")";
ndbout << " - ";
switch (idx.getType()) {
case NdbDictionary::Object::UniqueHashIndex:
ndbout << "UniqueHashIndex";
break;
case NdbDictionary::Object::OrderedIndex:
ndbout << "OrderedIndex";
break;
default:
ndbout << "Type " << idx.getType();
break;
}
return ndbout;
}
...@@ -980,8 +980,8 @@ UtilTransactions::verifyIndex(Ndb* pNdb, ...@@ -980,8 +980,8 @@ UtilTransactions::verifyIndex(Ndb* pNdb,
} }
switch (pIndex->getType()){ switch (pIndex->getType()){
case UniqueHashIndex: case NdbDictionary::Index::UniqueHashIndex:
case OrderedIndex: case NdbDictionary::Index::OrderedIndex:
return verifyUniqueIndex(pNdb, indexName, parallelism, transactional); return verifyUniqueIndex(pNdb, indexName, parallelism, transactional);
break; break;
default: default:
......
...@@ -19,19 +19,19 @@ ...@@ -19,19 +19,19 @@
#include <NdbApi.hpp> #include <NdbApi.hpp>
int main(int argc, const char** argv){ int main(int argc, const char** argv){
const char* _tabname = NULL; const char* _tabname = NULL;
const char* _dbname = "TEST_DB"; const char* _dbname = "TEST_DB";
int _frm = 0;
int _unqualified = 0; int _unqualified = 0;
int _help = 0; int _help = 0;
struct getargs args[] = { struct getargs args[] = {
{ "unqualified", 'u', arg_integer, &_unqualified, "unqualified", { "unqualified", 'u', arg_flag, &_unqualified, "unqualified",
"Use unqualified table names"}, "Use unqualified table names"},
{ "database", 'd', arg_string, &_dbname, "dbname", { "database", 'd', arg_string, &_dbname, "dbname",
"Name of database table is in"}, "Name of database table is in"},
{ "frm-data", 'f', arg_flag, &_frm, "Show frm data for table", "" } ,
{ "usage", '?', arg_flag, &_help, "Print help", "" } { "usage", '?', arg_flag, &_help, "Print help", "" }
}; };
int num_args = sizeof(args) / sizeof(args[0]); int num_args = sizeof(args) / sizeof(args[0]);
...@@ -62,15 +62,40 @@ int main(int argc, const char** argv){ ...@@ -62,15 +62,40 @@ int main(int argc, const char** argv){
NdbDictionary::Dictionary * dict = pMyNdb->getDictionary(); NdbDictionary::Dictionary * dict = pMyNdb->getDictionary();
for (int i = optind; i < argc; i++) { for (int i = optind; i < argc; i++) {
NDBT_Table* pTab = (NDBT_Table*)dict->getTable(argv[i]); NDBT_Table* pTab = (NDBT_Table*)dict->getTable(argv[i]);
if (pTab != 0) { if (pTab != 0){
ndbout << (* pTab) << endl; ndbout << (* pTab) << endl;
if (_frm){
ndbout << "getFrmLength: "<< endl NdbDictionary::Dictionary::List list;
<< pTab->getFrmLength() << endl; if (dict->listIndexes(list, argv[i]) != 0){
ndbout << argv[i] << ": " << dict->getNdbError() << endl;
return NDBT_ProgramExit(NDBT_FAILED);
}
ndbout << "-- Indexes -- " << endl;
ndbout << "PRIMARY KEY(";
for (unsigned j= 0; j < pTab->getNoOfPrimaryKeys(); j++)
{
const NdbDictionary::Column * col = pTab->getColumn(j);
ndbout << col->getName();
if (j < pTab->getNoOfPrimaryKeys()-1)
ndbout << ", ";
} }
} else { ndbout << ") - UniqueHashIndex" << endl;
for (unsigned j= 0; j < list.count; j++) {
NdbDictionary::Dictionary::List::Element& elt = list.elements[j];
const NdbDictionary::Index *pIdx = dict->getIndex(elt.name, argv[i]);
if (!pIdx){
ndbout << argv[i] << ": " << dict->getNdbError() << endl; ndbout << argv[i] << ": " << dict->getNdbError() << endl;
return NDBT_ProgramExit(NDBT_FAILED);
}
ndbout << (*pIdx) << endl;
} }
ndbout << endl;
}
else
ndbout << argv[i] << ": " << dict->getNdbError() << endl;
} }
delete pMyNdb; delete pMyNdb;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment