=== modified file 'interface/ndbapi/NdbRecAttr.i'
--- a/interface/ndbapi/NdbRecAttr.i	2008-04-19 18:53:30 +0000
+++ b/interface/ndbapi/NdbRecAttr.i	2008-04-22 06:21:51 +0000
@@ -101,20 +101,30 @@
   decimal_t * getDecimal() {
     NdbDictionary::Column::Type colType = self->getType();
 
-    // (an array of ints, not base-10 digits)
-    decimal_digit_t digits[DECIMAL_BUFF];
-    decimal_t * dec = (decimal_t *)malloc(sizeof(decimal_t));
-    dec->intg = 0;
-    dec->frac = 0;
-    dec->len = DECIMAL_BUFF;
-    dec->sign = 0;
-    dec->buf = digits;
+    decimal_t * dec = NULL;
 
     if(colType == NdbDictionary::Column::Decimal) {
 
       int prec  = self->getColumn()->getPrecision();
       int scale = self->getColumn()->getScale();
-      bin2decimal(self->aRef(), dec, prec, scale);
+
+      char * ref = self->aRef();
+
+      // (an array of ints, not base-10 digits)
+      dec = (decimal_t *)malloc(sizeof(decimal_t));
+      dec->intg = 0;
+      dec->frac = 0;
+      /* 8 decimal_digit_t's per byte */
+      dec->len = ceil(prec/8)+1;
+      dec->sign = 0;
+      dec->buf = (decimal_digit_t *)malloc(sizeof(decimal_digit_t)*(dec->len));
+
+      int ret = bin2decimal(ref, dec, prec, scale);
+
+      if (ret != 0) {
+        return NULL;
+      }
+      
     }
 
     return dec;

=== modified file 'interface/ndbapi/NdbTransaction.i'
--- a/interface/ndbapi/NdbTransaction.i	2008-04-19 18:53:30 +0000
+++ b/interface/ndbapi/NdbTransaction.i	2008-04-22 06:21:51 +0000
@@ -151,7 +151,8 @@
     return self->execute(NoCommit, abortOption,false);
   }
   int executeCommit(AbortOption abortOption = AbortOnError) {
-    return self->execute(Commit, abortOption,false);
+    return self->execute(Commit, abortOption);
+    
   }
   int executeRollback(AbortOption abortOption = AbortOnError) {
     return self->execute(Rollback, abortOption,false);

=== modified file 'interface/ndbapi/ndbglobals.i'
--- a/interface/ndbapi/ndbglobals.i	2008-04-19 18:53:30 +0000
+++ b/interface/ndbapi/ndbglobals.i	2008-04-22 06:21:51 +0000
@@ -21,7 +21,7 @@
 
 %include "globals.i"
 %include "config.h"
-
+%include "ndb_constants.h"
 %{
 
 #include <my_global.h>

=== modified file 'python/Makefile.am'
--- a/python/Makefile.am	2008-04-18 18:24:20 +0000
+++ b/python/Makefile.am	2008-04-22 06:21:51 +0000
@@ -29,7 +29,7 @@
 ${SWIG_BIN}:
 	( cd $(top_builddir)/swig && $(MAKE) $(AM_MAKEFLAGS) )
 
-ndbapi.cpp: ${SWIG_NDB_SOURCES} ndbapi.i ${SWIG_BIN}
+ndbapi.cpp: ${SWIG_NDB_SOURCES} $(srcdir)/swig/*.i ndbapi.i ${SWIG_BIN}
 
 mgmapi.cpp: ${SWIG_MGM_SOURCES} mgmapi.i ${SWIG_BIN}
 
@@ -39,7 +39,7 @@
 
 SUFFIXES = .cpp .i
 
-.i.cpp: $(SWIG_SOURCES) ${SWIG_BIN}
+.i.cpp: $(SWIG_SOURCES) $(srcdir)/swig/*.i ${SWIG_BIN}
 	@test ! -d $(builddir)/mysql && cp -a $(srcdir)/mysql $(builddir) || true
 	@chmod -R u+w $(builddir)/mysql
 	$(SWIG) -c++ -python $(SWIG_OPTS) -o $@ $<

=== modified file 'python/ndbapi.i'
--- a/python/ndbapi.i	2008-04-13 21:51:23 +0000
+++ b/python/ndbapi.i	2008-04-22 06:21:51 +0000
@@ -22,10 +22,15 @@
 
 %module ndbapi
 
+%pythoncode %{
+import decimal
+  %}
+
 %include "ndbapi/ndbglobals.i"
 
 
 %include "swig/datetime.i"
+%include "swig/decimal.i"
 
 
 %typemap(in) (const char* anInputString, size_t len) {

=== added file 'python/swig/decimal.i'
--- a/python/swig/decimal.i	1970-01-01 00:00:00 +0000
+++ b/python/swig/decimal.i	2008-04-22 06:21:51 +0000
@@ -0,0 +1,85 @@
+/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
+ *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ *  ndb-bindings: Bindings for the NDB API
+ *  Copyright (C) 2008 MySQL
+ *
+ *  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; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+
+/**
+ * Typemap to convert a decimal_t* to a decimal.Decimal
+ * $1 is a decimal_t *
+ * $result is a PyObject representing a decimal.Decimal
+
+ * fixed_precision is the total number of digits. 
+ * fixed_scale is the number after the decimal point
+ * int decimal2string(decimal_t *from, char *to, int *to_len,
+ *                      int fixed_precision, int fixed_decimals,
+ *                      char filler);
+ * theLen is the string length, and needs to account for the "."
+ *   character
+ **/
+%typemap(out) decimal_t * {
+
+  if ($1 == NULL) { 
+    return NULL;
+  }
+  int theLen = ($1->frac > 0) ? $1->intg+$1->frac+1 : $1->intg;
+  if ($1->sign) { 
+    theLen++;
+  }
+  PyObject * retVal = PyString_FromStringAndSize(NULL,theLen);
+  if (retVal != NULL) {
+    
+    Py_INCREF(retVal);
+    // PyString AsString returns a pointer to an internal string buffer
+    // so we should only have one memcpy here
+    char * destString = PyString_AsString(retVal);
+    if (destString == NULL) {
+      Py_DECREF(retVal);
+      retVal = NULL;
+    } else {
+      int ret = decimal2string($1, destString, &theLen,
+                               $1->intg+$1->frac,$1->frac,'0');
+      if (ret != 0){ 
+        Py_DECREF(retVal);
+        retVal = NULL;
+      }
+    }
+  }
+  /* We're done with the decimal_t* which we malloc'd in
+   * NdbRecAttr::getDecimal()
+   */
+  free($1);
+  return retVal;
+
+ }
+
+/* Internal method indent starts at 8 spaces. */
+%pythonappend NdbRecAttr::getDecimal() %{
+        val=decimal.Decimal(val)
+  %}
+/**
+ * Typemap to convert a java.math.BigDecimal to a decimal_t *
+ * $input is a jobject representing a java.math.BigDecimal
+ * $1 is a decimal_t *
+ **/
+%typemap(in) decimal_t * {
+
+
+ }
+

=== modified file 'python/swig/recattr_getvalue.i'
--- a/python/swig/recattr_getvalue.i	2008-04-20 18:58:47 +0000
+++ b/python/swig/recattr_getvalue.i	2008-04-22 06:21:51 +0000
@@ -25,7 +25,7 @@
 def getValue(self):
   t=self.getColType()
 
-  if t >= NDB_TYPE_TINYINT and t <= NDB_TYPE_BIGINT and (t%2==0.0):
+  if t >= ndbapi.NDB_TYPE_TINYINT and t <= NDB_TYPE_BIGINT and (t%2==0.0):
     ret = self.getInt32()
   elif t >= NDB_TYPE_TINYUNSIGNED and t <= NDB_TYPE_BIGUNSIGNED and (t%2==1):
     ret = self.getUint32()
@@ -35,6 +35,8 @@
      ret = self.getDouble()
   elif t >= NDB_TYPE_CHAR and t <= NDB_TYPE_VARBINARY:
     ret = self.aRef()
+  elif t == NDB_TYPE_DECIMAL:
+    ret = self.getDecimal()
   elif t == NDB_TYPE_DATE:
     ret = self.getUint32()
     year = ret/10000 % 10000

=== added file 'python/tests/ndbapi/TestDecimal.py'
--- a/python/tests/ndbapi/TestDecimal.py	1970-01-01 00:00:00 +0000
+++ b/python/tests/ndbapi/TestDecimal.py	2008-04-22 06:21:51 +0000
@@ -0,0 +1,67 @@
+from tests import ClusterTestCase
+from mysql.cluster import ndbapi
+import unittest, decimal
+
+class TestDecimal(ClusterTestCase.ClusterTestCase):
+
+
+    PRIMARYKEYINDEXNAME = "PRIMARY"
+
+    TABLE1 = "t_decimal"
+
+    val1 = "10.5"
+    val2 = "-10.5"
+
+    def setUp(self):
+        super(TestDecimal, self).setUp()
+
+        cur=self.MYSQL_CONN.cursor()
+         
+        self.createTable(self.TABLE1,"""
+        ( id integer NOT NULL primary key,
+          val decimal(10,5)
+        ) engine=ndbcluster""")
+
+        cur.execute("insert into %s values (1,%s)" % (self.TABLE1, self.val1))
+        cur.execute("insert into %s values (2,%s)" % (self.TABLE1, self.val2))
+        self.MYSQL_CONN.commit()
+
+    def testSelectTable1(self):
+
+        trans = self.ndb.startTransaction();
+
+        op = trans.getNdbOperation(self.TABLE1);
+        op.readTuple(ndbapi.NdbOperation.LM_CommittedRead)
+
+        op.equalInt("id",1)
+
+        rec = op.getValue("val")
+        trans.executeCommit()
+        
+        d = rec.getDecimal()
+        self.assertEquals(d,decimal.Decimal(self.val1))
+        trans.close()
+
+
+        #TODO: Fix Invalid Schema Object Version
+        #def testSelectTable2(self):
+        trans = self.ndb.startTransaction();
+
+        op = trans.getNdbOperation(self.TABLE1);
+        op.readTuple(ndbapi.NdbOperation.LM_CommittedRead)
+
+        op.equalInt("id",2)
+
+        rec = op.getValue("val")
+        trans.executeCommit()
+        
+        d = rec.getDecimal()
+        self.assertEquals(d,decimal.Decimal(self.val2))
+        trans.close()
+
+
+
+test_ndb = unittest.TestLoader().loadTestsFromTestCase(TestDecimal)
+
+if __name__=="__main__":
+    unittest.TextTestRunner(verbosity=2).run(test_ndb)



