mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-09 22:42:58 +00:00
Fix SQL statement for PurgeRoomState (#2280)
This commit is contained in:
parent
fc0bdf5d88
commit
d8facd6308
@ -71,8 +71,8 @@ const upsertRoomStateSQL = "" +
|
|||||||
const deleteRoomStateByEventIDSQL = "" +
|
const deleteRoomStateByEventIDSQL = "" +
|
||||||
"DELETE FROM syncapi_current_room_state WHERE event_id = $1"
|
"DELETE FROM syncapi_current_room_state WHERE event_id = $1"
|
||||||
|
|
||||||
const DeleteRoomStateForRoomSQL = "" +
|
const deleteRoomStateForRoomSQL = "" +
|
||||||
"DELETE FROM syncapi_current_room_state WHERE event_id = $1"
|
"DELETE FROM syncapi_current_room_state WHERE room_id = $1"
|
||||||
|
|
||||||
const selectRoomIDsWithMembershipSQL = "" +
|
const selectRoomIDsWithMembershipSQL = "" +
|
||||||
"SELECT DISTINCT room_id FROM syncapi_current_room_state WHERE type = 'm.room.member' AND state_key = $1 AND membership = $2"
|
"SELECT DISTINCT room_id FROM syncapi_current_room_state WHERE type = 'm.room.member' AND state_key = $1 AND membership = $2"
|
||||||
@ -107,7 +107,7 @@ const selectEventsWithEventIDsSQL = "" +
|
|||||||
type currentRoomStateStatements struct {
|
type currentRoomStateStatements struct {
|
||||||
upsertRoomStateStmt *sql.Stmt
|
upsertRoomStateStmt *sql.Stmt
|
||||||
deleteRoomStateByEventIDStmt *sql.Stmt
|
deleteRoomStateByEventIDStmt *sql.Stmt
|
||||||
DeleteRoomStateForRoomStmt *sql.Stmt
|
deleteRoomStateForRoomStmt *sql.Stmt
|
||||||
selectRoomIDsWithMembershipStmt *sql.Stmt
|
selectRoomIDsWithMembershipStmt *sql.Stmt
|
||||||
selectRoomIDsWithAnyMembershipStmt *sql.Stmt
|
selectRoomIDsWithAnyMembershipStmt *sql.Stmt
|
||||||
selectCurrentStateStmt *sql.Stmt
|
selectCurrentStateStmt *sql.Stmt
|
||||||
@ -128,7 +128,7 @@ func NewPostgresCurrentRoomStateTable(db *sql.DB) (tables.CurrentRoomState, erro
|
|||||||
if s.deleteRoomStateByEventIDStmt, err = db.Prepare(deleteRoomStateByEventIDSQL); err != nil {
|
if s.deleteRoomStateByEventIDStmt, err = db.Prepare(deleteRoomStateByEventIDSQL); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if s.DeleteRoomStateForRoomStmt, err = db.Prepare(DeleteRoomStateForRoomSQL); err != nil {
|
if s.deleteRoomStateForRoomStmt, err = db.Prepare(deleteRoomStateForRoomSQL); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if s.selectRoomIDsWithMembershipStmt, err = db.Prepare(selectRoomIDsWithMembershipSQL); err != nil {
|
if s.selectRoomIDsWithMembershipStmt, err = db.Prepare(selectRoomIDsWithMembershipSQL); err != nil {
|
||||||
@ -261,7 +261,7 @@ func (s *currentRoomStateStatements) DeleteRoomStateByEventID(
|
|||||||
func (s *currentRoomStateStatements) DeleteRoomStateForRoom(
|
func (s *currentRoomStateStatements) DeleteRoomStateForRoom(
|
||||||
ctx context.Context, txn *sql.Tx, roomID string,
|
ctx context.Context, txn *sql.Tx, roomID string,
|
||||||
) error {
|
) error {
|
||||||
stmt := sqlutil.TxStmt(txn, s.DeleteRoomStateForRoomStmt)
|
stmt := sqlutil.TxStmt(txn, s.deleteRoomStateForRoomStmt)
|
||||||
_, err := stmt.ExecContext(ctx, roomID)
|
_, err := stmt.ExecContext(ctx, roomID)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,8 @@ const upsertRoomStateSQL = "" +
|
|||||||
const deleteRoomStateByEventIDSQL = "" +
|
const deleteRoomStateByEventIDSQL = "" +
|
||||||
"DELETE FROM syncapi_current_room_state WHERE event_id = $1"
|
"DELETE FROM syncapi_current_room_state WHERE event_id = $1"
|
||||||
|
|
||||||
const DeleteRoomStateForRoomSQL = "" +
|
const deleteRoomStateForRoomSQL = "" +
|
||||||
"DELETE FROM syncapi_current_room_state WHERE event_id = $1"
|
"DELETE FROM syncapi_current_room_state WHERE room_id = $1"
|
||||||
|
|
||||||
const selectRoomIDsWithMembershipSQL = "" +
|
const selectRoomIDsWithMembershipSQL = "" +
|
||||||
"SELECT DISTINCT room_id FROM syncapi_current_room_state WHERE type = 'm.room.member' AND state_key = $1 AND membership = $2"
|
"SELECT DISTINCT room_id FROM syncapi_current_room_state WHERE type = 'm.room.member' AND state_key = $1 AND membership = $2"
|
||||||
@ -93,7 +93,7 @@ type currentRoomStateStatements struct {
|
|||||||
streamIDStatements *streamIDStatements
|
streamIDStatements *streamIDStatements
|
||||||
upsertRoomStateStmt *sql.Stmt
|
upsertRoomStateStmt *sql.Stmt
|
||||||
deleteRoomStateByEventIDStmt *sql.Stmt
|
deleteRoomStateByEventIDStmt *sql.Stmt
|
||||||
DeleteRoomStateForRoomStmt *sql.Stmt
|
deleteRoomStateForRoomStmt *sql.Stmt
|
||||||
selectRoomIDsWithMembershipStmt *sql.Stmt
|
selectRoomIDsWithMembershipStmt *sql.Stmt
|
||||||
selectRoomIDsWithAnyMembershipStmt *sql.Stmt
|
selectRoomIDsWithAnyMembershipStmt *sql.Stmt
|
||||||
selectJoinedUsersStmt *sql.Stmt
|
selectJoinedUsersStmt *sql.Stmt
|
||||||
@ -115,7 +115,7 @@ func NewSqliteCurrentRoomStateTable(db *sql.DB, streamID *streamIDStatements) (t
|
|||||||
if s.deleteRoomStateByEventIDStmt, err = db.Prepare(deleteRoomStateByEventIDSQL); err != nil {
|
if s.deleteRoomStateByEventIDStmt, err = db.Prepare(deleteRoomStateByEventIDSQL); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if s.DeleteRoomStateForRoomStmt, err = db.Prepare(DeleteRoomStateForRoomSQL); err != nil {
|
if s.deleteRoomStateForRoomStmt, err = db.Prepare(deleteRoomStateForRoomSQL); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if s.selectRoomIDsWithMembershipStmt, err = db.Prepare(selectRoomIDsWithMembershipSQL); err != nil {
|
if s.selectRoomIDsWithMembershipStmt, err = db.Prepare(selectRoomIDsWithMembershipSQL); err != nil {
|
||||||
@ -246,7 +246,7 @@ func (s *currentRoomStateStatements) DeleteRoomStateByEventID(
|
|||||||
func (s *currentRoomStateStatements) DeleteRoomStateForRoom(
|
func (s *currentRoomStateStatements) DeleteRoomStateForRoom(
|
||||||
ctx context.Context, txn *sql.Tx, roomID string,
|
ctx context.Context, txn *sql.Tx, roomID string,
|
||||||
) error {
|
) error {
|
||||||
stmt := sqlutil.TxStmt(txn, s.DeleteRoomStateForRoomStmt)
|
stmt := sqlutil.TxStmt(txn, s.deleteRoomStateForRoomStmt)
|
||||||
_, err := stmt.ExecContext(ctx, roomID)
|
_, err := stmt.ExecContext(ctx, roomID)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user