Changeset: 117897e1dbca for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/117897e1dbca
Modified Files:
sql/server/rel_exp.c
sql/server/rel_optimizer.c
sql/server/rel_rel.c
sql/server/rel_rewriter.c
Branch: properties
Log Message:
Merged with default
diffs (truncated from 1464 to 300 lines):
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
@@ -318,7 +318,7 @@ makeFuncArgument(MalBlkPtr mb, mel_func_
}
int
-melFunction(bool command, const char *mod, const char *fcn, fptr imp, const
char *fname, bool unsafe, const char *comment, int retc, int argc, ... )
+melFunction(bool command, const char *mod, const char *fcn, MALfcn imp, const
char *fname, bool unsafe, const char *comment, int retc, int argc, ... )
{
int i, idx;
Module c;
diff --git a/monetdb5/mal/mel.h b/monetdb5/mal/mel.h
--- a/monetdb5/mal/mel.h
+++ b/monetdb5/mal/mel.h
@@ -17,8 +17,6 @@
#define MEL_OK 0
#define MEL_ERR 1
-typedef void* (*fptr)(void*);
-
typedef struct __attribute__((__designated_init__)) mel_atom {
char name[14];
char basetype[14];
@@ -43,8 +41,8 @@ typedef struct __attribute__((__designat
/*strings */
#ifdef MEL_STR
-#define command(MOD,FCN,IMP,UNSAFE,COMMENT,ARGS) { .command=true, .mod=MOD,
.fcn=FCN, .imp=(fptr)&IMP, .cname=#IMP, .unsafe=UNSAFE, .args=ARGS,
.comment=COMMENT }
-#define pattern(MOD,FCN,IMP,UNSAFE,COMMENT,ARGS) { .command=false, .mod=MOD,
.fcn=FCN, .imp=(fptr)&IMP, .cname=#IMP, .unsafe=UNSAFE, .args=ARGS,
.comment=COMMENT }
+#define command(MOD,FCN,IMP,UNSAFE,COMMENT,ARGS) { .command=true, .mod=MOD,
.fcn=FCN, .imp=(MALfcn)IMP, .cname=#IMP, .unsafe=UNSAFE, .args=ARGS,
.comment=COMMENT }
+#define pattern(MOD,FCN,IMP,UNSAFE,COMMENT,ARGS) { .command=false, .mod=MOD,
.fcn=FCN, .pimp=IMP, .cname=#IMP, .unsafe=UNSAFE, .args=ARGS, .comment=COMMENT }
/* ARGC = arg-count + ret-count */
//#define args(RETC,ARGC,...) (mel_arg[ARGC?ARGC:1]){__VA_ARGS__}, .retc=RETC,
.argc=ARGC
@@ -68,6 +66,7 @@ typedef struct __attribute__((__designat
nr:4;
} mel_arg;
+#include "mal_client.h"
typedef struct __attribute__((__designated_init__)) mel_func {
char mod[16];
char fcn[30];
@@ -78,18 +77,21 @@ typedef struct __attribute__((__designat
argc:6;
// comment on MAL instructions should also be available when TRACEing the
queries
char *comment;
- fptr imp;
+ union {
+ MALfcn imp;
+ char *(*pimp)(Client, MalBlkPtr, MalStkPtr, InstrPtr);
+ };
const mel_arg *args;
} mel_func;
#else
//#ifdef NDEBUG
-#define command(MOD,FCN,IMP,UNSAFE,COMMENT,ARGS) { .command=true, .mod=MOD,
.fcn=FCN, .imp=(fptr)&IMP, .unsafe=UNSAFE, .args=ARGS, .comment=COMMENT }
-#define pattern(MOD,FCN,IMP,UNSAFE,COMMENT,ARGS) { .command=false, .mod=MOD,
.fcn=FCN, .imp=(fptr)&IMP, .unsafe=UNSAFE, .args=ARGS, .comment=COMMENT }
+#define command(MOD,FCN,IMP,UNSAFE,COMMENT,ARGS) { .command=true, .mod=MOD,
.fcn=FCN, .imp=(MALfcn)IMP, .unsafe=UNSAFE, .args=ARGS, .comment=COMMENT }
+#define pattern(MOD,FCN,IMP,UNSAFE,COMMENT,ARGS) { .command=false, .mod=MOD,
.fcn=FCN, .pimp=IMP, .unsafe=UNSAFE, .args=ARGS, .comment=COMMENT }
//#else
-//#define command(MOD,FCN,IMP,UNSAFE,COMMENT,ARGS) { .command=true, .mod=MOD,
.fcn=FCN, .imp=(fptr)&IMP, .unsafe=UNSAFE, .comment=COMMENT, .args=ARGS,
.comment=COMMENT }
-//#define pattern(MOD,FCN,IMP,UNSAFE,COMMENT,ARGS) { .command=false, .mod=MOD,
.fcn=FCN, .imp=(fptr)&IMP, .unsafe=UNSAFE, .comment=COMMENT, .args=ARGS,
.comment=COMMENT }
+//#define command(MOD,FCN,IMP,UNSAFE,COMMENT,ARGS) { .command=true, .mod=MOD,
.fcn=FCN, .imp=(MALfcn)IMP, .unsafe=UNSAFE, .comment=COMMENT, .args=ARGS,
.comment=COMMENT }
+//#define pattern(MOD,FCN,IMP,UNSAFE,COMMENT,ARGS) { .command=false, .mod=MOD,
.fcn=FCN, .pimp=IMP, .unsafe=UNSAFE, .comment=COMMENT, .args=ARGS,
.comment=COMMENT }
//#endif
#define args(RETC,ARGC,...) {__VA_ARGS__}, .retc=RETC, .argc=ARGC
@@ -119,7 +121,10 @@ typedef struct __attribute__((__designat
argc:6;
// comment on MAL instructions should also be available when TRACEing the
queries
char *comment;
- fptr imp;
+ union {
+ MALfcn imp;
+ char *(*pimp)(Client, MalBlkPtr, MalStkPtr, InstrPtr);
+ };
mel_arg args[20];
} mel_func;
@@ -135,11 +140,14 @@ typedef struct __attribute__((__designat
} mel_func_arg;
/* var arg of arguments of type mel_func_arg */
-int melFunction(bool command, const char *mod, const char *fcn, fptr imp,
const char *fname, bool unsafe, const char *comment, int retc, int argc, ...);
+int melFunction(bool command, const char *mod, const char *fcn, MALfcn imp,
const char *fname, bool unsafe, const char *comment, int retc, int argc, ...);
#ifdef SPECS
typedef struct __attribute__((__designated_init__)) mal_spec{
- fptr imp;
+ union {
+ MALfcn imp;
+ char *(*pimp)(Client, MalBlkPtr, MalStkPtr, InstrPtr);
+ };
char *mal;
} mal_spec;
#endif
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
@@ -1411,144 +1411,144 @@ batcalc_init(void)
mel_func_arg ret = { .type = TYPE_bit, .isbat=1 };
mel_func_arg arg = { .type = *tp, .isbat=1 };
- err += melFunction(false, "batcalc", "iszero",
(fptr)&CMDbatISZERO, "CMDbatISZERO", false, "Unary check for zero over the tail
of the bat", 1, 2, ret, arg);
- err += melFunction(false, "batcalc", "iszero",
(fptr)&CMDbatISZERO, "CMDbatISZERO", false, "Unary check for zero over the tail
of the bat with candidates list", 1, 3, ret, arg, cand);
+ err += melFunction(false, "batcalc", "iszero",
(MALfcn)&CMDbatISZERO, "CMDbatISZERO", false, "Unary check for zero over the
tail of the bat", 1, 2, ret, arg);
+ err += melFunction(false, "batcalc", "iszero",
(MALfcn)&CMDbatISZERO, "CMDbatISZERO", false, "Unary check for zero over the
tail of the bat with candidates list", 1, 3, ret, arg, cand);
}
for(tp = types; tp < extra && !err; tp++) { /* bit + numeric */
mel_func_arg ret = { .type = *tp, .isbat =1 };
mel_func_arg arg = { .type = *tp, .isbat =1 };
- err += melFunction(false, "batcalc", "not", (fptr)&CMDbatNOT,
"CMDbatNOT", false, "Unary bitwise not over the tail of the bat", 1, 2, ret,
arg);
- err += melFunction(false, "batcalc", "not", (fptr)&CMDbatNOT,
"CMDbatNOT", false, "Unary bitwise not over the tail of the bat with candidates
list", 1, 3, ret, arg, cand);
+ err += melFunction(false, "batcalc", "not", (MALfcn)&CMDbatNOT,
"CMDbatNOT", false, "Unary bitwise not over the tail of the bat", 1, 2, ret,
arg);
+ err += melFunction(false, "batcalc", "not", (MALfcn)&CMDbatNOT,
"CMDbatNOT", false, "Unary bitwise not over the tail of the bat with candidates
list", 1, 3, ret, arg, cand);
}
for(tp = integer; tp < extra && !err; tp++) {
mel_func_arg ret = { .type = TYPE_bte, .isbat =1 };
mel_func_arg arg = { .type = *tp, .isbat =1 };
- err += melFunction(false, "batcalc", "sign", (fptr)&CMDbatSIGN,
"CMDbatSIGN", false, "Unary sign (-1,0,1) over the tail of the bat", 1, 2, ret,
arg);
- err += melFunction(false, "batcalc", "sign", (fptr)&CMDbatSIGN,
"CMDbatSIGN", false, "Unary sign (-1,0,1) over the tail of the bat with
candidates list", 1, 3, ret, arg, cand);
+ err += melFunction(false, "batcalc", "sign",
(MALfcn)&CMDbatSIGN, "CMDbatSIGN", false, "Unary sign (-1,0,1) over the tail of
the bat", 1, 2, ret, arg);
+ err += melFunction(false, "batcalc", "sign",
(MALfcn)&CMDbatSIGN, "CMDbatSIGN", false, "Unary sign (-1,0,1) over the tail of
the bat with candidates list", 1, 3, ret, arg, cand);
}
for(tp = integer; tp < extra && !err; tp++) {
mel_func_arg ret = { .type = *tp, .isbat =1 };
mel_func_arg arg = { .type = *tp, .isbat =1 };
- err += melFunction(false, "batcalc", "abs", (fptr)&CMDbatABS,
"CMDbatABS", false, "Unary abs over the tail of the bat", 1, 2, ret, arg);
- err += melFunction(false, "batcalc", "abs", (fptr)&CMDbatABS,
"CMDbatABS", false, "Unary abs over the tail of the bat with candidates list",
1, 3, ret, arg, cand);
+ err += melFunction(false, "batcalc", "abs", (MALfcn)&CMDbatABS,
"CMDbatABS", false, "Unary abs over the tail of the bat", 1, 2, ret, arg);
+ err += melFunction(false, "batcalc", "abs", (MALfcn)&CMDbatABS,
"CMDbatABS", false, "Unary abs over the tail of the bat with candidates list",
1, 3, ret, arg, cand);
- err += melFunction(false, "batcalc", "-", (fptr)&CMDbatNEG,
"CMDbatNEG", false, "Unary neg over the tail of the bat", 1, 2, ret, arg);
- err += melFunction(false, "batcalc", "-", (fptr)&CMDbatNEG,
"CMDbatNEG", false, "Unary neg over the tail of the bat with candidates list",
1, 3, ret, arg, cand);
+ err += melFunction(false, "batcalc", "-", (MALfcn)&CMDbatNEG,
"CMDbatNEG", false, "Unary neg over the tail of the bat", 1, 2, ret, arg);
+ err += melFunction(false, "batcalc", "-", (MALfcn)&CMDbatNEG,
"CMDbatNEG", false, "Unary neg over the tail of the bat with candidates list",
1, 3, ret, arg, cand);
- err += melFunction(false, "batcalc", "++", (fptr)&CMDbatINCR,
"CMDbatINCR", false, "Unary increment over the tail of the bat", 1, 2, ret,
arg);
- err += melFunction(false, "batcalc", "++", (fptr)&CMDbatINCR,
"CMDbatINCR", false, "Unary increment over the tail of the bat with candidates
list", 1, 3, ret, arg, cand);
+ err += melFunction(false, "batcalc", "++", (MALfcn)&CMDbatINCR,
"CMDbatINCR", false, "Unary increment over the tail of the bat", 1, 2, ret,
arg);
+ err += melFunction(false, "batcalc", "++", (MALfcn)&CMDbatINCR,
"CMDbatINCR", false, "Unary increment over the tail of the bat with candidates
list", 1, 3, ret, arg, cand);
- err += melFunction(false, "batcalc", "--", (fptr)&CMDbatDECR,
"CMDbatDECR", false, "Unary decrement over the tail of the bat", 1, 2, ret,
arg);
- err += melFunction(false, "batcalc", "--", (fptr)&CMDbatDECR,
"CMDbatDECR", false, "Unary decrement over the tail of the bat with candidates
list", 1, 3, ret, arg, cand);
+ err += melFunction(false, "batcalc", "--", (MALfcn)&CMDbatDECR,
"CMDbatDECR", false, "Unary decrement over the tail of the bat", 1, 2, ret,
arg);
+ err += melFunction(false, "batcalc", "--", (MALfcn)&CMDbatDECR,
"CMDbatDECR", false, "Unary decrement over the tail of the bat with candidates
list", 1, 3, ret, arg, cand);
}
/* possibly add the min/max + _no_nil */
/* binops on numeric types */
struct {
- char *op;
- char *op_ne;
- char *fname;
- char *fname_ne;
- char *fname_el;
- fptr fcn;
- fptr fcn_ne;
- fptr fcn_el;
- char *comment;
- char *comment_ne;
- char *comment_v;
- char *comment_v_ne;
- char *comment_v_;
- char *comment_v__ne;
- char *comment_el;
- char *comment_el_v;
- char *comment_el_v_;
+ char *op;
+ char *op_ne;
+ char *fname;
+ char *fname_ne;
+ char *fname_el;
+ MALfcn fcn;
+ MALfcn fcn_ne;
+ MALfcn fcn_el;
+ char *comment;
+ char *comment_ne;
+ char *comment_v;
+ char *comment_v_ne;
+ char *comment_v_;
+ char *comment_v__ne;
+ char *comment_el;
+ char *comment_el_v;
+ char *comment_el_v_;
} funcs[3] = {
- {
- .op = "+",
- .fcn = (fptr)CMDbatADDsignal,
- .fname = "CMDbatADDsignal",
- .op_ne = "add_noerror",
- .fcn_ne = (fptr)&CMDbatADD,
- .fname_ne = "CMDbatADD",
- .fcn_el = (fptr)&CMDbatADDenlarge,
- .fname_el = "CMDbatADDenlarge",
- .comment = "Return B1 + B2 with candidates list, signal error
on overflow",
- .comment_ne = "Return B1 + B2 with candidates list, overflow
causes NIL value",
- .comment_v = "Return B + V with candidates list, signal error
on overflow",
- .comment_v_ne = "Return B + V with candidates list, overflow
causes NIL value",
- .comment_v_ = "Return V + B with candidates list, signal error
on overflow",
- .comment_v__ne = "Return V + B with candidates list, overflow
causes NIL value",
- .comment_el = "Return B1 + B2 with candidates list, guarantee
no overflow by returning larger type",
- .comment_el_v = "Return B + V with candidates list, guarantee
no overflow by returning larger type",
- .comment_el_v_ = "Return V + B with candidates list, guarantee
no overflow by returning larger type",
- }, {
- .op = "-",
- .fcn = (fptr)CMDbatSUBsignal,
- .fname = "CMDbatSUBsignal",
- .op_ne = "sub_noerror",
- .fcn_ne = (fptr)&CMDbatSUB,
- .fname_ne = "CMDbatSUB",
- .fcn_el = (fptr)&CMDbatSUBenlarge,
- .fname_el = "CMDbatSUBenlarge",
- .comment = "Return B1 - B2 with candidates list, signal error
on overflow",
- .comment_ne = "Return B1 - B2 with candidates list, overflow
causes NIL value",
- .comment_v = "Return B - V with candidates list, signal error
on overflow",
- .comment_v_ne = "Return B - V with candidates list, overflow
causes NIL value",
- .comment_v_ = "Return V - B with candidates list, signal error
on overflow",
- .comment_v__ne = "Return V - B with candidates list, overflow
causes NIL value",
- .comment_el = "Return B1 - B2 with candidates list, guarantee
no overflow by returning larger type",
- .comment_el_v = "Return B - V with candidates list, guarantee
no overflow by returning larger type",
- .comment_el_v_ = "Return V - B with candidates list, guarantee
no overflow by returning larger type",
- }, {
- .op = "*",
- .fcn = (fptr)CMDbatMULsignal,
- .fname = "CMDbatMULsignal",
- .op_ne = "mul_noerror",
- .fcn_ne = (fptr)&CMDbatMUL,
- .fname_ne = "CMDbatMUL",
- .fcn_el = (fptr)&CMDbatMULenlarge,
- .fname_el = "CMDbatMULenlarge",
- .comment = "Return B1 * B2 with candidates list, signal error
on overflow",
- .comment_ne = "Return B1 * B2 with candidates list, overflow
causes NIL value",
- .comment_v = "Return B * V with candidates list, signal error
on overflow",
- .comment_v_ne = "Return B * V with candidates list, overflow
causes NIL value",
- .comment_v_ = "Return V * B with candidates list, signal error
on overflow",
- .comment_v__ne = "Return V * B with candidates list, overflow
causes NIL value",
- .comment_el = "Return B1 * B2 with candidates list, guarantee
no overflow by returning larger type",
- .comment_el_v = "Return B * V with candidates list, guarantee
no overflow by returning larger type",
- .comment_el_v_ = "Return V * B with candidates list, guarantee
no overflow by returning larger type",
- }
+ {
+ .op = "+",
+ .fcn = (MALfcn)CMDbatADDsignal,
+ .fname = "CMDbatADDsignal",
+ .op_ne = "add_noerror",
+ .fcn_ne = (MALfcn)&CMDbatADD,
+ .fname_ne = "CMDbatADD",
+ .fcn_el = (MALfcn)&CMDbatADDenlarge,
+ .fname_el = "CMDbatADDenlarge",
+ .comment = "Return B1 + B2 with candidates list, signal
error on overflow",
+ .comment_ne = "Return B1 + B2 with candidates list,
overflow causes NIL value",
+ .comment_v = "Return B + V with candidates list, signal
error on overflow",
+ .comment_v_ne = "Return B + V with candidates list,
overflow causes NIL value",
+ .comment_v_ = "Return V + B with candidates list,
signal error on overflow",
+ .comment_v__ne = "Return V + B with candidates list,
overflow causes NIL value",
+ .comment_el = "Return B1 + B2 with candidates list,
guarantee no overflow by returning larger type",
+ .comment_el_v = "Return B + V with candidates list,
guarantee no overflow by returning larger type",
+ .comment_el_v_ = "Return V + B with candidates list,
guarantee no overflow by returning larger type",
+ }, {
+ .op = "-",
+ .fcn = (MALfcn)CMDbatSUBsignal,
+ .fname = "CMDbatSUBsignal",
+ .op_ne = "sub_noerror",
+ .fcn_ne = (MALfcn)&CMDbatSUB,
+ .fname_ne = "CMDbatSUB",
+ .fcn_el = (MALfcn)&CMDbatSUBenlarge,
+ .fname_el = "CMDbatSUBenlarge",
+ .comment = "Return B1 - B2 with candidates list, signal
error on overflow",
+ .comment_ne = "Return B1 - B2 with candidates list,
overflow causes NIL value",
+ .comment_v = "Return B - V with candidates list, signal
error on overflow",
+ .comment_v_ne = "Return B - V with candidates list,
overflow causes NIL value",
+ .comment_v_ = "Return V - B with candidates list,
signal error on overflow",
+ .comment_v__ne = "Return V - B with candidates list,
overflow causes NIL value",
+ .comment_el = "Return B1 - B2 with candidates list,
guarantee no overflow by returning larger type",
+ .comment_el_v = "Return B - V with candidates list,
guarantee no overflow by returning larger type",
+ .comment_el_v_ = "Return V - B with candidates list,
guarantee no overflow by returning larger type",
+ }, {
+ .op = "*",
+ .fcn = (MALfcn)CMDbatMULsignal,
+ .fname = "CMDbatMULsignal",
+ .op_ne = "mul_noerror",
+ .fcn_ne = (MALfcn)&CMDbatMUL,
+ .fname_ne = "CMDbatMUL",
+ .fcn_el = (MALfcn)&CMDbatMULenlarge,
+ .fname_el = "CMDbatMULenlarge",
+ .comment = "Return B1 * B2 with candidates list, signal
error on overflow",
+ .comment_ne = "Return B1 * B2 with candidates list,
overflow causes NIL value",
+ .comment_v = "Return B * V with candidates list, signal
error on overflow",
+ .comment_v_ne = "Return B * V with candidates list,
overflow causes NIL value",
+ .comment_v_ = "Return V * B with candidates list,
signal error on overflow",
+ .comment_v__ne = "Return V * B with candidates list,
overflow causes NIL value",
+ .comment_el = "Return B1 * B2 with candidates list,
guarantee no overflow by returning larger type",
+ .comment_el_v = "Return B * V with candidates list,
guarantee no overflow by returning larger type",
+ .comment_el_v_ = "Return V * B with candidates list,
guarantee no overflow by returning larger type",
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list