Changeset: 43efc5547600 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=43efc5547600
Modified Files:
        sql/backends/monet5/sql_round_impl.h
        sql/server/sql_decimal.c
        sql/test/SQLancer/Tests/sqlancer03.stable.err
        sql/test/SQLancer/Tests/sqlancer03.stable.out
Branch: Oct2020-merged-Jun2020
Log Message:

Fix some test output and use a more convervative digit convention.


diffs (135 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
@@ -309,15 +309,13 @@ nil_2dec(TYPE *res, const void *val, con
 static inline str
 str_2dec_body(TYPE *res, const str val, const int d, const int sc)
 {
-       char *s;
+       char *s = val;
        int digits;
        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);
-
-       s = val;
+               throw(SQL, STRING(TYPE), SQLSTATE(42000) "Decimal (%s) doesn't 
have format (%d.%d)", s, d, sc);
 
        int has_errors;
        value = 0;
@@ -326,7 +324,7 @@ 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)", s, d, sc);
 
        // handle situations where the de facto scale is different from the 
formal scale.
        if (scale < sc) {
diff --git a/sql/server/sql_decimal.c b/sql/server/sql_decimal.c
--- a/sql/server/sql_decimal.c
+++ b/sql/server/sql_decimal.c
@@ -60,12 +60,7 @@ fractional_sep_first_opp:
                // skip leading zeros in preceding digits, e.g. '0004563.1234' 
=> '4563.1234'
                dec++;
                if (*dec == '.') {
-                       if (dec[1] == 0) { // special case: '(0...0)0.'. We 
give this expression precision (1,0).
-                               _digits = 1;
-                               dec++;
-                               goto end_state;
-                       }
-
+                       _digits = 1; // case: 0.xyz the zero. the single 
preceding zero counts for one digit by convention.
                        goto fractional_sep_first_opp;
                }
        }
diff --git a/sql/test/SQLancer/Tests/sqlancer03.stable.err 
b/sql/test/SQLancer/Tests/sqlancer03.stable.err
--- a/sql/test/SQLancer/Tests/sqlancer03.stable.err
+++ b/sql/test/SQLancer/Tests/sqlancer03.stable.err
@@ -11,7 +11,7 @@ ERROR = !Wrong format (11313451898)
 CODE  = 42000
 MAPI  = (monetdb) /var/tmp/mtest-71583/.s.monetdb.38304
 QUERY = select cast(group_concat(all r'0.5787210717348131') as decimal) from 
t0 group by - (abs(- (- (1061572565)))), least(t0.c0, least(cast(0.09300166 as 
int), t0.c0));
-ERROR = !Rounding of decimal 
(0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131)
 doesn't fit format (18.3)
+ERROR = !Decimal 
(0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131,0.5787210717348131)
 doesn't have format (18.3)
 CODE  = 42000
 MAPI  = (monetdb) /var/tmp/mtest-608035/.s.monetdb.30116
 QUERY = SELECT ALL least(MIN(ALL CAST('0.3' AS TIME)), COALESCE 
(CAST("second"(TIMESTAMP '1970-01-19 08:50:25') AS TIME), CAST(TIME '13:00:42' 
AS TIME))), t0.c0 FROM t0
diff --git a/sql/test/SQLancer/Tests/sqlancer03.stable.out 
b/sql/test/SQLancer/Tests/sqlancer03.stable.out
--- a/sql/test/SQLancer/Tests/sqlancer03.stable.out
+++ b/sql/test/SQLancer/Tests/sqlancer03.stable.out
@@ -43,8 +43,8 @@ stdout of test 'sqlancer03` in directory
 #CREATE TABLE "sys"."t0" ("c0" BOOLEAN NOT NULL,"c1" BIGINT,CONSTRAINT 
"t0_c0_pkey" PRIMARY KEY ("c0"),CONSTRAINT "t0_c0_unique" UNIQUE ("c0"));
 #create view v0(c0, c1, c2) as (select all 2.020551048E9, 0.16688174, 
0.3732000026221729 from t0 where t0.c0) with check option;
 #SELECT sql_min(sql_max(NULL, ''), '') FROM v0 LEFT OUTER JOIN t0 ON true;
-% .%12 # table_name
-% %12 # name
+% .%1 # table_name
+% %1 # name
 % char # type
 % 0 # length
 #SELECT sql_min(sql_max(NULL, ''), '');
@@ -55,8 +55,8 @@ stdout of test 'sqlancer03` in directory
 [ NULL ]
 #SELECT ALL length(upper(MIN(ALL CAST(((trim(CAST(r'' AS STRING(659)), 
CAST(r'o3%+i]抔DCöf▟nßOpNbybಜ7' AS STRING)))||(sql_min(sql_max(NULL, r''), 
splitpart(r'x', r',7+.', t0.c1)))) AS STRING(151))))), 0.4179268710155164 
 #FROM v0 LEFT OUTER JOIN t0 ON NOT (t0.c0) WHERE t0.c0 GROUP BY 0.3584962, 
CAST(t0.c1 AS STRING(601)), t0.c1;
-% .%25,        .%26 # table_name
-% %25, %26 # name
+% .%12,        .%13 # table_name
+% %12, %13 # name
 % int, decimal # type
 % 1,   19 # length
 #ROLLBACK;
@@ -388,15 +388,15 @@ stdout of test 'sqlancer03` in directory
 #"Xh{%LTF"     false
 [ 2    ]
 #SELECT 1 FROM t0 CROSS JOIN t1 WHERE (t1.c1 AND (t0.c0 > t0.c0)) IS NULL;
-% .%4 # table_name
-% %4 # name
+% .%1 # table_name
+% %1 # name
 % tinyint # type
 % 1 # length
 #SELECT cast(SUM(agg0) as decimal(10,2)) FROM (SELECT ALL SUM(ALL 0.97) as 
agg0 FROM t0 CROSS JOIN t1 WHERE ((((t1.c1)AND(t1.c1)))AND(((t0.c0)>(t0.c0)))) 
 #UNION ALL SELECT SUM(ALL 0.97) as agg0 FROM t0 CROSS JOIN t1 WHERE NOT 
(((((t1.c1)AND(t1.c1)))AND(((t0.c0)>(t0.c0))))) 
 #UNION ALL SELECT SUM(ALL 0.97) as agg0 FROM t0 CROSS JOIN t1 WHERE 
(((((t1.c1)AND(t1.c1)))AND(((t0.c0)>(t0.c0))))) IS NULL) as asdf;
-% .%25 # table_name
-% %25 # name
+% .%17 # table_name
+% %17 # name
 % decimal # type
 % 12 # length
 [ 9.70 ]
@@ -411,8 +411,8 @@ stdout of test 'sqlancer03` in directory
 #0.916
 [ 5    ]
 #select coalesce(1 = true, false);
-% .%2 # table_name
-% %2 # name
+% .%3 # table_name
+% %3 # name
 % boolean # type
 % 5 # length
 [ true ]
@@ -673,15 +673,15 @@ stdout of test 'sqlancer03` in directory
 #NULL
 [ 7    ]
 #SELECT CASE TIMESTAMP '1970-01-02 23:16:17' WHEN DATE '1970-01-12' THEN 1 END;
-% .%2 # table_name
-% %2 # name
+% .%3 # table_name
+% %3 # name
 % tinyint # type
 % 1 # length
 [ NULL ]
 #SELECT TIME '08:16:10' FROM t1 JOIN t0 ON (t1.c0) NOT BETWEEN SYMMETRIC 
(t1.c0) AND (charindex(CAST(TIME '04:39:29' AS STRING), CASE COALESCE 
(TIMESTAMP '1970-01-02 23:16:17', TIMESTAMP '1970-01-02 23:07:33') 
 #WHEN COALESCE (DATE '1970-01-12', DATE '1970-01-02', DATE '1970-01-02') THEN 
COALESCE (r'/6望', r'hr?r3QDF*OD%6癰if}䃒5') END, t0.c0)) GROUP BY t1.c0;
-% .%4 # table_name
-% %4 # name
+% .%2 # table_name
+% %2 # name
 % time # type
 % 8 # length
 #ROLLBACK;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to