MonetDB: iot - Added bug test for tuple windows correctness

2016-08-16 Thread Pedro Ferreira
Changeset: b29c9d42646c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b29c9d42646c
Added Files:
sql/backends/monet5/iot/Tests/bug06.sql
Branch: iot
Log Message:

Added bug test for tuple windows correctness


diffs (26 lines):

diff --git a/sql/backends/monet5/iot/Tests/bug06.sql 
b/sql/backends/monet5/iot/Tests/bug06.sql
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/iot/Tests/bug06.sql
@@ -0,0 +1,21 @@
+CREATE SCHEMA iot;
+SET SCHEMA iot;
+SET OPTIMIZER = 'iot_pipe';
+
+CREATE STREAM TABLE temperature (t TIMESTAMP, sensor INT, val DECIMAL);
+CALL window('iot', 'temperature', 3);
+CREATE TABLE results (minimum TIMESTAMP, tuples INT, average DECIMAL);
+
+CREATE PROCEDURE testing()
+BEGIN
+   INSERT INTO results SELECT MIN(t), COUNT(*), AVG(val) FROM temperature;
+END;
+
+CALL query('iot', 'testing');
+
+INSERT INTO temperature VALUES (now(), 1, 1), (now(), 2, 2), (now(), 3, 3), 
(now(), 4, 4);
+
+SELECT * FROM results; /* should have only 1 row, where "tuples" column value 
is 3 */
+
+CALL getwindow('iot','temperature'); /* should not hang! */
+
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - In LoadLibrary, if a dynamic library exists b...

2016-08-16 Thread Mark Raasveldt
Changeset: 1eea294e3c5f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1eea294e3c5f
Modified Files:
gdk/gdk.h
gdk/gdk_storage.c
monetdb5/mal/mal_linker.c
Branch: default
Log Message:

In LoadLibrary, if a dynamic library exists but dlopen() fails throw an error 
message.

This should help when debugging runtime linking issues, currently only 
"sql.prelude() is missing" is displayed when linking fails. Now the actual 
linking error should be displayed.

e.g.:

!LoaderException:loadLibrary:Loading error failed to open library pyapi (from 
within file '/Users/myth/opt/lib/monetdb5/lib_pyapi.so'): 
dlopen(/Users/myth/opt/lib/monetdb5/lib_pyapi.so, 10): Symbol not found: 
_undefined_function
!  Referenced from: /Users/myth/opt/lib/monetdb5/lib_pyapi.so
!  Expected in: flat namespace
! in /Users/myth/opt/lib/monetdb5/lib_pyapi.so


diffs (63 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1494,6 +1494,7 @@ gdk_export size_t BATmemsize(BAT *b, int
 
 #define NOFARM (-1) /* indicate to GDKfilepath to create relative path */
 
+gdk_export int GDKfileexists(const char *path);
 gdk_export char *GDKfilepath(int farmid, const char *dir, const char *nme, 
const char *ext);
 gdk_export gdk_return GDKcreatedir(const char *nme);
 
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -87,6 +87,16 @@ GDKfilepath(int farmid, const char *dir,
return path;
 }
 
+/*
+ * returns 1 if the file exists
+ */
+int 
+GDKfileexists(const char *path) {
+   struct stat st;
+   int ret = stat(path, );
+   return (ret == 0);
+}
+
 /* make sure the parent directory of DIR exists (the argument itself
  * is usually a file that is to be created) */
 gdk_return
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
@@ -178,12 +178,18 @@ loadLibrary(str filename, int flag)
 mod_path, DIR_SEP, SO_PREFIX, s, SO_EXT);
 #endif
handle = dlopen(nme, mode);
+   if (handle == NULL && GDKfileexists(nme)) {
+   throw(LOADER, "loadLibrary", RUNTIME_LOAD_ERROR " 
failed to open library %s (from within file '%s'): %s", s, nme, dlerror());
+   }
if (handle == NULL && strcmp(SO_EXT, ".so") != 0) {
/* try .so */
snprintf(nme, PATHLENGTH, "%.*s%c%s_%s.so",
 (int) (p - mod_path),
 mod_path, DIR_SEP, SO_PREFIX, s);
handle = dlopen(nme, mode);
+   if (handle == NULL && GDKfileexists(nme)) {
+   throw(LOADER, "loadLibrary", RUNTIME_LOAD_ERROR 
" failed to open library %s (from within file '%s'): %s", s, nme, dlerror());
+   }
}
 #ifdef __APPLE__
if (handle == NULL && strcmp(SO_EXT, ".bundle") != 0) {
@@ -192,6 +198,9 @@ loadLibrary(str filename, int flag)
 (int) (p - mod_path),
 mod_path, DIR_SEP, SO_PREFIX, s);
handle = dlopen(nme, mode);
+   if (handle == NULL && GDKfileexists(nme)) {
+   throw(LOADER, "loadLibrary", RUNTIME_LOAD_ERROR 
" failed to open library %s (from within file '%s'): %s", s, nme, dlerror());
+   }
}
 #endif
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Modify split_filename to work correctly with ...

2016-08-16 Thread Mark Raasveldt
Changeset: d0ea7e938b39 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d0ea7e938b39
Added Files:
buildtools/autogen/autogen/filesplit.py
Modified Files:
buildtools/autogen/autogen/am.py
buildtools/autogen/autogen/codegen.py
buildtools/autogen/autogen/msc.py
Branch: default
Log Message:

Modify split_filename to work correctly with dots in a filename (e.g. 
file.bla.c).

Also modify it to work correctly with relative paths (../../file.c).


diffs (144 lines):

diff --git a/buildtools/autogen/autogen/am.py b/buildtools/autogen/autogen/am.py
--- a/buildtools/autogen/autogen/am.py
+++ b/buildtools/autogen/autogen/am.py
@@ -10,9 +10,7 @@ import sys
 sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
 from codegen import find_org
 import re
-
-automake_ext = ['', 'c', 'def', 'h', 'lo', 'o', 'pm.c',
-'tab.c', 'tab.h', 'yy.c']
+from filesplit import split_filename, rsplit_filename, automake_ext
 
 # buildtools_ext contains the extensions of files from which sources
 # are generated by rules that are specified in rules.mk in
@@ -23,21 +21,6 @@ buildtools_ext = ['brg', 'l', 'pm.i', 's
 
 am_assign = "+="
 
-def split_filename(f):
-base = f
-ext = ""
-if f.find(".") >= 0:
-return f.split(".", 1)
-return base, ext
-
-def rsplit_filename(f):
-base = f
-ext = ""
-s = f.rfind(".")
-if s >= 0:
-return f[:s], f[s+1:]
-return base, ext
-
 def cond_subdir(fd, dir, i):
 res = ""
 parts = dir.split("?")
diff --git a/buildtools/autogen/autogen/codegen.py 
b/buildtools/autogen/autogen/codegen.py
--- a/buildtools/autogen/autogen/codegen.py
+++ b/buildtools/autogen/autogen/codegen.py
@@ -13,6 +13,7 @@ import sys
 
 from tokenize import tokenize
 from tokenize import NL
+from filesplit import split_filename
 
 
 # direct rules
@@ -75,13 +76,6 @@ scan_map = {
 'tex': [ tex_inc, None, '' ],
 }
 
-def split_filename(f):
-base = f
-ext = ""
-if f.find(".") >= 0:
-return f.split(".", 1)
-return base,ext
-
 def readfile(f):
 src = open(f, 'r')
 buf = src.read()
diff --git a/buildtools/autogen/autogen/filesplit.py 
b/buildtools/autogen/autogen/filesplit.py
new file mode 100644
--- /dev/null
+++ b/buildtools/autogen/autogen/filesplit.py
@@ -0,0 +1,43 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0.  If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+
+
+# get the right-most extension of a filename
+def rsplit_filename(f):
+base = f
+ext = ""
+s = f.rfind(".")
+if s >= 0:
+return f[:s], f[s+1:]
+return base, ext
+
+automake_ext = ['', 'c', 'def', 'h', 'lo', 'o', 'pm.c', 'tab.c', 'tab.h', 
'yy.c', 'pm.i']
+automake_extra_extensions = set([rsplit_filename(x)[1] for x in automake_ext 
if '.' in x])
+extra_extensions = ['in', 'bat', 'sed']
+
+
+
+# get the left-most extension of a filename
+# we skip over known 'extra' extensions to get the real left-most extension
+# this allows us to work with files with periods in them (file.bla.c would 
have 'c' as extension)
+# while supporting files with multiple extensions (file.c.in would result in 
'c' rather than 'in')
+def split_filename(f):
+base,ext = rsplit_filename(f)
+# special case for automake extensions (tab.c,tab.h)
+# we want: file.tab.c -> 'tab.c'
+#  file.bla.c -> 'c'
+if ext in automake_extra_extensions:
+new_base,new_ext = rsplit_filename(base)
+new_ext = new_ext + '.' + ext
+if new_ext in automake_ext:
+return new_base,new_ext
+while ext in extra_extensions:
+new_base,new_ext = rsplit_filename(base)
+if len(new_ext) > 0 and '/' not in new_ext:
+base,ext = new_base,new_ext + '.' + ext
+else:
+break
+return base,ext
diff --git a/buildtools/autogen/autogen/msc.py 
b/buildtools/autogen/autogen/msc.py
--- a/buildtools/autogen/autogen/msc.py
+++ b/buildtools/autogen/autogen/msc.py
@@ -7,6 +7,7 @@
 import string
 import os
 import re
+from filesplit import rsplit_filename, split_filename, automake_ext
 
 # the text that is put at the top of every generated Makefile.msc
 MAKEFILE_HEAD = '''
@@ -16,23 +17,6 @@ MAKEFILE_HEAD = '''
 
 '''
 
-automake_ext = ['c', 'h', 'tab.c', 'tab.h', 'yy.c', 'pm.i', '']
-
-def split_filename(f):
-base = f
-ext = ""
-if f.find(".") >= 0:
-return f.split(".", 1)
-return base, ext
-
-def rsplit_filename(f):
-base = f
-ext = ""
-s = f.rfind(".")
-if s >= 0:
-return f[:s], f[s+1:]
-return base, ext
-
 def msc_basename(f):
 # return basename (i.e. just the file name part) of a path, no
 # matter which directory separator was used
___
checkin-list mailing list