Changeset: bfac9b6fe136 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bfac9b6fe136
Modified Files:
        monetdb5/modules/mal/Tests/inspect05.stable.out
        monetdb5/modules/mal/Tests/inspect05.stable.out.Windows
        sql/backends/monet5/sql.mx
        sql/server/rel_bin.c
        sql/server/rel_exp.c
        sql/server/rel_exp.h
        sql/server/rel_select.c
        sql/server/rel_semantic.c
        sql/test/BugTracker-2011/Tests/All
Branch: Dec2011
Log Message:

Merge with Aug2011 branch.


diffs (truncated from 323 to 300 lines):

diff --git a/monetdb5/modules/mal/Tests/inspect05.stable.out 
b/monetdb5/modules/mal/Tests/inspect05.stable.out
--- a/monetdb5/modules/mal/Tests/inspect05.stable.out
+++ b/monetdb5/modules/mal/Tests/inspect05.stable.out
@@ -4749,23 +4749,23 @@ end main;
 [ "sht",                         "command",      "calc",         "(x:chr):sht 
",                                                                              
                                           "CALCchr2sht;"                       
                   ]
 [ "sht",                         "command",      "calc",         "(x:bit):sht 
",                                                                              
                                           "CALCbit2sht;"                       
                   ]
 [ "sht",                         "command",      "calc",         "(x:oid):sht 
",                                                                              
                                           "CALCoid2sht;"                       
                   ]
-[ "sign",                        "command",      "calc",         "(x:dbl):dbl 
",                                                                              
                                           "CALCunarydblSIGN;"                  
                   ]
+[ "sign",                        "command",      "calc",         "(x:dbl):int 
",                                                                              
                                           "CALCunarydblSIGN;"                  
                   ]
 [ "sizeof",                      "command",      "calc",         "(x:dbl):int 
",                                                                              
                                           "CALCsizeofdbl;"                     
                   ]
-[ "sign",                        "command",      "calc",         "(x:lng):lng 
",                                                                              
                                           "CALCunarylngSIGN;"                  
                   ]
+[ "sign",                        "command",      "calc",         "(x:lng):int 
",                                                                              
                                           "CALCunarylngSIGN;"                  
                   ]
 [ "sizeof",                      "command",      "calc",         "(x:lng):int 
",                                                                              
                                           "CALCsizeoflng;"                     
                   ]
-[ "sign",                        "command",      "calc",         "(x:flt):flt 
",                                                                              
                                           "CALCunaryfltSIGN;"                  
                   ]
+[ "sign",                        "command",      "calc",         "(x:flt):int 
",                                                                              
                                           "CALCunaryfltSIGN;"                  
                   ]
 [ "sizeof",                      "command",      "calc",         "(x:flt):int 
",                                                                              
                                           "CALCsizeofflt;"                     
                   ]
-[ "sign",                        "command",      "calc",         "(x:wrd):wrd 
",                                                                              
                                           "CALCunarywrdSIGN;"                  
                   ]
+[ "sign",                        "command",      "calc",         "(x:wrd):int 
",                                                                              
                                           "CALCunarywrdSIGN;"                  
                   ]
 [ "sizeof",                      "command",      "calc",         "(x:wrd):int 
",                                                                              
                                           "CALCsizeofwrd;"                     
                   ]
 [ "sign",                        "command",      "calc",         "(x:int):int 
",                                                                              
                                           "CALCunaryintSIGN;"                  
                   ]
 [ "sizeof",                      "command",      "calc",         "(x:int):int 
",                                                                              
                                           "CALCsizeofint;"                     
                   ]
-[ "sign",                        "command",      "calc",         "(x:sht):sht 
",                                                                              
                                           "CALCunaryshtSIGN;"                  
                   ]
+[ "sign",                        "command",      "calc",         "(x:sht):int 
",                                                                              
                                           "CALCunaryshtSIGN;"                  
                   ]
 [ "sizeof",                      "command",      "calc",         "(x:sht):int 
",                                                                              
                                           "CALCsizeofsht;"                     
                   ]
-[ "sign",                        "command",      "calc",         "(x:bte):bte 
",                                                                              
                                           "CALCunarybteSIGN;"                  
                   ]
+[ "sign",                        "command",      "calc",         "(x:bte):int 
",                                                                              
                                           "CALCunarybteSIGN;"                  
                   ]
 [ "sizeof",                      "command",      "calc",         "(x:bte):int 
",                                                                              
                                           "CALCsizeofbte;"                     
                   ]
-[ "sign",                        "command",      "calc",         "(x:chr):chr 
",                                                                              
                                           "CALCunarychrSIGN;"                  
                   ]
+[ "sign",                        "command",      "calc",         "(x:chr):int 
",                                                                              
                                           "CALCunarychrSIGN;"                  
                   ]
 [ "sizeof",                      "command",      "calc",         "(x:chr):int 
",                                                                              
                                           "CALCsizeofchr;"                     
                   ]
-[ "sign",                        "command",      "calc",         "(x:bit):bit 
",                                                                              
                                   "CALCunarybitSIGN;"                          
           ]
+[ "sign",                        "command",      "calc",         "(x:bit):int 
",                                                                              
                                   "CALCunarybitSIGN;"                          
           ]
 [ "sizeof",                      "command",      "calc",         "(x:bit):int 
",                                                                              
                                   "CALCsizeofbit;"                             
           ]
 [ "sqladd",                              "command",      "calc",         
"(left:lng,right:dbl):dbl ",                                                    
                                                        
"CALCbinarySQLADDlngdbl;"                               ]
 [ "sqladd",                              "command",      "calc",         
"(left:lng,right:flt):dbl ",                                                    
                                                        
"CALCbinarySQLADDlngflt;"                               ]
diff --git a/monetdb5/modules/mal/Tests/inspect05.stable.out.Windows 
b/monetdb5/modules/mal/Tests/inspect05.stable.out.Windows
--- a/monetdb5/modules/mal/Tests/inspect05.stable.out.Windows
+++ b/monetdb5/modules/mal/Tests/inspect05.stable.out.Windows
@@ -4738,23 +4738,23 @@ end main;
 [ "sht",                         "command",      "calc",         "(x:chr):sht 
",                                                                              
                                           "CALCchr2sht;"                       
                   ]
 [ "sht",                         "command",      "calc",         "(x:bit):sht 
",                                                                              
                                           "CALCbit2sht;"                       
                   ]
 [ "sht",                         "command",      "calc",         "(x:oid):sht 
",                                                                              
                                           "CALCoid2sht;"                       
                   ]
-[ "sign",                        "command",      "calc",         "(x:dbl):dbl 
",                                                                              
                                           "CALCunarydblSIGN;"                  
                   ]
+[ "sign",                        "command",      "calc",         "(x:dbl):int 
",                                                                              
                                           "CALCunarydblSIGN;"                  
                   ]
 [ "sizeof",                      "command",      "calc",         "(x:dbl):int 
",                                                                              
                                           "CALCsizeofdbl;"                     
                   ]
-[ "sign",                        "command",      "calc",         "(x:lng):lng 
",                                                                              
                                           "CALCunarylngSIGN;"                  
                   ]
+[ "sign",                        "command",      "calc",         "(x:lng):int 
",                                                                              
                                           "CALCunarylngSIGN;"                  
                   ]
 [ "sizeof",                      "command",      "calc",         "(x:lng):int 
",                                                                              
                                           "CALCsizeoflng;"                     
                   ]
-[ "sign",                        "command",      "calc",         "(x:flt):flt 
",                                                                              
                                           "CALCunaryfltSIGN;"                  
                   ]
+[ "sign",                        "command",      "calc",         "(x:flt):int 
",                                                                              
                                           "CALCunaryfltSIGN;"                  
                   ]
 [ "sizeof",                      "command",      "calc",         "(x:flt):int 
",                                                                              
                                           "CALCsizeofflt;"                     
                   ]
-[ "sign",                        "command",      "calc",         "(x:wrd):wrd 
",                                                                              
                                           "CALCunarywrdSIGN;"                  
                   ]
+[ "sign",                        "command",      "calc",         "(x:wrd):int 
",                                                                              
                                           "CALCunarywrdSIGN;"                  
                   ]
 [ "sizeof",                      "command",      "calc",         "(x:wrd):int 
",                                                                              
                                           "CALCsizeofwrd;"                     
                   ]
 [ "sign",                        "command",      "calc",         "(x:int):int 
",                                                                              
                                           "CALCunaryintSIGN;"                  
                   ]
 [ "sizeof",                      "command",      "calc",         "(x:int):int 
",                                                                              
                                           "CALCsizeofint;"                     
                   ]
-[ "sign",                        "command",      "calc",         "(x:sht):sht 
",                                                                              
                                           "CALCunaryshtSIGN;"                  
                   ]
+[ "sign",                        "command",      "calc",         "(x:sht):int 
",                                                                              
                                           "CALCunaryshtSIGN;"                  
                   ]
 [ "sizeof",                      "command",      "calc",         "(x:sht):int 
",                                                                              
                                           "CALCsizeofsht;"                     
                   ]
-[ "sign",                        "command",      "calc",         "(x:bte):bte 
",                                                                              
                                           "CALCunarybteSIGN;"                  
                   ]
+[ "sign",                        "command",      "calc",         "(x:bte):int 
",                                                                              
                                           "CALCunarybteSIGN;"                  
                   ]
 [ "sizeof",                      "command",      "calc",         "(x:bte):int 
",                                                                              
                                           "CALCsizeofbte;"                     
                   ]
-[ "sign",                        "command",      "calc",         "(x:chr):chr 
",                                                                              
                                           "CALCunarychrSIGN;"                  
                   ]
+[ "sign",                        "command",      "calc",         "(x:chr):int 
",                                                                              
                                           "CALCunarychrSIGN;"                  
                   ]
 [ "sizeof",                      "command",      "calc",         "(x:chr):int 
",                                                                              
                                           "CALCsizeofchr;"                     
                   ]
-[ "sign",                        "command",      "calc",         "(x:bit):bit 
",                                                                              
                                   "CALCunarybitSIGN;"                          
           ]
+[ "sign",                        "command",      "calc",         "(x:bit):int 
",                                                                              
                                   "CALCunarybitSIGN;"                          
           ]
 [ "sizeof",                      "command",      "calc",         "(x:bit):int 
",                                                                              
                                   "CALCsizeofbit;"                             
           ]
 [ "sqladd",                              "command",      "calc",         
"(left:lng,right:dbl):dbl ",                                                    
                                                        
"CALCbinarySQLADDlngdbl;"                               ]
 [ "sqladd",                              "command",      "calc",         
"(left:lng,right:flt):dbl ",                                                    
                                                        
"CALCbinarySQLADDlngflt;"                               ]
diff --git a/sql/backends/monet5/sql.mx b/sql/backends/monet5/sql.mx
--- a/sql/backends/monet5/sql.mx
+++ b/sql/backends/monet5/sql.mx
@@ -5345,7 +5345,7 @@ str bat@2_dec2_@1( int *res, int *s1, in
                                bn->T->nonil= FALSE;
                        } else {
                                if (scale)
-                                       val = (@2) (( *p + 
((*p<0)?-5:5))/scales[scale]);
+                                       val = (@2) (( *p + (( 
*p<0)?-5:5))/scales[scale]);
                                else
                                        val = (@2) (*p);
                                /* see if the number fits in the data type */
diff --git a/sql/server/rel_bin.c b/sql/server/rel_bin.c
--- a/sql/server/rel_bin.c
+++ b/sql/server/rel_bin.c
@@ -196,25 +196,43 @@ static stmt *
 handle_in_exps( mvc *sql, sql_exp *ce, list *nl, stmt *left, stmt *right, 
group *grp, int in, int use_r) 
 {
        node *n;
-       stmt *s, *c;
-
-       /* create bat append values */
-       s = stmt_temp(sql->sa, exp_subtype(ce));
-       for( n = nl->h; n; n = n->next) {
-               sql_exp *e = n->data;
-               stmt *i = exp_bin(sql, use_r?e->r:e, left, right, grp, NULL);
-               
-               s = stmt_append(sql->sa, s, i);
+       stmt *s = NULL, *c = exp_bin(sql, ce, left, right, grp, NULL);
+
+       if (c->nrcols == 0) {
+               sql_subtype *bt = sql_bind_localtype("bit");
+               sql_subfunc *cmp = (in)
+                       ?sql_bind_func(sql->sa, sql->session->schema, "=", 
tail_type(c), tail_type(c))
+                       :sql_bind_func(sql->sa, sql->session->schema, "!=", 
tail_type(c), tail_type(c));
+               sql_subfunc *a = (in)?sql_bind_func(sql->sa, 
sql->session->schema, "or", bt, bt)
+                                    :sql_bind_func(sql->sa, 
sql->session->schema, "and", bt, bt);
+
+               for( n = nl->h; n; n = n->next) {
+                       sql_exp *e = n->data;
+                       stmt *i = exp_bin(sql, use_r?e->r:e, left, right, grp, 
NULL);
+                       
+                       i = stmt_binop(sql->sa, c, i, cmp); 
+                       if (s)
+                               s = stmt_binop(sql->sa, s, i, a);
+                       else
+                               s = i;
+               }
+       } else {
+               /* create bat append values */
+               s = stmt_temp(sql->sa, exp_subtype(ce));
+               for( n = nl->h; n; n = n->next) {
+                       sql_exp *e = n->data;
+                       stmt *i = exp_bin(sql, use_r?e->r:e, left, right, grp, 
NULL);
+                       
+                       s = stmt_append(sql->sa, s, i);
+               }
+               /*s = stmt_mark_tail(sql->sa, stmt_reverse(sql->sa, 
stmt_semijoin(sql->sa, stmt_reverse(sql->sa, c), stmt_reverse(sql->sa, s))), 
0);*/
+               /* not really a projection join, therefore make sure left 
values are unique !! */
+               if (in)
+                       s = stmt_project(sql->sa, c, stmt_reverse(sql->sa, 
stmt_unique(sql->sa, s, NULL)));
+               else 
+                       s = stmt_reverse(sql->sa, stmt_diff(sql->sa, 
stmt_reverse(sql->sa, c), stmt_reverse(sql->sa, stmt_unique(sql->sa, s, 
NULL))));
+               s = stmt_const(sql->sa, s, NULL);
        }
-       c = exp_bin(sql, ce, left, right, grp, NULL);
-       /*s = stmt_mark_tail(sql->sa, stmt_reverse(sql->sa, 
stmt_semijoin(sql->sa, stmt_reverse(sql->sa, c), stmt_reverse(sql->sa, s))), 
0);*/
-       /* not really a projection join, therefore make sure left values are 
unique !! */
-       c = column(sql->sa, c);
-       if (in)
-               s = stmt_project(sql->sa, c, stmt_reverse(sql->sa, 
stmt_unique(sql->sa, s, NULL)));
-       else 
-               s = stmt_reverse(sql->sa, stmt_diff(sql->sa, 
stmt_reverse(sql->sa, c), stmt_reverse(sql->sa, stmt_unique(sql->sa, s, 
NULL))));
-       s = stmt_const(sql->sa, s, NULL);
        return s;
 }
 
diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -340,6 +340,13 @@ exp_setname(sql_allocator *sa, sql_exp *
        e->rname = (rname)?sa_strdup(sa, rname):NULL;
 }
 
+void 
+noninternexp_setname(sql_allocator *sa, sql_exp *e, char *rname, char *name )
+{
+       if (!is_intern(e))
+               exp_setname(sa, e, rname, name);
+}
+
 str
 number2name(str s, int len, int i)
 {
diff --git a/sql/server/rel_exp.h b/sql/server/rel_exp.h
--- a/sql/server/rel_exp.h
+++ b/sql/server/rel_exp.h
@@ -64,6 +64,7 @@ extern sql_exp * exp_values(sql_allocato
 extern sql_exp * exp_column(sql_allocator *sa, char *rname, char *name, 
sql_subtype *t, int card, int has_nils, int intern);
 extern sql_exp * exp_alias(sql_allocator *sa, char *arname, char *acname, char 
*org_rname, char *org_cname, sql_subtype *t, int card, int has_nils, int 
intern);
 extern void exp_setname(sql_allocator *sa, sql_exp *e, char *rname, char *name 
);
+extern void noninternexp_setname(sql_allocator *sa, sql_exp *e, char *rname, 
char *name );
 extern sql_exp* exp_label(sql_allocator *sa, sql_exp *e, int nr);
 
 extern void exp_swap( sql_exp *e );
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -1159,8 +1159,8 @@ rel_table_optname(mvc *sql, sql_rel *sq,
                if (!columnrefs && sq->exps) {
                        node *ne = sq->exps->h;
 
-                       for (; ne; ne = ne->next)
-                               exp_setname(sql->sa, ne->data, tname, NULL );
+                       for (; ne; ne = ne->next) 
+                               noninternexp_setname(sql->sa, ne->data, tname, 
NULL );
                }
        }
        rel_add_intern(sql, sq);
@@ -1590,7 +1590,7 @@ table_ref(mvc *sql, sql_rel *rel, symbol
                        temp_table = rel_project(sql->sa, temp_table, exps);
                        set_processed(temp_table);
                        for (n = exps->h; n; n = n->next)
-                               exp_setname(sql->sa, n->data, tname, NULL);
+                               noninternexp_setname(sql->sa, n->data, tname, 
NULL);
                        return temp_table;
                } else if (isView(t) /*&& sql->emode != m_instantiate */) {
                        /* instantiate base view */
@@ -1611,7 +1611,7 @@ table_ref(mvc *sql, sql_rel *rel, symbol
                                for (n = t->columns.set->h, m = rel->exps->h; n 
&& m; n = n->next, m = m->next) {
                                        sql_column *c = n->data;
                                        sql_exp *e = m->data;
-       
+
                                        exp_setname(sql->sa, e, tname, 
c->base.name);
                                }
                        }
diff --git a/sql/server/rel_semantic.c b/sql/server/rel_semantic.c
--- a/sql/server/rel_semantic.c
+++ b/sql/server/rel_semantic.c
@@ -250,7 +250,7 @@ rel_semantic(mvc *sql, symbol *s)
                                node *ne = nrel->exps->h;
        
                                for (; ne; ne = ne->next) 
-                                       exp_setname(sql->sa, ne->data, name, 
NULL );
+                                       noninternexp_setname(sql->sa, ne->data, 
name, NULL );
                        }
                }
                rel = rel_semantic(sql, select);
diff --git a/sql/test/BugTracker-2011/Tests/All 
b/sql/test/BugTracker-2011/Tests/All
--- a/sql/test/BugTracker-2011/Tests/All
+++ b/sql/test/BugTracker-2011/Tests/All
@@ -56,3 +56,4 @@ history.Bug-2909
 interrupted-initialization.Bug-2875
 case-overflow.Bug-2239
 sqltables.Bug-2921
+Multiplication_and_cast.Bug-2923
diff --git 
a/sql/test/BugTracker-2011/Tests/Multiplication_and_cast.Bug-2923.sql 
b/sql/test/BugTracker-2011/Tests/Multiplication_and_cast.Bug-2923.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2011/Tests/Multiplication_and_cast.Bug-2923.sql
@@ -0,0 +1,4 @@
+create table test234(t decimal(3,2));
+insert into test234 (t) values (-1.21);
+select cast((t * 100) as integer) from test234;
+drop table test234;
diff --git 
a/sql/test/BugTracker-2011/Tests/Multiplication_and_cast.Bug-2923.stable.err 
b/sql/test/BugTracker-2011/Tests/Multiplication_and_cast.Bug-2923.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2011/Tests/Multiplication_and_cast.Bug-2923.stable.err
@@ -0,0 +1,37 @@
+stderr of test 'Multiplication_and_cast.Bug-2923` in directory 
'test/BugTracker-2011` itself:
+
+
+# 11:01:58 >  
+# 11:01:58 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"gdk_dbfarm=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB" "--set" 
"mapi_open=true" "--set" "mapi_port=31057" "--set" "monet_prompt=" "--trace" 
"--forcemito" "--set" "mal_listing=2" "--dbname=mTests_test_BugTracker-2011" 
"--set" "mal_listing=0"
+# 11:01:58 >  
+
+# builtin opt  gdk_dbname = demo
+# builtin opt  gdk_dbfarm = 
/home/niels/scratch/rc-clean/Linux-x86_64/var/monetdb5/dbfarm
+# builtin opt  gdk_debug = 0
+# builtin opt  gdk_alloc_map = no
+# builtin opt  gdk_vmtrim = yes
+# 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  gdk_dbfarm = 
/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB
+# cmdline opt  mapi_open = true
+# cmdline opt  mapi_port = 31057
+# cmdline opt  monet_prompt = 
+# cmdline opt  mal_listing = 2
+# cmdline opt  gdk_dbname = mTests_test_BugTracker-2011
+# cmdline opt  mal_listing = 0
+
+# 11:01:58 >  
+# 11:01:58 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" "--host=niels" 
"--port=31057"
+# 11:01:58 >  
+
+
+# 11:01:58 >  
+# 11:01:58 >  "Done."
+# 11:01:58 >  
+
diff --git 
a/sql/test/BugTracker-2011/Tests/Multiplication_and_cast.Bug-2923.stable.out 
b/sql/test/BugTracker-2011/Tests/Multiplication_and_cast.Bug-2923.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2011/Tests/Multiplication_and_cast.Bug-2923.stable.out
@@ -0,0 +1,40 @@
+stdout of test 'Multiplication_and_cast.Bug-2923` in directory 
'test/BugTracker-2011` itself:
+
+
+# 11:01:58 >  
+# 11:01:58 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"gdk_dbfarm=/home/niels/scratch/rc-clean/Linux-x86_64/var/MonetDB" "--set" 
"mapi_open=true" "--set" "mapi_port=31057" "--set" "monet_prompt=" "--trace" 
"--forcemito" "--set" "mal_listing=2" "--dbname=mTests_test_BugTracker-2011" 
"--set" "mal_listing=0"
+# 11:01:58 >  
+
+# MonetDB 5 server v11.5.4
+# This is an unreleased version
+# Serving database 'mTests_test_BugTracker-2011', using 4 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs dynamically 
linked
+# Found 3.788 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2011 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on 
mapi:monetdb://niels.nesco.mine.nu:31057/
+# MonetDB/GIS module loaded
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to