List:NDB Connectors« Previous MessageNext Message »
From:Monty Taylor Date:January 29 2008 9:57am
Subject:bzr COMMIT - http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel (mtaylor 435 )
View as plain text  
#At http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel

------------------------------------------------------------
revno: 435
revision-id:mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: devel
timestamp: Tue 2008-01-29 01:56:15 -0800
message:
  Broke BasicTest - but did it in an interesting way which points out a new test
  we need to add... and a _whole_ bunch of work on Exceptions we probably need 
  to do. 
added:
  java/com/mysql/cluster/ndbj/InvalidSchemaObjectVersionException.java
invalidschemaobjectv-20080129094607-77f8tbt3s5yvwsa5-1
modified:
  interface/globals.i            globals.i-20070528224404-qscgbkcvhcru9u2o-2
  interface/ndbapi/NdbTransaction.i ndbtransaction.i-20070227184716-ecjyhh3jgvmye4de-7
  java/Makefile.am               makefile.am-20070415032352-9dpe6aurqcnuwcrd-1
  java/testsuite/BaseNdbjTestCase.java basejdbc.java-20070517181935-98huwjarzuh25b30-45
  java/testsuite/ndbj/BasicTest.java basictest.java-20070529154705-qmbr2wjlqu4mcnay-1
=== modified file 'interface/globals.i'
--- a/interface/globals.i	2007-12-04 09:42:22 +0000
+++ b/interface/globals.i	2008-01-29 09:56:15 +0000
@@ -64,6 +64,7 @@
     NoSuchIndexException,
     NoSuchTableException,
     NdbMgmException,
+    InvalidSchemaObjectVersionException,
 };
 %}
 

=== modified file 'interface/ndbapi/NdbTransaction.i'
--- a/interface/ndbapi/NdbTransaction.i	2007-12-09 22:26:12 +0000
+++ b/interface/ndbapi/NdbTransaction.i	2008-01-29 09:56:15 +0000
@@ -60,7 +60,7 @@
   const NdbOperation * getNextCompletedOperation(const NdbOperation * op)const;
 
 
-  %ndbexception("NdbApiException,NdbApiTemporaryException,NdbApiPermanentException,") {
+ 
%ndbexception("NdbApiException,NdbApiTemporaryException,NdbApiPermanentException,InvalidSchemaObjectVersionException")
{
     $action
       if (result < 0) { 
         NdbError err = arg1->getNdbError();
@@ -69,6 +69,15 @@
             NDB_exception_err(NdbApiTemporaryException,err.message,err);
             break;
           case NdbError::PermanentError:
+            // TODO: We should probably at least handle all the various 
+            // error classifications. mmm, thats going to suck
+            // and then we should figure out how to do that all over the place
+            if (err.code == 241) { // Invalid Schema Version - see ndberror.c
+              NDB_exception_err(InvalidSchemaObjectVersionException,
+                                err.message,err);
+            } else {
+              NDB_exception_err(NdbApiException,err.message,err);
+            } 
             NDB_exception_err(NdbApiPermanentException,err.message,err);
             break; 
           default: 

=== modified file 'java/Makefile.am'
--- a/java/Makefile.am	2008-01-23 20:28:19 +0000
+++ b/java/Makefile.am	2008-01-29 09:56:15 +0000
@@ -137,6 +137,7 @@
 	${package_srcdir}/ndbj/NdbMgmException.java \
 	${package_srcdir}/ndbj/Ndb.java \
 	${package_srcdir}/ndbj/NdbApiException.java \
+	${package_srcdir}/ndbj/InvalidSchemaObjectVersionException.java \
 	${package_srcdir}/ndbj/NdbApiPermanentException.java \
 	${package_srcdir}/ndbj/NdbApiRuntimeException.java \
 	${package_srcdir}/ndbj/NdbApiTemporaryException.java \
@@ -227,6 +228,7 @@
 	${package_builddir}/ndbj/NdbMgmException.class \
 	${package_builddir}/ndbj/Ndb.class \
 	${package_builddir}/ndbj/NdbApiException.class \
+	${package_builddir}/ndbj/InvalidSchemaObjectVersionException.class \
 	${package_builddir}/ndbj/NdbApiPermanentException.class \
 	${package_builddir}/ndbj/NdbApiRuntimeException.class \
 	${package_builddir}/ndbj/NdbApiTemporaryException.class \

=== added file 'java/com/mysql/cluster/ndbj/InvalidSchemaObjectVersionException.java'
--- a/java/com/mysql/cluster/ndbj/InvalidSchemaObjectVersionException.java	1970-01-01
00:00:00 +0000
+++ b/java/com/mysql/cluster/ndbj/InvalidSchemaObjectVersionException.java	2008-01-29
09:56:15 +0000
@@ -0,0 +1,19 @@
+package com.mysql.cluster.ndbj;
+
+public class InvalidSchemaObjectVersionException extends NdbApiPermanentException {
+
+	protected static final long serialVersionUID=1L;
+	/**
+	 * @param error
+	 */
+	public InvalidSchemaObjectVersionException(long error) {
+		super(error);
+	}
+
+	/**
+	 * @param message
+	 */
+	public InvalidSchemaObjectVersionException(String message) {
+		super(message);
+	}
+}

=== modified file 'java/testsuite/BaseNdbjTestCase.java'
--- a/java/testsuite/BaseNdbjTestCase.java	2008-01-29 01:02:45 +0000
+++ b/java/testsuite/BaseNdbjTestCase.java	2008-01-29 09:56:15 +0000
@@ -11,6 +11,7 @@
 import com.mysql.cluster.ndbj.NdbClusterConnection;
 import com.mysql.cluster.ndbj.NdbDictionary;
 import com.mysql.cluster.ndbj.NdbFactory;
+import com.mysql.cluster.ndbj.NdbTable;
 import com.mysql.cluster.ndbj.NdbTransaction;
 import com.mysql.cluster.ndbj.ndbj;
 
@@ -203,7 +204,9 @@
 	protected void createTable(String tableName, String columnsAndOtherStuff) throws
SQLException {
 		super.createTable(tableName, columnsAndOtherStuff);
 		NdbDictionary theDict = ndb.getDictionary();
-		theDict.invalidateTable(tableName);
+		//theDict.invalidateTable(tableName);
+		theDict.removeCachedTable(tableName);
+		NdbTable theTable = theDict.getTable(tableName); 
 	}
 
 }

=== modified file 'java/testsuite/ndbj/BasicTest.java'
--- a/java/testsuite/ndbj/BasicTest.java	2007-12-27 02:37:27 +0000
+++ b/java/testsuite/ndbj/BasicTest.java	2008-01-29 09:56:15 +0000
@@ -3,6 +3,9 @@
 import testsuite.BaseNdbjTestCase;
 import com.mysql.cluster.ndbj.AbortOption;
 import com.mysql.cluster.ndbj.ExecType;
+import com.mysql.cluster.ndbj.InvalidSchemaObjectVersionException;
+import com.mysql.cluster.ndbj.NdbDictionary;
+import com.mysql.cluster.ndbj.NdbTable;
 
 import com.mysql.cluster.ndbj.NdbApiException;
 import com.mysql.cluster.ndbj.NdbOperation; 
@@ -43,13 +46,27 @@
 	
 	public void testSingleInsertString() throws NdbApiException,SQLException { 
 	
+		String tableName = "basic_test";
+		try { 
 		trans = ndb.startTransaction();
-		NdbOperation op = trans.getInsertOperation("basic_test");
+		NdbOperation op = trans.getInsertOperation(tableName);
 		op.equalInt("id", 1);
 		op.setString("name", "Monty");
 		trans.execute(ExecType.Commit,AbortOption.AbortOnError,true);
 		
-		String nameVal = (String)this.getSingleValue("basic_test", "name", "where id=1");
+		} catch (InvalidSchemaObjectVersionException e) {
+			System.out.println("Got invalid schema object version");
+			NdbDictionary theDict = ndb.getDictionary();
+			theDict.invalidateTable(tableName);
+			//theDict.removeCachedTable(tableName);
+			NdbTable theTable = theDict.getTable(tableName); 
+			trans = ndb.startTransaction();
+			NdbOperation op = trans.getInsertOperation(theTable);
+			op.equalInt("id", 1);
+			op.setString("name", "Monty");
+			trans.execute(ExecType.Commit,AbortOption.AbortOnError,true);
+		}
+		String nameVal = (String)this.getSingleValue(tableName, "name", "where id=1");
 		assertEquals("Monty",nameVal);
 	}
 	

Thread
bzr COMMIT - http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/devel (mtaylor 435 )Monty Taylor29 Jan