Changeset: e1b8f3977a5f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e1b8f3977a5f
Added Files:
        
sql/test/BugDay_2005-10-06_2.9.3/Tests/parser_crashes_server.SF-921996.stable.err.Darwin
Modified Files:
        gdk/gdk_system.h
        monetdb5/mal/mal_prelude.c
        monetdb5/mal/mel.h
        sql/server/rel_optimizer.c
        sql/server/rel_select.c
        sql/test/SQLancer/Tests/sqlancer03.sql
        sql/test/SQLancer/Tests/sqlancer03.stable.out
Branch: default
Log Message:

Merged with oscar


diffs (truncated from 454 to 300 lines):

diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -34,6 +34,7 @@
 #define __has_attribute__alloc_size__ 1
 #define __has_attribute__cold__ 1
 #define __has_attribute__format__ 1
+#define __has_attribute__designated_init__ 0
 #define __has_attribute__malloc__ 1
 #define __has_attribute__nonstring__ 0
 #define __has_attribute__noreturn__ 1
@@ -65,6 +66,9 @@
 #if !__has_attribute(__pure__)
 #define __pure__
 #endif
+#if !__has_attribute(__designated_init__)
+#define __designated_init__
+#endif
 /* these are used in some *private.h files */
 #if !__has_attribute(__visibility__)
 #define __visibility__(a)
diff --git a/monetdb5/mal/mal_prelude.c b/monetdb5/mal/mal_prelude.c
--- a/monetdb5/mal/mal_prelude.c
+++ b/monetdb5/mal/mal_prelude.c
@@ -10,7 +10,7 @@
  * This module takes the statically defined modules, atoms, commands and 
patterns
  * and populate the internal structures.
  *
-*/
+ */
 
 #include "monetdb_config.h"
 #include "mal_import.h"
@@ -39,10 +39,10 @@ mal_startup(void)
 }
 
 /* all MAL related functions register themselves
-* the order in which these registrations happen is significant
-* because there may be dependencies among the definitions.
-* For example, you better know the atoms before you use them
-*/
+ * the order in which these registrations happen is significant
+ * because there may be dependencies among the definitions.
+ * For example, you better know the atoms before you use them
+ */
 
 void
 mal_module2(str name, mel_atom *atoms, mel_func *funcs, mel_init initfunc, 
const char *code)
@@ -80,16 +80,16 @@ initModule(Client c, char *name)
                if (s) {
                        InstrPtr pci = getInstrPtr(s->def, 0);
 
-                               if (pci && pci->token == COMMANDsymbol && 
pci->argc == 1) {
-                                       int ret = 0;
+                       if (pci && pci->token == COMMANDsymbol && pci->argc == 
1) {
+                               int ret = 0;
 
-                                       assert(pci->fcn != NULL);
-                                       (*pci->fcn)(&ret);
-                                       (void)ret;
-                               } else if (pci && pci->token == PATTERNsymbol) {
-                                       assert(pci->fcn != NULL);
-                                       (*pci->fcn)(c, NULL, NULL, NULL);
-                               }
+                               assert(pci->fcn != NULL);
+                               (*pci->fcn)(&ret);
+                               (void)ret;
+                       } else if (pci && pci->token == PATTERNsymbol) {
+                               assert(pci->fcn != NULL);
+                               (*pci->fcn)(c, NULL, NULL, NULL);
+                       }
                }
        }
 }
@@ -184,14 +184,14 @@ makeArgument(MalBlkPtr mb, mel_arg *a, i
                        tpe = newBatType(tpe);
        }
        /*
-       if (a->name){
-               *idx = findVariableLength(mb, a->name, l = strlen(a->name));
-               if( *idx != -1)
-                       throw(LOADER, "addFunctions", "Duplicate argument name 
%s", a->name);
-               *idx = newVariable(mb, a->name, l, tpe);
-       } else
+         if (a->name){
+         *idx = findVariableLength(mb, a->name, l = strlen(a->name));
+         if( *idx != -1)
+         throw(LOADER, "addFunctions", "Duplicate argument name %s", a->name);
+         *idx = newVariable(mb, a->name, l, tpe);
+         } else
        */
-               *idx = newTmpVariable(mb, tpe);
+       *idx = newTmpVariable(mb, tpe);
        return MAL_SUCCEED;
 }
 
@@ -251,11 +251,11 @@ addFunctions(mel_func *fcn){
                        if (a->nr > 0) {
                                if (a->isbat)
                                        tpe = newBatType(tpe);
-                               setPolymorphic(sig, tpe, TRUE);
+                               setPolymorphic(sig, tpe, TRUE);
                        }
                        if (a->vargs) {
-                               sig->varargs |= VARRETS;
-                               setPolymorphic(sig, TYPE_any, TRUE);
+                               sig->varargs |= VARRETS;
+                               setPolymorphic(sig, TYPE_any, TRUE);
                        }
                }
                /* add the arguments */
@@ -272,11 +272,11 @@ addFunctions(mel_func *fcn){
                        if (a->nr > 0) {
                                if (a->isbat)
                                        tpe = newBatType(tpe);
-                               setPolymorphic(sig, tpe, TRUE);
+                               setPolymorphic(sig, tpe, TRUE);
                        }
                        if (a->vargs) {
-                               sig->varargs |= VARARGS;
-                               setPolymorphic(sig, TYPE_any, TRUE);
+                               sig->varargs |= VARARGS;
+                               setPolymorphic(sig, TYPE_any, TRUE);
                        }
                }
                assert(sig->retc > 0);
@@ -358,11 +358,11 @@ melFunction(bool command, char *mod, cha
                if (a.nr > 0) {
                        if (a.isbat)
                                tpe = newBatType(tpe);
-                               setPolymorphic(sig, tpe, TRUE);
+                       setPolymorphic(sig, tpe, TRUE);
                }
                if (a.vargs) {
-                       sig->varargs |= VARRETS;
-                               setPolymorphic(sig, TYPE_any, TRUE);
+                       sig->varargs |= VARRETS;
+                       setPolymorphic(sig, TYPE_any, TRUE);
                }
        }
        /* add the arguments */
@@ -376,11 +376,11 @@ melFunction(bool command, char *mod, cha
                if (a.nr > 0) {
                        if (a.isbat)
                                tpe = newBatType(tpe);
-                       setPolymorphic(sig, tpe, TRUE);
+                       setPolymorphic(sig, tpe, TRUE);
                }
                if (a.vargs) {
-                       sig->varargs |= VARARGS;
-                       setPolymorphic(sig, TYPE_any, TRUE);
+                       sig->varargs |= VARARGS;
+                       setPolymorphic(sig, TYPE_any, TRUE);
                }
        }
        assert(sig->retc > 0);
@@ -414,8 +414,8 @@ malPrelude(Client c, int listing, int em
                        msg = addFunctions(mel_module_funcs[i]);
                        if (!msg && mel_module_code[i]) /* some modules may 
also have some function definitions */
                                msg = malIncludeString(c, mel_module_name[i], 
(str)mel_module_code[i], listing, NULL);
-                               if (msg)
-                                       return msg;
+                       if (msg)
+                               return msg;
 
                        /* skip sql should be last to startup and mapi in the 
embedded version */
                        if (strcmp(mel_module_name[i], "sql") == 0 || (embedded 
&& strcmp(mel_module_name[i], "mapi") == 0))
diff --git a/monetdb5/mal/mel.h b/monetdb5/mal/mel.h
--- a/monetdb5/mal/mel.h
+++ b/monetdb5/mal/mel.h
@@ -19,7 +19,7 @@
 
 typedef void* (*fptr)(void*);
 
-typedef struct mel_atom {
+typedef struct __attribute__((__designated_init__)) mel_atom {
        char name[14];
        char basetype[14];
        int size;
@@ -59,22 +59,22 @@ typedef struct mel_atom {
 #define batargany(n,a)                 { /*.name=n,*/ .isbat=true, .nr=a, }
 #define batvarargany(n,a)      { /*.name=n,*/ .isbat=true, .vargs=true, .nr=a, 
}
 
-typedef struct mel_arg {
+typedef struct __attribute__((__designated_init__)) mel_arg {
        //char *name;
        char type[15];
-       bool isbat:1,
-               vargs:1;
-       uint8_t nr:4;
+       uint8_t isbat:1,
+               vargs:1,
+               nr:4;
 } mel_arg;
 
-typedef struct mel_func {
+typedef struct __attribute__((__designated_init__)) mel_func {
        char mod[14];
        char fcn[30];
        char *cname;
-       bool command:1,
-               unsafe:1;
-       uint16_t retc:6,
-            argc:6;
+       uint16_t command:1,
+               unsafe:1,
+               retc:6,
+               argc:6;
 //#ifdef NDEBUG
        //char *comment;
 //#endif
@@ -103,19 +103,19 @@ typedef struct mel_func {
 #define batargany(n,a)                 { /*.name=n,*/ .isbat=true, .nr=a, 
.type=TYPE_any }
 #define batvarargany(n,a)      { /*.name=n,*/ .isbat=true, .vargs=true, .nr=a, 
.type=TYPE_any }
 
-typedef struct mel_arg {
-       unsigned short type:8,
-               nr:4;
-       bool isbat:1,
+typedef struct __attribute__((__designated_init__)) mel_arg {
+       uint16_t type:8,
+               nr:4,
+               isbat:1,
                vargs:1;
 } mel_arg;
 
-typedef struct mel_func {
+typedef struct __attribute__((__designated_init__)) mel_func {
        char mod[14];
        char fcn[30];
-       bool command:1,
-               unsafe:1;
-       unsigned short retc:6,
+       uint16_t command:1,
+               unsafe:1,
+               retc:6,
                argc:6;
 //#ifdef NDEBUG
        //char *comment;
@@ -128,10 +128,10 @@ typedef struct mel_func {
 
 typedef str(*mel_init)(void);
 
-typedef struct mel_func_arg {
-       unsigned short type:8,
-               nr:4;
-       bool isbat:1,
+typedef struct __attribute__((__designated_init__)) mel_func_arg {
+       uint16_t type:8,
+               nr:4,
+               isbat:1,
                vargs:1;
 } mel_func_arg;
 
@@ -139,7 +139,7 @@ typedef struct mel_func_arg {
 int melFunction(bool command, char *mod, char *fcn, fptr imp, char *fname, 
bool unsafe, char *comment, int retc, int argc, ...);
 
 #ifdef SPECS
-typedef struct mal_spec{
+typedef struct __attribute__((__designated_init__)) mal_spec{
        fptr imp;
        char *mal;
 } mal_spec;
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
@@ -1389,8 +1389,11 @@ exp_needs_push_down(sql_exp *e)
        case e_convert:
                return exp_needs_push_down(e->l);
        case e_aggr:
-       case e_func:
+       case e_func: {
+               if (!e->l || exps_are_atoms(e->l))
+                       return 0;
                return 1;
+       } break;
        case e_column:
        case e_atom:
        default:
@@ -1458,6 +1461,8 @@ exp_push_single_func_down(visitor *v, sq
 
                if (exp_unsafe(e, 0))
                        return e;
+               if (!e->l || exps_are_atoms(e->l))
+                       return e;
                if ((is_joinop(rel->op) && ((can_push_func(e, l, &mustl) && 
mustl) || (can_push_func(e, r, &mustr) && mustr))) ||
                        (is_select(rel->op) && can_push_func(e, l, &must) && 
must)) {
                        exp_label(v->sql->sa, e, ++v->sql->label);
@@ -7637,7 +7642,7 @@ rel_simplify_predicates(visitor *v, sql_
                                }
                        } else if (is_atom(l->type) && is_atom(r->type) && 
!is_semantics(e)) {
                                if (exp_is_null(l) || exp_is_null(r)) {
-                                       e = exp_null(v->sql->sa, 
exp_subtype(l));
+                                       e = exp_null(v->sql->sa, 
sql_bind_localtype("bit"));
                                        v->changes++;
                                } else if (l->l && r->l) {
                                        int res = atom_cmp(l->l, r->l);
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
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to