MonetDB: iot - Merge changes

2016-06-09 Thread Pedro Ferreira
Changeset: 3cc8124c0247 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3cc8124c0247
Modified Files:
sql/backends/monet5/iot/basket.c
sql/backends/monet5/iot/basket.h
sql/backends/monet5/iot/petrinet.c
Branch: iot
Log Message:

Merge changes


diffs (94 lines):

diff --git a/sql/backends/monet5/iot/basket.c b/sql/backends/monet5/iot/basket.c
--- a/sql/backends/monet5/iot/basket.c
+++ b/sql/backends/monet5/iot/basket.c
@@ -35,7 +35,7 @@
 
 #define _DEBUG_BASKET_ if(0)
 
-str statusname[4] = { "", "active", "paused", "locked" };
+str statusname[4] = { "", "available", "wait", "locked" };
 
 BasketRec *baskets;   /* the global iot catalog */
 static int bsktTop = 0, bsktLimit = 0;
@@ -109,7 +109,7 @@ BSKTnewbasket(sql_schema *s, sql_table *
baskets[idx].table_name = GDKstrdup(t->base.name);
baskets[idx].seen = * timestamp_nil;
 
-   baskets[idx].status = BSKTPAUSED;
+   baskets[idx].status = BSKTWAIT;
baskets[idx].count = 0;
for (o = t->columns.set->h; o; o = o->next){
 sql_column *col = o->data;
@@ -205,7 +205,7 @@ BSKTactivate(Client cntxt, MalBlkPtr mb,
idx = BSKTlocate(sch, tbl);
if( idx == 0)
throw(SQL,"basket.activate","Stream table %s.%s not 
accessible to activate\n",sch,tbl);
-   if( baskets[idx].status == BSKTPAUSED){
+   if( baskets[idx].status == BSKTWAIT){
MT_lock_set();
baskets[idx].status = BSKTAVAILABLE;
MT_lock_unset();
@@ -237,13 +237,13 @@ BSKTdeactivate(Client cntxt, MalBlkPtr m
throw(SQL,"basket.activate","Stream table %s.%s not 
accessible to deactivate\n",sch,tbl);
if( baskets[idx].status == BSKTAVAILABLE ){
MT_lock_set();
-   baskets[idx].status = BSKTPAUSED;
+   baskets[idx].status = BSKTWAIT;
MT_lock_unset();
}
} else {
MT_lock_set();
for( idx =1; idx 

MonetDB: iot - Merge changes

2016-06-09 Thread Pedro Ferreira
Changeset: d40d60cb293a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d40d60cb293a
Modified Files:
sql/backends/monet5/iot/50_iot.sql
Branch: iot
Log Message:

Merge changes


diffs (13 lines):

diff --git a/sql/backends/monet5/iot/50_iot.sql 
b/sql/backends/monet5/iot/50_iot.sql
--- a/sql/backends/monet5/iot/50_iot.sql
+++ b/sql/backends/monet5/iot/50_iot.sql
@@ -106,7 +106,7 @@ create function iot.outputplaces()
 
 -- tables for iotwebserver
 
-CREATE TABLE iot.webserverflushing (table_id INTEGER, base TINYINT, "interval" 
INTEGER NULL, unit TINYINT NULL);
+CREATE TABLE iot.webserverstreams (table_id INTEGER, has_hostname BOOLEAN, 
base TINYINT, "interval" INTEGER NULL, unit TINYINT NULL);
 
-CREATE TABLE iot.webservervalidation (column_id INTEGER, special TINYINT NULL, 
validation1 string NULL, validation2 string NULL);
+CREATE TABLE iot.webservercolumns (column_id INTEGER, special TINYINT NULL, 
validation1 STRING NULL, validation2 STRING NULL);
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: iot - Added stream polling

2016-06-09 Thread Pedro Ferreira
Changeset: c44d0bb79a54 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c44d0bb79a54
Modified Files:
clients/iotapi/requirements.txt
clients/iotapi/src/Streams/datatypes.py
clients/iotapi/src/Streams/streampolling.py
clients/iotclient/requirements.txt
clients/iotclient/src/Settings/mapiconnection.py
clients/iotclient/src/Streams/datatypes.py
clients/iotclient/src/Streams/jsonschemas.py
clients/iotclient/src/Streams/streampolling.py
clients/iotclient/src/Streams/streamscontext.py
clients/iotclient/src/Streams/streamscreator.py
Branch: iot
Log Message:

Added stream polling


diffs (truncated from 705 to 300 lines):

diff --git a/clients/iotapi/requirements.txt b/clients/iotapi/requirements.txt
--- a/clients/iotapi/requirements.txt
+++ b/clients/iotapi/requirements.txt
@@ -4,7 +4,7 @@ jsonschema==2.5.1
 pymonetdb==0.1.1
 python-dateutil==2.5.3
 pytz==2016.4
-Sphinx==1.4.1
+Sphinx==1.4.3
 sphinx-rtd-theme==0.1.9
 tzlocal==1.2.2
 watchdog==0.8.3
diff --git a/clients/iotapi/src/Streams/datatypes.py 
b/clients/iotapi/src/Streams/datatypes.py
--- a/clients/iotapi/src/Streams/datatypes.py
+++ b/clients/iotapi/src/Streams/datatypes.py
@@ -328,14 +328,6 @@ class TimeType(StreamDataType):  # Store
.isoformat())
 return results
 
-def to_json_representation(self):
-json_value = super(TimeType, self).to_json_representation()
-if self._data_type == 'timez':
-json_value['with_timezone'] = True
-else:
-json_value['with_timezone'] = False
-return json_value
-
 
 class TimestampType(StreamDataType):  # it's represented with the two integers 
from time and date
 """Covers: TIMESTAMP"""
@@ -363,11 +355,3 @@ class TimestampType(StreamDataType):  # 
 results.append(datetime.combine(read_date, time(hour=hour, 
minute=minute, second=second,
 
microsecond=milliseconds * 1000)).isoformat())
 return results
-
-def to_json_representation(self):
-json_value = super(TimestampType, self).to_json_representation()
-if self._data_type == 'timestamptz':
-json_value['with_timezone'] = True
-else:
-json_value['with_timezone'] = False
-return json_value
diff --git a/clients/iotapi/src/Streams/streampolling.py 
b/clients/iotapi/src/Streams/streampolling.py
--- a/clients/iotapi/src/Streams/streampolling.py
+++ b/clients/iotapi/src/Streams/streampolling.py
@@ -1,5 +1,4 @@
 from itertools import groupby
-
 from Settings.mapiconnection import fetch_streams
 from Utilities.customthreading import PeriodicalThread
 from datatypes import *
diff --git a/clients/iotclient/requirements.txt 
b/clients/iotclient/requirements.txt
--- a/clients/iotclient/requirements.txt
+++ b/clients/iotclient/requirements.txt
@@ -1,13 +1,13 @@
-python-dateutil==2.5.3
 fake-factory==0.5.7
 Flask-RESTful==0.3.5
 IPy==0.83
 iso8601==0.1.11
 jsonschema==2.5.1
 pymonetdb==0.1.1
+python-dateutil==2.5.3
 pytz==2016.4
 rfc3987==1.3.6
-Sphinx==1.4.1
+Sphinx==1.4.3
 sphinx-rtd-theme==0.1.9
 strict-rfc3339==0.7
 tzlocal==1.2.2
diff --git a/clients/iotclient/src/Settings/mapiconnection.py 
b/clients/iotclient/src/Settings/mapiconnection.py
--- a/clients/iotclient/src/Settings/mapiconnection.py
+++ b/clients/iotclient/src/Settings/mapiconnection.py
@@ -49,22 +49,21 @@ def mapi_get_webserver_streams():
 try:
 Connection.execute("START TRANSACTION")
 cursor = Connection.cursor()
-sql_string = """SELECT tables."id", tables."name", schemas."name" AS 
schema, tables."name" AS table,
-extras."has_hostname", extras."flushing", extras."unit", 
extras."interval" FROM (SELECT "id", "name",
-"schema_id" FROM sys.tables WHERE type=4) AS tables INNER JOIN 
(SELECT "id", "name" FROM sys.schemas)
-AS schemas ON (tables."schema_id"=schemas."id") LEFT JOIN (SELECT 
"table_id", "has_hostname", "flushing",
-"unit", "interval" FROM iot.webserverstreams) AS extras ON 
(tables."id"=extras."table_id")"""\
-.replace('\n', ' ')
+sql_string = """SELECT tables."id", schemas."name" AS schema, 
tables."name" AS table, extras."has_hostname",
+extras."base", extras."interval", extras."unit" FROM (SELECT "id", 
"name", "schema_id" FROM sys.tables
+WHERE type=4) AS tables INNER JOIN (SELECT "id", "name" FROM 
sys.schemas) AS schemas ON
+(tables."schema_id"=schemas."id") LEFT JOIN (SELECT "table_id", 
"has_hostname", "base", "interval", "unit"
+FROM iot.webserverstreams) AS extras ON 
(tables."id"=extras."table_id")""".replace('\n', ' ')
 cursor.execute(sql_string)
 tables = cursor.fetchall()
 
 cursor = Connection.cursor()
-sql_string = """SELECT columns."table_id", columns."name" AS column, 

MonetDB: Jun2016 - Fix the dependency syntax.

2016-06-09 Thread Sjoerd Mullender
Changeset: 5bf038a6bdfa for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5bf038a6bdfa
Modified Files:
debian/control
Branch: Jun2016
Log Message:

Fix the dependency syntax.


diffs (21 lines):

diff --git a/debian/control b/debian/control
--- a/debian/control
+++ b/debian/control
@@ -237,7 +237,7 @@ Description: MonetDB5 SQL interface to t
 Package: monetdb5-server
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
-Recommends: monetdb5-server-hugeint [amd64] (= ${source:Version}),
+Recommends: monetdb5-server-hugeint (= ${source:Version}) [amd64],
  monetdb5-sql (= ${source:Version})
 Suggests: monetdb-client (= ${source:Version})
 Description: MonetDB database server version 5
@@ -279,7 +279,7 @@ Package: monetdb5-sql
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends},
  monetdb5-server (= ${source:Version})
-Recommends: monetdb5-sql-hugeint [amd64] (= ${source:Version})
+Recommends: monetdb5-sql-hugeint (= ${source:Version}) [amd64]
 Suggests: monetdb-client (= ${source:Version})
 Description: MonetDB SQL support for monetdb5
  MonetDB is a database management system that is developed from a
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2016 - Improved ResultSetMetaData methods: isAutoInc...

2016-06-09 Thread Martin van Dinther
Changeset: 03e42371b6fa for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=03e42371b6fa
Modified Files:
java/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
java/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
Branch: Jun2016
Log Message:

Improved ResultSetMetaData methods: isAutoIncrement(), isSigned(), 
getSchemaName() and getTableName().
Removed throwing AssertionError() in methods getSchemaName() and getTableName().
Instead return "" as defined in the JDBC spec.


diffs (241 lines):

diff --git a/java/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java 
b/java/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
--- a/java/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
+++ b/java/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
@@ -294,8 +294,8 @@ public class MonetPreparedStatement
}
 
/**
-* Returns the index in the backing arrays for the given
-* resultset column number
+* Returns the index (0..size-1) in the backing arrays for the given
+* resultset column number or an SQLException when not found
 */
private int getColumnIdx(int colnr) throws SQLException {
int curcol = 0;
@@ -309,8 +309,8 @@ public class MonetPreparedStatement
throw new SQLException("No such column with index: " + colnr, 
"M1M05");
}
/**
-* Returns the index in the backing arrays for the given
-* parameter number
+* Returns the index (0..size-1) in the backing arrays for the given
+* parameter number or an SQLException when not found
 */
private int getParamIdx(int paramnr) throws SQLException {
int curparam = 0;
@@ -367,29 +367,25 @@ public class MonetPreparedStatement
}
 
/**
-* Indicates whether the designated column is 
automatically
-* numbered, thus read-only.
-* 
+* Indicates whether the designated column is 
automatically numbered.
+*
 * @param column the first column is 1, the second is 
2, ...
 * @return true if so; false otherwise
 * @throws SQLException if a database access error 
occurs
 */
@Override
public boolean isAutoIncrement(int column) throws 
SQLException {
-   // the only column I know of is a 'secret' 
column called rowid
-   // with datatype oid
-   // avoid nullpointer exception here
-   if 
("oid".equals(monetdbType[getColumnIdx(column)])) {
-   return true;
-   } else {
-   return false;
-   }
+   /* TODO: in MonetDB only numeric (int, decimal) 
columns could be autoincrement/serial
+* This however requires an expensive 
dbmd.getColumns(null, schema, table, column)
+* query call to pull the IS_AUTOINCREMENT 
value for this column.
+* See also ResultSetMetaData.isAutoIncrement()
+*/
+   // For now we simply allways return false.
+   return false;
}
 
/**
-* Indicates whether a column's case matters. This 
holds for all
-* columns in MonetDB resultsets since the mapping is 
done case
-* insensitive, therefore this method will always 
return false.
+* Indicates whether a column's case matters.
 *
 * @param column the first column is 1, the second is 
2, ...
 * @returns false
@@ -410,11 +406,8 @@ public class MonetPreparedStatement
/**
 * Indicates whether the designated column can be used 
in a
 * where clause.
-* It is unknown to me what kind ot columns they regard 
to,
-* as I think all columns are useable in a where clause.
-* Returning true for all here, for the time being.
-* Possible thought; maybe they want to know here if 
it's a
-* real column existing in a table or not...
+*
+* Returning true for all here, even for CLOB, BLOB.
 *
 * @param column the first column is 1, the second 

MonetDB: Jun2016 - Approved new upgrade code.

2016-06-09 Thread Sjoerd Mullender
Changeset: b09b43d54d6b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b09b43d54d6b
Modified Files:
sql/test/emptydb-upgrade-chain-hge/Tests/check.stable.out.int128
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/check.stable.out
sql/test/emptydb-upgrade-chain/Tests/check.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-hge/Tests/check.stable.out.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/check.stable.out
sql/test/emptydb-upgrade/Tests/check.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.oid32
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.32bit
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.oid32
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.32bit
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: Jun2016
Log Message:

Approved new upgrade code.


diffs (truncated from 352 to 300 lines):

diff --git a/sql/test/emptydb-upgrade-chain-hge/Tests/check.stable.out.int128 
b/sql/test/emptydb-upgrade-chain-hge/Tests/check.stable.out.int128
--- a/sql/test/emptydb-upgrade-chain-hge/Tests/check.stable.out.int128
+++ b/sql/test/emptydb-upgrade-chain-hge/Tests/check.stable.out.int128
@@ -7723,6 +7723,8 @@ drop function pcre_replace(string, strin
 [ 12,  "SEQUENCE"  ]
 [ 13,  "PROCEDURE" ]
 [ 14,  "BE_DROPPED"]
+[ 15,  "TYPE"  ]
+#drop function pcre_replace(string, string, string, string);
 
 # 16:23:51 >  
 # 16:23:51 >  "Done."
diff --git a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
--- a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
+++ b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
@@ -5652,6 +5652,12 @@ insert into sys.keywords values
 ('VALUES'), ('VARCHAR'), ('VARYING'), ('VIEW'),
 ('WHEN'), ('WHERE'), ('WHILE'), ('WITH'), ('WORK'), ('WRITE'),
 ('XMLAGG'), ('XMLATTRIBUTES'), ('XMLCOMMENT'), ('XMLCONCAT'), ('XMLDOCUMENT'), 
('XMLELEMENT'), ('XMLFOREST'), ('XMLNAMESPACES'), ('XMLPARSE'), ('XMLPI'), 
('XMLQUERY'), ('XMLSCHEMA'), ('XMLTEXT'), ('XMLVALIDATE');
+insert into sys.dependency_types (dependency_type_id, dependency_type_name)
+ select 15 as id, 'TYPE' as name where 15 not in (select dependency_type_id 
from sys.dependency_types);
+insert into sys.dependencies (id, depend_id, depend_type)
+ select distinct types.id as type_id, args.func_id, 15 as depend_type from 
sys.args join sys.types on types.systemname = args.type where args.type in 
('inet', 'json', 'url', 'uuid')
+ except
+ select distinct id, depend_id, depend_type from sys.dependencies where 
depend_type = 15;
 create function sys."storage"( sname string)
 returns table (
 "schema" string,
diff --git a/sql/test/emptydb-upgrade-chain/Tests/check.stable.out 
b/sql/test/emptydb-upgrade-chain/Tests/check.stable.out
--- a/sql/test/emptydb-upgrade-chain/Tests/check.stable.out
+++ b/sql/test/emptydb-upgrade-chain/Tests/check.stable.out
@@ -7146,6 +7146,8 @@ drop function pcre_replace(string, strin
 [ 12,  "SEQUENCE"  ]
 [ 13,  "PROCEDURE" ]
 [ 14,  "BE_DROPPED"]
+[ 15,  "TYPE"  ]
+#drop function pcre_replace(string, string, string, string);
 
 # 12:41:47 >  
 # 12:41:47 >  "Done."
diff --git a/sql/test/emptydb-upgrade-chain/Tests/check.stable.out.int128 
b/sql/test/emptydb-upgrade-chain/Tests/check.stable.out.int128
--- a/sql/test/emptydb-upgrade-chain/Tests/check.stable.out.int128
+++ b/sql/test/emptydb-upgrade-chain/Tests/check.stable.out.int128
@@ -7723,6 +7723,8 @@ drop function pcre_replace(string, strin
 [ 12,  "SEQUENCE"  ]
 [ 13,  "PROCEDURE" ]
 [ 14,  "BE_DROPPED"]
+[ 15,  "TYPE"  ]
+#drop function pcre_replace(string, string, string, string);
 
 # 16:23:51 >  
 # 16:23:51 >  "Done."
diff --git a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out 
b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
--- a/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
+++ b/sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
@@ -4954,6 +4954,12 @@ insert into sys.keywords values
 ('VALUES'), ('VARCHAR'), 

MonetDB: Jun2016 - php-common is presumably the future.

2016-06-09 Thread Sjoerd Mullender
Changeset: da5b4376d8b5 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=da5b4376d8b5
Modified Files:
debian/control
debian/fix-deb.sh
Branch: Jun2016
Log Message:

php-common is presumably the future.


diffs (39 lines):

diff --git a/debian/control b/debian/control
--- a/debian/control
+++ b/debian/control
@@ -136,7 +136,9 @@ Description: MonetDB ODBC driver
 
 Package: php5-monetdb-client
 Architecture: all
-Depends: ${shlibs:Depends}, ${misc:Depends}, php5-common
+# wheezy, jessie, precise, trusty, wily: php5-common
+# xenial: php-common
+Depends: ${shlibs:Depends}, ${misc:Depends}, php-common
 Description: MonetDB php5 client module
  MonetDB is a database management system that is developed from a
  main-memory perspective with use of a fully decomposed storage model,
diff --git a/debian/fix-deb.sh b/debian/fix-deb.sh
--- a/debian/fix-deb.sh
+++ b/debian/fix-deb.sh
@@ -38,10 +38,18 @@ case $SUITE in
 wheezy | precise | trusty)
 # fix control file because these systems don't have liblas and a
 # too old version of libgeos
-sed -i 's/, libgeos-dev[^,]*//;s/, liblas-c-dev[^,]*//' debian/control
-sed -i '/^Package:.*lidar/,/^$/d' debian/control
-sed -i '/^Package:.*geom/,/^$/d' debian/control
+sed -i -e 's/, libgeos-dev[^,]*//;s/, liblas-c-dev[^,]*//' \
+   -e '/^Package:.*lidar/,/^$/d' \
+   -e '/^Package:.*geom/,/^$/d' debian/control
 rm debian/libmonetdb5-server-lidar.install 
debian/libmonetdb5-server-geom.install
 sed -i 
'/geo[ms]=yes/s/yes/no/;/gdal=yes/s/yes/no/;/lidar=yes/s/yes/no/;/liblas=yes/s/yes/no/'
 debian/rules
 ;;
 esac
+
+case $SUITE in
+wheezy | jessie | precise | trusty | wily)
+# Xenial Xerus (and presumably newer releases) uses php-common,
+# all others still have php5-common
+sed -i 's/php-common/php5-common/' debian/control
+;;
+esac
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - fwf fix for windows newlines and general gunk...

2016-06-09 Thread Hannes Muehleisen
Changeset: ee6e38863857 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ee6e38863857
Modified Files:
common/stream/stream.c
Branch: default
Log Message:

fwf fix for windows newlines and general gunk behind fwf area in line


diffs (57 lines):

diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -4688,6 +4688,7 @@ typedef struct {
char* out_buf;
size_t out_buf_start;
size_t out_buf_remaining;
+   char* nl_buf;
 } stream_fwf_data;
 
 
@@ -4713,6 +4714,9 @@ stream_fwf_read(stream *s, void *buf, si
}
return buf_written; // skip last line
}
+   // consume to next newline
+   while (fsd->s->read(fsd->s, fsd->nl_buf, 1, 1) == 1 && 
*fsd->nl_buf != '\n');
+
for (field_idx = 0; field_idx < fsd->num_fields; 
field_idx++) {
char *val_start, *val_end;
val_start = fsd->in_buf + in_buf_pos;
@@ -4760,6 +4764,7 @@ stream_fwf_close(stream *s)
free(fsd->widths);
free(fsd->in_buf);
free(fsd->out_buf);
+   free(fsd->nl_buf);
free(fsd);
}
// FIXME destroy(s);
@@ -4778,7 +4783,7 @@ stream_fwf_create (stream *s, size_t num
fsd->num_fields = num_fields;
fsd->widths = widths;
fsd->filler = filler;
-   fsd->line_len = 1; // newline
+   fsd->line_len = 0;
for (i = 0; i < num_fields; i++) {
fsd->line_len += widths[i];
}
@@ -4795,10 +4800,17 @@ stream_fwf_create (stream *s, size_t num
return NULL;
}
fsd->out_buf_remaining = 0;
-
+   fsd->nl_buf = malloc(1);
+   if (!fsd->nl_buf) {
+   free(fsd->in_buf);
+   free(fsd->out_buf);
+   free(fsd);
+   return NULL;
+   }
if ((ns = create_stream(STREAM_FWF_NAME)) == NULL) {
free(fsd->in_buf);
free(fsd->out_buf);
+   free(fsd->nl_buf);
free(fsd);
return NULL;
}
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2016 - A new dependency TYPE_DEPENDENCY has been add...

2016-06-09 Thread Martin van Dinther
Changeset: 4cfa16cbac2f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4cfa16cbac2f
Modified Files:
sql/backends/monet5/sql_upgrades.c
sql/scripts/51_sys_schema_extension.sql
Branch: Jun2016
Log Message:

A new dependency TYPE_DEPENDENCY has been added in 
dev/sql/include/sql_catalog.h.
This also needs to be added to the sys.dependency_types table population 
script: 51_sys_schema_extension.sql
Also extended the upgrade program with SQL statements to insert rows into
 both the sys.dependency_types and sys.dependencies tables.


diffs (31 lines):

diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -1332,6 +1332,18 @@ sql_update_jun2016(Client c, mvc *sql)
"('WHEN'), ('WHERE'), ('WHILE'), ('WITH'), ('WORK'), 
('WRITE'),\n"
"('XMLAGG'), ('XMLATTRIBUTES'), ('XMLCOMMENT'), ('XMLCONCAT'), 
('XMLDOCUMENT'), ('XMLELEMENT'), ('XMLFOREST'), ('XMLNAMESPACES'), 
('XMLPARSE'), ('XMLPI'), ('XMLQUERY'), ('XMLSCHEMA'), ('XMLTEXT'), 
('XMLVALIDATE');\n");
 
+   // Add new dependency_type 15 to table sys.dependency_types
+   pos += snprintf(buf + pos, bufsize - pos,
+   "insert into sys.dependency_types (dependency_type_id, 
dependency_type_name)\n"
+   " select 15 as id, 'TYPE' as name where 15 not in (select 
dependency_type_id from sys.dependency_types);\n");
+
+   // Add 46 missing sys.dependencies rows for new dependency_type: 15
+   pos += snprintf(buf + pos, bufsize - pos,
+   "insert into sys.dependencies (id, depend_id, depend_type)\n"
+   " select distinct types.id as type_id, args.func_id, 15 as 
depend_type from sys.args join sys.types on types.systemname = args.type where 
args.type in ('inet', 'json', 'url', 'uuid')\n"
+   " except\n"
+   " select distinct id, depend_id, depend_type from 
sys.dependencies where depend_type = 15;\n");
+
// Add the new storage inspection functions.
pos += snprintf(buf + pos, bufsize - pos,
"create function sys.\"storage\"( sname string)\n"
diff --git a/sql/scripts/51_sys_schema_extension.sql 
b/sql/scripts/51_sys_schema_extension.sql
--- a/sql/scripts/51_sys_schema_extension.sql
+++ b/sql/scripts/51_sys_schema_extension.sql
@@ -54,4 +54,4 @@ CREATE TABLE sys.dependency_types (
 INSERT INTO sys.dependency_types (dependency_type_id, dependency_type_name) 
VALUES
 -- values taken from sql_catalog.h
   (1, 'SCHEMA'), (2, 'TABLE'), (3, 'COLUMN'), (4, 'KEY'), (5, 'VIEW'), (6, 
'USER'), (7, 'FUNCTION'), (8, 'TRIGGER'),
-  (9, 'OWNER'), (10, 'INDEX'), (11, 'FKEY'), (12, 'SEQUENCE'), (13, 
'PROCEDURE'), (14, 'BE_DROPPED');
+  (9, 'OWNER'), (10, 'INDEX'), (11, 'FKEY'), (12, 'SEQUENCE'), (13, 
'PROCEDURE'), (14, 'BE_DROPPED'), (15, 'TYPE');
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: iot - Intermittent commit

2016-06-09 Thread Martin Kersten
Changeset: ce4374847fa0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ce4374847fa0
Modified Files:
sql/backends/monet5/iot/basket.c
sql/backends/monet5/iot/basket.h
sql/backends/monet5/iot/petrinet.c
Branch: iot
Log Message:

Intermittent commit


diffs (94 lines):

diff --git a/sql/backends/monet5/iot/basket.c b/sql/backends/monet5/iot/basket.c
--- a/sql/backends/monet5/iot/basket.c
+++ b/sql/backends/monet5/iot/basket.c
@@ -35,7 +35,7 @@
 
 #define _DEBUG_BASKET_ if(0)
 
-str statusname[4] = { "", "active", "paused", "locked" };
+str statusname[4] = { "", "available", "wait", "locked" };
 
 BasketRec *baskets;   /* the global iot catalog */
 static int bsktTop = 0, bsktLimit = 0;
@@ -109,7 +109,7 @@ BSKTnewbasket(sql_schema *s, sql_table *
baskets[idx].table_name = GDKstrdup(t->base.name);
baskets[idx].seen = * timestamp_nil;
 
-   baskets[idx].status = BSKTPAUSED;
+   baskets[idx].status = BSKTWAIT;
baskets[idx].count = 0;
for (o = t->columns.set->h; o; o = o->next){
 sql_column *col = o->data;
@@ -205,7 +205,7 @@ BSKTactivate(Client cntxt, MalBlkPtr mb,
idx = BSKTlocate(sch, tbl);
if( idx == 0)
throw(SQL,"basket.activate","Stream table %s.%s not 
accessible to activate\n",sch,tbl);
-   if( baskets[idx].status == BSKTPAUSED){
+   if( baskets[idx].status == BSKTWAIT){
MT_lock_set();
baskets[idx].status = BSKTAVAILABLE;
MT_lock_unset();
@@ -237,13 +237,13 @@ BSKTdeactivate(Client cntxt, MalBlkPtr m
throw(SQL,"basket.activate","Stream table %s.%s not 
accessible to deactivate\n",sch,tbl);
if( baskets[idx].status == BSKTAVAILABLE ){
MT_lock_set();
-   baskets[idx].status = BSKTPAUSED;
+   baskets[idx].status = BSKTWAIT;
MT_lock_unset();
}
} else {
MT_lock_set();
for( idx =1; idx 

MonetDB: Jun2016 - Packaging errors and improvements.

2016-06-09 Thread Sjoerd Mullender
Changeset: 9fda1be9c35f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9fda1be9c35f
Modified Files:
MonetDB.spec
debian/control
Branch: Jun2016
Log Message:

Packaging errors and improvements.
Mtest.py is actually architecture-dependent (because of the
conditionals).
Add version checks to Debian/Ubuntu packages.


diffs (195 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -910,7 +910,6 @@ Group: Applications/Databases
 Requires: %{name}-testing = %{version}-%{release}
 Requires: %{name}-client-tests = %{version}-%{release}
 Requires: python
-BuildArch: noarch
 
 %description testing-python
 MonetDB is a database management system that is developed from a
diff --git a/debian/control b/debian/control
--- a/debian/control
+++ b/debian/control
@@ -19,6 +19,7 @@ X-Python3-Version: >= 3.0
 Package: libmonetdb13
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}
+Conflicts: libmonetdb5-server-geom (< ${source:Version})
 Description: MonetDB core library
  MonetDB is a database management system that is developed from a
  main-memory perspective with use of a fully decomposed storage model,
@@ -58,7 +59,8 @@ Description: MonetDB stream library
 
 Package: libmonetdb-stream-dev
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, libmonetdb-stream8
+Depends: ${shlibs:Depends}, ${misc:Depends},
+ libmonetdb-stream8 (= ${source:Version})
 Description: MonetDB stream library development files
  MonetDB is a database management system that is developed from a
  main-memory perspective with use of a fully decomposed storage model,
@@ -82,7 +84,8 @@ Description: MonetDB client/server inter
 
 Package: libmonetdb-client-dev
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, libmonetdb-client8
+Depends: ${shlibs:Depends}, ${misc:Depends},
+ libmonetdb-client8 (= ${source:Version})
 Description: MonetDB client/server interface library development files
  MonetDB is a database management system that is developed from a
  main-memory perspective with use of a fully decomposed storage model,
@@ -95,7 +98,7 @@ Description: MonetDB client/server inter
 Package: monetdb-client
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends}
-Recommends: monetdb5-sql
+Recommends: monetdb5-sql (= ${source:Version})
 Description: MonetDB database client
  MonetDB is a database management system that is developed from a
  main-memory perspective with use of a fully decomposed storage model,
@@ -109,7 +112,8 @@ Description: MonetDB database client
 
 Package: monetdb-client-tools
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, monetdb-client
+Depends: ${shlibs:Depends}, ${misc:Depends},
+ monetdb-client (= ${source:Version})
 Description: MonetDB database client
  MonetDB is a database management system that is developed from a
  main-memory perspective with use of a fully decomposed storage model,
@@ -143,7 +147,7 @@ Description: MonetDB php5 client module
  program.
 
 Package: perl-monetdb-client
-Architecture: any
+Architecture: all
 Depends: ${shlibs:Depends}, ${perl:Depends}, libdbi-perl
 Provides: ${perl:Provides}
 Description: MonetDB perl client code
@@ -157,7 +161,12 @@ Description: MonetDB perl client code
 
 Package: monetdb-client-testing
 Architecture: any
-Depends: ${shlibs:Depends}, libmonetdb-client-odbc, monetdb5-server, 
perl-monetdb-client, php5-monetdb-client, python-monetdb, monetdb5-sql
+Depends: ${shlibs:Depends}, libmonetdb-client-odbc (= ${source:Version}),
+ monetdb5-server (= ${source:Version}),
+ perl-monetdb-client (= ${source:Version}),
+ php5-monetdb-client (= ${source:Version}),
+ python-monetdb (= ${source:Version}),
+ monetdb5-sql (= ${source:Version})
 Description: MonetDB client testing tools
  MonetDB is a database management system that is developed from a
  main-memory perspective with use of a fully decomposed storage model,
@@ -171,7 +180,8 @@ Description: MonetDB client testing tool
 Package: libmonetdb5-server-geom
 Section: libs
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, monetdb5-sql
+Depends: ${shlibs:Depends}, ${misc:Depends},
+ monetdb5-sql (= ${source:Version})
 Description: MonetDB5 SQL GIS support module
  MonetDB is a database management system that is developed from a
  main-memory perspective with use of a fully decomposed storage model,
@@ -184,7 +194,8 @@ Description: MonetDB5 SQL GIS support mo
 Package: libmonetdb5-server-lidar
 Section: libs
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, monetdb5-sql
+Depends: ${shlibs:Depends}, ${misc:Depends},
+ monetdb5-sql (= ${source:Version})
 Description: MonetDB5 SQL GIS support module
  MonetDB is a database management system that is developed from a
  main-memory perspective with use of a fully decomposed storage model,
@@ -196,7 +207,8 @@ Description: MonetDB5 SQL GIS support mo
 Package: libmonetdb5-server-gsl
 Section: libs
 Architecture: any
-Depends: 

MonetDB: Jun2016 - Migrating code of class MonetVirtualResultSet...

2016-06-09 Thread Martin van Dinther
Changeset: 41e9202e4bde for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=41e9202e4bde
Modified Files:
java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
java/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
Branch: Jun2016
Log Message:

Migrating code of class MonetVirtualResultSet from MonetDatabaseMetaData.java 
to MonetResultSet.java.
For the Jun2016 release I have removed all usages of MonetVirtualResultSet from 
MonetDatabaseMetaData.java
so it does not make sense to keep in this file.
MonetVirtualResultSet is a subclass of MonetResultSet, so it is more logical to 
include it in that file.
Also added info on issues with this internal (not part of JDBC) class.


diffs (192 lines):

diff --git a/java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java 
b/java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
--- a/java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
+++ b/java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
@@ -4074,88 +4074,3 @@ public class MonetDatabaseMetaData exten
 
//== end methods interface DatabaseMetaData
 }
-
-/**
- * This class is not intended for normal use. Therefore it is restricted to
- * classes from the very same package only. Because it is mainly used
- * only in the MonetDatabaseMetaData class it is placed here.
- */
-class MonetVirtualResultSet extends MonetResultSet {
-   private String results[][];
-   private boolean closed;
-
-   MonetVirtualResultSet(
-   String[] columns,
-   String[] types,
-   String[][] results
-   ) throws IllegalArgumentException {
-   super(columns, types, results.length);
-
-   this.results = results;
-   closed = false;
-   }
-
-   /**
-* This method is overridden in order to let it use the results array
-* instead of the cache in the Statement object that created it.
-*
-* @param row the number of the row to which the cursor should move. A
-*positive number indicates the row number counting from the
-*beginning of the result set; a negative number indicates the 
row
-*number counting from the end of the result set
-* @return true if the cursor is on the result set; false otherwise
-* @throws SQLException if a database error occurs
-*/
-   @Override
-   public boolean absolute(int row) throws SQLException {
-   if (closed)
-   throw new SQLException("ResultSet is closed!", "M1M20");
-
-   // first calculate what the JDBC row is
-   if (row < 0) {
-   // calculate the negatives...
-   row = tupleCount + row + 1;
-   }
-   // now place the row not farther than just before or after the 
result
-   if (row < 0) row = 0;   // before first
-   else if (row > tupleCount + 1) row = tupleCount + 1;// 
after last
-
-   // store it
-   curRow = row;
-
-   // see if we have the row
-   if (row < 1 || row > tupleCount) return false;
-
-   for (int i = 0; i < results[row - 1].length; i++) {
-   tlp.values[i] = results[row - 1][i];
-   }
-
-   return true;
-   }
-
-   /**
-* Mainly here to prevent errors when the close method is called. There
-* is no real need for this object to close it. We simply remove our
-* resultset data.
-*/
-   @Override
-   public void close() {
-   if (!closed) {
-   closed = true;
-   results = null;
-   // types and columns are MonetResultSets private parts
-   }
-   }
-
-   /**
-* Retrieves the fetch size for this ResultSet object, which will be
-* zero, since it's a virtual set.
-*
-* @return the current fetch size for this ResultSet object
-* @throws SQLException if a database access error occurs
-*/
-   @Override
-   public int getFetchSize() throws SQLException {
-   return 0;
-   }
-}
diff --git a/java/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java 
b/java/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
--- a/java/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
+++ b/java/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
@@ -3435,3 +3435,96 @@ public class MonetResultSet extends Mone
return new SQLFeatureNotSupportedException("Method " + name + " 
not implemented", "0A000");
}
 }
+
+/**
+ * This internal subclass is not intended for normal use. Therefore it is 
restricted to
+ * classes from the very same package only.
+ *
+ * Known issues with this class: some methods of the ResultSetMetaData object 

MonetDB: Jun2016 - Prevent out-of-bounds array access.

2016-06-09 Thread Sjoerd Mullender
Changeset: 36cea9050e68 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=36cea9050e68
Modified Files:
sql/backends/monet5/sql_round_impl.h
Branch: Jun2016
Log Message:

Prevent out-of-bounds array access.


diffs (12 lines):

diff --git a/sql/backends/monet5/sql_round_impl.h 
b/sql/backends/monet5/sql_round_impl.h
--- a/sql/backends/monet5/sql_round_impl.h
+++ b/sql/backends/monet5/sql_round_impl.h
@@ -296,6 +296,8 @@ str_2dec(TYPE *res, const str *val, cons
}
if (digits < 0)
throw(SQL, STRING(TYPE), "decimal (%s) doesn't have format 
(%d.%d)", *val, *d, *sc);
+   if (*d < 0 || *d >= (int) (sizeof(scales) / sizeof(scales[0])))
+   throw(SQL, STRING(TYPE), "decimal (%s) doesn't have format 
(%d.%d)", *val, *d, *sc);
 
value = decimal_from_str(s, );
if (*s == '+' || *s == '-')
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2016 - Typos.

2016-06-09 Thread Sjoerd Mullender
Changeset: 221e2a9d7e59 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=221e2a9d7e59
Modified Files:
MonetDB.spec
debian/changelog
monetdb5/ChangeLog-Archive
Branch: Jun2016
Log Message:

Typos.


diffs (45 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -695,7 +695,7 @@ fi
 %if %{bits} == 64
 %package -n MonetDB5-server-hugeint
 Summary: MonetDB - 128-bit integer support for MonetDB5-server
-Group: Application/Databases
+Group: Applications/Databases
 Requires: MonetDB5-server%{?_isa}
 
 %description -n MonetDB5-server-hugeint
@@ -1276,7 +1276,7 @@ rm -f %{buildroot}%{_bindir}/Maddlog
 - gdk: Removed all versions of the SORTloop macro.
 
 * Tue Apr  5 2016 Sjoerd Mullender  - 11.23.1-20160601
-- monetdb5: Removed algerbra.like with a BAT argument.  Use 
algebra.likesubselect
+- monetdb5: Removed algebra.like with a BAT argument.  Use 
algebra.likesubselect
   instead.
 
 * Tue Apr  5 2016 Sjoerd Mullender  - 11.23.1-20160601
diff --git a/debian/changelog b/debian/changelog
--- a/debian/changelog
+++ b/debian/changelog
@@ -382,7 +382,7 @@ monetdb (11.23.1) unstable; urgency=low
 
 monetdb (11.23.1) unstable; urgency=low
 
-  * monetdb5: Removed algerbra.like with a BAT argument.  Use 
algebra.likesubselect
+  * monetdb5: Removed algebra.like with a BAT argument.  Use 
algebra.likesubselect
 instead.
 
  -- Sjoerd Mullender   Tue, 5 Apr 2016 16:10:50 +0200
diff --git a/monetdb5/ChangeLog-Archive b/monetdb5/ChangeLog-Archive
--- a/monetdb5/ChangeLog-Archive
+++ b/monetdb5/ChangeLog-Archive
@@ -44,7 +44,7 @@
   always in UTF-8 encoding, so we can't allow code set conversions.
 
 * Wed Oct  7 2015 Sjoerd Mullender  - 11.23.1-20160601
-- Removed algerbra.like with a BAT argument.  Use algebra.likesubselect
+- Removed algebra.like with a BAT argument.  Use algebra.likesubselect
   instead.
 
 * Wed Sep 16 2015 Sjoerd Mullender  - 11.23.1-20160601
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2016 - Fix a bunch of leaks.

2016-06-09 Thread Sjoerd Mullender
Changeset: 5ac970b567e4 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5ac970b567e4
Modified Files:
sql/server/rel_dump.c
sql/server/rel_prop.c
sql/server/rel_psm.c
sql/storage/bat/bat_logger.c
Branch: Jun2016
Log Message:

Fix a bunch of leaks.


diffs (155 lines):

diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c
--- a/sql/server/rel_dump.c
+++ b/sql/server/rel_dump.c
@@ -212,9 +212,13 @@ exp_print(mvc *sql, stream *fout, sql_ex
mnstr_printf(fout, " NOT NULL");
if (e->p) {
prop *p = e->p;
+   char *pv;
 
-   for (; p; p = p->p) 
-   mnstr_printf(fout, " %s %s", propkind2string(p), 
propvalue2string(p));
+   for (; p; p = p->p) {
+   pv = propvalue2string(p);
+   mnstr_printf(fout, " %s %s", propkind2string(p), pv);
+   GDKfree(pv);
+   }
}
if (e->name && alias) {
mnstr_printf(fout, " as ");
@@ -502,9 +506,13 @@ rel_print_(mvc *sql, stream  *fout, sql_
}
if (rel->p) {
prop *p = rel->p;
+   char *pv;
 
-   for (; p; p = p->p) 
-   mnstr_printf(fout, " %s %s", propkind2string(p), 
propvalue2string(p));
+   for (; p; p = p->p) {
+   pv = propvalue2string(p);
+   mnstr_printf(fout, " %s %s", propkind2string(p), pv);
+   GDKfree(pv);
+   }
}
 }
 
diff --git a/sql/server/rel_prop.c b/sql/server/rel_prop.c
--- a/sql/server/rel_prop.c
+++ b/sql/server/rel_prop.c
@@ -99,5 +99,5 @@ propvalue2string( prop *p)
break;
}
}
-   return "";
+   return _STRDUP("");
 }
diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c
--- a/sql/server/rel_psm.c
+++ b/sql/server/rel_psm.c
@@ -725,8 +725,10 @@ rel_create_func(mvc *sql, dlist *qname, 
char *tpe =  subtype2string((sql_subtype *) 
n->data);

if (arg_list) {
+   char *t = arg_list;
arg_list = sql_message("%s, %s", 
arg_list, tpe);
-   _DELETE(tpe);   
+   _DELETE(t);
+   _DELETE(tpe);
} else {
arg_list = tpe;
}
@@ -911,19 +913,24 @@ resolve_func( mvc *sql, sql_schema *s, c
node *n;

if (type_list->cnt > 0) {
+   void *e;
for (n = type_list->h; n; n = n->next) {
char *tpe =  
subtype2string((sql_subtype *) n->data);

if (arg_list) {
+   char *t = arg_list;
arg_list = sql_message("%s, 
%s", arg_list, tpe);
-   _DELETE(tpe);   
+   _DELETE(tpe);
+   _DELETE(t);
} else {
arg_list = tpe;
}
}
list_destroy(list_func);
list_destroy(type_list);
-   return sql_error(sql, 02, "%s %s%s: no such 
%s%s '%s' (%s)", op, KF, F, kf, f, name, arg_list);
+   e = sql_error(sql, 02, "%s %s%s: no such %s%s 
'%s' (%s)", op, KF, F, kf, f, name, arg_list);
+   _DELETE(arg_list);
+   return e;
}
list_destroy(list_func);
list_destroy(type_list);
diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c
--- a/sql/storage/bat/bat_logger.c
+++ b/sql/storage/bat/bat_logger.c
@@ -211,37 +211,39 @@ bl_postversion( void *lg)
b = BATdescriptor((bat) logger_find_bat(lg, N(n, NULL, s, 
"types_systemname")));
bi = bat_iterator(b);
for (p=BUNfirst(b), q=BUNlast(b); p

MonetDB: iot - Merge with default

2016-06-09 Thread Martin Kersten
Changeset: 7677206ca543 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7677206ca543
Added Files:
clients/R/Tests/copy_into_fwf.R
clients/R/Tests/copy_into_fwf.reqtests
clients/R/Tests/copy_into_fwf.stable.err
clients/R/Tests/copy_into_fwf.stable.out
Modified Files:
clients/R/Tests/All
clients/R/Tests/dbi.R
clients/R/Tests/deps-test.R
clients/Tests/SQL-dump.stable.out
clients/Tests/SQL-dump.stable.out.int128
clients/Tests/exports.stable.out
common/stream/stream.c
common/stream/stream.h
monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out
sql/backends/monet5/Makefile.ag
sql/backends/monet5/sql.c
sql/common/sql_list.c
sql/common/sql_types.c
sql/include/sql_list.h
sql/server/rel_optimizer.c
sql/server/rel_updates.c
sql/server/sql_parser.y
sql/server/sql_scan.c
sql/test/BugTracker-2009/Tests/copy_multiple_files.SF-2902320.stable.out

sql/test/BugTracker-2009/Tests/segfault_when_quitting_debugger.SF-2538837.stable.out
sql/test/Tests/systemfunctions.stable.out
sql/test/Tests/systemfunctions.stable.out.int128
sql/test/leaks/Tests/check1.stable.out.int128
sql/test/leaks/Tests/check2.stable.out.int128
sql/test/leaks/Tests/check3.stable.out.int128
sql/test/leaks/Tests/check4.stable.out.int128
sql/test/leaks/Tests/check5.stable.out.int128
Branch: iot
Log Message:

Merge with default


diffs (truncated from 931 to 300 lines):

diff --git a/clients/R/Tests/All b/clients/R/Tests/All
--- a/clients/R/Tests/All
+++ b/clients/R/Tests/All
@@ -4,4 +4,5 @@ HAVE_LIBR?deps-test
 HAVE_LIBR?dbi
 HAVE_LIBR?dplyr
 HAVE_LIBR?dplyr-flights
+HAVE_LIBR?copy_into_fwf
 HAVE_LIBR_WIN32?dbapply
diff --git a/clients/R/Tests/copy_into_fwf.R b/clients/R/Tests/copy_into_fwf.R
new file mode 100644
--- /dev/null
+++ b/clients/R/Tests/copy_into_fwf.R
@@ -0,0 +1,35 @@
+if (Sys.getenv("TSTTRGDIR") != "") {
+   .libPaths(c(.libPaths(), paste0(Sys.getenv("TSTTRGDIR"),"/rlibdir")))
+}
+library(DBI, quietly = T)
+
+args <- commandArgs(trailingOnly = TRUE)
+dbport <- 5
+dbname <- "mTests_clients_R"
+if (length(args) > 0) 
+   dbport <- args[[1]]
+if (length(args) > 1) 
+   dbname <- args[[2]]
+
+con <- dbConnect(MonetDBLite::MonetDB(), port = dbport, dbname = dbname, wait 
= T)
+stopifnot(dbIsValid(con))
+
+tf <- tempfile()
+
+gdata::write.fwf(mtcars, tf, colnames = FALSE)
+
+if (dbExistsTable(con, "mtcars")) dbRemoveTable(con, "mtcars")
+
+dbBegin(con)
+dbSendQuery(con, "CREATE TABLE mtcars (mpg DOUBLE PRECISION, cyl DOUBLE 
PRECISION, disp DOUBLE PRECISION, hp DOUBLE PRECISION, drat DOUBLE PRECISION, 
wt DOUBLE PRECISION, qsec DOUBLE PRECISION, vs DOUBLE PRECISION, am DOUBLE 
PRECISION, gear DOUBLE PRECISION, carb DOUBLE PRECISION)")
+
+# delimiters are ineffective for fwf import just set them to make sure they 
dont break stuff
+res <- dbSendQuery(con, paste0("COPY OFFSET 1 INTO mtcars FROM '", tf, "' 
USING DELIMITERS 'a','b','c' NULL AS '' FWF (4, 2, 6, 4, 5, 6, 6, 2, 2, 2, 2)"))
+
+print(dbReadTable(con, "mtcars"))
+
+stopifnot(nrow(dbReadTable(con, "mtcars")) > 1)
+
+dbRollback(con)
+
+print("SUCCESS")
diff --git a/clients/R/Tests/copy_into_fwf.reqtests 
b/clients/R/Tests/copy_into_fwf.reqtests
new file mode 100644
--- /dev/null
+++ b/clients/R/Tests/copy_into_fwf.reqtests
@@ -0,0 +1,1 @@
+dbi
diff --git a/clients/R/Tests/copy_into_fwf.stable.err 
b/clients/R/Tests/copy_into_fwf.stable.err
new file mode 100644
--- /dev/null
+++ b/clients/R/Tests/copy_into_fwf.stable.err
@@ -0,0 +1,35 @@
+stderr of test 'copy_into_fwf` in directory 'clients/R` itself:
+
+
+# 16:40:22 >  
+# 16:40:22 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=30658" "--set" 
"mapi_usock=/var/tmp/mtest-16034/.s.monetdb.30658" "--set" "monet_prompt=" 
"--forcemito" "--dbpath=/tmp/fuckit/var/MonetDB/mTests_clients_R" "--set" 
"embedded_r=yes"
+# 16:40:22 >  
+
+# builtin opt  gdk_dbpath = /tmp/fuckit/var/monetdb5/dbfarm/demo
+# builtin opt  gdk_debug = 0
+# builtin opt  gdk_vmtrim = no
+# builtin opt  monet_prompt = >
+# builtin opt  monet_daemon = no
+# builtin opt  mapi_port = 5
+# builtin opt  mapi_open = false
+# builtin opt  mapi_autosense = false
+# builtin opt  sql_optimizer = default_pipe
+# builtin opt  sql_debug = 0
+# cmdline opt  gdk_nr_threads = 0
+# cmdline opt  mapi_open = true
+# cmdline opt  mapi_port = 30658
+# cmdline opt  mapi_usock = /var/tmp/mtest-16034/.s.monetdb.30658
+# cmdline opt  monet_prompt = 
+# cmdline opt  gdk_dbpath = /tmp/fuckit/var/MonetDB/mTests_clients_R
+# cmdline opt  embedded_r = yes
+# cmdline opt  gdk_debug = 536870922
+
+# 16:40:23 >  
+# 16:40:23 >  "R" "--vanilla" "--slave" "--args" "30658"
+# 16:40:23 >  
+
+
+# 16:40:23 >  
+# 16:40:23 >  "Done."
+# 16:40:23 >  
+
diff --git 

MonetDB: iot - Intermittent commit

2016-06-09 Thread Martin Kersten
Changeset: 8e15764fb0ef for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8e15764fb0ef
Modified Files:
sql/backends/monet5/iot/50_iot.sql
sql/backends/monet5/iot/Tests/All
sql/backends/monet5/iot/Tests/iot00.sql
sql/backends/monet5/iot/Tests/iot01.sql
sql/backends/monet5/iot/Tests/petrinet00.mal
sql/backends/monet5/iot/basket.c
sql/backends/monet5/iot/basket.h
sql/backends/monet5/iot/basket.mal
sql/backends/monet5/iot/iot.c
sql/backends/monet5/iot/iot.h
sql/backends/monet5/iot/petrinet.c
sql/backends/monet5/iot/petrinet.h
sql/backends/monet5/iot/petrinet.mal
Branch: iot
Log Message:

Intermittent commit


diffs (291 lines):

diff --git a/sql/backends/monet5/iot/50_iot.sql 
b/sql/backends/monet5/iot/50_iot.sql
--- a/sql/backends/monet5/iot/50_iot.sql
+++ b/sql/backends/monet5/iot/50_iot.sql
@@ -81,6 +81,8 @@ create procedure iot.window("schema" str
 create procedure iot.window("schema" string, "table" string, elem int, slide 
int)
external name iot.window;
 
+create procedure iot.wait() external name iot.wait;
+
 -- Inspection tables
 create function iot.baskets()
 returns table( "schema" string, "table" string, "status" string, threshold 
int, winsize int, winstride int, timeslice int, timestride int, beat int, seen 
timestamp, events int)
diff --git a/sql/backends/monet5/iot/Tests/All 
b/sql/backends/monet5/iot/Tests/All
--- a/sql/backends/monet5/iot/Tests/All
+++ b/sql/backends/monet5/iot/Tests/All
@@ -2,7 +2,12 @@ iot00
 iot01
 iot02
 iot03
+#iot05
+iot10
+iot12
+iot15
+receptor00
 receptor01
-cleaup
-petrinet00
+cleanup
+#petrinet00
 webtest
diff --git a/sql/backends/monet5/iot/Tests/iot00.sql 
b/sql/backends/monet5/iot/Tests/iot00.sql
--- a/sql/backends/monet5/iot/Tests/iot00.sql
+++ b/sql/backends/monet5/iot/Tests/iot00.sql
@@ -20,6 +20,7 @@ select * from  iot.outputplaces();
 
 -- stop all continuous queries
 call iot.deactivate();
+call iot.wait();
 
 insert into stmp values('2005-09-23 12:34:26.736',1,12.34);
 select * from stmp;
diff --git a/sql/backends/monet5/iot/Tests/iot01.sql 
b/sql/backends/monet5/iot/Tests/iot01.sql
--- a/sql/backends/monet5/iot/Tests/iot01.sql
+++ b/sql/backends/monet5/iot/Tests/iot01.sql
@@ -14,7 +14,12 @@ insert into stmp values('2005-09-23 12:3
 insert into stmp values('2005-09-23 12:34:27.000',1,12.0);
 insert into stmp values('2005-09-23 12:34:28.000',1,13.0);
 
+-- deactivate all when streams are empty.
+call iot.deactivate();
+
+-- stream table should be empty now
 select * from stmp;
+-- and result delivered
 select * from result;
 
 select * from  iot.queries();
diff --git a/sql/backends/monet5/iot/Tests/petrinet00.mal 
b/sql/backends/monet5/iot/Tests/petrinet00.mal
--- a/sql/backends/monet5/iot/Tests/petrinet00.mal
+++ b/sql/backends/monet5/iot/Tests/petrinet00.mal
@@ -5,5 +5,5 @@ end hello;
 
 petrinet.register("user","hello");
 
-(mod:bat[:str],fcn:bat[:str], 
status:bat[:str],lastrun:bat[:timestamp],cycles:bat[:int], 
events:bat[:int],time:bat[:lng],error:bat[:str]):= petrinet.queries();
+(mod:bat[:str],fcn:bat[:str], 
status:bat[:str],lastrun:bat[:timestamp],cycles:bat[:int], 
events:bat[:int],time:bat[:lng],error:bat[:str]):= iot.queries();
 io.print(mod,fcn, status,lastrun,cycles, events,time,error);
diff --git a/sql/backends/monet5/iot/basket.c b/sql/backends/monet5/iot/basket.c
--- a/sql/backends/monet5/iot/basket.c
+++ b/sql/backends/monet5/iot/basket.c
@@ -399,13 +399,9 @@ BSKTreset(void *ret)
 
 /* collect the binary files and append them to what we have */
 #define MAXLINE 4096
-str 
-BSKTpushBasket(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+str
+BSKTimportInternal(int bskt)
 {
-str sch = *getArgReference_str(stk, pci, 1);
-str tbl = *getArgReference_str(stk, pci, 2);
-str dir = *getArgReference_str(stk, pci, 3);
-int bskt;
char buf[PATHLENGTH];
node *n;
mvc *m = NULL;
@@ -416,14 +412,7 @@ BSKTpushBasket(Client cntxt, MalBlkPtr m
FILE *f;
long fsize;
char line[MAXLINE];
-
-   msg= getSQLContext(cntxt,NULL, , NULL);
-   if( msg != MAL_SUCCEED)
-   return msg;
-   BSKTregisterInternal(cntxt, mb, sch, tbl);
-bskt = BSKTlocate(sch,tbl);
-   if (bskt == 0)
-   throw(SQL, "iot.basket", "Could not find the basket 
%s.%s",sch,tbl);
+   str dir = baskets[bskt].source;
 
// check access permission to directory first
if( access (dir , F_OK | R_OK)){
@@ -538,10 +527,30 @@ recover:
}
 
MT_lock_unset();
-(void) mb;
 return msg;
 }
 
+str 
+BSKTimport(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+str sch = *getArgReference_str(stk, pci, 1);
+str tbl = *getArgReference_str(stk, pci, 2);
+str dir = *getArgReference_str(stk, pci, 3);
+int bskt;
+   str msg= MAL_SUCCEED;
+   mvc *m = NULL;
+
+   msg= getSQLContext(cntxt,NULL, ,