Changeset: a97854b56227 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a97854b56227
Modified Files:
        sql/backends/monet5/sql_round_impl.h
        sql/server/sql_parser.y
Branch: Oct2020-merged-Jun2020
Log Message:

Fix some compilation issue's and small differences.


diffs (110 lines):

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
@@ -314,10 +314,10 @@ str_2dec_body(TYPE *res, const str val, 
        int scale;
        BIG value;
 
-       if (*d < 0 || *d >= (int) (sizeof(scales) / sizeof(scales[0])))
-               throw(SQL, STRING(TYPE), SQLSTATE(42000) "Decimal (%s) doesn't 
have format (%d.%d)", *val, *d, *sc);
+       if (d < 0 || d >= (int) (sizeof(scales) / sizeof(scales[0])))
+               throw(SQL, STRING(TYPE), SQLSTATE(42000) "Decimal (%s) doesn't 
have format (%d.%d)", val, d, sc);
 
-       s = *val;
+       s = val;
 
        int has_errors;
        value = 0;
@@ -326,25 +326,25 @@ str_2dec_body(TYPE *res, const str val, 
 
        value = decimal_from_str(s, &digits, &scale, &has_errors);
        if (has_errors)
-               throw(SQL, STRING(TYPE), SQLSTATE(42000) "Decimal (%s) doesn't 
have format (%d.%d)", *val, *d, *sc);
+               throw(SQL, STRING(TYPE), SQLSTATE(42000) "Decimal (%s) doesn't 
have format (%d.%d)", val, d, sc);
 
        // handle situations where the de facto scale is different from the 
formal scale.
-       if (scale < *sc) {
+       if (scale < sc) {
                /* the current scale is too small, increase it by adding 0's */
-               int dff = *sc - scale;  /* CANNOT be 0! */
+               int dff = sc - scale;   /* CANNOT be 0! */
                if (dff >= MAX_SCALE)
-                       throw(SQL, STRING(TYPE), SQLSTATE(42000) "Rounding of 
decimal (%s) doesn't fit format (%d.%d)", *val, *d, *sc);
+                       throw(SQL, STRING(TYPE), SQLSTATE(42000) "Rounding of 
decimal (%s) doesn't fit format (%d.%d)", s, d, sc);
 
                value *= scales[dff];
                scale += dff;
                digits += dff;
-       } else if (scale > *sc) {
+       } else if (scale > sc) {
                /* the current scale is too big, decrease it by correctly 
rounding */
                /* we should round properly, and check for overflow (res >= 
10^digits+scale) */
-               int dff = scale - *sc;  /* CANNOT be 0 */
+               int dff = scale - sc;   /* CANNOT be 0 */
 
                if (dff >= MAX_SCALE)
-                       throw(SQL, STRING(TYPE), SQLSTATE(42000) "Rounding of 
decimal (%s) doesn't fit format (%d.%d)", *val, *d, *sc);
+                       throw(SQL, STRING(TYPE), SQLSTATE(42000) "Rounding of 
decimal (%s) doesn't fit format (%d.%d)", s, d, sc);
 
                BIG rnd = scales[dff] >> 1;
 
@@ -355,13 +355,11 @@ str_2dec_body(TYPE *res, const str val, 
                value /= scales[dff];
                scale -= dff;
                digits -= dff;
-               if (value >= scales[*d] || value <= -scales[*d]) {
-                       throw(SQL, STRING(TYPE), SQLSTATE(42000) "Rounding of 
decimal (%s) doesn't fit format (%d.%d)", *val, *d, *sc);
-               }
+               if (value >= scales[d] || value <= -scales[d])
+                       throw(SQL, STRING(TYPE), SQLSTATE(42000) "Rounding of 
decimal (%s) doesn't fit format (%d.%d)", s, d, sc);
        }
-       if (value <= -scales[*d] || value >= scales[*d]) {
-               throw(SQL, STRING(TYPE), SQLSTATE(42000) "Decimal (%s) doesn't 
have format (%d.%d)", *val, *d, *sc);
-       }
+       if (value <= -scales[d] || value >= scales[d])
+               throw(SQL, STRING(TYPE), SQLSTATE(42000) "Decimal (%s) doesn't 
have format (%d.%d)", s, d, sc);
        *res = (TYPE) value;
        return MAL_SUCCEED;
 }
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -4719,30 +4719,27 @@ literal:
 
                        if (!has_errors && digits <= MAX_DEC_DIGITS) {
                                // The float-like value seems to fit in decimal 
storage
-                               double val = strtod($1,NULL);
                                sql_find_subtype(&t, "decimal", digits, scale );
-                               $$ = _newAtomNode( atom_dec(SA, &t, value, 
val));
+                               $$ = _newAtomNode( atom_dec(SA, &t, value));
                        }
                        else {
                                /*
-                                * The float-like value either doesn't fit in 
integer decimal storage
-                                * or it is not a valid float representation.
-                                */
+                               * The float-like value either doesn't fit in 
integer decimal storage
+                               * or it is not a valid float representation.
+                               */
                                char *p = $1;
                                double val;
 
                                errno = 0;
                                val = strtod($1,&p);
                                if (p == $1 || is_dbl_nil(val) || (errno == 
ERANGE && (val < -1 || val > 1))) {
-                               sqlformaterror(m, SQLSTATE(22003) "Double value 
too large or not a number (%s)", $1);
-
-                                       yyerror(m, msg);
-                                       _DELETE(msg);
+                                       sqlformaterror(m, SQLSTATE(22003) 
"Double value too large or not a number (%s)", $1);
                                        $$ = NULL;
                                        YYABORT;
+                               } else {
+                                       sql_find_subtype(&t, "double", 51, 0 );
+                                       $$ = _newAtomNode(atom_float(SA, &t, 
val));
                                }
-                               sql_find_subtype(&t, "double", 51, 0 );
-                               $$ = _newAtomNode(atom_float(SA, &t, val));
                   }
                }
  |  APPROXNUM
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to