Changeset: f1d434bdbba6 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f1d434bdbba6
Modified Files:
monetdb5/modules/atoms/mtime.c
monetdb5/modules/atoms/mtime.mal
sql/test/BugTracker-2016/Tests/epoch.Bug-3979.sql
sql/test/BugTracker-2016/Tests/epoch.Bug-3979.stable.out
Branch: Jul2015
Log Message:
reverting the fix for 3979, we expect msec as input to the epoch(lng) function.
We cannot change this behaviour in a SP release.
diffs (72 lines):
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
@@ -2651,7 +2651,7 @@ MTIMEepoch2int(int *ret, const timestamp
}
str
-MTIMEtimestamplng(timestamp *ret, const lng *sec)
+MTIMEtimestamp(timestamp *ret, const int *sec)
{
timestamp t;
lng l;
@@ -2668,10 +2668,20 @@ MTIMEtimestamplng(timestamp *ret, const
}
str
-MTIMEtimestamp(timestamp *ret, const int *sec)
+MTIMEtimestamplng(timestamp *ret, const lng *sec)
{
- const lng s = *sec;
- return MTIMEtimestamplng(ret, &s);
+ timestamp t;
+ lng l;
+ str e;
+
+ if (*sec == lng_nil) {
+ *ret = *timestamp_nil;
+ return MAL_SUCCEED;
+ }
+ if ((e = MTIMEunix_epoch(&t)) != MAL_SUCCEED)
+ return e;
+ l = ((lng) *sec);
+ return MTIMEtimestamp_add(ret, &t, &l);
}
str
diff --git a/monetdb5/modules/atoms/mtime.mal b/monetdb5/modules/atoms/mtime.mal
--- a/monetdb5/modules/atoms/mtime.mal
+++ b/monetdb5/modules/atoms/mtime.mal
@@ -202,7 +202,7 @@ address MTIMEtimestamp
comment "convert seconds since epoch into a timestamp";
command epoch(t:lng):timestamp
address MTIMEtimestamplng
-comment "convert seconds since epoch into a timestamp";
+comment "convert milli seconds since epoch into a timestamp";
pattern ==(v:timestamp,w:timestamp):bit
diff --git a/sql/test/BugTracker-2016/Tests/epoch.Bug-3979.sql
b/sql/test/BugTracker-2016/Tests/epoch.Bug-3979.sql
--- a/sql/test/BugTracker-2016/Tests/epoch.Bug-3979.sql
+++ b/sql/test/BugTracker-2016/Tests/epoch.Bug-3979.sql
@@ -1,2 +1,3 @@
-SELECT epoch(1460453860-300);
+SELECT epoch((1460453860-300) * 1000);
SELECT epoch(CAST(1460453860-300 AS INTEGER));
+SELECT epoch(CAST(1460453860-300 AS INTERVAL SECOND));
diff --git a/sql/test/BugTracker-2016/Tests/epoch.Bug-3979.stable.out
b/sql/test/BugTracker-2016/Tests/epoch.Bug-3979.stable.out
--- a/sql/test/BugTracker-2016/Tests/epoch.Bug-3979.stable.out
+++ b/sql/test/BugTracker-2016/Tests/epoch.Bug-3979.stable.out
@@ -41,6 +41,12 @@ Ready.
% timestamp # type
% 26 # length
[ 2016-04-12 09:32:40.000000 ]
+#SELECT epoch(CAST(1460453860-300 AS INTERVAL SECOND));
+% .L1 # table_name
+% sql_sub_single_value # name
+% timestamp # type
+% 26 # length
+[ 2016-04-12 09:32:40.000000 ]
# 13:17:29 >
# 13:17:29 > "Done."
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list