2
/* ndb-connectors: Wrappers for the NDBAPI
3
Copyright (C) 2006 MySQL, Inc.
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2 of the License, or
8
(at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
%include "ndb_constants.h"
30
#if defined(SWIG_PYTHON)
40
CommitAsMuchAsPossible = 2,
52
typedef unsigned long long Uint64;
53
typedef unsigned int Uint32;
54
typedef signed long long Int64;
55
typedef signed int Int32;
58
/*%include "cluster.hpp"*/
60
class Ndb_cluster_connection {
64
Ndb_cluster_connection(const char * connectstring = 0);
65
~Ndb_cluster_connection();
70
const char * msg = "Connect to management server failed";
71
#if defined(SWIGPYTHON)
72
PyErr_SetString(PyExc_RuntimeError, msg);
73
return PyInt_FromLong(-1);
76
jclass clazz = jenv->FindClass("java/lang/RuntimeException");
77
jenv->ThrowNew(clazz, msg);
83
int connect(int no_retries=0, int retry_delay_in_seconds=1, int verbose=0);
84
int wait_until_ready(int timeout_for_first_alive,
85
int timeout_after_first_alive);
89
%extend Ndb_cluster_connection {
91
Ndb* getNdb(const char* aCatalogName="", const char* aSchemaName="def") {
92
Ndb* myNdb = new Ndb(self,aCatalogName,aSchemaName);
100
Ndb(Ndb_cluster_connection *ndb_cluster_connection,
101
const char* aCatalogName = "", const char* aSchemaName = "def");
106
int init(int maxNoOfTransactions = 4);
109
int waitUntilReady(int timeout = 60);
110
const NdbError & getNdbError() const;
112
%exception startTransaction {
115
NdbError err = arg1->getNdbError();
117
PyErr_SetString(PyExc_RuntimeError, err.message);
121
NdbTransaction* startTransaction(const NdbDictionary::Table *table= 0,
122
const char *keyData = 0,
125
int getAutoIncrementValue(const char* aTableName,
126
Uint64 & tupleId, Uint32 cacheSize);
127
void closeTransaction(NdbTransaction*);
132
NdbTransaction* startTransaction(const char* aTableName,
133
const char *keyData) {
134
const NdbDictionary::Dictionary *myDict = self->getDictionary();
135
const NdbDictionary::Table *myTable = myDict->getTable(aTableName);
136
return self->startTransaction(myTable,keyData);
138
NdbTransaction* startTransaction(const char* aTableName,
140
const NdbDictionary::Dictionary *myDict = self->getDictionary();
141
const NdbDictionary::Table *myTable = myDict->getTable(aTableName);
142
return self->startTransaction(myTable,(const char *) &keyData);
145
Uint64 getAutoIncrementValue(const char* aTableName,
149
self->getAutoIncrementValue(aTableName,id,cacheSize);
154
class NdbTransaction {
156
NdbTransaction(Ndb* aNdb);
159
NdbOperation* getNdbOperation(const char* aTableName);
160
NdbScanOperation* getNdbScanOperation(const char* aTableName);
161
const NdbError & getNdbError() const;
162
int execute(ExecType execType,
163
AbortOption abortOption = AbortOnError,
171
friend class NdbTransaction;
172
friend class NdbScanOperation;
173
friend class NdbScanReceiver;
174
friend class NdbScanFilter;
175
friend class NdbScanFilterImpl;
176
friend class NdbReceiver;
177
friend class NdbBlob;
182
PrimaryKeyAccess = 0,
183
UniqueIndexAccess = 1,
185
OrderedIndexScan = 3,
191
LM_CommittedRead = 2,
197
#if defined(SWIGPYTHON)
199
%rename(setValueU) setValue(const char *, Uint32);
200
%rename(setValueU64) setValue(const char *, Uint64);
202
%rename(setVal) setValue(const char* anAttrName, const char* aValue);
203
%rename(setVal) setValue(const char* anAttrName, Int32 aValue);
204
%rename(setVal) setValue(const char* anAttrName, Uint32 aValue);
205
%rename(setVal) setValue(const char* anAttrName, Uint64 aValue);
206
%rename(setVal) setValue(const char* anAttrName, Int64 aValue);
207
%rename(setVal) setValue(const char* anAttrName, float aValue);
208
%rename(setVal) setValue(const char* anAttrName, double aValue);
209
%rename(setVal) setValue(Uint32 anAttrId, const char* aValue);
210
%rename(setVal) setValue(Uint32 anAttrId, Int32 aValue);
211
%rename(setVal) setValue(Uint32 anAttrId, Uint32 aValue);
212
%rename(setVal) setValue(Uint32 anAttrId, Int64 aValue);
213
%rename(setVal) setValue(Uint32 anAttrId, Uint64 aValue);
214
%rename(setVal) setValue(Uint32 anAttrId, float aValue);
215
%rename(setVal) setValue(Uint32 anAttrId, double aValue);
220
int setValue(const char* anAttrName, const char* aValue);
221
int setValue(const char* anAttrName, Int32 aValue);
222
int setValue(const char* anAttrName, Uint32 aValue);
223
int setValue(const char* anAttrName, Uint64 aValue);
224
int setValue(const char* anAttrName, Int64 aValue);
225
int setValue(const char* anAttrName, float aValue);
226
int setValue(const char* anAttrName, double aValue);
227
int setValue(Uint32 anAttrId, const char* aValue);
228
int setValue(Uint32 anAttrId, Int32 aValue);
229
int setValue(Uint32 anAttrId, Uint32 aValue);
230
int setValue(Uint32 anAttrId, Int64 aValue);
231
int setValue(Uint32 anAttrId, Uint64 aValue);
232
int setValue(Uint32 anAttrId, float aValue);
233
int setValue(Uint32 anAttrId, double aValue);
236
const NdbError & getNdbError() const;
239
virtual int insertTuple();
241
#if defined(SWIGPYTHON)
242
%rename(equalU) equal(const char*, Uint32);
243
%rename(equalU64) equal(const char*, Uint64);
244
%rename(equalU) equal(Uint32, Uint32);
245
%rename(equalU64) equal(Uint32, Uint64);
249
int equal(const char* anAttrName, const char* aValue);
250
int equal(const char* anAttrName, Uint32 aValue);
251
int equal(const char* anAttrName, Int32 aValue);
252
int equal(const char* anAttrName, Int64 aValue);
253
int equal(const char* anAttrName, Uint64 aValue);
254
int equal(Uint32 anAttrId, const char* aValue);
255
int equal(Uint32 anAttrId, Int32 aValue);
256
int equal(Uint32 anAttrId, Uint32 aValue);
257
int equal(Uint32 anAttrId, Int64 aValue);
258
int equal(Uint32 anAttrId, Uint64 aValue);
262
NdbOperation(Ndb* aNdb, Type aType = PrimaryKeyAccess);
263
virtual ~NdbOperation();
270
Success = ndberror_st_success,
271
TemporaryError = ndberror_st_temporary,
272
PermanentError = ndberror_st_permanent,
273
UnknownResult = ndberror_st_unknown
276
enum Classification {
277
NoError = ndberror_cl_none,
278
ApplicationError = ndberror_cl_application,
279
NoDataFound = ndberror_cl_no_data_found,
280
ConstraintViolation = ndberror_cl_constraint_violation,
281
SchemaError = ndberror_cl_schema_error,
282
UserDefinedError = ndberror_cl_user_defined,
283
InsufficientSpace = ndberror_cl_insufficient_space,
284
TemporaryResourceError = ndberror_cl_temporary_resource,
285
NodeRecoveryError = ndberror_cl_node_recovery,
286
OverloadError = ndberror_cl_overload,
287
TimeoutExpired = ndberror_cl_timeout_expired,
288
UnknownResultError = ndberror_cl_unknown_result,
289
InternalError = ndberror_cl_internal_error,
290
FunctionNotImplemented = ndberror_cl_function_not_implemented,
291
UnknownErrorCode = ndberror_cl_unknown_error_code,
292
NodeShutdown = ndberror_cl_node_shutdown,
293
SchemaObjectExists = ndberror_cl_schema_object_already_exists,
294
InternalTemporary = ndberror_cl_internal_temporary
298
Classification classification;
301
const char * message;
306
status = UnknownResult;
307
classification = NoError;
313
NdbError(const ndberror_struct & ndberror){
314
status = (NdbError::Status) ndberror.status;
315
classification = (NdbError::Classification) ndberror.classification;
316
code = ndberror.code;
317
mysql_code = ndberror.mysql_code;
318
message = ndberror.message;
319
details = ndberror.details;
321
operator ndberror_struct() const {
322
ndberror_struct ndberror;
323
ndberror.status = (ndberror_status_enum) status;
324
ndberror.classification = (ndberror_classification_enum) classification;
325
ndberror.code = code;
326
ndberror.mysql_code = mysql_code;
327
ndberror.message = message;
328
ndberror.details = details;
334
const char * getMessage() {
335
return self->message;
339
/* -*- mode: c++ -*- */