Changeset: 461ae8abc2ac for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=461ae8abc2ac
Modified Files:
clients/Tests/exports.stable.out
monetdb5/modules/atoms/mtime.c
monetdb5/modules/atoms/mtime.mal
monetdb5/modules/mal/batmtime.mal.sh
sql/test/BugTracker-2019/Tests/duplicates-not-eliminated-long-CASE-stmt.Bug-6697.stable.out
sql/test/BugTracker-2019/Tests/duplicates-not-eliminated-long-CASE-stmt.Bug-6697.stable.out.single
Branch: unlock
Log Message:
merged...
diffs (truncated from 673 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
@@ -1511,12 +1511,18 @@ str MTIMEcurrent_time(daytime *ret);
str MTIMEcurrent_timestamp(timestamp *ret);
str MTIMEdate_add_msec_interval(date *ret, const date *v1, const lng *v2);
str MTIMEdate_add_msec_interval_bulk(bat *ret, const bat *bid1, const bat
*bid2);
+str MTIMEdate_add_msec_interval_bulk_p1(bat *ret, const date *v1, const bat
*bid2);
+str MTIMEdate_add_msec_interval_bulk_p2(bat *ret, const bat *bid1, const lng
*v2);
str MTIMEdate_addmonths(date *ret, const date *v1, const int *v2);
str MTIMEdate_addmonths_bulk(bat *ret, const bat *bid1, const bat *bid2);
+str MTIMEdate_addmonths_bulk_p1(bat *ret, const date *v1, const bat *bid2);
+str MTIMEdate_addmonths_bulk_p2(bat *ret, const bat *bid1, const int *v2);
str MTIMEdate_date(date *ret, const date *src);
str MTIMEdate_date_bulk(bat *ret, const bat *bid);
str MTIMEdate_diff(int *ret, const date *v1, const date *v2);
str MTIMEdate_diff_bulk(bat *ret, const bat *bid1, const bat *bid2);
+str MTIMEdate_diff_bulk_p1(bat *ret, const date *src1, const bat *bid2);
+str MTIMEdate_diff_bulk_p2(bat *ret, const bat *bid1, const date *src2);
str MTIMEdate_extract_century(int *ret, const date *src);
str MTIMEdate_extract_century_bulk(bat *ret, const bat *bid);
str MTIMEdate_extract_day(int *ret, const date *src);
@@ -1535,18 +1541,26 @@ str MTIMEdate_extract_weekofyear(int *re
str MTIMEdate_extract_weekofyear_bulk(bat *ret, const bat *bid);
str MTIMEdate_extract_year(int *ret, const date *src);
str MTIMEdate_extract_year_bulk(bat *ret, const bat *bid);
-str MTIMEdate_fromstr(date *ret, const const char *const *src);
+str MTIMEdate_fromstr(date *ret, const str *src);
str MTIMEdate_fromstr_bulk(bat *ret, const bat *bid);
str MTIMEdate_sub_msec_interval(date *ret, const date *v1, const lng *v2);
str MTIMEdate_sub_msec_interval_bulk(bat *ret, const bat *bid1, const bat
*bid2);
+str MTIMEdate_sub_msec_interval_bulk_p1(bat *ret, const date *v1, const bat
*bid2);
+str MTIMEdate_sub_msec_interval_bulk_p2(bat *ret, const bat *bid1, const lng
*v2);
str MTIMEdate_submonths(date *ret, const date *v1, const int *v2);
str MTIMEdate_submonths_bulk(bat *ret, const bat *bid1, const bat *bid2);
-str MTIMEdate_to_str(str *ret, const const date *v1, const const char *const
*v2);
+str MTIMEdate_submonths_bulk_p1(bat *ret, const date *v1, const bat *bid2);
+str MTIMEdate_submonths_bulk_p2(bat *ret, const bat *bid1, const int *v2);
+str MTIMEdate_to_str(str *ret, const date *v1, const str *v2);
str MTIMEdate_to_str_bulk(bat *ret, const bat *bid1, const bat *bid2);
+str MTIMEdate_to_str_bulk_p1(bat *ret, const date *src1, const bat *bid2);
+str MTIMEdate_to_str_bulk_p2(bat *ret, const bat *bid1, const str *src2);
str MTIMEdaytime_daytime(daytime *ret, const daytime *src);
str MTIMEdaytime_daytime_bulk(bat *ret, const bat *bid);
str MTIMEdaytime_diff_msec(lng *ret, const daytime *v1, const daytime *v2);
str MTIMEdaytime_diff_msec_bulk(bat *ret, const bat *bid1, const bat *bid2);
+str MTIMEdaytime_diff_msec_bulk_p1(bat *ret, const daytime *src1, const bat
*bid2);
+str MTIMEdaytime_diff_msec_bulk_p2(bat *ret, const bat *bid1, const daytime
*src2);
str MTIMEdaytime_extract_hours(int *ret, const daytime *src);
str MTIMEdaytime_extract_hours_bulk(bat *ret, const bat *bid);
str MTIMEdaytime_extract_minutes(int *ret, const daytime *src);
@@ -1555,7 +1569,7 @@ str MTIMEdaytime_extract_sql_seconds(int
str MTIMEdaytime_extract_sql_seconds_bulk(bat *ret, const bat *bid);
str MTIMEdaytime_fromseconds(daytime *ret, const const lng *src);
str MTIMEdaytime_fromseconds_bulk(bat *ret, const bat *bid);
-str MTIMEdaytime_fromstr(daytime *ret, const const char *const *src);
+str MTIMEdaytime_fromstr(daytime *ret, const str *src);
str MTIMEdaytime_fromstr_bulk(bat *ret, const bat *bid);
str MTIMElocal_timezone_msec(lng *ret);
str MTIMEseconds_since_epoch(int *ret, const timestamp *src);
@@ -1572,22 +1586,38 @@ str MTIMEsql_seconds(int *ret, const lng
str MTIMEsql_seconds_bulk(bat *ret, const bat *bid);
str MTIMEsql_year(int *ret, const int *src);
str MTIMEsql_year_bulk(bat *ret, const bat *bid);
-str MTIMEstr_to_date(date *ret, const const char *const *v1, const const char
*const *v2);
+str MTIMEstr_to_date(date *ret, const str *v1, const str *v2);
str MTIMEstr_to_date_bulk(bat *ret, const bat *bid1, const bat *bid2);
-str MTIMEstr_to_time(daytime *ret, const const char *const *v1, const const
char *const *v2);
+str MTIMEstr_to_date_bulk_p1(bat *ret, const str *src1, const bat *bid2);
+str MTIMEstr_to_date_bulk_p2(bat *ret, const bat *bid1, const str *src2);
+str MTIMEstr_to_time(daytime *ret, const str *v1, const str *v2);
str MTIMEstr_to_time_bulk(bat *ret, const bat *bid1, const bat *bid2);
-str MTIMEstr_to_timestamp(timestamp *ret, const const char *const *v1, const
const char *const *v2);
+str MTIMEstr_to_time_bulk_p1(bat *ret, const str *src1, const bat *bid2);
+str MTIMEstr_to_time_bulk_p2(bat *ret, const bat *bid1, const str *src2);
+str MTIMEstr_to_timestamp(timestamp *ret, const str *v1, const str *v2);
str MTIMEstr_to_timestamp_bulk(bat *ret, const bat *bid1, const bat *bid2);
+str MTIMEstr_to_timestamp_bulk_p1(bat *ret, const str *src1, const bat *bid2);
+str MTIMEstr_to_timestamp_bulk_p2(bat *ret, const bat *bid1, const str *src2);
str MTIMEtime_add_msec_interval(daytime *ret, const daytime *v1, const lng
*v2);
str MTIMEtime_add_msec_interval_bulk(bat *ret, const bat *bid1, const bat
*bid2);
+str MTIMEtime_add_msec_interval_bulk_p1(bat *ret, const daytime *src1, const
bat *bid2);
+str MTIMEtime_add_msec_interval_bulk_p2(bat *ret, const bat *bid1, const lng
*src2);
str MTIMEtime_sub_msec_interval(daytime *ret, const daytime *v1, const lng
*v2);
str MTIMEtime_sub_msec_interval_bulk(bat *ret, const bat *bid1, const bat
*bid2);
-str MTIMEtime_to_str(str *ret, const const daytime *v1, const const char
*const *v2);
+str MTIMEtime_sub_msec_interval_bulk_p1(bat *ret, const daytime *src1, const
bat *bid2);
+str MTIMEtime_sub_msec_interval_bulk_p2(bat *ret, const bat *bid1, const lng
*src2);
+str MTIMEtime_to_str(str *ret, const daytime *v1, const str *v2);
str MTIMEtime_to_str_bulk(bat *ret, const bat *bid1, const bat *bid2);
+str MTIMEtime_to_str_bulk_p1(bat *ret, const daytime *src1, const bat *bid2);
+str MTIMEtime_to_str_bulk_p2(bat *ret, const bat *bid1, const str *src2);
str MTIMEtimestamp_add_month_interval(timestamp *ret, const timestamp *v1,
const int *v2);
str MTIMEtimestamp_add_month_interval_bulk(bat *ret, const bat *bid1, const
bat *bid2);
+str MTIMEtimestamp_add_month_interval_bulk_p1(bat *ret, const timestamp *v1,
const bat *bid2);
+str MTIMEtimestamp_add_month_interval_bulk_p2(bat *ret, const bat *bid1, const
int *v2);
str MTIMEtimestamp_add_msec_interval(timestamp *ret, const timestamp *v1,
const lng *v2);
str MTIMEtimestamp_add_msec_interval_bulk(bat *ret, const bat *bid1, const bat
*bid2);
+str MTIMEtimestamp_add_msec_interval_bulk_p1(bat *ret, const timestamp *v1,
const bat *bid2);
+str MTIMEtimestamp_add_msec_interval_bulk_p2(bat *ret, const bat *bid1, const
lng *v2);
str MTIMEtimestamp_century(int *ret, const timestamp *src);
str MTIMEtimestamp_century_bulk(bat *ret, const bat *bid);
str MTIMEtimestamp_day(int *ret, const timestamp *src);
@@ -1596,6 +1626,8 @@ str MTIMEtimestamp_decade(int *ret, cons
str MTIMEtimestamp_decade_bulk(bat *ret, const bat *bid);
str MTIMEtimestamp_diff_msec(lng *ret, const timestamp *v1, const timestamp
*v2);
str MTIMEtimestamp_diff_msec_bulk(bat *ret, const bat *bid1, const bat *bid2);
+str MTIMEtimestamp_diff_msec_bulk_p1(bat *ret, const timestamp *src1, const
bat *bid2);
+str MTIMEtimestamp_diff_msec_bulk_p2(bat *ret, const bat *bid1, const
timestamp *src2);
str MTIMEtimestamp_extract_date(date *ret, const timestamp *src);
str MTIMEtimestamp_extract_date_bulk(bat *ret, const bat *bid);
str MTIMEtimestamp_extract_daytime(daytime *ret, const timestamp *src);
@@ -1606,7 +1638,7 @@ str MTIMEtimestamp_frommsec(timestamp *r
str MTIMEtimestamp_frommsec_bulk(bat *ret, const bat *bid);
str MTIMEtimestamp_fromsecond(timestamp *ret, const int *src);
str MTIMEtimestamp_fromsecond_bulk(bat *ret, const bat *bid);
-str MTIMEtimestamp_fromstr(timestamp *ret, const const char *const *src);
+str MTIMEtimestamp_fromstr(timestamp *ret, const str *src);
str MTIMEtimestamp_fromstr_bulk(bat *ret, const bat *bid);
str MTIMEtimestamp_hours(int *ret, const timestamp *src);
str MTIMEtimestamp_hours_bulk(bat *ret, const bat *bid);
@@ -1620,12 +1652,18 @@ str MTIMEtimestamp_sql_seconds(int *ret,
str MTIMEtimestamp_sql_seconds_bulk(bat *ret, const bat *bid);
str MTIMEtimestamp_sub_month_interval(timestamp *ret, const timestamp *v1,
const int *v2);
str MTIMEtimestamp_sub_month_interval_bulk(bat *ret, const bat *bid1, const
bat *bid2);
+str MTIMEtimestamp_sub_month_interval_bulk_p1(bat *ret, const timestamp *v1,
const bat *bid2);
+str MTIMEtimestamp_sub_month_interval_bulk_p2(bat *ret, const bat *bid1, const
int *v2);
str MTIMEtimestamp_sub_msec_interval(timestamp *ret, const timestamp *v1,
const lng *v2);
str MTIMEtimestamp_sub_msec_interval_bulk(bat *ret, const bat *bid1, const bat
*bid2);
+str MTIMEtimestamp_sub_msec_interval_bulk_p1(bat *ret, const timestamp *v1,
const bat *bid2);
+str MTIMEtimestamp_sub_msec_interval_bulk_p2(bat *ret, const bat *bid1, const
lng *v2);
str MTIMEtimestamp_timestamp(timestamp *ret, const timestamp *src);
str MTIMEtimestamp_timestamp_bulk(bat *ret, const bat *bid);
-str MTIMEtimestamp_to_str(str *ret, const const timestamp *v1, const const
char *const *v2);
+str MTIMEtimestamp_to_str(str *ret, const timestamp *v1, const str *v2);
str MTIMEtimestamp_to_str_bulk(bat *ret, const bat *bid1, const bat *bid2);
+str MTIMEtimestamp_to_str_bulk_p1(bat *ret, const timestamp *src1, const bat
*bid2);
+str MTIMEtimestamp_to_str_bulk_p2(bat *ret, const bat *bid1, const str *src2);
str MTIMEtimestamp_year(int *ret, const timestamp *src);
str MTIMEtimestamp_year_bulk(bat *ret, const bat *bid);
str OIDXcreate(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c
--- a/monetdb5/modules/atoms/mtime.c
+++ b/monetdb5/modules/atoms/mtime.c
@@ -65,6 +65,8 @@ MTIMEcurrent_timestamp(timestamp *ret)
return MAL_SUCCEED;
}
+#define is_str_nil strNil
+
#define COPYFLAGS do { bn->tsorted = b->tsorted; bn->trevsorted =
b->trevsorted; } while (0)
#define SETFLAGS do { bn->tsorted = bn->trevsorted = n < 2; } while (0)
#define func1(NAME, NAMEBULK, MALFUNC, INTYPE, OUTYPE, FUNC, SETFLAGS,
FUNC_CALL) \
@@ -125,6 +127,8 @@ bailout:
\
#define func2(NAME, NAMEBULK, MALFUNC, INTYPE1, INTYPE2, OUTTYPE, FUNC,
FUNC_CALL) \
mal_export str NAME(OUTTYPE *ret, const INTYPE1 *v1, const INTYPE2 *v2); \
mal_export str NAMEBULK(bat *ret, const bat *bid1, const bat *bid2); \
+mal_export str NAMEBULK##_p1(bat *ret, const INTYPE1 *src1, const bat *bid2);
\
+mal_export str NAMEBULK##_p2(bat *ret, const bat *bid1, const INTYPE2 *src2);
\
str
\
NAME(OUTTYPE *ret, const INTYPE1 *v1, const INTYPE2 *v2)
\
{
\
@@ -184,7 +188,87 @@ bailout:
\
else if (bn)
\
BBPkeepref(*ret = bn->batCacheid);
\
return msg;
\
-}
+}
\
+str
\
+NAMEBULK##_p1(bat *ret, const INTYPE1 *src1, const bat *bid2)
\
+{
\
+ BAT *b2 = NULL, *bn = NULL;
\
+ BUN n;
\
+ const INTYPE2 *src2;
\
+ OUTTYPE *dst;
\
+ str msg = MAL_SUCCEED;
\
+
\
+ if ((b2 = BATdescriptor(*bid2)) == NULL) {
\
+ msg = createException(MAL, "batmtime." MALFUNC,
\
+ SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
\
+ goto bailout;
\
+ }
\
+ n = BATcount(b2);
\
+ if ((bn = COLnew(b2->hseqbase, TYPE_##OUTTYPE, n, TRANSIENT)) == NULL)
{ \
+ msg = createException(MAL, "batmtime." MALFUNC,
\
+ SQLSTATE(HY013) MAL_MALLOC_FAIL);
\
+ goto bailout;
\
+ }
\
+ src2 = Tloc(b2, 0);
\
+ dst = Tloc(bn, 0);
\
+ for (BUN i = 0; i < n; i++) {
\
+ FUNC_CALL(FUNC, (dst[i]), (*src1), src2[i]);
\
+ }
\
+ bn->tnonil = !is_##INTYPE1##_nil(*src1) && b2->tnonil;
\
+ bn->tnil = is_##INTYPE1##_nil(*src1) || b2->tnil;
\
+ BATsetcount(bn, n);
\
+ bn->tsorted = n < 2;
\
+ bn->trevsorted = n < 2;
\
+ bn->tkey = false;
\
+bailout:
\
+ if (b2)
\
+ BBPunfix(b2->batCacheid);
\
+ if (msg && bn)
\
+ BBPreclaim(bn);
\
+ else if (bn)
\
+ BBPkeepref(*ret = bn->batCacheid);
\
+ return msg;
\
+}
\
+str
\
+NAMEBULK##_p2(bat *ret, const bat *bid1, const INTYPE2 *src2)
\
+{
\
+ BAT *b1 = NULL, *bn = NULL;
\
+ BUN n;
\
+ const INTYPE1 *src1;
\
+ OUTTYPE *dst;
\
+ str msg = MAL_SUCCEED;
\
+
\
+ if ((b1 = BATdescriptor(*bid1)) == NULL) {
\
+ msg = createException(MAL, "batmtime." MALFUNC,
\
+ SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
\
+ goto bailout;
\
+ }
\
+ n = BATcount(b1);
\
+ if ((bn = COLnew(b1->hseqbase, TYPE_##OUTTYPE, n, TRANSIENT)) == NULL)
{ \
+ msg = createException(MAL, "batmtime." MALFUNC,
\
+ SQLSTATE(HY013) MAL_MALLOC_FAIL);
\
+ goto bailout;
\
+ }
\
+ src1 = Tloc(b1, 0);
\
+ dst = Tloc(bn, 0);
\
+ for (BUN i = 0; i < n; i++) {
\
+ FUNC_CALL(FUNC, (dst[i]), src1[i], (*src2));
\
+ }
\
+ bn->tnonil = b1->tnonil && !is_##INTYPE2##_nil(*src2);
\
+ bn->tnil = b1->tnil || is_##INTYPE2##_nil(*src2);
\
+ BATsetcount(bn, n);
\
+ bn->tsorted = n < 2;
\
+ bn->trevsorted = n < 2;
\
+ bn->tkey = false;
\
+bailout:
\
+ if (b1)
\
+ BBPunfix(b1->batCacheid);
\
+ if (msg && bn)
\
+ BBPreclaim(bn);
\
+ else if (bn)
\
+ BBPkeepref(*ret = bn->batCacheid);
\
+ return msg;
\
+}
\
#define func2_noexcept(FUNC, RET, PARAM1, PARAM2) RET = FUNC(PARAM1, PARAM2)
#define func2_except(FUNC, RET, PARAM1, PARAM2) msg = FUNC(&RET, PARAM1,
PARAM2); if (msg) break;
@@ -195,6 +279,8 @@ func2(MTIMEdaytime_diff_msec, MTIMEdayti
#define func2chk(NAME, NAMEBULK, MALFUNC, INTYPE1, INTYPE2, OUTTYPE, FUNC)
\
mal_export str NAME(OUTTYPE *ret, const INTYPE1 *v1, const INTYPE2 *v2); \
mal_export str NAMEBULK(bat *ret, const bat *bid1, const bat *bid2); \
+mal_export str NAMEBULK##_p1(bat *ret, const INTYPE1 *v1, const bat *bid2);
\
+mal_export str NAMEBULK##_p2(bat *ret, const bat *bid1, const INTYPE2 *v2);
\
str
\
NAME(OUTTYPE *ret, const INTYPE1 *v1, const INTYPE2 *v2)
\
{
\
@@ -266,8 +352,93 @@ NAMEBULK(bat *ret, const bat *bid1, cons
BBPunfix(b2->batCacheid);
\
BBPkeepref(*ret = bn->batCacheid);
\
return MAL_SUCCEED;
\
+}
\
+str
\
+NAMEBULK##_p1(bat *ret, const INTYPE1 *v1, const bat *bid2)
\
+{
\
+ BAT *b2, *bn;
\
+ BUN n;
\
+ const INTYPE2 *src2;
\
+ OUTTYPE *dst;
\
+
\
+ if ((b2 = BATdescriptor(*bid2)) == NULL) {
\
+ throw(MAL, "batmtime." MALFUNC,
\
+ SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
\
+ }
\
+ n = BATcount(b2);
\
+ if ((bn = COLnew(b2->hseqbase, TYPE_##OUTTYPE, n, TRANSIENT)) == NULL)
{ \
+ BBPunfix(b2->batCacheid);
\
+ throw(MAL, "batmtime." MALFUNC, SQLSTATE(HY013)
MAL_MALLOC_FAIL); \
+ }
\
+ src2 = Tloc(b2, 0);
\
+ dst = Tloc(bn, 0);
\
+ bn->tnil = false;
\
+ for (BUN i = 0; i < n; i++) {
\
+ if (is_##INTYPE1##_nil(*v1) || is_##INTYPE2##_nil(src2[i])) {
\
+ dst[i] = OUTTYPE##_nil;
\
+ bn->tnil = true;
\
+ } else {
\
+ dst[i] = FUNC((*v1), src2[i]);
\
+ if (is_##OUTTYPE##_nil(dst[i])) {
\
+ BBPunfix(b2->batCacheid);
\
+ BBPreclaim(bn);
\
+ throw(MAL, "batmtime." MALFUNC,
\
+ SQLSTATE(22003) "overflow in
calculation"); \
+ }
\
+ }
\
+ }
\
+ bn->tnonil = !bn->tnil;
\
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list