Changeset: 54ffd3c27b39 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/54ffd3c27b39
Modified Files:
        sql/server/rel_optimize_proj.c
        sql/server/sql_atom.c
        sql/server/sql_atom.h
Branch: const_aggr_elim
Log Message:

New version cleanup atom one func added


diffs (92 lines):

diff --git a/sql/server/rel_optimize_proj.c b/sql/server/rel_optimize_proj.c
--- a/sql/server/rel_optimize_proj.c
+++ b/sql/server/rel_optimize_proj.c
@@ -2539,34 +2539,19 @@ rel_remove_const_aggr(visitor *v, sql_re
                                        sql_exp *w = m->data;
 
                                        if(w->type == e_atom && w->card == 
CARD_ATOM) {
-                                               if(sum && 
!(((atom*)w->l)->isnull || atom_is_zero((atom*)w->l))) {
-                                                       continue;
-                                               }
-
-                                               if(prd && 
!(((atom*)w->l)->isnull || ((atom*)w->l)->data.val.lval == 1)) {
+                                               atom *wa = w->l;
+
+                                               if(sum && !(wa->isnull || 
atom_is_zero(wa))) {
                                                        continue;
                                                }
-                                       
-                                               /*if(cnt && 
((atom*)w->l)->isnull) { // && 0
-                                                       list_remove_node(se, 
NULL, m);
-                                                       sql_exp 
*rr=exp_atom_lng(v->sql->sa, 0);
-                                                       list_append(se, rr);
-                                                       
-
-                                                       
exp_setalias(rr,e->alias.label,e->alias.rname,e->alias.name);
-                                                       n->data = rr;
-
-                                                       v->changes++;
-
+
+                                               if(prd && !(wa->isnull || 
atom_is_one(wa))) {
                                                        continue;
                                                }
-                                               else if(cnt) {
-                                                       continue;
-                                               }*/
 
                                                /* Handle: select 
count(distinct NULL) + 3 == 3 */
                                                if(cnt) {
-                                                       
if(((atom*)w->l)->isnull) {
+                                                       if(wa->isnull) {
                                                                
list_remove_node(se, NULL, m);
 
                                                                
w=exp_atom_lng(v->sql->sa, 0);
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
@@ -1080,6 +1080,33 @@ atom_is_zero(atom *a)
 }
 
 int
+atom_is_one(atom *a)
+{
+       if (a->isnull || !ATOMlinear(a->tpe.type->localtype))
+               return 0;
+       switch (ATOMstorage(a->tpe.type->localtype)) {
+       case TYPE_bte:
+               return a->data.val.btval == 1;
+       case TYPE_sht:
+               return a->data.val.shval == 1;
+       case TYPE_int:
+               return a->data.val.ival == 1;
+       case TYPE_lng:
+               return a->data.val.lval == 1;
+#ifdef HAVE_HGE
+       case TYPE_hge:
+               return a->data.val.hval == 1;
+#endif
+       case TYPE_flt:
+               return a->data.val.fval == 1;
+       case TYPE_dbl:
+               return a->data.val.dval == 1;
+       default:
+               return 0;
+       }
+}
+
+int
 atom_is_true(atom *a)
 {
        if (a->isnull)
diff --git a/sql/server/sql_atom.h b/sql/server/sql_atom.h
--- a/sql/server/sql_atom.h
+++ b/sql/server/sql_atom.h
@@ -65,6 +65,7 @@ extern atom *atom_inc(allocator *sa, ato
 extern int atom_is_true(atom *a);
 extern int atom_is_false(atom *a);
 extern int atom_is_zero(atom *a);
+extern int atom_is_one(atom *a);
 
 extern unsigned int atom_digits(atom *a);
 
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to