Changeset: 0088b1147885 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0088b1147885
Added Files:
        sql/test/BugTracker-2018/Tests/ordered-index-error.Bug-6572.sql
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case-nullif-coalesce.Bug-6565.stable.err
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case-nullif-coalesce.Bug-6565.stable.out
        sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case.Bug-6568.sql
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case.Bug-6568.stable.err
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case.Bug-6568.stable.out
        sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case.Bug-6573.sql
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-mal-calc-undefined.Bug-6566.stable.err
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-mal-calc-undefined.Bug-6566.stable.out
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-not-between-wrong.Bug-6569.sql
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-undefined-calc.Bug-6570.sql
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-undefined-calc.Bug-6570.stable.err
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-undefined-calc.Bug-6570.stable.out
Modified Files:
        clients/Tests/exports.stable.out
        common/utils/muuid.h
        gdk/gdk_cross.c
        gdk/gdk_group.c
        monetdb5/mal/mal_interpreter.c
        sql/server/rel_exp.c
        sql/server/rel_exp.h
        sql/server/rel_optimizer.c
        sql/server/rel_select.c
        sql/test/BugTracker-2015/Tests/null.Bug-3833.stable.out
        sql/test/BugTracker-2016/Tests/null_in_null.Bug-3900.stable.out
        sql/test/BugTracker-2018/Tests/All
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-complex-case-nullif-coalesce.Bug-6565.sql
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-mal-calc-undefined.Bug-6566.sql
        
sql/test/BugTracker-2018/Tests/sqlitelogictest-wrong-cast-null.Bug-6551.stable.out
        sql/test/bugs/Tests/create_insert_select_aggr-bug-00001.stable.out
        sql/test/mergetables/Tests/part-elim.stable.out
        testing/listexports.py.in
Branch: mapi_changes
Log Message:

Merge with default


diffs (truncated from 942 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
@@ -428,16 +428,6 @@ lng logger_read_last_transaction_id(logg
 gdk_return logger_reload(logger *lg);
 gdk_return logger_restart(logger *lg);
 int logger_sequence(logger *lg, int seq, lng *id);
-char *mcrypt_BackendSum(const char *string, size_t len);
-char *mcrypt_MD5Sum(const char *string, size_t len);
-char *mcrypt_RIPEMD160Sum(const char *string, size_t len);
-char *mcrypt_SHA1Sum(const char *string, size_t len);
-char *mcrypt_SHA224Sum(const char *string, size_t len);
-char *mcrypt_SHA256Sum(const char *string, size_t len);
-char *mcrypt_SHA384Sum(const char *string, size_t len);
-char *mcrypt_SHA512Sum(const char *string, size_t len);
-const char *mcrypt_getHashAlgorithms(void);
-char *mcrypt_hashPassword(const char *algo, const char *password, const char 
*challenge);
 void *mdlopen(const char *library, int mode);
 int mo_add_option(opt **Set, int setlen, opt_kind kind, const char *name, 
const char *value);
 int mo_builtin_settings(opt **Set);
@@ -445,23 +435,6 @@ char *mo_find_option(opt *set, int setle
 void mo_free_options(opt *set, int setlen);
 void mo_print_options(opt *set, int setlen);
 int mo_system_config(opt **Set, int setlen);
-void msab_dbfarminit(const char *dbfarm);
-void msab_dbpathinit(const char *dbpath);
-char *msab_deserialise(sabdb **ret, char *sabdb);
-char *msab_freeStatus(sabdb **ret);
-char *msab_getDBfarm(char **ret);
-char *msab_getDBname(char **ret);
-char *msab_getMyStatus(sabdb **ret);
-char *msab_getStatus(sabdb **ret, char *dbname);
-char *msab_getUplogInfo(sabuplog *ret, const sabdb *db);
-char *msab_marchConnection(const char *host, const int port);
-char *msab_marchScenario(const char *lang);
-char *msab_registerStarted(void);
-char *msab_registerStarting(void);
-char *msab_registerStop(void);
-char *msab_retreatScenario(const char *lang);
-char *msab_serialise(char **ret, const sabdb *db);
-char *msab_wildRetreat(void);
 const oid oid_nil;
 DIR *opendir(const char *dirname);
 void print_trace(void);
@@ -595,6 +568,22 @@ MapiMsg mapi_timeout(Mapi mid, unsigned 
 void mapi_trace(Mapi mid, int flag);
 char *mapi_unquote(char *msg);
 MapiMsg mapi_virtual_result(MapiHdl hdl, int columns, const char 
**columnnames, const char **columntypes, const int *columnlengths, int 
tuplecount, const char ***tuples);
+char *mcrypt_BackendSum(const char *string, size_t len);
+char *mcrypt_MD5Sum(const char *string, size_t len);
+char *mcrypt_RIPEMD160Sum(const char *string, size_t len);
+char *mcrypt_SHA1Sum(const char *string, size_t len);
+char *mcrypt_SHA224Sum(const char *string, size_t len);
+char *mcrypt_SHA256Sum(const char *string, size_t len);
+char *mcrypt_SHA384Sum(const char *string, size_t len);
+char *mcrypt_SHA512Sum(const char *string, size_t len);
+const char *mcrypt_getHashAlgorithms(void);
+char *mcrypt_hashPassword(const char *algo, const char *password, const char 
*challenge);
+int mo_add_option(opt **Set, int setlen, opt_kind kind, const char *name, 
const char *value);
+int mo_builtin_settings(opt **Set);
+char *mo_find_option(opt *set, int setlen, const char *name);
+void mo_free_options(opt *set, int setlen);
+void mo_print_options(opt *set, int setlen);
+int mo_system_config(opt **Set, int setlen);
 const char *wsaerror(int);
 
 # monetdb5
@@ -2367,6 +2356,23 @@ char monet_characteristics[4096];
 char monet_cwd[FILENAME_MAX];
 size_t monet_memory;
 void moveInstruction(MalBlkPtr mb, int pc, int target);
+void msab_dbfarminit(const char *dbfarm);
+void msab_dbpathinit(const char *dbpath);
+char *msab_deserialise(sabdb **ret, char *sabdb);
+char *msab_freeStatus(sabdb **ret);
+char *msab_getDBfarm(char **ret);
+char *msab_getDBname(char **ret);
+char *msab_getMyStatus(sabdb **ret);
+char *msab_getStatus(sabdb **ret, char *dbname);
+char *msab_getUplogInfo(sabuplog *ret, const sabdb *db);
+char *msab_marchConnection(const char *host, const int port);
+char *msab_marchScenario(const char *lang);
+char *msab_registerStarted(void);
+char *msab_registerStarting(void);
+char *msab_registerStop(void);
+char *msab_retreatScenario(const char *lang);
+char *msab_serialise(char **ret, const sabdb *db);
+char *msab_wildRetreat(void);
 void mserver_reset(int exit);
 str mtimeRef;
 str mulRef;
diff --git a/common/utils/muuid.h b/common/utils/muuid.h
--- a/common/utils/muuid.h
+++ b/common/utils/muuid.h
@@ -14,11 +14,13 @@
  * exported so that the call in sql can be satisfied by the version
  * that is included in monetdb5 */
 extern
-#if defined(WIN32) && !defined(LIBMSABAOTH) && !defined(LIBMUUID)
+#ifdef WIN32
+#if !defined(LIBMSABAOTH) && !defined(LIBMUUID)
 __declspec(dllimport)
 #else
 __declspec(dllexport)
 #endif
+#endif
 char *generateUUID(void);
 
 #endif
diff --git a/gdk/gdk_cross.c b/gdk/gdk_cross.c
--- a/gdk/gdk_cross.c
+++ b/gdk/gdk_cross.c
@@ -36,8 +36,13 @@ BATsubcross(BAT **r1p, BAT **r2p, BAT *l
                cnt2 = rcandend - rcand;
 
        bn1 = COLnew(0, TYPE_oid, cnt1 * cnt2, TRANSIENT);
-       if (bn1 == NULL)
+       bn2 = COLnew(0, TYPE_oid, cnt1 * cnt2, TRANSIENT);
+       if (bn1 == NULL || bn2 == NULL) {
+               BBPreclaim(bn1);
+               BBPreclaim(bn2);
                return GDK_FAIL;
+       }
+
        BATsetcount(bn1, cnt1 * cnt2);
        bn1->tsorted = 1;
        bn1->trevsorted = cnt1 <= 1;
@@ -58,13 +63,8 @@ BATsubcross(BAT **r1p, BAT **r2p, BAT *l
                BATtseqbase(bn1, bn1->tkey ? seq : oid_nil);
        }
 
-       bn2 = COLnew(0, TYPE_oid, cnt1 * cnt2, TRANSIENT);
-       if (bn2 == NULL) {
-               BBPreclaim(bn1);
-               return GDK_FAIL;
-       }
        BATsetcount(bn2, cnt1 * cnt2);
-       bn2->tsorted = cnt1 <= 1;
+       bn2->tsorted = cnt1 <= 1 || cnt2 <= 1;
        bn2->trevsorted = cnt2 <= 1;
        bn2->tkey = cnt1 <= 1;
        bn2->tnil = 0;
diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c
--- a/gdk/gdk_group.c
+++ b/gdk/gdk_group.c
@@ -633,7 +633,7 @@ BATgroup_internal(BAT **groups, BAT **ex
                                en->tnonil = 1;
                                en->tseqbase = oid_nil;
                        } else {
-                               en = BATdense(0, b->hseqbase, cnt);
+                               en = BATdense(0, b->hseqbase + start, cnt);
                                if (en == NULL)
                                        goto error;
                        }
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -655,8 +655,7 @@ str runMALsequence(Client cntxt, MalBlkP
                                                BAT *_b = BATdescriptor(bid);
                                                t = getBatType(t);
                                                assert(stk->stk[a].vtype == 
TYPE_bat);
-                                               assert(bid == 0 ||
-                                                          is_bat_nil(bid) ||
+                                               assert(is_bat_nil(bid) ||
                                                           t == TYPE_any ||
                                                           ATOMtype(_b->ttype) 
== ATOMtype(t));
                                                if(_b) BBPunfix(bid);
@@ -680,8 +679,7 @@ str runMALsequence(Client cntxt, MalBlkP
                                        bat bid = stk->stk[a].val.bval;
                                        t = getBatType(t);
                                        assert(stk->stk[a].vtype == TYPE_bat);
-                                       assert(bid == 0 ||
-                                                  is_bat_nil(bid) ||
+                                       assert(is_bat_nil(bid) ||
                                                   t == TYPE_any ||
                                                   
ATOMtype(BBP_desc(bid)->ttype) == ATOMtype(t));
                                } else {
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
@@ -1977,3 +1977,43 @@ exp_flatten(mvc *sql, sql_exp *e)
        return NULL;
 }
 
+void
+exp_sum_scales(sql_subfunc *f, sql_exp *l, sql_exp *r)
+{
+       sql_arg *ares = f->func->res->h->data;
+
+       if (strcmp(f->func->imp, "*") == 0 && ares->type.type->scale == 
SCALE_FIX) {
+               sql_subtype t;
+               sql_subtype *lt = exp_subtype(l);
+               sql_subtype *rt = exp_subtype(r);
+               sql_subtype *res = f->res->h->data;
+
+               res->scale = lt->scale + rt->scale;
+               res->digits = lt->digits + rt->digits;
+
+               /* HACK alert: digits should be less than max */
+#ifdef HAVE_HGE
+               if (have_hge) {
+                       if (ares->type.type->radix == 10 && res->digits > 39)
+                               res->digits = 39;
+                       if (ares->type.type->radix == 2 && res->digits > 128)
+                               res->digits = 128;
+               } else
+#endif
+               {
+
+                       if (ares->type.type->radix == 10 && res->digits > 19)
+                               res->digits = 19;
+                       if (ares->type.type->radix == 2 && res->digits > 64)
+                               res->digits = 64;
+               }
+
+               /* numeric types are fixed length */
+               if (ares->type.type->eclass == EC_NUM) {
+                       sql_find_numeric(&t, ares->type.type->localtype, 
res->digits);
+               } else {
+                       sql_find_subtype(&t, ares->type.type->sqlname, 
res->digits, res->scale);
+               }
+               *res = t;
+       }
+}
diff --git a/sql/server/rel_exp.h b/sql/server/rel_exp.h
--- a/sql/server/rel_exp.h
+++ b/sql/server/rel_exp.h
@@ -150,4 +150,6 @@ extern int is_identity( sql_exp *e, sql_
 
 extern atom *exp_flatten(mvc *sql, sql_exp *e);
 
+extern void exp_sum_scales(sql_subfunc *f, sql_exp *l, sql_exp *r);
+
 #endif /* _REL_EXP_H_ */
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
@@ -2880,15 +2880,20 @@ exp_simplify_math( mvc *sql, sql_exp *e,
                if (!f->func->s && list_length(l) == 2) {
                        sql_exp *le = l->h->data;
                        sql_exp *re = l->h->next->data;
+                       sql_subtype *et = exp_subtype(e);
 
                        if (exp_is_atom(le) && exp_is_null(sql, le)) {
                                (*changes)++;
                                exp_setname(sql->sa, le, exp_relname(e), 
exp_name(e));
+                               if (subtype_cmp(et, exp_subtype(le)) != 0)
+                                       le = exp_convert(sql->sa, le, 
exp_subtype(le), et);
                                return le;
                        }
                        if (exp_is_atom(re) && exp_is_null(sql, re)) {
                                (*changes)++;
                                exp_setname(sql->sa, re, exp_relname(e), 
exp_name(e));
+                               if (subtype_cmp(et, exp_subtype(re)) != 0)
+                                       re = exp_convert(sql->sa, re, 
exp_subtype(re), et);
                                return re;
                        }
                }
@@ -2937,10 +2942,11 @@ exp_simplify_math( mvc *sql, sql_exp *e,
                                }
                        }
                        /* move constants to the right, ie c*A = A*c */
-                       /* TODO beware of overflow,  */
                        else if (exp_is_atom(le)) {
                                l->h->data = re;
                                l->h->next->data = le;
+                               e->f = sql_bind_func(sql->sa, NULL, "sql_mul", 
exp_subtype(re), exp_subtype(le), F_FUNC);
+                               exp_sum_scales(e->f, re, le);
                                (*changes)++;
                                return e;
                        }
@@ -2988,9 +2994,13 @@ exp_simplify_math( mvc *sql, sql_exp *e,
                                                append(l, lre);
                                                append(l, re);
                                                le->l = l;
+                                               le->f = sql_bind_func(sql->sa, 
NULL, "sql_mul", exp_subtype(lre), exp_subtype(re), F_FUNC);
+                                               exp_sum_scales(le->f, lre, re);
                                                l = e->l;
                                                l->h->data = lle;
                                                l->h->next->data = le;
+                                               e->f = sql_bind_func(sql->sa, 
NULL, "sql_mul", exp_subtype(lle), exp_subtype(le), F_FUNC);
+                                               exp_sum_scales(e->f, lle, le);
                                                (*changes)++;
                                                return e;
                                        }
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
@@ -184,6 +184,8 @@ rel_project2groupby(mvc *sql, sql_rel *g
                g->op = op_groupby;
                g->r = new_exp_list(sql->sa); /* add empty groupby column list 
*/
                
+               if (!g->exps)
+                       g->exps = new_exp_list(sql->sa);
                for (en = g->exps->h; en; en = en->next) {
                        sql_exp *e = en->data;
 
@@ -1339,63 +1341,6 @@ rel_check_type(mvc *sql, sql_subtype *t,
 }
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to