Changeset: 00db70ac361d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=00db70ac361d
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/backends/monet5/sql_scenario.c
        sql/jdbc/tests/Tests/Test_Rtimedate.stable.out
        sql/server/sql_atom.c
        sql/server/sql_qc.c
        sql/server/sql_qc.h
Branch: default
Log Message:

Merge with Jul2017 branch.


diffs (299 lines):

diff --git a/sql/backends/monet5/sql_scenario.c 
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -1157,6 +1157,7 @@ SQLparser(Client c)
        } else if (caching(m) && cachable(m, NULL) && m->emode != m_prepare && 
(be->q = qc_match(m->qc, m->sym, m->args, m->argc, m->scanner.key ^ 
m->session->schema->base.id)) != NULL) {
                /* query template was found in the query cache */
                scanner_query_processed(&(m->scanner));
+               m->no_mitosis = be->q->no_mitosis;
        } else {
                sql_rel *r;
 
@@ -1213,7 +1214,8 @@ SQLparser(Client c)
                                                  m->args,      /* the argument 
list */
                                                  m->argc, m->scanner.key ^ 
m->session->schema->base.id,        /* the statement hash key */
                                                  m->emode == m_prepare ? 
Q_PREPARE : m->type,  /* the type of the statement */
-                                                 escaped_q);
+                                                 escaped_q,
+                                                 m->no_mitosis);
                        }
                        if(!be->q) {
                                err = 1;
diff --git a/sql/jdbc/tests/Tests/Test_Rtimedate.stable.out 
b/sql/jdbc/tests/Tests/Test_Rtimedate.stable.out
--- a/sql/jdbc/tests/Tests/Test_Rtimedate.stable.out
+++ b/sql/jdbc/tests/Tests/Test_Rtimedate.stable.out
@@ -24,31 +24,71 @@ Ready.
 # 21:26:11 >  
 
 false  false
-1. 1, 2004-04-24 11:43:53.000000, 2004-04-24 11:43:53.0
-2. 1, 2004-04-24 11:43:53.000000, 11:43:53
-3. 1, 2004-04-24 11:43:53.000000, 2004-04-24
-4. 2, 11:43:53, 1970-01-01 11:43:53.0
-5. 2, 11:43:53, 11:43:53
-6. 2, 11:43:53, 1970-01-01
-7. 3, 2004-04-24, 2004-04-24 00:00:00.0
-8. 3, 2004-04-24, 00:00:00
-9. 3, 2004-04-24, 2004-04-24
-1. 4, 2004-04-24 11:43:53.000000, 2004-04-24 11:43:53.0
-2. 4, 2004-04-24 11:43:53.000000, 00:00:00
-warning: java.sql.SQLWarning: parsing failed, found: '-' in: "2004-04-24 
11:43:53.000000" at pos: 4
-3. 4, 2004-04-24 11:43:53.000000, 2004-04-24
-4. 5, 11:43:53, 1970-01-01 00:00:00.0
-warning: java.sql.SQLWarning: parsing failed, found: ':' in: "11:43:53" at 
pos: 2
-5. 5, 11:43:53, 11:43:53
-6. 5, 11:43:53, 1970-01-01
-warning: java.sql.SQLWarning: parsing failed, found: ':' in: "11:43:53" at 
pos: 2
-7. 6, 2004-04-24, 1970-01-01 00:00:00.0
-warning: java.sql.SQLWarning: parsing failed, expected more data after 
'2004-04-24'
-8. 6, 2004-04-24, 00:00:00
-warning: java.sql.SQLWarning: parsing failed, found: '-' in: "2004-04-24" at 
pos: 4
-9. 6, 2004-04-24, 2004-04-24
+1. ts 2004-04-24 11:43:53.123000 to ts: 2004-04-24 11:43:53.123
+1. ts 2004-04-24 11:43:53.123000 to tm: 11:43:53
+1. ts 2004-04-24 11:43:53.123000 to dt: 2004-04-24
+2. t 11:43:53 to ts: 1970-01-01 11:43:53.0
+2. t 11:43:53 to tm: 11:43:53
+2. t 11:43:53 to dt: 1970-01-01
+3. d 2004-04-24 to ts: 2004-04-24 00:00:00.0
+3. d 2004-04-24 to tm: 00:00:00
+3. d 2004-04-24 to dt: 2004-04-24
+4. vc 2004-04-24 11:43:53.654321 to ts: 2004-04-24 11:43:53.654321
+rs.getTime(colnm) failed with error: parsing failed, found: '-' in: 
"2004-04-24 11:43:53.654321" at pos: 5
+4. vc 2004-04-24 11:43:53.654321 to dt: 2004-04-24
+rs.getTimestamp(colnm) failed with error: parsing failed, found: ':' in: 
"11:43:53" at pos: 3
+5. vc 11:43:53 to tm: 11:43:53
+rs.getDate(colnm) failed with error: parsing failed, found: ':' in: "11:43:53" 
at pos: 3
+6. vc 2004-04-24 to ts: 2004-04-24 00:00:00.0
+rs.getTime(colnm) failed with error: parsing failed, found: '-' in: 
"2004-04-24" at pos: 5
+6. vc 2004-04-24 to dt: 2004-04-24
+11. ts 904-04-24 11:43:53.567000 to ts: 0904-04-24 11:43:53.567
+11. ts 904-04-24 11:43:53.567000 to tm: 11:43:53
+11. ts 904-04-24 11:43:53.567000 to dt: 0904-04-24
+12. ts 74-04-24 11:43:53.567000 to ts: 0074-04-24 11:43:53.567
+12. ts 74-04-24 11:43:53.567000 to tm: 11:43:53
+12. ts 74-04-24 11:43:53.567000 to dt: 0074-04-24
+13. ts 4-04-24 11:43:53.567000 to ts: 0004-04-24 11:43:53.567
+13. ts 4-04-24 11:43:53.567000 to tm: 11:43:53
+13. ts 4-04-24 11:43:53.567000 to dt: 0004-04-24
+14. d 904-04-24 to ts: 0904-04-24 00:00:00.0
+14. d 904-04-24 to tm: 00:00:00
+14. d 904-04-24 to dt: 0904-04-24
+15. d 74-04-24 to ts: 0074-04-24 00:00:00.0
+15. d 74-04-24 to tm: 00:00:00
+15. d 74-04-24 to dt: 0074-04-24
+16. d 4-04-24 to ts: 0004-04-24 00:00:00.0
+16. d 4-04-24 to tm: 00:00:00
+16. d 4-04-24 to dt: 0004-04-24
+17. vc 904-04-24 11:43:53.567 to ts: 0904-04-24 11:43:53.567
+rs.getTime(colnm) failed with error: parsing failed, found: '-' in: "904-04-24 
11:43:53.567" at pos: 4
+17. vc 904-04-24 11:43:53.567 to dt: 0904-04-24
+18. vc 74-04-24 11:43:53.567 to ts: 0074-04-24 11:43:53.567
+rs.getTime(colnm) failed with error: parsing failed, found: '-' in: "74-04-24 
11:43:53.567" at pos: 3
+18. vc 74-04-24 11:43:53.567 to dt: 0074-04-24
+19. vc 4-04-24 11:43:53.567 to ts: 0004-04-24 11:43:53.567
+rs.getTime(colnm) failed with error: parsing failed, found: '-' in: "4-04-24 
11:43:53.567" at pos: 2
+19. vc 4-04-24 11:43:53.567 to dt: 0004-04-24
+21. ts -4-04-24 11:43:53.567000 to ts: 0004-04-24 11:43:53.567
+21. ts -4-04-24 11:43:53.567000 to tm: 11:43:53
+21. ts -4-04-24 11:43:53.567000 to dt: 0004-04-24
+22. ts -2004-04-24 11:43:53.567000 to ts: 2004-04-24 11:43:53.567
+22. ts -2004-04-24 11:43:53.567000 to tm: 11:43:53
+22. ts -2004-04-24 11:43:53.567000 to dt: 2004-04-24
+23. d -4-04-24 to ts: 0004-04-24 00:00:00.0
+23. d -4-04-24 to tm: 00:00:00
+23. d -4-04-24 to dt: 0004-04-24
+24. d -3004-04-24 to ts: 3004-04-24 00:00:00.0
+24. d -3004-04-24 to tm: 00:00:00
+24. d -3004-04-24 to dt: 3004-04-24
+25. vc -2004-04-24 11:43:53.654321 to ts: 2004-04-24 11:43:53.654321
+rs.getTime(colnm) failed with error: parsing failed, found: '-' in: 
"-2004-04-24 11:43:53.654321" at pos: 6
+25. vc -2004-04-24 11:43:53.654321 to dt: 2004-04-24
+26. vc -3004-04-24 to ts: 3004-04-24 00:00:00.0
+rs.getTime(colnm) failed with error: parsing failed, found: '-' in: 
"-3004-04-24" at pos: 6
+26. vc -3004-04-24 to dt: 3004-04-24
 
-# 09:05:23 >  
-# 09:05:23 >  Done.
-# 09:05:23 >  
+# 16:59:26 >  
+# 16:59:26 >  "Done."
+# 16:59:26 >  
 
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
@@ -1199,6 +1199,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;
@@ -1216,9 +1223,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)
@@ -1245,10 +1261,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/server/sql_qc.c b/sql/server/sql_qc.c
--- a/sql/server/sql_qc.c
+++ b/sql/server/sql_qc.c
@@ -238,7 +238,7 @@ qc_match(qc *cache, symbol *s, atom **pa
 }
 
 cq *
-qc_insert(qc *cache, sql_allocator *sa, sql_rel *r, char *qname,  symbol *s, 
atom **params, int paramlen, int key, int type, char *cmd)
+qc_insert(qc *cache, sql_allocator *sa, sql_rel *r, char *qname,  symbol *s, 
atom **params, int paramlen, int key, int type, char *cmd, int no_mitosis)
 {
        int i, namelen;
        cq *n = MNEW(cq);
@@ -275,6 +275,7 @@ qc_insert(qc *cache, sql_allocator *sa, 
        n->count = 1;
        namelen = 5 + ((n->id+7)>>3) + ((cache->clientid+7)>>3);
        n->name = sa_alloc(sa, namelen);
+       n->no_mitosis = no_mitosis;
        if(!n->name) {
                _DELETE(n->params);
                _DELETE(n);
diff --git a/sql/server/sql_qc.h b/sql/server/sql_qc.h
--- a/sql/server/sql_qc.h
+++ b/sql/server/sql_qc.h
@@ -29,6 +29,7 @@ typedef struct cq {
        int key;                /* the hash key for the query text */
        char *codestring;       /* keep code in string form to aid debugging */
        char *name;             /* name of cache query */
+       int no_mitosis;         /* run query without mitosis */
        int count;              /* number of times the query is matched */
 } cq;
 
@@ -44,7 +45,7 @@ extern void qc_destroy(qc *cache);
 extern void qc_clean(qc *cache);
 extern cq *qc_find(qc *cache, int id);
 extern cq *qc_match(qc *cache, symbol *s, atom **params, int plen, int key);
-extern cq *qc_insert(qc *cache, sql_allocator *sa, sql_rel *r, char *qname, 
symbol *s, atom **params, int paramlen, int key, int type, char *codedstr);
+extern cq *qc_insert(qc *cache, sql_allocator *sa, sql_rel *r, char *qname, 
symbol *s, atom **params, int paramlen, int key, int type, char *codedstr, int 
no_mitosis);
 extern void qc_delete(qc *cache, cq *q);
 extern int qc_size(qc *cache);
 extern int qc_isaquerytemplate(char *nme);
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
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to