Changeset: b35a861df01d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b35a861df01d
Added Files:
sql/test/BugTracker-2017/Tests/sqlitelogictest-algebra-operators.Bug-6494.stable.err
sql/test/BugTracker-2017/Tests/sqlitelogictest-algebra-operators.Bug-6494.stable.out
Modified Files:
sql/server/sql_atom.c
Branch: Jul2017
Log Message:
Use "largest" type as result type in atom_{add,sub,mul}.
This fixes bug 6494.
diffs (137 lines):
diff --git a/sql/server/sql_atom.c b/sql/server/sql_atom.c
--- a/sql/server/sql_atom.c
+++ b/sql/server/sql_atom.c
@@ -1197,6 +1197,13 @@ atom_add(atom *a1, atom *a2)
if ((!EC_COMPUTE(a1->tpe.type->eclass) && (a1->tpe.type->eclass !=
EC_DEC || a1->tpe.digits != a2->tpe.digits || a1->tpe.scale != a2->tpe.scale))
|| a1->tpe.digits < a2->tpe.digits || a1->tpe.type->localtype !=
a2->tpe.type->localtype) {
return NULL;
}
+ if (a1->tpe.type->localtype < a2->tpe.type->localtype ||
+ (a1->tpe.type->localtype == a2->tpe.type->localtype &&
+ a1->tpe.digits < a2->tpe.digits)) {
+ atom *t = a1;
+ a1 = a2;
+ a2 = t;
+ }
dst.vtype = a1->tpe.type->localtype;
if (VARcalcadd(&dst, &a1->data, &a2->data, 1) != GDK_SUCCEED)
return NULL;
@@ -1214,9 +1221,18 @@ atom_sub(atom *a1, atom *a2)
if ((!EC_COMPUTE(a1->tpe.type->eclass) && (a1->tpe.type->eclass !=
EC_DEC || a1->tpe.digits != a2->tpe.digits || a1->tpe.scale != a2->tpe.scale))
|| a1->tpe.digits < a2->tpe.digits || a1->tpe.type->localtype !=
a2->tpe.type->localtype) {
return NULL;
}
- dst.vtype = a1->tpe.type->localtype;
+ if (a1->tpe.type->localtype < a2->tpe.type->localtype ||
+ (a1->tpe.type->localtype == a2->tpe.type->localtype &&
+ a1->tpe.digits < a2->tpe.digits))
+ dst.vtype = a2->tpe.type->localtype;
+ else
+ dst.vtype = a1->tpe.type->localtype;
if (VARcalcsub(&dst, &a1->data, &a2->data, 1) != GDK_SUCCEED)
return NULL;
+ if (a1->tpe.type->localtype < a2->tpe.type->localtype ||
+ (a1->tpe.type->localtype == a2->tpe.type->localtype &&
+ a1->tpe.digits < a2->tpe.digits))
+ a1 = a2;
a1->data = dst;
dst.vtype = TYPE_dbl;
if (VARconvert(&dst, &a1->data, 1) == GDK_SUCCEED)
@@ -1243,10 +1259,14 @@ atom_mul(atom *a1, atom *a2)
a1->d = a1->data.val.dval = dst.val.dval;
return a1;
}
- if (a1->tpe.type->localtype >= a2->tpe.type->localtype)
- dst.vtype = a1->tpe.type->localtype;
- else
- dst.vtype = a2->tpe.type->localtype;
+ if (a1->tpe.type->localtype < a2->tpe.type->localtype ||
+ (a1->tpe.type->localtype == a2->tpe.type->localtype &&
+ a1->tpe.digits < a2->tpe.digits)) {
+ atom *t = a1;
+ a1 = a2;
+ a2 = t;
+ }
+ dst.vtype = a1->tpe.type->localtype;
if (VARcalcmul(&dst, &a1->data, &a2->data, 1) != GDK_SUCCEED)
return NULL;
a1->data = dst;
diff --git
a/sql/test/BugTracker-2017/Tests/sqlitelogictest-algebra-operators.Bug-6494.stable.err
b/sql/test/BugTracker-2017/Tests/sqlitelogictest-algebra-operators.Bug-6494.stable.err
new file mode 100644
--- /dev/null
+++
b/sql/test/BugTracker-2017/Tests/sqlitelogictest-algebra-operators.Bug-6494.stable.err
@@ -0,0 +1,34 @@
+stderr of test 'sqlitelogictest-algebra-operators.Bug-6494` in directory
'sql/test/BugTracker-2017` itself:
+
+
+# 16:01:45 >
+# 16:01:45 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=34700" "--set"
"mapi_usock=/var/tmp/mtest-6129/.s.monetdb.34700" "--set" "monet_prompt="
"--forcemito"
"--dbpath=/ufs/sjoerd/@Monet-stable/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 16:01:45 >
+
+# builtin opt gdk_dbpath = /ufs/sjoerd/@Monet-stable/var/monetdb5/dbfarm/demo
+# builtin opt gdk_debug = 0
+# builtin opt gdk_vmtrim = no
+# builtin opt monet_prompt = >
+# builtin opt monet_daemon = no
+# builtin opt mapi_port = 50000
+# builtin opt mapi_open = false
+# builtin opt mapi_autosense = false
+# builtin opt sql_optimizer = default_pipe
+# builtin opt sql_debug = 0
+# cmdline opt gdk_nr_threads = 0
+# cmdline opt mapi_open = true
+# cmdline opt mapi_port = 34700
+# cmdline opt mapi_usock = /var/tmp/mtest-6129/.s.monetdb.34700
+# cmdline opt monet_prompt =
+# cmdline opt gdk_dbpath =
/ufs/sjoerd/@Monet-stable/var/MonetDB/mTests_sql_test_BugTracker-2017
+# cmdline opt gdk_debug = 553648138
+
+# 16:01:45 >
+# 16:01:45 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-6129" "--port=34700"
+# 16:01:45 >
+
+
+# 16:01:45 >
+# 16:01:45 > "Done."
+# 16:01:45 >
+
diff --git
a/sql/test/BugTracker-2017/Tests/sqlitelogictest-algebra-operators.Bug-6494.stable.out
b/sql/test/BugTracker-2017/Tests/sqlitelogictest-algebra-operators.Bug-6494.stable.out
new file mode 100644
--- /dev/null
+++
b/sql/test/BugTracker-2017/Tests/sqlitelogictest-algebra-operators.Bug-6494.stable.out
@@ -0,0 +1,37 @@
+stdout of test 'sqlitelogictest-algebra-operators.Bug-6494` in directory
'sql/test/BugTracker-2017` itself:
+
+
+# 16:01:45 >
+# 16:01:45 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=34700" "--set"
"mapi_usock=/var/tmp/mtest-6129/.s.monetdb.34700" "--set" "monet_prompt="
"--forcemito"
"--dbpath=/ufs/sjoerd/@Monet-stable/var/MonetDB/mTests_sql_test_BugTracker-2017"
+# 16:01:45 >
+
+# MonetDB 5 server v11.27.12 (hg id: a2f70a576335+)
+# This is an unreleased version
+# Serving database 'mTests_sql_test_BugTracker-2017', using 8 threads
+# Compiled for x86_64-pc-linux-gnu/64bit with 128bit integers
+# Found 62.700 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2017 MonetDB B.V., all rights reserved
+# Visit https://www.monetdb.org/ for further information
+# Listening for connection requests on
mapi:monetdb://methuselah.da.cwi.nl:34700/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-6129/.s.monetdb.34700
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 16:01:45 >
+# 16:01:45 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-6129" "--port=34700"
+# 16:01:45 >
+
+#SELECT 85 * + 52 * 50 * ( + + 82 ) + - 78;
+% .L2 # table_name
+% L2 # name
+% int # type
+% 8 # length
+[ 18121922 ]
+
+# 16:01:45 >
+# 16:01:45 > "Done."
+# 16:01:45 >
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list