Changeset: 2b20a4e6746a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2b20a4e6746a
Modified Files:
clients/mapiclient/dump.c
gdk/gdk_analytic_bounds.c
gdk/gdk_calc.c
gdk/gdk_value.c
monetdb5/modules/atoms/mtime_analytic.c
sql/ChangeLog.Apr2019
sql/backends/monet5/sql_cat.c
sql/backends/monet5/sql_rank.c
sql/server/rel_exp.c
sql/server/rel_propagate.c
sql/server/rel_select.c
sql/server/sql_atom.c
sql/server/sql_atom.h
sql/server/sql_partition.c
sql/storage/store.c
sql/test/analytics/Tests/analytics03.stable.err
sql/test/analytics/Tests/analytics03.stable.out
sql/test/merge-partitions/Tests/mergepart05.sql
sql/test/merge-partitions/Tests/mergepart05.stable.err
sql/test/merge-partitions/Tests/mergepart05.stable.out
sql/test/merge-partitions/Tests/mergepart07.stable.err
sql/test/testdb-reload/Tests/reload.stable.out
sql/test/testdb/Tests/dump.stable.out
sql/test/testdb/Tests/load.sql
Branch: Apr2019
Log Message:
Changed the internal representation of RANGE MINVALUE and RANGE MAXVALUE.
See the ChangeLog message.
Using NULL (nil) as infinity was of course already done in BATselect.
Also added RANGE MINVALUE/MAXVALUE to the dump (and hence upgrade) test.
diffs (truncated from 1490 to 300 lines):
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -2703,14 +2703,20 @@ dump_database(Mapi mid, stream *toConsol
maxv = mapi_fetch_field(shdl, 1);
wnulls = mapi_fetch_field(shdl, 2);
}
- if (minv && maxv) {
+ if (minv || maxv) {
mnstr_printf(toConsole, " FROM ");
- squoted_print(toConsole, minv, '\'');
+ if (minv)
+ squoted_print(toConsole, minv,
'\'');
+ else
+ mnstr_printf(toConsole, "RANGE
MINVALUE");
mnstr_printf(toConsole, " TO ");
- squoted_print(toConsole, maxv, '\'');
+ if (maxv)
+ squoted_print(toConsole, maxv,
'\'');
+ else
+ mnstr_printf(toConsole, "RANGE
MAXVALUE");
}
if (strcmp(wnulls, "true") == 0) {
- mnstr_printf(toConsole, " %s NULL
VALUES", (minv && maxv) ? "WITH" : "FOR");
+ mnstr_printf(toConsole, " %s NULL
VALUES", (minv || maxv) ? "WITH" : "FOR");
}
mapi_close_handle(shdl);
}
diff --git a/gdk/gdk_analytic_bounds.c b/gdk/gdk_analytic_bounds.c
--- a/gdk/gdk_analytic_bounds.c
+++ b/gdk/gdk_analytic_bounds.c
@@ -529,13 +529,13 @@ GDKanalyticalrowbounds(BAT *r, BAT *b, B
lng limit;
switch (tp2) {
case TYPE_bte:
- limit = (lng) (*(bte *) bound);
+ limit = is_bte_nil(*(bte *) bound) ? lng_nil : (lng)
*(bte *) bound;
break;
case TYPE_sht:
- limit = (lng) (*(sht *) bound);
+ limit = is_sht_nil(*(sht *) bound) ? lng_nil : (lng)
*(sht *) bound;
break;
case TYPE_int:
- limit = (lng) (*(int *) bound);
+ limit = is_int_nil(*(int *) bound) ? lng_nil : (lng)
*(int *) bound;
break;
case TYPE_lng:
limit = (lng) (*(lng *) bound);
@@ -543,7 +543,7 @@ GDKanalyticalrowbounds(BAT *r, BAT *b, B
default:
goto bound_not_supported;
}
- if (limit == GDK_lng_max) {
+ if (is_lng_nil(limit)) {
return GDKanalyticalallbounds(r, b, p, preceding);
} else if (preceding) {
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_ROWS(_PRECEDING,
limit);
@@ -655,7 +655,7 @@ GDKanalyticalrangebounds(BAT *r, BAT *b,
switch (tp2) {
case TYPE_bte:{
bte ll = (*(bte *) bound);
- if (ll == GDK_bte_max) /* UNBOUNDED PRECEDING
and UNBOUNDED FOLLOWING cases, avoid overflow */
+ if (is_bte_nil(ll)) /* UNBOUNDED PRECEDING
and UNBOUNDED FOLLOWING cases, avoid overflow */
return GDKanalyticalallbounds(r, b, p,
preceding);
else
limit = (lng) ll;
@@ -663,7 +663,7 @@ GDKanalyticalrangebounds(BAT *r, BAT *b,
}
case TYPE_sht:{
sht ll = (*(sht *) bound);
- if (ll == GDK_sht_max)
+ if (is_sht_nil(ll))
return GDKanalyticalallbounds(r, b, p,
preceding);
else
limit = (lng) ll;
@@ -671,7 +671,7 @@ GDKanalyticalrangebounds(BAT *r, BAT *b,
}
case TYPE_int:{
int ll = (*(int *) bound);
- if (ll == GDK_int_max)
+ if (is_int_nil(ll))
return GDKanalyticalallbounds(r, b, p,
preceding);
else
limit = (lng) ll;
@@ -679,7 +679,7 @@ GDKanalyticalrangebounds(BAT *r, BAT *b,
}
case TYPE_lng:{
lng ll = (*(lng *) bound);
- if (ll == GDK_lng_max)
+ if (is_lng_nil(ll))
return GDKanalyticalallbounds(r, b, p,
preceding);
else
limit = (lng) ll;
@@ -697,7 +697,7 @@ GDKanalyticalrangebounds(BAT *r, BAT *b,
}
case TYPE_flt:{
flt limit = (*(flt *) bound);
- if (limit == GDK_flt_max) {
+ if (is_flt_nil(limit)) {
return GDKanalyticalallbounds(r, b, p,
preceding);
} else if (preceding) {
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_RANGE_FLT(_PRECEDING, limit);
@@ -708,7 +708,7 @@ GDKanalyticalrangebounds(BAT *r, BAT *b,
}
case TYPE_dbl:{
dbl limit = (*(dbl *) bound);
- if (limit == GDK_dbl_max) {
+ if (is_dbl_nil(limit)) {
return GDKanalyticalallbounds(r, b, p,
preceding);
} else if (preceding) {
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_RANGE_DBL(_PRECEDING, limit);
@@ -720,7 +720,7 @@ GDKanalyticalrangebounds(BAT *r, BAT *b,
#ifdef HAVE_HGE
case TYPE_hge:{
hge limit = (*(hge *) bound);
- if (limit == GDK_hge_max) {
+ if (is_hge_nil(limit)) {
return GDKanalyticalallbounds(r, b, p,
preceding);
} else if (preceding) {
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_RANGE_HGE(_PRECEDING, limit);
@@ -804,13 +804,13 @@ GDKanalyticalgroupsbounds(BAT *r, BAT *b
lng limit;
switch (tp2) {
case TYPE_bte:
- limit = (lng) (*(bte *) bound);
+ limit = is_bte_nil(*(bte *) bound) ? lng_nil : (lng)
*(bte *) bound;
break;
case TYPE_sht:
- limit = (lng) (*(sht *) bound);
+ limit = is_sht_nil(*(sht *) bound) ? lng_nil : (lng)
*(sht *) bound;
break;
case TYPE_int:
- limit = (lng) (*(int *) bound);
+ limit = is_int_nil(*(int *) bound) ? lng_nil : (lng)
*(int *) bound;
break;
case TYPE_lng:
limit = (lng) (*(lng *) bound);
@@ -818,7 +818,7 @@ GDKanalyticalgroupsbounds(BAT *r, BAT *b
default:
goto bound_not_supported;
}
- if (limit == GDK_lng_max) {
+ if (is_lng_nil(limit)) {
return GDKanalyticalallbounds(r, b, p, preceding);
} else if (preceding) {
ANALYTICAL_WINDOW_BOUNDS_BRANCHES_GROUPS(_PRECEDING,
limit);
diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -14566,5 +14566,6 @@ VARconvert(ValPtr ret, const ValRecord *
ATOMname(v->vtype), ATOMname(ret->vtype));
return GDK_FAIL;
}
+ ret->len = ATOMlen(ret->vtype, VALptr(ret));
return nils == BUN_NONE ? GDK_FAIL : GDK_SUCCEED;
}
diff --git a/gdk/gdk_value.c b/gdk/gdk_value.c
--- a/gdk/gdk_value.c
+++ b/gdk/gdk_value.c
@@ -74,17 +74,15 @@ VALset(ValPtr v, int t, ptr p)
#endif
case TYPE_str:
v->val.sval = (str) p;
- v->len = strLen((str) p);
break;
case TYPE_ptr:
v->val.pval = *(ptr *) p;
- v->len = ATOMlen(t, *(ptr *) p);
break;
default:
v->val.pval = p;
- v->len = ATOMlen(t, p);
break;
}
+ v->len = ATOMlen(v->vtype, VALptr(v));
return v;
}
@@ -163,6 +161,7 @@ VALcopy(ValPtr d, const ValRecord *s)
return NULL;
memcpy(d->val.pval, p, d->len);
}
+ d->len = ATOMlen(d->vtype, VALptr(d));
return d;
}
@@ -219,8 +218,9 @@ VALinit(ValPtr d, int tpe, const void *s
if (d->val.pval == NULL)
return NULL;
memcpy(d->val.pval, s, d->len);
- break;
+ return d;
}
+ d->len = ATOMlen(d->vtype, VALptr(d));
return d;
}
diff --git a/monetdb5/modules/atoms/mtime_analytic.c
b/monetdb5/modules/atoms/mtime_analytic.c
--- a/monetdb5/modules/atoms/mtime_analytic.c
+++ b/monetdb5/modules/atoms/mtime_analytic.c
@@ -15,66 +15,59 @@
*/
#include "monetdb_config.h"
+#include "mal_exception.h"
#include "mtime.h"
-#define MTIME_SUB_WITH_CHECK(lft, rgt, TYPE, dst, max, on_overflow) \
- do { \
- if ((rgt) < 1) { \
- if ((max) + (rgt) < (lft)) \
- on_overflow; \
- else \
- (dst) = (TYPE) (lft) - (rgt); \
- } else { \
- if (-(max) + (rgt) > (lft)) \
- on_overflow; \
- else \
- (dst) = (TYPE) (lft) - (rgt); \
- } \
- } while (0)
-
-#define MABSOLUTE(X) ((X) < 0 ? -(X) : (X))
-
-#define DATE_RANGE_MONTH_DIFF(X,Y,R) \
- do { \
- MTIME_SUB_WITH_CHECK(X, Y, date, R, date_max, goto
calc_overflow); \
- R = MABSOLUTE(R); \
- R /= 30; /* days in a month */ \
- R += (X != Y); /* in a '0' month interval, the rows don't
belong to the same frame if the difference is less than one month */ \
- } while (0)
+static inline date
+date_add_month(date D, int M)
+{
+ date ret;
+ MTIMEdate_addmonths(&ret, &D, &M);
+ return ret;
+}
+static inline date
+date_add_day(date D, int M)
+{
+ date ret;
+ MTIMEdate_adddays(&ret, &D, &M);
+ return ret;
+}
+static inline lng
+timestamp_add_month(lng T, int M)
+{
+ timestamp ret, v;
+ v.alignment = T;
+ MTIMEtimestamp_add_month_interval_wrap(&ret, &v, &M);
+ return ret.alignment;
+}
+static inline lng
+timestamp_add_msec(lng T, lng M)
+{
+ timestamp ret, v;
+ v.alignment = T;
+ MTIMEtimestamp_add(&ret, &v, &M);
+ return ret.alignment;
+}
+static inline daytime
+daytime_add_msec(daytime D, lng M)
+{
+ daytime ret;
+ MTIMEtime_add_msec_interval_wrap(&ret, &D, &M);
+ return ret;
+}
-#define TIMESTAMP_RANGE_MONTH_DIFF(X,Y,R) \
- do { \
- MTIME_SUB_WITH_CHECK(X.days, Y.days, date, R, date_max, goto
calc_overflow); \
- R = MABSOLUTE(R); \
- R /= 30; /* days in a month */ \
- R += (X.days != Y.days); /* same reason as above */ \
- } while (0)
-
-#define DAYTIME_RANGE_SEC_DIFF(X,Y,R) \
- do { \
- R = MABSOLUTE(X - Y); /* never overflows */ \
- } while (0)
+#define date_sub_month(D,M) date_add_month(D,-(M))
+#define timestamp_sub_month(T,M) timestamp_add_month(T,-(M))
+#define daytime_sub_msec(D,M) daytime_add_msec(D, -(M))
+#define date_add_msec(D,M) date_add_day(D,(int)
((M)/(24*60*60*1000)))
+#define date_sub_msec(D,M) date_add_day(D,(int)
(-(M)/(24*60*60*1000)))
+#define timestamp_sub_msec(T,M) timestamp_add_msec(T, -(M))
-#define DATE_RANGE_SEC_DIFF(X,Y,R) \
- do { \
- MTIME_SUB_WITH_CHECK(X, Y, date, R, date_max, goto
calc_overflow); \
- R = MABSOLUTE(R); \
- R *= 86400000; /* days in milliseconds */ \
- } while (0)
-
-#define TIMESTAMP_RANGE_SEC_DIFF(X,Y,R) \
- do { \
- MTIME_SUB_WITH_CHECK(X.days, Y.days, date, R, date_max, goto
calc_overflow); \
- R = MABSOLUTE(R); \
- R *= 86400000; /* days in milliseconds */ \
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list