mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-09 22:42:58 +00:00
Factor out StatementList to sqlutil
and use it in userapi
It helps with the boilerplate.
This commit is contained in:
parent
9e4618000e
commit
ed4097825b
@ -152,3 +152,19 @@ func RunLimitedVariablesQuery(ctx context.Context, query string, qp QueryProvide
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StatementList is a list of SQL statements to prepare and a pointer to where to store the resulting prepared statement.
|
||||||
|
type StatementList []struct {
|
||||||
|
Statement **sql.Stmt
|
||||||
|
SQL string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare the SQL for each statement in the list and assign the result to the prepared statement.
|
||||||
|
func (s StatementList) Prepare(db *sql.DB) (err error) {
|
||||||
|
for _, statement := range s {
|
||||||
|
if *statement.Statement, err = db.Prepare(statement.SQL); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/internal"
|
"github.com/matrix-org/dendrite/internal"
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/shared"
|
"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"
|
||||||
)
|
)
|
||||||
@ -67,7 +67,7 @@ func createEventJSONTable(db *sql.DB) error {
|
|||||||
func prepareEventJSONTable(db *sql.DB) (tables.EventJSON, error) {
|
func prepareEventJSONTable(db *sql.DB) (tables.EventJSON, error) {
|
||||||
s := &eventJSONStatements{}
|
s := &eventJSONStatements{}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertEventJSONStmt, insertEventJSONSQL},
|
{&s.insertEventJSONStmt, insertEventJSONSQL},
|
||||||
{&s.bulkSelectEventJSONStmt, bulkSelectEventJSONSQL},
|
{&s.bulkSelectEventJSONStmt, bulkSelectEventJSONSQL},
|
||||||
}.Prepare(db)
|
}.Prepare(db)
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"github.com/lib/pq"
|
"github.com/lib/pq"
|
||||||
"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/shared"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
@ -85,7 +84,7 @@ func createEventStateKeysTable(db *sql.DB) error {
|
|||||||
func prepareEventStateKeysTable(db *sql.DB) (tables.EventStateKeys, error) {
|
func prepareEventStateKeysTable(db *sql.DB) (tables.EventStateKeys, error) {
|
||||||
s := &eventStateKeyStatements{}
|
s := &eventStateKeyStatements{}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertEventStateKeyNIDStmt, insertEventStateKeyNIDSQL},
|
{&s.insertEventStateKeyNIDStmt, insertEventStateKeyNIDSQL},
|
||||||
{&s.selectEventStateKeyNIDStmt, selectEventStateKeyNIDSQL},
|
{&s.selectEventStateKeyNIDStmt, selectEventStateKeyNIDSQL},
|
||||||
{&s.bulkSelectEventStateKeyNIDStmt, bulkSelectEventStateKeyNIDSQL},
|
{&s.bulkSelectEventStateKeyNIDStmt, bulkSelectEventStateKeyNIDSQL},
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"github.com/lib/pq"
|
"github.com/lib/pq"
|
||||||
"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/shared"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
@ -108,7 +107,7 @@ func createEventTypesTable(db *sql.DB) error {
|
|||||||
func prepareEventTypesTable(db *sql.DB) (tables.EventTypes, error) {
|
func prepareEventTypesTable(db *sql.DB) (tables.EventTypes, error) {
|
||||||
s := &eventTypeStatements{}
|
s := &eventTypeStatements{}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertEventTypeNIDStmt, insertEventTypeNIDSQL},
|
{&s.insertEventTypeNIDStmt, insertEventTypeNIDSQL},
|
||||||
{&s.selectEventTypeNIDStmt, selectEventTypeNIDSQL},
|
{&s.selectEventTypeNIDStmt, selectEventTypeNIDSQL},
|
||||||
{&s.bulkSelectEventTypeNIDStmt, bulkSelectEventTypeNIDSQL},
|
{&s.bulkSelectEventTypeNIDStmt, bulkSelectEventTypeNIDSQL},
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
"github.com/lib/pq"
|
"github.com/lib/pq"
|
||||||
"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/shared"
|
|
||||||
"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/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
@ -160,7 +159,7 @@ func createEventsTable(db *sql.DB) error {
|
|||||||
func prepareEventsTable(db *sql.DB) (tables.Events, error) {
|
func prepareEventsTable(db *sql.DB) (tables.Events, error) {
|
||||||
s := &eventStatements{}
|
s := &eventStatements{}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertEventStmt, insertEventSQL},
|
{&s.insertEventStmt, insertEventSQL},
|
||||||
{&s.selectEventStmt, selectEventSQL},
|
{&s.selectEventStmt, selectEventSQL},
|
||||||
{&s.bulkSelectStateEventByIDStmt, bulkSelectStateEventByIDSQL},
|
{&s.bulkSelectStateEventByIDStmt, bulkSelectStateEventByIDSQL},
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
|
|
||||||
"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/shared"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
@ -90,7 +89,7 @@ func createInvitesTable(db *sql.DB) error {
|
|||||||
func prepareInvitesTable(db *sql.DB) (tables.Invites, error) {
|
func prepareInvitesTable(db *sql.DB) (tables.Invites, error) {
|
||||||
s := &inviteStatements{}
|
s := &inviteStatements{}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertInviteEventStmt, insertInviteEventSQL},
|
{&s.insertInviteEventStmt, insertInviteEventSQL},
|
||||||
{&s.selectInviteActiveForUserInRoomStmt, selectInviteActiveForUserInRoomSQL},
|
{&s.selectInviteActiveForUserInRoomStmt, selectInviteActiveForUserInRoomSQL},
|
||||||
{&s.updateInviteRetiredStmt, updateInviteRetiredSQL},
|
{&s.updateInviteRetiredStmt, updateInviteRetiredSQL},
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
"github.com/lib/pq"
|
"github.com/lib/pq"
|
||||||
"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/shared"
|
|
||||||
"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/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
@ -168,7 +167,7 @@ func createMembershipTable(db *sql.DB) error {
|
|||||||
func prepareMembershipTable(db *sql.DB) (tables.Membership, error) {
|
func prepareMembershipTable(db *sql.DB) (tables.Membership, error) {
|
||||||
s := &membershipStatements{}
|
s := &membershipStatements{}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertMembershipStmt, insertMembershipSQL},
|
{&s.insertMembershipStmt, insertMembershipSQL},
|
||||||
{&s.selectMembershipForUpdateStmt, selectMembershipForUpdateSQL},
|
{&s.selectMembershipForUpdateStmt, selectMembershipForUpdateSQL},
|
||||||
{&s.selectMembershipFromRoomAndTargetStmt, selectMembershipFromRoomAndTargetSQL},
|
{&s.selectMembershipFromRoomAndTargetStmt, selectMembershipFromRoomAndTargetSQL},
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/shared"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
@ -73,7 +72,7 @@ func createPrevEventsTable(db *sql.DB) error {
|
|||||||
func preparePrevEventsTable(db *sql.DB) (tables.PreviousEvents, error) {
|
func preparePrevEventsTable(db *sql.DB) (tables.PreviousEvents, error) {
|
||||||
s := &previousEventStatements{}
|
s := &previousEventStatements{}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertPreviousEventStmt, insertPreviousEventSQL},
|
{&s.insertPreviousEventStmt, insertPreviousEventSQL},
|
||||||
{&s.selectPreviousEventExistsStmt, selectPreviousEventExistsSQL},
|
{&s.selectPreviousEventExistsStmt, selectPreviousEventExistsSQL},
|
||||||
}.Prepare(db)
|
}.Prepare(db)
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
|
|
||||||
"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/shared"
|
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -58,7 +57,7 @@ func createPublishedTable(db *sql.DB) error {
|
|||||||
func preparePublishedTable(db *sql.DB) (tables.Published, error) {
|
func preparePublishedTable(db *sql.DB) (tables.Published, error) {
|
||||||
s := &publishedStatements{}
|
s := &publishedStatements{}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.upsertPublishedStmt, upsertPublishedSQL},
|
{&s.upsertPublishedStmt, upsertPublishedSQL},
|
||||||
{&s.selectAllPublishedStmt, selectAllPublishedSQL},
|
{&s.selectAllPublishedStmt, selectAllPublishedSQL},
|
||||||
{&s.selectPublishedStmt, selectPublishedSQL},
|
{&s.selectPublishedStmt, selectPublishedSQL},
|
||||||
|
@ -19,7 +19,6 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/shared"
|
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -68,7 +67,7 @@ func createRedactionsTable(db *sql.DB) error {
|
|||||||
func prepareRedactionsTable(db *sql.DB) (tables.Redactions, error) {
|
func prepareRedactionsTable(db *sql.DB) (tables.Redactions, error) {
|
||||||
s := &redactionStatements{}
|
s := &redactionStatements{}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertRedactionStmt, insertRedactionSQL},
|
{&s.insertRedactionStmt, insertRedactionSQL},
|
||||||
{&s.selectRedactionInfoByRedactionEventIDStmt, selectRedactionInfoByRedactionEventIDSQL},
|
{&s.selectRedactionInfoByRedactionEventIDStmt, selectRedactionInfoByRedactionEventIDSQL},
|
||||||
{&s.selectRedactionInfoByEventBeingRedactedStmt, selectRedactionInfoByEventBeingRedactedSQL},
|
{&s.selectRedactionInfoByEventBeingRedactedStmt, selectRedactionInfoByEventBeingRedactedSQL},
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
|
|
||||||
"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/shared"
|
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -70,7 +69,7 @@ func createRoomAliasesTable(db *sql.DB) error {
|
|||||||
func prepareRoomAliasesTable(db *sql.DB) (tables.RoomAliases, error) {
|
func prepareRoomAliasesTable(db *sql.DB) (tables.RoomAliases, error) {
|
||||||
s := &roomAliasesStatements{}
|
s := &roomAliasesStatements{}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertRoomAliasStmt, insertRoomAliasSQL},
|
{&s.insertRoomAliasStmt, insertRoomAliasSQL},
|
||||||
{&s.selectRoomIDFromAliasStmt, selectRoomIDFromAliasSQL},
|
{&s.selectRoomIDFromAliasStmt, selectRoomIDFromAliasSQL},
|
||||||
{&s.selectAliasesFromRoomIDStmt, selectAliasesFromRoomIDSQL},
|
{&s.selectAliasesFromRoomIDStmt, selectAliasesFromRoomIDSQL},
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"github.com/lib/pq"
|
"github.com/lib/pq"
|
||||||
"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/shared"
|
|
||||||
"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/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
@ -104,7 +103,7 @@ func createRoomsTable(db *sql.DB) error {
|
|||||||
func prepareRoomsTable(db *sql.DB) (tables.Rooms, error) {
|
func prepareRoomsTable(db *sql.DB) (tables.Rooms, error) {
|
||||||
s := &roomStatements{}
|
s := &roomStatements{}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertRoomNIDStmt, insertRoomNIDSQL},
|
{&s.insertRoomNIDStmt, insertRoomNIDSQL},
|
||||||
{&s.selectRoomNIDStmt, selectRoomNIDSQL},
|
{&s.selectRoomNIDStmt, selectRoomNIDSQL},
|
||||||
{&s.selectLatestEventNIDsStmt, selectLatestEventNIDsSQL},
|
{&s.selectLatestEventNIDsStmt, selectLatestEventNIDsSQL},
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
|
|
||||||
"github.com/lib/pq"
|
"github.com/lib/pq"
|
||||||
"github.com/matrix-org/dendrite/internal"
|
"github.com/matrix-org/dendrite/internal"
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/shared"
|
"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"
|
"github.com/matrix-org/util"
|
||||||
@ -79,7 +79,7 @@ func createStateBlockTable(db *sql.DB) error {
|
|||||||
func prepareStateBlockTable(db *sql.DB) (tables.StateBlock, error) {
|
func prepareStateBlockTable(db *sql.DB) (tables.StateBlock, error) {
|
||||||
s := &stateBlockStatements{}
|
s := &stateBlockStatements{}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertStateDataStmt, insertStateDataSQL},
|
{&s.insertStateDataStmt, insertStateDataSQL},
|
||||||
{&s.bulkSelectStateBlockEntriesStmt, bulkSelectStateBlockEntriesSQL},
|
{&s.bulkSelectStateBlockEntriesStmt, bulkSelectStateBlockEntriesSQL},
|
||||||
}.Prepare(db)
|
}.Prepare(db)
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
|
|
||||||
"github.com/lib/pq"
|
"github.com/lib/pq"
|
||||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/shared"
|
|
||||||
"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"
|
"github.com/matrix-org/util"
|
||||||
@ -86,7 +85,7 @@ func createStateSnapshotTable(db *sql.DB) error {
|
|||||||
func prepareStateSnapshotTable(db *sql.DB) (tables.StateSnapshot, error) {
|
func prepareStateSnapshotTable(db *sql.DB) (tables.StateSnapshot, error) {
|
||||||
s := &stateSnapshotStatements{}
|
s := &stateSnapshotStatements{}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertStateStmt, insertStateSQL},
|
{&s.insertStateStmt, insertStateSQL},
|
||||||
{&s.bulkSelectStateBlockNIDsStmt, bulkSelectStateBlockNIDsSQL},
|
{&s.bulkSelectStateBlockNIDsStmt, bulkSelectStateBlockNIDsSQL},
|
||||||
}.Prepare(db)
|
}.Prepare(db)
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/shared"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ func createTransactionsTable(db *sql.DB) error {
|
|||||||
func prepareTransactionsTable(db *sql.DB) (tables.Transactions, error) {
|
func prepareTransactionsTable(db *sql.DB) (tables.Transactions, error) {
|
||||||
s := &transactionStatements{}
|
s := &transactionStatements{}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertTransactionStmt, insertTransactionSQL},
|
{&s.insertTransactionStmt, insertTransactionSQL},
|
||||||
{&s.selectTransactionEventIDStmt, selectTransactionEventIDSQL},
|
{&s.selectTransactionEventIDStmt, selectTransactionEventIDSQL},
|
||||||
}.Prepare(db)
|
}.Prepare(db)
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
|
|
||||||
"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/shared"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
@ -63,7 +62,7 @@ func prepareEventJSONTable(db *sql.DB) (tables.EventJSON, error) {
|
|||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertEventJSONStmt, insertEventJSONSQL},
|
{&s.insertEventJSONStmt, insertEventJSONSQL},
|
||||||
{&s.bulkSelectEventJSONStmt, bulkSelectEventJSONSQL},
|
{&s.bulkSelectEventJSONStmt, bulkSelectEventJSONSQL},
|
||||||
}.Prepare(db)
|
}.Prepare(db)
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
|
|
||||||
"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/shared"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
@ -80,7 +79,7 @@ func prepareEventStateKeysTable(db *sql.DB) (tables.EventStateKeys, error) {
|
|||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertEventStateKeyNIDStmt, insertEventStateKeyNIDSQL},
|
{&s.insertEventStateKeyNIDStmt, insertEventStateKeyNIDSQL},
|
||||||
{&s.selectEventStateKeyNIDStmt, selectEventStateKeyNIDSQL},
|
{&s.selectEventStateKeyNIDStmt, selectEventStateKeyNIDSQL},
|
||||||
{&s.bulkSelectEventStateKeyNIDStmt, bulkSelectEventStateKeyNIDSQL},
|
{&s.bulkSelectEventStateKeyNIDStmt, bulkSelectEventStateKeyNIDSQL},
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
|
|
||||||
"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/shared"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
@ -95,7 +94,7 @@ func prepareEventTypesTable(db *sql.DB) (tables.EventTypes, error) {
|
|||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertEventTypeNIDStmt, insertEventTypeNIDSQL},
|
{&s.insertEventTypeNIDStmt, insertEventTypeNIDSQL},
|
||||||
{&s.insertEventTypeNIDResultStmt, insertEventTypeNIDResultSQL},
|
{&s.insertEventTypeNIDResultStmt, insertEventTypeNIDResultSQL},
|
||||||
{&s.selectEventTypeNIDStmt, selectEventTypeNIDSQL},
|
{&s.selectEventTypeNIDStmt, selectEventTypeNIDSQL},
|
||||||
|
@ -25,7 +25,6 @@ import (
|
|||||||
|
|
||||||
"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/shared"
|
|
||||||
"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/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
@ -131,7 +130,7 @@ func prepareEventsTable(db *sql.DB) (tables.Events, error) {
|
|||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertEventStmt, insertEventSQL},
|
{&s.insertEventStmt, insertEventSQL},
|
||||||
{&s.selectEventStmt, selectEventSQL},
|
{&s.selectEventStmt, selectEventSQL},
|
||||||
{&s.bulkSelectStateEventByIDStmt, bulkSelectStateEventByIDSQL},
|
{&s.bulkSelectStateEventByIDStmt, bulkSelectStateEventByIDSQL},
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
|
|
||||||
"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/shared"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
@ -80,7 +79,7 @@ func prepareInvitesTable(db *sql.DB) (tables.Invites, error) {
|
|||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertInviteEventStmt, insertInviteEventSQL},
|
{&s.insertInviteEventStmt, insertInviteEventSQL},
|
||||||
{&s.selectInviteActiveForUserInRoomStmt, selectInviteActiveForUserInRoomSQL},
|
{&s.selectInviteActiveForUserInRoomStmt, selectInviteActiveForUserInRoomSQL},
|
||||||
{&s.updateInviteRetiredStmt, updateInviteRetiredSQL},
|
{&s.updateInviteRetiredStmt, updateInviteRetiredSQL},
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
|
|
||||||
"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/shared"
|
|
||||||
"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/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
@ -146,7 +145,7 @@ func prepareMembershipTable(db *sql.DB) (tables.Membership, error) {
|
|||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertMembershipStmt, insertMembershipSQL},
|
{&s.insertMembershipStmt, insertMembershipSQL},
|
||||||
{&s.selectMembershipForUpdateStmt, selectMembershipForUpdateSQL},
|
{&s.selectMembershipForUpdateStmt, selectMembershipForUpdateSQL},
|
||||||
{&s.selectMembershipFromRoomAndTargetStmt, selectMembershipFromRoomAndTargetSQL},
|
{&s.selectMembershipFromRoomAndTargetStmt, selectMembershipFromRoomAndTargetSQL},
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/shared"
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
@ -81,7 +80,7 @@ func preparePrevEventsTable(db *sql.DB) (tables.PreviousEvents, error) {
|
|||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertPreviousEventStmt, insertPreviousEventSQL},
|
{&s.insertPreviousEventStmt, insertPreviousEventSQL},
|
||||||
{&s.selectPreviousEventNIDsStmt, selectPreviousEventNIDsSQL},
|
{&s.selectPreviousEventNIDsStmt, selectPreviousEventNIDsSQL},
|
||||||
{&s.selectPreviousEventExistsStmt, selectPreviousEventExistsSQL},
|
{&s.selectPreviousEventExistsStmt, selectPreviousEventExistsSQL},
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
|
|
||||||
"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/shared"
|
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -60,7 +59,7 @@ func preparePublishedTable(db *sql.DB) (tables.Published, error) {
|
|||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.upsertPublishedStmt, upsertPublishedSQL},
|
{&s.upsertPublishedStmt, upsertPublishedSQL},
|
||||||
{&s.selectAllPublishedStmt, selectAllPublishedSQL},
|
{&s.selectAllPublishedStmt, selectAllPublishedSQL},
|
||||||
{&s.selectPublishedStmt, selectPublishedSQL},
|
{&s.selectPublishedStmt, selectPublishedSQL},
|
||||||
|
@ -19,7 +19,6 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/shared"
|
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -69,7 +68,7 @@ func prepareRedactionsTable(db *sql.DB) (tables.Redactions, error) {
|
|||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertRedactionStmt, insertRedactionSQL},
|
{&s.insertRedactionStmt, insertRedactionSQL},
|
||||||
{&s.selectRedactionInfoByRedactionEventIDStmt, selectRedactionInfoByRedactionEventIDSQL},
|
{&s.selectRedactionInfoByRedactionEventIDStmt, selectRedactionInfoByRedactionEventIDSQL},
|
||||||
{&s.selectRedactionInfoByEventBeingRedactedStmt, selectRedactionInfoByEventBeingRedactedSQL},
|
{&s.selectRedactionInfoByEventBeingRedactedStmt, selectRedactionInfoByEventBeingRedactedSQL},
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
|
|
||||||
"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/shared"
|
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -74,7 +73,7 @@ func prepareRoomAliasesTable(db *sql.DB) (tables.RoomAliases, error) {
|
|||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertRoomAliasStmt, insertRoomAliasSQL},
|
{&s.insertRoomAliasStmt, insertRoomAliasSQL},
|
||||||
{&s.selectRoomIDFromAliasStmt, selectRoomIDFromAliasSQL},
|
{&s.selectRoomIDFromAliasStmt, selectRoomIDFromAliasSQL},
|
||||||
{&s.selectAliasesFromRoomIDStmt, selectAliasesFromRoomIDSQL},
|
{&s.selectAliasesFromRoomIDStmt, selectAliasesFromRoomIDSQL},
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
|
|
||||||
"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/shared"
|
|
||||||
"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/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
@ -96,7 +95,7 @@ func prepareRoomsTable(db *sql.DB) (tables.Rooms, error) {
|
|||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertRoomNIDStmt, insertRoomNIDSQL},
|
{&s.insertRoomNIDStmt, insertRoomNIDSQL},
|
||||||
{&s.selectRoomNIDStmt, selectRoomNIDSQL},
|
{&s.selectRoomNIDStmt, selectRoomNIDSQL},
|
||||||
{&s.selectLatestEventNIDsStmt, selectLatestEventNIDsSQL},
|
{&s.selectLatestEventNIDsStmt, selectLatestEventNIDsSQL},
|
||||||
|
@ -25,7 +25,6 @@ import (
|
|||||||
|
|
||||||
"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/shared"
|
|
||||||
"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"
|
"github.com/matrix-org/util"
|
||||||
@ -75,7 +74,7 @@ func prepareStateBlockTable(db *sql.DB) (tables.StateBlock, error) {
|
|||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertStateDataStmt, insertStateDataSQL},
|
{&s.insertStateDataStmt, insertStateDataSQL},
|
||||||
{&s.bulkSelectStateBlockEntriesStmt, bulkSelectStateBlockEntriesSQL},
|
{&s.bulkSelectStateBlockEntriesStmt, bulkSelectStateBlockEntriesSQL},
|
||||||
}.Prepare(db)
|
}.Prepare(db)
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
|
|
||||||
"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/shared"
|
|
||||||
"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"
|
"github.com/matrix-org/util"
|
||||||
@ -79,7 +78,7 @@ func prepareStateSnapshotTable(db *sql.DB) (tables.StateSnapshot, error) {
|
|||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertStateStmt, insertStateSQL},
|
{&s.insertStateStmt, insertStateSQL},
|
||||||
{&s.bulkSelectStateBlockNIDsStmt, bulkSelectStateBlockNIDsSQL},
|
{&s.bulkSelectStateBlockNIDsStmt, bulkSelectStateBlockNIDsSQL},
|
||||||
}.Prepare(db)
|
}.Prepare(db)
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/shared"
|
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
"github.com/matrix-org/dendrite/roomserver/storage/tables"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -59,7 +58,7 @@ func prepareTransactionsTable(db *sql.DB) (tables.Transactions, error) {
|
|||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, shared.StatementList{
|
return s, sqlutil.StatementList{
|
||||||
{&s.insertTransactionStmt, insertTransactionSQL},
|
{&s.insertTransactionStmt, insertTransactionSQL},
|
||||||
{&s.selectTransactionEventIDStmt, selectTransactionEventIDSQL},
|
{&s.selectTransactionEventIDStmt, selectTransactionEventIDSQL},
|
||||||
}.Prepare(db)
|
}.Prepare(db)
|
||||||
|
@ -61,16 +61,11 @@ func (s *accountDataStatements) prepare(db *sql.DB) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if s.insertAccountDataStmt, err = db.Prepare(insertAccountDataSQL); err != nil {
|
return sqlutil.StatementList{
|
||||||
return
|
{&s.insertAccountDataStmt, insertAccountDataSQL},
|
||||||
}
|
{&s.selectAccountDataStmt, selectAccountDataSQL},
|
||||||
if s.selectAccountDataStmt, err = db.Prepare(selectAccountDataSQL); err != nil {
|
{&s.selectAccountDataByTypeStmt, selectAccountDataByTypeSQL},
|
||||||
return
|
}.Prepare(db)
|
||||||
}
|
|
||||||
if s.selectAccountDataByTypeStmt, err = db.Prepare(selectAccountDataByTypeSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *accountDataStatements) insertAccountData(
|
func (s *accountDataStatements) insertAccountData(
|
||||||
|
@ -81,26 +81,15 @@ func (s *accountsStatements) execSchema(db *sql.DB) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *accountsStatements) prepare(db *sql.DB, server gomatrixserverlib.ServerName) (err error) {
|
func (s *accountsStatements) prepare(db *sql.DB, server gomatrixserverlib.ServerName) (err error) {
|
||||||
if s.insertAccountStmt, err = db.Prepare(insertAccountSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.updatePasswordStmt, err = db.Prepare(updatePasswordSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.deactivateAccountStmt, err = db.Prepare(deactivateAccountSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.selectAccountByLocalpartStmt, err = db.Prepare(selectAccountByLocalpartSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.selectPasswordHashStmt, err = db.Prepare(selectPasswordHashSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.selectNewNumericLocalpartStmt, err = db.Prepare(selectNewNumericLocalpartSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.serverName = server
|
s.serverName = server
|
||||||
return
|
return sqlutil.StatementList{
|
||||||
|
{&s.insertAccountStmt, insertAccountSQL},
|
||||||
|
{&s.updatePasswordStmt, updatePasswordSQL},
|
||||||
|
{&s.deactivateAccountStmt, deactivateAccountSQL},
|
||||||
|
{&s.selectAccountByLocalpartStmt, selectAccountByLocalpartSQL},
|
||||||
|
{&s.selectPasswordHashStmt, selectPasswordHashSQL},
|
||||||
|
{&s.selectNewNumericLocalpartStmt, selectNewNumericLocalpartSQL},
|
||||||
|
}.Prepare(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
// insertAccount creates a new account. 'hash' should be the password hash for this account. If it is missing,
|
// insertAccount creates a new account. 'hash' should be the password hash for this account. If it is missing,
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/internal"
|
"github.com/matrix-org/dendrite/internal"
|
||||||
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
"github.com/matrix-org/dendrite/userapi/api"
|
"github.com/matrix-org/dendrite/userapi/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -76,25 +77,14 @@ func (s *keyBackupStatements) prepare(db *sql.DB) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if s.insertBackupKeyStmt, err = db.Prepare(insertBackupKeySQL); err != nil {
|
return sqlutil.StatementList{
|
||||||
return
|
{&s.insertBackupKeyStmt, insertBackupKeySQL},
|
||||||
}
|
{&s.updateBackupKeyStmt, updateBackupKeySQL},
|
||||||
if s.updateBackupKeyStmt, err = db.Prepare(updateBackupKeySQL); err != nil {
|
{&s.countKeysStmt, countKeysSQL},
|
||||||
return
|
{&s.selectKeysStmt, selectKeysSQL},
|
||||||
}
|
{&s.selectKeysByRoomIDStmt, selectKeysByRoomIDSQL},
|
||||||
if s.countKeysStmt, err = db.Prepare(countKeysSQL); err != nil {
|
{&s.selectKeysByRoomIDAndSessionIDStmt, selectKeysByRoomIDAndSessionIDSQL},
|
||||||
return
|
}.Prepare(db)
|
||||||
}
|
|
||||||
if s.selectKeysStmt, err = db.Prepare(selectKeysSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.selectKeysByRoomIDStmt, err = db.Prepare(selectKeysByRoomIDSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.selectKeysByRoomIDAndSessionIDStmt, err = db.Prepare(selectKeysByRoomIDAndSessionIDSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s keyBackupStatements) countKeys(
|
func (s keyBackupStatements) countKeys(
|
||||||
|
@ -20,6 +20,8 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
const keyBackupVersionTableSchema = `
|
const keyBackupVersionTableSchema = `
|
||||||
@ -72,25 +74,14 @@ func (s *keyBackupVersionStatements) prepare(db *sql.DB) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if s.insertKeyBackupStmt, err = db.Prepare(insertKeyBackupSQL); err != nil {
|
return sqlutil.StatementList{
|
||||||
return
|
{&s.insertKeyBackupStmt, insertKeyBackupSQL},
|
||||||
}
|
{&s.updateKeyBackupAuthDataStmt, updateKeyBackupAuthDataSQL},
|
||||||
if s.updateKeyBackupAuthDataStmt, err = db.Prepare(updateKeyBackupAuthDataSQL); err != nil {
|
{&s.deleteKeyBackupStmt, deleteKeyBackupSQL},
|
||||||
return
|
{&s.selectKeyBackupStmt, selectKeyBackupSQL},
|
||||||
}
|
{&s.selectLatestVersionStmt, selectLatestVersionSQL},
|
||||||
if s.deleteKeyBackupStmt, err = db.Prepare(deleteKeyBackupSQL); err != nil {
|
{&s.updateKeyBackupETagStmt, updateKeyBackupETagSQL},
|
||||||
return
|
}.Prepare(db)
|
||||||
}
|
|
||||||
if s.selectKeyBackupStmt, err = db.Prepare(selectKeyBackupSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.selectLatestVersionStmt, err = db.Prepare(selectLatestVersionSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.updateKeyBackupETagStmt, err = db.Prepare(updateKeyBackupETagSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *keyBackupVersionStatements) insertKeyBackup(
|
func (s *keyBackupVersionStatements) insertKeyBackup(
|
||||||
|
@ -39,14 +39,11 @@ func (s *tokenStatements) prepare(db *sql.DB, server gomatrixserverlib.ServerNam
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if s.insertTokenStmt, err = db.Prepare(insertTokenSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.selectTokenStmt, err = db.Prepare(selectTokenSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.serverName = server
|
s.serverName = server
|
||||||
return
|
return sqlutil.StatementList{
|
||||||
|
{&s.insertTokenStmt, insertTokenSQL},
|
||||||
|
{&s.selectTokenStmt, selectTokenSQL},
|
||||||
|
}.Prepare(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
// insertToken inserts a new OpenID Connect token to the DB.
|
// insertToken inserts a new OpenID Connect token to the DB.
|
||||||
|
@ -64,22 +64,13 @@ func (s *profilesStatements) prepare(db *sql.DB) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if s.insertProfileStmt, err = db.Prepare(insertProfileSQL); err != nil {
|
return sqlutil.StatementList{
|
||||||
return
|
{&s.insertProfileStmt, insertProfileSQL},
|
||||||
}
|
{&s.selectProfileByLocalpartStmt, selectProfileByLocalpartSQL},
|
||||||
if s.selectProfileByLocalpartStmt, err = db.Prepare(selectProfileByLocalpartSQL); err != nil {
|
{&s.setAvatarURLStmt, setAvatarURLSQL},
|
||||||
return
|
{&s.setDisplayNameStmt, setDisplayNameSQL},
|
||||||
}
|
{&s.selectProfilesBySearchStmt, selectProfilesBySearchSQL},
|
||||||
if s.setAvatarURLStmt, err = db.Prepare(setAvatarURLSQL); err != nil {
|
}.Prepare(db)
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.setDisplayNameStmt, err = db.Prepare(setDisplayNameSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.selectProfilesBySearchStmt, err = db.Prepare(selectProfilesBySearchSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *profilesStatements) insertProfile(
|
func (s *profilesStatements) insertProfile(
|
||||||
|
@ -63,20 +63,12 @@ func (s *threepidStatements) prepare(db *sql.DB) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if s.selectLocalpartForThreePIDStmt, err = db.Prepare(selectLocalpartForThreePIDSQL); err != nil {
|
return sqlutil.StatementList{
|
||||||
return
|
{&s.selectLocalpartForThreePIDStmt, selectLocalpartForThreePIDSQL},
|
||||||
}
|
{&s.selectThreePIDsForLocalpartStmt, selectThreePIDsForLocalpartSQL},
|
||||||
if s.selectThreePIDsForLocalpartStmt, err = db.Prepare(selectThreePIDsForLocalpartSQL); err != nil {
|
{&s.insertThreePIDStmt, insertThreePIDSQL},
|
||||||
return
|
{&s.deleteThreePIDStmt, deleteThreePIDSQL},
|
||||||
}
|
}.Prepare(db)
|
||||||
if s.insertThreePIDStmt, err = db.Prepare(insertThreePIDSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.deleteThreePIDStmt, err = db.Prepare(deleteThreePIDSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *threepidStatements) selectLocalpartForThreePID(
|
func (s *threepidStatements) selectLocalpartForThreePID(
|
||||||
|
@ -62,16 +62,11 @@ func (s *accountDataStatements) prepare(db *sql.DB) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if s.insertAccountDataStmt, err = db.Prepare(insertAccountDataSQL); err != nil {
|
return sqlutil.StatementList{
|
||||||
return
|
{&s.insertAccountDataStmt, insertAccountDataSQL},
|
||||||
}
|
{&s.selectAccountDataStmt, selectAccountDataSQL},
|
||||||
if s.selectAccountDataStmt, err = db.Prepare(selectAccountDataSQL); err != nil {
|
{&s.selectAccountDataByTypeStmt, selectAccountDataByTypeSQL},
|
||||||
return
|
}.Prepare(db)
|
||||||
}
|
|
||||||
if s.selectAccountDataByTypeStmt, err = db.Prepare(selectAccountDataByTypeSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *accountDataStatements) insertAccountData(
|
func (s *accountDataStatements) insertAccountData(
|
||||||
|
@ -81,26 +81,15 @@ func (s *accountsStatements) execSchema(db *sql.DB) error {
|
|||||||
|
|
||||||
func (s *accountsStatements) prepare(db *sql.DB, server gomatrixserverlib.ServerName) (err error) {
|
func (s *accountsStatements) prepare(db *sql.DB, server gomatrixserverlib.ServerName) (err error) {
|
||||||
s.db = db
|
s.db = db
|
||||||
if s.insertAccountStmt, err = db.Prepare(insertAccountSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.updatePasswordStmt, err = db.Prepare(updatePasswordSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.deactivateAccountStmt, err = db.Prepare(deactivateAccountSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.selectAccountByLocalpartStmt, err = db.Prepare(selectAccountByLocalpartSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.selectPasswordHashStmt, err = db.Prepare(selectPasswordHashSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.selectNewNumericLocalpartStmt, err = db.Prepare(selectNewNumericLocalpartSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.serverName = server
|
s.serverName = server
|
||||||
return
|
return sqlutil.StatementList{
|
||||||
|
{&s.insertAccountStmt, insertAccountSQL},
|
||||||
|
{&s.updatePasswordStmt, updatePasswordSQL},
|
||||||
|
{&s.deactivateAccountStmt, deactivateAccountSQL},
|
||||||
|
{&s.selectAccountByLocalpartStmt, selectAccountByLocalpartSQL},
|
||||||
|
{&s.selectPasswordHashStmt, selectPasswordHashSQL},
|
||||||
|
{&s.selectNewNumericLocalpartStmt, selectNewNumericLocalpartSQL},
|
||||||
|
}.Prepare(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
// insertAccount creates a new account. 'hash' should be the password hash for this account. If it is missing,
|
// insertAccount creates a new account. 'hash' should be the password hash for this account. If it is missing,
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/internal"
|
"github.com/matrix-org/dendrite/internal"
|
||||||
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
"github.com/matrix-org/dendrite/userapi/api"
|
"github.com/matrix-org/dendrite/userapi/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -76,25 +77,14 @@ func (s *keyBackupStatements) prepare(db *sql.DB) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if s.insertBackupKeyStmt, err = db.Prepare(insertBackupKeySQL); err != nil {
|
return sqlutil.StatementList{
|
||||||
return
|
{&s.insertBackupKeyStmt, insertBackupKeySQL},
|
||||||
}
|
{&s.updateBackupKeyStmt, updateBackupKeySQL},
|
||||||
if s.updateBackupKeyStmt, err = db.Prepare(updateBackupKeySQL); err != nil {
|
{&s.countKeysStmt, countKeysSQL},
|
||||||
return
|
{&s.selectKeysStmt, selectKeysSQL},
|
||||||
}
|
{&s.selectKeysByRoomIDStmt, selectKeysByRoomIDSQL},
|
||||||
if s.countKeysStmt, err = db.Prepare(countKeysSQL); err != nil {
|
{&s.selectKeysByRoomIDAndSessionIDStmt, selectKeysByRoomIDAndSessionIDSQL},
|
||||||
return
|
}.Prepare(db)
|
||||||
}
|
|
||||||
if s.selectKeysStmt, err = db.Prepare(selectKeysSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.selectKeysByRoomIDStmt, err = db.Prepare(selectKeysByRoomIDSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.selectKeysByRoomIDAndSessionIDStmt, err = db.Prepare(selectKeysByRoomIDAndSessionIDSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s keyBackupStatements) countKeys(
|
func (s keyBackupStatements) countKeys(
|
||||||
|
@ -20,6 +20,8 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
const keyBackupVersionTableSchema = `
|
const keyBackupVersionTableSchema = `
|
||||||
@ -70,25 +72,14 @@ func (s *keyBackupVersionStatements) prepare(db *sql.DB) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if s.insertKeyBackupStmt, err = db.Prepare(insertKeyBackupSQL); err != nil {
|
return sqlutil.StatementList{
|
||||||
return
|
{&s.insertKeyBackupStmt, insertKeyBackupSQL},
|
||||||
}
|
{&s.updateKeyBackupAuthDataStmt, updateKeyBackupAuthDataSQL},
|
||||||
if s.updateKeyBackupAuthDataStmt, err = db.Prepare(updateKeyBackupAuthDataSQL); err != nil {
|
{&s.deleteKeyBackupStmt, deleteKeyBackupSQL},
|
||||||
return
|
{&s.selectKeyBackupStmt, selectKeyBackupSQL},
|
||||||
}
|
{&s.selectLatestVersionStmt, selectLatestVersionSQL},
|
||||||
if s.deleteKeyBackupStmt, err = db.Prepare(deleteKeyBackupSQL); err != nil {
|
{&s.updateKeyBackupETagStmt, updateKeyBackupETagSQL},
|
||||||
return
|
}.Prepare(db)
|
||||||
}
|
|
||||||
if s.selectKeyBackupStmt, err = db.Prepare(selectKeyBackupSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.selectLatestVersionStmt, err = db.Prepare(selectLatestVersionSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.updateKeyBackupETagStmt, err = db.Prepare(updateKeyBackupETagSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *keyBackupVersionStatements) insertKeyBackup(
|
func (s *keyBackupVersionStatements) insertKeyBackup(
|
||||||
|
@ -41,14 +41,11 @@ func (s *tokenStatements) prepare(db *sql.DB, server gomatrixserverlib.ServerNam
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if s.insertTokenStmt, err = db.Prepare(insertTokenSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.selectTokenStmt, err = db.Prepare(selectTokenSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.serverName = server
|
s.serverName = server
|
||||||
return
|
return sqlutil.StatementList{
|
||||||
|
{&s.insertTokenStmt, insertTokenSQL},
|
||||||
|
{&s.selectTokenStmt, selectTokenSQL},
|
||||||
|
}.Prepare(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
// insertToken inserts a new OpenID Connect token to the DB.
|
// insertToken inserts a new OpenID Connect token to the DB.
|
||||||
|
@ -66,22 +66,13 @@ func (s *profilesStatements) prepare(db *sql.DB) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if s.insertProfileStmt, err = db.Prepare(insertProfileSQL); err != nil {
|
return sqlutil.StatementList{
|
||||||
return
|
{&s.insertProfileStmt, insertProfileSQL},
|
||||||
}
|
{&s.selectProfileByLocalpartStmt, selectProfileByLocalpartSQL},
|
||||||
if s.selectProfileByLocalpartStmt, err = db.Prepare(selectProfileByLocalpartSQL); err != nil {
|
{&s.setAvatarURLStmt, setAvatarURLSQL},
|
||||||
return
|
{&s.setDisplayNameStmt, setDisplayNameSQL},
|
||||||
}
|
{&s.selectProfilesBySearchStmt, selectProfilesBySearchSQL},
|
||||||
if s.setAvatarURLStmt, err = db.Prepare(setAvatarURLSQL); err != nil {
|
}.Prepare(db)
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.setDisplayNameStmt, err = db.Prepare(setDisplayNameSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.selectProfilesBySearchStmt, err = db.Prepare(selectProfilesBySearchSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *profilesStatements) insertProfile(
|
func (s *profilesStatements) insertProfile(
|
||||||
|
@ -66,20 +66,12 @@ func (s *threepidStatements) prepare(db *sql.DB) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if s.selectLocalpartForThreePIDStmt, err = db.Prepare(selectLocalpartForThreePIDSQL); err != nil {
|
return sqlutil.StatementList{
|
||||||
return
|
{&s.selectLocalpartForThreePIDStmt, selectLocalpartForThreePIDSQL},
|
||||||
}
|
{&s.selectThreePIDsForLocalpartStmt, selectThreePIDsForLocalpartSQL},
|
||||||
if s.selectThreePIDsForLocalpartStmt, err = db.Prepare(selectThreePIDsForLocalpartSQL); err != nil {
|
{&s.insertThreePIDStmt, insertThreePIDSQL},
|
||||||
return
|
{&s.deleteThreePIDStmt, deleteThreePIDSQL},
|
||||||
}
|
}.Prepare(db)
|
||||||
if s.insertThreePIDStmt, err = db.Prepare(insertThreePIDSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if s.deleteThreePIDStmt, err = db.Prepare(deleteThreePIDSQL); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *threepidStatements) selectLocalpartForThreePID(
|
func (s *threepidStatements) selectLocalpartForThreePID(
|
||||||
|
Loading…
Reference in New Issue
Block a user