From: Monty Taylor Date: April 27 2007 11:21pm Subject: Rev 88: Merged changes from Mika: in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/mika-merge List-Archive: http://lists.mysql.com/ndb-connectors/49 Message-Id: ------------------------------------------------------------ revno: 88 revision-id: monty@stripped parent: monty@stripped parent: mikie@stripped committer: Monty Taylor branch nick: mika-merge timestamp: Fri 2007-04-27 16:20:52 -0700 message: Merged changes from Mika: support for NdbIndexOperation and NdbIndexScanOperation preliminary support for reading strings for all target languages preliminary support for reading values as appropriate types for perl added: perl/swig/perl_extend_ndbrecattr.i perl_extend_ndbrecat-20070426144041-56zrx1r6lro1c0px-1 perl/swig/perl_ndbrecattr_typemap.i perl_ndbrecattr_type-20070426145807-eyq5m0w83sabygjh-1 swig/NdbIndexOperation.i ndbindexoperation.i-20070426125056-cdc2fzutv5osp12a-1 swig/NdbIndexScanOperation.i ndbindexscanoperatio-20070426125039-esztodu0kcqbofgn-1 modified: acinclude.m4 acinclude.m4-20070228020914-u2pk759xg7thauwf-8 perl/ndbapi.i ndb.i-20070225155255-5ief7aicto319mbu-1 perl/swig/perl_callback_typemap.i perl_callback_typema-20070323110355-zppwqruk69m5t3hz-1 perl/swig/perl_extend_ndbtransaction_async.i perl_extend_ndbtrans-20070323110355-zppwqruk69m5t3hz-2 swig/NdbDictionary.i ndbdictionary.i-20070323110251-l7mg72hiddtuzeh0-1 swig/NdbOperation.i ndboperation.i-20070228021421-qkr4cbpxymyqdrf3-3 swig/NdbRecAttr.i ndbrecattr.i-20070228021421-qkr4cbpxymyqdrf3-4 swig/NdbTransaction.i ndbtransaction.i-20070227184716-ecjyhh3jgvmye4de-7 swig/globals.i globals.i-20070228021421-qkr4cbpxymyqdrf3-7 ------------------------------------------------------------ revno: 83.1.1 merged: mikie@stripped parent: monty@stripped committer: Mika Raento branch nick: devel-mine-new3 timestamp: Thu 2007-04-26 18:30:02 +0300 message: support for NdbIndexOperation and NdbIndexScanOperation preliminary support for reading strings for all target languages preliminary support for reading values as appropriate types for perl === added file 'perl/swig/perl_extend_ndbrecattr.i' --- a/perl/swig/perl_extend_ndbrecattr.i 1970-01-01 00:00:00 +0000 +++ b/perl/swig/perl_extend_ndbrecattr.i 2007-04-26 15:30:02 +0000 @@ -0,0 +1,6 @@ +%extend NdbRecAttr { +public: + void value_any(const NdbRecAttr** OutValueProxy) { + *OutValueProxy=self; + } +}; === added file 'perl/swig/perl_ndbrecattr_typemap.i' --- a/perl/swig/perl_ndbrecattr_typemap.i 1970-01-01 00:00:00 +0000 +++ b/perl/swig/perl_ndbrecattr_typemap.i 2007-04-26 15:30:02 +0000 @@ -0,0 +1,41 @@ +%typemap(in, numinputs=0) const NdbRecAttr** OutValueProxy (NdbRecAttr* temp) { + temp=0; + $1=&temp; +} + +%typemap(argout) const NdbRecAttr** OutValueProxy { + NdbRecAttr* rec=*$1; + if (rec->isNULL()==-1) { + croak("record not fetched"); + } + if (rec->isNULL()) { + $result=newSV(0); + } else { + switch(rec->getType()) { + case NDB_TYPE_CHAR: + case NDB_TYPE_BINARY: + $result=newSVpv(rec->aRef(), rec->get_size_in_bytes()); + break; + case NDB_TYPE_VARCHAR: + case NDB_TYPE_VARBINARY: + const char* buf=rec->aRef(); + int len=buf[0]; + buf++; + $result=newSVpv(buf, len); + break; + case NDB_TYPE_TINYINT: + $result=newSViv(rec->char_value()); + break; + case NDB_TYPE_SMALLINT: + $result=newSViv(rec->short_value()); + break; + case NDB_TYPE_MEDIUMINT: + $result=newSViv(sint3korr(rec->aRef())); + break; + case NDB_TYPE_INT: + $result=newSViv(rec->int32_value()); + break; + } + } + argvi++; +} === added file 'swig/NdbIndexOperation.i' --- a/swig/NdbIndexOperation.i 1970-01-01 00:00:00 +0000 +++ b/swig/NdbIndexOperation.i 2007-04-26 15:30:02 +0000 @@ -0,0 +1,51 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +class NdbIndexOperation : public NdbOperation +{ +public: + + %exception { // this applies to everything until we clear it + $action + if (result==-1) { + NdbError err = arg1->getNdbError(); + SWIG_exception(SWIG_RuntimeError,err.message); + } + } + + /** insert is not allowed */ + int insertTuple(); + int readTuple(LockMode); + int updateTuple(); + int deleteTuple(); + + + int interpretedUpdateTuple(); + int interpretedDeleteTuple(); + + %exception { // this applies to everything until we clear it + $action + if (result==0) { + NdbError err = arg1->getNdbError(); + SWIG_exception(SWIG_RuntimeError,err.message); + } + } + + const NdbDictionary::Index * getIndex() const; + +private: + NdbIndexOperation(Ndb* aNdb); + ~NdbIndexOperation(); +}; === added file 'swig/NdbIndexScanOperation.i' --- a/swig/NdbIndexScanOperation.i 1970-01-01 00:00:00 +0000 +++ b/swig/NdbIndexScanOperation.i 2007-04-26 15:30:02 +0000 @@ -0,0 +1,41 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +class NdbIndexScanOperation : public NdbScanOperation { +public: + virtual int readTuples(LockMode lock_mode = LM_Read, + Uint32 scan_flags = 0, + Uint32 parallel = 0, + Uint32 batch = 0); + enum BoundType { + BoundLE = 0, ///< lower bound + BoundLT = 1, ///< lower bound, strict + BoundGE = 2, ///< upper bound + BoundGT = 3, ///< upper bound, strict + BoundEQ = 4 ///< equality + }; + int setBound(const char* attr, int type, const void* value); + int setBound(Uint32 anAttrId, int type, const void* aValue); + + int reset_bounds(bool forceSend = false); + int end_of_bound(Uint32 range_no); + int get_range_no(); + bool getSorted() const; + bool getDescending(); + +private: + NdbIndexScanOperation(Ndb* aNdb); + virtual ~NdbIndexScanOperation(); +}; === modified file 'acinclude.m4' --- a/acinclude.m4 2007-04-15 09:56:16 +0000 +++ b/acinclude.m4 2007-04-26 15:30:02 +0000 @@ -139,6 +139,7 @@ ADDIFLAGS="$ADDIFLAGS $IBASE/ndb" ADDIFLAGS="$ADDIFLAGS $IBASE/ndb/ndbapi" ADDIFLAGS="$ADDIFLAGS $IBASE/ndb/mgmapi" + ADDIFLAGS="$ADDIFLAGS $IBASE" CFLAGS="$CFLAGS $ADDFLAGS $ADDIFLAGS" CXXFLAGS="$CXXFLAGS $ADDFLAGS $ADDIFLAGS" === modified file 'perl/ndbapi.i' --- a/perl/ndbapi.i 2007-04-27 05:23:30 +0000 +++ b/perl/ndbapi.i 2007-04-27 23:20:52 +0000 @@ -4,6 +4,7 @@ %{ #undef SWIG_exception #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) +#include %} %include "perl_callback_typemap.i" %include "NdbFactory.i" @@ -13,7 +14,11 @@ %include "perl_extend_ndbtransaction_async.i" %include "NdbOperation.i" %include "NdbScanOperation.i" +%include "NdbIndexOperation.i" +%include "NdbIndexScanOperation.i" +%include "perl_ndbrecattr_typemap.i" %include "NdbRecAttr.i" +%include "perl_extend_ndbrecattr.i" %include "NdbError.i" %include "NdbBlob.i" %include "NdbDictionary.i" === modified file 'perl/swig/perl_callback_typemap.i' --- a/perl/swig/perl_callback_typemap.i 2007-04-15 08:50:19 +0000 +++ b/perl/swig/perl_callback_typemap.i 2007-04-26 15:30:02 +0000 @@ -1,12 +1,3 @@ - -%typemap(in) SV* pFcn { - if (!SvROK($input)) - croak("Expected a reference.\n"); - if (SvTYPE($input)!=SVt_PVCV) - croak("Expected a CODEREF.\n"); - $1 = SvRV($input); -} - %{ /* This function matches the prototype of the normal C callback function for our widget. However, we use the clientdata pointer === modified file 'perl/swig/perl_extend_ndbtransaction_async.i' --- a/perl/swig/perl_extend_ndbtransaction_async.i 2007-04-15 08:50:19 +0000 +++ b/perl/swig/perl_extend_ndbtransaction_async.i 2007-04-26 15:30:02 +0000 @@ -1,9 +1,9 @@ %extend NdbTransaction { void executeAsynchPrepare(ExecType execType, - SV* func, + SV* pFcn, AbortOption abortOption = AbortOnError) { - self->executeAsynchPrepare(execType,PerlCallBack,(void *)func,abortOption); SvREFCNT_inc(func); + self->executeAsynchPrepare(execType,PerlCallBack,(void *)pFcn,abortOption); SvREFCNT_inc(pFcn); }; }; === modified file 'swig/NdbDictionary.i' --- a/swig/NdbDictionary.i 2007-03-24 00:15:41 +0000 +++ b/swig/NdbDictionary.i 2007-04-26 15:30:02 +0000 @@ -304,6 +304,13 @@ #endif const struct NdbError & getNdbError() const; + %exception { + $action + if (result==NULL) { + NdbError err = arg1->getNdbError(); + SWIG_exception(SWIG_RuntimeError,err.message); + } + } const NdbDictionary::Table * getTable(const char * name) const; const NdbDictionary::Index * getIndex(const char * indexName, const char * tableName) const; @@ -312,6 +319,13 @@ const NdbDictionary::Table & table) const; #endif + %exception { + $action + if (result==-1) { + NdbError err = arg1->getNdbError(); + SWIG_exception(SWIG_RuntimeError,err.message); + } + } #if 0 int listIndexes(List & list, const char * tableName); int listIndexes(List & list, const char * tableName) const; @@ -320,15 +334,16 @@ int dropTable(NdbDictionary::Table & table); int dropTable(const char * name); int alterTable(const NdbDictionary::Table &table); - void invalidateTable(const char * name); - void removeCachedTable(const char * table); - void removeCachedIndex(const char * index, const char * table); int createIndex(const NdbDictionary::Index &index); int dropIndex(const char * indexName, const char * tableName); #if defined(MYSQL_50) int dropIndex(const NdbDictionary::Index &); #endif + %exception; + void invalidateTable(const char * name); + void removeCachedTable(const char * table); + void removeCachedIndex(const char * index, const char * table); void invalidateIndex(const char * indexName, const char * tableName); private: === modified file 'swig/NdbOperation.i' --- a/swig/NdbOperation.i 2007-03-23 11:14:00 +0000 +++ b/swig/NdbOperation.i 2007-04-26 15:30:02 +0000 @@ -226,6 +226,30 @@ NdbRecAttr* getValue(const NdbDictionary::Column* col) { return self->getValue(col,NULL); } - + int equalNull(const char* anAttrName) { + return self->equal(anAttrName, (char*)0); + } + int equalNull(Uint32 anAttrId) { + return self->equal(anAttrId, (char*)0); + } + %cstring_input_binary(const char *aString, size_t len); + int equalString(const char* anAttrName, const char* aString, size_t len) { + if (len>65535) return -1; + if (len<256) { + char buf[257]; + unsigned char lowb=len; + buf[0]=lowb; + memcpy(buf+1, aString, len); + return self->equal(anAttrName, buf); + } else { + char* buf=(char*)malloc(len+2); + unsigned char lowb=len & 0xff; + unsigned char highb=len << 8; + buf[0]=highb; + buf[1]=lowb; + memcpy(buf+2, aString, len); + return self->equal(anAttrName, buf); + } + } }; === modified file 'swig/NdbRecAttr.i' --- a/swig/NdbRecAttr.i 2007-02-28 07:08:22 +0000 +++ b/swig/NdbRecAttr.i 2007-04-26 15:30:02 +0000 @@ -49,5 +49,18 @@ int y = (int)x; return y; } + %cstring_output_allocate_size(char ** s, int *slen, void()) + void string_value(char ** s, int *slen) { + char* ref=self->aRef(); + if ( self->getType() == NDB_TYPE_VARCHAR) { + *slen=ref[0]; + ref++; + *s=ref; + } else { + *slen=self->get_size_in_bytes(); + *s=ref; + } + } + }; === modified file 'swig/NdbTransaction.i' --- a/swig/NdbTransaction.i 2007-04-24 23:41:52 +0000 +++ b/swig/NdbTransaction.i 2007-04-26 15:30:02 +0000 @@ -27,23 +27,19 @@ const NdbError & getNdbError() const; - %exception getNdbOperation { + %exception { $action if (result==NULL) { NdbError err = arg1->getNdbError(); - SWIG_exception(SWIG_RuntimeError,err.message); + SWIG_exception(SWIG_RuntimeError,err.message); } } NdbOperation* getNdbOperation(const class NdbDictionary::Table* aTable); NdbOperation* getNdbOperation(const char* aTableName); - %exception { - $action - if (result==NULL) { - NdbError err = arg1->getNdbError(); - SWIG_exception(SWIG_RuntimeError,err.message); - } - } + NdbIndexScanOperation* getNdbIndexScanOperation(const NdbDictionary::Index *anIndex); + NdbIndexOperation* getNdbIndexOperation(const NdbDictionary::Index *anIndex); + NdbScanOperation* getNdbScanOperation(const class NdbDictionary::Table* aTable); NdbScanOperation* getNdbScanOperation(const char* aTableName); NdbOperation* getNdbErrorOperation(); === modified file 'swig/globals.i' --- a/swig/globals.i 2007-02-28 07:08:22 +0000 +++ b/swig/globals.i 2007-04-26 15:30:02 +0000 @@ -1,6 +1,7 @@ %include "typemaps.i" %include "exception.i" +%include "cstring.i" %{ #include