Update of /cvsroot/monetdb/sql/src/server
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv25651/src/server

Modified Files:
        rel_bin.mx sql_parser.mx sql_select.mx 
Log Message:
propagated changes of Friday Jun 13 2008 - Monday Jun 16 2008
from the SQL_2-24 branch to the development trunk

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2008/06/13 - nielsnes: src/test/bugs/Tests/All,1.112.2.5
        src/test/bugs/Tests/aggr_single_value.sql,1.1.2.1
        src/test/bugs/Tests/aggr_single_value.stable.err,1.1.2.1
        src/test/bugs/Tests/aggr_single_value.stable.out,1.1.2.1
add test for  bug in handling aggregates on single values
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2008/06/13 - nielsnes: src/server/rel_bin.mx,1.42.2.2
        src/server/sql_parser.mx,1.283.2.1 src/server/sql_select.mx,1.231.2.6
fix bug in handling aggregates over single values
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2008/06/14 - romulog:
        
src/test/BugTracker/Tests/nested_views_algebra_version.SF-1993765.sql,1.1.2.1
Add test for the open bug...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2008/06/14 - romulog: src/test/BugTracker/Tests/All,1.93.2.11
Activate it for testing...
nested_views_algebra_version.SF-1993765
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2008/06/16 - nielsnes:
        
src/test/BugTracker/Tests/nested_views_algebra_version.SF-1993765.stable.err,1.1.2.1
        
src/test/BugTracker/Tests/nested_views_algebra_version.SF-1993765.stable.out,1.1.2.1
adding stable output
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Index: rel_bin.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/rel_bin.mx,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- rel_bin.mx  30 May 2008 09:31:27 -0000      1.43
+++ rel_bin.mx  16 Jun 2008 09:23:25 -0000      1.44
@@ -241,13 +241,21 @@
                        as = exp_bin(sql, attr->h->data, left, right, NULL, 
sel);
                        if (list_length(attr) == 2)
                                as2 = exp_bin(sql, attr->h->next->data, left, 
right, NULL, sel);
+                       /* insert single value into a column */
+                       if (as && as->nrcols <= 0 && !left)
+                               as = stmt_append(stmt_temp(tail_type(as)), as);
                } else {
                        /* count(*) may need the default group (relation) and
                           and/or an attribute to count */
-                       if (g)
+                       if (g) {
                                as = stmt_dup(grp->grp);
-                       else
+                       } else if (left) {
                                as = bin_first_column(left);
+                       } else {
+                               /* create dummy single value in a column */
+                               as = stmt_atom_int(0);
+                               as = stmt_append(stmt_temp(tail_type(as)), as);
+                       }
                }
                if (!as) 
                        return NULL;    
@@ -1262,11 +1270,12 @@
        group *groupby = NULL;
 
 
-       if (rel->l) /* first construct the sub relation */
+       if (rel->l) { /* first construct the sub relation */
                sub = subrel_bin(sql, rel->l);
-       if (!sub) { 
-               assert(0);
-               return NULL;    
+               if (!sub) { 
+                       assert(0);
+                       return NULL;    
+               }
        }
 
        /* groupby columns */
@@ -1312,7 +1321,7 @@
                aggrstmt = stmt_rename(rel, aggrexp, aggrstmt);
                list_append(l, aggrstmt);
        }
-       stmt_destroy(sub);
+       if (sub) stmt_destroy(sub);
        if (groupby) grp_destroy(groupby);
        return cursub;
 }

Index: sql_parser.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_parser.mx,v
retrieving revision 1.283
retrieving revision 1.284
diff -u -d -r1.283 -r1.284
--- sql_parser.mx       22 May 2008 12:57:41 -0000      1.283
+++ sql_parser.mx       16 Jun 2008 09:23:25 -0000      1.284
@@ -3536,19 +3536,19 @@
                  append_int(l, TRUE);
                  append_symbol(l, _symbol_create_list(SQL_COLUMN, $4));
                  $$ = _symbol_create_list( SQL_AGGR, l ); }
- |  AGGR '(' DISTINCT scalar_exp ')'
+ |  AGGR '(' DISTINCT case_scalar_exp ')'
                { dlist *l = L();
                  append_string(l, $1);
                  append_int(l, FALSE);
                  append_symbol(l, $4);
                  $$ = _symbol_create_list( SQL_AGGR, l ); }
- |  AGGR '(' ALL scalar_exp ')'
+ |  AGGR '(' ALL case_scalar_exp ')'
                { dlist *l = L();
                  append_string(l, $1);
                  append_int(l, FALSE);
                  append_symbol(l, $4);
                  $$ = _symbol_create_list( SQL_AGGR, l ); }
- |  AGGR '(' scalar_exp ')'
+ |  AGGR '(' case_scalar_exp ')'
                { dlist *l = L();
                  append_string(l, $1);
                  append_int(l, FALSE);

Index: sql_select.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_select.mx,v
retrieving revision 1.234
retrieving revision 1.235
diff -u -d -r1.234 -r1.235
--- sql_select.mx       5 Jun 2008 09:23:24 -0000       1.234
+++ sql_select.mx       16 Jun 2008 09:23:26 -0000      1.235
@@ -1204,8 +1204,11 @@
                /* the values which are aggregated together, no grp should
                 * be given there to optain the values */
                s = sql_value_exp(sql, scp, l->h->next->next->data.sym, /*grp 
*/ NULL, subset, f, ek);
-               if (s && s->nrcols <= 0 && subset) /* single value */
+               if (s && s->nrcols <= 0 && subset) { /* single value */
                        s = stmt_const(first_subset(subset), s);
+               } else if (s && s->nrcols <=0) { /* single value */
+                       s = stmt_append(stmt_temp(tail_type(s)), s);
+               }
        }
 
        if (s && distinct) {


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to