List:NDB Connectors« Previous MessageNext Message »
From:Monty Taylor Date:September 20 2007 1:42pm
Subject:Rev 152: Merged changes adding lua test script. 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: 152
revision-id: mtaylor@stripped
parent: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: devel
timestamp: Thu 2007-09-20 15:41:55 +0200
message:
  Merged changes adding lua test script.
added:
  lua/test.lua                   test.lua-20070920131233-idnreujp7bwxsxre-1
modified:
  lua/Makefile.am                makefile.am-20070727221140-30x3yi1g0lf9rflk-2
  python/test.py                
svn-v2:1@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-python%2ftest.py
  testndbapi/Makefile           
svn-v2:1@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-testndbapi%2fMakefile
  testndbapi/teststrins.cpp     
svn-v2:1@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-testndbapi%2fteststrins.cpp
    ------------------------------------------------------------
    revno: 149.1.12
    revision-id: mtaylor@stripped
    parent: mtaylor@stripped
    committer: Monty Taylor <mtaylor@stripped>
    branch nick: ndbjmerge
    timestamp: Thu 2007-09-20 15:12:36 +0200
    message:
      Added simple lua example.
    added:
      lua/test.lua                   test.lua-20070920131233-idnreujp7bwxsxre-1
    modified:
      lua/Makefile.am                makefile.am-20070727221140-30x3yi1g0lf9rflk-2
      python/test.py                
svn-v2:1@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-python%2ftest.py
      testndbapi/Makefile           
svn-v2:1@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-testndbapi%2fMakefile
      testndbapi/teststrins.cpp     
svn-v2:1@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-testndbapi%2fteststrins.cpp
=== added file 'lua/test.lua'
--- a/lua/test.lua	1970-01-01 00:00:00 +0000
+++ b/lua/test.lua	2007-09-20 13:12:36 +0000
@@ -0,0 +1,29 @@
+require("ndbapi")
+
+
+ndbapi.ndb_init()
+
+connection = ndbapi.NdbFactory_createNdbClusterConnection("127.0.0.1")
+
+connection:connect(1,1,true)
+connection:waitUntilReady(30,30)
+
+myNdb = connection:createNdb("test")
+
+myNdb:init(4)
+
+print "running tests"
+
+myTransaction = myNdb:startTransaction()
+
+myOperation = myTransaction:getNdbOperation("mytablename")
+myOperation:insertTuple()
+auto_id = myNdb:getAutoIncrementValue("mytablename",100)
+
+print("Inserting",auto_id)
+
+myOperation:equalInt32("ATTR1",auto_id)
+myOperation:setInt("ATTR2",10)
+
+myTransaction:execute(ndbapi.Commit)
+myTransaction:close()

=== modified file 'lua/Makefile.am'
--- a/lua/Makefile.am	2007-07-27 22:11:44 +0000
+++ b/lua/Makefile.am	2007-09-20 13:12:36 +0000
@@ -1,7 +1,7 @@
 # -*- Mode: Makefile -*-
 
 luaarchdir=/usr/local/lub/lua
-luaarch_DATA=mysql/cluster/ndbapi.so
+luaarch_DATA=ndbapi.so
 
 CLEANFILES=*.db test-out.rdf core* \
 	$(rubyarch_DATA) ndbapi.cpp
@@ -14,8 +14,7 @@
 $(srcdir)/%.o: $(srcdir)/%.cpp
 	$(CXX) $(SWIG_OPTS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)
$(AM_CFLAGS) $(STANDARD_CFLAGS) -fPIC -DPIC $(LUA_CFLAGS) $< -c -o $@
 
-$(srcdir)/mysql/cluster/%.so: %.o
-	mkdir -p mysql/cluster
+$(srcdir)/%.so: %.o
 	echo $(CXX) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -shared $< $(LUA_LDFLAGS)
-o $@ 
 	$(CXX) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -shared $< $(LUA_LDFLAGS) -o
$@ 
 

=== modified file 'python/test.py'
--- a/python/test.py	2007-07-25 17:20:31 +0000
+++ b/python/test.py	2007-09-20 13:12:36 +0000
@@ -1,9 +1,6 @@
 import sys,time,random,struct,math
 from mysql.cluster import ndbapi
-import mysql.cluster.ndbapi
-
-e=mysql.cluster.ndbapi.NdbApiException()
-print e
+#import mysql.cluster.ndbapi
 
 import  MySQLdb
 
@@ -44,7 +41,7 @@
   connection = ndbapi.NdbFactory.createNdbClusterConnection();
 
   connection.connect(1,1,1)
-except mysql.cluster.ndbapi.NdbApiException,e:
+except ndbapi.NdbApiException,e:
   print e
   sys.exit(-1)
 

=== modified file 'testndbapi/Makefile'
--- a/testndbapi/Makefile	2007-05-02 02:56:57 +0000
+++ b/testndbapi/Makefile	2007-09-20 13:12:36 +0000
@@ -1,4 +1,4 @@
-TARGET = ndbapi_simple_index
+TARGET = teststrins
 SRCS = $(TARGET).cpp
 OBJS = $(TARGET).o
 CXX = g++

=== modified file 'testndbapi/teststrins.cpp'
--- a/testndbapi/teststrins.cpp	2006-11-22 20:17:43 +0000
+++ b/testndbapi/teststrins.cpp	2007-09-20 13:12:36 +0000
@@ -83,18 +83,18 @@
   }
 
   Ndb* myNdb = new Ndb( cluster_connection,
-			"sfndb" );  // Object representing the database
+			"test" );  // Object representing the database
   if (myNdb->init() == -1) { 
     APIERROR(myNdb->getNdbError());
     exit(-1);
   }
 
   const NdbDictionary::Dictionary* myDict= myNdb->getDictionary();
-  const NdbDictionary::Table *myTable= myDict->getTable("ContentObject");
-  const NdbDictionary::Column *myCol = myTable->getColumn("name");
+  const NdbDictionary::Table *myTable= myDict->getTable("mytablename");
+/*  const NdbDictionary::Column *myCol = myTable->getColumn("ATTR");
   const Uint32 sizeInBytes = myCol->getLength();
-  CHARSET_INFO* cs_info =  myCol->getCharset();
-  std::cout << "size in bytes: " << sizeInBytes << std::endl;
+  CHARSET_INFO* cs_info =  myCol->getCharset(); 
+  std::cout << "size in bytes: " << sizeInBytes << std::endl; */
   //std::cout << "charset name: " << cs_info->csname <<std::endl;
   if (myTable == NULL)
     APIERROR(myDict->getNdbError());
@@ -125,12 +125,12 @@
     //std::cout << "whee" << buf << "whee" << std::endl;
     //strncpy(buf,strcat(&mylen,"hello"),30);
     //std::cout << "whee" << buf << "whee" << std::endl;
-    if (myOperation->equal("id",(Uint32)auto_id) == -1)
+    if (myOperation->equal("ATTR1",(Uint32)auto_id) == -1)
       APIERROR(myOperation->getNdbError());
 
     std::cout << "before setvalue" << std::endl; 
 
-    if (myOperation->setValue("name", "\005hello", (Uint32)31) == -1)
+    if (myOperation->setValue("ATTR2", "\005hello" ) == -1)
       APIERROR(myOperation->getNdbError());
     std::cout << "after setvalue" << std::endl; 
       

Thread
Rev 152: Merged changes adding lua test script. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/develMonty Taylor20 Sep