Browse Source

Merge in updates for libdrizzle

Brian Aker 13 years ago
parent
commit
a742236388

+ 2 - 1
configure.ac

@@ -6,7 +6,7 @@
 # Use and distribution licensed under the BSD license.  See
 # the COPYING file in this directory for full text.
 
-AC_INIT([gearmand],[0.25],[https://launchpad.net/gearmand])
+AC_INIT([gearmand],[0.25],[https://launchpad.net/gearmand], [gearmand], [http://gearman.info/])
 
 AC_CONFIG_AUX_DIR(config)
 
@@ -65,6 +65,7 @@ dnl First look for Boost, maybe for a specific minimum version:
 BOOST_REQUIRE([1.39])
 BOOST_PROGRAM_OPTIONS([mt-])
 
+m4_include([m4/drizzled.m4])
 WITH_LIBDRIZZLE
 WITH_DRIZZLED
 

+ 9 - 5
libgearman-server/plugins/queue/drizzle/queue.cc

@@ -197,7 +197,9 @@ gearmand_error_t gearman_server_queue_libdrizzle_init(plugins::queue::Drizzle *q
   drizzle_con_set_db(queue->con, queue->schema.c_str());
 
   if (queue->mysql_protocol)
+  {
     drizzle_con_set_options(queue->con, DRIZZLE_CON_MYSQL);
+  }
 
   if (queue->uds.empty())
   {
@@ -262,7 +264,7 @@ gearmand_error_t gearman_server_queue_libdrizzle_init(plugins::queue::Drizzle *q
       return gearmand_gerror(drizzle_error(queue->drizzle), GEARMAN_QUEUE_ERROR);
     }
 
-    if (libdrizzle_failed(drizzle_column_skip(queue->result())))
+    if (libdrizzle_failed(drizzle_column_skip_all(queue->result())))
     {
       drizzle_result_free(queue->result());
       return gearmand_gerror(drizzle_error(queue->drizzle), GEARMAN_QUEUE_ERROR);
@@ -463,14 +465,14 @@ static gearmand_error_t _dump_queue(plugins::queue::Drizzle *queue)
 
   if (_libdrizzle_query(NULL, queue, query, query_size) != DRIZZLE_RETURN_OK)
   {
-    gearmand_log_error("drizzle_column_skip:%s", drizzle_error(queue->drizzle));
+    gearmand_log_error("drizzle_column_skip_all:%s", drizzle_error(queue->drizzle));
     return GEARMAN_QUEUE_ERROR;
   }
 
-  if (drizzle_column_skip(queue->result()) != DRIZZLE_RETURN_OK)
+  if (drizzle_column_skip_all(queue->result()) != DRIZZLE_RETURN_OK)
   {
     drizzle_result_free(queue->result());
-    gearmand_log_error("drizzle_column_skip:%s", drizzle_error(queue->drizzle));
+    gearmand_log_error("drizzle_column_skip_all:%s", drizzle_error(queue->drizzle));
 
     return GEARMAN_QUEUE_ERROR;
   }
@@ -535,7 +537,7 @@ static gearmand_error_t _libdrizzle_replay(gearman_server_st *server,
     return gearmand_gerror(drizzle_error(queue->drizzle), GEARMAN_QUEUE_ERROR);
   }
 
-  if (drizzle_column_skip(queue->result()) != DRIZZLE_RETURN_OK)
+  if (drizzle_column_skip_all(queue->result()) != DRIZZLE_RETURN_OK)
   {
     drizzle_result_free(queue->result());
     return gearmand_gerror(drizzle_error(queue->drizzle), GEARMAN_QUEUE_ERROR);
@@ -555,7 +557,9 @@ static gearmand_error_t _libdrizzle_replay(gearman_server_st *server,
     }
 
     if (row == NULL)
+    {
       break;
+    }
 
     field_sizes= drizzle_row_field_sizes(queue->result());
 

+ 43 - 0
libtest/has.cc

@@ -0,0 +1,43 @@
+/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ * 
+ *  libtest
+ *
+ *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 3 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <config.h>
+#include <libtest/has.hpp>
+
+bool has_memcached_support(void)
+{
+  if (HAVE_LIBMEMCACHED and HAVE_MEMCACHED_BINARY)
+  {
+    return true;
+  }
+
+  return false;
+}
+
+bool has_drizzle_support(void)
+{
+  if (HAVE_LIBDRIZZLE and HAVE_DRIZZLED_BINARY)
+  {
+    return true;
+  }
+
+  return false;
+}

+ 26 - 0
libtest/has.hpp

@@ -0,0 +1,26 @@
+/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ * 
+ *  libtest
+ *
+ *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 3 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#pragma once
+
+bool has_memcached_support(void);
+
+bool has_drizzle_support(void);

+ 2 - 0
libtest/include.am

@@ -67,6 +67,7 @@ noinst_HEADERS+= \
 		 libtest/framework.h \
 		 libtest/gearmand.h \
 		 libtest/get.h \
+		 libtest/has.hpp \
 		 libtest/is_pid.hpp \
 		 libtest/is_local.hpp \
 		 libtest/killpid.h \
@@ -94,6 +95,7 @@ libtest_libtest_la_SOURCES= \
 			    libtest/core.cc \
 			    libtest/dream.cc \
 			    libtest/framework.cc \
+			    libtest/has.cc \
 			    libtest/is_local.cc \
 			    libtest/killpid.cc \
 			    libtest/libtool.cc \

+ 3 - 3
libtest/server.cc

@@ -43,7 +43,7 @@ static inline std::string &rtrim(std::string &s)
 #include <libtest/killpid.h>
 
 extern "C" {
-  static bool exited_successfully(int status)
+  static bool exited_successfully(int status, const std::string &command)
   {
     if (status == 0)
     {
@@ -60,7 +60,7 @@ extern "C" {
       }
       else if (ret == EXIT_FAILURE)
       {
-        libtest::Error << "Command executed, but returned EXIT_FAILURE";
+        libtest::Error << "Command executed, but returned EXIT_FAILURE: " << command;
       }
       else
       {
@@ -198,7 +198,7 @@ bool Server::start()
   }
 
   int ret= system(_running.c_str());
-  if (not exited_successfully(ret))
+  if (not exited_successfully(ret, _running))
   {
     Error << "system() failed:" << strerror(errno);
     _running.clear();

+ 1 - 0
libtest/test.hpp

@@ -32,6 +32,7 @@
 #include <libtest/visibility.h>
 #include <libtest/version.h>
 
+#include <libtest/has.hpp>
 #include <libtest/error.h>
 #include <libtest/strerror.h>
 #include <libtest/stream.h>

+ 10 - 29
m4/drizzled.m4

@@ -1,29 +1,10 @@
-AC_DEFUN([WITH_DRIZZLED],
-  [AC_ARG_WITH([drizzled],
-    [AS_HELP_STRING([--with-drizzled],
-      [Drizzled binary to use for make test])],
-    [ac_cv_with_drizzled="$withval"],
-    [ac_cv_with_drizzled=drizzled])
-
-  # Disable if --without-drizzled
-  # only used by make test
-  AS_IF([test "x$withval" = "xno"],
-    [
-      ac_cv_with_drizzled=
-      DRIZZLED_BINARY=
-    ],
-    [
-       AS_IF([test -f "$withval"],
-         [
-           ac_cv_with_drizzled=$withval
-           DRIZZLED_BINARY=$withval
-           AC_DEFINE_UNQUOTED([DRIZZLED_BINARY], "$DRIZZLED_BINARY", [Name of the drizzled binary used in make test])
-         ],
-         [
-           ac_cv_with_drizzled=
-           DRIZZLED_BINARY=
-         ])
-    ])
-  AM_CONDITIONAL(HAVE_DRIZZLED, test -n ${ac_cv_with_drizzled})
-  AC_SUBST(DRIZZLED_BINARY)
-])
+AX_WITH_PROG(DRIZZLED_BINARY, drizzled)
+AS_IF([test -f "$ac_cv_path_DRIZZLED_BINARY"],
+      [
+        AC_DEFINE([HAVE_DRIZZLED_BINARY], [1], [If Drizzled binary is available])
+        AC_DEFINE_UNQUOTED([DRIZZLED_BINARY], "$ac_cv_path_DRIZZLED_BINARY", [Name of the drizzled binary used in make test])
+       ],
+       [
+        AC_DEFINE([HAVE_DRIZZLED_BINARY], [0], [If Drizzled binary is available])
+        AC_DEFINE([DRIZZLED_BINARY], [0], [Name of the drizzled binary used in make test])
+      ])

+ 2 - 1
m4/libdrizzle.m4

@@ -9,7 +9,8 @@ AC_DEFUN([_WITH_LIBDRIZZLE],
          [ PKG_CHECK_MODULES([libdrizzle], 
 			     [ libdrizzle-1.0 >= 2011.03.13 ], 
 			     [AC_DEFINE([HAVE_LIBDRIZZLE], [ 1 ], [Enable libdrizzle support])], 
-			     [ac_enable_libdrizzle="no"] )])
+			     [ac_enable_libdrizzle="no"] )],
+         [ AC_DEFINE([HAVE_LIBDRIZZLE], [ 0 ], [Enable libdrizzle support]) ])
     AM_CONDITIONAL(HAVE_LIBDRIZZLE, test "x${ac_enable_libdrizzle}" = "xyes")
     ])
 ])

+ 44 - 10
tests/drizzle_test.cc

@@ -26,19 +26,47 @@ using namespace libtest;
 
 #define WORKER_FUNCTION "drizzle_queue_test"
 
-#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wold-style-cast"
-#endif
+#if defined(HAVE_LIBDRIZZLE) && HAVE_LIBDRIZZLE
+
+#include <libdrizzle-1.0/drizzle_client.h>
 
-static test_return_t test_for_HAVE_LIBDRIZZLE(void *)
+static bool ping_drizzled(void)
 {
-#if defined HAVE_LIBDRIZZLE && defined HAVE_DRIZZLED
-  return TEST_SUCCESS;
-#else
-  return TEST_SKIPPED;
-#endif
+  drizzle_st *drizzle= drizzle_create(NULL);
+
+  if (drizzle == NULL)
+  {
+    return false;
+  }
+
+  drizzle_con_st *con;
+
+  if ((con= drizzle_con_create(drizzle, NULL)) == NULL)
+  {
+    drizzle_free(drizzle);
+    return false;
+  }
+
+  drizzle_con_set_tcp(con, NULL, 0);
+  drizzle_con_set_auth(con, "root", 0);
+  drizzle_return_t rc;
+  drizzle_result_st *result= drizzle_ping(con, NULL, &rc);
+
+  bool success= bool(result);
+
+  drizzle_result_free(result);
+  drizzle_con_free(con);
+  drizzle_free(drizzle);
+
+  return success;
 }
 
+#endif
+
+#ifndef __INTEL_COMPILER
+#pragma GCC diagnostic ignored "-Wold-style-cast"
+#endif
+
 static test_return_t gearmand_basic_option_test(void *)
 {
   const char *args[]= { "--check-args", 
@@ -79,7 +107,13 @@ static test_return_t collection_cleanup(void *object)
 
 static void *world_create(server_startup_st& servers, test_return_t& error)
 {
-  if (test_for_HAVE_LIBDRIZZLE(NULL) == TEST_SKIPPED)
+  if (has_drizzle_support() == false)
+  {
+    error= TEST_SKIPPED;
+    return NULL;
+  }
+
+  if (ping_drizzled() == false)
   {
     error= TEST_SKIPPED;
     return NULL;

Some files were not shown because too many files changed in this diff