aboutsummaryrefslogtreecommitdiff
path: root/syncapi/storage/sqlite3
diff options
context:
space:
mode:
Diffstat (limited to 'syncapi/storage/sqlite3')
-rw-r--r--syncapi/storage/sqlite3/account_data_table.go4
-rw-r--r--syncapi/storage/sqlite3/backwards_extremities_table.go4
-rw-r--r--syncapi/storage/sqlite3/current_room_state_table.go20
-rw-r--r--syncapi/storage/sqlite3/invites_table.go8
-rw-r--r--syncapi/storage/sqlite3/output_room_events_table.go22
-rw-r--r--syncapi/storage/sqlite3/output_room_events_topology_table.go12
-rw-r--r--syncapi/storage/sqlite3/stream_id_table.go6
-rw-r--r--syncapi/storage/sqlite3/syncserver.go6
8 files changed, 41 insertions, 41 deletions
diff --git a/syncapi/storage/sqlite3/account_data_table.go b/syncapi/storage/sqlite3/account_data_table.go
index 435a399c..a3c79734 100644
--- a/syncapi/storage/sqlite3/account_data_table.go
+++ b/syncapi/storage/sqlite3/account_data_table.go
@@ -19,7 +19,7 @@ import (
"context"
"database/sql"
- "github.com/matrix-org/dendrite/common"
+ "github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/syncapi/storage/tables"
"github.com/matrix-org/dendrite/syncapi/types"
@@ -100,7 +100,7 @@ func (s *accountDataStatements) SelectAccountDataInRange(
if err != nil {
return
}
- defer common.CloseAndLogIfError(ctx, rows, "selectAccountDataInRange: rows.close() failed")
+ defer internal.CloseAndLogIfError(ctx, rows, "selectAccountDataInRange: rows.close() failed")
var entries int
diff --git a/syncapi/storage/sqlite3/backwards_extremities_table.go b/syncapi/storage/sqlite3/backwards_extremities_table.go
index c5d9cae5..e16e54a6 100644
--- a/syncapi/storage/sqlite3/backwards_extremities_table.go
+++ b/syncapi/storage/sqlite3/backwards_extremities_table.go
@@ -18,7 +18,7 @@ import (
"context"
"database/sql"
- "github.com/matrix-org/dendrite/common"
+ "github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/syncapi/storage/tables"
)
@@ -84,7 +84,7 @@ func (s *backwardExtremitiesStatements) SelectBackwardExtremitiesForRoom(
if err != nil {
return
}
- defer common.CloseAndLogIfError(ctx, rows, "selectBackwardExtremitiesForRoom: rows.close() failed")
+ defer internal.CloseAndLogIfError(ctx, rows, "selectBackwardExtremitiesForRoom: rows.close() failed")
bwExtrems = make(map[string][]string)
for rows.Next() {
diff --git a/syncapi/storage/sqlite3/current_room_state_table.go b/syncapi/storage/sqlite3/current_room_state_table.go
index b540fbc6..b0cf1297 100644
--- a/syncapi/storage/sqlite3/current_room_state_table.go
+++ b/syncapi/storage/sqlite3/current_room_state_table.go
@@ -21,7 +21,7 @@ import (
"encoding/json"
"strings"
- "github.com/matrix-org/dendrite/common"
+ "github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/syncapi/storage/tables"
"github.com/matrix-org/dendrite/syncapi/types"
"github.com/matrix-org/gomatrixserverlib"
@@ -129,7 +129,7 @@ func (s *currentRoomStateStatements) SelectJoinedUsers(
if err != nil {
return nil, err
}
- defer common.CloseAndLogIfError(ctx, rows, "selectJoinedUsers: rows.close() failed")
+ defer internal.CloseAndLogIfError(ctx, rows, "selectJoinedUsers: rows.close() failed")
result := make(map[string][]string)
for rows.Next() {
@@ -152,12 +152,12 @@ func (s *currentRoomStateStatements) SelectRoomIDsWithMembership(
userID string,
membership string, // nolint: unparam
) ([]string, error) {
- stmt := common.TxStmt(txn, s.selectRoomIDsWithMembershipStmt)
+ stmt := internal.TxStmt(txn, s.selectRoomIDsWithMembershipStmt)
rows, err := stmt.QueryContext(ctx, userID, membership)
if err != nil {
return nil, err
}
- defer common.CloseAndLogIfError(ctx, rows, "selectRoomIDsWithMembership: rows.close() failed")
+ defer internal.CloseAndLogIfError(ctx, rows, "selectRoomIDsWithMembership: rows.close() failed")
var result []string
for rows.Next() {
@@ -175,7 +175,7 @@ func (s *currentRoomStateStatements) SelectCurrentState(
ctx context.Context, txn *sql.Tx, roomID string,
stateFilterPart *gomatrixserverlib.StateFilter,
) ([]gomatrixserverlib.HeaderedEvent, error) {
- stmt := common.TxStmt(txn, s.selectCurrentStateStmt)
+ stmt := internal.TxStmt(txn, s.selectCurrentStateStmt)
rows, err := stmt.QueryContext(ctx, roomID,
nil, // FIXME: pq.StringArray(stateFilterPart.Senders),
nil, // FIXME: pq.StringArray(stateFilterPart.NotSenders),
@@ -187,7 +187,7 @@ func (s *currentRoomStateStatements) SelectCurrentState(
if err != nil {
return nil, err
}
- defer common.CloseAndLogIfError(ctx, rows, "selectCurrentState: rows.close() failed")
+ defer internal.CloseAndLogIfError(ctx, rows, "selectCurrentState: rows.close() failed")
return rowsToEvents(rows)
}
@@ -195,7 +195,7 @@ func (s *currentRoomStateStatements) SelectCurrentState(
func (s *currentRoomStateStatements) DeleteRoomStateByEventID(
ctx context.Context, txn *sql.Tx, eventID string,
) error {
- stmt := common.TxStmt(txn, s.deleteRoomStateByEventIDStmt)
+ stmt := internal.TxStmt(txn, s.deleteRoomStateByEventIDStmt)
_, err := stmt.ExecContext(ctx, eventID)
return err
}
@@ -218,7 +218,7 @@ func (s *currentRoomStateStatements) UpsertRoomState(
}
// upsert state event
- stmt := common.TxStmt(txn, s.upsertRoomStateStmt)
+ stmt := internal.TxStmt(txn, s.upsertRoomStateStmt)
_, err = stmt.ExecContext(
ctx,
event.RoomID(),
@@ -241,12 +241,12 @@ func (s *currentRoomStateStatements) SelectEventsWithEventIDs(
for k, v := range eventIDs {
iEventIDs[k] = v
}
- query := strings.Replace(selectEventsWithEventIDsSQL, "($1)", common.QueryVariadic(len(iEventIDs)), 1)
+ query := strings.Replace(selectEventsWithEventIDsSQL, "($1)", internal.QueryVariadic(len(iEventIDs)), 1)
rows, err := txn.QueryContext(ctx, query, iEventIDs...)
if err != nil {
return nil, err
}
- defer common.CloseAndLogIfError(ctx, rows, "selectEventsWithEventIDs: rows.close() failed")
+ defer internal.CloseAndLogIfError(ctx, rows, "selectEventsWithEventIDs: rows.close() failed")
return rowsToStreamEvents(rows)
}
diff --git a/syncapi/storage/sqlite3/invites_table.go b/syncapi/storage/sqlite3/invites_table.go
index 9cb184f2..64b52339 100644
--- a/syncapi/storage/sqlite3/invites_table.go
+++ b/syncapi/storage/sqlite3/invites_table.go
@@ -20,7 +20,7 @@ import (
"database/sql"
"encoding/json"
- "github.com/matrix-org/dendrite/common"
+ "github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/syncapi/storage/tables"
"github.com/matrix-org/dendrite/syncapi/types"
"github.com/matrix-org/gomatrixserverlib"
@@ -123,12 +123,12 @@ func (s *inviteEventsStatements) DeleteInviteEvent(
func (s *inviteEventsStatements) SelectInviteEventsInRange(
ctx context.Context, txn *sql.Tx, targetUserID string, r types.Range,
) (map[string]gomatrixserverlib.HeaderedEvent, error) {
- stmt := common.TxStmt(txn, s.selectInviteEventsInRangeStmt)
+ stmt := internal.TxStmt(txn, s.selectInviteEventsInRangeStmt)
rows, err := stmt.QueryContext(ctx, targetUserID, r.Low(), r.High())
if err != nil {
return nil, err
}
- defer common.CloseAndLogIfError(ctx, rows, "selectInviteEventsInRange: rows.close() failed")
+ defer internal.CloseAndLogIfError(ctx, rows, "selectInviteEventsInRange: rows.close() failed")
result := map[string]gomatrixserverlib.HeaderedEvent{}
for rows.Next() {
var (
@@ -153,7 +153,7 @@ func (s *inviteEventsStatements) SelectMaxInviteID(
ctx context.Context, txn *sql.Tx,
) (id int64, err error) {
var nullableID sql.NullInt64
- stmt := common.TxStmt(txn, s.selectMaxInviteIDStmt)
+ stmt := internal.TxStmt(txn, s.selectMaxInviteIDStmt)
err = stmt.QueryRowContext(ctx).Scan(&nullableID)
if nullableID.Valid {
id = nullableID.Int64
diff --git a/syncapi/storage/sqlite3/output_room_events_table.go b/syncapi/storage/sqlite3/output_room_events_table.go
index c89e007e..4a84ecc6 100644
--- a/syncapi/storage/sqlite3/output_room_events_table.go
+++ b/syncapi/storage/sqlite3/output_room_events_table.go
@@ -25,7 +25,7 @@ import (
"github.com/matrix-org/dendrite/syncapi/storage/tables"
"github.com/matrix-org/dendrite/syncapi/types"
- "github.com/matrix-org/dendrite/common"
+ "github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/gomatrixserverlib"
log "github.com/sirupsen/logrus"
)
@@ -149,7 +149,7 @@ func (s *outputRoomEventsStatements) SelectStateInRange(
ctx context.Context, txn *sql.Tx, r types.Range,
stateFilterPart *gomatrixserverlib.StateFilter,
) (map[string]map[string]bool, map[string]types.StreamEvent, error) {
- stmt := common.TxStmt(txn, s.selectStateInRangeStmt)
+ stmt := internal.TxStmt(txn, s.selectStateInRangeStmt)
rows, err := stmt.QueryContext(
ctx, r.Low(), r.High(),
@@ -236,7 +236,7 @@ func (s *outputRoomEventsStatements) SelectMaxEventID(
ctx context.Context, txn *sql.Tx,
) (id int64, err error) {
var nullableID sql.NullInt64
- stmt := common.TxStmt(txn, s.selectMaxEventIDStmt)
+ stmt := internal.TxStmt(txn, s.selectMaxEventIDStmt)
err = stmt.QueryRowContext(ctx).Scan(&nullableID)
if nullableID.Valid {
id = nullableID.Int64
@@ -286,7 +286,7 @@ func (s *outputRoomEventsStatements) InsertEvent(
return
}
- insertStmt := common.TxStmt(txn, s.insertEventStmt)
+ insertStmt := internal.TxStmt(txn, s.insertEventStmt)
_, err = insertStmt.ExecContext(
ctx,
streamPos,
@@ -313,16 +313,16 @@ func (s *outputRoomEventsStatements) SelectRecentEvents(
) ([]types.StreamEvent, error) {
var stmt *sql.Stmt
if onlySyncEvents {
- stmt = common.TxStmt(txn, s.selectRecentEventsForSyncStmt)
+ stmt = internal.TxStmt(txn, s.selectRecentEventsForSyncStmt)
} else {
- stmt = common.TxStmt(txn, s.selectRecentEventsStmt)
+ stmt = internal.TxStmt(txn, s.selectRecentEventsStmt)
}
rows, err := stmt.QueryContext(ctx, roomID, r.Low(), r.High(), limit)
if err != nil {
return nil, err
}
- defer common.CloseAndLogIfError(ctx, rows, "selectRecentEvents: rows.close() failed")
+ defer internal.CloseAndLogIfError(ctx, rows, "selectRecentEvents: rows.close() failed")
events, err := rowsToStreamEvents(rows)
if err != nil {
return nil, err
@@ -342,12 +342,12 @@ func (s *outputRoomEventsStatements) SelectEarlyEvents(
ctx context.Context, txn *sql.Tx,
roomID string, r types.Range, limit int,
) ([]types.StreamEvent, error) {
- stmt := common.TxStmt(txn, s.selectEarlyEventsStmt)
+ stmt := internal.TxStmt(txn, s.selectEarlyEventsStmt)
rows, err := stmt.QueryContext(ctx, roomID, r.Low(), r.High(), limit)
if err != nil {
return nil, err
}
- defer common.CloseAndLogIfError(ctx, rows, "selectEarlyEvents: rows.close() failed")
+ defer internal.CloseAndLogIfError(ctx, rows, "selectEarlyEvents: rows.close() failed")
events, err := rowsToStreamEvents(rows)
if err != nil {
return nil, err
@@ -367,7 +367,7 @@ func (s *outputRoomEventsStatements) SelectEvents(
ctx context.Context, txn *sql.Tx, eventIDs []string,
) ([]types.StreamEvent, error) {
var returnEvents []types.StreamEvent
- stmt := common.TxStmt(txn, s.selectEventsStmt)
+ stmt := internal.TxStmt(txn, s.selectEventsStmt)
for _, eventID := range eventIDs {
rows, err := stmt.QueryContext(ctx, eventID)
if err != nil {
@@ -376,7 +376,7 @@ func (s *outputRoomEventsStatements) SelectEvents(
if streamEvents, err := rowsToStreamEvents(rows); err == nil {
returnEvents = append(returnEvents, streamEvents...)
}
- common.CloseAndLogIfError(ctx, rows, "selectEvents: rows.close() failed")
+ internal.CloseAndLogIfError(ctx, rows, "selectEvents: rows.close() failed")
}
return returnEvents, nil
}
diff --git a/syncapi/storage/sqlite3/output_room_events_topology_table.go b/syncapi/storage/sqlite3/output_room_events_topology_table.go
index 22779238..0d727cb1 100644
--- a/syncapi/storage/sqlite3/output_room_events_topology_table.go
+++ b/syncapi/storage/sqlite3/output_room_events_topology_table.go
@@ -18,7 +18,7 @@ import (
"context"
"database/sql"
- "github.com/matrix-org/dendrite/common"
+ "github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/syncapi/storage/tables"
"github.com/matrix-org/dendrite/syncapi/types"
"github.com/matrix-org/gomatrixserverlib"
@@ -102,7 +102,7 @@ func NewSqliteTopologyTable(db *sql.DB) (tables.Topology, error) {
func (s *outputRoomEventsTopologyStatements) InsertEventInTopology(
ctx context.Context, txn *sql.Tx, event *gomatrixserverlib.HeaderedEvent, pos types.StreamPosition,
) (err error) {
- stmt := common.TxStmt(txn, s.insertEventInTopologyStmt)
+ stmt := internal.TxStmt(txn, s.insertEventInTopologyStmt)
_, err = stmt.ExecContext(
ctx, event.EventID(), event.Depth(), event.RoomID(), pos,
)
@@ -118,9 +118,9 @@ func (s *outputRoomEventsTopologyStatements) SelectEventIDsInRange(
// is requested or not.
var stmt *sql.Stmt
if chronologicalOrder {
- stmt = common.TxStmt(txn, s.selectEventIDsInRangeASCStmt)
+ stmt = internal.TxStmt(txn, s.selectEventIDsInRangeASCStmt)
} else {
- stmt = common.TxStmt(txn, s.selectEventIDsInRangeDESCStmt)
+ stmt = internal.TxStmt(txn, s.selectEventIDsInRangeDESCStmt)
}
// Query the event IDs.
@@ -149,7 +149,7 @@ func (s *outputRoomEventsTopologyStatements) SelectEventIDsInRange(
func (s *outputRoomEventsTopologyStatements) SelectPositionInTopology(
ctx context.Context, txn *sql.Tx, eventID string,
) (pos types.StreamPosition, spos types.StreamPosition, err error) {
- stmt := common.TxStmt(txn, s.selectPositionInTopologyStmt)
+ stmt := internal.TxStmt(txn, s.selectPositionInTopologyStmt)
err = stmt.QueryRowContext(ctx, eventID).Scan(&pos, &spos)
return
}
@@ -157,7 +157,7 @@ func (s *outputRoomEventsTopologyStatements) SelectPositionInTopology(
func (s *outputRoomEventsTopologyStatements) SelectMaxPositionInTopology(
ctx context.Context, txn *sql.Tx, roomID string,
) (pos types.StreamPosition, spos types.StreamPosition, err error) {
- stmt := common.TxStmt(txn, s.selectMaxPositionInTopologyStmt)
+ stmt := internal.TxStmt(txn, s.selectMaxPositionInTopologyStmt)
err = stmt.QueryRowContext(ctx, roomID).Scan(&pos, &spos)
return
}
diff --git a/syncapi/storage/sqlite3/stream_id_table.go b/syncapi/storage/sqlite3/stream_id_table.go
index 260f7a95..3bfe22dd 100644
--- a/syncapi/storage/sqlite3/stream_id_table.go
+++ b/syncapi/storage/sqlite3/stream_id_table.go
@@ -4,7 +4,7 @@ import (
"context"
"database/sql"
- "github.com/matrix-org/dendrite/common"
+ "github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/syncapi/types"
)
@@ -46,8 +46,8 @@ func (s *streamIDStatements) prepare(db *sql.DB) (err error) {
}
func (s *streamIDStatements) nextStreamID(ctx context.Context, txn *sql.Tx) (pos types.StreamPosition, err error) {
- increaseStmt := common.TxStmt(txn, s.increaseStreamIDStmt)
- selectStmt := common.TxStmt(txn, s.selectStreamIDStmt)
+ increaseStmt := internal.TxStmt(txn, s.increaseStreamIDStmt)
+ selectStmt := internal.TxStmt(txn, s.selectStreamIDStmt)
if _, err = increaseStmt.ExecContext(ctx, "global"); err != nil {
return
}
diff --git a/syncapi/storage/sqlite3/syncserver.go b/syncapi/storage/sqlite3/syncserver.go
index e23aeca4..8ab1d404 100644
--- a/syncapi/storage/sqlite3/syncserver.go
+++ b/syncapi/storage/sqlite3/syncserver.go
@@ -25,8 +25,8 @@ import (
// Import the sqlite3 package
_ "github.com/mattn/go-sqlite3"
- "github.com/matrix-org/dendrite/common"
"github.com/matrix-org/dendrite/eduserver/cache"
+ "github.com/matrix-org/dendrite/internal"
"github.com/matrix-org/dendrite/syncapi/storage/shared"
)
@@ -35,7 +35,7 @@ import (
type SyncServerDatasource struct {
shared.Database
db *sql.DB
- common.PartitionOffsetStatements
+ internal.PartitionOffsetStatements
streamID streamIDStatements
}
@@ -55,7 +55,7 @@ func NewDatabase(dataSourceName string) (*SyncServerDatasource, error) {
} else {
return nil, errors.New("no filename or path in connect string")
}
- if d.db, err = sqlutil.Open(common.SQLiteDriverName(), cs, nil); err != nil {
+ if d.db, err = sqlutil.Open(internal.SQLiteDriverName(), cs, nil); err != nil {
return nil, err
}
if err = d.prepare(); err != nil {