vendor: upgrade github.com/VictoriaMetrics/metricsql from v0.7.2 to v0.7.3

This fixes parsing of hex numbers in MetricsQL such as 0x3b

The bug has been detected at https://promlabs.com/promql-compliance-test-results/2020-12-01/victoriametrics/
This commit is contained in:
Aliaksandr Valialkin 2020-12-02 08:08:59 +02:00
parent b1fd390e16
commit 7590b8477b
5 changed files with 30 additions and 14 deletions

View file

@ -6,6 +6,7 @@
unlike in Prometheus exposition format. See [the docs](https://github.com/OpenObservability/OpenMetrics/blob/master/specification/OpenMetrics.md#timestamps).
* BUGFIX: return `nan` for `a >bool b` query when `a` equals to `nan` like Prometheus does. Previously `0` was returned in this case. This applies to any comparison operation
with `bool` modifier. See [these docs](https://prometheus.io/docs/prometheus/latest/querying/operators/#comparison-binary-operators) for details.
* BUGFIX: properly parse hex numbers in MetricsQL. Previously hex numbers with non-decimal digits such as `0x3b` couldn't be parsed.
# [v1.48.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.48.0)

2
go.mod
View file

@ -9,7 +9,7 @@ require (
// like https://github.com/valyala/fasthttp/commit/996610f021ff45fdc98c2ce7884d5fa4e7f9199b
github.com/VictoriaMetrics/fasthttp v1.0.9
github.com/VictoriaMetrics/metrics v1.12.3
github.com/VictoriaMetrics/metricsql v0.7.2
github.com/VictoriaMetrics/metricsql v0.7.3
github.com/aws/aws-sdk-go v1.35.31
github.com/cespare/xxhash/v2 v2.1.1
github.com/golang/snappy v0.0.2

4
go.sum
View file

@ -45,8 +45,8 @@ github.com/VictoriaMetrics/fasthttp v1.0.9/go.mod h1:3SeUL4zwB/p/a9aEeRc6gdlbrtN
github.com/VictoriaMetrics/metrics v1.12.2/go.mod h1:Z1tSfPfngDn12bTfZSCqArT3OPY3u88J12hSoOhuiRE=
github.com/VictoriaMetrics/metrics v1.12.3 h1:Fe6JHC6MSEKa+BtLhPN8WIvS+HKPzMc2evEpNeCGy7I=
github.com/VictoriaMetrics/metrics v1.12.3/go.mod h1:Z1tSfPfngDn12bTfZSCqArT3OPY3u88J12hSoOhuiRE=
github.com/VictoriaMetrics/metricsql v0.7.2 h1:ZdFPiA9Etrf3dow43IcPvLjPi5BYWIYj194wPKIhKfs=
github.com/VictoriaMetrics/metricsql v0.7.2/go.mod h1:ylO7YITho/Iw6P71oEaGyHbO94bGoGtzWfLGqFhMIg8=
github.com/VictoriaMetrics/metricsql v0.7.3 h1:ReI+UBleCkGMmYDt69gsuGld71l1WpQDIlhgU1N5xQ8=
github.com/VictoriaMetrics/metricsql v0.7.3/go.mod h1:ylO7YITho/Iw6P71oEaGyHbO94bGoGtzWfLGqFhMIg8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=

View file

@ -149,8 +149,14 @@ func scanString(s string) (string, error) {
func scanPositiveNumber(s string) (string, error) {
// Scan integer part. It may be empty if fractional part exists.
i := 0
if n := scanSpecialIntegerPrefix(s); n > 0 {
i += n
skipChars, isHex := scanSpecialIntegerPrefix(s)
i += skipChars
if isHex {
// Scan integer hex number
for i < len(s) && isHexChar(s[i]) {
i++
}
return s[:i], nil
}
for i < len(s) && isDecimalChar(s[i]) {
i++
@ -370,26 +376,31 @@ func isPositiveNumberPrefix(s string) bool {
}
func isSpecialIntegerPrefix(s string) bool {
return scanSpecialIntegerPrefix(s) > 0
skipChars, _ := scanSpecialIntegerPrefix(s)
return skipChars > 0
}
func scanSpecialIntegerPrefix(s string) int {
func scanSpecialIntegerPrefix(s string) (skipChars int, isHex bool) {
if len(s) < 1 || s[0] != '0' {
return 0
return 0, false
}
s = strings.ToLower(s[1:])
if len(s) == 0 {
return 0
return 0, false
}
if isDecimalChar(s[0]) {
// octal number: 0123
return 1
return 1, false
}
if s[0] == 'x' || s[0] == 'o' || s[0] == 'b' {
if s[0] == 'x' {
// 0x
return 2, true
}
if s[0] == 'o' || s[0] == 'b' {
// 0x, 0o or 0b prefix
return 2
return 2, false
}
return 0
return 0, false
}
func isPositiveDuration(s string) bool {
@ -536,6 +547,10 @@ func isDecimalChar(ch byte) bool {
return ch >= '0' && ch <= '9'
}
func isHexChar(ch byte) bool {
return isDecimalChar(ch) || ch >= 'a' && ch <= 'f' || ch >= 'A' && ch <= 'F'
}
func isIdentPrefix(s string) bool {
if len(s) == 0 {
return false

2
vendor/modules.txt vendored
View file

@ -16,7 +16,7 @@ github.com/VictoriaMetrics/fasthttp/fasthttputil
github.com/VictoriaMetrics/fasthttp/stackless
# github.com/VictoriaMetrics/metrics v1.12.3
github.com/VictoriaMetrics/metrics
# github.com/VictoriaMetrics/metricsql v0.7.2
# github.com/VictoriaMetrics/metricsql v0.7.3
github.com/VictoriaMetrics/metricsql
github.com/VictoriaMetrics/metricsql/binaryop
# github.com/aws/aws-sdk-go v1.35.31