All sorts of debugging information and tweaks - still no joy
This commit is contained in:
parent
7a7be4f0ac
commit
49ff4d6d8f
|
@ -18,6 +18,7 @@ package sqlite3
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/roomserver/types"
|
"github.com/matrix-org/dendrite/roomserver/types"
|
||||||
)
|
)
|
||||||
|
@ -76,6 +77,7 @@ func (s *eventJSONStatements) bulkSelectEventJSON(
|
||||||
) ([]eventJSONPair, error) {
|
) ([]eventJSONPair, error) {
|
||||||
rows, err := s.bulkSelectEventJSONStmt.QueryContext(ctx, eventNIDsAsArray(eventNIDs))
|
rows, err := s.bulkSelectEventJSONStmt.QueryContext(ctx, eventNIDsAsArray(eventNIDs))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("bulkSelectEventJSON s.bulkSelectEventJSONStmt.QueryContext:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer rows.Close() // nolint: errcheck
|
defer rows.Close() // nolint: errcheck
|
||||||
|
@ -90,6 +92,7 @@ func (s *eventJSONStatements) bulkSelectEventJSON(
|
||||||
result := &results[i]
|
result := &results[i]
|
||||||
var eventNID int64
|
var eventNID int64
|
||||||
if err := rows.Scan(&eventNID, &result.EventJSON); err != nil {
|
if err := rows.Scan(&eventNID, &result.EventJSON); err != nil {
|
||||||
|
fmt.Println("bulkSelectEventJSON rows.Scan:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
result.EventNID = types.EventNID(eventNID)
|
result.EventNID = types.EventNID(eventNID)
|
||||||
|
|
|
@ -18,6 +18,7 @@ package sqlite3
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/lib/pq"
|
"github.com/lib/pq"
|
||||||
"github.com/matrix-org/dendrite/common"
|
"github.com/matrix-org/dendrite/common"
|
||||||
|
@ -95,6 +96,11 @@ func (s *eventStateKeyStatements) insertEventStateKeyNID(
|
||||||
selectStmt := common.TxStmt(txn, s.insertEventStateKeyNIDResultStmt)
|
selectStmt := common.TxStmt(txn, s.insertEventStateKeyNIDResultStmt)
|
||||||
if _, err = insertStmt.ExecContext(ctx, eventStateKey); err == nil {
|
if _, err = insertStmt.ExecContext(ctx, eventStateKey); err == nil {
|
||||||
err = selectStmt.QueryRowContext(ctx).Scan(&eventStateKeyNID)
|
err = selectStmt.QueryRowContext(ctx).Scan(&eventStateKeyNID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("insertEventStateKeyNID selectStmt.QueryRowContext:", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Println("insertEventStateKeyNID insertStmt.ExecContext:", err)
|
||||||
}
|
}
|
||||||
return types.EventStateKeyNID(eventStateKeyNID), err
|
return types.EventStateKeyNID(eventStateKeyNID), err
|
||||||
}
|
}
|
||||||
|
@ -105,6 +111,9 @@ func (s *eventStateKeyStatements) selectEventStateKeyNID(
|
||||||
var eventStateKeyNID int64
|
var eventStateKeyNID int64
|
||||||
stmt := common.TxStmt(txn, s.selectEventStateKeyNIDStmt)
|
stmt := common.TxStmt(txn, s.selectEventStateKeyNIDStmt)
|
||||||
err := stmt.QueryRowContext(ctx, eventStateKey).Scan(&eventStateKeyNID)
|
err := stmt.QueryRowContext(ctx, eventStateKey).Scan(&eventStateKeyNID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("selectEventStateKeyNID stmt.QueryRowContext:", err)
|
||||||
|
}
|
||||||
return types.EventStateKeyNID(eventStateKeyNID), err
|
return types.EventStateKeyNID(eventStateKeyNID), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +124,7 @@ func (s *eventStateKeyStatements) bulkSelectEventStateKeyNID(
|
||||||
ctx, pq.StringArray(eventStateKeys),
|
ctx, pq.StringArray(eventStateKeys),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("bulkSelectEventStateKeyNID s.bulkSelectEventStateKeyNIDStmt.QueryContext:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer rows.Close() // nolint: errcheck
|
defer rows.Close() // nolint: errcheck
|
||||||
|
@ -123,6 +133,7 @@ func (s *eventStateKeyStatements) bulkSelectEventStateKeyNID(
|
||||||
var stateKey string
|
var stateKey string
|
||||||
var stateKeyNID int64
|
var stateKeyNID int64
|
||||||
if err := rows.Scan(&stateKey, &stateKeyNID); err != nil {
|
if err := rows.Scan(&stateKey, &stateKeyNID); err != nil {
|
||||||
|
fmt.Println("bulkSelectEventStateKeyNID rows.Scan:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
result[stateKey] = types.EventStateKeyNID(stateKeyNID)
|
result[stateKey] = types.EventStateKeyNID(stateKeyNID)
|
||||||
|
@ -139,6 +150,7 @@ func (s *eventStateKeyStatements) bulkSelectEventStateKey(
|
||||||
}
|
}
|
||||||
rows, err := s.bulkSelectEventStateKeyStmt.QueryContext(ctx, nIDs)
|
rows, err := s.bulkSelectEventStateKeyStmt.QueryContext(ctx, nIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("bulkSelectEventStateKey s.bulkSelectEventStateKeyStmt.QueryContext:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer rows.Close() // nolint: errcheck
|
defer rows.Close() // nolint: errcheck
|
||||||
|
@ -147,6 +159,7 @@ func (s *eventStateKeyStatements) bulkSelectEventStateKey(
|
||||||
var stateKey string
|
var stateKey string
|
||||||
var stateKeyNID int64
|
var stateKeyNID int64
|
||||||
if err := rows.Scan(&stateKey, &stateKeyNID); err != nil {
|
if err := rows.Scan(&stateKey, &stateKeyNID); err != nil {
|
||||||
|
fmt.Println("bulkSelectEventStateKey rows.Scan:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
result[types.EventStateKeyNID(stateKeyNID)] = stateKey
|
result[types.EventStateKeyNID(stateKeyNID)] = stateKey
|
||||||
|
|
|
@ -247,6 +247,9 @@ func (s *eventStatements) updateEventState(
|
||||||
ctx context.Context, eventNID types.EventNID, stateNID types.StateSnapshotNID,
|
ctx context.Context, eventNID types.EventNID, stateNID types.StateSnapshotNID,
|
||||||
) error {
|
) error {
|
||||||
_, err := s.updateEventStateStmt.ExecContext(ctx, int64(eventNID), int64(stateNID))
|
_, err := s.updateEventStateStmt.ExecContext(ctx, int64(eventNID), int64(stateNID))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("updateEventState s.updateEventStateStmt.ExecContext:", err)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,12 +258,20 @@ func (s *eventStatements) selectEventSentToOutput(
|
||||||
) (sentToOutput bool, err error) {
|
) (sentToOutput bool, err error) {
|
||||||
stmt := common.TxStmt(txn, s.selectEventSentToOutputStmt)
|
stmt := common.TxStmt(txn, s.selectEventSentToOutputStmt)
|
||||||
err = stmt.QueryRowContext(ctx, int64(eventNID)).Scan(&sentToOutput)
|
err = stmt.QueryRowContext(ctx, int64(eventNID)).Scan(&sentToOutput)
|
||||||
|
//err = s.selectEventSentToOutputStmt.QueryRowContext(ctx, int64(eventNID)).Scan(&sentToOutput)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("selectEventSentToOutput stmt.QueryRowContext:", err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *eventStatements) updateEventSentToOutput(ctx context.Context, txn *sql.Tx, eventNID types.EventNID) error {
|
func (s *eventStatements) updateEventSentToOutput(ctx context.Context, txn *sql.Tx, eventNID types.EventNID) error {
|
||||||
stmt := common.TxStmt(txn, s.updateEventSentToOutputStmt)
|
stmt := common.TxStmt(txn, s.updateEventSentToOutputStmt)
|
||||||
_, err := stmt.ExecContext(ctx, int64(eventNID))
|
_, err := stmt.ExecContext(ctx, int64(eventNID))
|
||||||
|
//_, err := s.updateEventSentToOutputStmt.ExecContext(ctx, int64(eventNID))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("updateEventSentToOutput stmt.QueryRowContext:", err)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,6 +280,9 @@ func (s *eventStatements) selectEventID(
|
||||||
) (eventID string, err error) {
|
) (eventID string, err error) {
|
||||||
stmt := common.TxStmt(txn, s.selectEventIDStmt)
|
stmt := common.TxStmt(txn, s.selectEventIDStmt)
|
||||||
err = stmt.QueryRowContext(ctx, int64(eventNID)).Scan(&eventID)
|
err = stmt.QueryRowContext(ctx, int64(eventNID)).Scan(&eventID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("selectEventID stmt.QueryRowContext:", err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,8 +290,9 @@ func (s *eventStatements) bulkSelectStateAtEventAndReference(
|
||||||
ctx context.Context, txn *sql.Tx, eventNIDs []types.EventNID,
|
ctx context.Context, txn *sql.Tx, eventNIDs []types.EventNID,
|
||||||
) ([]types.StateAtEventAndReference, error) {
|
) ([]types.StateAtEventAndReference, error) {
|
||||||
stmt := common.TxStmt(txn, s.bulkSelectStateAtEventAndReferenceStmt)
|
stmt := common.TxStmt(txn, s.bulkSelectStateAtEventAndReferenceStmt)
|
||||||
rows, err := stmt.QueryContext(ctx, eventNIDsAsArray(eventNIDs))
|
rows, err := stmt.QueryContext(ctx, sqliteIn(eventNIDsAsArray(eventNIDs)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("bulkSelectStateAtEventAndREference stmt.QueryContext:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer rows.Close() // nolint: errcheck
|
defer rows.Close() // nolint: errcheck
|
||||||
|
@ -295,6 +310,7 @@ func (s *eventStatements) bulkSelectStateAtEventAndReference(
|
||||||
if err = rows.Scan(
|
if err = rows.Scan(
|
||||||
&eventTypeNID, &eventStateKeyNID, &eventNID, &stateSnapshotNID, &eventID, &eventSHA256,
|
&eventTypeNID, &eventStateKeyNID, &eventNID, &stateSnapshotNID, &eventID, &eventSHA256,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
|
fmt.Println("bulkSelectStateAtEventAndReference rows.Scan:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
result := &results[i]
|
result := &results[i]
|
||||||
|
@ -314,8 +330,9 @@ func (s *eventStatements) bulkSelectStateAtEventAndReference(
|
||||||
func (s *eventStatements) bulkSelectEventReference(
|
func (s *eventStatements) bulkSelectEventReference(
|
||||||
ctx context.Context, eventNIDs []types.EventNID,
|
ctx context.Context, eventNIDs []types.EventNID,
|
||||||
) ([]gomatrixserverlib.EventReference, error) {
|
) ([]gomatrixserverlib.EventReference, error) {
|
||||||
rows, err := s.bulkSelectEventReferenceStmt.QueryContext(ctx, eventNIDsAsArray(eventNIDs))
|
rows, err := s.bulkSelectEventReferenceStmt.QueryContext(ctx, sqliteIn(eventNIDsAsArray(eventNIDs)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("bulkSelectEventReference s.bulkSelectEventReferenceStmt.QueryContext:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer rows.Close() // nolint: errcheck
|
defer rows.Close() // nolint: errcheck
|
||||||
|
@ -324,6 +341,7 @@ func (s *eventStatements) bulkSelectEventReference(
|
||||||
for ; rows.Next(); i++ {
|
for ; rows.Next(); i++ {
|
||||||
result := &results[i]
|
result := &results[i]
|
||||||
if err = rows.Scan(&result.EventID, &result.EventSHA256); err != nil {
|
if err = rows.Scan(&result.EventID, &result.EventSHA256); err != nil {
|
||||||
|
fmt.Println("bulkSelectEventReference rows.Scan:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,8 +353,9 @@ func (s *eventStatements) bulkSelectEventReference(
|
||||||
|
|
||||||
// bulkSelectEventID returns a map from numeric event ID to string event ID.
|
// bulkSelectEventID returns a map from numeric event ID to string event ID.
|
||||||
func (s *eventStatements) bulkSelectEventID(ctx context.Context, eventNIDs []types.EventNID) (map[types.EventNID]string, error) {
|
func (s *eventStatements) bulkSelectEventID(ctx context.Context, eventNIDs []types.EventNID) (map[types.EventNID]string, error) {
|
||||||
rows, err := s.bulkSelectEventIDStmt.QueryContext(ctx, eventNIDsAsArray(eventNIDs))
|
rows, err := s.bulkSelectEventIDStmt.QueryContext(ctx, sqliteIn(eventNIDsAsArray(eventNIDs)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("bulkSelectEventID s.bulkSelectEventIDStmt.QueryContext:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer rows.Close() // nolint: errcheck
|
defer rows.Close() // nolint: errcheck
|
||||||
|
@ -346,6 +365,7 @@ func (s *eventStatements) bulkSelectEventID(ctx context.Context, eventNIDs []typ
|
||||||
var eventNID int64
|
var eventNID int64
|
||||||
var eventID string
|
var eventID string
|
||||||
if err = rows.Scan(&eventNID, &eventID); err != nil {
|
if err = rows.Scan(&eventNID, &eventID); err != nil {
|
||||||
|
fmt.Println("bulkSelectEventID rows.Scan:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
results[types.EventNID(eventNID)] = eventID
|
results[types.EventNID(eventNID)] = eventID
|
||||||
|
@ -361,6 +381,7 @@ func (s *eventStatements) bulkSelectEventID(ctx context.Context, eventNIDs []typ
|
||||||
func (s *eventStatements) bulkSelectEventNID(ctx context.Context, eventIDs []string) (map[string]types.EventNID, error) {
|
func (s *eventStatements) bulkSelectEventNID(ctx context.Context, eventIDs []string) (map[string]types.EventNID, error) {
|
||||||
rows, err := s.bulkSelectEventNIDStmt.QueryContext(ctx, pq.StringArray(eventIDs))
|
rows, err := s.bulkSelectEventNIDStmt.QueryContext(ctx, pq.StringArray(eventIDs))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("bulkSelectEventNID s.bulkSelectEventNIDStmt.QueryContext:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer rows.Close() // nolint: errcheck
|
defer rows.Close() // nolint: errcheck
|
||||||
|
@ -369,6 +390,7 @@ func (s *eventStatements) bulkSelectEventNID(ctx context.Context, eventIDs []str
|
||||||
var eventID string
|
var eventID string
|
||||||
var eventNID int64
|
var eventNID int64
|
||||||
if err = rows.Scan(&eventID, &eventNID); err != nil {
|
if err = rows.Scan(&eventID, &eventNID); err != nil {
|
||||||
|
fmt.Println("bulkSelectEventNID rows.Scan:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
results[eventID] = types.EventNID(eventNID)
|
results[eventID] = types.EventNID(eventNID)
|
||||||
|
@ -379,8 +401,9 @@ func (s *eventStatements) bulkSelectEventNID(ctx context.Context, eventIDs []str
|
||||||
func (s *eventStatements) selectMaxEventDepth(ctx context.Context, eventNIDs []types.EventNID) (int64, error) {
|
func (s *eventStatements) selectMaxEventDepth(ctx context.Context, eventNIDs []types.EventNID) (int64, error) {
|
||||||
var result int64
|
var result int64
|
||||||
stmt := s.selectMaxEventDepthStmt
|
stmt := s.selectMaxEventDepthStmt
|
||||||
err := stmt.QueryRowContext(ctx, eventNIDsAsArray(eventNIDs)).Scan(&result)
|
err := stmt.QueryRowContext(ctx, sqliteIn(eventNIDsAsArray(eventNIDs))).Scan(&result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("selectMaxEventDepth stmt.QueryRowContext:", err)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|
|
@ -18,6 +18,7 @@ package sqlite3
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/common"
|
"github.com/matrix-org/dendrite/common"
|
||||||
"github.com/matrix-org/dendrite/roomserver/types"
|
"github.com/matrix-org/dendrite/roomserver/types"
|
||||||
|
@ -83,14 +84,18 @@ func (s *inviteStatements) insertInviteEvent(
|
||||||
targetUserNID, senderUserNID types.EventStateKeyNID,
|
targetUserNID, senderUserNID types.EventStateKeyNID,
|
||||||
inviteEventJSON []byte,
|
inviteEventJSON []byte,
|
||||||
) (bool, error) {
|
) (bool, error) {
|
||||||
result, err := common.TxStmt(txn, s.insertInviteEventStmt).ExecContext(
|
stmt := common.TxStmt(txn, s.insertInviteEventStmt)
|
||||||
|
defer stmt.Close()
|
||||||
|
result, err := stmt.ExecContext(
|
||||||
ctx, inviteEventID, roomNID, targetUserNID, senderUserNID, inviteEventJSON,
|
ctx, inviteEventID, roomNID, targetUserNID, senderUserNID, inviteEventJSON,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("insertInviteEvent common.TxStmt.ExecContext:", err)
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
count, err := result.RowsAffected()
|
count, err := result.RowsAffected()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("insertInviteEvent result.RowsAffected:", err)
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
return count != 0, nil
|
return count != 0, nil
|
||||||
|
@ -103,12 +108,14 @@ func (s *inviteStatements) updateInviteRetired(
|
||||||
stmt := common.TxStmt(txn, s.updateInviteRetiredStmt)
|
stmt := common.TxStmt(txn, s.updateInviteRetiredStmt)
|
||||||
rows, err := stmt.QueryContext(ctx, roomNID, targetUserNID)
|
rows, err := stmt.QueryContext(ctx, roomNID, targetUserNID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("updateInviteRetired stmt.QueryContext:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer (func() { err = rows.Close() })()
|
defer (func() { err = rows.Close() })()
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var inviteEventID string
|
var inviteEventID string
|
||||||
if err := rows.Scan(&inviteEventID); err != nil {
|
if err := rows.Scan(&inviteEventID); err != nil {
|
||||||
|
fmt.Println("updateInviteRetired rows.Scan:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
eventIDs = append(eventIDs, inviteEventID)
|
eventIDs = append(eventIDs, inviteEventID)
|
||||||
|
@ -125,6 +132,7 @@ func (s *inviteStatements) selectInviteActiveForUserInRoom(
|
||||||
ctx, targetUserNID, roomNID,
|
ctx, targetUserNID, roomNID,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("selectInviteActiveForUserInRoom s.selectInviteActiveForUserInRoomStmt.QueryContext:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer rows.Close() // nolint: errcheck
|
defer rows.Close() // nolint: errcheck
|
||||||
|
@ -132,6 +140,7 @@ func (s *inviteStatements) selectInviteActiveForUserInRoom(
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var senderUserNID int64
|
var senderUserNID int64
|
||||||
if err := rows.Scan(&senderUserNID); err != nil {
|
if err := rows.Scan(&senderUserNID); err != nil {
|
||||||
|
fmt.Println("selectInviteActiveForUserInRoom rows.Scan:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
result = append(result, types.EventStateKeyNID(senderUserNID))
|
result = append(result, types.EventStateKeyNID(senderUserNID))
|
||||||
|
|
|
@ -18,6 +18,7 @@ package sqlite3
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/common"
|
"github.com/matrix-org/dendrite/common"
|
||||||
"github.com/matrix-org/dendrite/roomserver/types"
|
"github.com/matrix-org/dendrite/roomserver/types"
|
||||||
|
@ -100,6 +101,9 @@ func (s *membershipStatements) insertMembership(
|
||||||
) error {
|
) error {
|
||||||
stmt := common.TxStmt(txn, s.insertMembershipStmt)
|
stmt := common.TxStmt(txn, s.insertMembershipStmt)
|
||||||
_, err := stmt.ExecContext(ctx, roomNID, targetUserNID)
|
_, err := stmt.ExecContext(ctx, roomNID, targetUserNID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("insertMembership stmt.ExecContent:", err)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,9 +111,13 @@ func (s *membershipStatements) selectMembershipForUpdate(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
txn *sql.Tx, roomNID types.RoomNID, targetUserNID types.EventStateKeyNID,
|
txn *sql.Tx, roomNID types.RoomNID, targetUserNID types.EventStateKeyNID,
|
||||||
) (membership membershipState, err error) {
|
) (membership membershipState, err error) {
|
||||||
err = common.TxStmt(txn, s.selectMembershipForUpdateStmt).QueryRowContext(
|
stmt := common.TxStmt(txn, s.selectMembershipForUpdateStmt)
|
||||||
|
err = stmt.QueryRowContext(
|
||||||
ctx, roomNID, targetUserNID,
|
ctx, roomNID, targetUserNID,
|
||||||
).Scan(&membership)
|
).Scan(&membership)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("selectMembershipForUpdate common.TxStmt.Scan:", err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +128,9 @@ func (s *membershipStatements) selectMembershipFromRoomAndTarget(
|
||||||
err = s.selectMembershipFromRoomAndTargetStmt.QueryRowContext(
|
err = s.selectMembershipFromRoomAndTargetStmt.QueryRowContext(
|
||||||
ctx, roomNID, targetUserNID,
|
ctx, roomNID, targetUserNID,
|
||||||
).Scan(&membership, &eventNID)
|
).Scan(&membership, &eventNID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("selectMembershipForUpdate s.selectMembershipFromRoomAndTargetStmt.QueryRowContext:", err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,12 +139,14 @@ func (s *membershipStatements) selectMembershipsFromRoom(
|
||||||
) (eventNIDs []types.EventNID, err error) {
|
) (eventNIDs []types.EventNID, err error) {
|
||||||
rows, err := s.selectMembershipsFromRoomStmt.QueryContext(ctx, roomNID)
|
rows, err := s.selectMembershipsFromRoomStmt.QueryContext(ctx, roomNID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("selectMembershipsFromRoom s.selectMembershipsFromRoomStmt.QueryContext:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var eNID types.EventNID
|
var eNID types.EventNID
|
||||||
if err = rows.Scan(&eNID); err != nil {
|
if err = rows.Scan(&eNID); err != nil {
|
||||||
|
fmt.Println("selectMembershipsFromRoom rows.Scan:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
eventNIDs = append(eventNIDs, eNID)
|
eventNIDs = append(eventNIDs, eNID)
|
||||||
|
@ -147,12 +160,14 @@ func (s *membershipStatements) selectMembershipsFromRoomAndMembership(
|
||||||
stmt := s.selectMembershipsFromRoomAndMembershipStmt
|
stmt := s.selectMembershipsFromRoomAndMembershipStmt
|
||||||
rows, err := stmt.QueryContext(ctx, roomNID, membership)
|
rows, err := stmt.QueryContext(ctx, roomNID, membership)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("selectMembershipsFromRoomAndMembership stmt.QueryContext:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var eNID types.EventNID
|
var eNID types.EventNID
|
||||||
if err = rows.Scan(&eNID); err != nil {
|
if err = rows.Scan(&eNID); err != nil {
|
||||||
|
fmt.Println("selectMembershipsFromRoomAndMembership rows.Scan:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
eventNIDs = append(eventNIDs, eNID)
|
eventNIDs = append(eventNIDs, eNID)
|
||||||
|
@ -166,8 +181,12 @@ func (s *membershipStatements) updateMembership(
|
||||||
senderUserNID types.EventStateKeyNID, membership membershipState,
|
senderUserNID types.EventStateKeyNID, membership membershipState,
|
||||||
eventNID types.EventNID,
|
eventNID types.EventNID,
|
||||||
) error {
|
) error {
|
||||||
_, err := common.TxStmt(txn, s.updateMembershipStmt).ExecContext(
|
stmt := common.TxStmt(txn, s.updateMembershipStmt)
|
||||||
|
_, err := stmt.ExecContext(
|
||||||
ctx, roomNID, targetUserNID, senderUserNID, membership, eventNID,
|
ctx, roomNID, targetUserNID, senderUserNID, membership, eventNID,
|
||||||
)
|
)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("updateMembership common.TxStmt.ExecContent:", err)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ package sqlite3
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/common"
|
"github.com/matrix-org/dendrite/common"
|
||||||
"github.com/matrix-org/dendrite/roomserver/types"
|
"github.com/matrix-org/dendrite/roomserver/types"
|
||||||
|
@ -78,6 +79,9 @@ func (s *previousEventStatements) insertPreviousEvent(
|
||||||
_, err := stmt.ExecContext(
|
_, err := stmt.ExecContext(
|
||||||
ctx, previousEventID, previousEventReferenceSHA256, int64(eventNID),
|
ctx, previousEventID, previousEventReferenceSHA256, int64(eventNID),
|
||||||
)
|
)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("insertPreviousEvent stmt.ExecContext:", err)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,5 +92,8 @@ func (s *previousEventStatements) selectPreviousEventExists(
|
||||||
) error {
|
) error {
|
||||||
var ok int64
|
var ok int64
|
||||||
stmt := common.TxStmt(txn, s.selectPreviousEventExistsStmt)
|
stmt := common.TxStmt(txn, s.selectPreviousEventExistsStmt)
|
||||||
|
defer func() {
|
||||||
|
fmt.Println("SELECTED PREVIOUS EVENT EXISTS", ok)
|
||||||
|
}()
|
||||||
return stmt.QueryRowContext(ctx, eventID, eventReferenceSHA256).Scan(&ok)
|
return stmt.QueryRowContext(ctx, eventID, eventReferenceSHA256).Scan(&ok)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ package sqlite3
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const roomAliasesSchema = `
|
const roomAliasesSchema = `
|
||||||
|
@ -76,6 +77,9 @@ func (s *roomAliasesStatements) insertRoomAlias(
|
||||||
ctx context.Context, alias string, roomID string, creatorUserID string,
|
ctx context.Context, alias string, roomID string, creatorUserID string,
|
||||||
) (err error) {
|
) (err error) {
|
||||||
_, err = s.insertRoomAliasStmt.ExecContext(ctx, alias, roomID, creatorUserID)
|
_, err = s.insertRoomAliasStmt.ExecContext(ctx, alias, roomID, creatorUserID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("insertRoomAlias s.insertRoomAliasStmt.ExecContent:", err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,12 +99,14 @@ func (s *roomAliasesStatements) selectAliasesFromRoomID(
|
||||||
aliases = []string{}
|
aliases = []string{}
|
||||||
rows, err := s.selectAliasesFromRoomIDStmt.QueryContext(ctx, roomID)
|
rows, err := s.selectAliasesFromRoomIDStmt.QueryContext(ctx, roomID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("selectAliasesFromRoomID s.selectAliasesFromRoomIDStmt.QueryContext:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var alias string
|
var alias string
|
||||||
if err = rows.Scan(&alias); err != nil {
|
if err = rows.Scan(&alias); err != nil {
|
||||||
|
fmt.Println("selectAliasesFromRoomID rows.Scan:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ package sqlite3
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/lib/pq"
|
"github.com/lib/pq"
|
||||||
"github.com/matrix-org/dendrite/common"
|
"github.com/matrix-org/dendrite/common"
|
||||||
|
@ -90,6 +91,11 @@ func (s *roomStatements) insertRoomNID(
|
||||||
resultStmt := common.TxStmt(txn, s.insertRoomNIDResultStmt)
|
resultStmt := common.TxStmt(txn, s.insertRoomNIDResultStmt)
|
||||||
if _, err = insertStmt.ExecContext(ctx, roomID); err == nil {
|
if _, err = insertStmt.ExecContext(ctx, roomID); err == nil {
|
||||||
err = resultStmt.QueryRowContext(ctx).Scan(&roomNID)
|
err = resultStmt.QueryRowContext(ctx).Scan(&roomNID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("insertRoomNID resultStmt.QueryRowContext:", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Println("insertRoomNID insertStmt.ExecContext:", err)
|
||||||
}
|
}
|
||||||
return types.RoomNID(roomNID), err
|
return types.RoomNID(roomNID), err
|
||||||
}
|
}
|
||||||
|
@ -100,6 +106,9 @@ func (s *roomStatements) selectRoomNID(
|
||||||
var roomNID int64
|
var roomNID int64
|
||||||
stmt := common.TxStmt(txn, s.selectRoomNIDStmt)
|
stmt := common.TxStmt(txn, s.selectRoomNIDStmt)
|
||||||
err := stmt.QueryRowContext(ctx, roomID).Scan(&roomNID)
|
err := stmt.QueryRowContext(ctx, roomID).Scan(&roomNID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("selectRoomNID stmt.QueryRowContext:", err)
|
||||||
|
}
|
||||||
return types.RoomNID(roomNID), err
|
return types.RoomNID(roomNID), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +120,7 @@ func (s *roomStatements) selectLatestEventNIDs(
|
||||||
stmt := s.selectLatestEventNIDsStmt
|
stmt := s.selectLatestEventNIDsStmt
|
||||||
err := stmt.QueryRowContext(ctx, int64(roomNID)).Scan(&nids, &stateSnapshotNID)
|
err := stmt.QueryRowContext(ctx, int64(roomNID)).Scan(&nids, &stateSnapshotNID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("selectLatestEventNIDs stmt.QueryRowContext:", err)
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
eventNIDs := make([]types.EventNID, len(nids))
|
eventNIDs := make([]types.EventNID, len(nids))
|
||||||
|
@ -129,6 +139,7 @@ func (s *roomStatements) selectLatestEventsNIDsForUpdate(
|
||||||
stmt := common.TxStmt(txn, s.selectLatestEventNIDsForUpdateStmt)
|
stmt := common.TxStmt(txn, s.selectLatestEventNIDsForUpdateStmt)
|
||||||
err := stmt.QueryRowContext(ctx, int64(roomNID)).Scan(&nids, &lastEventSentNID, &stateSnapshotNID)
|
err := stmt.QueryRowContext(ctx, int64(roomNID)).Scan(&nids, &lastEventSentNID, &stateSnapshotNID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("selectLatestEventsNIDsForUpdate stmt.QueryRowContext:", err)
|
||||||
return nil, 0, 0, err
|
return nil, 0, 0, err
|
||||||
}
|
}
|
||||||
eventNIDs := make([]types.EventNID, len(nids))
|
eventNIDs := make([]types.EventNID, len(nids))
|
||||||
|
@ -154,5 +165,8 @@ func (s *roomStatements) updateLatestEventNIDs(
|
||||||
int64(lastEventSentNID),
|
int64(lastEventSentNID),
|
||||||
int64(stateSnapshotNID),
|
int64(stateSnapshotNID),
|
||||||
)
|
)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("updateLatestEventNIDs stmt.ExecContext:", err)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ const insertStateDataSQL = "" +
|
||||||
|
|
||||||
const selectNextStateBlockNIDSQL = `
|
const selectNextStateBlockNIDSQL = `
|
||||||
SELECT COALESCE((
|
SELECT COALESCE((
|
||||||
SELECT seq AS state_block_nid FROM sqlite_sequence
|
SELECT seq+1 AS state_block_nid FROM sqlite_sequence
|
||||||
WHERE name = 'roomserver_state_block'), 0
|
WHERE name = 'roomserver_state_block'), 0
|
||||||
) AS state_block_nid
|
) AS state_block_nid
|
||||||
`
|
`
|
||||||
|
@ -106,6 +106,7 @@ func (s *stateBlockStatements) bulkInsertStateData(
|
||||||
int64(entry.EventNID),
|
int64(entry.EventNID),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("bulkInsertStateData s.insertStateDataStmt.ExecContext:", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,8 +128,9 @@ func (s *stateBlockStatements) bulkSelectStateBlockEntries(
|
||||||
for i := range stateBlockNIDs {
|
for i := range stateBlockNIDs {
|
||||||
nids[i] = int64(stateBlockNIDs[i])
|
nids[i] = int64(stateBlockNIDs[i])
|
||||||
}
|
}
|
||||||
rows, err := s.bulkSelectStateBlockEntriesStmt.QueryContext(ctx, pq.Int64Array(nids))
|
rows, err := s.bulkSelectStateBlockEntriesStmt.QueryContext(ctx, sqliteIn(pq.Int64Array(nids)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("bulkSelectStateBlockEntries s.bulkSelectStateBlockEntriesStmt.QueryContext:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer rows.Close() // nolint: errcheck
|
defer rows.Close() // nolint: errcheck
|
||||||
|
@ -148,8 +150,10 @@ func (s *stateBlockStatements) bulkSelectStateBlockEntries(
|
||||||
if err := rows.Scan(
|
if err := rows.Scan(
|
||||||
&stateBlockNID, &eventTypeNID, &eventStateKeyNID, &eventNID,
|
&stateBlockNID, &eventTypeNID, &eventStateKeyNID, &eventNID,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
|
fmt.Println("bulkSelectStateBlockEntries rows.Scan:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
fmt.Println("state block NID", stateBlockNID, "event type NID", eventTypeNID, "event state key NID", eventStateKeyNID, "event NID", eventNID)
|
||||||
entry.EventTypeNID = types.EventTypeNID(eventTypeNID)
|
entry.EventTypeNID = types.EventTypeNID(eventTypeNID)
|
||||||
entry.EventStateKeyNID = types.EventStateKeyNID(eventStateKeyNID)
|
entry.EventStateKeyNID = types.EventStateKeyNID(eventStateKeyNID)
|
||||||
entry.EventNID = types.EventNID(eventNID)
|
entry.EventNID = types.EventNID(eventNID)
|
||||||
|
@ -162,8 +166,8 @@ func (s *stateBlockStatements) bulkSelectStateBlockEntries(
|
||||||
}
|
}
|
||||||
current.StateEntries = append(current.StateEntries, entry)
|
current.StateEntries = append(current.StateEntries, entry)
|
||||||
}
|
}
|
||||||
if i != len(stateBlockNIDs) {
|
if i != len(nids) {
|
||||||
return nil, fmt.Errorf("storage: state data NIDs missing from the database (%d != %d)", i, len(stateBlockNIDs))
|
return nil, fmt.Errorf("storage: state data NIDs missing from the database (%d != %d)", i, len(nids))
|
||||||
}
|
}
|
||||||
return results, nil
|
return results, nil
|
||||||
}
|
}
|
||||||
|
@ -182,9 +186,10 @@ func (s *stateBlockStatements) bulkSelectFilteredStateBlockEntries(
|
||||||
ctx,
|
ctx,
|
||||||
stateBlockNIDsAsArray(stateBlockNIDs),
|
stateBlockNIDsAsArray(stateBlockNIDs),
|
||||||
eventTypeNIDArray,
|
eventTypeNIDArray,
|
||||||
eventStateKeyNIDArray,
|
sqliteIn(eventStateKeyNIDArray),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("bulkSelectFilteredStateBlockEntries s.bulkSelectFilteredStateBlockEntriesStmt.QueryContext:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer rows.Close() // nolint: errcheck
|
defer rows.Close() // nolint: errcheck
|
||||||
|
@ -202,6 +207,7 @@ func (s *stateBlockStatements) bulkSelectFilteredStateBlockEntries(
|
||||||
if err := rows.Scan(
|
if err := rows.Scan(
|
||||||
&stateBlockNID, &eventTypeNID, &eventStateKeyNID, &eventNID,
|
&stateBlockNID, &eventTypeNID, &eventStateKeyNID, &eventNID,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
|
fmt.Println("bulkSelectFilteredStateBlockEntries rows.Scan:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
entry.EventTypeNID = types.EventTypeNID(eventTypeNID)
|
entry.EventTypeNID = types.EventTypeNID(eventTypeNID)
|
||||||
|
|
|
@ -77,6 +77,11 @@ func (s *stateSnapshotStatements) insertState(
|
||||||
}
|
}
|
||||||
if _, err = s.insertStateStmt.ExecContext(ctx, int64(roomNID), pq.Int64Array(nids)); err == nil {
|
if _, err = s.insertStateStmt.ExecContext(ctx, int64(roomNID), pq.Int64Array(nids)); err == nil {
|
||||||
err = s.insertStateResultStmt.QueryRowContext(ctx).Scan(&stateNID)
|
err = s.insertStateResultStmt.QueryRowContext(ctx).Scan(&stateNID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("insertState s.insertStateResultStmt.QueryRowContext:", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Println("insertState s.insertStateStmt.ExecContext:", err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -90,6 +95,7 @@ func (s *stateSnapshotStatements) bulkSelectStateBlockNIDs(
|
||||||
}
|
}
|
||||||
rows, err := s.bulkSelectStateBlockNIDsStmt.QueryContext(ctx, sqliteIn(pq.Int64Array(nids)))
|
rows, err := s.bulkSelectStateBlockNIDsStmt.QueryContext(ctx, sqliteIn(pq.Int64Array(nids)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("bulkSelectStateBlockNIDs s.bulkSelectStateBlockNIDsStmt.QueryContext:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer rows.Close() // nolint: errcheck
|
defer rows.Close() // nolint: errcheck
|
||||||
|
@ -99,6 +105,7 @@ func (s *stateSnapshotStatements) bulkSelectStateBlockNIDs(
|
||||||
result := &results[i]
|
result := &results[i]
|
||||||
var stateBlockNIDs pq.Int64Array
|
var stateBlockNIDs pq.Int64Array
|
||||||
if err := rows.Scan(&result.StateSnapshotNID, &stateBlockNIDs); err != nil {
|
if err := rows.Scan(&result.StateSnapshotNID, &stateBlockNIDs); err != nil {
|
||||||
|
fmt.Println("bulkSelectStateBlockNIDs rows.Scan:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
result.StateBlockNIDs = make([]types.StateBlockNID, len(stateBlockNIDs))
|
result.StateBlockNIDs = make([]types.StateBlockNID, len(stateBlockNIDs))
|
||||||
|
|
|
@ -18,6 +18,8 @@ package sqlite3
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/roomserver/api"
|
"github.com/matrix-org/dendrite/roomserver/api"
|
||||||
|
@ -39,16 +41,20 @@ func Open(dataSourceName string) (*Database, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
var cs string
|
||||||
if uri.Opaque != "" { // file:filename.db
|
if uri.Opaque != "" { // file:filename.db
|
||||||
if d.db, err = sql.Open("sqlite3", uri.Opaque); err != nil {
|
cs = fmt.Sprintf("%s?cache=shared&_busy_timeout=9999999", uri.Opaque)
|
||||||
|
} else if uri.Path != "" { // file:///path/to/filename.db
|
||||||
|
cs = fmt.Sprintf("%s?cache=shared&_busy_timeout=9999999", uri.Path)
|
||||||
|
} else {
|
||||||
|
return nil, errors.New("no filename or path in connect string")
|
||||||
|
}
|
||||||
|
if d.db, err = sql.Open("sqlite3", cs); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
//d.db.Exec("PRAGMA journal_mode=WAL;")
|
||||||
if uri.Path != "" { // file:///path/to/filename.db
|
//d.db.Exec("PRAGMA parser_trace = true;")
|
||||||
if d.db, err = sql.Open("sqlite3", uri.Path); err != nil {
|
d.db.SetMaxOpenConns(1)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err = d.statements.prepare(d.db); err != nil {
|
if err = d.statements.prepare(d.db); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ package sqlite3
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const transactionsSchema = `
|
const transactionsSchema = `
|
||||||
|
@ -66,6 +67,9 @@ func (s *transactionStatements) insertTransaction(
|
||||||
_, err = s.insertTransactionStmt.ExecContext(
|
_, err = s.insertTransactionStmt.ExecContext(
|
||||||
ctx, transactionID, sessionID, userID, eventID,
|
ctx, transactionID, sessionID, userID, eventID,
|
||||||
)
|
)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("insertTransaction s.insertTransactionStmt.ExecContent:", err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,5 +82,8 @@ func (s *transactionStatements) selectTransactionEventID(
|
||||||
err = s.selectTransactionEventIDStmt.QueryRowContext(
|
err = s.selectTransactionEventIDStmt.QueryRowContext(
|
||||||
ctx, transactionID, sessionID, userID,
|
ctx, transactionID, sessionID, userID,
|
||||||
).Scan(&eventID)
|
).Scan(&eventID)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("selectTransactionEventID s.selectTransactionEventIDStmt.QueryRowContext:", err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue