List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:September 19 2011 11:21am
Subject:bzr push into mysql-trunk branch (tor.didriksen:3438 to 3439)
View as plain text  
 3439 Tor Didriksen	2011-09-19
      Convert udf_example from .c to .cc

    renamed:
      sql/udf_example.c => sql/udf_example.cc
    modified:
      sql/CMakeLists.txt
      sql/udf_example.cc
 3438 Tor Didriksen	2011-09-19
      Try some simple stl usage in the server.

    modified:
      sql/mysqld.cc
      sql/set_var.cc
      sql/set_var.h
      sql/sql_plugin.cc
      sql/sql_plugin.h
=== modified file 'sql/CMakeLists.txt'
--- a/sql/CMakeLists.txt	2011-08-22 12:48:51 +0000
+++ b/sql/CMakeLists.txt	2011-09-19 11:20:45 +0000
@@ -349,7 +349,7 @@ ADD_CUSTOM_TARGET( 
 SET_TARGET_PROPERTIES(GenServerSource PROPERTIES EXCLUDE_FROM_ALL TRUE)
 
 IF(WIN32 OR HAVE_DLOPEN AND NOT DISABLE_SHARED)
-  ADD_LIBRARY(udf_example MODULE udf_example.c)
+  ADD_LIBRARY(udf_example MODULE udf_example.cc)
   SET_TARGET_PROPERTIES(udf_example PROPERTIES PREFIX "")
   # udf_example depends on strings 
   IF(WIN32)

=== renamed file 'sql/udf_example.c' => 'sql/udf_example.cc'
--- a/sql/udf_example.c	2011-06-30 15:50:45 +0000
+++ b/sql/udf_example.cc	2011-09-19 11:20:45 +0000
@@ -111,6 +111,8 @@
 **
 */
 
+#include <new>
+
 #ifdef STANDARD
 /* STANDARD is defined, don't use any mysql functions */
 #include <stdlib.h>
@@ -150,6 +152,7 @@ static pthread_mutex_t LOCK_hostname;
 
 /* These must be right or mysqld will not find the symbol! */
 
+C_MODE_START;
 my_bool metaphon_init(UDF_INIT *initid, UDF_ARGS *args, char *message);
 void metaphon_deinit(UDF_INIT *initid);
 char *metaphon(UDF_INIT *initid, UDF_ARGS *args, char *result,
@@ -173,7 +176,7 @@ double avgcost( UDF_INIT* initid, UDF_AR
 my_bool is_const_init(UDF_INIT *initid, UDF_ARGS *args, char *message);
 char *is_const(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long
                *length, char *is_null, char *error);
-
+C_MODE_END;
 
 /*************************************************************************
 ** Example of init function
@@ -696,6 +699,7 @@ longlong sequence(UDF_INIT *initid __att
 #include <netdb.h>
 #endif
 
+C_MODE_START;
 my_bool lookup_init(UDF_INIT *initid, UDF_ARGS *args, char *message);
 void lookup_deinit(UDF_INIT *initid);
 char *lookup(UDF_INIT *initid, UDF_ARGS *args, char *result,
@@ -704,6 +708,7 @@ my_bool reverse_lookup_init(UDF_INIT *in
 void reverse_lookup_deinit(UDF_INIT *initid);
 char *reverse_lookup(UDF_INIT *initid, UDF_ARGS *args, char *result,
 		     unsigned long *length, char *null_value, char *error);
+C_MODE_END;
 
 
 /****************************************************************************
@@ -939,7 +944,7 @@ avgcost_init( UDF_INIT* initid, UDF_ARGS
   initid->decimals	= 4;		/* We want 4 decimals in the result */
   initid->max_length	= 20;		/* 6 digits + . + 10 decimals */
 
-  if (!(data = (struct avgcost_data*) malloc(sizeof(struct avgcost_data))))
+  if (!(data = new (std::nothrow) avgcost_data))
   {
     strmov(message,"Couldn't allocate memory");
     return 1;
@@ -955,7 +960,9 @@ avgcost_init( UDF_INIT* initid, UDF_ARGS
 void
 avgcost_deinit( UDF_INIT* initid )
 {
-  free(initid->ptr);
+  void *void_ptr= initid->ptr;
+  avgcost_data *data= static_cast<avgcost_data*>(void_ptr);
+  delete data;
 }
 
 
@@ -1110,6 +1117,7 @@ char * is_const(UDF_INIT *initid, UDF_AR
 
 
 
+extern "C"
 my_bool check_const_len_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
 {
   if (args->arg_count != 1)
@@ -1133,6 +1141,7 @@ my_bool check_const_len_init(UDF_INIT *i
   return 0;
 }
 
+extern "C"
 char * check_const_len(UDF_INIT *initid, UDF_ARGS *args __attribute__((unused)),
                 char *result, unsigned long *length,
                 char *is_null, char *error __attribute__((unused)))

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (tor.didriksen:3438 to 3439) Tor Didriksen20 Sep