Date: Friday, December 2, 2005 @ 13:54:20
  Author: csaba
    Path: /cvsroot/carob/libmysequoia

   Added: doc/Doxyfile (1.1) proto/Makefile (1.1)
          proto/hello-libmysequoia.c (1.1) proto/libmysequoia.cpp (1.1)
          src/CarobMySQL.cpp (1.1) src/MySQLAPI.cpp (1.1) test/Makefile
          (1.1)
Modified: Makefile (1.4 -> 1.5)
 Removed: src/Makefile (1.2) src/hello-libmysequoia.c (1.1)
          src/libmysequoia.cpp (1.3)

Restructured:
- moved the first proto to the proto directory
- added the prototype of the functions
- created doc, test, include directory


----------------------------+
 Makefile                   |   87 +++++-
 doc/Doxyfile               |   20 +
 proto/Makefile             |   17 +
 proto/hello-libmysequoia.c |  130 +++++++++
 proto/libmysequoia.cpp     |  450 ++++++++++++++++++++++++++++++++
 src/CarobMySQL.cpp         |   96 ++++++
 src/Makefile               |   17 -
 src/MySQLAPI.cpp           |  591 +++++++++++++++++++++++++++++++++++++++++++
 src/hello-libmysequoia.c   |  130 ---------
 src/libmysequoia.cpp       |  450 --------------------------------
 test/Makefile              |   28 ++
 11 files changed, 1413 insertions(+), 603 deletions(-)


Index: libmysequoia/Makefile
diff -u libmysequoia/Makefile:1.4 libmysequoia/Makefile:1.5
--- libmysequoia/Makefile:1.4   Mon Nov 28 10:39:01 2005
+++ libmysequoia/Makefile       Fri Dec  2 13:54:20 2005
@@ -1,8 +1,83 @@
-all:
-       cd src; make all
+#
+# Sequoia: Database clustering technology.
+# Copyright (C) 2005 Emic Networks
+# Contact: [EMAIL PROTECTED]
+# 
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+# http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Initial developer(s): Zsolt Simon, Csaba Simon
+# Contributor(s): 
+#
+# Makefile crafted from LibCarobCpp Makefile. Thanks Giles!
+#
+# Makefile for LibMySequoia and tests
+#
 
-clean:
-       cd src; make clean      
+# General
+LIB_MAJOR_VERSION      = 1
 
-run: 
-       cd src; make run 
+# Tools
+
+RM                                     = /bin/rm -f
+RMDIR                          = /bin/rm -rf
+LN                                     = /bin/ln -s
+DOXYGEN                                = /usr/bin/doxygen
+
+# Dirs
+INCDIR                         = -Iinclude -I../carob/include `mysql_config 
--include`
+SRCDIR                         = src
+
+# LibMySequoia C++ lib
+OBJS                                           = ${SRCDIR}/CarobMySQL.o\
+                                                 ${SRCDIR}/MySQLAPI.o
+CXXFLAGS                                       = -g3 -Wall ${INCDIR}
+LDFLAGS                                        = -fPIC --shared -L../carob 
-lcarobcpp
+LIB_MYSEQUOIA                  = mysequoia
+LIB_MYSEQUOIA_LIB_SHORT = lib${LIB_MYSEQUOIA}.so
+LIB_MYSEQUOIA_LIB              = 
${LIB_MYSEQUOIA_LIB_SHORT}.${LIB_MAJOR_VERSION}
+
+
+# Doc
+# DOC_DIR is duplicated in Doxyfile
+DOC_DIR                                = doc
+DOC_OUT                                = ${DOC_DIR}/html
+DOXYFILE                               = ${DOC_DIR}/Doxyfile
+DOC_HTML                               = ${DOC_OUT}/index.html
+
+all: lib
+
+lib: ${LIB_MYSEQUOIA_LIB}
+
+test: all
+       $(MAKE) -C test
+
+${LIB_MYSEQUOIA_LIB}: ${OBJS}
+       ${CXX} ${LDFLAGS} -o ${LIB_MYSEQUOIA_LIB} ${OBJS}
+       ${RM} ${LIB_MYSEQUOIA_LIB_SHORT}
+       ${LN} ${LIB_MYSEQUOIA_LIB} ${LIB_MYSEQUOIA_LIB_SHORT}
+
+clean: clean-lib clean-test clean-doc
+
+clean-lib:
+       ${RM} ${SRCDIR}/*.o ${LIB_MYSEQUOIA_LIB} ${LIB_MYSEQUOIA_LIB_SHORT}
+
+clean-test:
+       $(MAKE) -C test clean
+
+clean-doc:
+       ${RMDIR} ${DOC_OUT}
+
+doc: ${DOC_HTML}
+
+${DOC_HTML}: ${DOXYFILE}
+       ${DOXYGEN} ${DOXYFILE}
Index: libmysequoia/doc/Doxyfile
diff -u /dev/null libmysequoia/doc/Doxyfile:1.1
--- /dev/null   Fri Dec  2 13:54:20 2005
+++ libmysequoia/doc/Doxyfile   Fri Dec  2 13:54:20 2005
@@ -0,0 +1,20 @@
+#
+# Sequoia: Database clustering technology.
+# Copyright (C) 2005 Emic Networks
+# Contact: [EMAIL PROTECTED]
+# 
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+# http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Initial developer(s): Zsolt Simon, Csaba Simon
+# Contributor(s): 
+#
Index: libmysequoia/proto/Makefile
diff -u /dev/null libmysequoia/proto/Makefile:1.1
--- /dev/null   Fri Dec  2 13:54:20 2005
+++ libmysequoia/proto/Makefile Fri Dec  2 13:54:20 2005
@@ -0,0 +1,17 @@
+all: hello-libmysequoia libmysqlclient.so.15.1
+
+hello-libmysequoia: hello-libmysequoia.c
+       cc -Wall -g `mysql_config --include` -o $@ $< `mysql_config --libs`
+
+libmysqlclient.so.15.1: libmysql.o
+       c++ -Wall -g -fPIC --shared -L../../carob -lcarobcpp -o $@ $<
+       ln -sf $@ libmysqlclient.so.15
+
+libmysql.o: libmysequoia.cpp
+       c++ -Wall -g -o $@ -I../../carob/include -I/usr/include/mysql -c $<
+
+clean:
+       rm -f libmysqlclient.so.15.1 libmysqlclient.so.15 libmysql.o 
hello-libmysequoia
+
+run: all
+       LD_LIBRARY_PATH=.:../../carob ./hello-libmysequoia
Index: libmysequoia/proto/hello-libmysequoia.c
diff -u /dev/null libmysequoia/proto/hello-libmysequoia.c:1.1
--- /dev/null   Fri Dec  2 13:54:20 2005
+++ libmysequoia/proto/hello-libmysequoia.c     Fri Dec  2 13:54:20 2005
@@ -0,0 +1,130 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <my_global.h>
+#include <my_sys.h>
+#include <mysql.h>
+
+/*
+ * To create the table and insert some data:
+ * $ mysql -uroot -prootpass
+ * > USE test;
+ * > CREATE table t1 ( `a` int(11) NOT NULL auto_increment,
+ *                    `b` int(11) default NULL,
+ *                     PRIMARY KEY  (`a`)
+ *                  ) ENGINE=InnoDB; 
+ * > INSERT INTO t1 (b) VALUES (1),(2),(3)
+ * > exit
+ */
+
+static void
+print_error (MYSQL * conn, char *message)
+{
+  fprintf (stderr, "%s\n", message);
+  if (conn != NULL)
+    {
+      fprintf (stderr, "Error %u (%s): %s\n",
+              mysql_errno (conn), mysql_sqlstate (conn), mysql_error (conn));
+    }
+}
+
+
+void
+process_result_set (MYSQL * conn, MYSQL_RES * res_set)
+{
+  MYSQL_ROW row;
+  unsigned int i;
+
+  while ((row = mysql_fetch_row (res_set)) != NULL)
+    {
+      for (i = 0; i < mysql_num_fields (res_set); i++)
+       {
+         if (i > 0)
+           {
+             fputc ('\t', stdout);
+           }
+         printf ("%s", row[i] != NULL ? row[i] : "NULL");
+       }
+      fputc ('\n', stdout);
+    }
+  if (mysql_errno (conn) != 0)
+    print_error (conn, "mysql_fetch_row() failed");
+  else
+    printf ("%lu rows returned\n", (unsigned long) mysql_num_rows (res_set));
+}
+
+
+int
+main ()
+{
+  char *opt_host_name = "localhost";   /* server host (default=localhost) */
+  char *opt_user_name = "user";        /* username (default=login name) */
+  char *opt_password = "userpass";     /* password (default=none) */
+  unsigned int opt_port_num = 0;       /* port number (use built-in value) */
+  char *opt_socket_name = NULL;        /* socket name (use built-in value) */
+  char *opt_db_name = "db";    /* database name (default=none) */
+  unsigned int opt_flags = 0;  /* connection flags (none) */
+  MYSQL *conn;                 /* pointer to connection handler */
+  MYSQL_RES *res_set;
+
+  /* initialize connection handler */
+  conn = mysql_init (NULL);
+  if (conn == NULL)
+    {
+      fprintf (stderr, "mysql_init() failed (probably out of memory)\n");
+      exit (1);
+    }
+
+  /* connect to server */
+  if (mysql_real_connect (conn, opt_host_name, opt_user_name, opt_password,
+                         opt_db_name, opt_port_num, opt_socket_name,
+                         opt_flags) == NULL)
+    {
+      fprintf (stderr, "mysql_real_connect() failed\n");
+      mysql_close (conn);
+      exit (1);
+    }
+
+  /* the insert must succed */
+  if (mysql_query (conn, "INSERT INTO t1(b) VALUES (4)") != 0)
+    {
+      print_error (conn, "INSERT statement failed");
+    }
+  else
+    {
+      printf ("INSERT statement succeeded: %lu rows affected\n",
+             (unsigned long) mysql_affected_rows (conn));
+    }
+
+  /* the insert must fail (duplicate key) */
+/*  if (mysql_query (conn, "INSERT INTO t1 (a,b) VALUES (1,2)") != 0)
+    {
+      print_error (conn, "INSERT statement failed");
+    }
+  else
+    {
+      printf ("INSERT statement succeeded: %lu rows affected\n",
+             (unsigned long) mysql_affected_rows (conn));
+    }*/
+
+  /* simple query */
+  if (mysql_query (conn, "SELECT * from t1") != 0)
+    print_error (conn, "mysql_query() failed");
+  else
+    {
+      res_set = mysql_store_result (conn);     /* generate result set */
+      if (res_set == NULL)
+       print_error (conn, "mysql_store_result() failed");
+      else
+       {
+         /* process result set, and then deallocate it */
+         process_result_set (conn, res_set);
+//       mysql_free_result (res_set);
+       }
+    }
+
+  /* disconnect from server */
+  mysql_close (conn);
+
+  return 0;
+}
Index: libmysequoia/proto/libmysequoia.cpp
diff -u /dev/null libmysequoia/proto/libmysequoia.cpp:1.1
--- /dev/null   Fri Dec  2 13:54:20 2005
+++ libmysequoia/proto/libmysequoia.cpp Fri Dec  2 13:54:20 2005
@@ -0,0 +1,450 @@
+/**
+ * Sequoia: Database clustering technology.
+ * Copyright (C) 2005 Emic Networks
+ * Contact: [EMAIL PROTECTED]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Initial developer(s): Zsolt Simon, Csaba Simon
+ * Contributor(s): 
+ */
+ 
+ /**
+  * This is only a first prototype that is demonstrating that 
+  * the libmysequoia project is doable.
+  * There is no error checking nor exception handling and no
+  * comment on the code.
+  */
+  
+/* C includes */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* MySQL includes */
+#include <my_global.h>
+#include <my_sys.h>
+#include <mysql.h>
+#include <errmsg.h>
+
+/* Carob includes */
+#include <ConnectionParameters.hpp>
+#include <ConnectionPool.hpp>
+#include <DriverResultSet.hpp>
+#include <Statement.hpp>
+
+/* C++ includes */
+#include <string>
+#include <vector>
+#include <locale>
+
+using namespace CarobNS;
+
+void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate);
+
+const char *client_errors[]=
+{
+  "Unknown MySQL error",
+  "Can't create UNIX socket (%d)",
+  "Can't connect to local MySQL server through socket '%-.100s' (%d)",
+  "Can't connect to MySQL server on '%-.100s' (%d)",
+  "Can't create TCP/IP socket (%d)",
+  "Unknown MySQL server host '%-.100s' (%d)",
+  "MySQL server has gone away",
+  "Protocol mismatch; server version = %d, client version = %d",
+  "MySQL client ran out of memory",
+  "Wrong host info",
+  "Localhost via UNIX socket",
+  "%-.100s via TCP/IP",
+  "Error in server handshake",
+  "Lost connection to MySQL server during query",
+  "Commands out of sync; you can't run this command now",
+  "Named pipe: %-.32s",
+  "Can't wait for named pipe to host: %-.64s  pipe: %-.32s (%lu)",
+  "Can't open named pipe to host: %-.64s  pipe: %-.32s (%lu)",
+  "Can't set state of named pipe to host: %-.64s  pipe: %-.32s (%lu)",
+  "Can't initialize character set %-.32s (path: %-.100s)",
+  "Got packet bigger than 'max_allowed_packet' bytes",
+  "Embedded server",
+  "Error on SHOW SLAVE STATUS:",
+  "Error on SHOW SLAVE HOSTS:",
+  "Error connecting to slave:",
+  "Error connecting to master:",
+  "SSL connection error",
+  "Malformed packet",
+  "This client library is licensed only for use with MySQL servers having '%s' 
license",
+  "Invalid use of null pointer",
+  "Statement not prepared",
+  "No data supplied for parameters in prepared statement",
+  "Data truncated",
+  "No parameters exist in the statement",
+  "Invalid parameter number",
+  "Can't send long data for non-string/non-binary data types (parameter: %d)",
+  "Using unsupported buffer type: %d  (parameter: %d)",
+  "Shared memory: %-.100s",
+  "Can't open shared memory; client could not create request event (%lu)",
+  "Can't open shared memory; no answer event received from server (%lu)",
+  "Can't open shared memory; server could not allocate file mapping (%lu)",
+  "Can't open shared memory; server could not get pointer to file mapping 
(%lu)",
+  "Can't open shared memory; client could not allocate file mapping (%lu)",
+  "Can't open shared memory; client could not get pointer to file mapping 
(%lu)",
+  "Can't open shared memory; client could not create %s event (%lu)",
+  "Can't open shared memory; no answer from server (%lu)",
+  "Can't open shared memory; cannot send request event to server (%lu)",
+  "Wrong or unknown protocol",
+  "Invalid connection handle",
+  "Connection using old (pre-4.1.1) authentication protocol refused (client 
option 'secure_auth' enabled)",
+  "Row retrieval was canceled by mysql_stmt_close() call",
+  "Attempt to read column without prior row fetch",
+  "Prepared statement contains no metadata",
+  "Attempt to read a row while there is no result set associated with the 
statement",
+  "This feature is not implemented yet",
+  ""
+};
+
+const char *unknown_sqlstate= "HY000";
+const char *not_error_sqlstate= "00000";
+
+class CarobMYSQL;
+
+typedef struct st_cmysql {
+       MYSQL my;
+       CarobMYSQL *carob;
+} CMYSQL;
+
+class CarobMYSQL
+{
+public:
+       CarobMYSQL();
+       ~CarobMYSQL();
+
+       bool connect(const char *host, const char *user,
+                   const char *passwd, const char *db, unsigned int port,
+                   const char *unix_socket, unsigned long clientflag);
+       bool real_query(const char *query, ulong length);
+       MYSQL_RES *get_results(int size);
+       MYSQL_ROW fetch_row();
+       
+       MYSQL *getMYSQL();
+
+private:
+       CMYSQL *mysqlPtr;
+       Connection *connectionPtr;
+       ConnectionPool *connectionPool;
+       Statement *stmtPtr;
+       DriverResultSet* drsPtr;
+       MYSQL_ROW row;
+       int nfields;
+       
+       void allocRow(int no);
+       void deleteRow();
+};
+
+CarobMYSQL::CarobMYSQL() : connectionPtr(NULL), stmtPtr(NULL), drsPtr(NULL)
+{
+       mysqlPtr = new CMYSQL();
+       memset(&mysqlPtr->my, 0, sizeof(MYSQL));
+       mysqlPtr->carob = this;
+       connectionPool = &ConnectionPool::getInstance();
+}
+
+CarobMYSQL::~CarobMYSQL()
+{
+       delete mysqlPtr;
+       if (connectionPtr) delete connectionPtr;
+       if (stmtPtr) delete stmtPtr;
+//     if (drsPtr) delete drsPtr;
+       deleteRow();
+}
+
+bool CarobMYSQL::connect(const char *host, const char *user,
+    const char *passwd, const char *db, unsigned int port,
+    const char *unix_socket, unsigned long clientflag)
+{
+       if (unix_socket)
+       {
+               set_mysql_error((MYSQL *)mysqlPtr, CR_NOT_IMPLEMENTED, 
unknown_sqlstate);
+               return false;
+       }
+       
+//TODO Fill the mysqlPtr structure
+       ConnectionParameters connectionParameters(fromString(host), port ? port 
: 25322, fromString(db), fromString(user), fromString(passwd), 
DEBUG_LEVEL_DEBUG);
+
+       try {
+               connectionPtr = 
connectionPool->connectToController(connectionParameters);
+               stmtPtr = connectionPtr->createStatement();
+       } catch (...) {
+               set_mysql_error((MYSQL *)mysqlPtr, CR_CONNECTION_ERROR, 
unknown_sqlstate);
+               return false;
+       }
+       
+       return true;
+}
+
+bool CarobMYSQL::real_query(const char *query, ulong length)
+{
+       try {
+               if (drsPtr) delete drsPtr;
+
+               if (stmtPtr->execute(fromString(query)))
+                       mysqlPtr->my.affected_rows = 0;
+               else
+                       mysqlPtr->my.affected_rows = stmtPtr->getUpdateCount();
+               
+               return true;
+       } catch (...) {
+               //TODO Error  : connectionPtr(NULL), stmtPtr(NULL), 
drsPtr(NULL)handling
+               return false;
+       }
+}
+
+MYSQL_RES * CarobMYSQL::get_results(int size)
+{
+       try {
+               if (stmtPtr)
+               {
+                       stmtPtr->setFetchSize(size);
+                       drsPtr = stmtPtr->getResultSet();
+                       if (drsPtr)
+                       {
+                               mysqlPtr->my.field_count = 
drsPtr->getNumberOfColumns();
+                               mysqlPtr->my.affected_rows = 
drsPtr->getNumberOfRowsInMemory();
+                       }
+                       return (MYSQL_RES *) this;
+               }
+               return NULL;
+       } catch (...) {
+               //TODO error handling
+               return NULL;
+       }
+}
+
+MYSQL_ROW CarobMYSQL::fetch_row()
+{
+       if (drsPtr)
+       {
+               deleteRow();
+               if (drsPtr->next())
+               {
+                       allocRow(mysqlPtr->my.field_count);
+                       for (unsigned i=0; i<mysqlPtr->my.field_count; i++)
+                       {
+                               char s[200];
+                               sprintf(s,"%d",drsPtr->getInt(i+1));
+                               row[i] = new char[strlen(s)+1];
+                               strcpy(row[i],s);
+                       }
+                       
+                       mysqlPtr->my.affected_rows = 
drsPtr->getNumberOfRowsInMemory();
+                       
+                       return row;
+               }
+               return 0;
+       }
+       else
+               return 0;
+}
+
+MYSQL *CarobMYSQL::getMYSQL()
+{
+       return (MYSQL *) mysqlPtr;
+}
+
+typedef char *PCHAR;
+
+void CarobMYSQL::allocRow(int no)
+{
+       row = new PCHAR[no];
+       nfields = no;
+       memset(row, sizeof(PCHAR)*no, 0);
+}
+
+void CarobMYSQL::deleteRow()
+{
+       if (row)
+       {
+               for (int i=0; i<nfields; i++)
+                       if (row[i])     delete row[i];
+               delete row;
+               row = NULL;
+       }
+}
+
+/***********************************
+ * MySQL functions
+ ***********************************/
+ 
+MYSQL *STDCALL
+mysql_init(MYSQL * mysql)
+{
+       if (!mysql)
+       {
+               CarobMYSQL *tmp = new CarobMYSQL();
+               mysql = tmp->getMYSQL();
+       }
+       
+       return mysql;
+}
+
+MYSQL *STDCALL
+mysql_real_connect (MYSQL * mysql, const char *host, const char *user,
+                   const char *passwd, const char *db, unsigned int port,
+                   const char *unix_socket, unsigned long clientflag)
+{
+       if (mysql) {
+               return ((CMYSQL *)mysql)->carob->connect(host, user, passwd, 
db, port, unix_socket, clientflag) ? mysql : 0;
+       }
+       else
+       {
+               set_mysql_error(mysql, CR_NULL_POINTER, unknown_sqlstate);
+               return 0;
+       }
+}
+
+void STDCALL
+mysql_close (MYSQL *sock)
+{
+       if (sock)
+               delete ((CMYSQL *)sock)->carob;
+}
+
+/* error handling functions */
+void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate)
+{
+  NET *net;
+
+  net= &mysql->net;
+  net->last_errno= errcode;
+  strcpy(net->last_error, ER(errcode));
+  strcpy(net->sqlstate, sqlstate);
+}
+
+unsigned int STDCALL
+mysql_errno(MYSQL *mysql)
+{
+       return mysql->net.last_errno;
+}
+
+const char * STDCALL
+mysql_error(MYSQL *mysql)
+{
+       return mysql->net.last_error;
+}
+
+const char *STDCALL
+mysql_sqlstate(MYSQL *mysql)
+{
+       return mysql->net.sqlstate;
+}
+
+int STDCALL
+mysql_query(MYSQL *mysql, const char *q)
+{
+       return mysql_real_query(mysql, q, 0);
+}
+
+int STDCALL
+mysql_real_query(MYSQL *mysql, const char *query, ulong length)
+{
+       if (mysql) {
+               //FIXME handle special strings which can contains '\0'
+               if ( ((CMYSQL *)mysql)->carob->real_query(query, length) )
+               {
+                       return 0;
+               }
+               else
+               {
+                       set_mysql_error(mysql, CR_UNKNOWN_ERROR, 
unknown_sqlstate);
+                       return CR_UNKNOWN_ERROR;
+               }
+       }
+       else
+       {
+               set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
+               return CR_UNKNOWN_ERROR;
+       }
+}
+
+MYSQL_RES * STDCALL
+mysql_store_result(MYSQL *mysql)
+{
+       if (mysql) {
+               return ((CMYSQL *)mysql)->carob->get_results(0);
+       }
+       else
+       {
+               set_mysql_error(mysql, CR_NULL_POINTER, unknown_sqlstate);
+               return 0;
+       }
+}
+
+MYSQL_RES * STDCALL
+mysql_use_result(MYSQL *mysql)
+{
+       if (mysql) {
+               return ((CMYSQL *)mysql)->carob->get_results(1);
+       }
+       else
+       {
+               set_mysql_error(mysql, CR_NULL_POINTER, unknown_sqlstate);
+               return 0;
+       }
+}
+
+MYSQL_ROW      STDCALL mysql_fetch_row(MYSQL_RES *result)
+{
+       if (result) {
+               return ((CarobMYSQL *)result)->fetch_row();
+       }
+       else
+       {
+               //TODO set error
+               return 0;
+       }
+}
+
+unsigned int STDCALL mysql_num_fields(MYSQL_RES *res)
+{
+       if (res) {
+               return ((CarobMYSQL *)res)->getMYSQL()->field_count; // 
get_num_fields();
+       }
+       else
+       {
+               //TODO set error
+               return 0;
+       }
+}
+
+my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql)
+{
+       if (mysql) {
+               return mysql->affected_rows; 
+       }
+       else
+       {
+               //TODO set error
+               return 0;
+       }
+}
+
+my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res)
+{
+       if (res) {
+               return ((CarobMYSQL *)res)->getMYSQL()->affected_rows;
+       }
+       else
+       {
+               //TODO set error
+               return 0;
+       }
+}
Index: libmysequoia/src/CarobMySQL.cpp
diff -u /dev/null libmysequoia/src/CarobMySQL.cpp:1.1
--- /dev/null   Fri Dec  2 13:54:20 2005
+++ libmysequoia/src/CarobMySQL.cpp     Fri Dec  2 13:54:20 2005
@@ -0,0 +1,96 @@
+/**
+ * Sequoia: Database clustering technology.
+ * Copyright (C) 2005 Emic Networks
+ * Contact: [EMAIL PROTECTED]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Initial developer(s): Zsolt Simon, Csaba Simon
+ * Contributor(s): 
+ */
+
+#include <CarobMySQL.hpp>
+
+CarobMYSQL::CarobMYSQL()
+{
+}
+
+CarobMYSQL::~CarobMYSQL()
+{
+}
+
+bool CarobMYSQL::connect(const char *host, const char *user,
+            const char *passwd, const char *db, unsigned int port,
+            const char *unix_socket, unsigned long clientflag)
+{
+}
+    
+bool CarobMYSQL::select_db(const char *db)
+{
+}
+    
+bool CarobMYSQL::change_user(const char *user, const char *passwd, const char 
*db)
+{
+}
+       
+bool CarobMYSQL::real_query(const char *query, ulong length)
+{
+}
+    
+MYSQL_RES * CarobMYSQL::get_results(my_bool fetch_all)
+{
+}
+       
+bool CarobMYSQL::more_results()
+{
+}
+
+bool CarobMYSQL::next_result()
+{
+}
+       
+void CarobMYSQL::free_results(MYSQL_RES *res)
+{
+}
+   
+bool CarobMYSQL::eof()
+{
+}
+    
+bool CarobMYSQL::set_autocommit(const my_bool mode)
+{
+}
+    
+bool CarobMYSQL::commit()
+{
+}
+    
+bool CarobMYSQL::rollback()
+{
+}
+    
+MYSQL_RES *CarobMYSQL::list_table_fields(const char *table, const char *wild)
+{
+}
+    
+MYSQL_RES *CarobMYSQL::list_databases(const char *wild)
+{
+}
+
+MYSQL_RES *CarobMYSQL::mysql_list_tables(const char *wild)
+{
+}
+
+MYSQL *CarobMYSQL::getMYSQL()
+{
+}
Index: libmysequoia/src/Makefile
diff -u libmysequoia/src/Makefile:1.2 libmysequoia/src/Makefile:removed
--- libmysequoia/src/Makefile:1.2       Mon Nov 28 10:39:01 2005
+++ libmysequoia/src/Makefile   Fri Dec  2 13:54:20 2005
@@ -1,17 +0,0 @@
-all: hello-libmysequoia libmysqlclient.so.15.1
-
-hello-libmysequoia: hello-libmysequoia.c
-       cc -Wall -g `mysql_config --include` -o $@ $< `mysql_config --libs`
-
-libmysqlclient.so.15.1: libmysql.o
-       c++ -Wall -g -fPIC --shared -L../../carob -lcarobcpp -o $@ $<
-       ln -sf $@ libmysqlclient.so.15
-
-libmysql.o: libmysequoia.cpp
-       c++ -Wall -g -o $@ -I../../carob/include -I/usr/include/mysql -c $<
-
-clean:
-       rm -f libmysqlclient.so.15.1 libmysqlclient.so.15 libmysql.o 
hello-libmysequoia
-
-run: all
-       LD_LIBRARY_PATH=.:../../carob ./hello-libmysequoia
Index: libmysequoia/src/MySQLAPI.cpp
diff -u /dev/null libmysequoia/src/MySQLAPI.cpp:1.1
--- /dev/null   Fri Dec  2 13:54:20 2005
+++ libmysequoia/src/MySQLAPI.cpp       Fri Dec  2 13:54:20 2005
@@ -0,0 +1,591 @@
+/**
+ * Sequoia: Database clustering technology.
+ * Copyright (C) 2005 Emic Networks
+ * Contact: [EMAIL PROTECTED]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Initial developer(s): Zsolt Simon, Csaba Simon
+ * Contributor(s): 
+ */
+
+#include <CarobMySQL.hpp>
+
+/* Library initialization, shutdown */
+
+MYSQL *STDCALL
+mysql_init (MYSQL * mysql)
+{
+       return 0;
+}
+
+void STDCALL
+mysql_close (MYSQL * sock)
+{
+}
+
+int STDCALL
+mysql_server_init (int argc, char **argv, char **groups)
+{
+       return 0;
+}
+
+void STDCALL
+mysql_server_end (void)
+{
+}
+
+/* Connect functions */
+
+MYSQL *STDCALL
+mysql_connect (MYSQL * mysql, const char *host, const char *user,
+              const char *passwd)
+{
+       return 0;
+}
+
+MYSQL *STDCALL
+mysql_real_connect (MYSQL * mysql, const char *host, const char *user,
+                   const char *passwd, const char *db, unsigned int port,
+                   const char *unix_socket, unsigned long clientflag)
+{
+       return 0;
+}
+
+int STDCALL
+mysql_select_db (MYSQL * mysql, const char *db)
+{
+       return 0;
+}
+
+my_bool STDCALL
+mysql_change_user (MYSQL * mysql, const char *user, const char *passwd,
+                  const char *db)
+{
+       return 0;
+}
+
+int STDCALL
+mysql_options (MYSQL * mysql, enum mysql_option option, const char *arg)
+{
+       return 0;
+}
+
+int STDCALL
+mysql_ping (MYSQL * mysql)
+{
+       return 0;
+}
+
+/* Query functions */
+
+int STDCALL
+mysql_query (MYSQL * mysql, const char *q)
+{
+       return 0;
+}
+
+int STDCALL
+mysql_real_query (MYSQL * mysql, const char *q, unsigned long length)
+{
+       return 0;
+}
+
+MYSQL_RES *STDCALL
+mysql_use_result (MYSQL * mysql)
+{
+       return 0;
+}
+
+MYSQL_RES *STDCALL
+mysql_store_result (MYSQL * mysql)
+{
+       return 0;
+}
+
+void STDCALL
+mysql_free_result (MYSQL_RES * result)
+{
+}
+
+MYSQL_ROW STDCALL
+mysql_fetch_row (MYSQL_RES * result)
+{
+       return 0;
+}
+
+my_bool STDCALL
+mysql_eof (MYSQL_RES * res)
+{
+       return 0;
+}
+
+my_bool STDCALL
+mysql_more_results (MYSQL * mysql)
+{
+       return 0;
+}
+
+int STDCALL
+mysql_next_result (MYSQL * mysql)
+{
+       return 0;
+}
+
+void STDCALL
+mysql_data_seek (MYSQL_RES * result, my_ulonglong offset)
+{
+}
+
+MYSQL_ROW_OFFSET STDCALL
+mysql_row_seek (MYSQL_RES * result, MYSQL_ROW_OFFSET offset)
+{
+       return 0;
+}
+
+MYSQL_ROW_OFFSET STDCALL
+mysql_row_tell (MYSQL_RES * res)
+{
+       return 0;
+}
+
+MYSQL_FIELD *STDCALL
+mysql_fetch_field (MYSQL_RES * result)
+{
+       return 0;
+}
+
+MYSQL_FIELD *STDCALL
+mysql_fetch_field_direct (MYSQL_RES * res, unsigned int fieldnr)
+{
+       return 0;
+}
+
+MYSQL_FIELD *STDCALL
+mysql_fetch_fields (MYSQL_RES * res)
+{
+       return 0;
+}
+
+unsigned long *STDCALL
+mysql_fetch_lengths (MYSQL_RES * result)
+{
+       return 0;
+}
+
+MYSQL_FIELD_OFFSET STDCALL
+mysql_field_seek (MYSQL_RES * result, MYSQL_FIELD_OFFSET offset)
+{
+       return 0;
+}
+
+unsigned int STDCALL
+mysql_field_count (MYSQL * mysql)
+{
+       return 0;
+}
+
+MYSQL_FIELD_OFFSET STDCALL
+mysql_field_tell (MYSQL_RES * res)
+{
+       return 0;
+}
+
+unsigned int STDCALL
+mysql_num_fields (MYSQL_RES * res)
+{
+       return 0;
+}
+
+my_ulonglong
+mysql_affected_rows (MYSQL * mysql)
+{
+       return 0;
+}
+
+my_ulonglong STDCALL
+mysql_num_rows (MYSQL_RES * res)
+{
+       return 0;
+}
+
+my_ulonglong STDCALL
+mysql_insert_id (MYSQL * mysql)
+{
+       return 0;
+}
+
+/* Error handling */
+
+unsigned int STDCALL
+mysql_errno (MYSQL * mysql)
+{
+       return 0;
+}
+
+const char *STDCALL
+mysql_error (MYSQL * mysql)
+{
+       return 0;
+}
+
+const char *STDCALL
+mysql_sqlstate (MYSQL * mysql)
+{
+       return 0;
+}
+
+unsigned int STDCALL
+mysql_warning_count (MYSQL * mysql)
+{
+       return 0;
+}
+
+void STDCALL
+mysql_debug (const char *debug)
+{
+}
+
+/* Misc functions */
+
+unsigned long STDCALL
+mysql_escape_string (char *to, const char *from, unsigned long from_length)
+{
+       return 0;
+}
+
+unsigned long STDCALL
+mysql_real_escape_string (MYSQL * mysql, char *to, const char *from,
+                         unsigned long length)
+{
+       return 0;
+}
+
+const char *
+mysql_character_set_name (MYSQL * mysql)
+{
+       return 0;
+}
+
+/* Transaction support */
+
+my_bool STDCALL
+mysql_autocommit (MYSQL * mysql, my_bool auto_mode)
+{
+       return 0;
+}
+
+my_bool STDCALL
+mysql_commit (MYSQL * mysql)
+{
+       return 0;
+}
+
+my_bool STDCALL
+mysql_rollback (MYSQL * mysql)
+{
+       return 0;
+}
+
+/* Server management */
+
+int STDCALL
+mysql_create_db (MYSQL * mysql, const char *DB)
+{
+       return 0;
+}
+
+int STDCALL
+mysql_drop_db (MYSQL * mysql, const char *DB)
+{
+       return 0;
+}
+
+int STDCALL
+mysql_shutdown (MYSQL * mysql, enum mysql_enum_shutdown_level shutdown_level)
+{
+       return 0;
+}
+
+int STDCALL
+mysql_refresh (MYSQL * mysql, unsigned int refresh_options)
+{
+       return 0;
+}
+
+/* Metadata */
+
+const char *STDCALL
+mysql_get_client_info (void)
+{
+       return 0;
+}
+
+unsigned long STDCALL
+mysql_get_client_version (void)
+{
+       return 0;
+}
+
+const char *STDCALL
+mysql_get_host_info (MYSQL * mysql)
+{
+       return 0;
+}
+
+const char *
+mysql_get_server_info (MYSQL * mysql)
+{
+       return 0;
+}
+
+unsigned long STDCALL
+mysql_get_server_version (MYSQL * mysql)
+{
+       return 0;
+}
+
+unsigned int STDCALL
+mysql_get_proto_info (MYSQL * mysql)
+{
+       return 0;
+}
+
+const char *STDCALL
+mysql_info (MYSQL * mysql)
+{
+       return 0;
+}
+
+MYSQL_RES *STDCALL
+mysql_list_dbs (MYSQL * mysql, const char *wild)
+{
+       return 0;
+}
+
+MYSQL_RES *STDCALL
+mysql_list_fields (MYSQL * mysql, const char *table, const char *wild)
+{
+       return 0;
+}
+
+MYSQL_RES *STDCALL
+mysql_list_processes (MYSQL * mysql)
+{
+       return 0;
+}
+
+MYSQL_RES *STDCALL
+mysql_list_tables (MYSQL * mysql, const char *wild)
+{
+       return 0;
+}
+
+const char *STDCALL
+mysql_stat (MYSQL * mysql)
+{
+       return 0;
+}
+
+/* Thread functions */
+
+my_bool
+mysql_thread_init (void)
+{
+       return 0;
+}
+
+void
+mysql_thread_end (void)
+{
+}
+
+unsigned long STDCALL
+mysql_thread_id (MYSQL * mysql)
+{
+       return 0;
+}
+
+unsigned int STDCALL
+mysql_thread_safe (void)
+{
+       return 0;
+}
+
+/* Prepared statements */
+
+my_ulonglong
+mysql_stmt_affected_rows (MYSQL_STMT * stmt)
+{
+       return 0;
+}
+
+my_bool
+mysql_stmt_attr_get (MYSQL_STMT * stmt, enum enum_stmt_attr_type option,
+                    void *arg)
+{
+       return 0;
+}
+
+my_bool
+mysql_stmt_attr_set (MYSQL_STMT * stmt, enum enum_stmt_attr_type option,
+                    const void *arg)
+{
+       return 0;
+}
+
+my_bool
+mysql_stmt_bind_param (MYSQL_STMT * stmt, MYSQL_BIND * bind)
+{
+       return 0;
+}
+
+my_bool
+mysql_stmt_bind_result (MYSQL_STMT * stmt, MYSQL_BIND * bind)
+{
+       return 0;
+}
+
+my_bool
+mysql_stmt_close (MYSQL_STMT *)
+{
+       return 0;
+}
+
+void
+mysql_stmt_data_seek (MYSQL_STMT * stmt, my_ulonglong offset)
+{
+}
+
+unsigned int
+mysql_stmt_errno (MYSQL_STMT * stmt)
+{
+       return 0;
+}
+
+const char *
+mysql_stmt_error (MYSQL_STMT * stmt)
+{
+       return 0;
+}
+
+int
+mysql_stmt_execute (MYSQL_STMT * stmt)
+{
+       return 0;
+}
+
+int
+mysql_stmt_fetch (MYSQL_STMT * stmt)
+{
+       return 0;
+}
+
+int
+mysql_stmt_fetch_column (MYSQL_STMT * stmt, MYSQL_BIND * bind,
+                        unsigned int column, unsigned long offset)
+{
+       return 0;
+}
+
+unsigned int
+mysql_stmt_field_count (MYSQL_STMT * stmt)
+{
+       return 0;
+}
+
+my_bool
+mysql_stmt_free_result (MYSQL_STMT * stmt)
+{
+       return 0;
+}
+
+MYSQL_STMT *
+mysql_stmt_init (MYSQL * mysql)
+{
+       return 0;
+}
+
+my_ulonglong
+mysql_stmt_insert_id (MYSQL_STMT * stmt)
+{
+       return 0;
+}
+
+my_ulonglong
+mysql_stmt_num_rows (MYSQL_STMT * stmt)
+{
+       return 0;
+}
+
+unsigned long
+mysql_stmt_param_count (MYSQL_STMT * stmt)
+{
+       return 0;
+}
+
+MYSQL_RES *
+mysql_stmt_param_metadata (MYSQL_STMT * stmt)
+{
+       return 0;
+}
+
+int
+mysql_stmt_prepare (MYSQL_STMT * stmt, const char *query,
+                   unsigned long length)
+{
+       return 0;
+}
+
+my_bool
+mysql_stmt_reset (MYSQL_STMT * stmt)
+{
+       return 0;
+}
+
+MYSQL_RES *
+mysql_stmt_result_metadata (MYSQL_STMT * stmt)
+{
+       return 0;
+}
+
+MYSQL_ROW_OFFSET
+mysql_stmt_row_seek (MYSQL_STMT * stmt, MYSQL_ROW_OFFSET offset)
+{
+       return 0;
+}
+
+MYSQL_ROW_OFFSET
+mysql_stmt_row_tell (MYSQL_STMT * stmt)
+{
+       return 0;
+}
+
+my_bool
+mysql_stmt_send_long_data (MYSQL_STMT * stmt, unsigned int parameter_number,
+                          const char *data, unsigned long length)
+{
+       return 0;
+}
+
+const char *
+mysql_stmt_sqlstate (MYSQL_STMT * stmt)
+{
+       return 0;
+}
+
+int
+mysql_stmt_store_result (MYSQL_STMT * stmt)
+{
+       return 0;
+}
Index: libmysequoia/src/hello-libmysequoia.c
diff -u libmysequoia/src/hello-libmysequoia.c:1.1 
libmysequoia/src/hello-libmysequoia.c:removed
--- libmysequoia/src/hello-libmysequoia.c:1.1   Mon Nov 28 10:20:40 2005
+++ libmysequoia/src/hello-libmysequoia.c       Fri Dec  2 13:54:20 2005
@@ -1,130 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <my_global.h>
-#include <my_sys.h>
-#include <mysql.h>
-
-/*
- * To create the table and insert some data:
- * $ mysql -uroot -prootpass
- * > USE test;
- * > CREATE table t1 ( `a` int(11) NOT NULL auto_increment,
- *                    `b` int(11) default NULL,
- *                     PRIMARY KEY  (`a`)
- *                  ) ENGINE=InnoDB; 
- * > INSERT INTO t1 (b) VALUES (1),(2),(3)
- * > exit
- */
-
-static void
-print_error (MYSQL * conn, char *message)
-{
-  fprintf (stderr, "%s\n", message);
-  if (conn != NULL)
-    {
-      fprintf (stderr, "Error %u (%s): %s\n",
-              mysql_errno (conn), mysql_sqlstate (conn), mysql_error (conn));
-    }
-}
-
-
-void
-process_result_set (MYSQL * conn, MYSQL_RES * res_set)
-{
-  MYSQL_ROW row;
-  unsigned int i;
-
-  while ((row = mysql_fetch_row (res_set)) != NULL)
-    {
-      for (i = 0; i < mysql_num_fields (res_set); i++)
-       {
-         if (i > 0)
-           {
-             fputc ('\t', stdout);
-           }
-         printf ("%s", row[i] != NULL ? row[i] : "NULL");
-       }
-      fputc ('\n', stdout);
-    }
-  if (mysql_errno (conn) != 0)
-    print_error (conn, "mysql_fetch_row() failed");
-  else
-    printf ("%lu rows returned\n", (unsigned long) mysql_num_rows (res_set));
-}
-
-
-int
-main ()
-{
-  char *opt_host_name = "localhost";   /* server host (default=localhost) */
-  char *opt_user_name = "user";        /* username (default=login name) */
-  char *opt_password = "userpass";     /* password (default=none) */
-  unsigned int opt_port_num = 0;       /* port number (use built-in value) */
-  char *opt_socket_name = NULL;        /* socket name (use built-in value) */
-  char *opt_db_name = "db";    /* database name (default=none) */
-  unsigned int opt_flags = 0;  /* connection flags (none) */
-  MYSQL *conn;                 /* pointer to connection handler */
-  MYSQL_RES *res_set;
-
-  /* initialize connection handler */
-  conn = mysql_init (NULL);
-  if (conn == NULL)
-    {
-      fprintf (stderr, "mysql_init() failed (probably out of memory)\n");
-      exit (1);
-    }
-
-  /* connect to server */
-  if (mysql_real_connect (conn, opt_host_name, opt_user_name, opt_password,
-                         opt_db_name, opt_port_num, opt_socket_name,
-                         opt_flags) == NULL)
-    {
-      fprintf (stderr, "mysql_real_connect() failed\n");
-      mysql_close (conn);
-      exit (1);
-    }
-
-  /* the insert must succed */
-  if (mysql_query (conn, "INSERT INTO t1(b) VALUES (4)") != 0)
-    {
-      print_error (conn, "INSERT statement failed");
-    }
-  else
-    {
-      printf ("INSERT statement succeeded: %lu rows affected\n",
-             (unsigned long) mysql_affected_rows (conn));
-    }
-
-  /* the insert must fail (duplicate key) */
-/*  if (mysql_query (conn, "INSERT INTO t1 (a,b) VALUES (1,2)") != 0)
-    {
-      print_error (conn, "INSERT statement failed");
-    }
-  else
-    {
-      printf ("INSERT statement succeeded: %lu rows affected\n",
-             (unsigned long) mysql_affected_rows (conn));
-    }*/
-
-  /* simple query */
-  if (mysql_query (conn, "SELECT * from t1") != 0)
-    print_error (conn, "mysql_query() failed");
-  else
-    {
-      res_set = mysql_store_result (conn);     /* generate result set */
-      if (res_set == NULL)
-       print_error (conn, "mysql_store_result() failed");
-      else
-       {
-         /* process result set, and then deallocate it */
-         process_result_set (conn, res_set);
-//       mysql_free_result (res_set);
-       }
-    }
-
-  /* disconnect from server */
-  mysql_close (conn);
-
-  return 0;
-}
Index: libmysequoia/src/libmysequoia.cpp
diff -u libmysequoia/src/libmysequoia.cpp:1.3 
libmysequoia/src/libmysequoia.cpp:removed
--- libmysequoia/src/libmysequoia.cpp:1.3       Fri Dec  2 12:11:08 2005
+++ libmysequoia/src/libmysequoia.cpp   Fri Dec  2 13:54:20 2005
@@ -1,450 +0,0 @@
-/**
- * Sequoia: Database clustering technology.
- * Copyright (C) 2005 Emic Networks
- * Contact: [EMAIL PROTECTED]
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Initial developer(s): Zsolt Simon, Csaba Simon
- * Contributor(s): 
- */
- 
- /**
-  * This is only a first prototype that is demonstrating that 
-  * the libmysequoia project is doable.
-  * There is no error checking nor exception handling and no
-  * comment on the code.
-  */
-  
-/* C includes */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-/* MySQL includes */
-#include <my_global.h>
-#include <my_sys.h>
-#include <mysql.h>
-#include <errmsg.h>
-
-/* Carob includes */
-#include <ConnectionParameters.hpp>
-#include <ConnectionPool.hpp>
-#include <DriverResultSet.hpp>
-#include <Statement.hpp>
-
-/* C++ includes */
-#include <string>
-#include <vector>
-#include <locale>
-
-using namespace CarobNS;
-
-void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate);
-
-const char *client_errors[]=
-{
-  "Unknown MySQL error",
-  "Can't create UNIX socket (%d)",
-  "Can't connect to local MySQL server through socket '%-.100s' (%d)",
-  "Can't connect to MySQL server on '%-.100s' (%d)",
-  "Can't create TCP/IP socket (%d)",
-  "Unknown MySQL server host '%-.100s' (%d)",
-  "MySQL server has gone away",
-  "Protocol mismatch; server version = %d, client version = %d",
-  "MySQL client ran out of memory",
-  "Wrong host info",
-  "Localhost via UNIX socket",
-  "%-.100s via TCP/IP",
-  "Error in server handshake",
-  "Lost connection to MySQL server during query",
-  "Commands out of sync; you can't run this command now",
-  "Named pipe: %-.32s",
-  "Can't wait for named pipe to host: %-.64s  pipe: %-.32s (%lu)",
-  "Can't open named pipe to host: %-.64s  pipe: %-.32s (%lu)",
-  "Can't set state of named pipe to host: %-.64s  pipe: %-.32s (%lu)",
-  "Can't initialize character set %-.32s (path: %-.100s)",
-  "Got packet bigger than 'max_allowed_packet' bytes",
-  "Embedded server",
-  "Error on SHOW SLAVE STATUS:",
-  "Error on SHOW SLAVE HOSTS:",
-  "Error connecting to slave:",
-  "Error connecting to master:",
-  "SSL connection error",
-  "Malformed packet",
-  "This client library is licensed only for use with MySQL servers having '%s' 
license",
-  "Invalid use of null pointer",
-  "Statement not prepared",
-  "No data supplied for parameters in prepared statement",
-  "Data truncated",
-  "No parameters exist in the statement",
-  "Invalid parameter number",
-  "Can't send long data for non-string/non-binary data types (parameter: %d)",
-  "Using unsupported buffer type: %d  (parameter: %d)",
-  "Shared memory: %-.100s",
-  "Can't open shared memory; client could not create request event (%lu)",
-  "Can't open shared memory; no answer event received from server (%lu)",
-  "Can't open shared memory; server could not allocate file mapping (%lu)",
-  "Can't open shared memory; server could not get pointer to file mapping 
(%lu)",
-  "Can't open shared memory; client could not allocate file mapping (%lu)",
-  "Can't open shared memory; client could not get pointer to file mapping 
(%lu)",
-  "Can't open shared memory; client could not create %s event (%lu)",
-  "Can't open shared memory; no answer from server (%lu)",
-  "Can't open shared memory; cannot send request event to server (%lu)",
-  "Wrong or unknown protocol",
-  "Invalid connection handle",
-  "Connection using old (pre-4.1.1) authentication protocol refused (client 
option 'secure_auth' enabled)",
-  "Row retrieval was canceled by mysql_stmt_close() call",
-  "Attempt to read column without prior row fetch",
-  "Prepared statement contains no metadata",
-  "Attempt to read a row while there is no result set associated with the 
statement",
-  "This feature is not implemented yet",
-  ""
-};
-
-const char *unknown_sqlstate= "HY000";
-const char *not_error_sqlstate= "00000";
-
-class CarobMYSQL;
-
-typedef struct st_cmysql {
-       MYSQL my;
-       CarobMYSQL *carob;
-} CMYSQL;
-
-class CarobMYSQL
-{
-public:
-       CarobMYSQL();
-       ~CarobMYSQL();
-
-       bool connect(const char *host, const char *user,
-                   const char *passwd, const char *db, unsigned int port,
-                   const char *unix_socket, unsigned long clientflag);
-       bool real_query(const char *query, ulong length);
-       MYSQL_RES *get_results(int size);
-       MYSQL_ROW fetch_row();
-       
-       MYSQL *getMYSQL();
-
-private:
-       CMYSQL *mysqlPtr;
-       Connection *connectionPtr;
-       ConnectionPool *connectionPool;
-       Statement *stmtPtr;
-       DriverResultSet* drsPtr;
-       MYSQL_ROW row;
-       int nfields;
-       
-       void allocRow(int no);
-       void deleteRow();
-};
-
-CarobMYSQL::CarobMYSQL() : connectionPtr(NULL), stmtPtr(NULL), drsPtr(NULL)
-{
-       mysqlPtr = new CMYSQL();
-       memset(&mysqlPtr->my, 0, sizeof(MYSQL));
-       mysqlPtr->carob = this;
-       connectionPool = &ConnectionPool::getInstance();
-}
-
-CarobMYSQL::~CarobMYSQL()
-{
-       delete mysqlPtr;
-       if (connectionPtr) delete connectionPtr;
-       if (stmtPtr) delete stmtPtr;
-//     if (drsPtr) delete drsPtr;
-       deleteRow();
-}
-
-bool CarobMYSQL::connect(const char *host, const char *user,
-    const char *passwd, const char *db, unsigned int port,
-    const char *unix_socket, unsigned long clientflag)
-{
-       if (unix_socket)
-       {
-               set_mysql_error((MYSQL *)mysqlPtr, CR_NOT_IMPLEMENTED, 
unknown_sqlstate);
-               return false;
-       }
-       
-//TODO Fill the mysqlPtr structure
-       ConnectionParameters connectionParameters(fromString(host), port ? port 
: 25322, fromString(db), fromString(user), fromString(passwd), 
DEBUG_LEVEL_DEBUG);
-
-       try {
-               connectionPtr = 
connectionPool->connectToController(connectionParameters);
-               stmtPtr = connectionPtr->createStatement();
-       } catch (...) {
-               set_mysql_error((MYSQL *)mysqlPtr, CR_CONNECTION_ERROR, 
unknown_sqlstate);
-               return false;
-       }
-       
-       return true;
-}
-
-bool CarobMYSQL::real_query(const char *query, ulong length)
-{
-       try {
-               if (drsPtr) delete drsPtr;
-
-               if (stmtPtr->execute(fromString(query)))
-                       mysqlPtr->my.affected_rows = 0;
-               else
-                       mysqlPtr->my.affected_rows = stmtPtr->getUpdateCount();
-               
-               return true;
-       } catch (...) {
-               //TODO Error  : connectionPtr(NULL), stmtPtr(NULL), 
drsPtr(NULL)handling
-               return false;
-       }
-}
-
-MYSQL_RES * CarobMYSQL::get_results(int size)
-{
-       try {
-               if (stmtPtr)
-               {
-                       stmtPtr->setFetchSize(size);
-                       drsPtr = stmtPtr->getResultSet();
-                       if (drsPtr)
-                       {
-                               mysqlPtr->my.field_count = 
drsPtr->getNumberOfColumns();
-                               mysqlPtr->my.affected_rows = 
drsPtr->getNumberOfRowsInMemory();
-                       }
-                       return (MYSQL_RES *) this;
-               }
-               return NULL;
-       } catch (...) {
-               //TODO error handling
-               return NULL;
-       }
-}
-
-MYSQL_ROW CarobMYSQL::fetch_row()
-{
-       if (drsPtr)
-       {
-               deleteRow();
-               if (drsPtr->next())
-               {
-                       allocRow(mysqlPtr->my.field_count);
-                       for (unsigned i=0; i<mysqlPtr->my.field_count; i++)
-                       {
-                               char s[200];
-                               sprintf(s,"%d",drsPtr->getInt(i+1));
-                               row[i] = new char[strlen(s)+1];
-                               strcpy(row[i],s);
-                       }
-                       
-                       mysqlPtr->my.affected_rows = 
drsPtr->getNumberOfRowsInMemory();
-                       
-                       return row;
-               }
-               return 0;
-       }
-       else
-               return 0;
-}
-
-MYSQL *CarobMYSQL::getMYSQL()
-{
-       return (MYSQL *) mysqlPtr;
-}
-
-typedef char *PCHAR;
-
-void CarobMYSQL::allocRow(int no)
-{
-       row = new PCHAR[no];
-       nfields = no;
-       memset(row, sizeof(PCHAR)*no, 0);
-}
-
-void CarobMYSQL::deleteRow()
-{
-       if (row)
-       {
-               for (int i=0; i<nfields; i++)
-                       if (row[i])     delete row[i];
-               delete row;
-               row = NULL;
-       }
-}
-
-/***********************************
- * MySQL functions
- ***********************************/
- 
-MYSQL *STDCALL
-mysql_init(MYSQL * mysql)
-{
-       if (!mysql)
-       {
-               CarobMYSQL *tmp = new CarobMYSQL();
-               mysql = tmp->getMYSQL();
-       }
-       
-       return mysql;
-}
-
-MYSQL *STDCALL
-mysql_real_connect (MYSQL * mysql, const char *host, const char *user,
-                   const char *passwd, const char *db, unsigned int port,
-                   const char *unix_socket, unsigned long clientflag)
-{
-       if (mysql) {
-               return ((CMYSQL *)mysql)->carob->connect(host, user, passwd, 
db, port, unix_socket, clientflag) ? mysql : 0;
-       }
-       else
-       {
-               set_mysql_error(mysql, CR_NULL_POINTER, unknown_sqlstate);
-               return 0;
-       }
-}
-
-void STDCALL
-mysql_close (MYSQL *sock)
-{
-       if (sock)
-               delete ((CMYSQL *)sock)->carob;
-}
-
-/* error handling functions */
-void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate)
-{
-  NET *net;
-
-  net= &mysql->net;
-  net->last_errno= errcode;
-  strcpy(net->last_error, ER(errcode));
-  strcpy(net->sqlstate, sqlstate);
-}
-
-unsigned int STDCALL
-mysql_errno(MYSQL *mysql)
-{
-       return mysql->net.last_errno;
-}
-
-const char * STDCALL
-mysql_error(MYSQL *mysql)
-{
-       return mysql->net.last_error;
-}
-
-const char *STDCALL
-mysql_sqlstate(MYSQL *mysql)
-{
-       return mysql->net.sqlstate;
-}
-
-int STDCALL
-mysql_query(MYSQL *mysql, const char *q)
-{
-       return mysql_real_query(mysql, q, 0);
-}
-
-int STDCALL
-mysql_real_query(MYSQL *mysql, const char *query, ulong length)
-{
-       if (mysql) {
-               //FIXME handle special strings which can contains '\0'
-               if ( ((CMYSQL *)mysql)->carob->real_query(query, length) )
-               {
-                       return 0;
-               }
-               else
-               {
-                       set_mysql_error(mysql, CR_UNKNOWN_ERROR, 
unknown_sqlstate);
-                       return CR_UNKNOWN_ERROR;
-               }
-       }
-       else
-       {
-               set_mysql_error(mysql, CR_UNKNOWN_ERROR, unknown_sqlstate);
-               return CR_UNKNOWN_ERROR;
-       }
-}
-
-MYSQL_RES * STDCALL
-mysql_store_result(MYSQL *mysql)
-{
-       if (mysql) {
-               return ((CMYSQL *)mysql)->carob->get_results(0);
-       }
-       else
-       {
-               set_mysql_error(mysql, CR_NULL_POINTER, unknown_sqlstate);
-               return 0;
-       }
-}
-
-MYSQL_RES * STDCALL
-mysql_use_result(MYSQL *mysql)
-{
-       if (mysql) {
-               return ((CMYSQL *)mysql)->carob->get_results(1);
-       }
-       else
-       {
-               set_mysql_error(mysql, CR_NULL_POINTER, unknown_sqlstate);
-               return 0;
-       }
-}
-
-MYSQL_ROW      STDCALL mysql_fetch_row(MYSQL_RES *result)
-{
-       if (result) {
-               return ((CarobMYSQL *)result)->fetch_row();
-       }
-       else
-       {
-               //TODO set error
-               return 0;
-       }
-}
-
-unsigned int STDCALL mysql_num_fields(MYSQL_RES *res)
-{
-       if (res) {
-               return ((CarobMYSQL *)res)->getMYSQL()->field_count; // 
get_num_fields();
-       }
-       else
-       {
-               //TODO set error
-               return 0;
-       }
-}
-
-my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql)
-{
-       if (mysql) {
-               return mysql->affected_rows; 
-       }
-       else
-       {
-               //TODO set error
-               return 0;
-       }
-}
-
-my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res)
-{
-       if (res) {
-               return ((CarobMYSQL *)res)->getMYSQL()->affected_rows;
-       }
-       else
-       {
-               //TODO set error
-               return 0;
-       }
-}
Index: libmysequoia/test/Makefile
diff -u /dev/null libmysequoia/test/Makefile:1.1
--- /dev/null   Fri Dec  2 13:54:20 2005
+++ libmysequoia/test/Makefile  Fri Dec  2 13:54:20 2005
@@ -0,0 +1,28 @@
+#
+# Sequoia: Database clustering technology.
+# Copyright (C) 2005 Emic Networks
+# Contact: [EMAIL PROTECTED]
+# 
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+# 
+# http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Initial developer(s): Zsolt Simon, Csaba Simon
+# Contributor(s): 
+#
+# Makefile crafted from LibCarobCpp Makefile. Thanks Giles!
+#
+# Makefile for LibMySequoia and tests
+#
+
+all:
+
+clean:

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to