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.
parent 15023e1b
......@@ -50,7 +50,6 @@ include/mgmapi/mgmapi.h
include/mgmapi/mgmapi_debug.h
include/ndbapi/
include/ndbapi/ndbapi_limits.h
include/ndbapi/AttrType.hpp
include/ndbapi/Ndb.hpp
include/ndbapi/NdbApi.hpp
include/ndbapi/NdbConnection.hpp
......
......@@ -860,7 +860,6 @@
#include <ndb_types.h>
#include <ndbapi_limits.h>
#include <AttrType.hpp>
#include <NdbError.hpp>
#include <NdbDictionary.hpp>
......@@ -870,8 +869,6 @@ class NdbEventOperationImpl;
class NdbScanOperation;
class NdbIndexOperation;
class NdbConnection;
class NdbSchemaOp;
class NdbSchemaCon;
class NdbApiSignal;
class NdbRecAttr;
class NdbLabel;
......@@ -961,8 +958,6 @@ class Ndb
friend class NdbOperation;
friend class NdbEventOperationImpl;
friend class NdbConnection;
friend class NdbSchemaOp;
friend class NdbSchemaCon;
friend class Table;
friend class NdbApiSignal;
friend class NdbScanReceiver;
......@@ -1064,8 +1059,6 @@ public:
* A value larger than 1024 will be downgraded to 1024.
* This means that one Ndb object can handle at most 1024 parallel
* transactions.
* There is a maximum of 128 simultaneous
* Ndb object within one application process.
* @return 0 if successful, -1 otherwise.
*
* @note The internal implementation multiplies this value
......@@ -1245,22 +1238,6 @@ public:
*/
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:
/** @} *********************************************************************/
#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
* (i.e. send a special signal to DBDIH, the NDB distribution handler).
......@@ -1398,14 +1389,7 @@ public:
* In a release versions of NDB Cluster,
* this call always return -1 and does nothing.
*
* @param aAction Action to be taken
* - 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 aAction Action to be taken according to TamperType above
*
* @param aNode Which node the action will be taken
* -1: Master DIH.
......@@ -1616,9 +1600,6 @@ private:
NdbScanOperation* theScanOpIdleList; // First scan 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** theConnectionArray;
NdbRecAttr* theRecAttrIdleList;
......@@ -1649,7 +1630,14 @@ private:
NdbError theError;
Int32 theNdbBlockNumber;
InitType theInitState;
enum InitType {
NotConstructed,
NotInitialised,
StartingInit,
Initialised,
InitConfigError
} theInitState;
// Ensure good distribution of connects
Uint32 theCurrentConnectIndex;
......
......@@ -17,14 +17,12 @@
#ifndef NdbApi_H
#define NdbApi_H
#include "ndbapi_limits.h"
#include "Ndb.hpp"
#include "AttrType.hpp"
#include "NdbConnection.hpp"
#include "NdbOperation.hpp"
#include "NdbScanOperation.hpp"
#include "NdbIndexOperation.hpp"
#include "NdbSchemaCon.hpp"
#include "NdbSchemaOp.hpp"
#include "NdbRecAttr.hpp"
#include "NdbResultSet.hpp"
#include "NdbDictionary.hpp"
......
......@@ -18,7 +18,6 @@
#define NdbConnection_H
#include <ndb_types.h>
#include <AttrType.hpp>
#include <NdbError.hpp>
class NdbConnection;
......@@ -40,6 +39,35 @@ class NdbScanReceiver;
*/
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
* @brief Represents a transaction.
......@@ -419,6 +447,14 @@ public:
* @return The commit status of the transaction, i.e. one of
* { 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();
/** @} *********************************************************************/
......@@ -515,8 +551,17 @@ private:
Uint32 getBuddyConPtr(); // Gets Buddy Con Ptr
NdbConnection* next(); // Returns the next pointer
void next(NdbConnection*); // Sets the next pointer
ConStatusType Status(); // Read the status information
void Status(ConStatusType); // Set the status information
enum ConStatusType {
NotConnected,
Connecting,
Connected,
DisConnecting,
ConnectFailure
};
ConStatusType Status(); // Read the status information
void Status(ConStatusType); // Set the status information
Uint32 get_send_size(); // Get size to send
void set_send_size(Uint32); // Set size to send;
......@@ -595,6 +640,18 @@ private:
Uint32 theId;
// 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;
NdbAsynchCallback theCallbackFunction; // Pointer to the callback function
void* theCallbackObject; // The callback object pointer
......@@ -628,12 +685,18 @@ private:
Uint64 theTransactionId; // theTransactionId of the transaction
Uint32 theGlobalCheckpointId; // The gloabl checkpoint identity of the transaction
ConStatusType theStatus; // The status of the connection
CompletionStatus theCompletionStatus; // The Completion status of the transaction
enum CompletionStatus {
NotCompleted,
CompletedSuccess,
CompletedFailure,
DefinitionFailure
} theCompletionStatus; // The Completion status of the transaction
CommitStatusType theCommitStatus; // The commit status of the transaction
Uint32 theMagicNumber; // Magic Number to verify correct object
Uint32 thePriority; // Transaction Priority
enum ReturnType { ReturnSuccess, ReturnFailure };
ReturnType theReturnStatus; // Did we have any read/update/delete failing
// to find the tuple.
bool theTransactionIsStarted;
......@@ -641,7 +704,12 @@ private:
bool theSimpleState;
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 theNodeSequence; // The sequence no of the db node
......@@ -830,7 +898,7 @@ Parameters: aStatus: The status.
Remark: Sets Connect status.
******************************************************************************/
inline
ConStatusType
NdbConnection::ConStatusType
NdbConnection::Status()
{
return theStatus;
......@@ -849,6 +917,7 @@ NdbConnection::Status( ConStatusType aStatus )
theStatus = aStatus;
}
/******************************************************************************
void setGCI();
......
......@@ -184,7 +184,7 @@ private:
// Private attributes
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_theNoOfIndexDefined; // The number of index attributes
};
......
......@@ -18,10 +18,9 @@
#define NdbOperation_H
#include <ndb_types.h>
#include <AttrType.hpp>
#include <NdbError.hpp>
#include <NdbReceiver.hpp>
#include "ndbapi_limits.h"
#include "NdbError.hpp"
#include "NdbReceiver.hpp"
class Ndb;
class NdbApiSignal;
......@@ -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:
/******************************************************************************
* These are the methods used to create and delete the NdbOperation objects.
......@@ -865,11 +880,27 @@ protected:
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
void Status(OperationStatus); // Set the status information
OperationType RequestType();
void NdbCon(NdbConnection*); // Set reference to connection
// object.
......@@ -879,8 +910,6 @@ protected:
// the operations object.
void setStartIndicator();
void setCommitIndicator(CommitType aCommitType);
/******************************************************************************
* The methods below is the execution part of the NdbOperation
* class. This is where the NDB signals are sent and received. The
......@@ -1013,18 +1042,13 @@ protected:
Uint32 theCurrRecAI_Len; // The currently received length
Uint32 theAI_ElementLen; // How many words long is this 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_accessTable;
// Set to TRUE when a tuple key attribute has been defined.
// A tuple key is allowed to consist of 64 attributes.
Uint32 theTupleKeyDefined[MAXNROFTUPLEKEY][3];
Uint32 theTupleKeyDefined[NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY][3];
Uint32 theTotalNrOfKeyWordInSignal; // The total number of
Uint32 theTotalNrOfKeyWordInSignal; // The total number of
// keyword in signal.
Uint32 theTupKeyLen; // Length of the tuple key in words
......@@ -1094,16 +1118,6 @@ NdbOperation::setStartIndicator()
theStartIndicator = 1;
}
#if 0
inline
void
NdbOperation::setCommitIndicator(CommitType aTypeOfCommit)
{
theCommitIndicator = 1;
theCommitType = (Uint8)aTypeOfCommit;
}
#endif
inline
int
NdbOperation::getNdbErrorLine()
......@@ -1145,7 +1159,7 @@ Parameters: aStatus: The status.
Remark: Sets Operation status.
******************************************************************************/
inline
OperationStatus
NdbOperation::OperationStatus
NdbOperation::Status()
{
return theStatus;
......@@ -1178,18 +1192,6 @@ NdbOperation::NdbCon(NdbConnection* aNdbCon)
theNdbCon = aNdbCon;
}
/******************************************************************************
OperationType RequestType();
Remark: Return the request typ of the operation..
******************************************************************************/
inline
OperationType
NdbOperation::RequestType()
{
return theOperationType;
}
inline
int
NdbOperation::equal(const char* anAttrName, Int32 aPar)
......
......@@ -18,7 +18,6 @@
#define NdbRecAttr_H
#include <NdbDictionary.hpp>
#include "AttrType.hpp"
class NdbOperation;
class AttrInfo;
......@@ -85,13 +84,11 @@ public:
* @{
*/
const NdbDictionary::Column * getColumn() const;
/**
* Get attribute type.
*
* @return Type of attribute: { Signed, UnSigned, Float, String }
* Get type of column
* @return Data type of the column
*/
AttrType attrType() const ;
NdbDictionary::Column::Type getType() 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
Uint32
NdbRecAttr::arraySize() const
......
......@@ -16,15 +16,16 @@
#ifndef NdbSchemaCon_H
#define NdbSchemaCon_H
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
#include <ndb_types.h>
#include "AttrType.hpp"
#include "NdbError.hpp"
#include <NdbSchemaOp.hpp>
class NdbSchemaOp;
class NdbApiSignal;
class Ndb;
class NdbApiSignal;
/**
* @class NdbSchemaCon
......@@ -44,6 +45,7 @@ class Ndb;
* into the database.
*
* @note Currently only one table can be added per transaction.
* @note Depricated, use NdbDictionary
*/
class NdbSchemaCon
{
......@@ -51,6 +53,18 @@ friend class Ndb;
friend class NdbSchemaOp;
public:
static
NdbSchemaCon* startSchemaTrans(Ndb* pNdb){
return new NdbSchemaCon(pNdb);
}
static
void closeSchemaTrans(NdbSchemaCon* pSchCon){
delete pSchCon;
}
/**
* Execute a schema transaction.
*
......@@ -75,6 +89,7 @@ public:
const NdbError & getNdbError() const;
private:
/******************************************************************************
* These are the create and delete methods of this class.
*****************************************************************************/
......@@ -85,8 +100,6 @@ private:
/******************************************************************************
* These are the private methods of this class.
*****************************************************************************/
void init(); // Initialise connection object for new
// transaction.
void release(); // Release all schemaop in schemaCon
......@@ -105,7 +118,6 @@ private:
int receiveDROP_INDX_REF(NdbApiSignal*);
/*****************************************************************************
* These are the private variables of this class.
*****************************************************************************/
......@@ -126,6 +138,9 @@ NdbSchemaCon::checkMagicNumber()
return -1;
return 0;
}//NdbSchemaCon::checkMagicNumber()
#endif
#endif
......
......@@ -16,14 +16,126 @@
#ifndef NdbSchemaOp_H
#define NdbSchemaOp_H
#include <NdbDictionary.hpp>
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
#include "NdbDictionary.hpp"
#include "AttrType.hpp"
#include "NdbSchemaCon.hpp"
/**
* Type of attribute
*
* 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
};
/**
* 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 NdbApiSignal;
class NdbSchemaCon;
class Ndb;
/**
* @class NdbSchemaOp
......@@ -41,8 +153,10 @@ class NdbSchemaOp
{
friend class Ndb;
friend class NdbSchemaCon;
public:
/**
* Create a new table in the database.
*
......@@ -184,7 +298,6 @@ public:
int aMemoryType = 1,
bool aStoredTable = true);
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
/**
* This is the old function declaration, don't use.
*
......@@ -211,7 +324,6 @@ public:
aMemoryType,
(aStoredTable == 1 ? true : false));
}
#endif
/**
* Add a new attribute to a database table.
......@@ -367,7 +479,6 @@ public:
bool aAutoIncrement = false,
const char* aDefaultValue = 0);
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
/**
* @deprecated do not use!
*/
......@@ -394,19 +505,8 @@ public:
aDistributionGroup,
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:
......@@ -440,17 +540,48 @@ protected:
Ndb* theNdb; // Point back to the Ndb object.
NdbSchemaCon* theSchemaCon; // Point back to the connection object.
class NdbDictionary::Table * m_currentTable;
};
inline
const NdbError &
NdbSchemaOp::getNdbError() const
{
return theSchemaCon->getNdbError();
}
/**
* Get old attribute type from new type
*
* NOTE! attrType is deprecated, use getType instead!
*
* @return Type of attribute: { Signed, UnSigned, Float,a String }
*/
inline
AttrType
convertColumnTypeToAttrType(NdbDictionary::Column::Type _type)
{
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
......@@ -18,29 +18,16 @@
#define NDBAPI_LIMITS_H
#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_SCHEMA_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_INDEX NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY
#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_KEY_SIZE NDB_MAX_KEYSIZE_IN_WORDS*sizeof(Uint32)
#define NDB_MAX_TUPLE_SIZE 8191
#define NDB_MAX_TRANSACTIONS 1024
#define NDB_MAX_PARALLEL_SCANS 12
#define NDB_MAX_TUPLE_SIZE NDB_MAX_TUPLE_SIZE_IN_WORDS*sizeof(uint32)
#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
......@@ -10,7 +10,6 @@ DIRS := \
rep \
mgmclient \
cw \
newtonapi \
ndbbaseclient
ifneq ($(NDB_ODBC),N)
DIRS += ndbclient
......
......@@ -20,9 +20,7 @@
#include <ndb_global.h>
#include <BackupFormat.hpp>
#include <NdbApi.hpp>
#include <AttrType.hpp>
#include <NdbOut.hpp>
#include <NdbSchemaCon.hpp>
#include "myVector.hpp"
#include <ndb_version.h>
......
......@@ -23,6 +23,9 @@
#ifdef USE_MYSQL
#include <mysql.h>
#endif
#include <NdbOut.hpp>
NdbOut& operator<<(NdbOut& ndbout, const TupleS& tuple);
NdbOut& operator<<(NdbOut& ndbout, const LogEntry& logEntry);
NdbOut& operator<<(NdbOut& ndbout, const RestoreMetaData &);
......@@ -606,7 +609,7 @@ operator<<(NdbOut& ndbout, const AttributeS& attr){
break;
} // switch size
break;
case (String):
case String:
if (desc.size == 8){
NdbDictionary::Column::Type type = desc.m_table->m_dictTable->getColumn(desc.attrId)->getType();
if(type == NdbDictionary::Column::Varchar){
......@@ -622,7 +625,7 @@ operator<<(NdbOut& ndbout, const AttributeS& attr){
}
j = desc.arraySize;
break;
case (Float):
case Float:
// Not yet supported to print float
ndbout << "float";
break;
......
......@@ -21,7 +21,6 @@
#include "MgmtErrorReporter.hpp"
#include <NdbOut.hpp>
#include <AttrType.hpp>
#include <NdbApiSignal.hpp>
#include <kernel_types.h>
#include <RefConvert.hpp>
......
......@@ -21,7 +21,6 @@
#include "TransporterFacade.hpp"
#include "ClusterMgr.hpp"
#include <IPCConfig.hpp>
#include "AttrType.hpp"
#include "NdbApiSignal.hpp"
#include "API.hpp"
#include <NdbSleep.h>
......
......@@ -26,8 +26,6 @@ Name: Ndb.cpp
#include "NdbApiSignal.hpp"
#include "NdbImpl.hpp"
#include "NdbSchemaOp.hpp"
#include "NdbSchemaCon.hpp"
#include <NdbOperation.hpp>
#include <NdbConnection.hpp>
#include <NdbEventOperation.hpp>
......@@ -155,7 +153,7 @@ Ndb::NDB_connect(Uint32 tNode)
// Set connection pointer as NdbConnection object
//************************************************
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;
{ // send and receive signal
tp->lock_mutex();
......@@ -178,7 +176,7 @@ Ndb::NDB_connect(Uint32 tNode)
}//if
}
if ((tReturnCode == 0) && (tNdbCon->Status() == Connected)) {
if ((tReturnCode == 0) && (tNdbCon->Status() == NdbConnection::Connected)) {
//************************************************
// Send and receive was successful
//************************************************
......@@ -434,7 +432,7 @@ Ndb::startTransactionLocal(Uint32 aPriority, Uint32 nodeId)
theFirstTransId = tFirstTransId + 1;
}//if
#ifdef VM_TRACE
if (tConnection->theListState != NotInList) {
if (tConnection->theListState != NdbConnection::NotInList) {
printState("startTransactionLocal %x", tConnection);
abort();
}
......@@ -589,7 +587,7 @@ Ndb::NdbTamper(TamperType aAction, int aNode)
tSignal.setData (tAction, 1);
tSignal.setData(tNdbConn->ptr2int(),2);
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();
if (tAction == 3) {
tp->lock_mutex();
......@@ -622,7 +620,7 @@ Ndb::NdbTamper(TamperType aAction, int aNode)
}//if
ret_code = sendRecSignal(tNode, WAIT_NDB_TAMPER, &tSignal, 0);
if (ret_code == 0) {
if (tNdbConn->Status() != Connected) {
if (tNdbConn->Status() != NdbConnection::Connected) {
theRestartGCI = 0;
}//if
releaseNdbCon(tNdbConn);
......@@ -637,6 +635,7 @@ Ndb::NdbTamper(TamperType aAction, int aNode)
return 0;
#endif
}
#if 0
/****************************************************************************
NdbSchemaCon* startSchemaTransaction();
......@@ -678,7 +677,7 @@ Ndb::closeSchemaTransaction(NdbSchemaCon* aSchemaCon)
theSchemaConToNdbList = NULL;
return;
}//Ndb::closeSchemaTransaction()
#endif
/*****************************************************************************
void RestartGCI(int aRestartGCI);
......
......@@ -29,7 +29,6 @@ Adjust: 971114 UABMNST First version.
******************************************************************************/
#include "API.hpp"
#include "NdbApiSignal.hpp"
#include <AttrType.hpp>
/**
* The following include includes
......
......@@ -31,7 +31,6 @@
#define NdbApiSignal_H
#include <kernel_types.h>
#include "AttrType.hpp"
#include "TransporterFacade.hpp"
#include <TransporterDefinitions.hpp>
#include "Ndb.hpp"
......
......@@ -1706,7 +1706,7 @@ NdbConnection::getTransactionId()
return theTransactionId;
}//NdbConnection::getTransactionId()
CommitStatusType
NdbConnection::CommitStatusType
NdbConnection::commitStatus()
{
return theCommitStatus;
......
......@@ -17,7 +17,6 @@
#include "NdbDictionaryImpl.hpp"
#include "API.hpp"
#include <NdbOut.hpp>
#include <AttrType.hpp>
#include "NdbApiSignal.hpp"
#include "TransporterFacade.hpp"
#include <signaldata/GetTabInfo.hpp>
......@@ -1257,7 +1256,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
NdbTableImpl & impl,
bool alter)
{
if((unsigned)impl.getNoOfPrimaryKeys() > MAXNROFTUPLEKEY){
if((unsigned)impl.getNoOfPrimaryKeys() > NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY){
m_error.code = 4317;
return -1;
}
......
......@@ -21,7 +21,6 @@
#include "NdbDictionaryImpl.hpp"
#include "API.hpp"
#include <NdbOut.hpp>
#include <AttrType.hpp>
#include "NdbApiSignal.hpp"
#include "TransporterFacade.hpp"
#include <signaldata/CreateEvnt.hpp>
......@@ -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
NdbEventOperationImpl::print()
......@@ -1294,3 +1248,60 @@ NdbGlobalEventBuffer::real_wait(NdbGlobalEventBufferHandle *h,
n += hasData(h->m_bufferIds[i]);
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,
m_accessTable = anIndex->m_table;
m_theIndexLen = 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++)
m_theIndexDefined[i][j] = false;
......@@ -221,7 +221,7 @@ int NdbIndexOperation::equal_impl(const NdbColumnImpl* tAttrInfo,
goto equal_error2;
}//if
}//if
} while (i < MAXNROFTUPLEKEY);
} while (i < NDB_MAX_ATTRIBUTES_IN_INDEX);
goto equal_error2;
} else {
goto equal_error1;
......@@ -695,7 +695,7 @@ NdbIndexOperation::receiveTCINDXREF( NdbApiSignal* aSignal)
theStatus = Finished;
theNdbCon->theReturnStatus = ReturnFailure;
theNdbCon->theReturnStatus = NdbConnection::ReturnFailure;
//--------------------------------------------------------------------------//
// If the transaction this operation belongs to consists only of simple reads
// we set the error code on the transaction object.
......
......@@ -31,7 +31,7 @@
#include "NdbApiSignal.hpp"
#include "NdbRecAttr.hpp"
#include "NdbUtil.hpp"
#include "ndbapi_limits.h"
#include <signaldata/TcKeyReq.hpp>
#include "NdbDictionaryImpl.hpp"
......@@ -163,7 +163,7 @@ NdbOperation::init(NdbTableImpl* tab, NdbConnection* myConnection){
m_currentTable = m_accessTable = tab;
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++)
theTupleKeyDefined[i][j] = false;
......
......@@ -31,7 +31,6 @@
#include "NdbConnection.hpp"
#include "Ndb.hpp"
#include "NdbRecAttr.hpp"
#include "AttrType.hpp"
#include "NdbUtil.hpp"
#include "NdbOut.hpp"
#include "NdbImpl.hpp"
......
......@@ -757,7 +757,7 @@ NdbOperation::receiveTCKEYREF( NdbApiSignal* aSignal)
theStatus = Finished;
theNdbCon->theReturnStatus = ReturnFailure;
theNdbCon->theReturnStatus = NdbConnection::ReturnFailure;
//-------------------------------------------------------------------------//
// If the transaction this operation belongs to consists only of simple reads
// we set the error code on the transaction object.
......
......@@ -31,7 +31,6 @@ Adjust: 991029 UABRONM First version.
#include "NdbConnection.hpp"
#include "Ndb.hpp"
#include "NdbRecAttr.hpp"
#include "AttrType.hpp"
#include "NdbUtil.hpp"
#include "Interpreter.hpp"
......@@ -69,7 +68,7 @@ NdbOperation::incCheck(const NdbColumnImpl* tNdbColumnImpl)
}
return tNdbColumnImpl->m_attrId;
} else {
if (theNdbCon->theCommitStatus == Started)
if (theNdbCon->theCommitStatus == NdbConnection::Started)
setErrorCodeAbort(4200);
}
return -1;
......@@ -121,7 +120,7 @@ NdbOperation::write_attrCheck(const NdbColumnImpl* tNdbColumnImpl)
}
return tNdbColumnImpl->m_attrId;
} else {
if (theNdbCon->theCommitStatus == Started)
if (theNdbCon->theCommitStatus == NdbConnection::Started)
setErrorCodeAbort(4200);
}
return -1;
......@@ -169,7 +168,7 @@ NdbOperation::read_attrCheck(const NdbColumnImpl* tNdbColumnImpl)
}
return tNdbColumnImpl->m_attrId;
} else {
if (theNdbCon->theCommitStatus == Started)
if (theNdbCon->theCommitStatus == NdbConnection::Started)
setErrorCodeAbort(4200);
}
return -1;
......@@ -209,7 +208,7 @@ NdbOperation::initial_interpreterCheck()
}
return 0;
} else {
if (theNdbCon->theCommitStatus == Started)
if (theNdbCon->theCommitStatus == NdbConnection::Started)
setErrorCodeAbort(4200);
}
return -1;
......@@ -235,7 +234,7 @@ NdbOperation::labelCheck()
}
return 0;
} else {
if (theNdbCon->theCommitStatus == Started)
if (theNdbCon->theCommitStatus == NdbConnection::Started)
setErrorCodeAbort(4200);
}
return -1;
......@@ -255,7 +254,7 @@ NdbOperation::intermediate_interpreterCheck()
}
return 0;
} else {
if (theNdbCon->theCommitStatus == Started)
if (theNdbCon->theCommitStatus == NdbConnection::Started)
setErrorCodeAbort(4200);
}
return -1;
......
......@@ -31,7 +31,7 @@ NdbOperation::openScanRead(Uint32 aParallelism)
{
aParallelism = checkParallelism(aParallelism);
if ((theNdbCon->theCommitStatus != Started) &&
if ((theNdbCon->theCommitStatus != NdbConnection::Started) &&
(theStatus != Init) &&
(aParallelism == 0)) {
setErrorCode(4200);
......@@ -48,7 +48,7 @@ NdbOperation::openScanExclusive(Uint32 aParallelism)
{
aParallelism = checkParallelism(aParallelism);
if ((theNdbCon->theCommitStatus != Started) &&
if ((theNdbCon->theCommitStatus != NdbConnection::Started) &&
(theStatus != Init) &&
(aParallelism == 0)) {
setErrorCode(4200);
......@@ -65,7 +65,7 @@ NdbOperation::openScanReadHoldLock(Uint32 aParallelism)
{
aParallelism = checkParallelism(aParallelism);
if ((theNdbCon->theCommitStatus != Started) &&
if ((theNdbCon->theCommitStatus != NdbConnection::Started) &&
(theStatus != Init) &&
(aParallelism == 0)) {
setErrorCode(4200);
......@@ -82,7 +82,7 @@ NdbOperation::openScanReadCommitted(Uint32 aParallelism)
{
aParallelism = checkParallelism(aParallelism);
if ((theNdbCon->theCommitStatus != Started) &&
if ((theNdbCon->theCommitStatus != NdbConnection::Started) &&
(theStatus != Init) &&
(aParallelism == 0)) {
setErrorCode(4200);
......
......@@ -35,7 +35,6 @@ Adjust: 971022 UABMNST First version.
#include <Ndb.hpp>
#include "NdbImpl.hpp"
#include <NdbOut.hpp>
#include "AttrType.hpp"
#include <AttributeHeader.hpp>
#include <signaldata/TcKeyReq.hpp>
......@@ -102,7 +101,7 @@ NdbOperation::equal_impl(const NdbColumnImpl* tAttrInfo,
goto equal_error2;
}//if
}//if
} while (i < MAXNROFTUPLEKEY);
} while (i < NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY);
goto equal_error2;
} else {
goto equal_error1;
......
......@@ -61,7 +61,8 @@ NdbResultSet::updateTuple(){
}
NdbScanOperation * op = (NdbScanOperation*)(m_operation);
return op->takeOverScanOp(UpdateRequest, op->m_transConnection);
return op->takeOverScanOp(NdbOperation::UpdateRequest,
op->m_transConnection);
}
NdbOperation*
......@@ -71,7 +72,8 @@ NdbResultSet::updateTuple(NdbConnection* takeOverTrans){
return 0;
}
return m_operation->takeOverScanOp(UpdateRequest, takeOverTrans);
return m_operation->takeOverScanOp(NdbOperation::UpdateRequest,
takeOverTrans);
}
int
......@@ -82,7 +84,8 @@ NdbResultSet::deleteTuple(){
}
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)
return -1;
return 0;
......@@ -95,7 +98,8 @@ NdbResultSet::deleteTuple(NdbConnection * takeOverTrans){
return 0;
}
void * res = m_operation->takeOverScanOp(DeleteRequest, takeOverTrans);
void * res = m_operation->takeOverScanOp(NdbOperation::DeleteRequest,
takeOverTrans);
if(res == 0)
return -1;
return 0;
......
......@@ -14,28 +14,31 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*********************************************************************
Name: NdbSchemaCon.C
Name: NdbSchemaCon.cpp
Include:
Link:
Author: UABMNST Mona Natterkvist UAB/B/SD
EMIKRON Mikael Ronstrom
Date: 020826
Version: 2.0
Description: Interface between application and NDB
Version: 3.0
Description: Old Interface between application and NDB
Documentation:
Adjust: 980126 UABMNST First 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 "NdbSchemaOp.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);
......
......@@ -16,24 +16,31 @@
/*****************************************************************************
Name: NdbSchemaOp.C
Name: NdbSchemaOp.cpp
Include:
Link:
Author: UABMNST Mona Natterkvist UAB/B/SD
EMIKRON Mikael Ronstrom
Date: 020826
Version: 2.0
Date: 040524
Version: 3.0
Description: Interface between application and NDB
Documentation: Handles createTable and createAttribute calls
Adjust: 980125 UABMNST First version.
020826 EMIKRON New version for new DICT
040524 Magnus Svensson - Adapted to not be included in public NdbApi
unless the user wants to use it.
NOTE: This file is only used as a compatibility layer for old test programs,
New programs should use NdbDictionary.hpp
*****************************************************************************/
#include <assert.h>
#include "NdbSchemaOp.hpp"
#include "NdbSchemaCon.hpp"
#include "API.hpp"
/*****************************************************************************
NdbSchemaOp(Ndb* aNdb, Table* aTable);
......@@ -203,3 +210,11 @@ NdbSchemaOp::init(NdbSchemaCon* aSchemaCon)
theSchemaCon = aSchemaCon;
return 0;
}//NdbSchemaOp::init()
const NdbError &
NdbSchemaOp::getNdbError() const
{
return theSchemaCon->getNdbError();
}
......@@ -30,7 +30,6 @@ Comment:
#define NdbUtil_H
#include <ndb_global.h>
#include "AttrType.hpp"
class NdbApiSignal;
class NdbOperation;
......
This diff is collapsed.
......@@ -17,8 +17,8 @@
#include "NdbApiSignal.hpp"
#include "NdbImpl.hpp"
#include "NdbSchemaOp.hpp"
#include "NdbSchemaCon.hpp"
//#include "NdbSchemaOp.hpp"
//#include "NdbSchemaCon.hpp"
#include "NdbOperation.hpp"
#include "NdbConnection.hpp"
#include "NdbRecAttr.hpp"
......@@ -72,8 +72,8 @@ Ndb::Ndb( const char* aDataBase , const char* aDataBaseSchema) :
theOpIdleList(NULL),
theScanOpIdleList(NULL),
theIndexOpIdleList(NULL),
theSchemaConIdleList(NULL),
theSchemaConToNdbList(NULL),
// theSchemaConIdleList(NULL),
// theSchemaConToNdbList(NULL),
theTransactionList(NULL),
theConnectionArray(NULL),
theRecAttrIdleList(NULL),
......@@ -207,8 +207,8 @@ Ndb::~Ndb()
NdbMutex_Unlock(&createNdbMutex);
if (theSchemaConToNdbList != NULL)
closeSchemaTransaction(theSchemaConToNdbList);
// if (theSchemaConToNdbList != NULL)
// closeSchemaTransaction(theSchemaConToNdbList);
while ( theConIdleList != NULL )
freeNdbCon();
while ( theSignalIdleList != NULL )
......
......@@ -16,8 +16,8 @@
#include <NdbOut.hpp>
#include "Ndb.hpp"
#include "NdbSchemaOp.hpp"
#include "NdbSchemaCon.hpp"
//#include "NdbSchemaOp.hpp"
//#include "NdbSchemaCon.hpp"
#include "NdbOperation.hpp"
#include "NdbScanOperation.hpp"
#include "NdbIndexOperation.hpp"
......@@ -104,7 +104,7 @@ Ndb::createConIdleList(int aNrOfCon)
tNdbCon->next(theConIdleList);
theConIdleList = tNdbCon;
}
tNdbCon->Status(NotConnected);
tNdbCon->Status(NdbConnection::NotConnected);
}
theNoOfAllocatedTransactions = aNrOfCon;
return aNrOfCon;
......@@ -770,7 +770,7 @@ Ndb::releaseConnectToNdb(NdbConnection* a_con)
tSignal.setData((tConPtr = a_con->getTC_ConnectPtr()), 1);
tSignal.setData(theMyRef, 2);
tSignal.setData(a_con->ptr2int(), 3);
a_con->Status(DisConnecting);
a_con->Status(NdbConnection::DisConnecting);
a_con->theMagicNumber = 0x37412619;
int ret_code = sendRecSignal(node_id,
WAIT_TC_RELEASE,
......
......@@ -16,7 +16,6 @@
#include <ndb_global.h>
#include <ndb_limits.h>
#include <AttrType.hpp>
#include "TransporterFacade.hpp"
#include "ClusterMgr.hpp"
#include <IPCConfig.hpp>
......
......@@ -17,7 +17,6 @@
#ifndef TransporterFacade_H
#define TransporterFacade_H
#include <AttrType.hpp>
#include <kernel_types.h>
#include <ndb_limits.h>
#include <NdbThread.h>
......@@ -43,6 +42,10 @@ extern "C" {
void atexit_stop_instance();
}
/**
* Max number of Ndb objects in different threads.
* (Ndb objects should not be shared by different threads.)
*/
class TransporterFacade
{
public:
......@@ -156,6 +159,8 @@ private:
/**
* Block number handling
*/
static const unsigned MAX_NO_THREADS = 4711;
struct ThreadData {
static const Uint32 ACTIVE = (1 << 16) | 1;
static const Uint32 INACTIVE = (1 << 16);
......
......@@ -25,66 +25,6 @@
class NDBT_Attribute : public NdbDictionary::Column {
friend class NdbOut& operator <<(class NdbOut&, const NDBT_Attribute &);
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,
Column::Type _type,
int _length = 1,
......@@ -132,4 +72,13 @@ NDBT_Table::discoverTableFromDb(Ndb* ndb, const char * 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
......@@ -15,6 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <NdbApi.hpp>
#include <NdbSchemaCon.hpp>
#include <NdbMutex.h>
#include <NdbOut.hpp>
#include <NdbSleep.h>
......@@ -230,7 +231,6 @@ extern "C" void* NdbThreadFuncInsert(void* pArg)
VerifyMethodInt(pNdbOperationW, setValue(c_szWarehouseSum, nWarehouseSum));
int iExec = pNdbConnection->execute(Commit);
int iError = pNdbConnection->getNdbError().code;
CommitStatusType cs = pNdbConnection->commitStatus();
if(iExec<0 && iError!=0 && iError!=266 && iError!=630) {
ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__);
......@@ -285,7 +285,6 @@ extern "C" void* NdbThreadFuncUpdate(void* pArg)
VerifyMethodInt(pNdbOperationW, setValue(c_szWarehouseSum, nWarehouseSum));
int iExec = pNdbConnection->execute(Commit);
int iError = pNdbConnection->getNdbError().code;
CommitStatusType cs = pNdbConnection->commitStatus();
if(iExec<0 && iError!=0 && iError!=266 && iError!=626) {
ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__);
......@@ -333,7 +332,6 @@ extern "C" void* NdbThreadFuncDelete(void* pArg)
}
int iExec = pNdbConnection->execute(Commit);
int iError = pNdbConnection->getNdbError().code;
CommitStatusType cs = pNdbConnection->commitStatus();
if(iExec<0 && iError!=0 && iError!=266 && iError!=626) {
ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__);
......@@ -389,7 +387,7 @@ extern "C" void* NdbThreadFuncRead(void* pArg)
}
int iExec = pNdbConnection->execute(Commit);
int iError = pNdbConnection->getNdbError().code;
CommitStatusType cs = pNdbConnection->commitStatus();
if(iExec<0 && iError!=0 && iError!=266 && iError!=626) {
ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__);
}
......@@ -465,8 +463,7 @@ NDB_COMMAND(acid, "acid", "acid", "acid", 65535)
VerifyMethodInt(pNdb, init());
VerifyMethodInt(pNdb, waitUntilReady());
NdbSchemaCon* pNdbSchemaCon = NULL ;
VerifyMethodPtr(pNdbSchemaCon, pNdb, startSchemaTransaction());
NdbSchemaCon* pNdbSchemaCon= NdbSchemaCon::startSchemaTrans(pNdb);
if(!pNdbSchemaCon){
ndbout <<"startSchemaTransaction failed, exiting now" << endl ;
delete pNdb ;
......@@ -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_szWarehouseCount, NoKey, 32, 1, UnSigned, MMBased, false));
VerifyMethodInt(pNdbSchemaCon, execute());
VerifyMethodVoid(pNdb, closeSchemaTransaction(pNdbSchemaCon));
NdbSchemaCon::closeSchemaTrans(pNdbSchemaCon);
VerifyMethodPtr(pNdbSchemaCon, pNdb, startSchemaTransaction());
pNdbSchemaCon= NdbSchemaCon::startSchemaTrans(pNdb);
VerifyMethodPtr(pNdbSchemaOp, pNdbSchemaCon, getNdbSchemaOp());
#if defined NDB_OSE || defined NDB_SOFTOSE
VerifyMethodInt(pNdbSchemaOp, createTable(
......@@ -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_szDistrictCount, NoKey, 32, 1, UnSigned, MMBased, false));
VerifyMethodInt(pNdbSchemaCon, execute());
VerifyMethodVoid(pNdb, closeSchemaTransaction(pNdbSchemaCon));
NdbSchemaCon::closeSchemaTrans(pNdbSchemaCon);
g_pNdbMutex = NdbMutex_Create();
NdbMutex_Lock(g_pNdbMutex);
......
......@@ -15,7 +15,9 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "NdbApi.hpp"
#include <NdbSchemaCon.hpp>
#include <NdbMain.h>
#include <md5_hash.hpp>
......@@ -738,7 +740,7 @@ createTables(Ndb* pMyNdb){
if (theTableCreateFlag == 0) {
for(int i=0; i < 1 ;i++) {
ndbout << "Creating " << tableName[i] << "..." << endl;
MySchemaTransaction = pMyNdb->startSchemaTransaction();
MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pMyNdb);
if(MySchemaTransaction == NULL &&
(!error_handler(MySchemaTransaction->getNdbError())))
......@@ -748,7 +750,8 @@ createTables(Ndb* pMyNdb){
if(MySchemaOp == NULL &&
(!error_handler(MySchemaTransaction->getNdbError())))
return -1;
check = MySchemaOp->createTable( tableName[i]
,8 // Table Size
,TupleKey // Key Type
......@@ -793,7 +796,7 @@ createTables(Ndb* pMyNdb){
(!error_handler(MySchemaTransaction->getNdbError())))
return -1;
pMyNdb->closeSchemaTransaction(MySchemaTransaction);
NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
}
}
......
......@@ -62,6 +62,7 @@
#include <NdbMain.h>
#include <NdbTest.hpp>
#include <NDBT_Error.hpp>
#include <NdbSchemaCon.hpp>
#define PKSIZE 1
#define FOREVER 1
......@@ -151,7 +152,6 @@ static void UpdateArray(int *attrValue)
int attrCount = 0;
int opCount = 0;
int sizeCount = 0;
int Index = 0;
int* pValue = attrValue;
for (tableCount = 0; tableCount < tNoOfTables; tableCount++) {
......@@ -179,7 +179,6 @@ static void Compare(int* attrValue, int* readValue)
int attrCount = 0;
int OpCount = 0;
int first = 0;
int sizeCount = 0;
for (tableCount = 0; tableCount < tNoOfTables; tableCount++) {
for (attrCount = 0; attrCount < tNoOfAttributes-1; attrCount++) {
......@@ -592,19 +591,14 @@ flexScanThread(void* ThreadData)
ThreadNdb* pThreadData = (ThreadNdb*)ThreadData;
unsigned int thread_no = pThreadData->ThreadNo;
unsigned int thread_base = (thread_no * 2000000) + (tNodeId * 26000);
int NrOfScannedRecords = 0;
int tThreadResult = 0;
Ndb* MyNdb = NULL;
NdbConnection *MyTransaction = NULL;
NdbOperation* MyOperation[MAXTABLES];
int check = 0;
StartType tType = stLast;
int* pkValue = NULL;
int* attrValue = NULL;
int* readValue = NULL;
int AllocSize = 0;
NdbRecAttr* tTmp = NULL;
OperationType opType;
AllocSize = tNoOfTables * (tNoOfAttributes-1) * tNoOfOperations *
tAttributeSize * sizeof(int);
......@@ -770,15 +764,15 @@ static int createTables(Ndb* pMyNdb)
do {
i++;
ndbout << endl << "Creating " << tableName[i - 1] << "..." << endl;
MySchemaTransaction = pMyNdb->startSchemaTransaction();
MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pMyNdb);
if( MySchemaTransaction == NULL ) {
return (-1);
} // if
MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
if( MySchemaOp == NULL ) {
pMyNdb->closeSchemaTransaction(MySchemaTransaction);
NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return (-1);
} // if
......@@ -800,14 +794,14 @@ static int createTables(Ndb* pMyNdb)
,40); // Nr of Pages
#endif
if (check == -1) {
pMyNdb->closeSchemaTransaction(MySchemaTransaction);
NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return -1;
} // if
check = MySchemaOp->createAttribute( (char*)attrName[0], TupleKey, 32, PKSIZE,
UnSigned, MMBased, NotNullAttribute );
if (check == -1) {
pMyNdb->closeSchemaTransaction(MySchemaTransaction);
NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return -1;
} // if
......@@ -815,7 +809,7 @@ static int createTables(Ndb* pMyNdb)
check = MySchemaOp->createAttribute( (char*)attrName[j], NoKey, 32, tAttributeSize,
UnSigned, MMBased, NotNullAttribute );
if (check == -1) {
pMyNdb->closeSchemaTransaction(MySchemaTransaction);
NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return -1;
} // if
} // for
......@@ -825,7 +819,7 @@ static int createTables(Ndb* pMyNdb)
ndbout << "Probably, " << tableName[i - 1] << " already exist" << endl;
} // if
pMyNdb->closeSchemaTransaction(MySchemaTransaction);
NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
} while (tNoOfTables > i);
}
......@@ -1058,7 +1052,6 @@ static int insertRows(Ndb* pNdb, // NDB object
int attrCount = 0;
NdbConnection* MyTransaction = NULL;
NdbOperation* MyOperations[MAXTABLES] = {NULL};
int Index = 0;
int opCount = 0;
for (opCount = 0; opCount < tNoOfOperations; opCount++) {
......@@ -1099,7 +1092,7 @@ static int insertRows(Ndb* pNdb, // NDB object
} // if
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;
check = MyOperations[tableCount]->
setValue((char*)attrName[attrCount + 1],
......
......@@ -58,6 +58,7 @@
#include <NdbThread.h>
#include <NdbMutex.h>
#include <NdbApi.hpp>
#include <NdbSchemaCon.hpp>
#include <NDBT.hpp>
#define MAXATTR 3
......@@ -93,8 +94,8 @@ TTYPE t_addReg(int, NdbOperation*);
TTYPE t_subReg(int, NdbOperation*);
TTYPE t_subroutineWithBranchLabel(int, NdbOperation*);
char tableName[MAXTABLES][MAXSTRLEN+1] = {0};
char attrName[MAXATTR][MAXSTRLEN+1] = {0};
char tableName[MAXSTRLEN+1];
char attrName[MAXATTR][MAXSTRLEN+1];
int attrValue[NUMBEROFRECORDS] = {0};
int pkValue[NUMBEROFRECORDS] = {0};
const int tAttributeSize = 1 ;
......@@ -105,11 +106,9 @@ int bTestPassed = 0;
int main(int argc, const char** argv) {
int tTableId = 0;
int operationType = 0;
int tupTest = 0 ;
int scanTest = 0 ;
bool loop = 0 ;
int tupTest = 0;
int scanTest = 0;
Ndb* pNdb = new Ndb("TEST_DB");
pNdb->init();
......@@ -140,7 +139,7 @@ int main(int argc, const char** argv) {
setAttrNames() ;
setTableNames() ;
const void * p = NDBT_Table::discoverTableFromDb(pNdb, tableName[0]);
const void * p = NDBT_Table::discoverTableFromDb(pNdb, tableName);
if (p != 0){
create_table(pNdb);
}
......@@ -252,18 +251,17 @@ void create_table(Ndb* pMyNdb) {
***************************************************************/
int check = -1 ;
NdbSchemaCon *MySchemaTransaction = 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);
MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
if( !MySchemaOp ) error_handler(MySchemaTransaction->getNdbError(), NO_FAIL);
// Create table
check = MySchemaOp->createTable( tableName[0],
check = MySchemaOp->createTable( tableName,
8, // Table size
TupleKey, // Key Type
40 // Nr of Pages
......@@ -305,7 +303,8 @@ void create_table(Ndb* pMyNdb) {
ndbout << tableName[0] << " created" << endl;
}
pMyNdb->closeSchemaTransaction(MySchemaTransaction);
NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return;
......@@ -333,7 +332,7 @@ void write_rows (Ndb* pMyNdb) {
error_handler(pMyNdb->getNdbError(), NO_FAIL);
}//if
MyOperation = MyTransaction->getNdbOperation(tableName[0]);
MyOperation = MyTransaction->getNdbOperation(tableName);
if (!MyOperation) {
error_handler(pMyNdb->getNdbError(), NO_FAIL);
}//if
......@@ -366,9 +365,6 @@ void verify_deleted(Ndb* pMyNdb) {
int check = -1 ;
int loop_count_ops = nRecords;
NdbRecAttr* tTmp;
int readValue[MAXATTR];
NdbConnection* pMyTransaction = NULL ;
NdbOperation* pMyOperation = NULL ;
ndbout << "Verifying deleted records..."<< flush;
......@@ -378,7 +374,7 @@ void verify_deleted(Ndb* pMyNdb) {
NdbConnection* pMyTransaction = pMyNdb->startTransaction();
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);
check = pMyOperation->readTuple();
......@@ -421,7 +417,7 @@ void read_and_verify_rows(Ndb* pMyNdb, bool pre) {
pMyTransaction = pMyNdb->startTransaction();
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);
......@@ -1232,14 +1228,13 @@ void scan_rows(Ndb* pMyNdb, int opType, int tupleType, int scanType) {
int readValue = 0 ;
int readValue2 = 0 ;
int scanCount = 0 ;
NdbRecAttr* tTmp = NULL ;
TTYPE fail = NO_FAIL ;
for (int count=0 ; count < loop_count_ops ; count++) {
NdbConnection* MyTransaction = pMyNdb->startTransaction();
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 (opType == 1)
......@@ -1306,7 +1301,7 @@ void scan_rows(Ndb* pMyNdb, int opType, int tupleType, int scanType) {
}else{
// Sends the SCAN_NEXTREQ signal(s) and reads the answer in TRANS_ID signals.
// SCAN_TABCONF or SCAN_TABREF is the confirmation.
while (eOf = MyTransaction->nextScanResult() == 0) {
while ((eOf = MyTransaction->nextScanResult()) == 0) {
ndbout << readValue <<"; ";
// Here we call takeOverScanOp for update of the tuple.
}
......@@ -1348,7 +1343,7 @@ void update_rows(Ndb* pMyNdb, int tupleType, int opType) {
return;
}//if
MyOperation = MyTransaction->getNdbOperation(tableName[0]);
MyOperation = MyTransaction->getNdbOperation(tableName);
if (MyOperation == NULL) {
error_handler(pMyNdb->getNdbError(), NO_FAIL);
return;
......@@ -1442,7 +1437,7 @@ void delete_rows(Ndb* pMyNdb, int tupleTest, int opType) {
MyTransaction = pMyNdb->startTransaction();
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) ;
check = MyOperation->interpretedDeleteTuple();
......@@ -1517,8 +1512,6 @@ inline void setAttrNames(){
inline void setTableNames(){
for (int i = 0; i < MAXTABLES; i++){
snprintf(tableName[i], MAXSTRLEN, "TAB%d", i);
}
snprintf(tableName, MAXSTRLEN, "TAB1");
}
......@@ -32,6 +32,7 @@
#include <NdbSleep.h>
#include "ndb_schema.hpp"
#include <NDBT.hpp>
#include <NdbSchemaCon.hpp>
/***************************************************************
* L O C A L C O N S T A N T S *
......@@ -141,13 +142,11 @@ extern int useIndexTables;
int
create_table_server(Ndb * pNDB){
create_table_server(Ndb * pNdb){
int check;
NdbSchemaCon * MySchemaTransaction = pNDB->startSchemaTransaction();
NdbSchemaCon * MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pNdb);
if( MySchemaTransaction == NULL )
error_handler("startSchemaTransaction", pNDB->getNdbError(), 0);
error_handler("startSchemaTransaction", pNdb->getNdbError(), 0);
NdbSchemaOp * MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
if( MySchemaOp == NULL )
......@@ -246,17 +245,17 @@ create_table_server(Ndb * pNDB){
error_handler("schemaTransaction->execute()",
MySchemaTransaction->getNdbError(), 0);
}
pNDB->closeSchemaTransaction(MySchemaTransaction);
NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return 0;
}
int
create_table_group(Ndb * pNDB){
create_table_group(Ndb * pNdb){
int check;
NdbSchemaCon * MySchemaTransaction = pNDB->startSchemaTransaction();
NdbSchemaCon * MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pNdb);
if( MySchemaTransaction == NULL )
error_handler("startSchemaTransaction", pNDB->getNdbError(), 0);
error_handler("startSchemaTransaction", pNdb->getNdbError(), 0);
NdbSchemaOp * MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
if( MySchemaOp == NULL )
......@@ -340,16 +339,16 @@ create_table_group(Ndb * pNDB){
error_handler("schemaTransaction->execute()",
MySchemaTransaction->getNdbError(), 0);
}
pNDB->closeSchemaTransaction(MySchemaTransaction);
NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return 0;
}
int
create_table_subscriber(Ndb * pNDB){
create_table_subscriber(Ndb * pNdb){
int check;
NdbSchemaCon * MySchemaTransaction = pNDB->startSchemaTransaction();
NdbSchemaCon * MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pNdb);
if( MySchemaTransaction == NULL )
error_handler("startSchemaTransaction", pNDB->getNdbError(), 0);
error_handler("startSchemaTransaction", pNdb->getNdbError(), 0);
NdbSchemaOp * MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
if( MySchemaOp == NULL )
......@@ -459,16 +458,16 @@ create_table_subscriber(Ndb * pNDB){
error_handler("schemaTransaction->execute()",
MySchemaTransaction->getNdbError(), 0);
}
pNDB->closeSchemaTransaction(MySchemaTransaction);
NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return 0;
}
int
create_table_session(Ndb * pNDB){
create_table_session(Ndb * pNdb){
int check;
NdbSchemaCon * MySchemaTransaction = pNDB->startSchemaTransaction();
NdbSchemaCon * MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pNdb);
if( MySchemaTransaction == NULL )
error_handler("startSchemaTransaction", pNDB->getNdbError(), 0);
error_handler("startSchemaTransaction", pNdb->getNdbError(), 0);
NdbSchemaOp * MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
if( MySchemaOp == NULL )
......@@ -533,29 +532,29 @@ create_table_session(Ndb * pNDB){
error_handler("schemaTransaction->execute()",
MySchemaTransaction->getNdbError(), 0);
}
pNDB->closeSchemaTransaction(MySchemaTransaction);
NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
return 0;
}
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);
if(pNDB->getDictionary()->getTable(name) != 0){
if(pNdb->getDictionary()->getTable(name) != 0){
printf(" it already exists\n");
return;
} else {
printf("\n");
}
function(pNDB);
function(pNdb);
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(GROUP_TABLE , create_table_group, pNDB);
create_table(SESSION_TABLE , create_table_session, pNDB);
create_table(SERVER_TABLE , create_table_server, pNDB);
create_table(SUBSCRIBER_TABLE, create_table_subscriber, pNdb);
create_table(GROUP_TABLE , create_table_group, pNdb);
create_table(SESSION_TABLE , create_table_session, pNdb);
create_table(SERVER_TABLE , create_table_server, pNdb);
return 0;
}
......@@ -570,23 +569,23 @@ userDbConnect(uint32 createDb, char *dbName)
{
NdbMutex_Lock(startupMutex);
Ndb * pNDB = new Ndb("");
Ndb * pNdb = new Ndb("");
//printf("Initializing...\n");
pNDB->init();
pNdb->init();
//printf("Waiting...");
while(pNDB->waitUntilReady() != 0){
while(pNdb->waitUntilReady() != 0){
//printf("...");
}
// printf("done\n");
if( createDb )
dbCreate(pNDB);
dbCreate(pNdb);
UserHandle * uh = new UserHandle;
uh->pNDB = pNDB;
uh->pNDB = pNdb;
uh->pCurrTrans = 0;
NdbMutex_Unlock(startupMutex);
......
......@@ -21,6 +21,7 @@
* *************************************************** */
#include "NdbApi.hpp"
#include "NdbSchemaCon.hpp"
#include <NdbOut.hpp>
#include <NdbMain.h>
#include <NdbTest.hpp>
......@@ -90,7 +91,7 @@ NDB_COMMAND(initronja, "initronja", "initronja", "initronja", 65535){
ndbout << endl << "Creating the table SHORT_REC" << "..." << endl;
MySchemaTransaction = pNdb->startSchemaTransaction();
MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pNdb);
if(!MySchemaTransaction) goto error_handler;
MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
if(!MySchemaOp) goto error_handler;
......@@ -148,11 +149,11 @@ NDB_COMMAND(initronja, "initronja", "initronja", "initronja", 65535){
ndbout << "SHORT_REC created " << endl;
}// if
pNdb->closeSchemaTransaction(MySchemaTransaction);
NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
ndbout << endl << "Creating the table LONG_REC..." << endl;
MySchemaTransaction = pNdb->startSchemaTransaction();
MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pNdb);
if(!MySchemaTransaction) goto error_handler;
MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
......@@ -212,7 +213,7 @@ NDB_COMMAND(initronja, "initronja", "initronja", "initronja", 65535){
ndbout << "LONG_REC created" << endl;
}// if
pNdb->closeSchemaTransaction(MySchemaTransaction);
NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
check = InsertRecords(pNdb, tNoOfRecords);
......@@ -234,7 +235,7 @@ NDB_COMMAND(initronja, "initronja", "initronja", "initronja", 65535){
error_handler:
ndbout << "SchemaTransaction returned error:" ;
ndbout << MySchemaTransaction->getNdbError() << endl;
pNdb->closeSchemaTransaction(MySchemaTransaction);
NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
delete pNdb ;
NDBT_ProgramExit(NDBT_FAILED) ;
exit(-1);
......
......@@ -17,6 +17,7 @@
#include <ndb_global.h>
#include <NdbApi.hpp>
#include <NdbSchemaCon.hpp>
#include <NdbCondition.h>
#include <NdbMutex.h>
#include <NdbSleep.h>
......@@ -849,7 +850,7 @@ int CreateCallContextTable(Ndb* pNdb, const char* szTableName, bool bStored)
NdbError err;
memset(&err, 0, sizeof(err));
NdbSchemaCon* pNdbSchemaCon = pNdb->startSchemaTransaction();
NdbSchemaCon* pNdbSchemaCon = NdbSchemaCon::startSchemaTrans(pNdb);
if(pNdbSchemaCon)
{
NdbSchemaOp* pNdbSchemaOp = pNdbSchemaCon->getNdbSchemaOp();
......@@ -874,7 +875,8 @@ int CreateCallContextTable(Ndb* pNdb, const char* szTableName, bool bStored)
}
else
err = pNdbSchemaCon->getNdbError();
pNdb->closeSchemaTransaction(pNdbSchemaCon);
NdbSchemaCon::closeSchemaTrans(pNdbSchemaCon);
}
else
err = pNdb->getNdbError();
......
......@@ -34,7 +34,7 @@
#include <NdbOut.hpp>
#include <NdbApi.hpp>
#include <NdbTest.hpp>
#include <NdbSchemaCon.hpp>
// limits
static int const MaxAttr = 64;
static int const MaxOper = 1000;
......@@ -99,7 +99,7 @@ ndberror(char const* fmt, ...)
if (tcon)
ndbout << "tcon: " << tcon->getNdbError() << endl;
if (top)
ndbout << "top : " << top->getNdbError() << endl;
ndbout << "top: " << top->getNdbError() << endl;
if (con)
ndbout << "con : " << con->getNdbError() << endl;
if (op)
......@@ -258,7 +258,7 @@ testcase(int flag)
if (ndb->waitUntilReady(30) < 0)
return ndberror("waitUntilReady");
if ((tcon = ndb->startSchemaTransaction()) == 0)
if ((tcon = NdbSchemaCon::startSchemaTrans(ndb)) == 0)
return ndberror("startSchemaTransaction");
if ((top = tcon->getNdbSchemaOp()) == 0)
return ndberror("getNdbSchemaOp");
......
......@@ -23,8 +23,8 @@
#include <Vector.hpp>
#include <random.h>
#include <NdbTick.h>
#include <AttrType.hpp>
#define MAX_NDB_OBJECTS 32678
#define CHECK(b) if (!(b)) { \
ndbout << "ERR: "<< step->getName() \
......@@ -79,7 +79,7 @@ int runTestMaxNdb(NDBT_Context* ctx, NDBT_Step* step){
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
<< i << " != " << oldi << endl;
result = NDBT_FAILED;
......
......@@ -121,7 +121,7 @@ int runVerifyInserts(NDBT_Context* ctx, NDBT_Step* step){
HugoOperations hugoOps(*ctx->getTab());
NdbRestarter restarter;
int restartGCI = pNdb->NdbTamper(ReadRestartGCI, 0);
int restartGCI = pNdb->NdbTamper(Ndb::ReadRestartGCI, 0);
ndbout << "restartGCI = " << restartGCI << endl;
int count = 0;
......
......@@ -17,6 +17,7 @@
#include <ndb_global.h>
#include "NDBT_ResultRow.hpp"
#include <NdbOut.hpp>
#include <NdbSchemaCon.hpp>
NDBT_ResultRow::NDBT_ResultRow(const NdbDictionary::Table& tab,
char attrib_delimiter)
......@@ -109,6 +110,12 @@ BaseString NDBT_ResultRow::c_str() {
return str;
}
/**
* TODO This could chare the sanme printer function as in
* NdbEventOperationImpl.cpp, using new types of course :)
*/
NdbOut &
operator << (NdbOut& ndbout, const NDBT_ResultRow & res) {
for(int i = 0; i<res.cols; i++){
......@@ -117,7 +124,7 @@ operator << (NdbOut& ndbout, const NDBT_ResultRow & res) {
else{
const int size = res.data[i]->attrSize();
const int aSize = res.data[i]->arraySize();
switch(res.data[i]->attrType()){
switch(convertColumnTypeToAttrType(res.data[i]->getType())){
case UnSigned:
switch(size){
case 8:
......@@ -174,7 +181,8 @@ operator << (NdbOut& ndbout, const NDBT_ResultRow & res) {
break;
default:
ndbout << "Unknown(" << res.data[i]->attrType() << ")";
ndbout << "Unknown(" <<
convertColumnTypeToAttrType(res.data[i]->getType()) << ")";
break;
}
}
......
......@@ -26,7 +26,7 @@ operator <<(class NdbOut& ndbout, const NDBT_Attribute & attr){
bool key = attr.getPrimaryKey();
bool null = attr.getNullable();
ndbout << attr.getName() << "\t";
ndbout << attr.getName() << " ";
char tmp[100];
if(attr.getLength() != 1)
snprintf(tmp, 100," [%d]", attr.getLength());
......@@ -103,16 +103,16 @@ operator <<(class NdbOut& ndbout, const NDBT_Attribute & attr){
ndbout << "Unknown(" << type << ")";
}
ndbout << "\t";
ndbout << " ";
if(null){
ndbout << "NULL";
} else {
ndbout << "NOT NULL";
}
ndbout << "\t";
ndbout << " ";
if(key)
ndbout << "\tprimary key";
ndbout << "PRIMARY KEY";
return ndbout;
}
......@@ -130,6 +130,9 @@ operator <<(class NdbOut& ndbout, const NDBT_Table & tab)
ndbout << "Temporary table: " << (tab.getStoredTable() ? "no" : "yes") << endl;
ndbout << "Number of attributes: " << tab.getNoOfColumns() << endl;
ndbout << "Number of primary keys: " << tab.getNoOfPrimaryKeys() << endl;
ndbout << "Length of frm data: " << tab.getFrmLength() << endl;
//<< ((tab.getTupleKey() == TupleId) ? " tupleid" : "") <<endl;
ndbout << "TableStatus: ";
switch(tab.getObjectStatus()){
......@@ -154,3 +157,32 @@ operator <<(class NdbOut& ndbout, const NDBT_Table & tab)
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,
}
switch (pIndex->getType()){
case UniqueHashIndex:
case OrderedIndex:
case NdbDictionary::Index::UniqueHashIndex:
case NdbDictionary::Index::OrderedIndex:
return verifyUniqueIndex(pNdb, indexName, parallelism, transactional);
break;
default:
......
......@@ -19,19 +19,19 @@
#include <NdbApi.hpp>
int main(int argc, const char** argv){
const char* _tabname = NULL;
const char* _dbname = "TEST_DB";
int _frm = 0;
int _unqualified = 0;
int _help = 0;
struct getargs args[] = {
{ "unqualified", 'u', arg_integer, &_unqualified, "unqualified",
{ "unqualified", 'u', arg_flag, &_unqualified, "unqualified",
"Use unqualified table names"},
{ "database", 'd', arg_string, &_dbname, "dbname",
"Name of database table is in"},
{ "frm-data", 'f', arg_flag, &_frm, "Show frm data for table", "" } ,
{ "usage", '?', arg_flag, &_help, "Print help", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
......@@ -62,15 +62,40 @@ int main(int argc, const char** argv){
NdbDictionary::Dictionary * dict = pMyNdb->getDictionary();
for (int i = optind; i < argc; i++) {
NDBT_Table* pTab = (NDBT_Table*)dict->getTable(argv[i]);
if (pTab != 0) {
if (pTab != 0){
ndbout << (* pTab) << endl;
if (_frm){
ndbout << "getFrmLength: "<< endl
<< pTab->getFrmLength() << endl;
}
} else {
ndbout << argv[i] << ": " << dict->getNdbError() << endl;
NdbDictionary::Dictionary::List list;
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 << ", ";
}
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;
return NDBT_ProgramExit(NDBT_FAILED);
}
ndbout << (*pIdx) << endl;
}
ndbout << endl;
}
else
ndbout << argv[i] << ": " << dict->getNdbError() << endl;
}
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