Skip to content

Commit

Permalink
fix: do not panic when empty tags are queried (#24784) (#24787)
Browse files Browse the repository at this point in the history
Do not panic if a cursor array is nil and the number
of timestamps is retrieved.

closes #24536

(cherry picked from commit bc80e88)
  • Loading branch information
davidby-influx committed Mar 19, 2024
1 parent b2d348c commit e4fba98
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
36 changes: 30 additions & 6 deletions tsdb/cursors/arrayvalues.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion tsdb/cursors/arrayvalues.gen.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e4fba98

Please sign in to comment.