Changeset: 65367360de91 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=65367360de91
Modified Files:
        CMakeLists.txt
        clients/CMakeLists.txt
        common/utils/mutils.h
        embedded/CMakeLists.txt
        embedded/monetdb_embedded.c
        embedded/monetdb_embedded.h
        monetdb5/mal/mal_dataflow.c
        monetdb5/mal/mal_embedded.c
        monetdb5/mal/mal_import.c
        monetdb5/mal/mal_interpreter.c
        monetdb5/mal/mal_private.h
        monetdb5/mal/mal_runtime.c
        monetdb5/modules/atoms/str.c
        monetdb5/modules/atoms/str.h
        monetdb5/modules/mal/pcre.c
        monetdb5/optimizer/opt_evaluate.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_gencode.c
        sql/backends/monet5/sql_scenario.c
        sql/backends/monet5/sql_upgrades.c
        sql/backends/monet5/sql_user.c
        sql/server/rel_schema.c
        tools/CMakeLists.txt
Branch: cmake-monetdblite
Log Message:

MonetDBLite compiles on Linux.


diffs (truncated from 1198 to 300 lines):

diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -794,6 +794,7 @@ endif()
 if(HAVE_MONETDB5)
        add_subdirectory(monetdb5)
        add_subdirectory(geom) # The SHP vault requires the geom module, so the 
geom module should compile before SQL
+       add_subdirectory(tools)
 endif()
 if(HAVE_SQL OR HAVE_EMBEDDED)
        compile_sqlparser()
@@ -801,7 +802,6 @@ endif()
 if(HAVE_SQL)
        add_subdirectory(sql)
 endif()
-add_subdirectory(tools)
 if(HAVE_EMBEDDED)
        add_subdirectory(embedded)
 endif()
diff --git a/clients/CMakeLists.txt b/clients/CMakeLists.txt
--- a/clients/CMakeLists.txt
+++ b/clients/CMakeLists.txt
@@ -6,15 +6,17 @@
 # Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
 #]]
 
-if(${ENABLE_MAPI} STREQUAL "YES")
+if(NOT ${ENABLE_MAPI} STREQUAL "NO")
        set(HAVE_MAPI ON CACHE INTERNAL "mapi extension is available" FORCE)
        add_subdirectory(mapilib)
        add_subdirectory(mapiclient)
        add_subdirectory(examples)
+       if(WIN32)
+               add_subdirectory(NT)
+       endif()
 else()
        set(HAVE_MAPI OFF CACHE INTERNAL "mapi extension is available" FORCE)
 endif()
-add_subdirectory(odbc)
-if(WIN32)
-       add_subdirectory(NT)
+if(NOT ${ENABLE_ODBC} STREQUAL "NO")
+       add_subdirectory(odbc)
 endif()
diff --git a/common/utils/mutils.h b/common/utils/mutils.h
--- a/common/utils/mutils.h
+++ b/common/utils/mutils.h
@@ -76,9 +76,9 @@ mutils_export void MT_srand(unsigned int
  * pointer to a static buffer that is overwritten by subsequent calls to
  * this function. */
 mutils_export char *get_bin_path(void);
+#endif
 /* Returns the Mercurial changeset of the current checkout, if available */
 mutils_export const char *mercurial_revision(void);
-#endif
 
 /* print to stdout/stderr conditionally */
 mutils_export void MT_fprintf_silent(bool silent);
diff --git a/embedded/CMakeLists.txt b/embedded/CMakeLists.txt
--- a/embedded/CMakeLists.txt
+++ b/embedded/CMakeLists.txt
@@ -110,6 +110,7 @@ add_library(monetdblite SHARED
                        ../gdk/gdk_select.c
                        ../gdk/gdk_ssort.c
                        ../gdk/gdk_storage.c
+                       ../gdk/gdk_string.c
                        ../gdk/gdk_system.c
                        ../gdk/gdk_tm.c
                        ../gdk/gdk_unique.c
diff --git a/embedded/monetdb_embedded.c b/embedded/monetdb_embedded.c
--- a/embedded/monetdb_embedded.c
+++ b/embedded/monetdb_embedded.c
@@ -14,30 +14,21 @@
 #include "monetdb_config.h"
 
 #include "monetdb_embedded.h"
-
+#include "gdk.h"
 #include "mal.h"
 #include "mal_client.h"
-#include "mal_builder.h"
-
-#include "mal_linker.h"
-#include "sql_scenario.h"
-#include "gdk_utils.h"
+#include "mal_embedded.h"
+#include "mtime.h"
+#include "blob.h"
+#include "sql_mvc.h"
+#include "sql_catalog.h"
+#include "sql_gencode.h"
 #include "sql_scenario.h"
-#include "sql_execute.h"
-#include "sql.h"
-#include "sql_mvc.h"
-#include "res_table.h"
-#include "sql_scenario.h"
-#include "opt_prelude.h"
-#include "rel_semantic.h"
-#include "sql_gencode.h"
 #include "sql_optimizer.h"
 #include "rel_exp.h"
 #include "rel_rel.h"
 #include "rel_updates.h"
-
-#include "mtime.h"
-#include "blob.h"
+#include "monet_options.h"
 
 static int monetdb_embedded_initialized = 0;
 
@@ -54,10 +45,10 @@ validate_connection(monetdb_connection c
                return createException(MAL, call, SQLSTATE(HY001) "Embedded 
MonetDB is not started");
        if (!MCvalid((Client) conn))
                return createException(MAL, call, SQLSTATE(HY001) "Invalid 
connection");
-       return MAL_SUCCEDED;
+       return MAL_SUCCEED;
 }
 
-MT_Lock embedded_lock MT_LOCK_INITIALIZER("embedded_lock");
+MT_Lock embedded_lock = MT_LOCK_INITIALIZER("embedded_lock");
 
 static void monetdb_destroy_column(monetdb_column* column);
 
@@ -88,7 +79,7 @@ monetdb_connect(monetdb_connection *conn
                goto cleanup;
        }
        mc->curmodule = mc->usermodule = userModule();
-       if(c->usermodule == NULL) {
+       if (mc->usermodule == NULL) {
                msg = createException(MAL, "embedded.monetdb_connect", 
SQLSTATE(HY001) "Failed to initialize client MAL module");
                goto cleanup;
        }
@@ -121,6 +112,16 @@ monetdb_disconnect(monetdb_connection co
        return MAL_SUCCEED;
 }
 
+static str
+monetdb_shutdown_internal(void)
+{
+       if (monetdb_embedded_initialized) {
+               malEmbeddedReset();
+               monetdb_embedded_initialized = 0;
+       }
+       return MAL_SUCCEED;
+}
+
 str
 monetdb_startup(char* dbdir, char silent, char sequential)
 {
@@ -187,7 +188,7 @@ monetdb_startup(char* dbdir, char silent
 
        // we do not want to jump after this point, since we cannot do so 
between threads
        // sanity check, run a SQL query
-       if ((msg = monetdb_query(c, "SELECT id FROM _tables LIMIT 1;", 1, &res, 
NULL, NULL)) != MAL_SUCCEED) {
+       if ((msg = monetdb_query(c, "SELECT id FROM _tables LIMIT 1;", &res, 
NULL, NULL)) != MAL_SUCCEED) {
                monetdb_embedded_initialized = false;
                goto cleanup;
        }
@@ -211,7 +212,7 @@ static str
 monetdb_query_internal(monetdb_connection conn, char* query, monetdb_result** 
result, lng* affected_rows,
                                           lng* prepare_id, char language)
 {
-       str msg = MAL_SUCCEED;
+       str msg = MAL_SUCCEED, commit_msg;
        Client c = (Client) conn;
        mvc* m;
        backend *b;
@@ -227,12 +228,10 @@ monetdb_query_internal(monetdb_connectio
        b = (backend *) c->sqlcontext;
        m = b->mvc;
 
-       query_stream = buffer_rastream(&query_buf, qname);
-       if (!query_stream)
-               return createException(MAL, "embedded.monetdb_query_internal", 
SQLSTATE(HY001) "WARNING: could not setup query stream.");
-
        if (!query)
                return createException(MAL, "embedded.monetdb_query_internal", 
SQLSTATE(42000) "Query missing");
+       if (!(query_stream = buffer_rastream(&query_buf, qname)))
+               return createException(MAL, "embedded.monetdb_query_internal", 
SQLSTATE(HY001) "WARNING: could not setup query stream.");
        query_len = strlen(query) + 3;
        nq = GDKmalloc(query_len);
        if (!nq)
@@ -243,12 +242,14 @@ monetdb_query_internal(monetdb_connectio
        query_buf.len = query_len;
        query_buf.buf = nq;
 
-       c->fdin = bstream_create(query_stream, query_len);
-       if (!c->fdin) {
+       if (!(c->fdin = bstream_create(query_stream, query_len))) {
                close_stream(query_stream);
                return createException(MAL, "embedded.monetdb_query_internal", 
SQLSTATE(HY001) "WARNING: could not setup query stream.");
        }
-       bstream_next(c->fdin);
+       if (bstream_next(c->fdin) < 0) {
+               close_stream(query_stream);
+               throw(MAL, "embedded.monetdb_query_internal", SQLSTATE(HY001) 
"Internal error with ");
+       }
 
        b->language = language;
        m->scanner.mode = LINE_N;
@@ -267,8 +268,7 @@ monetdb_query_internal(monetdb_connectio
        if (prepare_id && m->emode == m_prepare)
                *prepare_id = b->q->id;
 
-       msg = SQLengine(c);
-       if (msg != MAL_SUCCEED)
+       if ((msg = SQLengine(c)) != MAL_SUCCEED)
                goto cleanup;
 
        if (!m->results && m->rowcnt >= 0 && affected_rows)
@@ -293,13 +293,13 @@ monetdb_query_internal(monetdb_connectio
                if (m->results) {
                        res_internal->res.ncols = m->results->nr_cols;
                        if (m->results->nr_cols > 0 && m->results->order) {
-                               BAT* b = BATdescriptor(m->results->order)
-                               if (!b) {
+                               BAT* bb = BATdescriptor(m->results->order);
+                               if (!bb) {
                                        msg = createException(MAL, 
"embedded.monetdb_query_internal", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
                                        goto cleanup;
                                }
-                               res_internal->res.nrows = BATcount(b);
-                               BBPunfix(m->results->order);
+                               res_internal->res.nrows = BATcount(bb);
+                               BBPunfix(bb->batCacheid);
                        }
                        res_internal->monetdb_resultset = m->results;
                        res_internal->converted_columns = 
GDKzalloc(sizeof(monetdb_column*) * res_internal->res.ncols);
@@ -335,22 +335,22 @@ cleanup:
 }
 
 str
-monetdb_clear_prepare(monetdb_connection conn, size_t id)
+monetdb_clear_prepare(monetdb_connection conn, lng id)
 {
        char query[100];
 
-       sprintf(query, "release "ULLFMT, (uint64_t) id);
+       sprintf(query, "release "LLFMT, id);
        return(monetdb_query_internal(conn, query, NULL, NULL, NULL, 'X'));
 }
 
 str
-monetdb_send_close(monetdb_connection conn, size_t id)
+monetdb_send_close(monetdb_connection conn, lng id)
 {
        char query[100];
 
        if (id < 1)
                return createException(MAL, "embedded.monetdb_send_close", 
SQLSTATE(42000) "Invalid value, must be positive.");
-       sprintf(query, "close "ULLFMT, (uint64_t) id);
+       sprintf(query, "close "LLFMT, id);
        return(monetdb_query_internal(conn, query, NULL, NULL, NULL, 'X'));
 }
 
@@ -359,9 +359,9 @@ monetdb_set_autocommit(monetdb_connectio
 {
        char query[100];
 
-       if (val != 1 && val != 0)
+       if (value != 1 && value != 0)
                return createException(MAL, "embedded.monetdb_set_autocommit", 
SQLSTATE(42000) "Invalid value, need 0 or 1.");
-       sprintf(query, "auto_commit %i", val);
+       sprintf(query, "auto_commit %i", value);
        return(monetdb_query_internal(conn, query, NULL, NULL, NULL, 'X'));
 }
 
@@ -375,8 +375,7 @@ str
 monetdb_append(monetdb_connection conn, const char* schema, const char* table, 
append_data *data, size_t column_count)
 {
        Client c = (Client) conn;
-       mvc* m;
-       int i;
+       mvc *m;
        str msg = MAL_SUCCEED;
 
        if ((msg = validate_connection(conn, "embedded.monetdb_append")) != 
MAL_SUCCEED)
@@ -391,49 +390,49 @@ monetdb_append(monetdb_connection conn, 
        if ((msg = getSQLContext(c, NULL, &m, NULL)) != MAL_SUCCEED)
                return msg;
        if (m->session->status < 0 && m->session->auto_commit == 0)
-               return createException(MAL, "embedded.monetdb_append", 
SQLSTATE(25005) "Current transaction is aborted (please ROLLBACK)");
+               return createException(SQL, "embedded.monetdb_append", 
SQLSTATE(25005) "Current transaction is aborted (please ROLLBACK)");
+       if (!m->sa) // unclear why this is required
+               m->sa = sa_create();
+       if (!m->sa)
+               return createException(SQL, "embedded.monetdb_append", 
SQLSTATE(HY001) MAL_MALLOC_FAIL);
 
        if ((msg = SQLtrans(m)) != MAL_SUCCEED)
                return msg;
-       if (!m->sa) { // unclear why this is required
-               m->sa = sa_create();
-               if (!m->sa)
-                       return createException(MAL, "embedded.monetdb_append", 
SQLSTATE(HY001) MAL_MALLOC_FAIL);
-       }
        {
+               node *n;
+               size_t i;
                sql_rel *rel;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to