List:NDB Connectors« Previous MessageNext Message »
From:Monty Taylor Date:September 20 2007 12:39pm
Subject:Rev 151: Merged mgmapi build fixes. 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: 151
revision-id: mtaylor@stripped
parent: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: devel
timestamp: Thu 2007-09-20 14:39:42 +0200
message:
  Merged mgmapi build fixes.
modified:
  perl/mgmapi.i                  mgmapi.i-20070415084702-pjs702i1rleb6otl-1
  python/mgmapi.i               
svn-v2:10@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-python%2fmgm.i
  ruby/mgmapi.i                  mgmapi.i-20070415091411-plc5gtpiwg93c2lx-1
  ruby/test.rb                   test.rb-20070228212451-7arjxk90dkwcn5xr-4
  ruby/testreaddt.rb             testreaddt.rb-20070521223831-70qncxglgiscqe0a-1
    ------------------------------------------------------------
    revno: 149.1.11
    revision-id: mtaylor@stripped
    parent: mtaylor@stripped
    committer: Monty Taylor <mtaylor@stripped>
    branch nick: ndbjmerge
    timestamp: Thu 2007-09-20 14:39:05 +0200
    message:
      Fixed perl and python mgm build issues.
    modified:
      perl/mgmapi.i                  mgmapi.i-20070415084702-pjs702i1rleb6otl-1
      python/mgmapi.i               
svn-v2:10@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-python%2fmgm.i
    ------------------------------------------------------------
    revno: 149.1.10
    revision-id: mtaylor@stripped
    parent: mtaylor@stripped
    committer: Monty Taylor <mtaylor@stripped>
    branch nick: ndbjmerge
    timestamp: Wed 2007-09-19 11:54:56 +0200
    message:
      Added NDB_exception info to mgmapi.i for ruby.
    modified:
      ruby/mgmapi.i                  mgmapi.i-20070415091411-plc5gtpiwg93c2lx-1
      ruby/test.rb                   test.rb-20070228212451-7arjxk90dkwcn5xr-4
      ruby/testreaddt.rb             testreaddt.rb-20070521223831-70qncxglgiscqe0a-1
=== modified file 'perl/mgmapi.i'
--- a/perl/mgmapi.i	2007-07-25 14:16:35 +0000
+++ b/perl/mgmapi.i	2007-09-20 12:39:05 +0000
@@ -23,6 +23,11 @@
 %{
 #undef SWIG_exception
 #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
+
+#define NDB_exception(excp, msg) do { sv_setpvf(GvSV(PL_errgv),#excp " %s\n", msg);
SWIG_fail; } while (0)
+
+#include <my_global.h>
+
 %}
 
 %include "mgmglobals.i"

=== modified file 'python/mgmapi.i'
--- a/python/mgmapi.i	2007-07-25 17:20:31 +0000
+++ b/python/mgmapi.i	2007-09-20 12:39:05 +0000
@@ -27,5 +27,90 @@
 
 %init %{
   ndb_init();
+
+  NEW_pyexcept(NdbApiException,NULL);
+  NEW_pyexcept(NdbApiRuntimeException,PyExc_NdbApiException);
+  NEW_pyexcept(NdbApiPermanentException,PyExc_NdbApiException);
+  NEW_pyexcept(NdbApiTemporaryException,PyExc_NdbApiException);
+  NEW_pyexcept(NdbApiUserErrorPermanentException,PyExc_NdbApiPermanentException);
+  NEW_pyexcept(NdbClusterConnectionPermanentException,PyExc_NdbApiPermanentException);
+  NEW_pyexcept(NdbClusterConnectionTemporaryException,PyExc_NdbApiTemporaryException);
+  NEW_pyexcept(NdbApiTimeStampOutOfBoundsException,PyExc_NdbApiException);
+  NEW_pyexcept(BlobUndefinedException,PyExc_NdbApiException);
+  NEW_pyexcept(NoSuchColumnException,PyExc_NdbApiException);
+  NEW_pyexcept(NoSuchIndexException,PyExc_NdbApiException);
+  NEW_pyexcept(NoSuchTableException,PyExc_NdbApiException);
+
 %}
 
+%{
+
+#define NEW_pyexcept(EXCPT,EPARENT) { PyExc_ ## EXCPT =
PyErr_NewException("mysql.cluster.ndbapi." #EXCPT ,EPARENT,NULL); PyDict_SetItemString(d,
#EXCPT ,PyExc_ ## EXCPT); Py_INCREF(PyExc_ ## EXCPT); }
+  
+  PyObject * PyExc_NdbApiException; 
+  PyObject * PyExc_BlobUndefinedException;
+  PyObject * PyExc_NdbApiPermanentException;
+  PyObject * PyExc_NdbApiRuntimeException;
+  PyObject * PyExc_NdbApiTemporaryException;
+  PyObject * PyExc_NdbApiTimeStampOutOfBoundsException;
+  PyObject * PyExc_NdbApiUserErrorPermanentException;
+  PyObject * PyExc_NdbClusterConnectionPermanentException;
+  PyObject * PyExc_NdbClusterConnectionTemporaryException;
+  PyObject * PyExc_NoSuchColumnException;
+  PyObject * PyExc_NoSuchIndexException;
+  PyObject * PyExc_NoSuchTableException;
+  
+#define NDB_exception(excp, msg) { ndb_throw_exception(excp,msg); SWIG_fail; }
+  
+  void ndb_throw_exception(NdbException excp_mod, const char * msg) { 
+    
+    PyObject * exception; 
+    
+    switch (excp_mod) { 
+    case NdbApiException:
+      exception = PyExc_NdbApiException;
+      break; 
+    case BlobUndefinedException:
+      exception = PyExc_BlobUndefinedException;
+      break;
+    case NdbApiPermanentException:
+      exception = PyExc_NdbApiPermanentException;
+      break;
+    case NdbApiRuntimeException:
+      exception = PyExc_NdbApiRuntimeException;
+      break;
+    case NdbApiTemporaryException:
+      exception = PyExc_NdbApiTemporaryException;
+      break;
+    case NdbApiTimeStampOutOfBoundsException:
+      exception = PyExc_NdbApiTimeStampOutOfBoundsException;
+      break;
+    case NdbApiUserErrorPermanentException:
+      exception = PyExc_NdbApiUserErrorPermanentException;
+      break;
+    case NdbClusterConnectionPermanentException:
+      exception = PyExc_NdbClusterConnectionPermanentException;
+      break;
+    case NdbClusterConnectionTemporaryException:
+      exception = PyExc_NdbClusterConnectionTemporaryException;
+      break;
+    case NoSuchColumnException:
+      exception = PyExc_NoSuchColumnException;
+      break;
+    case NoSuchIndexException:
+      exception = PyExc_NoSuchIndexException;
+      break;
+    case NoSuchTableException:
+      exception = PyExc_NoSuchTableException;
+      break;
+    default:
+      exception = PyExc_RuntimeError;
+    }
+    exception = PyExc_NdbApiException;
+    PyErr_SetString(exception,msg);
+    Py_INCREF(exception);  
+  }
+  
+  
+  
+  %}

=== modified file 'ruby/mgmapi.i'
--- a/ruby/mgmapi.i	2007-07-25 17:20:31 +0000
+++ b/ruby/mgmapi.i	2007-09-19 09:54:56 +0000
@@ -38,6 +38,72 @@
   $1[i]=0;
 }
 
+%{ 
+
+#define NDB_exception(code,msg) do { ndb_raise_exception(code, msg); SWIG_fail; }
while(0);
+
+#define getExceptionMethod(excptype,eparent) \
+  SWIGINTERN VALUE \
+get ## excptype () { \
+  static int init ## excptype = 0 ; \
+  static VALUE rb_e ## excptype ; \
+  VALUE rb_eparent = ndb_get_exception (eparent); \
+  if (! init ## excptype ) { \
+    init ## excptype = 1; \
+    rb_e ## excptype = rb_define_class(#excptype , rb_eparent); \
+  } \
+  return rb_e ## excptype ; \
+}
+VALUE ndb_get_exception(NdbException excpcode);
+
+getExceptionMethod(NdbApiException,BaseRuntimeError);
+getExceptionMethod(NdbApiRuntimeException,NdbApiException);
+getExceptionMethod(NdbApiPermanentException,NdbApiException);
+getExceptionMethod(NdbApiTemporaryException,NdbApiException);
+getExceptionMethod(NdbApiUserErrorPermanentException,NdbApiPermanentException);
+getExceptionMethod(NdbClusterConnectionPermanentException,NdbApiPermanentException);
+getExceptionMethod(NdbClusterConnectionTemporaryException,NdbApiTemporaryException);
+getExceptionMethod(NdbApiTimeStampOutOfBoundsException,NdbApiException);
+getExceptionMethod(BlobUndefinedException,NdbApiException);
+getExceptionMethod(NoSuchColumnException,NdbApiException);
+getExceptionMethod(NoSuchIndexException,NdbApiException);
+getExceptionMethod(NoSuchTableException,NdbApiException);
+
+void ndb_raise_exception(NdbException excpcode, const char * msg) {
+  rb_raise(ndb_get_exception(excpcode),msg);
+}
+
+#define CASE_exception(excp) case excp : exception = get ## excp (); break;
+
+VALUE ndb_get_exception(NdbException excpcode) { 
+
+ VALUE exception;
+
+ switch (excpcode) {
+    case BaseRuntimeError:
+      exception = rb_eRuntimeError;
+      break;
+    CASE_exception(NdbApiException)
+    CASE_exception(BlobUndefinedException)
+    CASE_exception(NdbApiPermanentException)
+    CASE_exception(NdbApiRuntimeException)
+    CASE_exception(NdbApiTemporaryException)
+    CASE_exception(NdbApiTimeStampOutOfBoundsException)
+    CASE_exception(NdbApiUserErrorPermanentException)
+    CASE_exception(NdbClusterConnectionPermanentException)
+    CASE_exception(NdbClusterConnectionTemporaryException)
+    CASE_exception(NoSuchColumnException)
+    CASE_exception(NoSuchIndexException)
+    CASE_exception(NoSuchTableException)
+    default:
+      exception = rb_eRuntimeError;
+      break;
+  }
+  return exception;
+}
+
+%}
+
 //%apply ndb_logevent *OUTPUT { ndb_logevent *dst };
 
 %include "NdbMgm.i"

=== modified file 'ruby/test.rb'
--- a/ruby/test.rb	2007-06-25 16:54:09 +0000
+++ b/ruby/test.rb	2007-09-19 09:54:56 +0000
@@ -15,7 +15,7 @@
   connection.connect(1,1,1)
   connection.wait_until_ready(30, 30)
   
-rescue Ndbapi::NdbApiException => e
+rescue NdbApiException => e
   puts "ERROR:" + e
   exit 
 end
@@ -35,8 +35,15 @@
 
 puts "Inserting" , auto_id
 
-myOperation.equalInt32("ATTR1",auto_id)
-myOperation.set_string("ATTR2","monty")
+begin
+  
+  myOperation.equalInt32("ATTR1",auto_id)
+  myOperation.set_int("ATTR2",10)
+
+rescue NdbApiException => e
+  puts "ERROR:" + e
+  exit
+end
 
 myTransaction.execute(Ndbapi::Commit)
 

=== modified file 'ruby/testreaddt.rb'
--- a/ruby/testreaddt.rb	2007-07-25 17:20:31 +0000
+++ b/ruby/testreaddt.rb	2007-09-19 09:54:56 +0000
@@ -32,7 +32,7 @@
 
 puts "Reading" , insertid
 
-myOperation.equal("id",insertid)
+myOperation.equalInt32("id",insertid)
 ra=myOperation.get_value("ts")
 
 myTransaction.execute(Ndbapi::Commit)

Thread
Rev 151: Merged mgmapi build fixes. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/develMonty Taylor20 Sep