MonetDB: default - Merged with oscar

2020-08-11 Thread Pedro Ferreira
Changeset: deb4101c08a4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=deb4101c08a4
Branch: default
Log Message:

Merged with oscar


diffs (158 lines):

diff --git a/sql/backends/monet5/sql_statistics.c 
b/sql/backends/monet5/sql_statistics.c
--- a/sql/backends/monet5/sql_statistics.c
+++ b/sql/backends/monet5/sql_statistics.c
@@ -34,9 +34,7 @@ sql_drop_statistics(mvc *m, sql_table *t
tr = m->session->tr;
sys = mvc_bind_schema(m, "sys");
if (sys == NULL)
-   throw(SQL, "sql_drop_statistics", SQLSTATE(3F000) "Internal 
error");
-   if (!mvc_schema_privs(m, sys))
-   throw(SQL, "sql.sql_drop_statistics", SQLSTATE(42000) "Access 
denied for %s to schema '%s'", sqlvar_get_string(find_global_var(m, 
mvc_bind_schema(m, "sys"), "current_user")), sys->base.name);
+   throw(SQL, "sql_drop_statistics", SQLSTATE(3F000) "Internal 
error: No schema sys");
sysstats = mvc_bind_table(m, sys, "statistics");
if (sysstats == NULL)
throw(SQL, "sql_drop_statistics", SQLSTATE(3F000) "No table 
sys.statistics");
@@ -44,6 +42,22 @@ sql_drop_statistics(mvc *m, sql_table *t
if (statsid == NULL)
throw(SQL, "sql_drop_statistics", SQLSTATE(3F000) "No table 
sys.statistics");
 
+   /* Do all the validations before any drop */
+   if (!isTable(t))
+   throw(SQL, "sql_drop_statistics", SQLSTATE(42S02) "DROP 
STATISTICS: %s '%s' is not persistent", TABLE_TYPE_DESCRIPTION(t->type, 
t->properties), t->base.name);
+   if (!table_privs(m, t, PRIV_SELECT))
+   throw(SQL, "sql_drop_statistics", SQLSTATE(42000) "DROP 
STATISTICS: access denied for %s to table '%s.%s'", 
+ sqlvar_get_string(find_global_var(m, 
mvc_bind_schema(m, "sys"), "current_user")), t->s->base.name, t->base.name);
+   if (isTable(t) && t->columns.set) {
+   for (ncol = (t)->columns.set->h; ncol; ncol = ncol->next) {
+   sql_column *c = (sql_column *) ncol->data;
+
+   if (!column_privs(m, c, PRIV_SELECT))
+   throw(SQL, "sql_drop_statistics", 
SQLSTATE(42000) "DROP STATISTICS: access denied for %s to column '%s' on table 
'%s.%s'", 
+ sqlvar_get_string(find_global_var(m, 
mvc_bind_schema(m, "sys"), "current_user")), c->base.name, t->s->base.name, 
t->base.name);
+   }
+   }
+
if (isTable(t) && t->columns.set) {
for (ncol = (t)->columns.set->h; ncol; ncol = ncol->next) {
sql_column *c = ncol->data;
@@ -51,7 +65,7 @@ sql_drop_statistics(mvc *m, sql_table *t
rid = table_funcs.column_find_row(tr, statsid, 
>base.id, NULL);
if (!is_oid_nil(rid) &&
table_funcs.table_delete(tr, sysstats, rid) != 
LOG_OK)
-   throw(SQL, "analyze", "delete failed");
+   throw(SQL, "sql_drop_statistics", "delete 
failed");
}
}
return MAL_SUCCEED;
@@ -87,8 +101,6 @@ sql_analyze(Client cntxt, MalBlkPtr mb, 
sys = mvc_bind_schema(m, "sys");
if (sys == NULL)
throw(SQL, "sql.analyze", SQLSTATE(3F000) "Internal error: No 
schema sys");
-   if (!mvc_schema_privs(m, sys))
-   throw(SQL, "sql.analyze", SQLSTATE(42000) "Access denied for %s 
to schema '%s'", sqlvar_get_string(find_global_var(m, mvc_bind_schema(m, 
"sys"), "current_user")), sys->base.name);
sysstats = mvc_bind_table(m, sys, "statistics");
if (sysstats == NULL)
throw(SQL, "sql.analyze", SQLSTATE(3F000) "Internal error: No 
table sys.statistics");
@@ -109,6 +121,48 @@ sql_analyze(Client cntxt, MalBlkPtr mb, 
 
TRC_DEBUG(SQL_PARSER, "analyze %s.%s.%s sample " LLFMT "%s\n", (sch ? 
sch : ""), (tbl ? tbl : " "), (col ? col : " "), samplesize, 
(minmax)?"MinMax":"");
 
+   /* Do all the validations before doing any analyze */
+   for (nsch = tr->schemas.set->h; nsch; nsch = nsch->next) {
+   sql_schema *s = (sql_schema *) nsch->data;
+   if (!isalpha((unsigned char) s->base.name[0]))
+   continue;
+
+   if (sch && strcmp(s->base.name, sch))
+   continue;
+   sfnd = 1;
+   if (s->tables.set)
+   for (ntab = (s)->tables.set->h; ntab; ntab = 
ntab->next) {
+   sql_table *t = (sql_table *) ntab->data;
+
+   if (tbl && strcmp(t->base.name, tbl))
+   continue;
+   tfnd = 1;
+   if (tbl && !isTable(t))
+   throw(SQL, "analyze", SQLSTATE(42S02) 
"%s '%s' is not persistent", TABLE_TYPE_DESCRIPTION(t->type, 

MonetDB: default - Merged with oscar

2020-08-06 Thread Pedro Ferreira
Changeset: 7cd0cc386025 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7cd0cc386025
Modified Files:
gdk/gdk_select.c
sql/server/rel_select.c

sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.stable.out
sql/test/miscellaneous/Tests/simple_selects.stable.out
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 435 to 300 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -111,7 +111,7 @@ BuildRequires: checkpolicy
 BuildRequires: selinux-policy-devel
 BuildRequires: hardlink
 %endif
-BuildRequires: cmake >= 3.12
+BuildRequires: cmake3 >= 3.12
 BuildRequires: gcc
 BuildRequires: bison
 BuildRequires: /usr/bin/python3
@@ -605,7 +605,7 @@ use SQL with MonetDB, you will need to i
 %config(noreplace) %attr(664,monetdb,monetdb) 
%{_localstatedir}/monetdb5/dbfarm/.merovingian_properties
 %verify(not mtime) %attr(664,monetdb,monetdb) 
%{_localstatedir}/monetdb5/dbfarm/.merovingian_lock
 %config(noreplace) %attr(644,root,root) %{_sysconfdir}/logrotate.d/monetdbd
-%{_libdir}/monetdb5/lib_sql.so*
+%{_libdir}/libmonetdbsql.so*
 %doc %{_mandir}/man1/monetdb.1.gz
 %doc %{_mandir}/man1/monetdbd.1.gz
 %dir %{_datadir}/doc/MonetDB-SQL
@@ -762,7 +762,7 @@ fi
 %setup -q
 
 %build
-%{cmake} \
+%cmake3 \
-DASSERT=OFF \
-DCINTEGRATION=%{?with_cintegration:ON}%{!?with_cintegration:OFF} \
-DFITS=%{?with_fits:ON}%{!?with_fits:OFF} \
@@ -791,7 +791,7 @@ fi
-DWITH_XML2=ON \
-DWITH_ZLIB=ON
 
-%cmake_build
+%cmake3_build
 
 %if %{?rhel:0}%{!?rhel:1} || 0%{?rhel} >= 7
 cd buildtools/selinux
@@ -810,7 +810,7 @@ cd -
 %endif
 
 %install
-%cmake_install
+%cmake3_install
 
 # move file to correct location
 %if %{?rhel:0}%{!?rhel:1} || 0%{?rhel} >= 7
diff --git a/NT/mksqlwxs.py b/NT/mksqlwxs.py
--- a/NT/mksqlwxs.py
+++ b/NT/mksqlwxs.py
@@ -124,9 +124,10 @@ def main():
   [r'bin\mclient.exe',
r'bin\mserver5.exe',
r'bin\msqldump.exe',
-   r'bin\gdk.dll',
+   r'bin\bat.dll',
r'bin\mapi.dll',
r'bin\monetdb5.dll',
+   r'bin\monetdbsql.dll',
r'bin\stream.dll',
vcpkg.format(r'bin\libiconv.dll'),
vcpkg.format(r'bin\bz2.dll'),
@@ -166,18 +167,19 @@ def main():
 id = comp(features, id, 16,
   [r'lib\monetdb5\microbenchmark.mal'])
 id = comp(features, id, 16,
-  [r'lib\monetdb5\{}'.format(x) for x in sorted(filter(lambda x: 
x.startswith('lib_') and x.endswith('.dll') and ('geom' not in x) and ('pyapi' 
not in x) and ('opt_sql_append' not in x), os.listdir(os.path.join(sys.argv[3], 
'lib', 'monetdb5'])
+  [r'lib\monetdb5\{}'.format(x) for x in sorted(filter(lambda x: 
x.startswith('_') and x.endswith('.dll') and ('geom' not in x) and ('pyapi' not 
in x) and ('opt_sql_append' not in x), os.listdir(os.path.join(sys.argv[3], 
'lib', 'monetdb5'])
 id = comp(debug, id, 16,
-  [r'lib\monetdb5\{}'.format(x) for x in sorted(filter(lambda x: 
x.startswith('lib_') and x.endswith('.pdb') and ('geom' not in x) and 
('opt_sql_append' not in x), os.listdir(os.path.join(sys.argv[3], 'lib', 
'monetdb5'])
+  [r'lib\monetdb5\{}'.format(x) for x in sorted(filter(lambda x: 
x.startswith('_') and x.endswith('.pdb') and ('geom' not in x) and 
('opt_sql_append' not in x), os.listdir(os.path.join(sys.argv[3], 'lib', 
'monetdb5'])
 id = comp(geom, id, 16,
-  [r'lib\monetdb5\{}'.format(x) for x in sorted(filter(lambda x: 
x.startswith('lib_') and (x.endswith('.dll') or x.endswith('.pdb')) and ('geom' 
in x), os.listdir(os.path.join(sys.argv[3], 'lib', 'monetdb5'])
+  [r'lib\monetdb5\{}'.format(x) for x in sorted(filter(lambda x: 
x.startswith('_') and (x.endswith('.dll') or x.endswith('.pdb')) and ('geom' in 
x), os.listdir(os.path.join(sys.argv[3], 'lib', 'monetdb5'])
 id = comp(pyapi3, id, 16,
   [r'lib\monetdb5\_pyapi3.dll'])
 print(r'  ')
 id = comp(extend, id, 14,
-  [r'lib\gdk.lib',
+  [r'lib\bat.lib',
r'lib\mapi.lib',
r'lib\monetdb5.lib',
+   r'lib\monetdbsql.lib',
r'lib\stream.lib',
vcpkg.format(r'lib\libiconv.lib'),
vcpkg.format(r'lib\bz2.lib'),
diff --git a/debian/control b/debian/control
--- a/debian/control
+++ b/debian/control
@@ -5,11 +5,10 @@ Maintainer: MonetDB BV https://www.monetdb.org/
 Vcs-Browser: https://dev.monetdb.org/hg/MonetDB/
 Vcs-Hg: https://dev.monetdb.org/hg/MonetDB/
-Build-Depends: debhelper (>= 9), cmake, bison,
+Build-Depends: debhelper (>= 9), cmake (>= 3.12), bison,
  libbz2-dev, libcurl4-gnutls-dev, libgeos-dev (>= 3.4.0),
  libpcre3-dev, libreadline-dev, liblzma-dev,
  libssl-dev, libxml2-dev, pkg-config,
- python, python-dev, 

MonetDB: default - Merged with oscar

2020-08-03 Thread Pedro Ferreira
Changeset: e5df861c73d3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e5df861c73d3
Modified Files:
sql/common/CMakeLists.txt
sql/include/CMakeLists.txt
tools/mserver/CMakeLists.txt
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 1089 to 300 lines):

diff --git a/misc/packages/rpm/COPYING b/COPYING
rename from misc/packages/rpm/COPYING
rename to COPYING
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -65,6 +65,9 @@
 # operators.  Otherwise the POSIX regex functions are used.
 %bcond_without pcre
 
+# By default, include C integration
+%bcond_without cintegration
+
 %if %{fedpkgs}
 # By default, create the MonetDB-R package.
 %bcond_without rintegration
@@ -108,6 +111,7 @@ BuildRequires: checkpolicy
 BuildRequires: selinux-policy-devel
 BuildRequires: hardlink
 %endif
+BuildRequires: cmake >= 3.12
 BuildRequires: gcc
 BuildRequires: bison
 BuildRequires: /usr/bin/python3
@@ -187,6 +191,7 @@ functionality of MonetDB.
 %{_includedir}/monetdb/gdk*.h
 %{_includedir}/monetdb/matomic.h
 %{_includedir}/monetdb/mstring.h
+%exclude %{_includedir}/monetdb/monetdbe.h
 %{_includedir}/monetdb/monet*.h
 %{_libdir}/libbat.so
 %{_libdir}/pkgconfig/monetdb-gdk.pc
@@ -462,7 +467,6 @@ Provides: MonetDB5-server-hugeint%{?_isa
 %endif
 %if (0%{?fedora} >= 22)
 Recommends: %{name}-SQL-server5%{?_isa} = %{version}-%{release}
-%endif
 Suggests: %{name}-client%{?_isa} = %{version}-%{release}
 %endif
 # versions up to 1.0.5 don't accept the queryid field in the result set
@@ -515,7 +519,10 @@ exit 0
 %{_libdir}/libmonetdb5.so.*
 %dir %{_libdir}/monetdb5
 %{_libdir}/monetdb5/microbenchmark.mal
+%{_libdir}/monetdb5/run_*.mal
+%if %{with cintegration}
 %{_libdir}/monetdb5/lib_capi.so
+%endif
 %{_libdir}/monetdb5/lib_generator.so
 %{_libdir}/monetdb5/lib_udf.so
 %doc %{_mandir}/man1/mserver5.1.gz
@@ -599,13 +606,46 @@ use SQL with MonetDB, you will need to i
 %config(noreplace) %attr(664,monetdb,monetdb) 
%{_localstatedir}/monetdb5/dbfarm/.merovingian_properties
 %verify(not mtime) %attr(664,monetdb,monetdb) 
%{_localstatedir}/monetdb5/dbfarm/.merovingian_lock
 %config(noreplace) %attr(644,root,root) %{_sysconfdir}/logrotate.d/monetdbd
-%{_libdir}/monetdb5/lib_sql.so
+%{_libdir}/monetdb5/lib_sql.so*
 %doc %{_mandir}/man1/monetdb.1.gz
 %doc %{_mandir}/man1/monetdbd.1.gz
 %dir %{_datadir}/doc/MonetDB-SQL
 %docdir %{_datadir}/doc/MonetDB-SQL
 %{_datadir}/doc/MonetDB-SQL/*
 
+%package embedded
+Summary: MonetDB as an embedded library
+Group: Applications/Databases
+
+%description embedded
+MonetDB is a database management system that is developed from a
+main-memory perspective with use of a fully decomposed storage model,
+automatic index management, extensibility of data types and search
+accelerators.  It also has an SQL front end.
+
+This package contains the library to turn MonetDB into an embeddable
+library.  Also see %{name}-embedded-devel to use this in a program.
+
+%files embedded
+%{_libdir}/libmonetdbe.so.*
+
+%package embedded-devel
+Summary: MonetDB as an embedded library development files
+Group: Applications/Databases
+
+%description embedded-devel
+MonetDB is a database management system that is developed from a
+main-memory perspective with use of a fully decomposed storage model,
+automatic index management, extensibility of data types and search
+accelerators.  It also has an SQL front end.
+
+This package contains the library and include files to turn MonetDB
+into an embeddable library.
+
+%files embedded-devel
+%{_libdir}/libmonetdbe.so
+%{_includedir}/monetdb/monetdbe.h
+
 %package testing
 Summary: MonetDB - Monet Database Management System
 Group: Applications/Databases
@@ -719,66 +759,36 @@ fi
 %setup -q
 
 %build
-
-# There is a bug in GCC version 4.8 on AArch64 architectures
-# that causes it to report an internal error when compiling
-# testing/difflib.c.  The work around is to not use -fstack-protector-strong.
-# The bug exhibits itself on CentOS 7 on AArch64.
-# Everywhere else, add -Wno-format-truncation to the compiler options
-# to reduce the number of warnings during compilation.
-%ifarch aarch64
-if gcc -v 2>&1 | grep -q 'gcc version 4\.'; then
-   CFLAGS="${CFLAGS:-$(echo %optflags | sed 
's/-fstack-protector-strong//')}"
-else
-   CFLAGS="${CFLAGS:-%optflags -Wno-format-truncation}"
-fi
-%else
-CFLAGS="${CFLAGS:-%optflags -Wno-format-truncation}"
-%endif
-export CFLAGS
-# do not use --enable-optimize or --disable-optimize: we don't want
-# any changes to optimization flags
-%{configure} \
-   --with-rundir=%{_rundir}/monetdb \
-   --enable-assert=no \
-   --enable-debug=yes \
-   --enable-developer=no \
-   --enable-embedded=no \
-   --enable-embedded-r=no \
-   --enable-fits=%{?with_fits:yes}%{!?with_fits:no} \
-   --enable-geom=%{?with_geos:yes}%{!?with_geos:no} \
-   --enable-int128=%{?with_hugeint:yes}%{!?with_hugeint:no} \
-   

MonetDB: default - Merged with oscar

2020-07-31 Thread Pedro Ferreira
Changeset: d341804686b2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d341804686b2
Modified Files:
sql/server/rel_optimizer.c
Branch: default
Log Message:

Merged with oscar


diffs (97 lines):

diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -7641,6 +7641,8 @@ rel_simplify_predicates(visitor *v, sql_
 
if 
(!strcmp(inf->func->base.name, "<>"))
flag = !flag;
+   if (e->flag == 
cmp_notequal)
+   flag = !flag;

assert(list_length(args) == 2);
l = args->h->data;
r = args->h->next->data;
diff --git a/sql/test/SQLancer/Tests/sqlancer01.sql 
b/sql/test/SQLancer/Tests/sqlancer01.sql
--- a/sql/test/SQLancer/Tests/sqlancer01.sql
+++ b/sql/test/SQLancer/Tests/sqlancer01.sql
@@ -319,6 +319,23 @@ create view v1(c0) as (select distinct t
 select max(all abs(+ (- (- (-1620427795) from v0, t0 join v1 on 
v1.c0)||(t0.c1)))ilike(v1.c0));
 ROLLBACK;
 
+START TRANSACTION;
+CREATE TABLE "sys"."t1" ("c0" VARCHAR(427),"c1" TIME);
+COPY 5 RECORDS INTO "sys"."t1" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+"-"NULL
+"0.9494786438610024"   NULL
+"MA4DƹXb,⻇멫ho\trYmꈋP-aR"   NULL
+NULL   02:45:58
+NULL   05:45:05
+
+SELECT MEDIAN(ALL abs(CASE TIMESTAMP '1970-01-24 09:25:06' WHEN TIMESTAMP 
'1970-01-19 10:35:50' THEN 2 END)) FROM t1 GROUP BY abs(0.8);
+SELECT MEDIAN(ALL abs(CASE TIMESTAMP '1970-01-24 09:25:06' WHEN TIMESTAMP 
'1970-01-19 10:35:50' THEN 2 END)) FROM t1 GROUP BY abs(0.8) HAVING (NOT 
(MIN(ALL NOT (NOT ((0.7) IS NULL) = TRUE
+UNION ALL
+SELECT MEDIAN(ALL abs(CASE TIMESTAMP '1970-01-24 09:25:06' WHEN TIMESTAMP 
'1970-01-19 10:35:50' THEN 2 END)) FROM t1 GROUP BY abs(0.8) HAVING NOT ((NOT 
(MIN(ALL NOT (NOT ((0.7) IS NULL) = TRUE)
+UNION ALL
+SELECT MEDIAN(ALL abs(CASE TIMESTAMP '1970-01-24 09:25:06' WHEN TIMESTAMP 
'1970-01-19 10:35:50' THEN 2 END)) FROM t1 GROUP BY abs(0.8) HAVING ((NOT 
(MIN(ALL NOT (NOT ((0.7) IS NULL) = TRUE) IS NULL;
+ROLLBACK;
+
 DROP TABLE tbl_ProductSales;
 DROP TABLE another_T;
 DROP TABLE integers;
diff --git a/sql/test/SQLancer/Tests/sqlancer01.stable.out 
b/sql/test/SQLancer/Tests/sqlancer01.stable.out
--- a/sql/test/SQLancer/Tests/sqlancer01.stable.out
+++ b/sql/test/SQLancer/Tests/sqlancer01.stable.out
@@ -213,8 +213,8 @@ stdout of test 'sqlancer01` in directory
 % int # type
 % 1 # length
 #select 1 from another_t join integers on (cast(another_t.col4 between 1 and 2 
as int)) where false;
-% .%15 # table_name
-% %15 # name
+% .%11 # table_name
+% %11 # name
 % tinyint # type
 % 1 # length
 #SELECT another_T.col2 FROM tbl_productsales, integers LEFT OUTER JOIN 
another_T ON another_T.col1 > 1 WHERE another_T.col2 > 1 GROUP BY 
another_T.col2 HAVING COUNT((another_T.col2) IN (another_T.col2)) > 0;
@@ -272,8 +272,8 @@ stdout of test 'sqlancer01` in directory
 % 1 # length
 [ 1]
 #select 1 from t0 where (3 in (1, 2)) is null; --simplified
-% .%5 # table_name
-% %5 # name
+% .%4 # table_name
+% %4 # name
 % tinyint # type
 % 1 # length
 #SELECT 1 FROM t0 WHERE t0.c0 BETWEEN SYMMETRIC (1 IN (2, 1)) AND t0.c0;
@@ -625,6 +625,32 @@ stdout of test 'sqlancer01` in directory
 % 1 # length
 [ NULL ]
 #ROLLBACK;
+#START TRANSACTION;
+#CREATE TABLE "sys"."t1" ("c0" VARCHAR(427),"c1" TIME);
+#COPY 5 RECORDS INTO "sys"."t1" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+#"-"   NULL
+#"0.9494786438610024"  NULL
+#"MA4DƹXb,⻇멫ho\trYmꈋP-aR"  NULL
+#NULL  02:45:58
+#NULL  05:45:05
+[ 5]
+#SELECT MEDIAN(ALL abs(CASE TIMESTAMP '1970-01-24 09:25:06' WHEN TIMESTAMP 
'1970-01-19 10:35:50' THEN 2 END)) FROM t1 GROUP BY abs(0.8);
+% .%2 # table_name
+% %2 # name
+% tinyint # type
+% 1 # length
+[ NULL ]
+#SELECT MEDIAN(ALL abs(CASE TIMESTAMP '1970-01-24 09:25:06' WHEN TIMESTAMP 
'1970-01-19 10:35:50' THEN 2 END)) FROM t1 GROUP BY abs(0.8) HAVING (NOT 
(MIN(ALL NOT (NOT ((0.7) IS NULL) = TRUE
+#UNION ALL
+#SELECT MEDIAN(ALL abs(CASE TIMESTAMP '1970-01-24 09:25:06' WHEN TIMESTAMP 
'1970-01-19 10:35:50' THEN 2 END)) FROM t1 GROUP BY abs(0.8) HAVING NOT ((NOT 
(MIN(ALL NOT (NOT ((0.7) IS NULL) = TRUE)
+#UNION ALL
+#SELECT MEDIAN(ALL abs(CASE TIMESTAMP '1970-01-24 09:25:06' WHEN TIMESTAMP 
'1970-01-19 10:35:50' THEN 2 END)) FROM t1 GROUP BY abs(0.8) HAVING ((NOT 
(MIN(ALL NOT (NOT ((0.7) IS NULL) = TRUE) IS NULL;
+% .%23 # table_name
+% %2 # name
+% tinyint # type
+% 1 # length
+[ NULL ]
+#ROLLBACK;
 #DROP TABLE tbl_ProductSales;
 #DROP TABLE another_T;
 #DROP TABLE integers;
___
checkin-list mailing list

MonetDB: default - Merged with oscar

2020-07-29 Thread Pedro Ferreira
Changeset: bd15c5848d40 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bd15c5848d40
Modified Files:
sql/server/rel_dump.c
sql/server/rel_select.c
sql/server/rel_unnest.c
sql/test/subquery/Tests/subquery6.sql
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 860 to 300 lines):

diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -319,11 +319,6 @@ BATcalcnot(BAT *b, BAT *s, BAT *r)
bn->tnonil = nils == 0;
bn->tkey = b->tkey && nils <= 1;
 
-   if (nils != 0 && !b->tnil) {
-   b->tnil = true;
-   b->batDirtydesc = true;
-   }
-
TRC_DEBUG(ALGO, "b=" ALGOBATFMT ",s=" ALGOOPTBATFMT
  ",r=" ALGOOPTBATFMT " -> " ALGOOPTBATFMT " " LLFMT "usec\n",
  ALGOBATPAR(b), ALGOOPTBATPAR(s),
@@ -449,11 +444,6 @@ BATcalcnegate(BAT *b, BAT *s, BAT *r)
bn->tnonil = nils == 0;
bn->tkey = b->tkey && nils <= 1;
 
-   if (nils != 0 && !b->tnil) {
-   b->tnil = true;
-   b->batDirtydesc = true;
-   }
-
TRC_DEBUG(ALGO, "b=" ALGOBATFMT ",s=" ALGOOPTBATFMT
  ",r=" ALGOOPTBATFMT " -> " ALGOOPTBATFMT " " LLFMT "usec\n",
  ALGOBATPAR(b), ALGOOPTBATPAR(s),
@@ -589,11 +579,6 @@ BATcalcabsolute(BAT *b, BAT *s, BAT *r)
bn->tnil = nils != 0;
bn->tnonil = nils == 0;
 
-   if (nils && !b->tnil) {
-   b->tnil = true;
-   b->batDirtydesc = true;
-   }
-
TRC_DEBUG(ALGO, "b=" ALGOBATFMT ",s=" ALGOOPTBATFMT
  ",r=" ALGOOPTBATFMT " -> " ALGOOPTBATFMT " " LLFMT "usec\n",
  ALGOBATPAR(b), ALGOOPTBATPAR(s),
@@ -728,11 +713,6 @@ BATcalciszero(BAT *b, BAT *s, BAT *r)
bn->tnil = nils != 0;
bn->tnonil = nils == 0;
 
-   if (nils != 0 && !b->tnil) {
-   b->tnil = true;
-   b->batDirtydesc = true;
-   }
-
TRC_DEBUG(ALGO, "b=" ALGOBATFMT ",s=" ALGOOPTBATFMT
  ",r=" ALGOOPTBATFMT " -> " ALGOOPTBATFMT " " LLFMT "usec\n",
  ALGOBATPAR(b), ALGOOPTBATPAR(s),
@@ -871,11 +851,6 @@ BATcalcsign(BAT *b, BAT *s, BAT *r)
bn->tnil = nils != 0;
bn->tnonil = nils == 0;
 
-   if (nils != 0 && !b->tnil) {
-   b->tnil = true;
-   b->batDirtydesc = true;
-   }
-
TRC_DEBUG(ALGO, "b=" ALGOBATFMT ",s=" ALGOOPTBATFMT
  ",r=" ALGOOPTBATFMT " -> " ALGOOPTBATFMT " " LLFMT "usec\n",
  ALGOBATPAR(b), ALGOOPTBATPAR(s),
@@ -3809,15 +3784,6 @@ BATcalcincrdecr(BAT *b, BAT *s, BAT *r, 
bn->tnil = nils != 0;
bn->tnonil = nils == 0;
 
-   if (nils && !b->tnil) {
-   b->tnil = true;
-   b->batDirtydesc = true;
-   }
-   if (nils == 0 && !b->tnonil) {
-   b->tnonil = true;
-   b->batDirtydesc = true;
-   }
-
TRC_DEBUG(ALGO, "%s: b=" ALGOBATFMT ",s=" ALGOOPTBATFMT
  ",r=" ALGOOPTBATFMT " -> " ALGOOPTBATFMT " " LLFMT "usec\n",
  func, ALGOBATPAR(b), ALGOOPTBATPAR(s),
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
@@ -924,10 +924,22 @@ exp_read(mvc *sql, sql_rel *lrel, sql_re
if (!(rexps = read_exps(sql, lrel, rrel, pexps, r, pos, 
'(', 0)))
return NULL;
if (filter) {
-   sql_subfunc *func = sql_find_func(sql->sa, 
mvc_bind_schema(sql, "sys"), fname, 1+list_length(exps), F_FILT, NULL);
-   if (!func)
+   sql_subfunc *func = NULL;
+   list *tl = sa_list(sql->sa);
+
+   for (node *n = lexps->h; n; n = n->next){
+   sql_exp *e = n->data;
+
+   list_append(tl, exp_subtype(e));
+   }
+   for (node *n = rexps->h; n; n = n->next){
+   sql_exp *e = n->data;
+   
+   list_append(tl, exp_subtype(e));
+   }
+
+   if (!(func = sql_bind_func_(sql->sa, 
mvc_bind_schema(sql, "sys"), fname, tl, F_FILT)))
return sql_error(sql, -1, 
SQLSTATE(42000) "Filter: missing function '%s'\n", fname);
-
return exp_filter(sql->sa, lexps, rexps, func, 
anti);
}
return exp_or(sql->sa, lexps, rexps, anti);
@@ -1028,12 +1040,16 @@ exp_read(mvc *sql, sql_rel *lrel, sql_re
if (tname && !s)
return sql_error(sql, -1, SQLSTATE(42000) "Schema %s 
not found\n", tname);
   

MonetDB: default - Merged with oscar

2020-07-28 Thread Pedro Ferreira
Changeset: b6acf611475a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b6acf611475a
Modified Files:
sql/common/sql_types.c
sql/server/rel_optimizer.c
sql/server/rel_select.c
sql/test/SQLancer/Tests/sqlancer03.sql
sql/test/SQLancer/Tests/sqlancer03.stable.out
sql/test/pg_regress/Tests/date.stable.err
sql/test/pg_regress/Tests/date.stable.out
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 851 to 300 lines):

diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -107,7 +107,7 @@ static int convert_matrix[EC_MAX][EC_MAX
 /* EC_FLT */   { 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 
0 },
 /* EC_TIME */  { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 
0 },
 /* EC_TIME_TZ */   { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 
0 },
-/* EC_DATE */  { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 0, 
0 },
+/* EC_DATE */  { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0, 
0 },
 /* EC_TSTAMP */{ 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 
1, 2, 0, 0 },
 /* EC_TSTAMP_TZ */ { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 
0 },
 /* EC_GEOM */  { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 
0 },
diff --git a/sql/server/CMakeLists.txt b/sql/server/CMakeLists.txt
--- a/sql/server/CMakeLists.txt
+++ b/sql/server/CMakeLists.txt
@@ -9,7 +9,7 @@
 BISON_TARGET(sqlparser
   sql_parser.y
   ${CMAKE_CURRENT_BINARY_DIR}/sql_parser.tab.c
-  COMPILE_FLAGS "-d -p sql -r all"
+  COMPILE_FLAGS "-d -p sql"
   DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/sql_parser.tab.h)
 
 add_library(sqlserver STATIC)
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -1491,6 +1491,7 @@ rel_push_func_down(visitor *v, sql_rel *
sql_rel *nrel;
sql_rel *l = rel->l, *ol = l;
sql_rel *r = rel->r, *or = r;
+   visitor nv = { .sql = v->sql, .parent = v->parent };
 
/* we need a full projection, group by's and unions 
cannot be extended
 * with more expressions */
@@ -1510,13 +1511,9 @@ rel_push_func_down(visitor *v, sql_rel *
}
nrel = rel_project(v->sql->sa, rel, 
rel_projections(v->sql, rel, NULL, 1, 1));
 
-   int old_changes = v->changes;
-   v->changes = 0;
-   if (!(exps = exps_push_single_func_down(v, rel, l, r, 
exps))) {
-   v->changes = old_changes;
+   if (!(exps = exps_push_single_func_down(, rel, l, r, 
exps)))
return NULL;
-   }
-   if (v->changes) {
+   if (nv.changes) {
rel = nrel;
} else {
if (l != ol)
@@ -1524,7 +1521,7 @@ rel_push_func_down(visitor *v, sql_rel *
if (is_joinop(rel->op) && r != or)
rel->r = or;
}
-   v->changes += old_changes;
+   v->changes += nv.changes;
}
}
if (rel->op == op_project && rel->l && rel->exps) {
@@ -1826,18 +1823,15 @@ rel_simplify_fk_joins(visitor *v, sql_re
 static list *
 sum_limit_offset(mvc *sql, sql_rel *rel)
 {
-   list *nexps = new_exp_list(sql->sa);
-   sql_subtype *lng = sql_bind_localtype("lng");
-   sql_subfunc *add;
-
/* for sample we always propagate */
if (is_sample(rel->op))
return exps_copy(sql, rel->exps);
/* if the expression list only consists of a limit expression, we copy 
it */
if (list_length(rel->exps) == 1 && rel->exps->h->data)
-   return append(nexps, rel->exps->h->data);
-   add = sql_bind_func_result(sql->sa, sql->session->schema, "sql_add", 
F_FUNC, lng, 2, lng, lng);
-   return append(nexps, exp_op(sql->sa, rel->exps, add));
+   return list_append(sa_list(sql->sa), rel->exps->h->data);
+   sql_subtype *lng = sql_bind_localtype("lng");
+   sql_subfunc *add = sql_bind_func_result(sql->sa, sql->session->schema, 
"sql_add", F_FUNC, lng, 2, lng, lng);
+   return list_append(sa_list(sql->sa), exp_op(sql->sa, rel->exps, add));
 }
 
 static int
@@ -1968,7 +1962,7 @@ rel_push_topn_and_sample_down(visitor *v
}
}
 
-   if (r && need_distinct(r))
+   if (r && is_simple_project(r->op) && need_distinct(r))
return rel;
 
/* push topn/sample under projections */
@@ -1995,24 +1989,28 @@ 

MonetDB: default - Merged with oscar

2020-07-27 Thread Pedro Ferreira
Changeset: 460573640da0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=460573640da0
Modified Files:
CMakeLists.txt
cmake/monetdb-defines.cmake
gdk/gdk_utils.c
sql/backends/monet5/sql_upgrades.c
sql/common/sql_types.c
sql/server/rel_exp.c
sql/server/rel_optimizer.c
sql/server/rel_select.c
sql/storage/store.c

sql/test/BugTracker-2018/Tests/sqlitelogictest-cast-null-add.Bug-6630.stable.out
sql/test/SQLancer/Tests/sqlancer03.sql
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.ppc64.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/emptydb-upgrade/Tests/upgrade.stable.out
sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
sql/test/miscellaneous/Tests/simple_plans.stable.out
sql/test/miscellaneous/Tests/simple_plans.stable.out.single
sql/test/miscellaneous/Tests/simple_selects.stable.out
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 2338 to 300 lines):

diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -154,6 +154,7 @@ add_subdirectory(tools)
 if(TESTING)
   add_subdirectory(testing)
 endif()
+add_subdirectory(buildtools)
 
 include(CMakePackageConfigHelpers)
 configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
diff --git a/NT/mkodbcwxs.py b/NT/mkodbcwxs.py
--- a/NT/mkodbcwxs.py
+++ b/NT/mkodbcwxs.py
@@ -4,7 +4,7 @@
 #
 # Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V.
 
-# python mkodbcwxs.py VERSION makedefs.txt PREFIX > 
PREFIX/MonetDB-ODBC-Installer.wxs
+# python mkodbcwxs.py VERSION BITS PREFIX > PREFIX/MonetDB-ODBC-Installer.wxs
 # "c:\Program Files (x86)\WiX Toolset v3.10\bin\candle.exe" -nologo -arch 
x64/x86 PREFIX/MonetDB-ODBC-Installer.wxs
 # "c:\Program Files (x86)\WiX Toolset v3.10\bin\light.exe" -nologo -sice:ICE03 
-sice:ICE60 -sice:ICE82 -ext WixUIExtension PREFIX/MonetDB-ODBC-Installer.wixobj
 
@@ -29,21 +29,19 @@ def comp(features, id, depth, files, fid
 
 def main():
 if len(sys.argv) != 4:
-print(r'Usage: mkodbcwxs.py version makedefs.txt installdir')
+print(r'Usage: mkodbcwxs.py version bits installdir')
 return 1
-makedefs = {}
-for line in open(sys.argv[2]):
-key, val = line.strip().split('=', 1)
-makedefs[key] = val
-if makedefs['bits'] == '64':
+if sys.argv[2] == '64':
 folder = r'ProgramFiles64Folder'
 arch = 'x64'
 libcrypto = '-x64'
+vcpkg = r'C:\vcpkg\installed\x64-windows\{}'
 else:
 folder = r'ProgramFilesFolder'
 arch = 'x86'
 libcrypto = ''
-vs = os.getenv('vs')# inherited from TestTools\common.bat
+vcpkg = r'C:\vcpkg\installed\x86-windows\{}'
+vs = '2019'
 features = []
 print(r'')
 print(r'http://schemas.microsoft.com/wix/2006/wi;>')
@@ -59,7 +57,7 @@ def main():
 print(r'')
 print(r'')
 print(r'')
-msvc = r'C:\Program Files (x86)\Microsoft Visual 
Studio\20{}\Community\VC\Redist\MSVC'.format(vs)
+msvc = r'C:\Program Files (x86)\Microsoft Visual 
Studio\{}\Community\VC\Redist\MSVC'.format(vs)
 d = sorted(os.listdir(msvc))[-1]
 msm = '_CRT_{}.msm'.format(arch)
 for f in sorted(os.listdir(os.path.join(msvc, d, 'MergeModules'))):
@@ -72,14 +70,14 @@ def main():
 id = 1
 print(r'')
 id = comp(features, id, 14,
-  [r'lib\libmapi.dll', r'lib\libmapi.pdb',
-   r'lib\libMonetODBC.dll', r'lib\libMonetODBC.pdb',
-   r'lib\libMonetODBCs.dll', r'lib\libMonetODBCs.pdb',
-   r'lib\libstream.dll', r'lib\libstream.pdb',
-   r'{}\bin\iconv-2.dll'.format(makedefs['LIBICONV']),
-   r'{}\bin\libbz2.dll'.format(makedefs['LIBBZIP2']),
-   r'{}\bin\libcrypto-1_1{}.dll'.format(makedefs['LIBOPENSSL'], 
libcrypto),
-   r'{}\bin\zlib1.dll'.format(makedefs['LIBZLIB'])])
+  [r'bin\mapi.dll', # r'lib\mapi.pdb',
+   r'bin\MonetODBC.dll', # r'lib\MonetODBC.pdb',
+   r'bin\MonetODBCs.dll', # r'lib\MonetODBCs.pdb',
+   r'bin\stream.dll', # r'lib\stream.pdb',
+ 

MonetDB: default - merged with oscar

2020-07-24 Thread Niels Nes
Changeset: d28853482462 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d28853482462
Modified Files:
sql/backends/monet5/rel_bin.c
Branch: default
Log Message:

merged with oscar


diffs (38 lines):

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
@@ -775,13 +775,15 @@ exp_bin(backend *be, sql_exp *e, stmt *l
assert(!e->r);
if (exps) {
int nrcols = 0;
-   int push_cond_exec = 0;
+   int push_cond_exec = 0, coalesce = 0;
stmt *ncond = NULL, *ocond = cond;
 
if (sel && strcmp(sql_func_mod(f->func), "calc") == 0 
&& strcmp(sql_func_imp(f->func), "ifthenelse") != 0)
push_cands = 1;
if (strcmp(sql_func_mod(f->func), "calc") == 0 && 
strcmp(sql_func_imp(f->func), "ifthenelse") == 0)
push_cond_exec = 1;
+   if (strcmp(sql_func_mod(f->func), "") == 0 && 
strcmp(sql_func_imp(f->func), "") == 0 && strcmp(f->func->base.name, 
"coalesce") == 0)
+   coalesce = 1;
 
assert(list_length(exps) == list_length(f->func->ops) 
|| f->func->type == F_ANALYTIC || f->func->type == F_LOADER || f->func->vararg 
|| f->func->varres);
for (en = exps->h; en; en = en->next) {
@@ -809,6 +811,17 @@ exp_bin(backend *be, sql_exp *e, stmt *l
 
if (push_cands && es->nrcols)
nrcands++;
+   if (coalesce && en->next) {
+   sql_subfunc *a = sql_bind_func(sql->sa, 
sql->session->schema, "isnull", tail_type(es), NULL, F_FUNC);
+   ncond = stmt_unop(be, es, a);
+   if (ocond) {
+   sql_subtype *bt = 
sql_bind_localtype("bit");
+   sql_subfunc *a = 
sql_bind_func(sql->sa, sql->session->schema, "and", bt, bt, F_FUNC);
+   cond = stmt_binop(be, ocond, 
ncond, a);
+   } else {
+   cond = ncond;
+   }
+   }
if (push_cond_exec && ncond) { /* handled then 
part */
sql_subtype *bt = 
sql_bind_localtype("bit");
sql_subfunc *a = sql_bind_func(sql->sa, 
sql->session->schema, "not", bt, NULL, F_FUNC);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Merged with oscar

2020-07-24 Thread Pedro Ferreira
Changeset: 12987b3f64fe for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=12987b3f64fe
Modified Files:
gdk/gdk_utils.c
sql/backends/monet5/sql_gencode.c
sql/backends/monet5/sql_statement.c
sql/common/sql_types.c
sql/server/rel_exp.c
sql/server/rel_exp.h
sql/server/rel_optimizer.c
sql/server/rel_select.c

sql/test/BugDay_2005-11-09_2.9.3/Tests/sql_server_crash.SF-1080024.stable.out

sql/test/BugTracker-2016/Tests/column_alias_in_where_clause.Bug-3947.stable.out

sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case-nullif-coalesce.Bug-6565.stable.out

sql/test/BugTracker-2018/Tests/sqlitelogictest-groupby-having-in.Bug-6560.stable.out

sql/test/BugTracker-2018/Tests/sqlitelogictest-select-errors.Bug-6600.stable.out
sql/test/SQLancer/Tests/sqlancer03.sql
sql/test/SQLancer/Tests/sqlancer03.stable.out
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
sql/test/miscellaneous/Tests/simple_plans.stable.out
sql/test/miscellaneous/Tests/simple_plans.stable.out.single
sql/test/sys-schema/Tests/systemfunctions.stable.out
sql/test/sys-schema/Tests/systemfunctions.stable.out.int128
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 1318 to 300 lines):

diff --git a/sql/backends/monet5/sql_statement.c 
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -3145,77 +3145,120 @@ stmt_Nop(backend *be, stmt *ops, sql_sub
}
}
 
-   if (backend_create_subfunc(be, f, ops->op4.lval) < 0)
-   return NULL;
-   mod = sql_func_mod(f->func);
-   fimp = sql_func_imp(f->func);
-   if (o && o->nrcols > 0 && f->func->type != F_LOADER && f->func->type != 
F_PROC) {
-   sql_subtype *res = f->res->h->data;
-   fimp = convertMultiplexFcn(fimp);
-   q = NULL;
-   if (strcmp(fimp, "rotate_xor_hash") == 0 &&
-   strcmp(mod, calcRef) == 0 &&
-   (q = newStmt(mb, mkeyRef, bulk_rotate_xor_hashRef)) == NULL)
-   return NULL;
-   if (!q) {
-   if (f->func->type == F_UNION)
-   q = newStmt(mb, batmalRef, multiplexRef);
-   else
-   q = newStmt(mb, malRef, multiplexRef);
-   if (q == NULL)
-   return NULL;
-   setVarType(mb, getArg(q, 0), 
newBatType(res->type->localtype));
-   setVarUDFtype(mb, getArg(q, 0));
-   q = pushStr(mb, q, mod);
-   q = pushStr(mb, q, fimp);
-   } else {
-   setVarType(mb, getArg(q, 0), 
newBatType(res->type->localtype));
-   setVarUDFtype(mb, getArg(q, 0));
+   /* handle coalesce and nullif */
+   if (list_length(ops->op4.lval) == 2 &&
+   f->func->mod && strcmp(f->func->mod, "") == 0 && f->func->imp 
&& strcmp(f->func->imp, "") == 0) {
+   stmt *e1 = ops->op4.lval->h->data;
+   stmt *e2 = ops->op4.lval->h->next->data;
+   int nrcols = 0;
+
+   nrcols = e1->nrcols>e2->nrcols ? e1->nrcols:e2->nrcols;
+   /* nrcols */
+   //coalesce(e1,e2) -> ifthenelse(not(isnil(e1)),e1,e2)
+   if (strcmp(f->func->base.name, "coalesce") == 0) {
+   str mod = (!nrcols)?calcRef:batcalcRef;
+   q = newStmt(mb, e1->nrcols?mod:calcRef, "isnil");
+   q = pushArgument(mb, q, e1->nr);
+   int nr = getDestVar(q);
+
+   q = newStmt(mb, e1->nrcols?mod:calcRef, "not");
+   q = pushArgument(mb, q, nr);
+   nr = getDestVar(q);
+
+   q = newStmt(mb, mod, "ifthenelse");
+   q = pushArgument(mb, q, nr);
+   q = pushArgument(mb, q, e1->nr);
+   q = pushArgument(mb, q, e2->nr);
}
-   } else {
-   fimp = convertOperator(fimp);
-   q = newStmt(mb, mod, fimp);
-
-   if (f->res && list_length(f->res)) {
-   sql_subtype *res = f->res->h->data;
-
-   setVarType(mb, getArg(q, 0), res->type->localtype);
-   setVarUDFtype(mb, getArg(q, 0));
+   //nullif(e1,e2) -> ifthenelse(e1==e2),NULL,e1)
+   if (strcmp(f->func->base.name, "nullif") == 0) {
+   str mod = (!nrcols)?calcRef:batcalcRef;
+   sql_subtype *t = tail_type(e1);
+   int tt = 

MonetDB: default - Merged with oscar

2020-07-24 Thread Pedro Ferreira
Changeset: af8c3691379c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=af8c3691379c
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 2214 to 300 lines):

diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c
--- a/gdk/gdk_analytic_func.c
+++ b/gdk/gdk_analytic_func.c
@@ -1677,25 +1677,19 @@ GDKanalyticalavg(BAT *r, BAT *b, BAT *s,
 #ifdef TRUNCATE_NUMBERS
 #define ANALYTICAL_AVERAGE_INT_CALC_FINALIZE(avg, rem, ncnt) \
do {
-   if (rem > 0 && avg < 0) { \
+   if (rem > 0 && avg < 0) \
avg++; \
-   rem -= ncnt; \
-   }
} while(0)
 #else
 #define ANALYTICAL_AVERAGE_INT_CALC_FINALIZE(avg, rem, ncnt) \
do { \
if (rem > 0) { \
if (avg < 0) { \
-   if (2*rem > ncnt) { \
+   if (2*rem > ncnt) \
avg++; \
-   rem -= ncnt; \
-   } \
} else { \
-   if (2*rem >= ncnt) { \
+   if (2*rem >= ncnt) \
avg++; \
-   rem -= ncnt; \
-   } \
} \
} \
} while(0)
diff --git a/sql/benchmarks/tpcds/Tests/47.stable.out 
b/sql/benchmarks/tpcds/Tests/47.stable.out
--- a/sql/benchmarks/tpcds/Tests/47.stable.out
+++ b/sql/benchmarks/tpcds/Tests/47.stable.out
@@ -37,112 +37,112 @@ stdout of test '47` in directory 'sql/be
 #  s_company_name,
 % sys.v2,  sys.v2, sys.v2, sys.v2, sys.v2, sys.v2, sys.v2, sys.v2, sys.v2, 
sys.v2 # table_name
 % i_category,  i_brand,s_store_name,   s_company_name, d_year, d_moy,  
avg_monthly_sales,  sum_sales,  psum,   nsum # name
-% char,char,   varchar,varchar,int,int,double, 
decimal,decimal,decimal # type
-% 50,  50, 5,  7,  4,  1,  24, 20, 20, 20 # 
length
-[ "Men",   "importoimporto #1","ese",  "Unknown",  1999,   3,  
5492.817525,2070.65,3307.78,2784.11 ]
-[ "Music", "exportischolar #1","eing", "Unknown",  1999,   2,  
5134.238322,1740.21,4401.89,2721.61 ]
-[ "Music", "edu packscholar #1",   "ese",  "Unknown",  1999,   4,  
5463.700806,2091.07,3391.39,3095.31 ]
-[ "Music", "edu packscholar #1",   "ought","Unknown",  1999,   
7,  5552.305013,2226.34,4081.99,7573.33 ]
-[ "Music", "edu packscholar #1",   "ese",  "Unknown",  1999,   2,  
5463.700806,2268.27,4139.47,3391.39 ]
-[ "Men",   "edu packimporto #1",   "ought","Unknown",  1999,   
7,  5176.257426,1993.73,3542.54,5764.35 ]
-[ "Children",  "exportiexporti #1","ese",  "Unknown",  1999,   3,  
5185.898254,2019.69,3479.21,2982.05 ]
-[ "Shoes", "amalgedu pack #1", "ation","Unknown",  1999,   
6,  5152.095886,2077.67,3123.43,2368.73 ]
-[ "Men",   "edu packimporto #1",   "eing", "Unknown",  1999,   3,  
5501.180766,2453.88,2683.70,2615.32 ]
-[ "Children",  "exportiexporti #1","ation","Unknown",  1999,   
4,  5238.357524,2232.03,3221.70,3649.52 ]
-[ "Shoes", "importoedu pack #1",   "eing", "Unknown",  1999,   5,  
4698.612447,1703.27,2687.15,2757.83 ]
-[ "Music", "exportischolar #1","bar",  "Unknown",  1999,   7,  
5318.146708,2346.06,3483.88,7658.62 ]
-[ "Music", "edu packscholar #1",   "ation","Unknown",  1999,   
2,  5622.227458,2657.68,4207.03,3543.82 ]
-[ "Children",  "exportiexporti #1","bar",  "Unknown",  1999,   7,  
5280.662557,2324.79,3003.61,5961.39 ]
-[ "Children",  "importoexporti #1","eing", "Unknown",  1999,   2,  
4650.438314,1734.45,2341.19,2720.78 ]
-[ "Shoes", "importoedu pack #1",   "ought","Unknown",  1999,   
4,  4537.635834,1623.33,2928.34,1905.23 ]
-[ "Women", "edu packamalg #1", "ation","Unknown",  1999,   
4,  4507.417511,1596.92,2865.38,2665.75 ]
-[ "Men",   "importoimporto #1","ought","Unknown",  1999,   
6,  5045.758321,2152.15,2834.94,2667.92 ]
-[ "Men",   "edu packimporto #1",   "eing", "Unknown",  1999,   4,  
5501.180766,2615.32,2453.88,2874.96 ]
-[ "Shoes", "exportiedu pack #1",   "bar",  "Unknown",  1999, 

MonetDB: default - Merged with oscar

2020-07-23 Thread Pedro Ferreira
Changeset: 29df59ff595f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=29df59ff595f
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
monetdb5/mal/mal.h
monetdb5/modules/mal/batcalc.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/sql_upgrades.c
sql/common/sql_types.c
sql/server/rel_exp.c
sql/server/rel_optimizer.c
sql/server/rel_select.c
sql/server/sql_parser.y
sql/server/sql_scan.c
sql/test/sys-schema/Tests/systemfunctions.stable.out
sql/test/sys-schema/Tests/systemfunctions.stable.out.int128
tools/monetdbe/monetdbe.c
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 6189 to 300 lines):

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -777,3 +777,6 @@ 28480e096722b7f76ab021c0d16c68c6949f41b4
 80bd3e89c48032840f493a63d6c4c12ee6273b3d Jun2020_release
 1e3bd8cd485a0880a7557aa5307e986a210a1e00 Jun2020_9
 1e3bd8cd485a0880a7557aa5307e986a210a1e00 Jun2020_SP1_release
+bb157905ecb86908dcfb112d102a8c6152557b5d Jun2020_11
+1e3bd8cd485a0880a7557aa5307e986a210a1e00 Jun2020_SP1_release
+bb157905ecb86908dcfb112d102a8c6152557b5d Jun2020_SP1_release
diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -7,7 +7,7 @@
 # The --with OPTION and --without OPTION arguments can be passed on
 # the commandline of both rpmbuild and mock.
 
-# On 64 bit architectures we build "hugeint" packages.
+# On 64 bit architectures compile with 128 bit integer support.
 %if "%{?_lib}" == "lib64"
 %bcond_without hugeint
 %endif
@@ -379,9 +379,6 @@ extensions for %{name}-SQL-server5.
 
 %files geom-MonetDB5
 %defattr(-,root,root)
-%{_libdir}/monetdb5/autoload/*_geom.mal
-%{_libdir}/monetdb5/createdb/*_geom.sql
-%{_libdir}/monetdb5/geom.mal
 %{_libdir}/monetdb5/lib_geom.so
 %endif
 
@@ -406,8 +403,7 @@ install it.
 
 %files R
 %defattr(-,root,root)
-%{_libdir}/monetdb5/rapi.*
-%{_libdir}/monetdb5/autoload/*_rapi.mal
+%{_libdir}/monetdb5/rapi.R
 %{_libdir}/monetdb5/lib_rapi.so
 %endif
 
@@ -432,8 +428,6 @@ install it.
 
 %files python3
 %defattr(-,root,root)
-%{_libdir}/monetdb5/pyapi3.*
-%{_libdir}/monetdb5/autoload/*_pyapi3.mal
 %{_libdir}/monetdb5/lib_pyapi3.so
 %endif
 
@@ -454,9 +448,6 @@ format.
 
 %files cfitsio
 %defattr(-,root,root)
-%{_libdir}/monetdb5/fits.mal
-%{_libdir}/monetdb5/autoload/*_fits.mal
-%{_libdir}/monetdb5/createdb/*_fits.sql
 %{_libdir}/monetdb5/lib_fits.so
 %endif
 
@@ -465,10 +456,12 @@ Summary: MonetDB - Monet Database Manage
 Group: Applications/Databases
 Requires(pre): shadow-utils
 Requires: %{name}-client%{?_isa} = %{version}-%{release}
+Obsoletes: MonetDB5-server-hugeint < 11.38.0
+%if %{with hugeint}
+Provides: MonetDB5-server-hugeint%{?_isa} = %{version}-%{release}
+%endif
 %if (0%{?fedora} >= 22)
 Recommends: %{name}-SQL-server5%{?_isa} = %{version}-%{release}
-%if %{with hugeint}
-Recommends: MonetDB5-server-hugeint%{?_isa} = %{version}-%{release}
 %endif
 Suggests: %{name}-client%{?_isa} = %{version}-%{release}
 %endif
@@ -521,37 +514,7 @@ exit 0
 %exclude %{_bindir}/stethoscope
 %{_libdir}/libmonetdb5.so.*
 %dir %{_libdir}/monetdb5
-%dir %{_libdir}/monetdb5/autoload
-%if %{with fits}
-%exclude %{_libdir}/monetdb5/fits.mal
-%exclude %{_libdir}/monetdb5/autoload/*_fits.mal
-%endif
-%if %{with geos}
-%exclude %{_libdir}/monetdb5/geom.mal
-%endif
-%if %{with py3integration}
-%exclude %{_libdir}/monetdb5/pyapi3.mal
-%endif
-%if %{with rintegration}
-%exclude %{_libdir}/monetdb5/rapi.mal
-%endif
-%exclude %{_libdir}/monetdb5/sql*.mal
-%if %{with hugeint}
-%exclude %{_libdir}/monetdb5/*_hge.mal
-%exclude %{_libdir}/monetdb5/autoload/*_hge.mal
-%endif
-%{_libdir}/monetdb5/*.mal
-%if %{with geos}
-%exclude %{_libdir}/monetdb5/autoload/*_geom.mal
-%endif
-%if %{with py3integration}
-%exclude %{_libdir}/monetdb5/autoload/*_pyapi3.mal
-%endif
-%if %{with rintegration}
-%exclude %{_libdir}/monetdb5/autoload/*_rapi.mal
-%endif
-%exclude %{_libdir}/monetdb5/autoload/??_sql*.mal
-%{_libdir}/monetdb5/autoload/*.mal
+%{_libdir}/monetdb5/microbenchmark.mal
 %{_libdir}/monetdb5/lib_capi.so
 %{_libdir}/monetdb5/lib_generator.so
 %{_libdir}/monetdb5/lib_udf.so
@@ -560,28 +523,6 @@ exit 0
 %docdir %{_datadir}/doc/MonetDB
 %{_datadir}/doc/MonetDB/*
 
-%if %{with hugeint}
-%package -n MonetDB5-server-hugeint
-Summary: MonetDB - 128-bit integer support for MonetDB5-server
-Group: Applications/Databases
-Requires: MonetDB5-server%{?_isa}
-
-%description -n MonetDB5-server-hugeint
-MonetDB is a database management system that is developed from a
-main-memory perspective with use of a fully decomposed storage model,
-automatic index management, extensibility of data types and search
-accelerators.  It also has an SQL front end.
-
-This package provides HUGEINT (128-bit integer) support for the
-MonetDB5-server component.
-
-%files -n 

MonetDB: default - Merged with oscar

2020-07-22 Thread Pedro Ferreira
Changeset: 386f73ba1ded for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=386f73ba1ded
Modified Files:
sql/server/rel_optimizer.c
sql/server/sql_atom.c
Branch: default
Log Message:

Merged with oscar


diffs (43 lines):

diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -5283,7 +5283,7 @@ rel_remove_empty_join(visitor *v, sql_re
 static bool
 find_projection_for_join2semi(sql_rel *rel)
 {
-   if (is_simple_project(rel->op) || is_groupby(rel->op)) {
+   if (is_project(rel->op) && !is_union(rel->op)) {
if (rel->card < CARD_AGGR) /* const or groupby without group by 
exps */
return true;
 
diff --git a/sql/server/sql_atom.c b/sql/server/sql_atom.c
--- a/sql/server/sql_atom.c
+++ b/sql/server/sql_atom.c
@@ -318,6 +318,7 @@ atom_general(sql_allocator *sa, sql_subt
if (res < 0 || !p || ATOMcmp(type, p, ATOMnilptr(type)) 
== 0) {
if (p)
GDKfree(p);
+   GDKclrerr();
return NULL;
}
VALset(>data, a->data.vtype, p);
@@ -1229,8 +1230,10 @@ atom_cast(sql_allocator *sa, atom *a, sq
p = &(a->data.val.dval);
else
p = &(a->data.val.fval);
-   if ((res = ATOMfromstr(tpe, , , 
s, false)) < 0)
+   if ((res = ATOMfromstr(tpe, , , 
s, false)) < 0) {
+   GDKclrerr();
return 0;
+   }
} else {
return 0;
}
@@ -1251,6 +1254,7 @@ atom_cast(sql_allocator *sa, atom *a, sq
ATOMcmp(type, p, ATOMnilptr(type)) == 0) {
GDKfree(p);
a->data.len = strlen(a->data.val.sval);
+   GDKclrerr();
return 0;
}
a->tpe = *tp;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Merged with oscar

2020-07-22 Thread Pedro Ferreira
Changeset: 0d4861649c31 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0d4861649c31
Modified Files:
sql/server/rel_optimizer.c
tools/merovingian/client/monetdb.c
Branch: default
Log Message:

Merged with oscar


diffs (118 lines):

diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -4658,43 +4658,6 @@ rel_push_select_down_join(visitor *v, sq
return rel;
 }
 
-static bool
-find_simple_projection_for_join2semi(sql_rel *rel)
-{
-   if (is_project(rel->op) && list_length(rel->exps) == 1) {
-   sql_exp *e = rel->exps->h->data;
-
-   if (rel->card < CARD_AGGR) /* const or groupby without group by 
exps */
-   return true;
-   /* a single group by column in the projection list from a group 
by relation is guaranteed to be unique, but not an aggregate */
-   if (e->type == e_column) {
-   sql_rel *res = NULL;
-   sql_exp *found = NULL;
-   bool underjoin = false;
-
-   if (is_groupby(rel->op) || need_distinct(rel) || 
find_prop(e->p, PROP_HASHCOL))
-   return true;
-
-   found = rel_find_exp_and_corresponding_rel(rel->l, e, 
, ); /* grouping column on inner relation */
-   if (found && !underjoin) {
-   if (find_prop(found->p, PROP_HASHCOL)) /* 
primary key always unique */
-   return true;
-   if (found->type == e_column && found->card <= 
CARD_AGGR) {
-   if (!(is_groupby(res->op) || 
need_distinct(res)) && list_length(res->exps) != 1)
-   return false;
-   for (node *n = res->exps->h ; n ; n = 
n->next) { /* must be the single column in the group by expression list */
-   sql_exp *e = n->data;
-   if (e != found && e->type == 
e_column)
-   return false;
-   }
-   return true;
-   }
-   }
-   }
-   }
-   return false;
-}
-
 /*
  * Push {semi}joins down, pushes the joins through group by expressions.
  * When the join is on the group by columns, we can push the joins left
@@ -4713,13 +4676,13 @@ rel_push_join_down(visitor *v, sql_rel *
 {
list *exps = NULL;
 
-   if (!rel_is_ref(rel) && ((is_join(rel->op) || is_semi(rel->op)) && 
rel->l && rel->exps)) {
+   if (!rel_is_ref(rel) && ((is_left(rel->op) || rel->op == op_join || 
is_semi(rel->op)) && rel->l && rel->exps)) {
sql_rel *gb = rel->r, *ogb = gb, *l = NULL, *rell = rel->l;
 
if (gb->op == op_project)
gb = gb->l;
 
-   if (rel_is_ref(rell) || 
!find_simple_projection_for_join2semi(rell))
+   if (rel_is_ref(rell))
return rel;
 
exps = rel->exps;
@@ -5304,6 +5267,43 @@ rel_remove_empty_join(visitor *v, sql_re
return rel;
 }
 
+static bool
+find_simple_projection_for_join2semi(sql_rel *rel)
+{
+   if (is_project(rel->op) && list_length(rel->exps) == 1) {
+   sql_exp *e = rel->exps->h->data;
+
+   if (rel->card < CARD_AGGR) /* const or groupby without group by 
exps */
+   return true;
+   /* a single group by column in the projection list from a group 
by relation is guaranteed to be unique, but not an aggregate */
+   if (e->type == e_column) {
+   sql_rel *res = NULL;
+   sql_exp *found = NULL;
+   bool underjoin = false;
+
+   if (is_groupby(rel->op) || need_distinct(rel) || 
find_prop(e->p, PROP_HASHCOL))
+   return true;
+
+   found = rel_find_exp_and_corresponding_rel(rel->l, e, 
, ); /* grouping column on inner relation */
+   if (found && !underjoin) {
+   if (find_prop(found->p, PROP_HASHCOL)) /* 
primary key always unique */
+   return true;
+   if (found->type == e_column && found->card <= 
CARD_AGGR) {
+   if (!(is_groupby(res->op) || 
need_distinct(res)) && list_length(res->exps) != 1)
+   return false;
+   for (node *n = res->exps->h ; n ; n = 
n->next) { /* must be the single column in the group by expression list */
+ 

MonetDB: default - Merged with oscar

2020-07-21 Thread Pedro Ferreira
Changeset: 3ed18b503bce for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3ed18b503bce
Modified Files:
gdk/gdk_utils.c
sql/backends/monet5/sql_upgrades.c
sql/common/sql_types.c
sql/common/sql_types.h
sql/server/rel_exp.c
sql/server/rel_exp.h
sql/server/rel_optimizer.c
sql/server/rel_propagate.c
sql/server/sql_atom.c
sql/server/sql_atom.h
sql/storage/sql_storage.h
sql/storage/store.c
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 128069 to 300 lines):

diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -1360,7 +1360,10 @@ GDKusec(void)
return (lng) (f.QuadPart / 10);
 #elif defined(HAVE_CLOCK_GETTIME)
struct timespec ts;
-   clock_gettime(CLOCK_REALTIME, );
+#ifdef CLOCK_REALTIME_COARSE
+   if (clock_gettime(CLOCK_REALTIME_COARSE, ) < 0)
+#endif
+   (void) clock_gettime(CLOCK_REALTIME, );
return (lng) (ts.tv_sec * LL_CONSTANT(100) + ts.tv_nsec / 1000);
 #elif defined(HAVE_GETTIMEOFDAY)
struct timeval tv;
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
@@ -2153,7 +2153,7 @@ sql_update_default_lidar(Client c)
 }
 
 static str
-sql_update_default(Client c, mvc *sql, const char *prev_schema)
+sql_update_default(Client c, mvc *sql, const char *prev_schema, bool 
*systabfixed)
 {
size_t bufsize = 8192, pos = 0;
char *err = NULL, *buf = GDKmalloc(bufsize);
@@ -2176,6 +2176,11 @@ sql_update_default(Client c, mvc *sql, c
if (b) {
BATiter bi = bat_iterator(b);
if (BATcount(b) > 0 && strcmp(BUNtail(bi, 0), "progress") == 0) 
{
+   if (!*systabfixed &&
+   (err = sql_fix_system_tables(c, sql, 
prev_schema)) != NULL)
+   return err;
+   *systabfixed = true;
+
pos = 0;
pos += snprintf(buf + pos, bufsize - pos,
"set schema \"sys\";\n");
@@ -2294,20 +2299,6 @@ sql_update_default(Client c, mvc *sql, c
pos += snprintf(buf + pos, bufsize - pos,
"delete from args where id in (select 
args.id from args left join functions on args.func_id = functions.id where 
functions.id is null);\n");
 
-   list *functions = sa_list(sql->sa);
-   /* Adding fixed versions of degrees and radians 
functions */
-   sql_subtype *flt_types[2] = {sql_bind_localtype("flt"), 
sql_bind_localtype("dbl")};
-   for (int i = 0; i < 2; i++) {
-   sql_subtype *next = flt_types[i];
-   /*  TODO: This is BAD: its redundantly is 
trying to add duplicate function definitions to the global funcs list instead 
of updating the functions table.
-*  But it just ends up corrupting the 
global funcs list because it is using the wrong sql allocator.
-*/
-   list_append(functions, sql_create_func(sql->sa, 
"degrees", "mmath", "degrees", FALSE, FALSE, SCALE_FIX, 0, next->type, 1, 
next->type));
-   list_append(functions, sql_create_func(sql->sa, 
"radians", "mmath", "radians", FALSE, FALSE, SCALE_FIX, 0, next->type, 1, 
next->type));
-   }
-
-   insert_functions(sql->session->tr, mvc_bind_table(sql, 
sys, "functions"), functions, mvc_bind_table(sql, sys, "args"));
-
pos += snprintf(buf + pos, bufsize - pos,
"UPDATE sys.functions set semantics = false 
WHERE (name, func) IN (VALUES \n"
"('length', 'nitems'),\n"
@@ -2677,7 +2668,7 @@ SQLupgrades(Client c, mvc *m)
return -1;
}
 
-   if ((err = sql_update_default(c, m, prev_schema)) != NULL) {
+   if ((err = sql_update_default(c, m, prev_schema, )) != 
NULL) {
TRC_CRITICAL(SQL_PARSER, "%s\n", err);
freeException(err);
GDKfree(prev_schema);
diff --git a/sql/common/sql_types.c b/sql/common/sql_types.c
--- a/sql/common/sql_types.c
+++ b/sql/common/sql_types.c
@@ -1055,7 +1055,7 @@ 

MonetDB: default - Merged with oscar

2020-07-17 Thread Pedro Ferreira
Changeset: 4f09cc113461 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4f09cc113461
Modified Files:
cmake/monetdb-versions.cmake
gdk/gdk_align.c
gdk/gdk_batop.c
gdk/gdk_project.c
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_statement.c
sql/server/rel_exp.c
sql/server/rel_optimizer.c
sql/server/rel_rel.c
sql/server/rel_rewriter.c
sql/server/rel_unnest.c
sql/server/rel_updates.c
sql/test/SQLancer/Tests/sqlancer03.sql
sql/test/SQLancer/Tests/sqlancer03.stable.out
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 905 to 300 lines):

diff --git a/cmake/monetdb-versions.cmake b/cmake/monetdb-versions.cmake
--- a/cmake/monetdb-versions.cmake
+++ b/cmake/monetdb-versions.cmake
@@ -6,26 +6,6 @@
 # Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V.
 #]]
 
-set(GDK_VERSION_MAJOR "20")
-set(GDK_VERSION_MINOR "3")
-set(GDK_VERSION_PATCH "0")
-set(GDK_VERSION 
"${GDK_VERSION_MAJOR}.${GDK_VERSION_MINOR}.${GDK_VERSION_PATCH}")
-
-set(MAPI_VERSION_MAJOR "12")
-set(MAPI_VERSION_MINOR "4")
-set(MAPI_VERSION_PATCH "0")
-set(MAPI_VERSION 
"${MAPI_VERSION_MAJOR}.${MAPI_VERSION_MINOR}.${MAPI_VERSION_PATCH}")
-
-set(MONETDB5_VERSION_MAJOR "29")
-set(MONETDB5_VERSION_MINOR "3")
-set(MONETDB5_VERSION_PATCH "0")
-set(MONETDB5_VERSION 
"${MONETDB5_VERSION_MAJOR}.${MONETDB5_VERSION_MINOR}.${MONETDB5_VERSION_PATCH}")
-
-set(STREAM_VERSION_MAJOR "13")
-set(STREAM_VERSION_MINOR "5")
-set(STREAM_VERSION_PATCH "0")
-set(STREAM_VERSION 
"${STREAM_VERSION_MAJOR}.${STREAM_VERSION_MINOR}.${STREAM_VERSION_PATCH}")
-
 set(MONETDB_VERSION_MAJOR "11")
 set(MONETDB_VERSION_MINOR "38")
 set(MONETDB_VERSION_PATCH "0")
@@ -42,3 +22,64 @@ if(RELEASE_VERSION)
 #  set(MONETDB_RELEASE "unreleased")
 endif()
 set(MONETDB_VERSION 
"${MONETDB_VERSION_MAJOR}.${MONETDB_VERSION_MINOR}.${MONETDB_VERSION_PATCH}")
+
+# Version numbers for the shared libraries that we provide
+# the numbers are: ::
+# The scheme used here comes from libtool but is also usable in the
+# current context.
+# These numbers must be changed according to the following rules
+# (follow them all in order):
+
+#   1. Update the version information only immediately before a public
+#  release.
+#   2. If the library source code has changed at all since the last
+#  update, then increment REVISION (`C:R:A' becomes `C:r+1:A').
+#   3. If any interfaces have been added, removed, or changed since the
+#  last update, increment CURRENT, and set REVISION to 0.
+#   4. If any interfaces have been added since the last public release,
+#  then increment AGE.
+#   5. If any interfaces have been removed or changed since the last
+#  public release, then set AGE to 0.
+
+# In other words
+# X   if there are no code changes, don't change version numbers;
+# FIX if there are changes to the code (bug fixes) but no API changes,
+# just increment REVISION;
+# NEW if there are only backward compatible API changes (new
+# interfaces), increment both CURRENT and AGE, and set REVISION to
+# 0;
+# BRK if there are also incompatible API changes (interfaces removed or
+# changed), increment CURRENT, and set AGE and REVISION to 0.
+# IMPORTANT: also change debian package names for the relevant
+# library.  This involves renaming the file in debian/ and
+# updating references to the package in debian/control.  The version
+# number should match the ELF SONAME
+
+# version of the GDK library (subdirectory gdk; also includes
+# common/options and common/utils)
+set(GDK_VERSION_CURRENT "20")
+set(GDK_VERSION_REVISION "3")
+set(GDK_VERSION_AGE "0")
+math(EXPR GDK_VERSION_MAJOR "${GDK_VERSION_CURRENT} - ${GDK_VERSION_AGE}")
+set(GDK_VERSION 
"${GDK_VERSION_MAJOR}.${GDK_VERSION_AGE}.${GDK_VERSION_REVISION}")
+
+# version of the MAPI library (subdirectory clients/mapilib)
+set(MAPI_VERSION_CURRENT "12")
+set(MAPI_VERSION_REVISION "4")
+set(MAPI_VERSION_AGE "0")
+math(EXPR MAPI_VERSION_MAJOR "${MAPI_VERSION_CURRENT} - ${MAPI_VERSION_AGE}")
+set(MAPI_VERSION 
"${MAPI_VERSION_MAJOR}.${MAPI_VERSION_AGE}.${MAPI_VERSION_REVISION}")
+
+# version of the MONETDB5 library (subdirectory monetdb5, not including extras 
or sql)
+set(MONETDB5_VERSION_CURRENT "29")
+set(MONETDB5_VERSION_REVISION "3")
+set(MONETDB5_VERSION_AGE "0")
+math(EXPR MONETDB5_VERSION_MAJOR "${MONETDB5_VERSION_CURRENT} - 
${MONETDB5_VERSION_AGE}")
+set(MONETDB5_VERSION 
"${MONETDB5_VERSION_MAJOR}.${MONETDB5_VERSION_AGE}.${MONETDB5_VERSION_REVISION}")
+
+# version of the STREAM library (subdirectory common/stream)
+set(STREAM_VERSION_CURRENT "13")
+set(STREAM_VERSION_REVISION "5")
+set(STREAM_VERSION_AGE "0")
+math(EXPR STREAM_VERSION_MAJOR "${STREAM_VERSION_CURRENT} - 
${STREAM_VERSION_AGE}")
+set(STREAM_VERSION 
"${STREAM_VERSION_MAJOR}.${STREAM_VERSION_AGE}.${STREAM_VERSION_REVISION}")
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- 

MonetDB: default - Merged with oscar

2020-07-16 Thread Pedro Ferreira
Changeset: a008b844b741 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a008b844b741
Modified Files:
sql/backends/monet5/sql_statement.c
sql/server/rel_optimizer.c
sql/server/sql_atom.c
sql/server/sql_atom.h
sql/server/sql_semantic.c
sql/test/SQLancer/Tests/sqlancer03.sql
sql/test/SQLancer/Tests/sqlancer03.stable.out
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 374 to 300 lines):

diff --git a/sql/backends/monet5/sql_statement.c 
b/sql/backends/monet5/sql_statement.c
--- a/sql/backends/monet5/sql_statement.c
+++ b/sql/backends/monet5/sql_statement.c
@@ -1527,6 +1527,8 @@ stmt_uselect(backend *be, stmt *op1, stm
q = pushArgument(mb, q, l);
if (sub && !op1->cand)
q = pushArgument(mb, q, sub->nr);
+   else
+   sub = NULL;
q = pushArgument(mb, q, r);
q = pushArgument(mb, q, r);
q = pushBit(mb, q, TRUE);
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -1740,6 +1740,11 @@ rel_simplify_count_fk_join(mvc *sql, sql
if (oce->l) /* we only handle COUNT(*) */
return r;
 
+   /* primary side must be a full table */
+   if ((fk_left && (!is_left(r->op) && !is_full(r->op)) && 
!is_basetable(rr->op)) ||
+   (!fk_left && (!is_right(r->op) && !is_full(r->op)) && 
!is_basetable(rl->op)))
+   return r;
+
if (fk_left && is_join(rl->op) && !rel_is_ref(rl)) {
rl = rel_simplify_count_fk_join(sql, rl, gexps, changes);
r->l = rl;
@@ -1748,10 +1753,6 @@ rel_simplify_count_fk_join(mvc *sql, sql
rr = rel_simplify_count_fk_join(sql, rr, gexps, changes);
r->r = rr;
}
-   /* primary side must be a full table */
-   if ((fk_left && (!is_left(r->op) && !is_full(r->op)) && 
!is_basetable(rr->op)) ||
-   (!fk_left && (!is_right(r->op) && !is_full(r->op)) && 
!is_basetable(rl->op)))
-   return r;
 
(*changes)++;
/* rewrite, ie remove pkey side */
diff --git a/sql/server/sql_atom.c b/sql/server/sql_atom.c
--- a/sql/server/sql_atom.c
+++ b/sql/server/sql_atom.c
@@ -417,7 +417,7 @@ atom2string(sql_allocator *sa, atom *a)
 }
 
 char *
-atom2sql(sql_allocator *sa, atom *a)
+atom2sql(sql_allocator *sa, atom *a, int timezone)
 {
sql_class ec = a->tpe.type->eclass;
char buf[BUFSIZ];
@@ -554,22 +554,101 @@ atom2sql(sql_allocator *sa, atom *a)
sprintf(buf, "%f", a->data.val.fval);
break;
case EC_TIME:
+   case EC_TIME_TZ:
case EC_DATE:
case EC_TIMESTAMP:
-   if (a->data.vtype == TYPE_str) {
-   char *val1 = sql_escape_str(sa, a->tpe.type->sqlname), 
*val2 = sql_escape_str(sa, a->data.val.sval), *res;
+   case EC_TIMESTAMP_TZ: {
+   char val1[64], sbuf[64], *val2 = sbuf, *res;
+   size_t len = sizeof(sbuf);
 
-   if (!val1 || !val2) {
-   return NULL;
+   switch (ec) {
+   case EC_TIME:
+   case EC_TIME_TZ:
+   case EC_TIMESTAMP:
+   case EC_TIMESTAMP_TZ: {
+   char *n = stpcpy(val1, (ec == EC_TIME || ec == 
EC_TIME_TZ) ? "TIME" : "TIMESTAMP");
+   if (a->tpe.digits) {
+   char str[16];
+   sprintf(str, "%u", a->tpe.digits);
+   n = stpcpy(stpcpy(stpcpy(n, " ("), str), ")");
}
+   if (ec == EC_TIME_TZ || ec == EC_TIMESTAMP_TZ)
+   stpcpy(n, " WITH TIME ZONE");
+   } break;
+   case EC_DATE:
+   strcpy(val1, "DATE");
+   break;
+   default:
+   assert(0);
+   }
+
+   switch (ec) {
+   case EC_TIME:
+   case EC_TIME_TZ: {
+   daytime dt = a->data.val.lval;
+   int digits = a->tpe.digits ? a->tpe.digits - 1 : 0;
+   char *s = val2;
+   ssize_t lens;
+
+   if (ec == EC_TIME_TZ)
+   dt = daytime_add_usec_modulo(dt, timezone * 
1000);
+   if ((lens = daytime_precision_tostr(, , dt, 
digits, true)) < 0)
+   assert(0);
+
+   if (ec == EC_TIME_TZ) {
+   lng timezone_hours = llabs(timezone / 6);
+   char *end = sbuf + sizeof(sbuf) - 1;
 
-   if ((res = 

MonetDB: default - Merged with oscar

2020-07-15 Thread Pedro Ferreira
Changeset: 5d5946303e35 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5d5946303e35
Modified Files:
sql/storage/store.c
sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out

sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.stable.out
sql/test/miscellaneous/Tests/groupby_error.stable.out
Branch: default
Log Message:

Merged with oscar


diffs (111 lines):

diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -4611,13 +4611,18 @@ validate_tables(sql_schema *s, sql_schem
if (cs_size(>tables))
for (n = s->tables.set->h; n; n = n->next) {
sql_table *t = n->data;
-   sql_table *ot;
+   sql_table *ot = NULL;
 
if (!t->base.wtime && !t->base.rtime)
continue;
 
-   ot = find_sql_table(os, t->base.name);
-   if (ot && isKindOfTable(ot) && isKindOfTable(t) && 
!isDeclaredTable(ot) && !isDeclaredTable(t)) {
+   o = list_find_base_id(os->tables.set, t->base.id);
+   if (o)
+   ot = o->data;
+   if (!ot && os->tables.dset && 
list_find_base_id(os->tables.dset, t->base.id) != NULL) {
+   /* dropped table */
+   return 0;
+   } else if (ot && isKindOfTable(ot) && isKindOfTable(t) 
&& !isDeclaredTable(ot) && !isDeclaredTable(t)) {
if ((t->base.wtime && (t->base.wtime < 
ot->base.rtime || t->base.wtime < ot->base.wtime)) ||
(t->base.rtime && (t->base.rtime < 
ot->base.wtime)))
return 0;
@@ -4876,7 +4881,8 @@ reset_table(sql_trans *tr, sql_table *ft
ft->access = pft->access;
if (pft->p) {
ft->p = find_sql_table(ft->s, pft->p->base.name);
-   assert(isMergeTable(ft->p) || isReplicaTable(ft->p));
+   //the parent (merge or replica table) maybe created 
later!
+   //assert(isMergeTable(ft->p) || isReplicaTable(ft->p));
} else
ft->p = NULL;
 
diff --git a/sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out 
b/sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out
--- a/sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out
+++ b/sql/test/BugTracker-2015/Tests/crash.Bug-3736.stable.out
@@ -97,7 +97,7 @@ single project (
 | ) [ "o"."open_auction_id" NOT NULL * = "%32"."%32" NOT NULL ]
 ) [ "o"."id" NOT NULL HASHCOL , "o"."open_auction_id" NOT NULL, "o"."initial" 
NOT NULL, "o"."reserve" NOT NULL, "o"."aktuell" NOT NULL, "o"."privacy" NOT 
NULL, "o"."itemref" NOT NULL, "o"."seller" NOT NULL, "o"."quantity" NOT NULL, 
"o"."type" NOT NULL, "o"."start" NOT NULL, "o"."ende" NOT NULL, "o"."%TID%" NOT 
NULL, "b"."id" NOT NULL HASHCOL , "b"."open_auction_id" NOT NULL, "b"."date" 
NOT NULL, "b"."time" NOT NULL, "b"."personref" NOT NULL, "b"."increase" NOT 
NULL, "b"."%TID%" NOT NULL, "b3"."increase" NOT NULL as "%2"."%2" ]
 project (
-| select (
+| single select (
 | | single join (
 | | | & REF 2 ,
 | | | project (
diff --git 
a/sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.stable.out
 
b/sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.stable.out
--- 
a/sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.stable.out
+++ 
b/sql/test/BugTracker-2018/Tests/count_from_commented_function_signatures.Bug-6542.stable.out
@@ -92,29 +92,25 @@ project (
 | | | | | project (
 | | | | | | project (
 | | | | | | | project (
-| | | | | | | | project (
-| | | | | | | | | project (
-| | | | | | | | | | left outer join (
-| | | | | | | | | | | left outer join (
-| | | | | | | | | | | | join (
-| | | | | | | | | | | | | join (
-| | | | | | | | | | | | | | table(sys.functions) [ "functions"."id" as 
"f"."id", "functions"."schema_id" as "f"."schema_id" ] COUNT ,
-| | | | | | | | | | | | | | table(sys.comments) [ "comments"."id" NOT NULL 
HASHCOL  as "c"."id" ] COUNT 
-| | | | | | | | | | | | | ) [ "f"."id" = "c"."id" NOT NULL HASHCOL  ],
-| | | | | | | | | | | | | table(sys.schemas) [ "schemas"."id" as "s"."id" ] 
COUNT 
-| | | | | | | | | | | | ) [ "f"."schema_id" = "s"."id" ],
-| | | | | | | | | | | | select (
-| | | | | | | | | | | | | table(sys.functions) [ "functions"."id", 
"functions"."system" ] COUNT 
-| | | | | | | | | | | | ) [ "functions"."system" = boolean "true" ]
-| | | | | | | | | | | ) [ "f"."id" = "functions"."id" ],
-| | | | | | | | | | | select (
-| | | | | | | | | | | | table(sys.args) [ "args"."func_id" as "p"."func_id", 
"args"."inout" as "p"."inout", "args"."number" as "p"."number" 

MonetDB: default - Merged with oscar

2020-07-13 Thread Pedro Ferreira
Changeset: 660945657d8b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=660945657d8b
Modified Files:
sql/common/sql_list.c
sql/include/sql_list.h
sql/server/rel_optimizer.c
sql/server/rel_rel.c
sql/server/rel_rel.h
sql/server/rel_rewriter.c
sql/server/rel_rewriter.h
sql/server/rel_unnest.c
sql/test/miscellaneous/Tests/groupby_error.stable.out
sql/test/miscellaneous/Tests/simple_plans.stable.out
sql/test/miscellaneous/Tests/simple_plans.stable.out.single
testing/Mtest.py.bat
testing/Mtest.py.in
Branch: default
Log Message:

Merged with oscar


diffs (72 lines):

diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -1652,7 +1652,6 @@ rel_push_count_down(visitor *v, sql_rel 
return rel;
 }
 
-
 static sql_rel *
 rel_simplify_project_fk_join(mvc *sql, sql_rel *r, list *pexps, int *changes)
 {
@@ -3684,7 +3683,6 @@ merge_notequal(mvc *sql, list *exps, int
return nexps;
 }
 
-
 static sql_rel *
 rel_select_cse(visitor *v, sql_rel *rel)
 {
diff --git a/testing/Mtest.py.bat b/testing/Mtest.py.bat
--- a/testing/Mtest.py.bat
+++ b/testing/Mtest.py.bat
@@ -4,4 +4,4 @@
 @REM
 @REM Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V.
 
-@python3 "%~dpn0" %*
+@python "%~dpn0" %*
diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -104,22 +104,37 @@ if isatty:
 left, top, right, bottom, maxx, maxy) = 
struct.unpack("Hhh", csbi.raw)
 return wattr
 reset = get_csbi_attributes(handle)
-def prred(str, write = sys.stdout.write, scta = 
ctypes.windll.kernel32.SetConsoleTextAttribute):
+def prred(str,
+  write=sys.stdout.write,
+  flush=sys.stdout.flush,
+  scta=ctypes.windll.kernel32.SetConsoleTextAttribute):
 try:
+flush()
 scta(handle, 0x4)
 write(str)
+flush()
 finally:
 scta(handle, reset)
-def prgreen(str, write = sys.stdout.write, scta = 
ctypes.windll.kernel32.SetConsoleTextAttribute):
+def prgreen(str,
+write=sys.stdout.write,
+flush=sys.stdout.flush,
+
scta=ctypes.windll.kernel32.SetConsoleTextAttribute):
 try:
+flush()
 scta(handle, 0x2)
 write(str)
+flush()
 finally:
 scta(handle, reset)
-def prpurple(str, write = sys.stdout.write, scta = 
ctypes.windll.kernel32.SetConsoleTextAttribute):
+def prpurple(str,
+ write=sys.stdout.write,
+ flush=sys.stdout.flush,
+ 
scta=ctypes.windll.kernel32.SetConsoleTextAttribute):
 try:
+flush()
 scta(handle, 0x5)
 write(str)
+flush()
 finally:
 scta(handle, reset)
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Merged with oscar

2020-07-13 Thread Pedro Ferreira
Changeset: 6ff09b4366ee for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6ff09b4366ee
Modified Files:
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_scenario.c
sql/server/rel_dump.c
sql/server/rel_exp.c
sql/server/rel_exp.h
sql/server/rel_optimizer.c
sql/server/rel_rel.c
sql/server/rel_rel.h
sql/server/rel_select.c
sql/server/rel_unnest.c
sql/server/rel_updates.c
sql/server/sql_atom.c
sql/storage/bat/bat_storage.c
sql/storage/store.c
sql/test/BugTracker-2016/Tests/storagemodel.stable.out
sql/test/SQLancer/Tests/sqlancer03.stable.out
sql/test/subquery/Tests/subquery6.stable.out
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 875 to 300 lines):

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
@@ -3716,13 +3716,13 @@ insert_check_ukey(backend *be, list *ins
stmt *sel = NULL;
 
/* remove any nils as in stmt_order NULL = NULL, 
instead of NULL != NULL */
-   if ((k->type == ukey) && stmt_has_null(col)) {
-
+   if (k->type == ukey) {
for (m = k->columns->h; m; m = m->next) {
sql_kc *c = m->data;
stmt *cs = list_fetch(inserts, 
c->c->colnr);
 
-   sel = stmt_selectnonil(be, cs, sel);
+   if (stmt_has_null(cs))
+   sel = stmt_selectnonil(be, cs, 
sel);
}
}
/* implementation uses sort key check */
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
@@ -1162,10 +1162,12 @@ SQLparser(Client c)
msg = SQLoptimizeQuery(c, c->curprg->def);
 
if (msg != MAL_SUCCEED) {
+   str other = c->curprg->def->errors;
c->curprg->def->errors = 0;
MSresetInstructions(c->curprg->def, 
oldstop);
freeVariables(c, c->curprg->def, NULL, 
oldvtop);
-   sqlcleanup(be, err);
+   if (other != msg)
+   freeException(other);
goto finalize;
}
}
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
@@ -1805,7 +1805,7 @@ rel_read(mvc *sql, char *r, int *pos, li
if (!(exps = read_exps(sql, NULL, NULL, NULL, r, pos, '[', 0)))
return NULL;
rel = rel_setop(sql->sa, lrel, rrel, j);
-   rel->exps = exps;
+   rel_setop_set_exps(sql, rel, exps);
if (rel_set_types(sql, rel) < 0)
return sql_error(sql, -1, SQLSTATE(42000) "Setop: 
number of expressions don't match\n");
set_processed(rel);
diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -701,16 +701,16 @@ exp_alias_or_copy( mvc *sql, const char 
tname = exp_relname(old);
 
if (!cname && exp_name(old) && has_label(old)) {
-   ne = exp_column(sql->sa, exp_relname(old), exp_name(old), 
exp_subtype(old), orel?orel->card:CARD_ATOM, has_nil(old), is_intern(old));
+   ne = exp_column(sql->sa, exp_relname(old), exp_name(old), 
exp_subtype(old), orel && old->card != CARD_ATOM?orel->card:CARD_ATOM, 
has_nil(old), is_intern(old));
return exp_propagate(sql->sa, ne, old);
} else if (!cname) {
exp_label(sql->sa, old, ++sql->label);
-   ne = exp_column(sql->sa, exp_relname(old), exp_name(old), 
exp_subtype(old), orel?orel->card:CARD_ATOM, has_nil(old), is_intern(old));
+   ne = exp_column(sql->sa, exp_relname(old), exp_name(old), 
exp_subtype(old), orel && old->card != CARD_ATOM?orel->card:CARD_ATOM, 
has_nil(old), is_intern(old));
return exp_propagate(sql->sa, ne, old);
} else if (cname && !old->alias.name) {
exp_setname(sql->sa, old, tname, cname);
}
-   ne = exp_column(sql->sa, tname, cname, exp_subtype(old), 
orel?orel->card:CARD_ATOM, has_nil(old), is_intern(old));
+   ne = exp_column(sql->sa, tname, cname, exp_subtype(old), orel && 
old->card != CARD_ATOM?orel->card:CARD_ATOM, 

MonetDB: default - Merged with oscar

2020-07-10 Thread Pedro Ferreira
Changeset: e1b8f3977a5f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e1b8f3977a5f
Added Files:

sql/test/BugDay_2005-10-06_2.9.3/Tests/parser_crashes_server.SF-921996.stable.err.Darwin
Modified Files:
gdk/gdk_system.h
monetdb5/mal/mal_prelude.c
monetdb5/mal/mel.h
sql/server/rel_optimizer.c
sql/server/rel_select.c
sql/test/SQLancer/Tests/sqlancer03.sql
sql/test/SQLancer/Tests/sqlancer03.stable.out
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 454 to 300 lines):

diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -34,6 +34,7 @@
 #define __has_attribute__alloc_size__ 1
 #define __has_attribute__cold__ 1
 #define __has_attribute__format__ 1
+#define __has_attribute__designated_init__ 0
 #define __has_attribute__malloc__ 1
 #define __has_attribute__nonstring__ 0
 #define __has_attribute__noreturn__ 1
@@ -65,6 +66,9 @@
 #if !__has_attribute(__pure__)
 #define __pure__
 #endif
+#if !__has_attribute(__designated_init__)
+#define __designated_init__
+#endif
 /* these are used in some *private.h files */
 #if !__has_attribute(__visibility__)
 #define __visibility__(a)
diff --git a/monetdb5/mal/mal_prelude.c b/monetdb5/mal/mal_prelude.c
--- a/monetdb5/mal/mal_prelude.c
+++ b/monetdb5/mal/mal_prelude.c
@@ -10,7 +10,7 @@
  * This module takes the statically defined modules, atoms, commands and 
patterns
  * and populate the internal structures.
  *
-*/
+ */
 
 #include "monetdb_config.h"
 #include "mal_import.h"
@@ -39,10 +39,10 @@ mal_startup(void)
 }
 
 /* all MAL related functions register themselves
-* the order in which these registrations happen is significant
-* because there may be dependencies among the definitions.
-* For example, you better know the atoms before you use them
-*/
+ * the order in which these registrations happen is significant
+ * because there may be dependencies among the definitions.
+ * For example, you better know the atoms before you use them
+ */
 
 void
 mal_module2(str name, mel_atom *atoms, mel_func *funcs, mel_init initfunc, 
const char *code)
@@ -80,16 +80,16 @@ initModule(Client c, char *name)
if (s) {
InstrPtr pci = getInstrPtr(s->def, 0);
 
-   if (pci && pci->token == COMMANDsymbol && 
pci->argc == 1) {
-   int ret = 0;
+   if (pci && pci->token == COMMANDsymbol && pci->argc == 
1) {
+   int ret = 0;
 
-   assert(pci->fcn != NULL);
-   (*pci->fcn)();
-   (void)ret;
-   } else if (pci && pci->token == PATTERNsymbol) {
-   assert(pci->fcn != NULL);
-   (*pci->fcn)(c, NULL, NULL, NULL);
-   }
+   assert(pci->fcn != NULL);
+   (*pci->fcn)();
+   (void)ret;
+   } else if (pci && pci->token == PATTERNsymbol) {
+   assert(pci->fcn != NULL);
+   (*pci->fcn)(c, NULL, NULL, NULL);
+   }
}
}
 }
@@ -184,14 +184,14 @@ makeArgument(MalBlkPtr mb, mel_arg *a, i
tpe = newBatType(tpe);
}
/*
-   if (a->name){
-   *idx = findVariableLength(mb, a->name, l = strlen(a->name));
-   if( *idx != -1)
-   throw(LOADER, "addFunctions", "Duplicate argument name 
%s", a->name);
-   *idx = newVariable(mb, a->name, l, tpe);
-   } else
+ if (a->name){
+ *idx = findVariableLength(mb, a->name, l = strlen(a->name));
+ if( *idx != -1)
+ throw(LOADER, "addFunctions", "Duplicate argument name %s", a->name);
+ *idx = newVariable(mb, a->name, l, tpe);
+ } else
*/
-   *idx = newTmpVariable(mb, tpe);
+   *idx = newTmpVariable(mb, tpe);
return MAL_SUCCEED;
 }
 
@@ -251,11 +251,11 @@ addFunctions(mel_func *fcn){
if (a->nr > 0) {
if (a->isbat)
tpe = newBatType(tpe);
-   setPolymorphic(sig, tpe, TRUE);
+   setPolymorphic(sig, tpe, TRUE);
}
if (a->vargs) {
-   sig->varargs |= VARRETS;
-   setPolymorphic(sig, TYPE_any, TRUE);
+   sig->varargs |= VARRETS;
+   setPolymorphic(sig, TYPE_any, TRUE);
}
}
/* add the arguments */
@@ -272,11 +272,11 @@ 

MonetDB: default - Merged with oscar

2020-07-10 Thread Pedro Ferreira
Changeset: 563c611e4168 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=563c611e4168
Modified Files:
gdk/gdk_bbp.c
sql/server/sql_atom.c
testing/mktest.py
testing/sqllogictest.py
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 338 to 300 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -504,6 +504,12 @@ fixdateheap(BAT *b, const char *anme)
bnme = nme;
sprintf(filename, "BACKUP%c%s", DIR_SEP, bnme);
 
+   /* we don't maintain index structures */
+   HASHdestroy(b);
+   IMPSdestroy(b);
+   OIDXdestroy(b);
+   PROPdestroy(b);
+
/* make backup of heap */
if (GDKmove(b->theap.farmid, srcdir, bnme, "tail", BAKDIR, bnme, 
"tail") != GDK_SUCCEED) {
GDKfree(srcdir);
@@ -661,18 +667,11 @@ fixdatebats(void)
}
fclose(fp);
}
-   /* The date type is not known in GDK when reading the BBP */
-   if (b->ttype < 0) {
-   const char *anme;
-
-   /* as yet unknown tail column type */
-   anme = ATOMunknown_name(b->ttype);
-   /* known string types */
-   if ((strcmp(anme, "date") == 0 ||
-strcmp(anme, "timestamp") == 0 ||
-strcmp(anme, "daytime") == 0) &&
-   fixdateheap(b, anme) != GDK_SUCCEED)
-   return GDK_FAIL;
+   if ((b->ttype == TYPE_date ||
+b->ttype == TYPE_timestamp ||
+b->ttype == TYPE_daytime) &&
+   fixdateheap(b, ATOMname(b->ttype)) != GDK_SUCCEED) {
+   return GDK_FAIL;
}
}
return GDK_SUCCEED;
diff --git a/sql/server/sql_atom.c b/sql/server/sql_atom.c
--- a/sql/server/sql_atom.c
+++ b/sql/server/sql_atom.c
@@ -1329,67 +1329,7 @@ atom_is_zero(atom *a)
 {
if (a->isnull)
return 0;
-   switch (a->tpe.type->localtype) {
-   case TYPE_bte:
-   return a->data.val.btval == 0;
-   case TYPE_sht:
-   return a->data.val.shval == 0;
-   case TYPE_int:
-   return a->data.val.ival == 0;
-   case TYPE_lng:
-   return a->data.val.lval == 0;
-#ifdef HAVE_HGE
-   case TYPE_hge:
-   return a->data.val.hval == 0;
-#endif
-   case TYPE_flt:
-   return a->data.val.fval == 0;
-   case TYPE_dbl:
-   return a->data.val.dval == 0;
-   default:
-   break;
-   }
-   return 0;
-}
-
-int
-atom_is_true(atom *a)
-{
-   if (a->isnull)
-   return 0;
-   switch (a->tpe.type->localtype) {
-   case TYPE_bit:
-   return a->data.val.btval != 0;
-   case TYPE_bte:
-   return a->data.val.btval != 0;
-   case TYPE_sht:
-   return a->data.val.shval != 0;
-   case TYPE_int:
-   return a->data.val.ival != 0;
-   case TYPE_lng:
-   return a->data.val.lval != 0;
-#ifdef HAVE_HGE
-   case TYPE_hge:
-   return a->data.val.hval != 0;
-#endif
-   case TYPE_flt:
-   return a->data.val.fval != 0;
-   case TYPE_dbl:
-   return a->data.val.dval != 0;
-   default:
-   break;
-   }
-   return 0;
-}
-
-int
-atom_is_false( atom *a )
-{
-   if (a->isnull)
-   return 0;
-   switch(a->tpe.type->localtype) {
-   case TYPE_bit:
-   return a->data.val.btval == 0;
+   switch (ATOMstorage(a->tpe.type->localtype)) {
case TYPE_bte:
return a->data.val.btval == 0;
case TYPE_sht:
@@ -1407,9 +1347,66 @@ atom_is_false( atom *a )
case TYPE_dbl:
return a->data.val.dval == 0;
default:
-   break;
+   return 0;
}
-   return 0;
+}
+
+int
+atom_is_true(atom *a)
+{
+   if (a->isnull)
+   return 0;
+   switch (ATOMstorage(a->tpe.type->localtype)) {
+   case TYPE_bte:
+   return a->data.val.btval != 0;
+   case TYPE_sht:
+   return a->data.val.shval != 0;
+   case TYPE_int:
+   return a->data.val.ival != 0;
+   case TYPE_lng:
+   return a->data.val.lval != 0;
+#ifdef HAVE_HGE
+   case TYPE_hge:
+   return a->data.val.hval != 0;
+#endif
+   case TYPE_flt:
+   return a->data.val.fval != 0;
+   case TYPE_dbl:
+   return a->data.val.dval != 0;
+   case TYPE_str:
+   return strcmp(a->data.val.sval, "") != 0;
+   default:
+   return 0;
+   }
+}
+
+int
+atom_is_false(atom *a)
+{
+   if (a->isnull)
+   return 0;
+   switch 

MonetDB: default - Merged with oscar

2020-07-09 Thread Pedro Ferreira
Changeset: f267f9421fd5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f267f9421fd5
Modified Files:
sql/server/rel_select.c
sql/test/SQLancer/Tests/sqlancer03.sql
sql/test/SQLancer/Tests/sqlancer03.stable.out
Branch: default
Log Message:

Merged with oscar


diffs (91 lines):

diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -2079,9 +2079,17 @@ negate_symbol_tree(mvc *sql, symbol *sc)
case SQL_IS_NOT_NULL:
sc->token = SQL_IS_NULL;
break;
-   case SQL_NOT: /* nested NOTs eliminate each other */
-   memmove(sc, sc->data.sym, sizeof(symbol));
-   break;
+   case SQL_NOT: { /* nested NOTs eliminate each other */
+   if (sc->data.sym->token == SQL_ATOM) {
+   AtomNode *an = (AtomNode*) sc->data.sym;
+   memmove(sc, an, sizeof(AtomNode));
+   } else if (sc->data.sym->token == SQL_SELECT) {
+   SelectNode *sn = (SelectNode*) sc->data.sym;
+   memmove(sc, sn, sizeof(SelectNode));
+   } else {
+   memmove(sc, sc->data.sym, sizeof(symbol));
+   }
+   } break;
case SQL_COMPARE: {
dnode *cmp_n = sc->data.lval->h;
comp_type neg_cmp_type = 
negate_compare(compare_str2type(cmp_n->next->data.sval)); /* negate the 
comparator */
@@ -2094,8 +2102,7 @@ negate_symbol_tree(mvc *sql, symbol *sc)
negate_symbol_tree(sql, sc->data.lval->h->data.sym);
negate_symbol_tree(sql, sc->data.lval->h->next->data.sym);
sc->token = sc->token == SQL_AND ? SQL_OR : SQL_AND;
-   break;
-   }
+   } break;
default:
break;
}
diff --git a/sql/test/SQLancer/Tests/sqlancer03.sql 
b/sql/test/SQLancer/Tests/sqlancer03.sql
--- a/sql/test/SQLancer/Tests/sqlancer03.sql
+++ b/sql/test/SQLancer/Tests/sqlancer03.sql
@@ -127,6 +127,23 @@ false  true23
 DROP TABLE t0;
 
 START TRANSACTION;
+CREATE TABLE "sys"."t0" (
+   "c0" DECIMAL(18,3) NOT NULL DEFAULT 
cast(cast("sys"."sql_sub"("sys"."sql_neg"(1933820187),"sys"."charindex"(cast(0.235784
 as 
clob(182)),"sys"."concat"('rt\\b',1174691962),"sys"."locate"('!oLqvKg恺','!G+tZ9\'A\'LZ*滻mW^',1174691962)))
 as int) as decimal(18,3)),
+   "c1" DECIMAL(18,3),
+   "c2" CHARACTER LARGE OBJECT,
+   CONSTRAINT "t0_c0_pkey" PRIMARY KEY ("c0"),
+   CONSTRAINT "t0_c0_unique" UNIQUE ("c0"),
+   CONSTRAINT "t0_c2_unique" UNIQUE ("c2"),
+   CONSTRAINT "t0_c0_c2_c1_unique" UNIQUE ("c0", "c2", "c1")
+);
+COMMENT ON COLUMN "sys"."t0"."c2" IS 'vi';
+COPY 1 RECORDS INTO "sys"."t0" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+-1933820187.000NULL"-1554387152"
+
+select t0.c0 from t0 where not (true) union all select all t0.c0 from t0 where 
not (not (true)) union all select t0.c0 from t0 where (not (true)) is null;
+ROLLBACK;
+
+START TRANSACTION;
 CREATE TABLE t0 (c0 BOOLEAN);
 create view v1(c0, c1, c2, c3) as (select 1, lower('1'), 1, cot(1) from t0);
 SELECT v1.c0 FROM v1 WHERE v1.c1 LIKE v1.c1 AND v1.c3 BETWEEN v1.c3 AND v1.c3 
= TRUE;
diff --git a/sql/test/SQLancer/Tests/sqlancer03.stable.out 
b/sql/test/SQLancer/Tests/sqlancer03.stable.out
--- a/sql/test/SQLancer/Tests/sqlancer03.stable.out
+++ b/sql/test/SQLancer/Tests/sqlancer03.stable.out
@@ -211,6 +211,26 @@ stdout of test 'sqlancer03` in directory
 #false true23
 [ 14   ]
 #DROP TABLE t0;
+#START TRANSACTION;
+#CREATE TABLE "sys"."t0" (
+#  "c0" DECIMAL(18,3) NOT NULL DEFAULT 
cast(cast("sys"."sql_sub"("sys"."sql_neg"(1933820187),"sys"."charindex"(cast(0.235784
 as 
clob(182)),"sys"."concat"('rt\\b',1174691962),"sys"."locate"('!oLqvKg恺','!G+tZ9\'A\'LZ*滻mW^',1174691962)))
 as int) as decimal(18,3)),
+#  "c1" DECIMAL(18,3),
+#  "c2" CHARACTER LARGE OBJECT,
+#  CONSTRAINT "t0_c0_pkey" PRIMARY KEY ("c0"),
+#  CONSTRAINT "t0_c0_unique" UNIQUE ("c0"),
+#  CONSTRAINT "t0_c2_unique" UNIQUE ("c2"),
+#  CONSTRAINT "t0_c0_c2_c1_unique" UNIQUE ("c0", "c2", "c1")
+#COMMENT ON COLUMN "sys"."t0"."c2" IS 'vi';
+#COPY 1 RECORDS INTO "sys"."t0" FROM stdin USING DELIMITERS E'\t',E'\n','"';
+#-1933820187.000   NULL"-1554387152"
+[ 1]
+#select t0.c0 from t0 where not (true) union all select all t0.c0 from t0 
where not (not (true)) union all select t0.c0 from t0 where (not (true)) is 
null;
+% .%12 # table_name
+% c0 # name
+% decimal # type
+% 20 # length
+[ -1933820187.000  ]
+#ROLLBACK;
 
 # 17:14:16 >  
 # 17:14:16 >  "Done."
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Merged with oscar

2020-07-09 Thread Pedro Ferreira
Changeset: 2ba142f7c7c3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2ba142f7c7c3
Modified Files:
geom/monetdb5/geom.c
monetdb5/optimizer/opt_mergetable.c
sql/backends/monet5/sql_scenario.c
sql/include/sql_catalog.h
sql/server/rel_optimizer.c
testing/mktest.py
testing/sqllogictest.py
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 776 to 300 lines):

diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -6039,7 +6039,362 @@ wkbContains_point(bit *out, wkb **a, dbl
return MAL_SUCCEED;
 }
 
-static const unsigned char geom_functions[] = 
{109,111,100,117,108,101,32,103,101,111,109,59,10,102,117,110,99,116,105,111,110,32,65,115,84,101,120,116,40,119,58,119,107,98,41,32,58,115,116,114,59,10,120,32,58,61,32,84,111,84,101,120,116,40,119,44,48,41,59,10,114,101,116,117,114,110,32,120,59,10,101,110,100,32,65,115,84,101,120,116,59,10,102,117,110,99,116,105,111,110,32,65,115,69,87,75,84,40,119,58,119,107,98,41,32,58,115,116,114,59,10,120,32,58,61,32,84,111,84,101,120,116,40,119,44,49,41,59,10,114,101,116,117,114,110,32,120,59,10,101,110,100,32,65,115,69,87,75,84,59,10,102,117,110,99,116,105,111,110,32,71,101,111,109,70,114,111,109,84,101,120,116,40,119,107,116,58,115,116,114,44,32,115,114,105,100,58,105,110,116,41,32,58,119,107,98,59,32,120,32,58,61,32,70,114,111,109,84,101,120,116,40,119,107,116,44,115,114,105,100,44,48,41,59,10,114,101,116,117,114,110,32,120,59,10,101,110,100,32,71,101,111,109,70,114,111,109,84,101,120,116,59,10,102,117,110,99,116,105,111,110,32,80,111,105,110,
 
116,70,114,111,109,84,101,120,116,40,119,107,116,58,115,116,114,44,32,115,114,105,100,58,105,110,116,41,32,58,119,107,98,59,32,120,32,58,61,32,70,114,111,109,84,101,120,116,40,119,107,116,44,115,114,105,100,44,49,41,59,10,114,101,116,117,114,110,32,120,59,10,101,110,100,32,80,111,105,110,116,70,114,111,109,84,101,120,116,59,10,102,117,110,99,116,105,111,110,32,76,105,110,101,70,114,111,109,84,101,120,116,40,119,107,116,58,115,116,114,44,32,115,114,105,100,58,105,110,116,41,32,58,119,107,98,59,10,120,32,58,61,32,70,114,111,109,84,101,120,116,40,119,107,116,44,115,114,105,100,44,50,41,59,10,114,101,116,117,114,110,32,120,59,10,101,110,100,32,76,105,110,101,70,114,111,109,84,101,120,116,59,10,102,117,110,99,116,105,111,110,32,80,111,108,121,103,111,110,70,114,111,109,84,101,120,116,40,119,107,116,58,115,116,114,44,32,115,114,105,100,58,105,110,116,41,32,58,119,107,98,59,10,120,32,58,61,32,70,114,111,109,84,101,120,116,40,119,107,116,44,115,114,105,100,44,52,41,59,10,114,101,116,117,114
 
,110,32,120,59,10,101,110,100,32,80,111,108,121,103,111,110,70,114,111,109,84,101,120,116,59,10,102,117,110,99,116,105,111,110,32,77,80,111,105,110,116,70,114,111,109,84,101,120,116,40,119,107,116,58,115,116,114,44,32,115,114,105,100,58,105,110,116,41,32,58,119,107,98,59,10,120,32,58,61,32,70,114,111,109,84,101,120,116,40,119,107,116,44,115,114,105,100,44,53,41,59,10,114,101,116,117,114,110,32,120,59,10,101,110,100,32,77,80,111,105,110,116,70,114,111,109,84,101,120,116,59,10,102,117,110,99,116,105,111,110,32,77,76,105,110,101,70,114,111,109,84,101,120,116,40,119,107,116,58,115,116,114,44,32,115,114,105,100,58,105,110,116,41,32,58,119,107,98,59,10,120,32,58,61,32,70,114,111,109,84,101,120,116,40,119,107,116,44,115,114,105,100,44,54,41,59,10,114,101,116,117,114,110,32,120,59,10,101,110,100,32,77,76,105,110,101,70,114,111,109,84,101,120,116,59,10,102,117,110,99,116,105,111,110,32,77,80,111,108,121,70,114,111,109,84,101,120,116,40,119,107,116,58,115,116,114,44,32,115,114,105,100,58,105,
 
110,116,41,32,58,119,107,98,59,10,120,32,58,61,32,70,114,111,109,84,101,120,116,40,119,107,116,44,115,114,105,100,44,55,41,59,10,114,101,116,117,114,110,32,120,59,10,101,110,100,32,77,80,111,108,121,70,114,111,109,84,101,120,116,59,10,102,117,110,99,116,105,111,110,32,71,101,111,109,67,111,108,108,70,114,111,109,84,101,120,116,40,119,107,116,58,115,116,114,44,32,115,114,105,100,58,105,110,116,41,32,58,119,107,98,59,10,120,32,58,61,32,70,114,111,109,84,101,120,116,40,119,107,116,44,115,114,105,100,44,56,41,59,10,114,101,116,117,114,110,32,120,59,10,101,110,100,32,71,101,111,109,67,111,108,108,70,114,111,109,84,101,120,116,59,10,102,117,110,99,116,105,111,110,32,71,101,111,109,70,114,111,109,84,101,120,116,40,119,107,116,58,115,116,114,41,32,58,119,107,98,59,32,120,32,58,61,32,70,114,111,109,84,101,120,116,40,119,107,116,44,48,44,48,41,59,10,114,101,116,117,114,110,32,120,59,10,101,110,100,32,71,101,111,109,70,114,111,109,84,101,120,116,59,10,102,117,110,99,116,105,111,110,32,80,111,1
 

MonetDB: default - Merged with oscar

2020-07-08 Thread Pedro Ferreira
Changeset: c2e4cf271f0c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c2e4cf271f0c
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk_analytic_bounds.c
monetdb5/modules/atoms/str.c
monetdb5/modules/atoms/str.h
monetdb5/modules/kernel/batstr.c
sql/backends/monet5/sql_cast.c
sql/backends/monet5/sql_optimizer.c
sql/backends/monet5/sql_time.c
sql/backends/monet5/sql_upgrades.c
sql/common/sql_types.c
sql/server/rel_optimizer.c
sql/server/rel_rewriter.c
sql/server/rel_rewriter.h
sql/server/rel_unnest.c
sql/storage/bat/bat_storage.c
sql/storage/bat/bat_storage.h
sql/storage/store.c
sql/test/BugTracker-2013/Tests/timestamp.Bug-3401.stable.err
sql/test/BugTracker-2016/Tests/convert-function-test.Bug-3460.stable.err

sql/test/BugTracker-2016/Tests/convert-function-test.Bug-3460.stable.err.int128

sql/test/BugTracker/Tests/inserting_invalid_timestamp.SF-1363557.stable.err
sql/test/miscellaneous/Tests/select_groupby.stable.err
sql/test/pg_regress/Tests/date.stable.err
sql/test/pg_regress/Tests/time.stable.err
sql/test/pg_regress/Tests/timestamp.stable.err
sql/test/pg_regress/Tests/timestamptz.stable.err
sql/test/pg_regress/Tests/timetz.stable.err
sql/test/sys-schema/Tests/systemfunctions.stable.out
sql/test/sys-schema/Tests/systemfunctions.stable.out.int128
sql/test/wlcr/Tests/wlr110.stable.err
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 2427 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1144,46 +1144,6 @@ str STRTail(str *res, const str *arg1, c
 str STRUpper(str *res, const str *arg1);
 str STRWChrAt(int *res, const str *arg1, const int *at);
 str STRascii(int *ret, const str *s);
-str STRbatBytes(bat *ret, const bat *l);
-str STRbatLength(bat *ret, const bat *l);
-str STRbatLower(bat *ret, const bat *l);
-str STRbatLpad2_bat_bat(bat *ret, const bat *l, const bat *n, const bat *l2);
-str STRbatLpad2_bat_const(bat *ret, const bat *l, const bat *n, const str *s2);
-str STRbatLpad2_const_bat(bat *ret, const bat *l, const int *n, const bat *l2);
-str STRbatLpad2_const_const(bat *ret, const bat *l, const int *n, const str 
*s2);
-str STRbatLpad_bat(bat *ret, const bat *l, const bat *n);
-str STRbatLpad_const(bat *ret, const bat *l, const int *n);
-str STRbatLtrim(bat *ret, const bat *l);
-str STRbatLtrim2_bat(bat *ret, const bat *l, const bat *l2);
-str STRbatLtrim2_const(bat *ret, const bat *l, const str *s2);
-str STRbatPrefix(bat *ret, const bat *l, const bat *r);
-str STRbatPrefixcst(bat *ret, const bat *l, const str *cst);
-str STRbatRpad2_bat_bat(bat *ret, const bat *l, const bat *n, const bat *l2);
-str STRbatRpad2_bat_const(bat *ret, const bat *l, const bat *n, const str *s2);
-str STRbatRpad2_const_bat(bat *ret, const bat *l, const int *n, const bat *l2);
-str STRbatRpad2_const_const(bat *ret, const bat *l, const int *n, const str 
*s2);
-str STRbatRpad_bat(bat *ret, const bat *l, const bat *n);
-str STRbatRpad_const(bat *ret, const bat *l, const int *n);
-str STRbatRstrSearch(bat *ret, const bat *l, const bat *r);
-str STRbatRstrSearchcst(bat *ret, const bat *l, const str *cst);
-str STRbatRtrim(bat *ret, const bat *l);
-str STRbatRtrim2_bat(bat *ret, const bat *l, const bat *l2);
-str STRbatRtrim2_const(bat *ret, const bat *l, const str *s2);
-str STRbatStrip(bat *ret, const bat *l);
-str STRbatStrip2_bat(bat *ret, const bat *l, const bat *l2);
-str STRbatStrip2_const(bat *ret, const bat *l, const str *s2);
-str STRbatSubstitutecst(bat *ret, const bat *l, const str *arg2, const str 
*arg3, const bit *rep);
-str STRbatSuffix(bat *ret, const bat *l, const bat *r);
-str STRbatSuffixcst(bat *ret, const bat *l, const str *cst);
-str STRbatTail(bat *ret, const bat *l, const bat *r);
-str STRbatTailcst(bat *ret, const bat *l, const int *cst);
-str STRbatUpper(bat *ret, const bat *l);
-str STRbatWChrAt(bat *ret, const bat *l, const bat *r);
-str STRbatWChrAtcst(bat *ret, const bat *l, const int *cst);
-str STRbatstrSearch(bat *ret, const bat *l, const bat *r);
-str STRbatstrSearchcst(bat *ret, const bat *l, const str *cst);
-str STRbatsubstring(bat *ret, const bat *l, const bat *r, const bat *t);
-str STRbatsubstringcst(bat *ret, const bat *bid, const int *start, const int 
*length);
 str STRinsert(str *ret, const str *s, const int *start, const int *l, const 
str *s2);
 str STRlikewrap(bit *ret, const str *s, const str *pat, const str *esc);
 str STRlikewrap2(bit *ret, const str *s, const str *pat);
@@ -1872,8 +1832,6 @@ str stopTrace(Client cntxt);
 str stoptraceRef;
 void strAfterCall(ValPtr v, ValPtr bak);
 void strBeforeCall(ValPtr v, ValPtr bak);
-str strEpilogue(void *ret);
-str 

MonetDB: default - Merged with oscar

2020-07-07 Thread Pedro Ferreira
Changeset: 8b1a2f29421d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8b1a2f29421d
Added Files:
README.rst
Removed Files:
README
documentation/old/README.rst
Modified Files:
sql/server/rel_optimizer.c
sql/test/SQLancer/Tests/sqlancer03.sql
sql/test/SQLancer/Tests/sqlancer03.stable.out
sql/test/mergetables/Tests/sqlsmith-exists2.sql
sql/test/mergetables/Tests/sqlsmith-exists2.stable.out
sql/test/miscellaneous/Tests/simple_plans.stable.out
sql/test/miscellaneous/Tests/simple_plans.stable.out.single
sql/test/xquery/Tests/q01.stable.out
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 383 to 300 lines):

diff --git a/README b/README
deleted file mode 100644
--- a/README
+++ /dev/null
@@ -1,22 +0,0 @@
-The MonetDB Database System
-
-The MonetDB database is developed by the CWI database research group
-(see https://www.monetdb.org/).
-
-Via the MonetDB project we have brought the MonetDB system in open source,
-where it is accessible at https://www.monetdb.org/Downloads/
-
-The MonetDB database system is a high-performance database kernel for
-query-intensive applications. The MonetDB source can be found at our mercurial 
server (https://dev.monetdb.org/hg/MonetDB/). There is also a github clone 
(https://github.com/MonetDB/MonetDB) that is updated once a day.
-
-If you got a source distribution, please compile and install MonetDB first,
-following the instructions in the "documentation" directory.
-
-
-Copyright Notice
-
-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 - 2020 MonetDB B.V.
diff --git a/documentation/old/README.rst b/README.rst
rename from documentation/old/README.rst
rename to README.rst
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -1449,6 +1449,9 @@ exp_push_single_func_down(visitor *v, sq
}
} break;
case e_convert:
+   if ((e->l = exp_push_single_func_down(v, rel, l, r, e->l)) == 
NULL)
+   return NULL;
+   break;
case e_aggr:
case e_func: {
int must = 0, mustl = 0, mustr = 0;
@@ -3751,6 +3754,7 @@ rel_project_cse(visitor *v, sql_rel *rel
sql_exp *ne = 
exp_alias(v->sql->sa, exp_relname(e1), exp_name(e1), exp_relname(e2), 
exp_name(e2), exp_subtype(e2), e2->card, has_nil(e2), is_intern(e1));
 
ne = exp_propagate(v->sql->sa, 
ne, e1);
+   exp_setname(v->sql->sa, ne, 
exp_relname(e1), exp_name(e1));
e1 = ne;
break;
}
diff --git a/sql/test/SQLancer/Tests/sqlancer03.sql 
b/sql/test/SQLancer/Tests/sqlancer03.sql
--- a/sql/test/SQLancer/Tests/sqlancer03.sql
+++ b/sql/test/SQLancer/Tests/sqlancer03.sql
@@ -66,20 +66,20 @@ select "insert"('屁{珙', 1, 1, '1'), "insert"('屁{珙', 1, 1, 
'抔'), "insert"('屁抔珙', 1, 1, 'ಜ'), "insert"('a', 0, 1, 'ಜ'), "insert"('a', 0, 0, 
'ಜ');
 select "insert"('屁{珙', 1, 1, '1'), "insert"('屁{珙', 1, 1, '抔'), "insert"('屁抔珙', 
1, 1, 'ಜ') from t0;
 ROLLBACK;
 
-CREATE TABLE t0(c0 boolean, c1 boolean, c2 serial, UNIQUE(c0, c1)); -- Bug 6920
-INSERT INTO t0(c1) VALUES((0.5968066098520423) NOT  BETWEEN SYMMETRIC 
(CAST(length(upper(r'z')) AS INT)) AND (1347145665)), (FALSE);
+CREATE TABLE t0(c0 boolean, c1 boolean, c2 int, UNIQUE(c0, c1)); -- Bug 6920
+INSERT INTO t0(c1) VALUES((0.5) NOT  BETWEEN SYMMETRIC 
(CAST(length(upper(r'z')) AS INT)) AND (2)), (FALSE);
 INSERT INTO t0(c0) VALUES(TRUE);
 INSERT INTO t0(c1) VALUES(FALSE), (TRUE);
-INSERT INTO t0(c2, c0, c1) VALUES(1347145665, (ltrim(lower(r'K'), 
((upper(r'296348087'))||(- (1582370739) IS NOT NULL, (((lower(r'ö
-eg#K,纗HSJw!{cOw⇒l/l!B*H'))||(((CAST(0.12411368110083143 AS 
INT))+(-1795901173) IN (lower(CAST(TRUE AS STRING, (-1795901173, NULL, 
(0.9575114678279173) NOT IN (2.96348087E8, 0.501053365665)), (1922411524, 
TRUE, (0.5020325273627405) NOT IN (-1388966352, 1163825182));
+INSERT INTO t0(c2, c0, c1) VALUES(2, (ltrim(lower(r'K'), ((upper(r'4'))||(- 
(7) IS NOT NULL, (((lower(r'ö
+eg#K,纗HSJw!{cOw⇒l/l!B*H'))||(((CAST(0.1 AS INT))+(-5) IN (lower(CAST(TRUE 
AS STRING, (-9, NULL, (0.3) NOT IN (2.96348087E8, 0.3)), (4, TRUE, (0.5) 
NOT IN (-3, 4));
 INSERT INTO t0(c1) VALUES(TRUE);
 INSERT INTO t0(c1, c2) VALUES(FALSE, 623585248);
-INSERT INTO t0(c0) VALUES(NOT (NOT -1388966352)*(-984145454))) NOT IN 
(0.7356286, (FALSE);
+INSERT INTO t0(c0) VALUES(NOT (NOT -1)*(-9))) NOT IN (0.7, (FALSE);
 INSERT 

MonetDB: default - Merged with oscar

2020-07-06 Thread Pedro Ferreira
Changeset: 13efef9d7245 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=13efef9d7245
Modified Files:
cmake/monetdb-defines.cmake
monetdb5/modules/mal/batExtensions.c
Branch: default
Log Message:

Merged with oscar


diffs (81 lines):

diff --git a/monetdb5/modules/mal/batExtensions.c 
b/monetdb5/modules/mal/batExtensions.c
--- a/monetdb5/modules/mal/batExtensions.c
+++ b/monetdb5/modules/mal/batExtensions.c
@@ -194,8 +194,10 @@ CMDBATimprintsize(lng *ret, bat *bid)
return MAL_SUCCEED;
 }
 
-#define append_bulk_imp_fixed_size(TPE) \
+#define append_bulk_imp_fixed_size(TPE, UNION_VAL) \
do { \
+   ValRecord *stack = stk->stk; \
+   int *argv = pci->argv; \
TPE *restrict heap; \
total = number_existing + inputs; \
if (BATextend(b, total) != GDK_SUCCEED) { \
@@ -205,13 +207,13 @@ CMDBATimprintsize(lng *ret, bat *bid)
heap = (TPE*) Tloc(b, number_existing); \
if (!b->tsorted && !b->trevsorted) { \
for (int i = 3, args = pci->argc; i < args; i++) { \
-   TPE next = *(TPE*) getArgReference(stk,pci,i); \
+   TPE next = stack[argv[i]].val.UNION_VAL; \
new_nil |= is_##TPE##_nil(next); \
heap[j++] = next; \
} \
} else { \
bool sorted = b->tsorted, revsorted = b->trevsorted; \
-   TPE prev = *(TPE*) getArgReference(stk,pci,3); \
+   TPE prev = stack[argv[3]].val.UNION_VAL; \
new_nil |= is_##TPE##_nil(prev); \
if (number_existing) { \
TPE last = *(TPE*) Tloc(b, number_existing - 
1); \
@@ -220,7 +222,7 @@ CMDBATimprintsize(lng *ret, bat *bid)
} \
heap[j++] = prev; \
for (int i = 4, args = pci->argc; i < args; i++) { \
-   TPE next = *(TPE*) getArgReference(stk,pci,i); \
+   TPE next = stack[argv[i]].val.UNION_VAL; \
new_nil |= is_##TPE##_nil(next); \
sorted &= next >= prev; \
revsorted &= next <= prev; \
@@ -266,32 +268,32 @@ CMDBATappend_bulk(Client cntxt, MalBlkPt
switch (b->ttype) {
case TYPE_bit:
case TYPE_bte:
-   append_bulk_imp_fixed_size(bte);
+   append_bulk_imp_fixed_size(bte, btval);
break;
case TYPE_sht:
-   append_bulk_imp_fixed_size(sht);
+   append_bulk_imp_fixed_size(sht, shval);
break;
case TYPE_date:
case TYPE_int:
-   append_bulk_imp_fixed_size(int);
+   append_bulk_imp_fixed_size(int, ival);
break;
case TYPE_daytime:
case TYPE_timestamp:
case TYPE_lng:
-   append_bulk_imp_fixed_size(lng);
+   append_bulk_imp_fixed_size(lng, lval);
break;
case TYPE_oid:
-   append_bulk_imp_fixed_size(oid);
+   append_bulk_imp_fixed_size(oid, oval);
break;
case TYPE_flt:
-   append_bulk_imp_fixed_size(flt);
+   append_bulk_imp_fixed_size(flt, fval);
break;
case TYPE_dbl:
-   append_bulk_imp_fixed_size(dbl);
+   append_bulk_imp_fixed_size(dbl, dval);
break;
 #ifdef HAVE_HGE
case TYPE_hge:
-   append_bulk_imp_fixed_size(hge);
+   append_bulk_imp_fixed_size(hge, hval);
break;
 #endif
default:
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Merged with oscar

2020-07-06 Thread Pedro Ferreira
Changeset: a559af546856 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a559af546856
Modified Files:
monetdb5/modules/atoms/json.c
Branch: default
Log Message:

Merged with oscar


diffs (31 lines):

diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c
--- a/monetdb5/modules/atoms/json.c
+++ b/monetdb5/modules/atoms/json.c
@@ -1247,13 +1247,6 @@ JSONplaintext(char **r, size_t *l, size_
 }
 
 static str
-JSONjson2text(str *ret, json *js)
-{
-   char *sep = " ";
-   return JSONjson2textSeparator(ret, js, );
-}
-
-static str
 JSONjson2textSeparator(str *ret, json *js, str *sep)
 {
JSON *jt;
@@ -1281,6 +1274,13 @@ JSONjson2textSeparator(str *ret, json *j
 }
 
 static str
+JSONjson2text(str *ret, json *js)
+{
+   char *sep = " ";
+   return JSONjson2textSeparator(ret, js, );
+}
+
+static str
 JSONjson2numberInternal(void **ret, json *js, void (*str2num)(void **ret, 
const char *nptr, size_t len)) {
JSON *jt;
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list