Changeset: 89a5f0dd6857 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/89a5f0dd6857
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk.h
sql/server/rel_statistics.c
sql/test/emptydb/Tests/check.stable.out.int128
Branch: persistent_sketches
Log Message:
Merge with default branch.
diffs (truncated from 3314 to 300 lines):
diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -862,3 +862,4 @@ b4c2936c46f28ad6b3e59ed5a1a844726d521994
bc5735402f969151c941c100a7552769c0e89a9a Dec2025_9
bc5735402f969151c941c100a7552769c0e89a9a Dec2025_SP4_release
7fc4b6dba998768109bbc40409a6128992eef08e Dec2025_11
+7fc4b6dba998768109bbc40409a6128992eef08e Dec2025_SP5_release
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
@@ -463,6 +463,11 @@ void VIEWbounds(BAT *b, BAT *view, BUN l
BAT *VIEWcreate(oid seq, BAT *b, BUN l, BUN h);
size_t _MT_npages;
size_t _MT_pagesize;
+bool add_int128_overflow(int128_t a, int128_t b, int128_t *d);
+bool add_int16_overflow(int16_t a, int16_t b, int16_t *d);
+bool add_int32_overflow(int32_t a, int32_t b, int32_t *d);
+bool add_int64_overflow(int64_t a, int64_t b, int64_t *d);
+bool add_int8_overflow(int8_t a, int8_t b, int8_t *d);
char *asctime_r(const struct tm *restrict, char *restrict);
gdk_return bat_sketch(BATiter *bi, struct canditer *bci, void *sketch);
ssize_t bitFromStr(allocator *ma, const char *src, size_t *len, bit **dst,
bool external);
@@ -592,6 +597,11 @@ const char *mo_find_option(opt *set, int
void mo_free_options(opt *set, int setlen);
void mo_print_options(opt *set, int setlen);
int mo_system_config(opt **Set, int setlen);
+bool mul_int128_overflow(int128_t a, int128_t b, int128_t *d);
+bool mul_int16_overflow(int16_t a, int16_t b, int16_t *d);
+bool mul_int32_overflow(int32_t a, int32_t b, int32_t *d);
+bool mul_int64_overflow(int64_t a, int64_t b, int64_t *d);
+bool mul_int8_overflow(int8_t a, int8_t b, int8_t *d);
const oid oid_nil;
ssize_t ptrFromStr(allocator *ma, const char *src, size_t *len, ptr **dst,
bool external);
ssize_t ptrToStr(allocator *ma, char **dst, size_t *len, const ptr *src, bool
external);
@@ -607,6 +617,11 @@ ssize_t sql_timestamp_fromstr(allocator
ssize_t strFromStr(allocator *ma, const char *restrict src, size_t *restrict
len, char **restrict dst, bool external);
const char str_nil[2];
int strerror_r(int errnum, char *buf, size_t buflen);
+bool sub_int128_overflow(int128_t a, int128_t b, int128_t *d);
+bool sub_int16_overflow(int16_t a, int16_t b, int16_t *d);
+bool sub_int32_overflow(int32_t a, int32_t b, int32_t *d);
+bool sub_int64_overflow(int64_t a, int64_t b, int64_t *d);
+bool sub_int8_overflow(int8_t a, int8_t b, int8_t *d);
timestamp timestamp_add_month(timestamp t, int m);
timestamp timestamp_add_usec(timestamp t, lng usec);
timestamp timestamp_create(date dt, daytime tm);
diff --git a/common/stream/fwf.c b/common/stream/fwf.c
--- a/common/stream/fwf.c
+++ b/common/stream/fwf.c
@@ -74,18 +74,20 @@ stream_fwf_read(stream *restrict s, void
for (field_idx = 0; field_idx < fsd->num_fields;
field_idx++) {
char *val_start, *val_end;
- val_start = fsd->in_buf + in_buf_pos;
- in_buf_pos += fsd->widths[field_idx];
- val_end = fsd->in_buf + in_buf_pos - 1;
- while (*val_start == fsd->filler)
- val_start++;
- while (*val_end == fsd->filler)
- val_end--;
- while (val_start <= val_end) {
- if (*val_start == STREAM_FWF_FIELD_SEP)
{
- fsd->out_buf[out_buf_pos++] =
STREAM_FWF_ESCAPE;
+ if (fsd->widths[field_idx] > 0) {
+ val_start = fsd->in_buf + in_buf_pos;
+ in_buf_pos += fsd->widths[field_idx];
+ val_end = fsd->in_buf + in_buf_pos - 1;
+ while (*val_start == fsd->filler)
+ val_start++;
+ while (*val_end == fsd->filler)
+ val_end--;
+ while (val_start <= val_end) {
+ if (*val_start ==
STREAM_FWF_FIELD_SEP) {
+
fsd->out_buf[out_buf_pos++] = STREAM_FWF_ESCAPE;
+ }
+ fsd->out_buf[out_buf_pos++] =
*val_start++;
}
- fsd->out_buf[out_buf_pos++] =
*val_start++;
}
fsd->out_buf[out_buf_pos++] =
STREAM_FWF_FIELD_SEP;
}
@@ -161,7 +163,7 @@ stream_fwf_create(stream *restrict s, si
mnstr_set_open_error(STREAM_FWF_NAME, errno, NULL);
return NULL;
}
- fsd->out_buf = malloc(fsd->line_len * 3);
+ fsd->out_buf = malloc(fsd->line_len * 2 + num_fields + 1);
if (fsd->out_buf == NULL) {
free(fsd->in_buf);
free(fsd);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2013,8 +2013,8 @@ gdk_export size_t escapedStr(char *restr
#define GDK_lng_max ((lng) INT64_MAX)
#define GDK_lng_min ((lng) INT64_MIN+1)
#ifdef HAVE_HGE
-#define GDK_hge_max ((((hge) 1) << 126) - 1 + (((hge) 1) << 126))
-#define GDK_hge_min (-GDK_hge_max)
+#define GDK_hge_max ((hge) INT128_MAX)
+#define GDK_hge_min ((hge) INT128_MIN+1)
#endif
#define GDK_flt_max ((flt) FLT_MAX)
#define GDK_flt_min ((flt) -FLT_MAX)
@@ -2327,6 +2327,28 @@ VarHeapVal(const void *b, BUN p, int w)
}
}
+gdk_export bool add_int8_overflow(int8_t a, int8_t b, int8_t *d);
+gdk_export bool add_int16_overflow(int16_t a, int16_t b, int16_t *d);
+gdk_export bool add_int32_overflow(int32_t a, int32_t b, int32_t *d);
+gdk_export bool add_int64_overflow(int64_t a, int64_t b, int64_t *d);
+#ifdef HAVE_INT128_T
+gdk_export bool add_int128_overflow(int128_t a, int128_t b, int128_t *d);
+#endif
+gdk_export bool sub_int8_overflow(int8_t a, int8_t b, int8_t *d);
+gdk_export bool sub_int16_overflow(int16_t a, int16_t b, int16_t *d);
+gdk_export bool sub_int32_overflow(int32_t a, int32_t b, int32_t *d);
+gdk_export bool sub_int64_overflow(int64_t a, int64_t b, int64_t *d);
+#ifdef HAVE_INT128_T
+gdk_export bool sub_int128_overflow(int128_t a, int128_t b, int128_t *d);
+#endif
+gdk_export bool mul_int8_overflow(int8_t a, int8_t b, int8_t *d);
+gdk_export bool mul_int16_overflow(int16_t a, int16_t b, int16_t *d);
+gdk_export bool mul_int32_overflow(int32_t a, int32_t b, int32_t *d);
+gdk_export bool mul_int64_overflow(int64_t a, int64_t b, int64_t *d);
+#ifdef HAVE_INT128_T
+gdk_export bool mul_int128_overflow(int128_t a, int128_t b, int128_t *d);
+#endif
+
/* BAT iterator, also protects use of BAT heaps with reference counts.
*
* A BAT iterator has to be used with caution, but it does have to be
diff --git a/gdk/gdk_calc_addsub.c b/gdk/gdk_calc_addsub.c
--- a/gdk/gdk_calc_addsub.c
+++ b/gdk/gdk_calc_addsub.c
@@ -13,6 +13,80 @@
#include "gdk_private.h"
#include "gdk_calc_private.h"
+bool
+add_int8_overflow(int8_t a, int8_t b, int8_t *d)
+{
+ ADDI_WITH_CHECK(a, b, int8_t, *d, INT8_MAX, return true);
+ return false;
+}
+
+bool
+add_int16_overflow(int16_t a, int16_t b, int16_t *d)
+{
+ ADDI_WITH_CHECK(a, b, int16_t, *d, INT16_MAX, return true);
+ return false;
+}
+
+bool
+add_int32_overflow(int32_t a, int32_t b, int32_t *d)
+{
+ ADDI_WITH_CHECK(a, b, int32_t, *d, INT32_MAX, return true);
+ return false;
+}
+
+bool
+add_int64_overflow(int64_t a, int64_t b, int64_t *d)
+{
+ ADDI_WITH_CHECK(a, b, int64_t, *d, INT64_MAX, return true);
+ return false;
+}
+
+#ifdef HAVE_INT128_T
+bool
+add_int128_overflow(int128_t a, int128_t b, int128_t *d)
+{
+ ADDI_WITH_CHECK(a, b, int128_t, *d, INT128_MAX, return true);
+ return false;
+}
+#endif
+
+bool
+sub_int8_overflow(int8_t a, int8_t b, int8_t *d)
+{
+ SUBI_WITH_CHECK(a, b, int8_t, *d, INT8_MAX, return true);
+ return false;
+}
+
+bool
+sub_int16_overflow(int16_t a, int16_t b, int16_t *d)
+{
+ SUBI_WITH_CHECK(a, b, int16_t, *d, INT16_MAX, return true);
+ return false;
+}
+
+bool
+sub_int32_overflow(int32_t a, int32_t b, int32_t *d)
+{
+ SUBI_WITH_CHECK(a, b, int32_t, *d, INT32_MAX, return true);
+ return false;
+}
+
+bool
+sub_int64_overflow(int64_t a, int64_t b, int64_t *d)
+{
+ SUBI_WITH_CHECK(a, b, int64_t, *d, INT64_MAX, return true);
+ return false;
+}
+
+#ifdef HAVE_INT128_T
+bool
+sub_int128_overflow(int128_t a, int128_t b, int128_t *d)
+{
+ SUBI_WITH_CHECK(a, b, int128_t, *d, INT128_MAX, return true);
+ return false;
+}
+#endif
+
/* ---------------------------------------------------------------------- */
/* addition (any numeric type) */
diff --git a/gdk/gdk_calc_mul.c b/gdk/gdk_calc_mul.c
--- a/gdk/gdk_calc_mul.c
+++ b/gdk/gdk_calc_mul.c
@@ -13,6 +13,43 @@
#include "gdk_private.h"
#include "gdk_calc_private.h"
+bool
+mul_int8_overflow(int8_t a, int8_t b, int8_t *d)
+{
+ MULI4_WITH_CHECK(a, b, int8_t, *d, INT8_MAX, int16_t, return true);
+ return false;
+}
+
+bool
+mul_int16_overflow(int16_t a, int16_t b, int16_t *d)
+{
+ MULI4_WITH_CHECK(a, b, int16_t, *d, INT16_MAX, int32_t, return true);
+ return false;
+}
+
+bool
+mul_int32_overflow(int32_t a, int32_t b, int32_t *d)
+{
+ MULI4_WITH_CHECK(a, b, int32_t, *d, INT32_MAX, int64_t, return true);
+ return false;
+}
+
+bool
+mul_int64_overflow(int64_t a, int64_t b, int64_t *d)
+{
+ LNGMUL_CHECK(a, b, *d, INT64_MAX, return true);
+ return false;
+}
+
+#ifdef HAVE_INT128_T
+bool
+mul_int128_overflow(int128_t a, int128_t b, int128_t *d)
+{
+ HGEMUL_CHECK(a, b, *d, INT128_MAX, return true);
+ return false;
+}
+#endif
+
/* ---------------------------------------------------------------------- */
/* multiplication (any numeric type) */
diff --git a/gdk/gdk_calc_private.h b/gdk/gdk_calc_private.h
--- a/gdk/gdk_calc_private.h
+++ b/gdk/gdk_calc_private.h
@@ -146,10 +146,7 @@
#define MULI4_WITH_CHECK(lft, rgt, TYPE3, dst, max, TYPE4, on_overflow) \
MUL4_WITH_CHECK(lft, rgt, TYPE3, dst, max, TYPE4, on_overflow)
#endif
-#ifdef HAVE_HGE
-#define LNGMUL_CHECK(lft, rgt, dst, max, on_overflow) \
- MULI4_WITH_CHECK(lft, rgt, lng, dst, max, hge, on_overflow)
-#elif defined(HAVE_INT128_T)
+#ifdef HAVE_INT128_T
#define LNGMUL_CHECK(lft, rgt, dst, max, on_overflow) \
MULI4_WITH_CHECK(lft, rgt, lng, dst, max, int128_t, on_overflow)
#elif defined(_MSC_VER) && defined(_M_AMD64) && !defined(__INTEL_COMPILER)
@@ -157,11 +154,11 @@
#pragma intrinsic(_mul128)
#define LNGMUL_CHECK(lft, rgt, dst, max, on_overflow) \
do { \
- __int64 clo, chi; \
- clo = _mul128((__int64) (lft), (__int64) (rgt), &chi); \
- if ((chi == 0 && clo >= 0 /*&& clo <= (max)*/) || \
- (chi == -1 && clo < 0 && clo >= -(max))) { \
- (dst) = (lng) clo; \
+ __int64 _clo, _chi; \
+ _clo = _mul128((__int64) (lft), (__int64) (rgt), &_chi); \
+ if ((_chi == 0 && _clo >= 0 /*&& _clo <= (max)*/) || \
+ (_chi == -1 && _clo < 0 && _clo >= -(max))) { \
+ (dst) = (lng) _clo; \
} else { \
on_overflow; \
} \
@@ -169,29 +166,29 @@
#else
#define LNGMUL_CHECK(lft, rgt, dst, max, on_overflow) \
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]