This commit is contained in:
Aliaksandr Valialkin 2024-05-19 13:58:06 +02:00
parent 4e5b24c53a
commit 30a6aee52a
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB

View file

@ -1335,11 +1335,9 @@ func (br *blockResult) getColumnByName(columnName string) *blockResultColumn {
}
cs := br.getColumns()
// Search for the needed column in reverse order, since the old column may be overridden by new column in addResultColumn()
for i := len(cs) - 1; i >= 0; i-- {
if cs[i].name == columnName {
return cs[i]
}
idx := getBlockResultColumnIdxByName(cs, columnName)
if idx >= 0 {
return cs[idx]
}
br.addConstColumn(columnName, "")
@ -1365,7 +1363,13 @@ func (br *blockResult) getColumns() []*blockResultColumn {
clear(br.cs)
cs := br.cs[:0]
for i := range csBuf {
cs = append(cs, &csBuf[i])
c := &csBuf[i]
idx := getBlockResultColumnIdxByName(cs, c.name)
if idx >= 0 {
cs[idx] = c
} else {
cs = append(cs, c)
}
}
br.cs = cs
br.csInitialized = true
@ -1373,6 +1377,15 @@ func (br *blockResult) getColumns() []*blockResultColumn {
return br.cs
}
func getBlockResultColumnIdxByName(cs []*blockResultColumn, name string) int {
for i, c := range cs {
if c.name == name {
return i
}
}
return -1
}
func (br *blockResult) skipRows(skipRows int) {
br.timestamps = append(br.timestamps[:0], br.timestamps[skipRows:]...)
for _, c := range br.getColumns() {