Changeset: ecda37e93a60 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ecda37e93a60
Modified Files:
        common/stream/stream.c
        sql/backends/monet5/sql_cast_impl_down_from_int.h
        sql/backends/monet5/sql_round_impl.h
Branch: Jan2014
Log Message:

merged


diffs (129 lines):

diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -3435,7 +3435,7 @@ wbs_write(stream *s, const void *buf, si
        size_t nbytes, reqsize = cnt * elmsize, todo = reqsize;
 
        wbs = (wbs_stream *) s->stream_data.p;
-       if (wbs == NULL || wbs->buf == NULL)
+       if (wbs == NULL)
                return -1;
        while (todo > 0) {
                int flush = 1;
diff --git a/sql/backends/monet5/sql_cast_impl_down_from_int.h 
b/sql/backends/monet5/sql_cast_impl_down_from_int.h
--- a/sql/backends/monet5/sql_cast_impl_down_from_int.h
+++ b/sql/backends/monet5/sql_cast_impl_down_from_int.h
@@ -47,7 +47,11 @@ FUN(,TP1,_2_,TP2) (TP2 *res, TP1 *v)
        }
 
        /* see if the number fits in the data type */
-       if ((lng) (TP2) val > (lng) GDKmin(TP2) && val > (lng) GDKmin(TP2) && 
val <= (lng) GDKmax(TP2)) {
+       if (val > (lng) GDKmin(TP2)
+#if TPE(TP2) != TYPE_wrd || SIZEOF_LNG != SIZEOF_WRD
+           && val <= (lng) GDKmax(TP2)
+#endif
+               ) {
                *res = (TP2) val;
                return (MAL_SUCCEED);
        } else {
@@ -82,7 +86,11 @@ FUN(bat,TP1,_2_,TP2) (int *res, int *bid
                for (; p < q; p++, o++) {
                        val = *p;
                        /* see if the number fits in the data type */
-                       if ((lng) (TP2) val > (lng) GDKmin(TP2) && val > (lng) 
GDKmin(TP2) && val <= (lng) GDKmax(TP2)) {
+                       if (val > (lng) GDKmin(TP2)
+#if TPE(TP2) != TYPE_wrd || SIZEOF_LNG != SIZEOF_WRD
+                           && val <= (lng) GDKmax(TP2)
+#endif
+                               ) {
                                *o = (TP2) val;
                        } else {
                                msg = createException(SQL, "convert", 
"22003!value (" LLFMT ") exceeds limits of type "STRNG(TP2), val);
@@ -97,7 +105,11 @@ FUN(bat,TP1,_2_,TP2) (int *res, int *bid
                        } else {
                                val = *p;
                                /* see if the number fits in the data type */
-                               if ((lng) (TP2) val > (lng) GDKmin(TP2) && val 
> (lng) GDKmin(TP2) && val <= (lng) GDKmax(TP2)) {
+                               if (val > (lng) GDKmin(TP2)
+#if TPE(TP2) != TYPE_wrd || SIZEOF_LNG != SIZEOF_WRD
+                                   && val <= (lng) GDKmax(TP2)
+#endif
+                                       ) {
                                        *o = (TP2) val;
                                } else {
                                        msg = createException(SQL, "convert", 
"22003!value (" LLFMT ") exceeds limits of type "STRNG(TP2), val);
@@ -143,7 +155,11 @@ FUN(,TP1,_dec2_,TP2) (TP2 *res, int *s1,
        if (scale)
                val = (val + h * scales[scale - 1]) / scales[scale];
        /* see if the number fits in the data type */
-       if (val > GDKmin(TP2) && val <= GDKmax(TP2)) {
+       if (val > (lng) GDKmin(TP2)
+#if TPE(TP2) != TYPE_wrd || SIZEOF_LNG != SIZEOF_WRD
+           && val <= GDKmax(TP2)
+#endif
+               ) {
                *res = (TP2) val;
                return MAL_SUCCEED;
        } else {
@@ -179,7 +195,11 @@ FUN(,TP1,_dec2dec_,TP2) (TP2 *res, int *
                val = (val + h * scales[s1 - s2 - 1]) / scales[s1 - s2];
 
        /* see if the number fits in the data type */
-       if (val > GDKmin(TP2) && val <= GDKmax(TP2)) {
+       if (val > (lng) GDKmin(TP2)
+#if TPE(TP2) != TYPE_wrd || SIZEOF_LNG != SIZEOF_WRD
+           && val <= GDKmax(TP2)
+#endif
+               ) {
                *res = (TP2) val;
                return MAL_SUCCEED;
        } else {
@@ -226,7 +246,11 @@ FUN(bat,TP1,_dec2_,TP2) (int *res, int *
                        else
                                val = (TP1) (*p);
                        /* see if the number fits in the data type */
-                       if (val > GDKmin(TP2) && val <= GDKmax(TP2))
+                       if (val > (lng) GDKmin(TP2)
+#if TPE(TP2) != TYPE_wrd || SIZEOF_LNG != SIZEOF_WRD
+                           && val <= GDKmax(TP2)
+#endif
+                               )
                                *o = (TP2) val;
                        else {
                                BBPreleaseref(b->batCacheid);
@@ -245,7 +269,11 @@ FUN(bat,TP1,_dec2_,TP2) (int *res, int *
                                else
                                        val = (TP1) (*p);
                                /* see if the number fits in the data type */
-                               if (val > GDKmin(TP2) && val <= GDKmax(TP2))
+                               if (val > (lng) GDKmin(TP2)
+#if TPE(TP2) != TYPE_wrd || SIZEOF_LNG != SIZEOF_WRD
+                                   && val <= GDKmax(TP2)
+#endif
+                                       )
                                        *o = (TP2) val;
                                else {
                                        BBPreleaseref(b->batCacheid);
diff --git a/sql/backends/monet5/sql_round_impl.h 
b/sql/backends/monet5/sql_round_impl.h
--- a/sql/backends/monet5/sql_round_impl.h
+++ b/sql/backends/monet5/sql_round_impl.h
@@ -158,7 +158,9 @@ round_body_nonil(TYPE v, int d, int s, i
                        lres = (((v + rnd) / scales[dff]) * scales[dff]);
                else
                        lres = (((v - rnd) / scales[dff]) * scales[dff]);
+#if TPE(TYPE) != TYPE_lng && (TPE(TYPE) != TYPE_wrd || SIZEOF_WRD != 
SIZEOF_LNG)
                assert((lng) GDKmin(TYPE) < lres && lres <= (lng) GDKmax(TYPE));
+#endif
                res = (TYPE) lres;
        } else if (r <= 0 && -r + s > 0) {
                int dff = -r + s;
@@ -168,7 +170,9 @@ round_body_nonil(TYPE v, int d, int s, i
                        lres = (((v + rnd) / scales[dff]) * scales[dff]);
                else
                        lres = (((v - rnd) / scales[dff]) * scales[dff]);
+#if TPE(TYPE) != TYPE_lng && (TPE(TYPE) != TYPE_wrd || SIZEOF_WRD != 
SIZEOF_LNG)
                assert((lng) GDKmin(TYPE) < lres && lres <= (lng) GDKmax(TYPE));
+#endif
                res = (TYPE) lres;
        } else {
                res = v;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to