diff --git a/internal/api/handler.go b/internal/api/handler.go index d74ce96de..49a42485f 100644 --- a/internal/api/handler.go +++ b/internal/api/handler.go @@ -2847,14 +2847,13 @@ func (c *pointsSelectCols) rowAt(i int) tsSelectRow { row.val[j] = c.val[j][i] } for j := range c.tag { - var hasSTag bool - if len(c.stag) != 0 { - hasSTag = c.stag[j].Pos[i].Start < c.stag[j].Pos[i].End && c.stag[j].Pos[i].End <= len(c.stag[j].Buf) - } - if hasSTag { - row.stag[c.tagIx[j]] = string(c.stag[j].Buf[c.stag[j].Pos[i].Start:c.stag[j].Pos[i].End]) - } else { + if c.tag[j][i] != 0 { row.tag[c.tagIx[j]] = c.tag[j][i] + } else if len(c.stag) != 0 { + hasSTag := c.stag[j].Pos[i].Start < c.stag[j].Pos[i].End && c.stag[j].Pos[i].End <= len(c.stag[j].Buf) + if hasSTag { + row.stag[c.tagIx[j]] = string(c.stag[j].Buf[c.stag[j].Pos[i].Start:c.stag[j].Pos[i].End]) + } } } if c.tagStr.Pos != nil && i < len(c.tagStr.Pos) { diff --git a/internal/api/sql.go b/internal/api/sql.go index 5944cc7f9..847c3994b 100644 --- a/internal/api/sql.go +++ b/internal/api/sql.go @@ -55,8 +55,13 @@ const ( func (pq *pointsQuery) cacheKey() string { var sb strings.Builder - sb.WriteString(";v=") - sb.WriteString(fmt.Sprint(pq.version)) + sb.WriteString("v=") + switch pq.version { + case Version1: + sb.WriteString(Version1) + default: + sb.WriteString(Version2) + } sb.WriteString(";m=") sb.WriteString(fmt.Sprint(pq.metricID)) sb.WriteString(";pk=")