Changeset: 7d00b5e5604d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7d00b5e5604d
Modified Files:
        sql/backends/monet5/sql_round_impl.h
        sql/test/bugs/Tests/alter_add_column-bug.stable.err
Branch: Oct2014
Log Message:

fixed bug string 2 decimal conversion


diffs (47 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
@@ -291,8 +291,8 @@ str_2dec(TYPE *res, str *val, int *d, in
 {
        char *s = strip_extra_zeros(*val);
        char *dot = strchr(s, '.'), *end = NULL;
-       int digits = _strlen(s) - 1;
-       int scale = digits - (int) (dot - s);
+       int digits = _strlen(s);
+       int scale = digits - (int) (dot - s) - 1;
        lng value = 0;
 
        if (!dot) {
@@ -305,7 +305,7 @@ str_2dec(TYPE *res, str *val, int *d, in
        } else { /* we have a dot in the string */
                digits--;
        }
-       if (digits <= 0)
+       if (digits < 0)
                throw(SQL, STRING(TYPE), "decimal (%s) doesn't have format 
(%d.%d)", *val, *d, *sc);
 
        value = decimal_from_str(s, &end);
@@ -335,7 +335,7 @@ str_2dec(TYPE *res, str *val, int *d, in
                        throw(SQL, STRING(TYPE), "rounding of decimal (%s) 
doesn't fit format (%d.%d)", *val, *d, *sc);
                }
        }
-       if (digits <= 0 || digits > *d || *end) {
+       if (value <= -scales[*d] || value >= scales[*d]  || *end) {
                throw(SQL, STRING(TYPE), "decimal (%s) doesn't have format 
(%d.%d)", *val, *d, *sc);
        }
        *res = (TYPE) value;
diff --git a/sql/test/bugs/Tests/alter_add_column-bug.stable.err 
b/sql/test/bugs/Tests/alter_add_column-bug.stable.err
--- a/sql/test/bugs/Tests/alter_add_column-bug.stable.err
+++ b/sql/test/bugs/Tests/alter_add_column-bug.stable.err
@@ -12,9 +12,9 @@ stderr of test 'alter_add_column-bug` in
 # 23:04:06 >  mclient -lsql -umonetdb -Pmonetdb --host=koala --port=36740 
 # 23:04:06 >  
 
-MAPI  = (monetdb) /var/tmp/mtest-23209/.s.monetdb.33225
+MAPI  = (monetdb) /var/tmp/mtest-28252/.s.monetdb.32257
 QUERY = ALTER TABLE "myschema"."COLLECTION_INFO" ADD COLUMN test_col1  
varchar(256);
-ERROR = !ALTER TABLE: no such table 'COLLECTION_INFO'
+ERROR = !ALTER TABLE: no such table 'COLLECTION_INFO' in schema 'myschema'
 
 # 23:04:06 >  
 # 23:04:06 >  Done.
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to