Changeset: 12ec39d8bcd8 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=12ec39d8bcd8
Added Files:
tools/embedded/demo.c
Modified Files:
common/utils/mcrypt.h
configure.ag
monetdb5/mal/mal.c
monetdb5/mal/mal_authorize.c
monetdb5/mal/mal_session.c
monetdb5/modules/atoms/mtime.h
sql/backends/monet5/sql_scenario.c
tools/embedded/embedded.c
tools/embedded/embedded.h
tools/embedded/embeddedr.c
tools/embedded/embeddedr.h
tools/embedded/rpackage/configure
Branch: embedded
Log Message:
embedded c demo, much to be done
diffs (truncated from 330 to 300 lines):
diff --git a/common/utils/mcrypt.h b/common/utils/mcrypt.h
--- a/common/utils/mcrypt.h
+++ b/common/utils/mcrypt.h
@@ -19,5 +19,7 @@ char *mcrypt_SHA512Sum(const char *strin
char *mcrypt_RIPEMD160Sum(const char *string, size_t len);
char *mcrypt_BackendSum(const char *string, size_t len);
char *mcrypt_hashPassword(const char *algo, const char *password, const char
*challenge);
-
+#ifdef HAVE_EMBEDDED
+char* mcrypt_sum_fail(const char *string, size_t len);
#endif
+#endif
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -208,7 +208,18 @@ if test "x$enable_embedded" != xno; then
fi
AM_CONDITIONAL(HAVE_EMBEDDED, test x"$enable_embedded" != xno)
+dft_embedded_r=no
+AC_ARG_ENABLE(embedded-r,
+ AS_HELP_STRING([--enable-embedded-r],
+ [enable support for running MonetDB as a library for R
(default=no)]),
+ enable_embedded_r=$enableval,
+ enable_embedded_r=$dft_embedded_r)
+AM_CONDITIONAL(HAVE_EMBEDDED_R, test x$enable_embedded_r != xno)
+if test "x$enable_embedded_r" != xno; then
+ AC_DEFINE(HAVE_EMBEDDED_R, 1, [Support for MonetDB as a library for R])
+fi
+AM_CONDITIONAL(HAVE_EMBEDDED_R, test x"$enable_embedded_R" != xno)
dft_microhttpd=no
AC_ARG_ENABLE(microhttpd,
@@ -2543,6 +2554,83 @@ if test "x$enable_netcdf" != xno; then
fi
AM_CONDITIONAL(HAVE_NETCDF, test x"$have_netcdf" != xno)
+# liblas, only used in lidar module
+org_have_liblas=auto
+have_liblas=$org_have_liblas
+LIBLAS_INCS=''
+LIBLAS_LIBS=''
+AC_ARG_WITH(liblas,
+ AS_HELP_STRING([--with-liblas=DIR],
+ [liblas library is installed in DIR]),
+ have_liblas="$withval")
+case "$enable_lidar" in
+yes|auto)
+ # liblas >= 1.8.0 required
+ LIBLAS_VERSION_REQUIRED_MIN=1.8.0
+ LIBLAS_CONFIG=''
+ # locate liblas-config
+ if test "x$have_liblas" != xno; then
+ case "$have_liblas" in
+ yes|auto)
+ XPATH="$PATH"
+ ;;
+ *)
+ XPATH="$have_liblas/bin"
+ have_liblas=yes
+ ;;
+ esac
+ AC_PATH_PROG(LIBLAS_CONFIG,liblas-config,,$XPATH)
+ if test "x$LIBLAS_CONFIG" = x; then
+ if test "x$have_liblas" = "xyes" ; then
+ AC_MSG_ERROR([liblas-config not found in
$XPATH])
+ else
+ have_liblas=no
+ why_have_liblas="(liblas-config not found)"
+ fi
+ fi
+ fi
+ # check the version if liblas
+ if test "x$have_liblas" != xno; then
+ AC_MSG_CHECKING([for liblas >= $LIBLAS_VERSION_REQUIRED_MIN])
+ LIBLAS_VERSION="`$LIBLAS_CONFIG --version`"
+ AC_MSG_RESULT(found $LIBLAS_VERSION)
+ if test MONETDB_VERSION_TO_NUMBER(echo $LIBLAS_VERSION) -lt
MONETDB_VERSION_TO_NUMBER(echo $LIBLAS_VERSION_REQUIRED_MIN); then
+ if test "x$have_liblas" = "xyes" ; then
+ AC_MSG_ERROR([liblas version $LIBLAS_VERSION is
too old])
+ else
+ have_liblas=no
+ why_have_liblas="(liblas version
$LIBLAS_VERSION is older than required version $LIBLAS_VERSION_REQUIRED_MIN)"
+ fi
+ fi
+ fi
+ # read include dirs, libs and cflags
+ if test "x$have_liblas" != xno; then
+ LIBLAS_INCS="`$LIBLAS_CONFIG --includes`"
+ LIBLAS_LIBS="`$LIBLAS_CONFIG --libs`"
+ fi
+ # if lidar is enabled and liblas was not found abort
+ if test "x$have_liblas" = xno; then
+ if test "x$enable_lidar" = xyes; then
+ AC_MSG_ERROR([liblas library required for lidar module])
+ fi
+ # no liblas, so don't compile lidar
+ enable_lidar=no
+ if test "x$disable_lidar" = x; then
+ disable_lidar=${why_have_liblas:-"(liblas library
required for lidar module)"}
+ fi
+ fi
+ ;;
+no)
+ enable_lidar=no
+ have_liblas=no
+ why_have_liblas="(lidar module is disabled)"
+ ;;
+esac
+AC_SUBST(LIBLAS_INCS)
+AC_SUBST(LIBLAS_LIBS)
+
+AC_MSG_CHECKING(['enable lidar: $enable_lidar'])
+AM_CONDITIONAL(HAVE_LIDAR, test "x$enable_lidar" = xyes -o "x$enable_lidar" =
xauto)
PKG_CHECK_MODULES([atomic_ops], [atomic_ops], [have_atomic_ops="yes"],
[have_atomic_ops="no"; why_have_atomic_ops="(atomic_ops library not
found)"])
diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c
--- a/monetdb5/mal/mal.c
+++ b/monetdb5/mal/mal.c
@@ -176,7 +176,8 @@ void mal_exit(void){
//freeModuleList(mal_clients->nspace);
freeModuleList(NULL);
finishNamespace();
- MTIMEreset();
+ // FIXME: this required?
+ // MTIMEreset();
#endif
GDKexit(0); /* properly end GDK */
diff --git a/monetdb5/mal/mal_authorize.c b/monetdb5/mal/mal_authorize.c
--- a/monetdb5/mal/mal_authorize.c
+++ b/monetdb5/mal/mal_authorize.c
@@ -834,6 +834,7 @@ AUTHverifyPassword(str *passwd)
"representation of an MD5 password
hash?");
} else
#endif
+ len++; // required in case all the checks above are false
{
throw(MAL, "verifyPassword", "Unknown backend hash algorithm:
%s",
MONETDB5_PASSWDHASH);
diff --git a/monetdb5/mal/mal_session.c b/monetdb5/mal/mal_session.c
--- a/monetdb5/mal/mal_session.c
+++ b/monetdb5/mal/mal_session.c
@@ -22,7 +22,8 @@
#include <gdk.h> /* for opendir and friends */
#ifdef HAVE_EMBEDDED
-#include "mal_init_inline.h"
+// FIXME:
+//#include "mal_init_inline.h"
#endif
/*
diff --git a/monetdb5/modules/atoms/mtime.h b/monetdb5/modules/atoms/mtime.h
--- a/monetdb5/modules/atoms/mtime.h
+++ b/monetdb5/modules/atoms/mtime.h
@@ -125,7 +125,7 @@ mtime_export str MTIMEdaytime2daytime(da
mtime_export str MTIMEsecs2daytime(daytime *ret, const lng *src);
mtime_export str MTIMEsecs2daytime_bulk(bat *ret, bat *bid);
mtime_export str MTIMEtimestamp2timestamp(timestamp *ret, const timestamp
*src);
-mtime_export void MTIMEreset();
+mtime_export void MTIMEreset(void);
mtime_export str MTIMEprelude(void *ret);
mtime_export str MTIMEepilogue(void *ret);
mtime_export str MTIMEsynonyms(void *ret, const bit *allow);
diff --git a/sql/backends/monet5/sql_scenario.c
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -404,7 +404,6 @@ str
SQLinitClient(Client c)
{
mvc *m;
- str schema;
str msg = MAL_SUCCEED;
backend *be;
bstream *bfd = NULL;
@@ -449,7 +448,7 @@ SQLinitClient(Client c)
#ifndef HAVE_EMBEDDED
/* pass through credentials of the user if not console */
if (c->user != 0) {
- schema = monet5_user_get_def_schema(m, c->user);
+ str schema = monet5_user_get_def_schema(m, c->user);
if (!schema) {
_DELETE(schema);
throw(PERMD, "SQLinitClient", "08004!schema
authorization error");
diff --git a/tools/embedded/demo.c b/tools/embedded/demo.c
new file mode 100644
--- /dev/null
+++ b/tools/embedded/demo.c
@@ -0,0 +1,47 @@
+#include "monetdb_config.h"
+#include "monet_options.h"
+#include "sql_scenario.h"
+#include "mal.h"
+#include "embedded.h"
+
+/*
+ configure & install MonetDB as follows:
+
+./configure --prefix=/tmp/embedded-install --enable-embedded \
+--disable-fits --disable-geom --disable-rintegration --disable-gsl
--disable-netcdf \
+--disable-jdbc --disable-merocontrol --disable-odbc --disable-console
--disable-microhttpd \
+--without-perl --without-python2 --without-python3 --without-rubygem
--without-unixodbc \
+--without-samtools --without-sphinxclient --without-geos --without-samtools
--without-readline \
+--enable-debug --enable-silent-rules --disable-assert --disable-strict
+make -j install
+
+then build this file as follows:
+
+gcc demo.c -I../../monetdb5/mal -I../../gdk -I../../common/stream
-I../../common/options \
+-I../../ -I ../../sql/backends/monet5 -I../../sql/include
-I../../monetdb5/modules/atoms \
+-I../../sql/server -I ../../sql/common -I../../sql/storage
-I../../clients/mapilib \
+-I../../monetdb5/modules/mal -lembedded -lbat -L/tmp/embedded-install/lib -g
+
+*/
+
+int main() {
+ char* err = NULL;
+ void* conn = NULL;
+ res_table* result = NULL;
+
+ // we want to get rid of first argument, this is why we want to inline
mal/sql scripts and have fat library
+ err = monetdb_startup("/tmp/embedded-install/lib",
"/tmp/embedded-dbfarm", 1);
+ if (err != NULL) {
+ fprintf(stderr, "Init fail: %s\n", err);
+ return -1;
+ }
+ conn = monetdb_connect();
+ err = monetdb_query(conn, "SELECT * FROM tables;", (void**) &result);
+ if (err != NULL) {
+ fprintf(stderr, "Query fail: %s\n", err);
+ return -2;
+ }
+ fprintf(stderr, "Query result with %i cols and %lu rows\n",
result->nr_cols, BATcount(BATdescriptor(result->cols[0].b)));
+ monetdb_disconnect(conn);
+ monetdb_shutdown();
+}
diff --git a/tools/embedded/embedded.c b/tools/embedded/embedded.c
--- a/tools/embedded/embedded.c
+++ b/tools/embedded/embedded.c
@@ -65,6 +65,7 @@ void* monetdb_connect() {
return NULL;
}
((backend *) c->sqlcontext)->mvc->session->auto_commit = 1;
+ // TODO: keep track of pointers returned
return c;
}
@@ -166,6 +167,7 @@ cleanup:
}
char* monetdb_query(void* conn, char* query, void** result) {
+ // TODO: check client pointer
str res = MAL_SUCCEED;
Client c = (Client) conn;
mvc* m = ((backend *) c->sqlcontext)->mvc;
@@ -292,6 +294,8 @@ str monetdb_get_columns(void* conn, cons
return msg;
}
+
+// TODO: fix this, it is not working correctly
void monetdb_shutdown() {
MT_lock_set(&monetdb_embedded_lock);
// kill SQL
diff --git a/tools/embedded/embedded.h b/tools/embedded/embedded.h
--- a/tools/embedded/embedded.h
+++ b/tools/embedded/embedded.h
@@ -20,13 +20,13 @@ typedef struct append_data {
extern int monetdb_embedded_initialized;
-void* monetdb_connect();
+void* monetdb_connect(void);
void monetdb_disconnect(void* conn);
char* monetdb_startup(char* libdir, char* dbdir, char silent);
char* monetdb_query(void* conn, char* query, void** result);
char* monetdb_append(void* conn, const char* schema, const char* table,
append_data *data, int ncols);
void monetdb_cleanup_result(void* conn, void* output);
char* monetdb_get_columns(void* conn, const char* schema_name, const char
*table_name, int *column_count, char ***column_names, int **column_types);
-void monetdb_shutdown();
+void monetdb_shutdown(void);
#endif
diff --git a/tools/embedded/embeddedr.c b/tools/embedded/embeddedr.c
--- a/tools/embedded/embeddedr.c
+++ b/tools/embedded/embeddedr.c
@@ -1,6 +1,7 @@
+#include "monetdb_config.h"
+
+#ifdef HAVE_EMBEDDED_R
#include "embeddedr.h"
-
-#include "monetdb_config.h"
#include "monet_options.h"
#include "mal.h"
#include "mal_client.h"
@@ -153,3 +154,4 @@ SEXP monetdb_shutdown_R() {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list