fix: do not panic when empty tags are queried (#24784)

Do not panic if a cursor array is nil and the number
of timestamps is retrieved.

closes https://github.com/influxdata/influxdb/issues/24536
pull/24818/head
davidby-influx 2024-03-18 15:28:29 -07:00 committed by GitHub
parent 393178892e
commit bc80e881fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 7 deletions

View File

@ -27,7 +27,11 @@ func (a *FloatArray) MaxTime() int64 {
}
func (a *FloatArray) Len() int {
return len(a.Timestamps)
if a != nil {
return len(a.Timestamps)
} else {
return 0
}
}
// search performs a binary search for UnixNano() v in a
@ -224,7 +228,11 @@ func (a *IntegerArray) MaxTime() int64 {
}
func (a *IntegerArray) Len() int {
return len(a.Timestamps)
if a != nil {
return len(a.Timestamps)
} else {
return 0
}
}
// search performs a binary search for UnixNano() v in a
@ -421,7 +429,11 @@ func (a *UnsignedArray) MaxTime() int64 {
}
func (a *UnsignedArray) Len() int {
return len(a.Timestamps)
if a != nil {
return len(a.Timestamps)
} else {
return 0
}
}
// search performs a binary search for UnixNano() v in a
@ -618,7 +630,11 @@ func (a *StringArray) MaxTime() int64 {
}
func (a *StringArray) Len() int {
return len(a.Timestamps)
if a != nil {
return len(a.Timestamps)
} else {
return 0
}
}
// search performs a binary search for UnixNano() v in a
@ -815,7 +831,11 @@ func (a *BooleanArray) MaxTime() int64 {
}
func (a *BooleanArray) Len() int {
return len(a.Timestamps)
if a != nil {
return len(a.Timestamps)
} else {
return 0
}
}
// search performs a binary search for UnixNano() v in a
@ -1010,7 +1030,11 @@ func (a *TimestampArray) MaxTime() int64 {
}
func (a *TimestampArray) Len() int {
return len(a.Timestamps)
if a != nil {
return len(a.Timestamps)
} else {
return 0
}
}
// search performs a binary search for UnixNano() v in a

View File

@ -29,7 +29,11 @@ func (a *{{ $typename }}) MaxTime() int64 {
}
func (a *{{ $typename}}) Len() int {
return len(a.Timestamps)
if a != nil {
return len(a.Timestamps)
} else {
return 0
}
}
// search performs a binary search for UnixNano() v in a