List:NDB Connectors« Previous MessageNext Message »
From:Monty Taylor Date:August 30 2007 5:38am
Subject:Rev 142: Merged in changes from ndbjmerge tree. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel
View as plain text  
At http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel

------------------------------------------------------------
revno: 142
revision-id: mtaylor@stripped
parent: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: devel
timestamp: Wed 2007-08-29 22:38:33 -0700
message:
  Merged in changes from ndbjmerge tree.
modified:
  swig/NdbRecAttr.i              ndbrecattr.i-20070228021421-qkr4cbpxymyqdrf3-4
  swig/NdbScanFilter.i           ndbscanfilter.i-20070521223726-lvjwmtu5b6uvgsft-1
    ------------------------------------------------------------
    revno: 140.1.1
    revision-id: mtaylor@stripped
    parent: johan@stingray-20070802163619-e2c9121956414ff4
    committer: Monty Taylor <mtaylor@stripped>
    branch nick: ndbjmerge
    timestamp: Wed 2007-08-29 22:34:54 -0700
    message:
      Added length calculations for NdbScanFilter::cmp (thanks JD) 
      Fixed (?) exception thrown by NdbRecAttr::getTimestamp. Seems like there's no way
for this to thrown an exception? 
    modified:
      swig/NdbRecAttr.i              ndbrecattr.i-20070228021421-qkr4cbpxymyqdrf3-4
      swig/NdbScanFilter.i           ndbscanfilter.i-20070521223726-lvjwmtu5b6uvgsft-1
=== modified file 'swig/NdbRecAttr.i'
--- a/swig/NdbRecAttr.i	2007-08-01 16:44:14 +0000
+++ b/swig/NdbRecAttr.i	2007-08-30 05:34:54 +0000
@@ -174,13 +174,17 @@
     return NULL;
   }
 
+  MYSQL_TIME * getDatetime() { 
+    return NULL;
+  }
+
+  %ndbexception("NdbApiException") {
+    $action
+  }
 
   NdbTimestamp getTimestamp() { 
     return (NdbTimestamp)(self->u_32_value());
   }
 
-  MYSQL_TIME * getDatetime() { 
-    return NULL;
-  }
-
+  %ndbnoexception;
 };

=== modified file 'swig/NdbScanFilter.i'
--- a/swig/NdbScanFilter.i	2007-05-29 15:45:11 +0000
+++ b/swig/NdbScanFilter.i	2007-08-30 05:34:54 +0000
@@ -17,6 +17,38 @@
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
+%{
+
+  Uint32 cmpGetColumnLength(const NdbDictionary::Column * theColumn) { 
+
+    Uint32 cmpLength = 0; 
+    switch(theColumn->getType()) {
+    case NDB_TYPE_VARCHAR:
+    case NDB_TYPE_VARBINARY:
+    { 
+      cmpLength=theColumn->getLength()+1;
+      break;
+    }
+    case NDB_TYPE_LONGVARCHAR:
+    case NDB_TYPE_LONGVARBINARY:
+    {
+      cmpLength=theColumn->getLength()+2;
+      break; 
+    }
+    case NDB_TYPE_CHAR:
+    case NDB_TYPE_BINARY:
+    { 
+      cmpLength=theColumn->getLength();
+      break;
+    }
+    default:
+      return 0;
+    }
+    return cmpLength;
+  }
+
+%}
+
 class NdbScanFilter {
 
   class NdbScanFilterImpl & m_impl;
@@ -209,7 +241,12 @@
     char * stringVal = ndbFormatString(theColumn,BYTE,len);
     if (stringVal == NULL) 
       return -1;
-    int retval = self->cmp(cond,ColId,(void *)stringVal);
+
+    Uint32 cmpLength = cmpGetColumnLength(theColumn);
+    if (cmpLength == 0) 
+      return -1;
+
+    int retval = self->cmp(cond,ColId,(void *)stringVal,cmpLength);
     free(stringVal);
     return retval;
   };
@@ -218,7 +255,12 @@
     char * stringVal = ndbFormatString(theColumn,anInputString,len);
     if (stringVal == NULL) 
       return -1;
-    int retval = self->cmp(cond,ColId,(void *)stringVal);
+
+    Uint32 cmpLength = cmpGetColumnLength(theColumn);
+    if (cmpLength == 0) 
+      return -1;
+
+    int retval = self->cmp(cond,ColId,(void *)stringVal,cmpLength);
     free(stringVal);
     return retval;
   };
@@ -301,7 +343,12 @@
     char * stringVal = ndbFormatString(theColumn,BYTE,len);
     if (stringVal == NULL) 
       return -1;
-    int retval = self->cmp(cond,ColId,(void *)stringVal);
+
+    Uint32 cmpLength = cmpGetColumnLength(theColumn);
+    if (cmpLength == 0) 
+      return -1;
+
+    int retval = self->cmp(cond,ColId,(void *)stringVal,cmpLength);
     free(stringVal);
     return retval;
   };
@@ -314,7 +361,11 @@
     char * stringVal = ndbFormatString(theColumn,anInputString,len);
     if (stringVal == NULL) 
       return -1;
-    int retval = self->cmp(cond,ColId,(void *)stringVal);
+    Uint32 cmpLength = cmpGetColumnLength(theColumn);
+    if (cmpLength == 0) 
+      return -1;
+    
+    int retval = self->cmp(cond,ColId,(void *)stringVal,cmpLength);
     free(stringVal);
     return retval;
   };

Thread
Rev 142: Merged in changes from ndbjmerge tree. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/develMonty Taylor30 Aug