Changeset: fc40a3d4e730 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fc40a3d4e730
Modified Files:
        clients/Tests/exports.stable.out
        configure.ag
        monetdb5/mal/mal_properties.c
        monetdb5/modules/atoms/mtime.c
        monetdb5/modules/atoms/mtime.h
        monetdb5/modules/mal/batmtime.mal
        monetdb5/modules/mal/batmtime.mal.sh
        sql/rel.txt
        sql/server/rel_optimizer.c
        sql/server/rel_psm.c
        sql/server/rel_select.c
        sql/server/sql_mvc.c
        sql/storage/bat/bat_storage.c
        sql/storage/restrict/restrict_storage.c
        
sql/test/BugDay_2005-12-19_2.9.3/Tests/select_from_env.SF-1240701.1242164.stable.err
        
sql/test/BugDay_2005-12-19_2.9.3/Tests/select_from_env.SF-1240701.1242164.stable.out
        sql/test/BugTracker/Tests/cardinality_violation.SF-1240701.stable.err
Branch: default
Log Message:

Merge with Oct2012 branch.


diffs (truncated from 380 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1731,6 +1731,7 @@ str MTIMEdate_addyears(date *ret, date *
 str MTIMEdate_create(date *ret, int *year, int *month, int *day);
 str MTIMEdate_date(date *d, date *s);
 str MTIMEdate_diff(int *ret, date *v1, date *v2);
+str MTIMEdate_diff_bulk(bat *ret, bat *bid1, bat *bid2);
 str MTIMEdate_extract_day(int *ret, date *v);
 str MTIMEdate_extract_day_bulk(int *ret, int *bid);
 str MTIMEdate_extract_dayofweek(int *ret, date *v);
@@ -1811,6 +1812,7 @@ str MTIMEtimestamp_create_default(timest
 str MTIMEtimestamp_create_from_date(timestamp *ret, date *d);
 str MTIMEtimestamp_day(int *ret, timestamp *t);
 str MTIMEtimestamp_diff(lng *ret, timestamp *v1, timestamp *v2);
+str MTIMEtimestamp_diff_bulk(bat *ret, bat *bid1, bat *bid2);
 str MTIMEtimestamp_extract_date(date *ret, timestamp *t, tzone *z);
 str MTIMEtimestamp_extract_date_default(date *ret, timestamp *t);
 str MTIMEtimestamp_extract_daytime(daytime *ret, timestamp *t, tzone *z);
diff --git a/monetdb5/mal/mal_properties.c b/monetdb5/mal/mal_properties.c
--- a/monetdb5/mal/mal_properties.c
+++ b/monetdb5/mal/mal_properties.c
@@ -303,7 +303,7 @@ PropertyIndex(str name)
                        return i;
        }
        MT_lock_set(&mal_contextLock, "propertyIndex");
-       /* small change its allready added */
+       /* small change its already added */
        for (i=0; i<nr_properties; i++) {
                if (strcmp(properties[i], name) == 0) {
                        MT_lock_unset(&mal_contextLock, "propertyIndex");
diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c
--- a/monetdb5/modules/atoms/mtime.c
+++ b/monetdb5/modules/atoms/mtime.c
@@ -1533,18 +1533,6 @@ MTIMEtimestamp_add(timestamp *ret, times
        return MAL_SUCCEED;
 }
 
-/* returns the number of milliseconds between 'val1' and 'val2'. */
-static str
-timestamp_diff(lng *ret, timestamp *v1, timestamp *v2)
-{
-       if (ts_isnil(*v1) || ts_isnil(*v2)) {
-               *ret = lng_nil;
-       } else {
-               *ret = ((lng) (v1->days - v2->days)) * ((lng) 24 * 60 * 60 * 
1000) + ((lng) (v1->msecs - v2->msecs));
-       }
-       return MAL_SUCCEED;
-}
-
 /* create a DST start/end date rule. */
 static str
 rule_create(rule *ret, int *month, int *day, int *weekday, int *minutes)
@@ -2076,9 +2064,125 @@ MTIMEdate_diff(int *ret, date *v1, date 
 }
 
 str
+MTIMEdate_diff_bulk(bat *ret, bat *bid1, bat *bid2)
+{
+       BAT *b1, *b2, *bn;
+       date *t1, *t2;
+       int *tn;
+       BUN i, n;
+
+       b1 = BATdescriptor(*bid1);
+       b2 = BATdescriptor(*bid2);
+       if (b1 == NULL || b2 == NULL) {
+               if (b1)
+                       BBPreleaseref(b1->batCacheid);
+               if (b2)
+                       BBPreleaseref(b2->batCacheid);
+               throw(MAL, "batmtime.diff", RUNTIME_OBJECT_MISSING);
+       }
+       n = BATcount(b1);
+       if (n != BATcount(b2)) {
+               BBPreleaseref(b1->batCacheid);
+               BBPreleaseref(b2->batCacheid);
+               throw(MAL, "batmtime.diff", "inputs not the same size");
+       }
+       bn = BATnew(TYPE_void, TYPE_int, BATcount(b1));
+       if (bn == NULL) {
+               BBPreleaseref(b1->batCacheid);
+               BBPreleaseref(b2->batCacheid);
+               throw(MAL, "batmtime.diff", MAL_MALLOC_FAIL);
+       }
+       t1 = (date *) Tloc(b1, BUNfirst(b1));
+       t2 = (date *) Tloc(b2, BUNfirst(b2));
+       tn = (int *) Tloc(bn, BUNfirst(bn));
+       for (i = 0; i < n; i++) {
+               if (*t1 == date_nil || *t2 == date_nil) {
+                       *tn = int_nil;
+               } else {
+                       *tn = (int) (*t1 - *t2);
+               }
+               t1++;
+               t2++;
+               tn++;
+       }
+       BBPreleaseref(b2->batCacheid);
+       if (b1->htype != bn->htype) {
+               /* temporarily reuse b2 */
+               b2 = VIEWcreate(b1, bn);
+               BBPunfix(bn->batCacheid);
+               bn = b2;
+       }
+       BBPreleaseref(b1->batCacheid);
+       BBPkeepref(bn->batCacheid);
+       *ret = bn->batCacheid;
+       return MAL_SUCCEED;
+}
+
+/* returns the number of milliseconds between 'val1' and 'val2'. */
+str
 MTIMEtimestamp_diff(lng *ret, timestamp *v1, timestamp *v2)
 {
-       return timestamp_diff(ret, v1, v2);
+       if (ts_isnil(*v1) || ts_isnil(*v2)) {
+               *ret = lng_nil;
+       } else {
+               *ret = ((lng) (v1->days - v2->days)) * ((lng) 24 * 60 * 60 * 
1000) + ((lng) (v1->msecs - v2->msecs));
+       }
+       return MAL_SUCCEED;
+}
+
+str
+MTIMEtimestamp_diff_bulk(bat *ret, bat *bid1, bat *bid2)
+{
+       BAT *b1, *b2, *bn;
+       timestamp *t1, *t2;
+       lng *tn;
+       BUN i, n;
+
+       b1 = BATdescriptor(*bid1);
+       b2 = BATdescriptor(*bid2);
+       if (b1 == NULL || b2 == NULL) {
+               if (b1)
+                       BBPreleaseref(b1->batCacheid);
+               if (b2)
+                       BBPreleaseref(b2->batCacheid);
+               throw(MAL, "batmtime.diff", RUNTIME_OBJECT_MISSING);
+       }
+       n = BATcount(b1);
+       if (n != BATcount(b2)) {
+               BBPreleaseref(b1->batCacheid);
+               BBPreleaseref(b2->batCacheid);
+               throw(MAL, "batmtime.diff", "inputs not the same size");
+       }
+       bn = BATnew(TYPE_void, TYPE_lng, BATcount(b1));
+       if (bn == NULL) {
+               BBPreleaseref(b1->batCacheid);
+               BBPreleaseref(b2->batCacheid);
+               throw(MAL, "batmtime.diff", MAL_MALLOC_FAIL);
+       }
+       t1 = (timestamp *) Tloc(b1, BUNfirst(b1));
+       t2 = (timestamp *) Tloc(b2, BUNfirst(b2));
+       tn = (lng *) Tloc(bn, BUNfirst(bn));
+       for (i = 0; i < n; i++) {
+               if (ts_isnil(*t1) || ts_isnil(*t2)) {
+                       *tn = lng_nil;
+               } else {
+                       *tn = ((lng) (t1->days - t2->days)) * ((lng) 24 * 60 * 
60 * 1000) + ((lng) (t1->msecs - t2->msecs));
+               }
+               t1++;
+               t2++;
+               tn++;
+       }
+       BBPreleaseref(b2->batCacheid);
+       if (b1->htype != bn->htype) {
+               /* temporarily reuse b2 */
+               b2 = VIEWcreate(b1, bn);
+               BBPunfix(bn->batCacheid);
+               bn = b2;
+       }
+       BBPreleaseref(b1->batCacheid);
+       BBPkeepref(bn->batCacheid);
+       *ret = bn->batCacheid;
+       return MAL_SUCCEED;
 }
 
 /* return whether DST holds in the tzone at a certain point of time. */
@@ -2454,7 +2558,7 @@ MTIMEepoch2int(int *ret, timestamp *t)
 
        if ((err = MTIMEunix_epoch(&e)) != MAL_SUCCEED)
                return err;
-       if ((err = timestamp_diff(&v, t, &e)) != MAL_SUCCEED)
+       if ((err = MTIMEtimestamp_diff(&v, t, &e)) != MAL_SUCCEED)
                return err;
        if (v == lng_nil)
                *ret = int_nil;
diff --git a/monetdb5/modules/atoms/mtime.h b/monetdb5/modules/atoms/mtime.h
--- a/monetdb5/modules/atoms/mtime.h
+++ b/monetdb5/modules/atoms/mtime.h
@@ -176,8 +176,10 @@ mtime_export str MTIMEdate_addyears(date
 mtime_export str MTIMEdate_adddays(date *ret, date *v, int *delta);
 mtime_export str MTIMEdate_addmonths(date *ret, date *v, int *delta);
 mtime_export str MTIMEdate_diff(int *ret, date *v1, date *v2);
+mtime_export str MTIMEdate_diff_bulk(bat *ret, bat *bid1, bat *bid2);
 mtime_export str MTIMEtimestamp_add(timestamp *ret, timestamp *v, lng *msecs);
 mtime_export str MTIMEtimestamp_diff(lng *ret, timestamp *v1, timestamp *v2);
+mtime_export str MTIMEtimestamp_diff_bulk(bat *ret, bat *bid1, bat *bid2);
 mtime_export str MTIMEtimestamp_inside_dst(bit *ret, timestamp *p, tzone *z);
 
 mtime_export str MTIMEtimestamp_year(int *ret, timestamp *t);
diff --git a/monetdb5/modules/mal/batmtime.mal 
b/monetdb5/modules/mal/batmtime.mal
--- a/monetdb5/modules/mal/batmtime.mal
+++ b/monetdb5/modules/mal/batmtime.mal
@@ -382,3 +382,13 @@ pattern isnil(b:bat[:oid,:timestamp],s:b
 address CMDbatISNIL
 comment "Unary check for nil over the tail of the bat with candidates list";
 
+module batmtime;
+
+command diff(b1:bat[:oid,:date],b2:bat[:oid,:date]) :bat[:oid,:int]
+address MTIMEdate_diff_bulk
+comment "Difference of two sets of date.";
+
+command diff(b1:bat[:oid,:timestamp],b2:bat[:oid,:timestamp]) :bat[:oid,:lng]
+address MTIMEtimestamp_diff_bulk
+comment "Difference of two sets of timestamp.";
+
diff --git a/monetdb5/modules/mal/batmtime.mal.sh 
b/monetdb5/modules/mal/batmtime.mal.sh
--- a/monetdb5/modules/mal/batmtime.mal.sh
+++ b/monetdb5/modules/mal/batmtime.mal.sh
@@ -78,3 +78,19 @@ comment "Unary check for nil over the ta
 
 EOF
 done
+
+cat <<EOF
+module batmtime;
+
+EOF
+
+for tp in date:int timestamp:lng; do
+    rtp=${tp#*:}
+    tp=${tp%:*}
+    cat <<EOF
+command diff(b1:bat[:oid,:$tp],b2:bat[:oid,:$tp]) :bat[:oid,:$rtp]
+address MTIME${tp}_diff_bulk
+comment "Difference of two sets of $tp.";
+
+EOF
+done
diff --git a/sql/rel.txt b/sql/rel.txt
--- a/sql/rel.txt
+++ b/sql/rel.txt
@@ -72,7 +72,7 @@ INSERT|DELETE|UPDATE  (card MULTI)
                        For update the ->r projection joins in current
                        values for 'none' updated columns.
 
-       -> flag         (if set don't insert (is done allready))
+       -> flag         (if set don't insert (is done already))
 only (UPDATE)
        -> exps         
                        Named columns to update
diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -1324,7 +1324,7 @@ exps_can_push_func(list *exps, sql_rel *
  *  sometimes share (correct or not) expressions on a shared referenced table).
  *
  *  not renaming gives problems with overloaded names (ie on the lower level 
an expression
- *  with the given name could allready exist
+ *  with the given name could already exist
  *
  * 2 
  *  creating projections for subqueries are empty, for now we just don't 
rewrite these.
diff --git a/sql/server/rel_psm.c b/sql/server/rel_psm.c
--- a/sql/server/rel_psm.c
+++ b/sql/server/rel_psm.c
@@ -133,7 +133,7 @@ rel_psm_declare(mvc *sql, dnode *n)
                        /* check if we overwrite a scope local variable declare 
x; declare x; */
                        if (frame_find_var(sql, name)) {
                                return sql_error(sql, 01, 
-                                       "Variable '%s' allready declared", 
name);
+                                       "Variable '%s' already declared", name);
                        }
                        /* variables are put on stack, 
                         * TODO make sure on plan/explain etc they only 
@@ -160,7 +160,7 @@ rel_psm_declare_table(mvc *sql, dnode *n
        if (sname)  /* not allowed here */
                return sql_error(sql, 02, "DECLARE TABLE: qualified name not 
allowed");
        if (frame_find_var(sql, name)) 
-               return sql_error(sql, 01, "Variable '%s' allready declared", 
name);
+               return sql_error(sql, 01, "Variable '%s' already declared", 
name);
        
        assert(n->next->next->next->type == type_int);
        
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
@@ -1230,7 +1230,7 @@ rel_with_query(mvc *sql, symbol *q )
                sql_rel *nrel;
 
                if (frame_find_var(sql, name)) {
-                       return sql_error(sql, 01, "Variable '%s' allready 
declared", name);
+                       return sql_error(sql, 01, "Variable '%s' already 
declared", name);
                }
                nrel = rel_semantic(sql, sym);
                if (!nrel) {  
_______________________________________________
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to