Date: Tuesday, January 10, 2006 @ 08:56:10
  Author: zsolt
    Path: /cvsroot/carob/libmysequoia

   Added: include/CarobStmt.hpp (1.1) src/CarobStmt.cpp (1.1)
Modified: include/CarobMySQL.hpp (1.17 -> 1.18) include/Utils.hpp (1.10 ->
          1.11) src/CarobMySQL.cpp (1.27 -> 1.28) src/Makefile.am (1.4 ->
          1.5) src/MySQLAPI.cpp (1.19 -> 1.20) src/Utils.cpp (1.10 ->
          1.11) test/TestMySQLAPI.cpp (1.13 -> 1.14)

- modified isCarobObject to check in a MEM_ROOT structure if the object 
contains a valid pointer (used will point to the carob object either CarobMYSQL 
or CarobStmt and block_size will hold the magic number)
- modified the test case, MySQLAPI and CarobMYSQL to support the above 
mentioned modification
- introduced a prepared statement skeleton, where execute partially working


------------------------+
 include/CarobMySQL.hpp |   12 +-
 include/CarobStmt.hpp  |   77 +++++++++++++
 include/Utils.hpp      |    1 
 src/CarobMySQL.cpp     |    6 -
 src/CarobStmt.cpp      |  265 +++++++++++++++++++++++++++++++++++++++++++++++
 src/Makefile.am        |    1 
 src/MySQLAPI.cpp       |  202 +++++++++++++++++++++++------------
 src/Utils.cpp          |    7 +
 test/TestMySQLAPI.cpp  |    4 
 9 files changed, 492 insertions(+), 83 deletions(-)


Index: libmysequoia/include/CarobMySQL.hpp
diff -u libmysequoia/include/CarobMySQL.hpp:1.17 
libmysequoia/include/CarobMySQL.hpp:1.18
--- libmysequoia/include/CarobMySQL.hpp:1.17    Mon Jan  2 13:19:56 2006
+++ libmysequoia/include/CarobMySQL.hpp Tue Jan 10 08:56:10 2006
@@ -44,6 +44,8 @@
 
 class CarobMYSQL
 {
+friend class CarobStmt;
+
 public:
   CarobMYSQL (MYSQL * mysql, my_bool free_me);
   ~CarobMYSQL ();
@@ -152,9 +154,7 @@
     /** 
      * Set the autocommit mode. If autocommit is on then all SQL statements 
will
      * be executed and commited as individual transactions.
-     * @param mode - true set autoc    CarobMYSQL(MYSQL *mysql, my_bool 
free_me);
-       ~CarobMYSQL();
-     * ommit on
+     * @param mode - true set autocommit on
      *               false set autocommit off
      * @return true on success otherwise false
      */
@@ -198,10 +198,12 @@
         * Returns a pointer to the MYSQL structure
    */
   MYSQL *getMYSQL ();
-
-private:
+  
+protected:
   MYSQL * mysqlPtr;
   CarobNS::Connection * connectionPtr;
+
+private:
   CarobNS::Statement * stmtPtr;
   CarobNS::DriverResultSet * drsPtr;
   //holds the result set for 'live' type of results
Index: libmysequoia/include/CarobStmt.hpp
diff -u /dev/null libmysequoia/include/CarobStmt.hpp:1.1
--- /dev/null   Tue Jan 10 08:56:10 2006
+++ libmysequoia/include/CarobStmt.hpp  Tue Jan 10 08:56:10 2006
@@ -0,0 +1,77 @@
+/*
+ * Sequoia: Database clustering technology.
+ * Copyright (C) 2005-2006 Continuent, Inc.
+ * 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): 
+ */
+
+#ifndef _CAROBSTMT_HPP
+#define _CAROBSTMT_HPP
+
+#include <CarobMySQL.hpp>
+
+//MySQL include
+#include <mysql.h>
+
+//Carob includes
+#include <ParameterStatement.hpp>
+
+class CarobStmt
+{
+public:
+  CarobStmt(MYSQL *mysql);
+       ~CarobStmt();
+  
+  int execute();
+  int fetch();
+  int prepare(const char *query, unsigned long length);
+  bool bind_param(const MYSQL_BIND *bind);
+  bool reset();
+  
+  MYSQL_RES *param_metadata();
+
+  int store_result();
+  static bool free_result(MYSQL_STMT *stmt);
+
+  MYSQL_STMT *getMYSQL_STMT() {return m_stmt;}
+private:
+  MYSQL_STMT *m_stmt;
+  CarobNS::ParameterStatement *c_stmt;
+  CarobMYSQL *cmysql;
+
+  // logger
+  static log4cxx::LoggerPtr logger;
+
+  /**
+   * Set the current mysql error to the specified one. The mysql error message 
will be filled from the error list.
+   * @param errcode mysql error code
+   * @param sqlstate ansi sql specific error code
+   */
+  void set_error (int errcode, int sqlstate);
+
+  /**
+   * Set the current mysql error to the specified one
+   * @param errcode mysql error code
+   * @param errmsg detailed mysql error message
+   * @param sqlstate ansi sql specific error message
+   */
+  void set_error (int errcode, const char *errmsg, const char *sqlstate);
+
+  void clear();
+};
+
+#endif /*_CAROBSTMT_HPP*/
Index: libmysequoia/include/Utils.hpp
diff -u libmysequoia/include/Utils.hpp:1.10 libmysequoia/include/Utils.hpp:1.11
--- libmysequoia/include/Utils.hpp:1.10 Mon Jan  2 13:19:56 2006
+++ libmysequoia/include/Utils.hpp      Tue Jan 10 08:56:10 2006
@@ -105,5 +105,6 @@
  * Return true if p is containing our Carob object
  */
 bool isCarobObject(MYSQL *p);
+bool isCarobObject(MYSQL_STMT *p);
 
 #endif /* _UTILS_HPP */
Index: libmysequoia/src/CarobMySQL.cpp
diff -u libmysequoia/src/CarobMySQL.cpp:1.27 
libmysequoia/src/CarobMySQL.cpp:1.28
--- libmysequoia/src/CarobMySQL.cpp:1.27        Mon Jan  2 13:19:56 2006
+++ libmysequoia/src/CarobMySQL.cpp     Tue Jan 10 08:56:10 2006
@@ -40,7 +40,7 @@
   /* initialize the mysql structure */
   memset(mysql, 0, sizeof(MYSQL));
   
-  mysql->extra_info = MYSEQUOIA_MAGIC;
+  mysql->field_alloc.block_size = MYSEQUOIA_MAGIC;
   mysql->free_me = free_me;
   //TODO maybe a real server version string ???
   mysql->server_version = "50015";
@@ -65,7 +65,7 @@
   FREE_AND_NULL_ARRAY(mysqlPtr->host_info);
   FREE_AND_NULL_ARRAY(mysqlPtr->info);
   
-  mysqlPtr->thd = 0;
+  mysqlPtr->field_alloc.used = 0;
   mysqlPtr->extra_info = 0;
 
   LOG4CXX_DEBUG(logger, "Leaving destructor.");
@@ -411,7 +411,7 @@
                        //if it is a CarobMYSQL object, free the results from 
there too
       if (isCarobObject(mysqlPtr))
       {
-        cm = static_cast<CarobMYSQL *> (mysqlPtr->thd);
+        cm = (CarobMYSQL *) (mysqlPtr->field_alloc.used);
         if (res == cm->liveResultPtr)
         {
           cm->liveResultPtr = 0;
Index: libmysequoia/src/CarobStmt.cpp
diff -u /dev/null libmysequoia/src/CarobStmt.cpp:1.1
--- /dev/null   Tue Jan 10 08:56:10 2006
+++ libmysequoia/src/CarobStmt.cpp      Tue Jan 10 08:56:10 2006
@@ -0,0 +1,265 @@
+/*
+ * Sequoia: Database clustering technology.
+ * Copyright (C) 2005-2006 Continuent, Inc.
+ * 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>
+#include <Utils.hpp>
+
+#include <string>
+
+//Carob includes
+#include <CarobStmt.hpp>
+#include <Common.hpp>
+
+//MySQL includes
+#include <mysql.h>
+#include <my_alloc.h>
+#include <errmsg.h>
+
+using namespace log4cxx;
+using namespace CarobNS;
+using namespace std;
+
+LoggerPtr CarobStmt::logger(Logger::getLogger("MySQLAPI.CarobStmt"));
+
+CarobStmt::CarobStmt(MYSQL *mysql): c_stmt(0)
+{
+  LOG4CXX_DEBUG(logger, "Entering constructor.");
+
+  m_stmt = new MYSQL_STMT();
+  memset(m_stmt, 0, sizeof(MYSQL_STMT));
+
+  //Initialize the structure
+  m_stmt->mem_root.used = (USED_MEM *) this;
+  m_stmt->mem_root.block_size = MYSEQUOIA_MAGIC;
+  m_stmt->mysql = mysql;
+  m_stmt->prefetch_rows = 1;
+  m_stmt->state = MYSQL_STMT_INIT_DONE;
+  
+  cmysql = (CarobMYSQL *)mysql->field_alloc.used;
+  
+  LOG4CXX_DEBUG(logger, "Leaving constructor.");
+}
+
+CarobStmt::~CarobStmt()
+{
+  LOG4CXX_DEBUG(logger, "Entering destructor.");
+
+  clear();
+  
+  FREE_AND_NULL(m_stmt);
+
+  LOG4CXX_DEBUG(logger, "Leaving destructor.");
+}
+  
+int
+CarobStmt::prepare(const char *query, unsigned long length)
+{
+  LOG4CXX_DEBUG(logger, "Entering prepare.");
+
+  int result = 0;
+  
+  clear();
+   
+  try
+  {
+    c_stmt = 
cmysql->connectionPtr->createParameterStatement(fromString(string(query, 
length)));
+    m_stmt->param_count = c_stmt->getParameterCount();
+    m_stmt->state = MYSQL_STMT_PREPARE_DONE;
+    m_stmt->params = new MYSQL_BIND[m_stmt->param_count];
+  }
+  catch (CarobException &e)
+  {
+    set_error(e.getErrorCode(), toString(e.description()).c_str(), 
toString(e.getSQLState()).c_str());
+    result = 1;
+  }
+  
+  LOG4CXX_DEBUG(logger, "Leaving prepare.");
+  
+  return result;
+}
+
+bool
+CarobStmt::bind_param(const MYSQL_BIND *bind)
+{
+  LOG4CXX_DEBUG(logger, "Entering bind_param.");
+  bool result = false;
+
+  if (!m_stmt->param_count)
+  {
+    if (m_stmt->state < MYSQL_STMT_PREPARE_DONE)
+    {
+      set_error(CR_NO_PREPARE_STMT, SQLT_UNKNOWN);
+      result = true;
+    }
+  }
+  else
+  {
+    memcpy(m_stmt->params, bind, sizeof(MYSQL_BIND) * m_stmt->param_count);
+    //TODO maybe more parameter check / structure initialization
+  }
+  
+  LOG4CXX_DEBUG(logger, "Leaving bind_param.");
+  return result;
+}
+
+int
+CarobStmt::execute()
+{
+  LOG4CXX_DEBUG(logger, "Entering execute.");
+  int result = 1;
+  if (m_stmt->state < MYSQL_STMT_PREPARE_DONE)
+    set_error(CR_NO_PREPARE_STMT, SQLT_UNKNOWN);
+  else
+    if (m_stmt->param_count && !m_stmt->params)
+      set_error(CR_PARAMS_NOT_BOUND, SQLT_UNKNOWN);
+    else
+    {
+      try
+      {
+        MYSQL_BIND *p = m_stmt->params;
+        for (unsigned int no=1; no <= m_stmt->param_count; no++, p++)
+        {
+          if (p->is_null)
+            c_stmt->setNull(no);
+          else
+            switch (p->buffer_type) {
+            case MYSQL_TYPE_TINY:
+              c_stmt->setByte(no, *(java_byte *)p->buffer);
+              break;
+            case MYSQL_TYPE_SHORT:
+              c_stmt->setShort(no, *(short *)p->buffer);
+              break;
+            case MYSQL_TYPE_LONG:
+              c_stmt->setInt(no, *(int *)p->buffer);
+              break;
+            case MYSQL_TYPE_LONGLONG:
+              c_stmt->setLong(no, *(long long *)p->buffer);
+              break;
+            case MYSQL_TYPE_FLOAT:
+              c_stmt->setFloat(no, *(float *)p->buffer);
+              break;
+            case MYSQL_TYPE_DOUBLE:
+              c_stmt->setDouble(no, *(double *)p->buffer);
+              break;
+            case MYSQL_TYPE_TINY_BLOB:
+            case MYSQL_TYPE_MEDIUM_BLOB:
+            case MYSQL_TYPE_LONG_BLOB:
+            case MYSQL_TYPE_BLOB:
+            case MYSQL_TYPE_VARCHAR:
+            case MYSQL_TYPE_VAR_STRING:
+            case MYSQL_TYPE_STRING:
+              c_stmt->setString(no, fromString(string((char *)p->buffer, 
p->buffer_length)));
+              break;
+  /*          case MYSQL_TYPE_TIME:
+            case MYSQL_TYPE_DATE:
+            case MYSQL_TYPE_DATETIME:
+            case MYSQL_TYPE_TIMESTAMP:
+            case MYSQL_TYPE_DECIMAL:
+            case MYSQL_TYPE_NEWDECIMAL:
+            case MYSQL_TYPE_NULL:
+            default:*/
+            //TODO support other types
+            }
+        }
+        c_stmt->execute();
+        result = 0;
+      }
+      catch (CarobException &e)
+      {
+        set_error(e.getErrorCode(), toString(e.description()).c_str(), 
toString(e.getSQLState()).c_str());
+      }
+    }
+  
+  LOG4CXX_DEBUG(logger, "Leaving execute.");
+  return result;
+}
+
+int
+CarobStmt::fetch()
+{
+  return 0;
+}
+
+bool
+CarobStmt::reset()
+{
+  return 0;
+}
+  
+MYSQL_RES *
+CarobStmt::param_metadata()
+{
+  return 0;
+}
+
+int
+CarobStmt::store_result()
+{
+  return 0;
+}
+
+bool
+CarobStmt::free_result(MYSQL_STMT *stmt)
+{
+  return 0;
+}
+
+void
+CarobStmt::set_error(int errcode, int sqlstate)
+{
+  LOG4CXX_DEBUG(logger, "Entering set_error.");
+  set_error(errcode, error_messages[errcode-CR_MIN_ERROR], 
error_sqlstate[sqlstate]);
+  LOG4CXX_DEBUG(logger, "Leaving set_error.");
+}
+
+void
+CarobStmt::set_error(int errcode, const char *errmsg, const char *sqlstate)
+{
+  LOG4CXX_DEBUG(logger, "Entering set_error.");
+  m_stmt->last_errno = convert_errcode(errcode);
+  if (errmsg)
+    strcpy(m_stmt->last_error, errmsg);
+  else
+    *m_stmt->last_error = 0;
+  if (sqlstate)
+    strcpy(m_stmt->sqlstate, sqlstate);
+  else
+    *m_stmt->sqlstate = 0;
+  LOG4CXX_DEBUG(logger, "Leaving set_error.");
+}
+
+void
+CarobStmt::clear()
+{
+  if (c_stmt)
+    FREE_AND_NULL(c_stmt);
+    
+  FREE_AND_NULL_ARRAY(m_stmt->params);
+  FREE_AND_NULL_ARRAY(m_stmt->bind);
+  
+  m_stmt->bind_param_done = false;
+  m_stmt->bind_result_done = false;
+  m_stmt->param_count = 0;
+  m_stmt->field_count = 0;
+  m_stmt->last_errno = 0;
+  *m_stmt->last_error = 0;
+  *m_stmt->sqlstate = 0;
+}
Index: libmysequoia/src/Makefile.am
diff -u libmysequoia/src/Makefile.am:1.4 libmysequoia/src/Makefile.am:1.5
--- libmysequoia/src/Makefile.am:1.4    Mon Jan  2 13:19:56 2006
+++ libmysequoia/src/Makefile.am        Tue Jan 10 08:56:10 2006
@@ -23,6 +23,7 @@
 lib_LTLIBRARIES = libmysequoia.la
 
 libmysequoia_la_SOURCES  = CarobMySQL.cpp \
+                                                                               
                         CarobStmt.cpp \
                            MySQLAPI.cpp \
                            Utils.cpp \
                            IniParser.cpp
Index: libmysequoia/src/MySQLAPI.cpp
diff -u libmysequoia/src/MySQLAPI.cpp:1.19 libmysequoia/src/MySQLAPI.cpp:1.20
--- libmysequoia/src/MySQLAPI.cpp:1.19  Mon Jan  2 13:19:56 2006
+++ libmysequoia/src/MySQLAPI.cpp       Tue Jan 10 08:56:10 2006
@@ -21,8 +21,10 @@
 
 #define USE_OLD_FUNCTIONS
 #include <mysql.h>
+#include <my_alloc.h>
 
 #include <CarobMySQL.hpp>
+#include <CarobStmt.hpp>
 
 #include <Utils.hpp>
 
@@ -44,7 +46,7 @@
 
 /**
  * The pointer to the CarobMySQL object is stored
- * in the thd member of the MYSQL structure.
+ * in the field_alloc.used member of the MYSQL structure.
  * This function returns a pointer to the CarobMYSQL
  * object
  */ 
@@ -52,9 +54,21 @@
 CarobMYSQL *getCarob(MYSQL *mysql)
 {
   if (!isCarobObject(mysql))
-    mysql->thd = new CarobMYSQL(mysql, 0);
+    mysql->field_alloc.used = (USED_MEM *) new CarobMYSQL(mysql, 0);
 
-  return static_cast<CarobMYSQL *> (mysql->thd);
+  return (CarobMYSQL *) (mysql->field_alloc.used);
+}
+
+/**
+ * The pointer to the CarobMySQL object is stored
+ * in the field_alloc.used member of the MYSQL structure.
+ * This function returns a pointer to the CarobMYSQL
+ * object
+ */ 
+inline
+CarobStmt *getCarobStmt(MYSQL_STMT *stmt)
+{
+  return (CarobStmt *) stmt->mem_root.used;
 }
 
 /* Library initialization, shutdown */
@@ -76,14 +90,14 @@
     if (!mysql)
     {
       mysql = new MYSQL();
-      mysql->thd = 0;
+      mysql->field_alloc.used = 0;
       free_in_close = true;
     }
   
     if (isCarobObject(mysql))
-      delete static_cast<CarobMYSQL *>(mysql->thd);
+      delete (CarobMYSQL *)(mysql->field_alloc.used);
       
-    mysql->thd = new CarobMYSQL(mysql, free_in_close);
+    mysql->field_alloc.used = (USED_MEM *) new CarobMYSQL(mysql, 
free_in_close);
   }
   catch (...)
   {
@@ -990,6 +1004,114 @@
 
 /* Prepared statements */
 
+MYSQL_STMT *
+mysql_stmt_init (MYSQL * mysql)
+{
+  LOG4CXX_DEBUG(logger, "Entering mysql_stmt_init.");
+  
+  MYSQL_STMT *result = 0;
+  
+  if (isCarobObject(mysql))
+  {
+    CarobStmt *stmt = new CarobStmt(mysql);
+    result = stmt->getMYSQL_STMT();
+  }
+  else
+    LOG4CXX_ERROR(logger, "The given mysql pointer was not initialized with 
mysql_init.");
+
+  LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_init.");
+  return result;
+}
+
+my_bool
+mysql_stmt_close (MYSQL_STMT *stmt)
+{
+  LOG4CXX_DEBUG(logger, "Entering mysql_stmt_close.");
+  if (isCarobObject(stmt))
+    delete getCarobStmt(stmt);
+  LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_close.");
+  return 0;
+}
+
+int
+mysql_stmt_prepare (MYSQL_STMT * stmt, const char *query,
+        unsigned long length)
+{
+  LOG4CXX_DEBUG(logger, "Entering mysql_stmt_prepare.");
+  int result = 0;
+  if (isCarobObject(stmt))
+    result = getCarobStmt(stmt)->prepare(query, length);
+  else
+  {
+    LOG4CXX_ERROR(logger, "The given mysql stmt pointer was not initialized 
with mysql_stmt_init.");
+    //Todo maybe better errorhandling?
+    result = 1;
+  }
+  LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_prepare.");
+  return result;
+}
+
+my_bool
+mysql_stmt_bind_param (MYSQL_STMT * stmt, MYSQL_BIND * bind)
+{
+  LOG4CXX_DEBUG(logger, "Entering mysql_stmt_bind_param.");
+  my_bool result = false;
+  if (isCarobObject(stmt))
+    result = getCarobStmt(stmt)->bind_param(bind);
+  else
+  {
+    LOG4CXX_ERROR(logger, "The given mysql stmt pointer was not initialized 
with mysql_stmt_init.");
+    //Todo maybe better errorhandling?
+    result = true;
+  }
+  LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_bind_param.");
+  return result;
+}
+
+int
+mysql_stmt_execute (MYSQL_STMT * stmt)
+{
+  LOG4CXX_DEBUG(logger, "Entering mysql_stmt_execute.");
+  int result = 0;
+  if (isCarobObject(stmt))
+    result = getCarobStmt(stmt)->execute();
+  else
+  {
+    LOG4CXX_ERROR(logger, "The given mysql stmt pointer was not initialized 
with mysql_stmt_init.");
+    //Todo maybe better errorhandling?
+    result = 1;
+  }
+  LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_execute.");
+  return result;
+}
+
+unsigned int
+mysql_stmt_errno (MYSQL_STMT * stmt)
+{
+  LOG4CXX_DEBUG(logger, "Entering mysql_stmt_errno.");
+  unsigned int result = stmt ? stmt->last_errno : 0;
+  LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_errno.");
+  return result;
+}
+
+const char *
+mysql_stmt_error (MYSQL_STMT * stmt)
+{
+  LOG4CXX_DEBUG(logger, "Entering mysql_stmt_error.");
+  const char *result = stmt ? stmt->last_error : 0;
+  LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_error.");
+  return result;
+}
+
+const char *
+mysql_stmt_sqlstate (MYSQL_STMT * stmt)
+{
+  LOG4CXX_DEBUG(logger, "Entering mysql_stmt_sqlstate.");
+  const char *result = stmt ? stmt->sqlstate : 0;
+  LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_sqlstate.");
+  return result;
+}
+
 my_ulonglong
 mysql_stmt_affected_rows (MYSQL_STMT * stmt)
 {
@@ -1017,14 +1139,6 @@
 }
 
 my_bool
-mysql_stmt_bind_param (MYSQL_STMT * stmt, MYSQL_BIND * bind)
-{
-  LOG4CXX_DEBUG(logger, "Entering mysql_stmt_bind_param.");
-  LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_bind_param.");
-  return 0;
-}
-
-my_bool
 mysql_stmt_bind_result (MYSQL_STMT * stmt, MYSQL_BIND * bind)
 {
   LOG4CXX_DEBUG(logger, "Entering mysql_stmt_bind_result.");
@@ -1032,14 +1146,6 @@
   return 0;
 }
 
-my_bool
-mysql_stmt_close (MYSQL_STMT *)
-{
-  LOG4CXX_DEBUG(logger, "Entering mysql_stmt_close.");
-  LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_close.");
-  return 0;
-}
-
 void
 mysql_stmt_data_seek (MYSQL_STMT * stmt, my_ulonglong offset)
 {
@@ -1047,30 +1153,6 @@
   LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_data_seek.");
 }
 
-unsigned int
-mysql_stmt_errno (MYSQL_STMT * stmt)
-{
-  LOG4CXX_DEBUG(logger, "Entering mysql_stmt_errno.");
-  LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_errno.");
-  return 0;
-}
-
-const char *
-mysql_stmt_error (MYSQL_STMT * stmt)
-{
-  LOG4CXX_DEBUG(logger, "Entering mysql_stmt_error.");
-  LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_error.");
-  return 0;
-}
-
-int
-mysql_stmt_execute (MYSQL_STMT * stmt)
-{
-  LOG4CXX_DEBUG(logger, "Entering mysql_stmt_execute.");
-  LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_execute.");
-  return 0;
-}
-
 int
 mysql_stmt_fetch (MYSQL_STMT * stmt)
 {
@@ -1104,14 +1186,6 @@
   return 0;
 }
 
-MYSQL_STMT *
-mysql_stmt_init (MYSQL * mysql)
-{
-  LOG4CXX_DEBUG(logger, "Entering mysql_stmt_init.");
-  LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_init.");
-  return 0;
-}
-
 my_ulonglong
 mysql_stmt_insert_id (MYSQL_STMT * stmt)
 {
@@ -1132,8 +1206,9 @@
 mysql_stmt_param_count (MYSQL_STMT * stmt)
 {
   LOG4CXX_DEBUG(logger, "Entering mysql_stmt_param_count.");
+  int result = stmt ? stmt->param_count : 0;
   LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_param_count.");
-  return 0;
+  return result;
 }
 
 MYSQL_RES *
@@ -1144,15 +1219,6 @@
   return 0;
 }
 
-int
-mysql_stmt_prepare (MYSQL_STMT * stmt, const char *query,
-        unsigned long length)
-{
-  LOG4CXX_DEBUG(logger, "Entering mysql_stmt_prepare.");
-  LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_prepare.");
-  return 0;
-}
-
 my_bool
 mysql_stmt_reset (MYSQL_STMT * stmt)
 {
@@ -1194,14 +1260,6 @@
   return 0;
 }
 
-const char *
-mysql_stmt_sqlstate (MYSQL_STMT * stmt)
-{
-  LOG4CXX_DEBUG(logger, "Entering mysql_stmt_sqlstate.");
-  LOG4CXX_DEBUG(logger, "Leaving mysql_stmt_sqlstate.");
-  return 0;
-}
-
 int
 mysql_stmt_store_result (MYSQL_STMT * stmt)
 {
Index: libmysequoia/src/Utils.cpp
diff -u libmysequoia/src/Utils.cpp:1.10 libmysequoia/src/Utils.cpp:1.11
--- libmysequoia/src/Utils.cpp:1.10     Mon Jan  2 13:19:56 2006
+++ libmysequoia/src/Utils.cpp  Tue Jan 10 08:56:10 2006
@@ -228,5 +228,10 @@
 
 bool isCarobObject(MYSQL *p)
 {
-  return (p != 0) && (p->extra_info == MYSEQUOIA_MAGIC);
+  return (p != 0) && (p->field_alloc.block_size == MYSEQUOIA_MAGIC);
+}
+
+bool isCarobObject(MYSQL_STMT *p)
+{
+  return (p != 0) && (p->mem_root.block_size == MYSEQUOIA_MAGIC);
 }
Index: libmysequoia/test/TestMySQLAPI.cpp
diff -u libmysequoia/test/TestMySQLAPI.cpp:1.13 
libmysequoia/test/TestMySQLAPI.cpp:1.14
--- libmysequoia/test/TestMySQLAPI.cpp:1.13     Mon Jan  2 13:19:56 2006
+++ libmysequoia/test/TestMySQLAPI.cpp  Tue Jan 10 08:56:10 2006
@@ -45,10 +45,10 @@
   MYSQL m;
   
   CPPUNIT_ASSERT(mysql != 0);
-  CPPUNIT_ASSERT(mysql->thd != 0); // the CarobMYSQL object
+  CPPUNIT_ASSERT(mysql->field_alloc.used != 0); // the CarobMYSQL object
   
   CPPUNIT_ASSERT(mysql_init(&m) != 0);
-  CPPUNIT_ASSERT(m.thd != 0); // the CarobMYSQL object
+  CPPUNIT_ASSERT(m.field_alloc.used != 0); // the CarobMYSQL object
   mysql_close(&m);
 }
 

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

Reply via email to