From 59ee00ba0da2e0a1143563f117daea7b0d51fa7a Mon Sep 17 00:00:00 2001 From: Daniel Morsing Date: Tue, 18 Aug 2015 14:17:18 -0700 Subject: [PATCH 1/2] interpret number literals compared against time as nanoseconds from epoch fixes #3719 --- influxql/ast.go | 2 ++ influxql/ast_test.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/influxql/ast.go b/influxql/ast.go index 04bb66bbb06..6235e405a0a 100644 --- a/influxql/ast.go +++ b/influxql/ast.go @@ -2469,6 +2469,8 @@ func timeExprValue(ref Expr, lit Expr) time.Time { return lit.Val case *DurationLiteral: return time.Unix(0, int64(lit.Val)).UTC() + case *NumberLiteral: + return time.Unix(0, int64(lit.Val)).UTC() } } return time.Time{} diff --git a/influxql/ast_test.go b/influxql/ast_test.go index 468b7b1f338..b58e7353b6f 100644 --- a/influxql/ast_test.go +++ b/influxql/ast_test.go @@ -483,6 +483,9 @@ func TestTimeRange(t *testing.T) { {expr: `'2000-01-01 00:00:00' < time`, min: `2000-01-01T00:00:00.000000001Z`, max: `0001-01-01T00:00:00Z`}, {expr: `'2000-01-01 00:00:00' <= time`, min: `2000-01-01T00:00:00Z`, max: `0001-01-01T00:00:00Z`}, + // number literal + {expr: `time < 10`, min: `0001-01-01T00:00:00Z`, max: `1970-01-01T00:00:00.000000009Z`}, + // Equality {expr: `time = '2000-01-01 00:00:00'`, min: `2000-01-01T00:00:00Z`, max: `2000-01-01T00:00:00Z`}, From 8fb548b9cca5412c0d8127316e8b74ddae664513 Mon Sep 17 00:00:00 2001 From: Daniel Morsing Date: Tue, 18 Aug 2015 14:29:27 -0700 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2de2f62541e..661467c4287 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ There are breaking changes in this release. Please see the *Features* section be - [#3635](https://github.com/influxdb/influxdb/pull/3635): Add build branch to version output. - [#3115](https://github.com/influxdb/influxdb/pull/3115): Various init.d script improvements. Thanks @KoeSystems. - [#3628](https://github.com/influxdb/influxdb/pull/3628): Wildcard expansion of tags and fields for raw queries +- [#3721](https://github.com/influxdb/influxdb/pull/3721): interpret number literals compared against time as nanoseconds from epoch ### Bugfixes - [#3405](https://github.com/influxdb/influxdb/pull/3405): Prevent database panic when fields are missing. Thanks @jhorwit2