Changeset: 0a79c50ecff4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0a79c50ecff4
Modified Files:
        monetdb5/mal/mal_linker.c
        sql/backends/monet5/UDF/pyapi/type_conversion.c
        sql/backends/monet5/UDF/pyapi/type_conversion.h
        sql/backends/monet5/rel_bin.c
        sql/backends/monet5/sql_scenario.c
        sql/backends/monet5/vaults/shp/shp.c
        testing/exportutils.py
Branch: analytics
Log Message:

Merge with default.


diffs (193 lines):

diff --git a/monetdb5/mal/mal_linker.c b/monetdb5/mal/mal_linker.c
--- a/monetdb5/mal/mal_linker.c
+++ b/monetdb5/mal/mal_linker.c
@@ -233,6 +233,7 @@ loadLibrary(str filename, int flag)
 
        MT_lock_set(&mal_contextLock);
        if (lastfile == maxfiles) {
+               MT_lock_unset(&mal_contextLock);
                if (handle)
                        dlclose(handle);
                throw(MAL,"mal.linker", "loadModule internal error, too many 
modules loaded");
diff --git a/sql/backends/monet5/UDF/pyapi/type_conversion.c 
b/sql/backends/monet5/UDF/pyapi/type_conversion.c
--- a/sql/backends/monet5/UDF/pyapi/type_conversion.c
+++ b/sql/backends/monet5/UDF/pyapi/type_conversion.c
@@ -18,7 +18,7 @@
 #define PyString_CheckExact PyUnicode_CheckExact
 #endif
 
-bool string_copy(char *source, char *dest, size_t max_size, bool allow_unicode)
+bool string_copy(const char *source, char *dest, size_t max_size, bool 
allow_unicode)
 {
        size_t i;
        for (i = 0; i < max_size; i++) {
@@ -175,7 +175,7 @@ str pyobject_to_str(PyObject **ptr, size
                ucs2_to_utf8(0, ((PyUnicodeObject *)obj)->length, utf8_string, 
str);
 #endif
 #else
-               char *str = PyUnicode_AsUTF8(obj);
+               const char *str = PyUnicode_AsUTF8(obj);
                if (!string_copy(str, utf8_string, len-1, true)) {
                        msg = createException(MAL, "pyapi.eval",
                                                                  
SQLSTATE(PY000) "Invalid string encoding used. Please return "
@@ -206,7 +206,7 @@ wrapup:
 }
 
 #define STRING_TO_NUMBER_FACTORY(tpe)                                          
\
-       str str_to_##tpe(char *ptr, size_t maxsize, tpe *value)                 
   \
+       str str_to_##tpe(const char *ptr, size_t maxsize, tpe *value)           
   \
        {                                                                       
   \
                size_t len = sizeof(tpe);                                       
       \
                char buf[256];                                                  
       \
diff --git a/sql/backends/monet5/UDF/pyapi/type_conversion.h 
b/sql/backends/monet5/UDF/pyapi/type_conversion.h
--- a/sql/backends/monet5/UDF/pyapi/type_conversion.h
+++ b/sql/backends/monet5/UDF/pyapi/type_conversion.h
@@ -24,12 +24,12 @@
 //! Copies the string of size up to max_size from the source to the 
destination,
 //! returns FALSE if "source" is not a legal ASCII string (i.e. a character is
 //! >= 128)
-bool string_copy(char *source, char *dest, size_t max_size, bool 
allow_unicode);
+bool string_copy(const char *source, char *dest, size_t max_size, bool 
allow_unicode);
 #ifdef HAVE_HGE
 //! Converts a hge to a string and writes it into the string "str"
 int hge_to_string(char *str, hge);
 //! Converts a base-10 string to a hge value
-str str_to_hge(char *ptr, size_t maxsize, hge *value);
+str str_to_hge(const char *ptr, size_t maxsize, hge *value);
 //! Converts a base-10 utf32-encoded string to a hge value
 str unicode_to_hge(Py_UNICODE *utf32, size_t maxsize, hge *value);
 //! Converts a PyObject to a hge value
@@ -48,7 +48,7 @@ str pyobject_to_blob(PyObject **ptr, siz
 
 //using macros, create a number of str_to_<type>, unicode_to_<type> and 
pyobject_to_<type> functions (we are Java now)
 #define CONVERSION_FUNCTION_HEADER_FACTORY(tpe)          \
-    str str_to_##tpe(char *ptr, size_t maxsize, tpe *value);          \
+    str str_to_##tpe(const char *ptr, size_t maxsize, tpe *value);          \
     str unicode_to_##tpe(Py_UNICODE *ptr, size_t maxsize, tpe *value);         
         \
     str pyobject_to_##tpe(PyObject **ptr, size_t maxsize, tpe *value);
 
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -403,9 +403,9 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                        (void)stmt_control_end(be, wstmt);
                        return stmt_control_end(be, ifstmt);
                } else if (e->flag & PSM_IF) {
-                       stmt *cond = exp_bin(be, e->l, left, right, grp, cnt, 
ext, sel);
+                       stmt *cond = exp_bin(be, e->l, left, right, grp, ext, 
cnt, sel);
                        stmt *ifstmt = stmt_cond(be, cond, NULL, 0, 0), *res;
-                       (void)exp_list(be, e->r, left, right, grp, cnt, ext, 
sel);
+                       (void)exp_list(be, e->r, left, right, grp, ext, cnt, 
sel);
                        res = stmt_control_end(be, ifstmt);
                        if (e->f) {
                                stmt *elsestmt = stmt_cond(be, cond, NULL, 0, 
1);
@@ -433,7 +433,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l
                                return r;
                        return stmt_table(be, r, 1);
                } else if (e->flag & PSM_EXCEPTION) {
-                       stmt *cond = exp_bin(be, e->l, left, right, grp, cnt, 
ext, sel);
+                       stmt *cond = exp_bin(be, e->l, left, right, grp, ext, 
cnt, sel);
                        return stmt_exception(be, cond, (const char *) e->r, 0);
                }
                break;
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
@@ -403,8 +403,10 @@ SQLinit(Client c)
        monet5_user_init(&be_funcs);
 
        msg = MTIMEtimezone(&tz, &gmt);
-       if (msg)
+       if (msg) {
+               MT_lock_unset(&sql_contextLock);
                return msg;
+       }
        (void) tz;
        if (debug_str)
                SQLdebug = strtol(debug_str, NULL, 10);
@@ -477,14 +479,18 @@ SQLinit(Client c)
                buffer* createdb_buf;
                stream* createdb_stream;
                bstream* createdb_bstream;
-               if ((createdb_buf = GDKmalloc(sizeof(buffer))) == NULL)
+               if ((createdb_buf = GDKmalloc(sizeof(buffer))) == NULL) {
+                       MT_lock_unset(&sql_contextLock);
                        throw(MAL, "createdb", SQLSTATE(HY001) MAL_MALLOC_FAIL);
+               }
                buffer_init(createdb_buf, createdb_inline, createdb_len);
                if ((createdb_stream = buffer_rastream(createdb_buf, 
"createdb.sql")) == NULL) {
+                       MT_lock_unset(&sql_contextLock);
                        GDKfree(createdb_buf);
                        throw(MAL, "createdb", SQLSTATE(HY001) MAL_MALLOC_FAIL);
                }
                if ((createdb_bstream = bstream_create(createdb_stream, 
createdb_len)) == NULL) {
+                       MT_lock_unset(&sql_contextLock);
                        close_stream(createdb_stream);
                        GDKfree(createdb_buf);
                        throw(MAL, "createdb", SQLSTATE(HY001) MAL_MALLOC_FAIL);
@@ -580,10 +586,12 @@ SQLinit(Client c)
                *m->errstr = 0;
                sqlcleanup(m, mvc_status(m));
        }
-       if ((msg = SQLresetClient(c)) != MAL_SUCCEED)
+
+       msg = SQLresetClient(c);
+       MT_lock_unset(&sql_contextLock);
+       if (msg != MAL_SUCCEED)
                return msg;
 
-       MT_lock_unset(&sql_contextLock);
        if (MT_create_thread(&sqllogthread, (void (*)(void *)) mvc_logmanager, 
NULL, MT_THR_JOINABLE) != 0) {
                throw(SQL, "SQLinit", SQLSTATE(42000) "Starting log manager 
failed");
        }
diff --git a/sql/backends/monet5/vaults/shp/shp.c 
b/sql/backends/monet5/vaults/shp/shp.c
--- a/sql/backends/monet5/vaults/shp/shp.c
+++ b/sql/backends/monet5/vaults/shp/shp.c
@@ -17,6 +17,9 @@
 #include "sql_mvc.h"
 #include "sql.h"
 #define HAVE_CXX11 0           /* stupid include file gdal/cpl_port.h */
+#ifndef __clang_major__                /* stupid include file gdal/cpl_port.h 
*/
+#define __clang_major__ 0
+#endif
 #include "shp.h"
 #include <cpl_conv.h>          /* for CPLFree */
 #include "sql_execute.h"
diff --git a/testing/exportutils.py b/testing/exportutils.py
--- a/testing/exportutils.py
+++ b/testing/exportutils.py
@@ -61,18 +61,18 @@ def preprocess(data):
 
 def replace(line, defines, tried):
     changed = False
+    # match argument to macro with optionally several levels
+    # of parentheses
+    if deepnesting:     # optionally deeply nested parentheses
+        nested = 
r'(?:\([^()]*(?:\([^()]*(?:\([^()]*(?:\([^()]*(?:\([^()]*(?:\([^()]*\)[^()]*)*\)[^()]*)*\)[^()]*)*\)[^()]*)*\)[^()]*)*\)[^()]*)*'
+    else:
+        nested = ''
     for name, (args, body) in defines.items():
         if name in tried:
             continue
         pat = r'\b%s\b' % name
         sep = r'\('
         for arg in args:
-            # match argument to macro with optionally several levels
-            # of parentheses
-            if deepnesting:     # optionally deeply nested parentheses
-                nested = 
r'(?:\([^()]*(?:\([^()]*(?:\([^()]*(?:\([^()]*(?:\([^()]*(?:\([^()]*\)[^()]*)*\)[^()]*)*\)[^()]*)*\)[^()]*)*\)[^()]*)*\)[^()]*)*'
-            else:
-                nested = ''
             pat = pat + sep + r'([^,()]*(?:\([^()]*' + nested + r'\)[^,()]*)*)'
             sep = ','
         pat += r'\)'
@@ -104,8 +104,8 @@ def replace(line, defines, tried):
                         pos = res2.start(0) + len(repl[arg])
                         bd = bd[:res2.start(0)] + repl[arg] + bd[res2.end(0):]
                     res2 = r2.search(bd, pos)
+            bd = bd.replace('##', '')
             bd, changed = replace(bd, defines, tried + [name])
-            bd = bd.replace('##', '')
             line = line[:res.start(0)] + bd + line[res.end(0):]
             res = r.search(line, res.start(0) + len(bd))
     return line, changed
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to