MonetDB: Nov2019 - small fix/cleanup (make sure we don't access ...

2020-07-15 Thread Niels Nes
Changeset: c95bac8e5ca4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c95bac8e5ca4
Modified Files:
sql/storage/store.c
Branch: Nov2019
Log Message:

small fix/cleanup (make sure we don't access a possible null pointer)


diffs (23 lines):

diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -1869,18 +1869,17 @@ store_load(void) {
if (store_readonly)
return -1;
tr = sql_trans_create(backend_stk, NULL, NULL, true);
-   tr->active = 1;
if (!tr) {
fprintf(stderr, "Failure to start a transaction while 
loading the storage\n");
return -1;
}
} else {
-   tr->active = 1;
if (!(store_oids = GDKzalloc(300 * sizeof(sqlid { /* 150 
suffices */
fprintf(stderr, "Allocation failure while loading the 
storage\n");
return -1;
}
}
+   tr->active = 1;
 
s = bootstrap_create_schema(tr, "sys", ROLE_SYSADMIN, USER_MONETDB);
if (!first)
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Nov2019 - active initial transaction (to make sure the ...

2020-07-15 Thread Niels Nes
Changeset: 93f4059b8da1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=93f4059b8da1
Modified Files:
sql/storage/bat/bat_storage.c
sql/storage/store.c
Branch: Nov2019
Log Message:

active initial transaction (to make sure the timestamps are set correctly)
reactivated asserts, on alters we expect equal wtimes (is dup of the new column)
cleanup some more old code


diffs (56 lines):

diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -1081,7 +1081,7 @@ count_col(sql_trans *tr, sql_column *c, 
 {
sql_delta *b;
 
-// assert(tr->active || tr == gtrans);
+   assert(tr->active || tr == gtrans);
if (!isTable(c->t))
return 0;
if (!c->data) {
@@ -1480,7 +1480,6 @@ create_col(sql_trans *tr, sql_column *c)
}
 
if (!isNew(c) && !isTempTable(c->t)){
-   //c->base.wtime = 0;
return load_bat(bat, type, c->t->bootstrap?0:LOG_COL, 
c->base.id);
} else if (bat && bat->ibid && !isTempTable(c->t)) {
return new_persistent_bat(tr, c->data, c->t->sz);
@@ -1580,7 +1579,6 @@ create_idx(sql_trans *tr, sql_idx *ni)
}
 
if (!isNew(ni) && !isTempTable(ni->t)){
-   //ni->base.wtime = 0;
return load_bat(bat, type, ni->t->bootstrap?0:LOG_IDX, 
ni->base.id);
} else if (bat && bat->ibid && !isTempTable(ni->t)) {
return new_persistent_bat( tr, ni->data, ni->t->sz);
@@ -1687,7 +1685,6 @@ create_del(sql_trans *tr, sql_table *t)
log_bid bid = logger_find_bat(bat_logger, bat->dname, 
t->bootstrap?0:LOG_TAB, t->base.id);
 
if (bid) {
-   //t->base.wtime = 0;
return load_dbat(bat, bid);
}
ok = LOG_ERR;
@@ -2754,7 +2751,7 @@ update_table(sql_trans *tr, sql_table *f
sql_column *oc = m->data;
 
if (ATOMIC_GET(_nr_active) == 1 || (cc->base.wtime && 
cc->base.allocated)) {
-// assert(!cc->base.wtime || oc->base.wtime < 
cc->base.wtime);
+   assert(!cc->base.wtime || oc->base.wtime < 
cc->base.wtime || (oc->base.wtime == cc->base.wtime && oc->base.allocated /* 
alter */));
if (ATOMIC_GET(_nr_active) > 1 && cc->data) { /* 
move delta */
sql_delta *b = cc->data;
sql_column *oldc = NULL;
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -1869,6 +1869,7 @@ store_load(void) {
if (store_readonly)
return -1;
tr = sql_trans_create(backend_stk, NULL, NULL, true);
+   tr->active = 1;
if (!tr) {
fprintf(stderr, "Failure to start a transaction while 
loading the storage\n");
return -1;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Nov2019 - Disable a couple of asserts that go off durin...

2020-07-15 Thread Sjoerd Mullender
Changeset: f162f5c778e8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f162f5c778e8
Modified Files:
sql/storage/bat/bat_storage.c
sql/storage/store.c
Branch: Nov2019
Log Message:

Disable a couple of asserts that go off during testing.
They need a closer look, but for now they allow Mtest to run.


diffs (33 lines):

diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -1081,7 +1081,7 @@ count_col(sql_trans *tr, sql_column *c, 
 {
sql_delta *b;
 
-   assert(tr->active || tr == gtrans);
+// assert(tr->active || tr == gtrans);
if (!isTable(c->t))
return 0;
if (!c->data) {
@@ -2754,7 +2754,7 @@ update_table(sql_trans *tr, sql_table *f
sql_column *oc = m->data;
 
if (ATOMIC_GET(_nr_active) == 1 || (cc->base.wtime && 
cc->base.allocated)) {
-   assert(!cc->base.wtime || oc->base.wtime < 
cc->base.wtime);
+// assert(!cc->base.wtime || oc->base.wtime < 
cc->base.wtime);
if (ATOMIC_GET(_nr_active) > 1 && cc->data) { /* 
move delta */
sql_delta *b = cc->data;
sql_column *oldc = NULL;
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -3312,7 +3312,7 @@ trans_init(sql_trans *tr, backend_stack 
 
t->base.rtime = t->base.wtime = 0;
t->base.stime = pt->base.wtime;
-   assert(t->base.stime > 0 || !isTable(t));
+// assert(t->base.stime > 0 || !isTable(t));
if (!istmp && !t->base.allocated)
t->data = NULL;
assert (istmp || !t->base.allocated);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Nov2019 - make sure to set the write time (wtime) of an...

2020-07-15 Thread Niels Nes
Changeset: 5befa07017aa for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5befa07017aa
Modified Files:
sql/storage/bat/bat_storage.c
sql/storage/store.c
Branch: Nov2019
Log Message:

make sure to set the write time (wtime) of an object (also on creation),
such that new transactions will properly use the active delta structures 
holding the
real data.
Removed ref counting structure (the list itself were not made for doing ref 
counting)


diffs (240 lines):

diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -1081,7 +1081,8 @@ count_col(sql_trans *tr, sql_column *c, 
 {
sql_delta *b;
 
-   if (!isTable(c->t)) 
+   assert(tr->active || tr == gtrans);
+   if (!isTable(c->t))
return 0;
if (!c->data) {
sql_column *oc = tr_find_column(tr->parent, c);
@@ -1101,7 +1102,8 @@ dcount_col(sql_trans *tr, sql_column *c)
 {
sql_delta *b;
 
-   if (!isTable(c->t)) 
+   assert(tr->active || tr == gtrans);
+   if (!isTable(c->t))
return 0;
if (!c->data) {
sql_column *oc = tr_find_column(tr->parent, c);
@@ -1136,7 +1138,8 @@ count_idx(sql_trans *tr, sql_idx *i, int
 {
sql_delta *b;
 
-   if (!isTable(i->t) || (hash_index(i->type) && list_length(i->columns) 
<= 1) || !idx_has_column(i->type)) 
+   assert(tr->active || tr == gtrans);
+   if (!isTable(i->t) || (hash_index(i->type) && list_length(i->columns) 
<= 1) || !idx_has_column(i->type))
return 0;
if (!i->data) {
sql_idx *oi = tr_find_idx(tr->parent, i);
@@ -1156,7 +1159,8 @@ count_del(sql_trans *tr, sql_table *t)
 {
sql_dbat *d;
 
-   if (!isTable(t)) 
+   assert(tr->active || tr == gtrans);
+   if (!isTable(t))
return 0;
if (!t->data) {
sql_table *ot = tr_find_table(tr->parent, t);
@@ -1173,6 +1177,7 @@ count_col_upd(sql_trans *tr, sql_column 
 {
sql_delta *b;
 
+   assert(tr->active || tr == gtrans);
assert (isTable(c->t)) ;
if (!c->data) {
sql_column *oc = tr_find_column(tr->parent, c);
@@ -1189,7 +1194,8 @@ count_idx_upd(sql_trans *tr, sql_idx *i)
 {
sql_delta *b;
 
-   if (!isTable(i->t) || (hash_index(i->type) && list_length(i->columns) 
<= 1) || !idx_has_column(i->type)) 
+   assert(tr->active || tr == gtrans);
+   if (!isTable(i->t) || (hash_index(i->type) && list_length(i->columns) 
<= 1) || !idx_has_column(i->type))
return 0;
if (!i->data) {
sql_idx *oi = tr_find_idx(tr->parent, i);
@@ -1207,7 +1213,8 @@ count_upd(sql_trans *tr, sql_table *t)
 {
node *n;
 
-   if (!isTable(t)) 
+   assert(tr->active || tr == gtrans);
+   if (!isTable(t))
return 0;
 
for( n = t->columns.set->h; n; n = n->next) {
@@ -1233,6 +1240,7 @@ sorted_col(sql_trans *tr, sql_column *co
 {
int sorted = 0;
 
+   assert(tr->active || tr == gtrans);
if (!isTable(col->t) || !col->t->s)
return 0;
/* fallback to central bat */
@@ -1253,6 +1261,7 @@ double_elim_col(sql_trans *tr, sql_colum
 {
int de = 0;
 
+   assert(tr->active || tr == gtrans);
if (!isTable(col->t) || !col->t->s)
return 0;
/* fallback to central bat */
@@ -1471,7 +1480,7 @@ create_col(sql_trans *tr, sql_column *c)
}
 
if (!isNew(c) && !isTempTable(c->t)){
-   c->base.wtime = 0;
+   //c->base.wtime = 0;
return load_bat(bat, type, c->t->bootstrap?0:LOG_COL, 
c->base.id);
} else if (bat && bat->ibid && !isTempTable(c->t)) {
return new_persistent_bat(tr, c->data, c->t->sz);
@@ -1571,7 +1580,7 @@ create_idx(sql_trans *tr, sql_idx *ni)
}
 
if (!isNew(ni) && !isTempTable(ni->t)){
-   ni->base.wtime = 0;
+   //ni->base.wtime = 0;
return load_bat(bat, type, ni->t->bootstrap?0:LOG_IDX, 
ni->base.id);
} else if (bat && bat->ibid && !isTempTable(ni->t)) {
return new_persistent_bat( tr, ni->data, ni->t->sz);
@@ -1678,7 +1687,7 @@ create_del(sql_trans *tr, sql_table *t)
log_bid bid = logger_find_bat(bat_logger, bat->dname, 
t->bootstrap?0:LOG_TAB, t->base.id);
 
if (bid) {
-   t->base.wtime = 0;
+   //t->base.wtime = 0;
return load_dbat(bat, bid);
}
ok = LOG_ERR;
@@ -1924,6 +1933,8 @@ delayed_destroy_dbat(sql_dbat *b)
while(n->next) 
n = n->next;
MT_lock_set(_lock);
+   while(n->next)
+   n = n->next;
n->next = tobe_destroyed_dbat;
tobe_destroyed_dbat = b;
MT_lock_unset(_lock);
diff --git 

MonetDB: hammertime - Merge heads.

2020-07-15 Thread Aris Koning
Changeset: a8377256d356 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a8377256d356
Modified Files:
cmake/monetdb-toolchain.cmake
common/utils/matomic.h
documentation/source/manual_pages/monetdb.rst
documentation/source/manual_pages/monetdbd.rst.in
gdk/gdk_join.c
monetdb5/modules/mal/batcalc.c
monetdb_config.h.in
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_statement.c
sql/backends/monet5/sql_statement.h
sql/include/sql_catalog.h
sql/server/rel_dump.c
sql/server/rel_optimizer.c
sql/server/rel_rel.c
sql/server/rel_rel.h
sql/server/rel_unnest.c
sql/server/sql_mvc.c
sql/server/sql_mvc.h
sql/storage/bat/bat_storage.c
sql/storage/sql_storage.h
sql/storage/store.c
tools/monetdbe/monetdbe.c
tools/monetdbe/monetdbe.h
Branch: hammertime
Log Message:

Merge heads.


diffs (truncated from 1229 to 300 lines):

diff --git a/cmake/monetdb-toolchain.cmake b/cmake/monetdb-toolchain.cmake
--- a/cmake/monetdb-toolchain.cmake
+++ b/cmake/monetdb-toolchain.cmake
@@ -67,8 +67,9 @@ function(monetdb_default_toolchain)
 elseif(${CMAKE_C_COMPILER_ID} STREQUAL "Intel")
   if(WIN32)
 set(COMPILER_OPTION "/")
-#MT_addCompilerFlag("${COMPILER_OPTION}DNO_ATOMIC_INSTRUCTIONS" 
"${COMPILER_OPTION}DNO_ATOMIC_INSTRUCTIONS=1" "${CMAKE_C_FLAGS}" "all" 
CMAKE_C_FLAGS)
 MT_addCompilerFlag("${COMPILER_OPTION}W3" "${COMPILER_OPTION}W3" 
"${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS)
+MT_addCompilerFlag("${COMPILER_OPTION}Qdiag-disable:11074" 
"${COMPILER_OPTION}Qdiag-disable:11074" "${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS)
+MT_addCompilerFlag("${COMPILER_OPTION}Qdiag-disable:11075" 
"${COMPILER_OPTION}Qdiag-disable:11075" "${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS)
   else()
 set(COMPILER_OPTION "-")
 MT_addCompilerFlag("${COMPILER_OPTION}Wall" "${COMPILER_OPTION}Wall" 
"${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS)
diff --git a/common/utils/matomic.h b/common/utils/matomic.h
--- a/common/utils/matomic.h
+++ b/common/utils/matomic.h
@@ -57,7 +57,9 @@
 /* define this if you don't want to use atomic instructions */
 /* #define NO_ATOMIC_INSTRUCTIONS */
 
-#if defined(HAVE_STDATOMIC_H) && !defined(__STDC_NO_ATOMICS__) && 
!defined(NO_ATOMIC_INSTRUCTIONS)
+/* ignore __STDC_NO_ATOMICS__ if compiling using Intel compiler on
+ * Windows since otherwise we can't compile this at all in C99 mode */
+#if defined(HAVE_STDATOMIC_H) && (!defined(__STDC_NO_ATOMICS__) || 
(defined(__INTEL_COMPILER) && defined(_WINDOWS))) && 
!defined(NO_ATOMIC_INSTRUCTIONS)
 
 #include 
 
diff --git a/documentation/source/manual_pages/monetdb.rst 
b/documentation/source/manual_pages/monetdb.rst
--- a/documentation/source/manual_pages/monetdb.rst
+++ b/documentation/source/manual_pages/monetdb.rst
@@ -1,7 +1,3 @@
-===
-MONETDB
-===
-
 NAME
 
 
@@ -56,10 +52,10 @@ COMMANDS
 
 The commands for the *monetdb* utility are **create**, **destroy**,
 **lock**, **release**, **status**, **start**, **stop**, **kill**,
-**profilerstart**, **profilerstop**, **set**, **get**, **inherit**,
-**discover**, **help**, and **version**. The commands facilitate adding,
-removing, maintaining, starting and stopping a database inside the
-MonetDB Database Server.
+**profilerstart**, **profilerstop**, **snapshot**, **set**, **get**,
+**inherit**, **discover**, **help**, and **version**. The commands
+facilitate adding, removing, maintaining, starting and stopping a
+database inside the MonetDB Database Server.
 
 For all commands, database arguments can be glob-like expressions. This
 allows to do wildcard matches. For details on the syntax, see
@@ -167,20 +163,21 @@ allows to do wildcard matches. For detai
 **kill [-a]**\ *database*\ **[**\ *database*\ **...]**
 
 Starts, stops or kills the given database, or, when **-a** is supplied,
-all known databases. The **kill** command immediately sends a SIGKILL
-and should only be used as last resort for a database that doesn't
-respond any more. Killing a database may result in (partial) data loss.
-It is more common to use the **stop** command to stop a database. It
-will first attempt to stop the database, waiting for
-**mero_exittimeout** seconds and if that fails, kill the database. When
-using the **start** command, *monetdb*\ (1) will output diagnostic
-messages if the requested action failed. When encountering an error, one
-should always consult the logfile of *monetdbd*\ (1) for more details.
-For the **kill** command a diagnostic message indicating the database
-has crashed is always emitted, due to the nature of that command. Note
-that in combination with **-a** the return code of *monetdb*\ (1)
-indicates failure if one of the databases had a failure, even though the
-operation on other databases was successful.
+all known databases. The **kill** command immediately 

MonetDB: hammertime - Remove rtime from sql_trans. We don't need...

2020-07-15 Thread Aris Koning
Changeset: 651ae1c5320f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=651ae1c5320f
Modified Files:
sql/include/sql_catalog.h
sql/storage/bat/bat_storage.c
sql/storage/store.c
Branch: hammertime
Log Message:

Remove rtime from sql_trans. We don't need it.


diffs (80 lines):

diff --git a/sql/include/sql_catalog.h b/sql/include/sql_catalog.h
--- a/sql/include/sql_catalog.h
+++ b/sql/include/sql_catalog.h
@@ -241,7 +241,6 @@ typedef struct sql_trans {
char *name;
int stime;  /* start of transaction */
int wstime; /* first write transaction time stamp */
-   int rtime;  /* timestamp of latest read performed in 
transaction*/
int wtime;  /* timestamp of latest write performed in 
transaction*/
int schema_number;  /* schema timestamp */
int schema_updates; /* set on schema changes */
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -132,7 +132,7 @@ bind_uidx(sql_trans *tr, sql_idx * i, in
i->t->data = timestamp_dbat(ot->data, i->t->base.stime);
}
assert(tr != gtrans);
-   i->base.rtime = i->t->base.rtime = i->t->s->base.rtime = tr->rtime = 
tr->stime;
+   i->base.rtime = i->t->base.rtime = i->t->s->base.rtime = tr->stime;
u = delta_bind_ubat(i->data, access, 
(oid_index(i->type))?TYPE_oid:TYPE_lng);
return u;
 }
@@ -220,7 +220,7 @@ bind_col(sql_trans *tr, sql_column *c, i
return bind_ucol(tr, c, access);
assert(access == QUICK || tr != gtrans);
if (tr && access != QUICK)
-   c->base.rtime = c->t->base.rtime = c->t->s->base.rtime = 
tr->rtime = tr->stime;
+   c->base.rtime = c->t->base.rtime = c->t->s->base.rtime = 
tr->stime;
return delta_bind_bat( c->data, access, isTemp(c));
 }
 
@@ -238,7 +238,7 @@ bind_idx(sql_trans *tr, sql_idx * i, int
return bind_uidx(tr, i, access);
assert(access == QUICK || tr != gtrans);
if (tr && access != QUICK)
-   i->base.rtime = i->t->base.rtime = i->t->s->base.rtime = 
tr->rtime = tr->stime;
+   i->base.rtime = i->t->base.rtime = i->t->s->base.rtime = 
tr->stime;
return delta_bind_bat( i->data, access, isTemp(i));
 }
 
@@ -623,7 +623,7 @@ update_col(sql_trans *tr, sql_column *c,
bat = c->data;
bat->wtime = c->base.wtime = c->t->base.wtime = c->t->s->base.wtime = 
tr->wtime = tr->wstime;
assert(tr != gtrans);
-   c->base.rtime = c->t->base.rtime = c->t->s->base.rtime = tr->rtime = 
tr->stime;
+   c->base.rtime = c->t->base.rtime = c->t->s->base.rtime = tr->stime;
if (tpe == TYPE_bat)
return delta_update_bat(bat, tids, upd, isNew(c));
else
@@ -663,7 +663,7 @@ update_idx(sql_trans *tr, sql_idx * i, v
bat = i->data;
bat->wtime = i->base.wtime = i->t->base.wtime = i->t->s->base.wtime = 
tr->wtime = tr->wstime;
assert(tr != gtrans);
-   i->base.rtime = i->t->base.rtime = i->t->s->base.rtime = tr->rtime = 
tr->stime;
+   i->base.rtime = i->t->base.rtime = i->t->s->base.rtime = tr->stime;
if (tpe == TYPE_bat)
return delta_update_bat(bat, tids, upd, isNew(i));
else
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -1366,7 +1366,7 @@ create_trans(sql_allocator *sa)
 
t->sa = sa;
t->name = NULL;
-   t->wtime = t->rtime = 0;
+   t->wtime = 0;
t->stime = 0;
t->wstime = timestamp();
t->schema_updates = 0;
@@ -3757,7 +3757,7 @@ schema_dup(sql_trans *tr, int flags, sql
 static void
 _trans_init(sql_trans *tr, sql_trans *otr)
 {
-   tr->wtime = tr->rtime = 0;
+   tr->wtime = 0;
tr->stime = otr->wtime;
tr->wstime = timestamp();
tr->schema_updates = 0;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: hammertime - Fail the pre-commit validate if there was ...

2020-07-15 Thread Aris Koning
Changeset: df442d54e7fd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=df442d54e7fd
Modified Files:
sql/storage/store.c
Branch: hammertime
Log Message:

Fail the pre-commit validate if there was access to a deleted a table.


diffs (33 lines):

diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -4616,8 +4616,27 @@ validate_tables(sql_schema *s, sql_schem
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)) {
+   ot = find_sql_table_id(os, t->base.id);
+
+   if (!ot) {
+   // table might be deleted search the set of 
deleted tables.
+   if (!os->tables.dset) {
+   // table must have been created in this 
transaction.
+   continue;
+   }
+
+   for (o = os->tables.dset->h; o; o = o->next) {
+   ot = o->data;
+   if (t->base.id == ot->base.id) {
+
+   /* We may have accessed a table 
wich has been removed by a previous committed transaction.
+* If this is the case, we have 
to invalidate this transaction.
+*/
+   return 0;
+   }
+   }
+   }
+   else if (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;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: hammertime - do not look into the dset to find a node o...

2020-07-15 Thread Aris Koning
Changeset: c779f929034b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c779f929034b
Modified Files:
sql/storage/sql_catalog.c
Branch: hammertime
Log Message:

do not look into the dset to find a node of changeset.


diffs (21 lines):

diff --git a/sql/storage/sql_catalog.c b/sql/storage/sql_catalog.c
--- a/sql/storage/sql_catalog.c
+++ b/sql/storage/sql_catalog.c
@@ -113,17 +113,6 @@ cs_find_id(changeset * cs, sqlid id)
return n;
}
}
-   if (cs->dset) {
-   l = cs->dset;
-   for (n = l->h; n; n = n->next) {
-   sql_base *b = n->data;
-
-   /* check if names match */
-   if (b->id == id) {
-   return n;
-   }
-   }
-   }
return NULL;
 }
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: hammertime - Merge with default

2020-07-15 Thread Aris Koning
Changeset: 787d7f64fcf3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=787d7f64fcf3
Modified Files:

monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows
sql/storage/store.c
Branch: hammertime
Log Message:

Merge with default


diffs (28 lines):

diff --git 
a/monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows
 
b/monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows
--- 
a/monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows
+++ 
b/monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows
@@ -179,7 +179,7 @@ function user.main():void;
 X_40:lng := aggr.count(X_28:bat[:int]);
 X_38:int := sql.append(X_35:int, "sys":str, "ttt":str, "c":str, 
X_28:bat[:int]);
 sql.affectedRows(X_38:int, X_40:lng);
-end user.s24_0;
+end user.main;
 #inline   actions= 0 time=0 usec 
 #remapactions= 0 time=0 usec 
 #costmodelactions= 1 time=0 usec 
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -4985,6 +4985,12 @@ reset_trans(sql_trans *tr, sql_trans *pt
 {
int res = reset_changeset(tr, >schemas, >schemas, (sql_base 
*)tr->parent, (resetf) _schema, (dupfunc) _dup);
TRC_DEBUG(SQL_STORE, "Reset transaction: %d\n", tr->wtime);
+
+   for (node *n = tr->schemas.set->h; n; n = n->next) { /* Set table 
members */
+   sql_schema *s = n->data;
+
+   set_members(>tables);
+   }
return res;
 }
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: hammertime - Merge with default.

2020-07-15 Thread Aris Koning
Changeset: a245be760dbc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a245be760dbc
Added Files:
cmake/Modules/FindDpkgBuildpackage.cmake
cmake/Modules/FindReprepro.cmake
cmake/Modules/FindRpmbuild.cmake
cmake/Modules/FindSemodule.cmake

sql/test/BugDay_2005-10-06_2.9.3/Tests/parser_crashes_server.SF-921996.stable.err.Darwin
sql/test/BugTracker-2019/Tests/str_to_time.Bug-6791.stable.out.single
sql/test/mapi/Tests/sql_int128.stable.out.int128.single
sql/test/pg_regress/Tests/float8.stable.err.int128.single
sql/test/pg_regress/Tests/float8.stable.err.single
Modified Files:
.editorconfig
CMakeLists.txt
clients/Tests/exports.stable.out
cmake/Modules/FindLZ4.cmake
cmake/monetdb-custom-targets.cmake
cmake/monetdb-defines.cmake
cmake/monetdb-findpackages.cmake
cmake/monetdb-functions.cmake
cmake/monetdb-toolchain.cmake
ctest/cmake/detect-curl.cmake
ctest/cmake/detect-fits.cmake
ctest/cmake/detect-gdal.cmake
ctest/cmake/detect-geos.cmake
ctest/cmake/detect-libr.cmake
ctest/cmake/detect-lz4.cmake
ctest/cmake/detect-lzma.cmake
ctest/cmake/detect-netcdf.cmake
ctest/cmake/detect-proj.cmake
ctest/cmake/detect-pthreadkill.cmake
ctest/cmake/detect-pthreadsig.cmake
ctest/cmake/detect-readline.cmake
ctest/cmake/detect-uuid.cmake
ctest/tools/monetdbe/cmocka_test.c
ctest/tools/monetdbe/test_helper.h
gdk/gdk_align.c
gdk/gdk_analytic_bounds.c
gdk/gdk_batop.c
gdk/gdk_bbp.c
gdk/gdk_join.c
gdk/gdk_private.h
gdk/gdk_system.h
gdk/gdk_utils.c
geom/monetdb5/geom.c
monetdb5/mal/mal_prelude.c
monetdb5/mal/mel.h
monetdb5/modules/atoms/blob.c
monetdb5/modules/atoms/str.c
monetdb5/modules/atoms/str.h
monetdb5/modules/kernel/batstr.c
monetdb5/optimizer/opt_mergetable.c
monetdb_config.h.in
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_cast.c
sql/backends/monet5/sql_optimizer.c
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/sql_time.c
sql/backends/monet5/sql_upgrades.c
sql/common/sql_list.c
sql/common/sql_types.c
sql/include/sql_catalog.h
sql/include/sql_list.h
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_rewriter.c
sql/server/rel_rewriter.h
sql/server/rel_select.c
sql/server/rel_unnest.c
sql/server/rel_updates.c
sql/server/sql_atom.c
sql/server/sql_atom.h
sql/server/sql_mvc.c
sql/server/sql_mvc.h
sql/server/sql_parser.y
sql/server/sql_semantic.c
sql/server/sql_var.c
sql/storage/bat/bat_storage.c
sql/storage/bat/bat_storage.h
sql/storage/sql_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-2016/Tests/storagemodel.stable.out

sql/test/BugTracker-2019/Tests/duplicates-not-eliminated-long-CASE-stmt.Bug-6697.stable.out.single

sql/test/BugTracker/Tests/inserting_invalid_timestamp.SF-1363557.stable.err
sql/test/SQLancer/Tests/sqlancer03.sql
sql/test/SQLancer/Tests/sqlancer03.stable.out
sql/test/miscellaneous/Tests/groupby_error.stable.out
sql/test/miscellaneous/Tests/select_groupby.stable.err
sql/test/miscellaneous/Tests/simple_plans.stable.out
sql/test/miscellaneous/Tests/simple_plans.stable.out.single
sql/test/pg_regress/Tests/date.stable.err
sql/test/pg_regress/Tests/float8.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/subquery/Tests/subquery6.stable.out
sql/test/sys-schema/Tests/systemfunctions.stable.out
sql/test/sys-schema/Tests/systemfunctions.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
sql/test/wlcr/Tests/wlr110.stable.err
testing/Mtest.py.bat
testing/Mtest.py.in
testing/mktest.py
testing/sqllogictest.py
   

MonetDB: default - merged

2020-07-15 Thread Niels Nes
Changeset: 353a1cd81877 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=353a1cd81877
Modified Files:
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_statement.c
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
sql/test/pg_regress/Tests/timestamp.stable.out
sql/test/pg_regress/Tests/timestamptz.stable.out
Branch: default
Log Message:

merged


diffs (187 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
@@ -1425,7 +1425,7 @@ stmt_genselect(backend *be, stmt *lops, 
s->op2 = rops;
s->op3 = sub;
s->flag = cmp_filter;
-   s->nrcols = (lops->nrcols == 2) ? 2 : 1;
+   s->nrcols = lops->nrcols;
s->nr = getDestVar(q);
s->q = q;
s->cand = sub;
@@ -1582,7 +1582,7 @@ stmt_uselect(backend *be, stmt *op1, stm
s->op2 = op2;
s->op3 = sub;
s->flag = cmptype;
-   s->nrcols = (op1->nrcols == 2) ? 2 : 1;
+   s->nrcols = op1->nrcols;
s->nr = getDestVar(q);
s->q = q;
s->cand = sub;
@@ -1811,7 +1811,6 @@ stmt_uselect2(backend *be, stmt *op1, st
InstrPtr q = select2_join2(be, op1, op2, op3, cmp, sub, anti, 0, 
st_uselect2, reduce);
 
if (q) {
-   int nrcols = (op1->nrcols || op2->nrcols || op3->nrcols);
stmt *s = stmt_create(be->mvc->sa, st_uselect2);
if (s == NULL) {
freeInstruction(q);
@@ -1823,7 +1822,7 @@ stmt_uselect2(backend *be, stmt *op1, st
s->op3 = op3;
s->op4.stval = sub;
s->flag = cmp;
-   s->nrcols = (!nrcols)?0:(op1->nrcols == 2) ? 2 : 1;
+   s->nrcols = op1->nrcols;
s->nr = getDestVar(q);
s->q = q;
s->cand = sub;
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, 

MonetDB: default - small fixes of between with scalar values

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

small fixes of between with scalar values


diffs (41 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
@@ -1054,7 +1054,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l
(re2 && re2->card > CARD_ATOM))) {
*/
(void)is_select;
-   if (left && right) {
+   if (reduce && left && right) {
if (l->nrcols == 0)
l = stmt_const(be, bin_first_column(be, 
swapped?right:left), l);
if (r->nrcols == 0)
@@ -1071,7 +1071,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l
} else {
if (r2) { /* handle all cases in stmt_uselect,
 reducing, non reducing, scalar 
etc */
-   if (l->nrcols == 0)
+   if (l->nrcols == 0 && left)
l = stmt_const(be, bin_first_column(be, 
left), l);
s = stmt_uselect2(be, l, r, r2, 
(comp_type)e->flag, sel, is_anti(e), reduce);
} else {
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
@@ -1811,6 +1811,7 @@ stmt_uselect2(backend *be, stmt *op1, st
InstrPtr q = select2_join2(be, op1, op2, op3, cmp, sub, anti, 0, 
st_uselect2, reduce);
 
if (q) {
+   int nrcols = (op1->nrcols || op2->nrcols || op3->nrcols);
stmt *s = stmt_create(be->mvc->sa, st_uselect2);
if (s == NULL) {
freeInstruction(q);
@@ -1822,7 +1823,7 @@ stmt_uselect2(backend *be, stmt *op1, st
s->op3 = op3;
s->op4.stval = sub;
s->flag = cmp;
-   s->nrcols = (op1->nrcols == 2) ? 2 : 1;
+   s->nrcols = (!nrcols)?0:(op1->nrcols == 2) ? 2 : 1;
s->nr = getDestVar(q);
s->q = q;
s->cand = sub;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


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: oscar - Merged with Jun2020

2020-07-15 Thread Pedro Ferreira
Changeset: 8f10367ee2b6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8f10367ee2b6
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: oscar
Log Message:

Merged with Jun2020


diffs (124 lines):

diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -4612,13 +4612,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;
@@ -4877,7 +4882,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;
 
@@ -4986,6 +4992,12 @@ reset_trans(sql_trans *tr, sql_trans *pt
 {
int res = reset_changeset(tr, >schemas, >schemas, (sql_base 
*)tr->parent, (resetf) _schema, (dupfunc) _dup);
TRC_DEBUG(SQL_STORE, "Reset transaction: %d\n", tr->wtime);
+
+   for (node *n = tr->schemas.set->h; n; n = n->next) { /* Set table 
members */
+   sql_schema *s = n->data;
+
+   set_members(>tables);
+   }
return res;
 }
 
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 
-| | | | | | | | | | | | ) [ 

MonetDB: default - Fixes for crashing SQLancer queries (there's ...

2020-07-15 Thread Pedro Ferreira
Changeset: 18cd5efc7681 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=18cd5efc7681
Modified Files:
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_statement.c
sql/test/pg_regress/Tests/timestamp.stable.out
sql/test/pg_regress/Tests/timestamptz.stable.out
Branch: default
Log Message:

Fixes for crashing SQLancer queries (there's more to do)


diffs (80 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
@@ -1071,7 +1071,7 @@ exp_bin(backend *be, sql_exp *e, stmt *l
} else {
if (r2) { /* handle all cases in stmt_uselect,
 reducing, non reducing, scalar 
etc */
-   if (l->nrcols == 0)
+   if (l->nrcols == 0 && left)
l = stmt_const(be, bin_first_column(be, 
left), l);
s = stmt_uselect2(be, l, r, r2, 
(comp_type)e->flag, sel, is_anti(e), reduce);
} else {
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
@@ -1425,7 +1425,7 @@ stmt_genselect(backend *be, stmt *lops, 
s->op2 = rops;
s->op3 = sub;
s->flag = cmp_filter;
-   s->nrcols = (lops->nrcols == 2) ? 2 : 1;
+   s->nrcols = lops->nrcols;
s->nr = getDestVar(q);
s->q = q;
s->cand = sub;
@@ -1582,7 +1582,7 @@ stmt_uselect(backend *be, stmt *op1, stm
s->op2 = op2;
s->op3 = sub;
s->flag = cmptype;
-   s->nrcols = (op1->nrcols == 2) ? 2 : 1;
+   s->nrcols = op1->nrcols;
s->nr = getDestVar(q);
s->q = q;
s->cand = sub;
@@ -1822,7 +1822,7 @@ stmt_uselect2(backend *be, stmt *op1, st
s->op3 = op3;
s->op4.stval = sub;
s->flag = cmp;
-   s->nrcols = (op1->nrcols == 2) ? 2 : 1;
+   s->nrcols = op1->nrcols;
s->nr = getDestVar(q);
s->q = q;
s->cand = sub;
diff --git a/sql/test/pg_regress/Tests/timestamp.stable.out 
b/sql/test/pg_regress/Tests/timestamp.stable.out
--- a/sql/test/pg_regress/Tests/timestamp.stable.out
+++ b/sql/test/pg_regress/Tests/timestamp.stable.out
@@ -74,13 +74,13 @@ stdout of test 'timestamp` in directory 
 % 1 # length
 [ 1 ]
 #SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = cast((select 
test_current_date from test_current_date) + interval '1' DAY as timestamp);
-% sys. # table_name
+% . # table_name
 % one # name
 % bigint # type
 % 1 # length
 [ 1]
 #SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = cast((select 
test_current_date from test_current_date) - interval '1' DAY as timestamp);
-% sys. # table_name
+% . # table_name
 % one # name
 % bigint # type
 % 1 # length
diff --git a/sql/test/pg_regress/Tests/timestamptz.stable.out 
b/sql/test/pg_regress/Tests/timestamptz.stable.out
--- a/sql/test/pg_regress/Tests/timestamptz.stable.out
+++ b/sql/test/pg_regress/Tests/timestamptz.stable.out
@@ -43,13 +43,13 @@ stdout of test 'timestamptz` in director
 % 1 # length
 [ 1 ]
 #SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = cast((select 
test_current_date from test_current_date) + interval '1' DAY as timestamp);
-% sys. # table_name
+% . # table_name
 % one # name
 % bigint # type
 % 1 # length
 [ 1]
 #SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = cast((select 
test_current_date from test_current_date) - interval '1' DAY as timestamp);
-% sys. # table_name
+% . # table_name
 % one # name
 % bigint # type
 % 1 # length
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - merged

2020-07-15 Thread Niels Nes
Changeset: 3cc21b190d96 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3cc21b190d96
Modified Files:
gdk/gdk_join.c
Branch: Jun2020
Log Message:

merged


diffs (86 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -3363,38 +3363,52 @@ leftjoin(BAT **r1p, BAT **r2p, BAT *l, B
}
if (semi)
r1->tkey = true;
-   BAT *ob;
-   rc = BATsort(, r2p ?  : NULL, NULL,
-r1, NULL, NULL, false, false, false);
-   BBPunfix(r1->batCacheid);
-   if (rc != GDK_SUCCEED) {
-   if (r2)
+   if (!VIEWtparent(r1) &&
+   r1->ttype == TYPE_oid &&
+   BBP_refs(r1->batCacheid) == 1 &&
+   (r2 == NULL ||
+(!VIEWtparent(r2) &&
+ BBP_refs(r2->batCacheid) == 1 &&
+ r2->ttype == TYPE_oid))) {
+   /* in-place sort if we can */
+   if (r2) {
+   GDKqsort(r1->theap.base, r2->theap.base,
+NULL, r1->batCount, r1->twidth,
+r2->twidth, TYPE_oid, false,
+false);
+   r2->tsorted = false;
+   r2->trevsorted = false;
+   *r2p = r2;
+   } else {
+   GDKqsort(r1->theap.base, NULL, NULL,
+r1->batCount, r1->twidth, 0,
+TYPE_oid, false, false);
+   }
+   r1->tsorted = true;
+   r1->trevsorted = false;
+   *r1p = r1;
+   } else {
+   BAT *ob;
+   rc = BATsort(, r2p ?  : NULL, NULL,
+r1, NULL, NULL, false, false, 
false);
+   BBPunfix(r1->batCacheid);
+   if (rc != GDK_SUCCEED) {
+   if (r2)
+   BBPunfix(r2->batCacheid);
+   return rc;
+   }
+   *r1p = r1 = tmp;
+   if (r2p) {
+   tmp = BATproject(ob, r2);
BBPunfix(r2->batCacheid);
-   return rc;
+   BBPunfix(ob->batCacheid);
+   if (tmp == NULL) {
+   BBPunfix(r1->batCacheid);
+   return GDK_FAIL;
+   }
+   *r2p = tmp;
+   }
}
-   *r1p = r1 = tmp;
-   if (r2p) {
-   tmp = BATproject(ob, r2);
-   BBPunfix(r2->batCacheid);
-   BBPunfix(ob->batCacheid);
-   if (tmp == NULL) {
-   BBPunfix(r1->batCacheid);
-   return GDK_FAIL;
-   }
-   *r2p = tmp;
-   }
-#if 0
-#ifndef NDEBUG
-   BAT *x1;
-   canditer_reset();
-   canditer_reset();
-   hashjoin(, NULL, l, r, , , nil_matches, 
false, false, false, false, false, estimate, t0, false, rhash, prhash, func);
-   assert(x1->batCount == r1->batCount);
-   for (BUN x = 0; x < x1->batCount; x++)
-   assert(BUNtoid(r1, x) == BUNtoid(x1, x));
-   BBPunfix(x1->batCacheid);
-#endif
-#endif
return GDK_SUCCEED;
}
}
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - approved output

2020-07-15 Thread Niels Nes
Changeset: f31151e2f3fd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f31151e2f3fd
Modified Files:
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: Jun2020
Log Message:

approved output


diffs (76 lines):

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" ] COUNT 
-| | | | | | | | | | | ) [ "p"."inout" = tinyint "1" ]
-| | | | | | | | | | ) [ "f"."id" = "p"."func_id" ]
-| | | | | | | | | ) [ "f"."id", "p"."number" ] [ "f"."id" ASC, "p"."number" 
ASC ]
-| | | | | | | | ) [ "f"."id", "p"."number" ]
-| | | | | | | ) [ "f"."id", "p"."number" ] [ "f"."id" ASC, "p"."number" NULLS 
LAST ]
-| | | | | | ) [ "f"."id", "p"."number" ]
+| | | | | | | | 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" ] COUNT 
+| | | | | | | | | ) [ "p"."inout" = tinyint "1" ]
+| | | | | | | | ) [ "f"."id" = "p"."func_id" ]
+| | | | | | | ) [ "f"."id", "p"."number" ] [ "f"."id" ASC, "p"."number" ASC ]
+| | | | | | ) [ "f"."id", "p"."number" ] [ "f"."id" ASC, "p"."number" NULLS 
LAST ]
 | | | | | ) [ "f"."id", "p"."number" ] [ "f"."id" ASC, "p"."number" ASC ]
 | | | | ) [ "f"."id", sys.row_number("f"."id", boolean "false" as "%17"."%17", 
sys.diff(sys.diff("f"."id" ASC), "p"."number" ASC) as "%20"."%20") as "line" ]
 | | | ) [ "f"."id" as "fid", "line" ]
diff --git a/sql/test/miscellaneous/Tests/groupby_error.stable.out 

MonetDB: Jun2020 - make sure we don't validate queries which upd...

2020-07-15 Thread Niels Nes
Changeset: c6fe2bd9de87 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c6fe2bd9de87
Modified Files:
sql/storage/store.c
Branch: Jun2020
Log Message:

make sure we don't validate queries which update already dropped tables


diffs (48 lines):

diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -4564,13 +4564,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)) {
+   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;
@@ -4829,7 +4834,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;
 
@@ -4938,6 +4944,12 @@ reset_trans(sql_trans *tr, sql_trans *pt
 {
int res = reset_changeset(tr, >schemas, >schemas, (sql_base 
*)tr->parent, (resetf) _schema, (dupfunc) _dup);
TRC_DEBUG(SQL_STORE, "Reset transaction: %d\n", tr->wtime);
+
+   for (node *n = tr->schemas.set->h; n; n = n->next) { /* Set table 
members */
+   sql_schema *s = n->data;
+
+   set_members(>tables);
+   }
return res;
 }
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: hammertime - merged with default

2020-07-15 Thread Niels Nes
Changeset: 05e0c4514eb8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=05e0c4514eb8
Added Files:
cmake/Modules/FindDpkgBuildpackage.cmake
cmake/Modules/FindReprepro.cmake
cmake/Modules/FindRpmbuild.cmake
cmake/Modules/FindSemodule.cmake

sql/test/BugDay_2005-10-06_2.9.3/Tests/parser_crashes_server.SF-921996.stable.err.Darwin
sql/test/BugTracker-2019/Tests/str_to_time.Bug-6791.stable.out.single
sql/test/mapi/Tests/sql_int128.stable.out.int128.single
sql/test/pg_regress/Tests/float8.stable.err.int128.single
sql/test/pg_regress/Tests/float8.stable.err.single
Modified Files:
.editorconfig
CMakeLists.txt
clients/Tests/exports.stable.out
cmake/Modules/FindLZ4.cmake
cmake/monetdb-custom-targets.cmake
cmake/monetdb-defines.cmake
cmake/monetdb-findpackages.cmake
cmake/monetdb-functions.cmake
cmake/monetdb-toolchain.cmake
common/utils/matomic.h
ctest/cmake/detect-curl.cmake
ctest/cmake/detect-fits.cmake
ctest/cmake/detect-gdal.cmake
ctest/cmake/detect-geos.cmake
ctest/cmake/detect-libr.cmake
ctest/cmake/detect-lz4.cmake
ctest/cmake/detect-lzma.cmake
ctest/cmake/detect-netcdf.cmake
ctest/cmake/detect-proj.cmake
ctest/cmake/detect-pthreadkill.cmake
ctest/cmake/detect-pthreadsig.cmake
ctest/cmake/detect-readline.cmake
ctest/cmake/detect-uuid.cmake
ctest/tools/monetdbe/cmocka_test.c
ctest/tools/monetdbe/test_helper.h
documentation/source/manual_pages/monetdb.rst
documentation/source/manual_pages/monetdbd.rst.in
gdk/gdk_align.c
gdk/gdk_analytic_bounds.c
gdk/gdk_batop.c
gdk/gdk_bbp.c
gdk/gdk_join.c
gdk/gdk_private.h
gdk/gdk_system.h
gdk/gdk_utils.c
geom/monetdb5/geom.c

monetdb5/extras/mal_optimizer_template/Tests/opt_sql_append.stable.out.Windows
monetdb5/mal/mal_prelude.c
monetdb5/mal/mel.h
monetdb5/modules/atoms/blob.c
monetdb5/modules/atoms/str.c
monetdb5/modules/atoms/str.h
monetdb5/modules/kernel/batstr.c
monetdb5/modules/mal/batcalc.c
monetdb5/optimizer/opt_mergetable.c
monetdb_config.h.in
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_cast.c
sql/backends/monet5/sql_optimizer.c
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/sql_statement.c
sql/backends/monet5/sql_statement.h
sql/backends/monet5/sql_time.c
sql/backends/monet5/sql_upgrades.c
sql/common/sql_list.c
sql/common/sql_types.c
sql/include/sql_catalog.h
sql/include/sql_list.h
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_rewriter.c
sql/server/rel_rewriter.h
sql/server/rel_select.c
sql/server/rel_unnest.c
sql/server/rel_updates.c
sql/server/sql_atom.c
sql/server/sql_atom.h
sql/server/sql_mvc.c
sql/server/sql_mvc.h
sql/server/sql_parser.y
sql/server/sql_semantic.c
sql/server/sql_var.c
sql/storage/bat/bat_storage.c
sql/storage/bat/bat_storage.h
sql/storage/sql_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-2016/Tests/storagemodel.stable.out

sql/test/BugTracker-2019/Tests/duplicates-not-eliminated-long-CASE-stmt.Bug-6697.stable.out.single

sql/test/BugTracker/Tests/inserting_invalid_timestamp.SF-1363557.stable.err
sql/test/SQLancer/Tests/sqlancer03.sql
sql/test/SQLancer/Tests/sqlancer03.stable.out
sql/test/miscellaneous/Tests/groupby_error.stable.out
sql/test/miscellaneous/Tests/select_groupby.stable.err
sql/test/miscellaneous/Tests/simple_plans.stable.out
sql/test/miscellaneous/Tests/simple_plans.stable.out.single
sql/test/pg_regress/Tests/date.stable.err
sql/test/pg_regress/Tests/float8.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/subquery/Tests/subquery6.stable.out
sql/test/sys-schema/Tests/systemfunctions.stable.out
sql/test/sys-schema/Tests/systemfunctions.stable.out.int128
sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128

MonetDB: default - Simplified version of crashing query

2020-07-15 Thread Pedro Ferreira
Changeset: 52cf0a1bdead for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=52cf0a1bdead
Modified Files:
sql/test/SQLancer/Tests/sqlancer03.sql
Branch: default
Log Message:

Simplified version of crashing query


diffs (11 lines):

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
@@ -218,6 +218,7 @@ ROLLBACK;
 
 START TRANSACTION;
 CREATE TABLE t0(c0 INT);
+insert into t0(c0) values (1 between 2 and 3);
 insert into t0(c0) values(13), (((cast((0.1) between symmetric (0.2) and (0.3) 
as int))%(length(upper(r'u鋔wsD30pYi&ᴮ*2*W쉉t+詫sD^#cjX{'), 
(cast(cast(cast(0.12 as int) as string(646)) as int));
 
 SELECT COUNT(t0.c0 = t0.c0 OR 1 BETWEEN ASYMMETRIC 1 AND 1) FROM t0;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Merge with oscar branch.

2020-07-15 Thread Sjoerd Mullender
Changeset: f77668f69f27 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f77668f69f27
Modified Files:
cmake/monetdb-toolchain.cmake
common/utils/matomic.h
gdk/gdk_join.c
monetdb5/modules/mal/batcalc.c
monetdb_config.h.in
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_statement.c
sql/backends/monet5/sql_statement.h
sql/include/sql_catalog.h
sql/server/rel_dump.c
sql/server/rel_optimizer.c
sql/server/rel_rel.c
sql/server/rel_rel.h
sql/server/rel_unnest.c
sql/server/sql_mvc.c
sql/server/sql_mvc.h
sql/storage/bat/bat_storage.c
sql/storage/sql_storage.h
sql/storage/store.c
tools/monetdbe/monetdbe.c
tools/monetdbe/monetdbe.h
Branch: default
Log Message:

Merge with oscar branch.


diffs (truncated from 1060 to 300 lines):

diff --git a/cmake/monetdb-toolchain.cmake b/cmake/monetdb-toolchain.cmake
--- a/cmake/monetdb-toolchain.cmake
+++ b/cmake/monetdb-toolchain.cmake
@@ -67,8 +67,9 @@ function(monetdb_default_toolchain)
 elseif(${CMAKE_C_COMPILER_ID} STREQUAL "Intel")
   if(WIN32)
 set(COMPILER_OPTION "/")
-#MT_addCompilerFlag("${COMPILER_OPTION}DNO_ATOMIC_INSTRUCTIONS" 
"${COMPILER_OPTION}DNO_ATOMIC_INSTRUCTIONS=1" "${CMAKE_C_FLAGS}" "all" 
CMAKE_C_FLAGS)
 MT_addCompilerFlag("${COMPILER_OPTION}W3" "${COMPILER_OPTION}W3" 
"${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS)
+MT_addCompilerFlag("${COMPILER_OPTION}Qdiag-disable:11074" 
"${COMPILER_OPTION}Qdiag-disable:11074" "${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS)
+MT_addCompilerFlag("${COMPILER_OPTION}Qdiag-disable:11075" 
"${COMPILER_OPTION}Qdiag-disable:11075" "${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS)
   else()
 set(COMPILER_OPTION "-")
 MT_addCompilerFlag("${COMPILER_OPTION}Wall" "${COMPILER_OPTION}Wall" 
"${CMAKE_C_FLAGS}" "all" CMAKE_C_FLAGS)
diff --git a/common/utils/matomic.h b/common/utils/matomic.h
--- a/common/utils/matomic.h
+++ b/common/utils/matomic.h
@@ -57,7 +57,9 @@
 /* define this if you don't want to use atomic instructions */
 /* #define NO_ATOMIC_INSTRUCTIONS */
 
-#if defined(HAVE_STDATOMIC_H) && !defined(__STDC_NO_ATOMICS__) && 
!defined(NO_ATOMIC_INSTRUCTIONS)
+/* ignore __STDC_NO_ATOMICS__ if compiling using Intel compiler on
+ * Windows since otherwise we can't compile this at all in C99 mode */
+#if defined(HAVE_STDATOMIC_H) && (!defined(__STDC_NO_ATOMICS__) || 
(defined(__INTEL_COMPILER) && defined(_WINDOWS))) && 
!defined(NO_ATOMIC_INSTRUCTIONS)
 
 #include 
 
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -3063,7 +3063,6 @@ bitmaskjoin(BAT *l, BAT *r,
const char *reason, lng t0)
 {
BAT *r1;
-   const oid *rp = BATtdense(r) ? NULL : Tloc(r, 0);
size_t nmsk = (lci->ncand + 31) / 32;
uint32_t *mask = GDKzalloc(nmsk * sizeof(uint32_t));
BUN cnt = 0;
@@ -3073,13 +3072,9 @@ bitmaskjoin(BAT *l, BAT *r,
 
for (BUN n = 0; n < rci->ncand; n++) {
oid o = canditer_next(rci) - r->hseqbase;
-   if (rp) {
-   o = rp[o];
-   if (is_oid_nil(o))
-   continue;
-   } else {
-   o = o - r->hseqbase + r->tseqbase;
-   }
+   o = BUNtoid(r, o);
+   if (is_oid_nil(o))
+   continue;
o += l->hseqbase;
if (o < lci->seq + l->tseqbase)
continue;
@@ -3362,39 +3357,58 @@ leftjoin(BAT **r1p, BAT **r2p, BAT *l, B
BBPunfix(sr->batCacheid);
if (rc != GDK_SUCCEED)
return rc;
+   if (r2p == NULL) {
+   BBPunfix(r2->batCacheid);
+   r2 = NULL;
+   }
if (semi)
r1->tkey = true;
-   BAT *ob;
-   rc = BATsort(, r2p ?  : NULL, NULL,
-r1, NULL, NULL, false, false, false);
-   BBPunfix(r1->batCacheid);
-   if (rc != GDK_SUCCEED) {
-   BBPunfix(r2->batCacheid);
-   return rc;
+   if (!VIEWtparent(r1) &&
+   r1->ttype == TYPE_oid &&
+   BBP_refs(r1->batCacheid) == 1 &&
+   (r2 == NULL ||
+(!VIEWtparent(r2) &&
+ BBP_refs(r2->batCacheid) == 1 &&
+ r2->ttype == TYPE_oid))) {
+   /* in-place sort if we can */
+   if (r2) {
+   

MonetDB: oscar - Merge with Jun2020 branch.

2020-07-15 Thread Sjoerd Mullender
Changeset: 2fa2e53945be for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2fa2e53945be
Modified Files:
gdk/gdk_join.c
monetdb5/modules/mal/batcalc.c
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_statement.c
sql/backends/monet5/sql_statement.h
sql/include/sql_catalog.h
sql/server/rel_dump.c
sql/server/rel_optimizer.c
sql/server/rel_rel.c
sql/server/rel_rel.h
sql/server/rel_unnest.c
sql/server/sql_mvc.c
sql/server/sql_mvc.h
sql/storage/bat/bat_storage.c
sql/storage/sql_storage.h
sql/storage/store.c
Branch: oscar
Log Message:

Merge with Jun2020 branch.


diffs (truncated from 977 to 300 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -3063,7 +3063,6 @@ bitmaskjoin(BAT *l, BAT *r,
const char *reason, lng t0)
 {
BAT *r1;
-   const oid *rp = BATtdense(r) ? NULL : Tloc(r, 0);
size_t nmsk = (lci->ncand + 31) / 32;
uint32_t *mask = GDKzalloc(nmsk * sizeof(uint32_t));
BUN cnt = 0;
@@ -3073,13 +3072,9 @@ bitmaskjoin(BAT *l, BAT *r,
 
for (BUN n = 0; n < rci->ncand; n++) {
oid o = canditer_next(rci) - r->hseqbase;
-   if (rp) {
-   o = rp[o];
-   if (is_oid_nil(o))
-   continue;
-   } else {
-   o = o - r->hseqbase + r->tseqbase;
-   }
+   o = BUNtoid(r, o);
+   if (is_oid_nil(o))
+   continue;
o += l->hseqbase;
if (o < lci->seq + l->tseqbase)
continue;
@@ -3362,39 +3357,58 @@ leftjoin(BAT **r1p, BAT **r2p, BAT *l, B
BBPunfix(sr->batCacheid);
if (rc != GDK_SUCCEED)
return rc;
+   if (r2p == NULL) {
+   BBPunfix(r2->batCacheid);
+   r2 = NULL;
+   }
if (semi)
r1->tkey = true;
-   BAT *ob;
-   rc = BATsort(, r2p ?  : NULL, NULL,
-r1, NULL, NULL, false, false, false);
-   BBPunfix(r1->batCacheid);
-   if (rc != GDK_SUCCEED) {
-   BBPunfix(r2->batCacheid);
-   return rc;
+   if (!VIEWtparent(r1) &&
+   r1->ttype == TYPE_oid &&
+   BBP_refs(r1->batCacheid) == 1 &&
+   (r2 == NULL ||
+(!VIEWtparent(r2) &&
+ BBP_refs(r2->batCacheid) == 1 &&
+ r2->ttype == TYPE_oid))) {
+   /* in-place sort if we can */
+   if (r2) {
+   GDKqsort(r1->theap.base, r2->theap.base,
+NULL, r1->batCount, r1->twidth,
+r2->twidth, TYPE_oid, false,
+false);
+   r2->tsorted = false;
+   r2->trevsorted = false;
+   *r2p = r2;
+   } else {
+   GDKqsort(r1->theap.base, NULL, NULL,
+r1->batCount, r1->twidth, 0,
+TYPE_oid, false, false);
+   }
+   r1->tsorted = true;
+   r1->trevsorted = false;
+   *r1p = r1;
+   } else {
+   BAT *ob;
+   rc = BATsort(, r2p ?  : NULL, NULL,
+r1, NULL, NULL, false, false, 
false);
+   BBPunfix(r1->batCacheid);
+   if (rc != GDK_SUCCEED) {
+   if (r2)
+   BBPunfix(r2->batCacheid);
+   return rc;
+   }
+   *r1p = r1 = tmp;
+   if (r2p) {
+   tmp = BATproject(ob, r2);
+   BBPunfix(r2->batCacheid);
+   BBPunfix(ob->batCacheid);
+   if (tmp == NULL) {
+   BBPunfix(r1->batCacheid);
+   

MonetDB: Jun2020 - Use in-place sorting if we can.

2020-07-15 Thread Sjoerd Mullender
Changeset: 879bc42e179e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=879bc42e179e
Modified Files:
gdk/gdk_join.c
Branch: Jun2020
Log Message:

Use in-place sorting if we can.


diffs (62 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -3363,14 +3363,51 @@ leftjoin(BAT **r1p, BAT **r2p, BAT *l, B
}
if (semi)
r1->tkey = true;
-   BAT *ob;
-   rc = BATsort(, r2p ?  : NULL, NULL,
-r1, NULL, NULL, false, false, false);
-   BBPunfix(r1->batCacheid);
-   if (rc != GDK_SUCCEED) {
-   if (r2)
+   if (!VIEWtparent(r1) &&
+   r1->ttype == TYPE_oid &&
+   BBP_refs(r1->batCacheid) == 1 &&
+   (r2 == NULL ||
+(!VIEWtparent(r2) &&
+ BBP_refs(r2->batCacheid) == 1 &&
+ r2->ttype == TYPE_oid))) {
+   /* in-place sort if we can */
+   if (r2) {
+   GDKqsort(r1->theap.base, r2->theap.base,
+NULL, r1->batCount, r1->twidth,
+r2->twidth, TYPE_oid, false,
+false);
+   r2->tsorted = false;
+   r2->trevsorted = false;
+   *r2p = r2;
+   } else {
+   GDKqsort(r1->theap.base, NULL, NULL,
+r1->batCount, r1->twidth, 0,
+TYPE_oid, false, false);
+   }
+   r1->tsorted = true;
+   r1->trevsorted = false;
+   *r1p = r1;
+   } else {
+   BAT *ob;
+   rc = BATsort(, r2p ?  : NULL, NULL,
+r1, NULL, NULL, false, false, 
false);
+   BBPunfix(r1->batCacheid);
+   if (rc != GDK_SUCCEED) {
+   if (r2)
+   BBPunfix(r2->batCacheid);
+   return rc;
+   }
+   *r1p = r1 = tmp;
+   if (r2p) {
+   tmp = BATproject(ob, r2);
BBPunfix(r2->batCacheid);
-   return rc;
+   BBPunfix(ob->batCacheid);
+   if (tmp == NULL) {
+   BBPunfix(r1->batCacheid);
+   return GDK_FAIL;
+   }
+   *r2p = tmp;
+   }
}
return GDK_SUCCEED;
}
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - Remove debug code.

2020-07-15 Thread Sjoerd Mullender
Changeset: 2e2315f69357 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2e2315f69357
Modified Files:
gdk/gdk_join.c
Branch: Jun2020
Log Message:

Remove debug code.


diffs (33 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -3372,29 +3372,6 @@ leftjoin(BAT **r1p, BAT **r2p, BAT *l, B
BBPunfix(r2->batCacheid);
return rc;
}
-   *r1p = r1 = tmp;
-   if (r2p) {
-   tmp = BATproject(ob, r2);
-   BBPunfix(r2->batCacheid);
-   BBPunfix(ob->batCacheid);
-   if (tmp == NULL) {
-   BBPunfix(r1->batCacheid);
-   return GDK_FAIL;
-   }
-   *r2p = tmp;
-   }
-#if 0
-#ifndef NDEBUG
-   BAT *x1;
-   canditer_reset();
-   canditer_reset();
-   hashjoin(, NULL, l, r, , , nil_matches, 
false, false, false, false, false, estimate, t0, false, rhash, prhash, func);
-   assert(x1->batCount == r1->batCount);
-   for (BUN x = 0; x < x1->batCount; x++)
-   assert(BUNtoid(r1, x) == BUNtoid(x1, x));
-   BBPunfix(x1->batCacheid);
-#endif
-#endif
return GDK_SUCCEED;
}
}
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Update rst manual pages

2020-07-15 Thread Panagiotis Koutsourakis
Changeset: 8d399b62201a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8d399b62201a
Modified Files:
documentation/source/manual_pages/monetdb.rst
documentation/source/manual_pages/monetdbd.rst.in
Branch: default
Log Message:

Update rst manual pages


diffs (169 lines):

diff --git a/documentation/source/manual_pages/monetdb.rst 
b/documentation/source/manual_pages/monetdb.rst
--- a/documentation/source/manual_pages/monetdb.rst
+++ b/documentation/source/manual_pages/monetdb.rst
@@ -1,7 +1,3 @@
-===
-MONETDB
-===
-
 NAME
 
 
@@ -56,10 +52,10 @@ COMMANDS
 
 The commands for the *monetdb* utility are **create**, **destroy**,
 **lock**, **release**, **status**, **start**, **stop**, **kill**,
-**profilerstart**, **profilerstop**, **set**, **get**, **inherit**,
-**discover**, **help**, and **version**. The commands facilitate adding,
-removing, maintaining, starting and stopping a database inside the
-MonetDB Database Server.
+**profilerstart**, **profilerstop**, **snapshot**, **set**, **get**,
+**inherit**, **discover**, **help**, and **version**. The commands
+facilitate adding, removing, maintaining, starting and stopping a
+database inside the MonetDB Database Server.
 
 For all commands, database arguments can be glob-like expressions. This
 allows to do wildcard matches. For details on the syntax, see
@@ -167,20 +163,21 @@ allows to do wildcard matches. For detai
 **kill [-a]**\ *database*\ **[**\ *database*\ **...]**
 
 Starts, stops or kills the given database, or, when **-a** is supplied,
-all known databases. The **kill** command immediately sends a SIGKILL
-and should only be used as last resort for a database that doesn't
-respond any more. Killing a database may result in (partial) data loss.
-It is more common to use the **stop** command to stop a database. It
-will first attempt to stop the database, waiting for
-**mero_exittimeout** seconds and if that fails, kill the database. When
-using the **start** command, *monetdb*\ (1) will output diagnostic
-messages if the requested action failed. When encountering an error, one
-should always consult the logfile of *monetdbd*\ (1) for more details.
-For the **kill** command a diagnostic message indicating the database
-has crashed is always emitted, due to the nature of that command. Note
-that in combination with **-a** the return code of *monetdb*\ (1)
-indicates failure if one of the databases had a failure, even though the
-operation on other databases was successful.
+all known databases. The **kill** command immediately terminates the
+database by sending the SIGKILL signal. Any data that hasn't been
+committed will be lost. This command should only be used as last resort
+for a database that doesn't respond any more. It is more common to use
+the **stop** command to stop a database. This will first attempt to stop
+the database, waiting for **exittimeout** seconds and if that fails,
+kill the database. When using the **start** command, *monetdb*\ (1) will
+output diagnostic messages if the requested action failed. When
+encountering an error, one should always consult the logfile of
+*monetdbd*\ (1) for more details. For the **kill** command a diagnostic
+message indicating the database has crashed is always emitted, due to
+the nature of that command. Note that in combination with **-a** the
+return code of *monetdb*\ (1) indicates failure if one of the databases
+had a failure, even though the operation on other databases was
+successful.
 
 **profilerstart**\ *database*\ **[**\ *database*\ **...]**
 
@@ -196,6 +193,53 @@ recording the pid of the profiler is wri
 therefore each database needs to have a different **profilerlogpath**
 value.
 
+**monetdb snapshot write**\ *dbname*
+   Takes a snapshot of the given database and writes it to stdout.
+
+**monetdb snapshot create [-t**\ *targetfile*\ **]**\ *dbname*\ **[**\ 
*dbname*\ **..]**
+   Takes a snapshot of the given databases. Here, *dbname* can be either
+   the name of a single database or a pattern such as *staging\**
+   indicating multiple databases to snapshot. Unless **-t** is given,
+   the snapshots are written to files named
+   */_TUTC*
+   where *snapshotdir* is a *monetdbd* setting that has to be configured
+   explicitly using **monetdbd set** and *snapshotcompression* is
+   another **monetdbd** setting which defaults to *.tar.lz4* or *.tar*.
+   If **-t** is given, only a single database can be snapshotted and the
+   snapshot is written to *targetfile*, a file on the server which must
+   be somewhere under *snapshotdir* but which does not have to follow
+   any particular naming convention.
+
+**monetdb snapshot list [**\ *dbname*\ **..]**
+   Lists the snapshots for the given databases, or all databases if none
+   is given, showing the snapshot id, the time the snapshot was taken
+   and the (compressed) size of the snapshot file. Only snapshots
+   following the naming convention described under **monetdb snapshot
+ 

MonetDB: Jun2020 - use leftjoin for update statements to make su...

2020-07-15 Thread Niels Nes
Changeset: 8c1c4d44c37e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8c1c4d44c37e
Modified Files:
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_statement.c
sql/backends/monet5/sql_statement.h
sql/include/sql_catalog.h
sql/server/rel_dump.c
Branch: Jun2020
Log Message:

use leftjoin for update statements to make sure the replace is in order of the 
storage


diffs (283 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
@@ -433,7 +433,7 @@ handle_in_exps(backend *be, sql_exp *ce,
s = stmt_project(be, stmt_selectnonil(be, s, NULL), s);
}
 
-   s = stmt_join(be, c, s, in, cmp_left, 0, false);
+   s = stmt_join(be, c, s, in, cmp_equal, 1, 0, false);
s = stmt_result(be, s, 0);
 
if (!in) {
@@ -1060,9 +1060,9 @@ exp_bin(backend *be, sql_exp *e, stmt *l
if (r2) {
s = stmt_join2(be, l, r, r2, 
(comp_type)e->flag, is_anti(e), swapped);
} else if (swapped) {
-   s = stmt_join(be, r, l, is_anti(e), 
swap_compare((comp_type)e->flag), is_semantics(e), false);
+   s = stmt_join(be, r, l, is_anti(e), 
swap_compare((comp_type)e->flag), 0, is_semantics(e), false);
} else {
-   s = stmt_join(be, l, r, is_anti(e), 
(comp_type)e->flag, is_semantics(e), false);
+   s = stmt_join(be, l, r, is_anti(e), 
(comp_type)e->flag, 0, is_semantics(e), false);
}
} else {
if (r2) {
@@ -2069,9 +2069,9 @@ rel2bin_hash_lookup(backend *be, sql_rel
}
if (h && h->nrcols) {
if (!swap_rel) {
-   return stmt_join(be, idx, h, 0, cmp_equal, semantics, 
false);
+   return stmt_join(be, idx, h, 0, cmp_equal, 0, 
semantics, false);
} else {
-   return stmt_join(be, h, idx, 0, cmp_equal, semantics, 
false);
+   return stmt_join(be, h, idx, 0, cmp_equal, 0, 
semantics, false);
}
} else {
return stmt_uselect(be, idx, h, cmp_equal, NULL, 0, semantics);
@@ -2121,9 +2121,7 @@ releqjoin( backend *be, list *l1, list *
e = n3->data;
is_semantics = is_semantics(e);
}
-   r =  stmt_join(be, l, r, 0, cmp_op, is_semantics, false);
-   if (need_left)
-   r->flag = cmp_left;
+   r =  stmt_join(be, l, r, 0, cmp_op, need_left, is_semantics, 
false);
return r;
}
if (used_hash) {
@@ -2132,14 +2130,12 @@ releqjoin( backend *be, list *l1, list *
n1 = n1->next;
n2 = n2->next;
n3 = n3?n3->next:NULL;
-   res = stmt_join(be, l, r, 0, cmp_op, 1, false);
+   res = stmt_join(be, l, r, 0, cmp_op, need_left, 1, false);
} else { /* need hash */
l = join_hash_key(be, l1);
r = join_hash_key(be, l2);
-   res = stmt_join(be, l, r, 0, cmp_op, 1, false);
-   }
-   if (need_left)
-   res->flag = cmp_left;
+   res = stmt_join(be, l, r, 0, cmp_op, need_left, 1, false);
+   }
l = stmt_result(be, res, 0);
r = stmt_result(be, res, 1);
for (; n1 && n2; n1 = n1->next, n2 = n2->next, n3 = n3?n3->next:NULL) {
@@ -2170,7 +2166,7 @@ releqjoin( backend *be, list *l1, list *
l = stmt_project(be, cmp, l );
r = stmt_project(be, cmp, r );
}
-   res = stmt_join(be, l, r, 0, cmp_joined, 0, false);
+   res = stmt_join(be, l, r, 0, cmp_joined, 0, 0, false);
return res;
 }
 
@@ -2306,7 +2302,7 @@ rel2bin_join(backend *be, sql_rel *rel, 
if (list_empty(jexps)) { /* cross product and continue after 
project */
stmt *l = bin_first_column(be, left);
stmt *r = bin_first_column(be, right);
-   join = stmt_join(be, l, r, 0, cmp_all, 0, false);
+   join = stmt_join(be, l, r, 0, cmp_all, 0, 0, false);
}
 
if (join) {
@@ -2362,17 +2358,15 @@ rel2bin_join(backend *be, sql_rel *rel, 
}
if (list_length(lje) > 1) {
join = releqjoin(be, lje, rje, exps, used_hash, 
cmp_equal, need_left, 0);
-   } else if (!join) {
+   } else if (!join || need_left) {
sql_exp *e = exps->h->data;
-   join = stmt_join(be, lje->h->data, 

MonetDB: Jun2020 - Add missing unfix.

2020-07-15 Thread Sjoerd Mullender
Changeset: a44c6d7052f1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a44c6d7052f1
Modified Files:
gdk/gdk_join.c
Branch: Jun2020
Log Message:

Add missing unfix.


diffs (24 lines):

diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -3357,6 +3357,10 @@ leftjoin(BAT **r1p, BAT **r2p, BAT *l, B
BBPunfix(sr->batCacheid);
if (rc != GDK_SUCCEED)
return rc;
+   if (r2p == NULL) {
+   BBPunfix(r2->batCacheid);
+   r2 = NULL;
+   }
if (semi)
r1->tkey = true;
BAT *ob;
@@ -3364,7 +3368,8 @@ leftjoin(BAT **r1p, BAT **r2p, BAT *l, B
 r1, NULL, NULL, false, false, false);
BBPunfix(r1->batCacheid);
if (rc != GDK_SUCCEED) {
-   BBPunfix(r2->batCacheid);
+   if (r2)
+   BBPunfix(r2->batCacheid);
return rc;
}
*r1p = r1 = tmp;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - Look for alocation failures and allocate less

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

Look for alocation failures and allocate less


diffs (41 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
@@ -7627,15 +7627,29 @@ score_se(mvc *sql, sql_rel *rel, sql_exp
 static sql_rel *
 rel_select_order(visitor *v, sql_rel *rel)
 {
-   if (is_select(rel->op) && rel->exps && list_length(rel->exps)>1) {
-   int i, *scores = GDKzalloc(list_length(rel->exps) * 
sizeof(int));
+   int *scores = NULL;
+   sql_exp **exps = NULL;
+
+   if (is_select(rel->op) && list_length(rel->exps) > 1) {
node *n;
-
-   for (i = 0, n = rel->exps->h; n; i++, n = n->next)
-   scores[i] = score_se(v->sql, rel, n->data);
-   rel->exps = list_keysort(rel->exps, scores, (fdup)NULL);
-   GDKfree(scores);
-   }
+   int i, nexps = list_length(rel->exps);
+   scores = GDKmalloc(nexps * sizeof(int));
+   exps = GDKmalloc(nexps * sizeof(sql_exp*));
+
+   if (scores && exps) {
+   for (i = 0, n = rel->exps->h; n; i++, n = n->next) {
+   exps[i] = n->data;
+   scores[i] = score_se(v->sql, rel, n->data);
+   }
+   GDKqsort(scores, exps, NULL, nexps, sizeof(int), 
sizeof(void *), TYPE_int, true, true);
+
+   for (i = 0, n = rel->exps->h; n; i++, n = n->next)
+   n->data = exps[i];
+   }
+   }
+
+   GDKfree(scores);
+   GDKfree(exps);
return rel;
 }
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - merge 2 projects where last only does simple ...

2020-07-15 Thread Niels Nes
Changeset: 9c63366d0dc3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9c63366d0dc3
Modified Files:
sql/server/rel_optimizer.c
Branch: Jun2020
Log Message:

merge 2 projects where last only does simple (useless) renames and no reduction 
of number of columns


diffs (17 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
@@ -5662,7 +5662,12 @@ rel_push_project_down(visitor *v, sql_re
return l;
 #endif
} else if (list_check_prop_all(rel->exps, 
(prop_check_func)_is_useless_rename)) {
-   if (is_select(l->op)) {
+   if (is_simple_project(l->op) && list_length(l->exps) == 
list_length(rel->exps)) {
+   rel->l = NULL;
+   rel_destroy(rel);
+   v->changes++;
+   return l;
+   } else if (is_select(l->op)) {
/* push project under select (include exps used 
by selection) */
l->l = rel_project(v->sql->sa, l->l, 
rel_projections(v->sql, l, NULL, 1, 1));
l->l = rel_push_project_down(v, l->l);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - Added some missing unfixes.

2020-07-15 Thread Sjoerd Mullender
Changeset: 6b087b674ffc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6b087b674ffc
Modified Files:
monetdb5/modules/mal/batcalc.c
Branch: Jun2020
Log Message:

Added some missing unfixes.


diffs (30 lines):

diff --git a/monetdb5/modules/mal/batcalc.c b/monetdb5/modules/mal/batcalc.c
--- a/monetdb5/modules/mal/batcalc.c
+++ b/monetdb5/modules/mal/batcalc.c
@@ -74,6 +74,8 @@ CMDbatUNARY(MalStkPtr stk, InstrPtr pci,
BBPunfix(b->batCacheid);
if (s)
BBPunfix(s->batCacheid);
+   if (r)
+   BBPunfix(r->batCacheid);
if (bn == NULL) {
return mythrow(MAL, malfunc, OPERATION_FAILED);
}
@@ -122,6 +124,8 @@ CMDbatUNARY1(MalStkPtr stk, InstrPtr pci
BBPunfix(b->batCacheid);
if (s)
BBPunfix(s->batCacheid);
+   if (r)
+   BBPunfix(r->batCacheid);
if (bn == NULL) {
return mythrow(MAL, malfunc, OPERATION_FAILED);
}
@@ -1309,6 +1313,8 @@ CMDconvertbat(MalStkPtr stk, InstrPtr pc
BBPunfix(b->batCacheid);
if (s)
BBPunfix(s->batCacheid);
+   if (r)
+   BBPunfix(r->batCacheid);
if (bn == NULL) {
char buf[20];
snprintf(buf, sizeof(buf), "batcalc.%s", ATOMname(tp));
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Jun2020 - Check tkey property for uniqueness, and give ...

2020-07-15 Thread Pedro Ferreira
Changeset: 9d91604e3407 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9d91604e3407
Modified Files:
sql/server/rel_optimizer.c
sql/server/sql_mvc.c
sql/server/sql_mvc.h
sql/storage/bat/bat_storage.c
sql/storage/sql_storage.h
sql/storage/store.c
Branch: Jun2020
Log Message:

Check tkey property for uniqueness, and give higher score for distinct columns


diffs (133 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
@@ -5791,20 +5791,20 @@ sql_class_base_score(mvc *sql, sql_colum
}
 }
 
-/* Compute the efficiency of using this expression early in a group by list */
+/* Compute the efficiency of using this expression early in a group by 
list */
 static int
 score_gbe(mvc *sql, sql_rel *rel, sql_exp *e)
 {
int res = 0;
sql_subtype *t = exp_subtype(e);
-   sql_column *c = NULL;
+   sql_column *c = exp_find_column(rel, e, -2);
 
if (e->card == CARD_ATOM) /* constants are trivial to group */
res += 1000;
/* can we find out if the underlying table is sorted */
-   if (find_prop(e->p, PROP_HASHCOL)) /* distinct columns */
-   res += 600;
-   if ((c = exp_find_column(rel, e, -2)) && mvc_is_sorted(sql, c))
+   if (find_prop(e->p, PROP_HASHCOL) || (c && mvc_is_unique(sql, c))) /* 
distinct columns */
+   res += 700;
+   if (c && mvc_is_sorted(sql, c))
res += 500;
if (find_prop(e->p, PROP_SORTIDX)) /* has sort index */
res += 300;
diff --git a/sql/server/sql_mvc.c b/sql/server/sql_mvc.c
--- a/sql/server/sql_mvc.c
+++ b/sql/server/sql_mvc.c
@@ -1629,6 +1629,13 @@ mvc_is_sorted(mvc *m, sql_column *col)
 }
 
 int
+mvc_is_unique(mvc *m, sql_column *col)
+{
+   TRC_DEBUG(SQL_TRANS, "Is unique: %s\n", col->base.name);
+   return sql_trans_is_unique(m->session->tr, col);
+}
+
+int
 mvc_is_duplicate_eliminated(mvc *m, sql_column *col)
 {
TRC_DEBUG(SQL_TRANS, "Is duplicate eliminated: %s\n", col->base.name);
diff --git a/sql/server/sql_mvc.h b/sql/server/sql_mvc.h
--- a/sql/server/sql_mvc.h
+++ b/sql/server/sql_mvc.h
@@ -212,6 +212,7 @@ extern sql_column *mvc_drop_default(mvc 
 extern sql_column *mvc_storage(mvc *c, sql_column *col, char *storage);
 extern sql_table * mvc_access(mvc *m, sql_table *t, sht access);
 extern int mvc_is_sorted(mvc *c, sql_column *col);
+extern int mvc_is_unique(mvc *m, sql_column *col);
 extern int mvc_is_duplicate_eliminated(mvc *c, sql_column *col);
 
 extern sql_ukey *mvc_create_ukey(mvc *m, sql_table *t, const char *kname, 
key_type kt);
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -1247,6 +1247,27 @@ sorted_col(sql_trans *tr, sql_column *co
 }
 
 static int
+unique_col(sql_trans *tr, sql_column *col)
+{
+   int distinct = 0;
+
+   assert(tr->active || tr == gtrans);
+   if (!isTable(col->t) || !col->t->s)
+   return 0;
+   /* fallback to central bat */
+   if (tr && tr->parent && !col->data && col->po)
+   col = col->po;
+
+   if (col && col->data) {
+   BAT *b = bind_col(tr, col, QUICK);
+
+   if (b)
+   distinct = b->tkey;
+   }
+   return distinct;
+}
+
+static int
 double_elim_col(sql_trans *tr, sql_column *col)
 {
int de = 0;
@@ -3102,6 +3123,7 @@ bat_storage_init( store_functions *sf)
sf->count_idx = (count_idx_fptr)_idx;
sf->dcount_col = (dcount_col_fptr)_col;
sf->sorted_col = (prop_col_fptr)_col;
+   sf->unique_col = (prop_col_fptr)_col;
sf->double_elim_col = (prop_col_fptr)_elim_col;
 
sf->create_col = (create_col_fptr)_col;
diff --git a/sql/storage/sql_storage.h b/sql/storage/sql_storage.h
--- a/sql/storage/sql_storage.h
+++ b/sql/storage/sql_storage.h
@@ -247,6 +247,7 @@ typedef struct store_functions {
count_idx_fptr count_idx;
dcount_col_fptr dcount_col;
prop_col_fptr sorted_col;
+   prop_col_fptr unique_col;
prop_col_fptr double_elim_col; /* varsize col with double elimination */
 
create_col_fptr create_col;
@@ -439,6 +440,7 @@ extern sql_column *sql_trans_alter_null(
 extern sql_column *sql_trans_alter_default(sql_trans *tr, sql_column *col, 
char *val);
 extern sql_column *sql_trans_alter_storage(sql_trans *tr, sql_column *col, 
char *storage);
 extern int sql_trans_is_sorted(sql_trans *tr, sql_column *col);
+extern int sql_trans_is_unique(sql_trans *tr, sql_column *col);
 extern int sql_trans_is_duplicate_eliminated(sql_trans *tr, sql_column *col);
 extern size_t sql_trans_dist_count(sql_trans *tr, sql_column *col);
 extern int sql_trans_ranges(sql_trans *tr, sql_column *col, char **min, char 
**max);
diff --git a/sql/storage/store.c 

MonetDB: Jun2020 - A reverse ordered column is also sorted

2020-07-15 Thread Pedro Ferreira
Changeset: e86232fa99e8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e86232fa99e8
Modified Files:
sql/storage/bat/bat_storage.c
Branch: Jun2020
Log Message:

A reverse ordered column is also sorted


diffs (12 lines):

diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -1241,7 +1241,7 @@ sorted_col(sql_trans *tr, sql_column *co
BAT *b = bind_col(tr, col, QUICK);
 
if (b)
-   sorted = BATtordered(b);
+   sorted = BATtordered(b) || BATtrevordered(b);
}
return sorted;
 }
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list