Update of /cvsroot/monetdb/sql/src/server
In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv1260/src/server

Modified Files:
        bin_optimizer.mx rel_bin.mx sql_rel2bin.mx sql_statement.mx 
Log Message:
bat new+append was/is used for single value results of aggr operations
which later are needed as bat results. These are now put together in
a single function (sql.single). This way they should be easily detected
by optimizers.



Index: sql_rel2bin.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_rel2bin.mx,v
retrieving revision 1.145
retrieving revision 1.146
diff -u -d -r1.145 -r1.146
--- sql_rel2bin.mx      31 Jan 2010 12:45:10 -0000      1.145
+++ sql_rel2bin.mx      10 Feb 2010 22:32:42 -0000      1.146
@@ -115,6 +115,7 @@
        case st_basetable:      /* a table is not a column */
        case st_table:          /* a table is not a column */
        case st_temp:
+       case st_single:
        case st_unop:
        case st_binop:
        case st_Nop:
@@ -198,6 +199,7 @@
        case st_basetable:
        case st_table:
        case st_temp:
+       case st_single:
        case st_idxbat:
 
        case st_rs_column:
@@ -1185,6 +1187,7 @@
        case st_uselectN: 
 
        case st_temp:
+       case st_single:
        case st_diff:
        case st_union:
        case st_outerjoin:

Index: bin_optimizer.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/bin_optimizer.mx,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- bin_optimizer.mx    31 Jan 2010 12:44:41 -0000      1.26
+++ bin_optimizer.mx    10 Feb 2010 22:32:31 -0000      1.27
@@ -539,6 +539,7 @@
        }
 
        case st_temp:
+       case st_single:
        case st_diff:
        case st_union:
        case st_outerjoin:

Index: rel_bin.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/rel_bin.mx,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -d -r1.109 -r1.110
--- rel_bin.mx  22 Jan 2010 17:52:11 -0000      1.109
+++ rel_bin.mx  10 Feb 2010 22:32:36 -0000      1.110
@@ -360,7 +360,7 @@
                                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);
+                               as = const_column(as);
                } else {
                        /* count(*) may need the default group (relation) and
                           and/or an attribute to count */
@@ -371,7 +371,7 @@
                        } else {
                                /* create dummy single value in a column */
                                as = stmt_atom_wrd(0);
-                               as = stmt_append(stmt_temp(tail_type(as)), as);
+                               as = const_column(as);
                        }
                }
                if (!as) 
@@ -1617,9 +1617,7 @@
 static stmt *
 rel2bin_predicate(void) 
 {
-       sql_subtype *bt = sql_bind_localtype("bit");
-       stmt *temp = stmt_temp(bt);
-       return stmt_append(temp, stmt_bool(1));
+       return const_column(stmt_bool(1));
 }
 
 static stmt *
@@ -2282,12 +2280,9 @@
                /* add missing nulls (and NULLs only (SIMPLE MATCH)) */
                s = stmt_mark(stmt_reverse(s), 0);
                if (cond) {
-                       stmt *t = stmt_temp(bt);
-                       stmt *isnull = stmt_temp(tail_type(s));
                        stmt *notnull = s;
-
-                       isnull = stmt_append(isnull, 
stmt_atom(atom_general(tail_type(s), NULL, 0)));
-                       t = stmt_append(t, cond);
+                       stmt *isnull = 
const_column(stmt_atom(atom_general(tail_type(s), NULL, 0)));
+                       stmt *t = const_column(cond);
                        isnull = stmt_join(t, 
stmt_reverse(stmt_const(stmt_reverse(isnull), stmt_bool(1))), cmp_equal);
                        notnull = stmt_join(stmt_dup(t), 
stmt_reverse(stmt_const(stmt_reverse(notnull), stmt_bool(0))), cmp_equal);
                        s = stmt_union(isnull, notnull);

Index: sql_statement.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_statement.mx,v
retrieving revision 1.198
retrieving revision 1.199
diff -u -d -r1.198 -r1.199
--- sql_statement.mx    31 Jan 2010 12:45:15 -0000      1.198
+++ sql_statement.mx    10 Feb 2010 22:32:46 -0000      1.199
@@ -55,6 +55,7 @@
        st_basetable,   
        st_table,               /* some functions return a table */
        st_temp,                /* temporal bat */
+       st_single,              /* single value bat */
        st_rs_column,
        st_column,              /* relational column result */
        st_bat,
@@ -349,6 +350,7 @@
                ST(basetable);
                ST(table);
                ST(temp);
+               ST(single);
 
                ST(rs_column);
                ST(column);
@@ -680,6 +682,7 @@
 
                        /* special cases */
                case st_temp:
+               case st_single:
                        if (s->op1.stval)
                                stmt_destroy(s->op1.stval);
 
@@ -927,6 +930,7 @@
                case st_none:
                case st_var:
                case st_temp:
+               case st_single:
                case st_atom:
                case st_trans:
                case st_catalog:
@@ -1097,6 +1101,17 @@
 }
 
 stmt *
+stmt_single(sql_subtype *t)
+{
+       stmt *s = stmt_create(st_single);
+
+       s->op4.typeval = *t;
+       s->nrcols = 1;
+       return s;
+}
+
+
+stmt *
 stmt_column(stmt *op1, stmt *table, sql_table *t)
 {
        stmt *s = stmt_create(st_column);
@@ -2230,6 +2245,7 @@
                return atom_type(st->op1.aval);
        case st_convert:
        case st_temp:
+       case st_single:
        case st_rs_column:
                return &st->op4.typeval;
        case st_var:
@@ -2295,6 +2311,7 @@
                return head_type(st->op1.lval->h->data);
 
        case st_temp:
+       case st_single:
        case st_bat:
        case st_idxbat:
        case st_const:
@@ -2438,6 +2455,7 @@
                        return atom2string(st->op1.aval);
        case st_var:
        case st_temp:
+       case st_single:
                return _strdup("single_value");
 
        case st_relselect:
@@ -2506,6 +2524,7 @@
 
        case st_var:
        case st_temp:
+       case st_single:
        case st_relselect:
        case st_releqjoin:
        case st_reljoin:
@@ -2563,6 +2582,7 @@
                return NULL;
        case st_var:
        case st_temp:
+       case st_single:
                return NULL;
        case st_relselect:
        case st_releqjoin:
@@ -2733,6 +2753,7 @@
                /* large group with only up till 3 operants */ 
                case st_column:
                case st_temp:
+               case st_single:
                case st_aggr:
                case st_unop: case st_binop: case st_Nop:
                case st_diff: case st_union:
@@ -2854,6 +2875,7 @@
        switch(s->type) {
        case st_none:   
        case st_temp:
+       case st_single:
        case st_unique:
                        printf("temp,unique,none\n"); break;
        case st_exception:


------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to