Compare commits

...

1 commit

Author SHA1 Message Date
Till Faelligen 10ccd50df0
Testing 2022-10-28 14:59:23 +02:00

View file

@ -16,16 +16,19 @@
package postgres package postgres
import ( import (
"bytes"
"context" "context"
"database/sql" "database/sql"
"fmt" "fmt"
"strconv"
"github.com/lib/pq" "github.com/lib/pq"
"github.com/matrix-org/util"
"github.com/matrix-org/dendrite/internal" "github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/internal/sqlutil" "github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/dendrite/roomserver/storage/tables" "github.com/matrix-org/dendrite/roomserver/storage/tables"
"github.com/matrix-org/dendrite/roomserver/types" "github.com/matrix-org/dendrite/roomserver/types"
"github.com/matrix-org/util"
) )
const stateDataSchema = ` const stateDataSchema = `
@ -113,14 +116,20 @@ func (s *stateBlockStatements) BulkSelectStateBlockEntries(
results := make([][]types.EventNID, len(stateBlockNIDs)) results := make([][]types.EventNID, len(stateBlockNIDs))
i := 0 i := 0
var stateBlockNID types.StateBlockNID var stateBlockNID types.StateBlockNID
var result pq.Int64Array var result []byte
var parsed int64
for ; rows.Next(); i++ { for ; rows.Next(); i++ {
if err = rows.Scan(&stateBlockNID, &result); err != nil { if err = rows.Scan(&stateBlockNID, &result); err != nil {
return nil, err return nil, err
} }
r := make([]types.EventNID, len(result)) split := bytes.Split(result[1:len(result)-1], []byte(","))
for x := range result { r := make([]types.EventNID, len(split))
r[x] = types.EventNID(result[x]) for x, y := range split {
parsed, err = strconv.ParseInt(string(y), 10, 64)
if err != nil {
return nil, err
}
r[x] = types.EventNID(parsed)
} }
results[i] = r results[i] = r
} }