Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui committed Nov 21, 2024
1 parent adf277e commit c6e6c35
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions go/transactions/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"fmt"
"io"
"os"
"slices"
"sort"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -51,10 +53,11 @@ type (
}

predicateInfo struct {
Table string
Col string
Op sqlparser.ComparisonExprOperator
Val int
Table string
Col string
Op sqlparser.ComparisonExprOperator
Val int
Signature string
}

state struct {
Expand All @@ -65,8 +68,12 @@ type (
}
)

func (pi predicateInfo) String() string {
return fmt.Sprintf("%s.%s %s %d", pi.Table, pi.Col, pi.Op.ToString(), pi.Val)
func (pi *predicateInfo) String() string {
if pi.Signature != "" {
return pi.Signature
}
pi.Signature = fmt.Sprintf("%s.%s %s %d", pi.Table, pi.Col, pi.Op.ToString(), pi.Val)
return pi.Signature
}

func (tx *TxSignature) MarshalJSON() ([]byte, error) {
Expand Down Expand Up @@ -320,6 +327,12 @@ func (s *state) consumeUpdate(query *sqlparser.Update, st *semantics.SemTable, n
func (s *state) addSignature(tx TxSignature) {
s.mu.Lock()
defer s.mu.Unlock()

slices.Sort(tx.Queries)
sort.Slice(tx.Predicates, func(i, j int) bool {
return tx.Predicates[i]

Check failure on line 333 in go/transactions/transactions.go

View workflow job for this annotation

GitHub Actions / test

cannot use tx.Predicates[i] (variable of type predicateInfo) as bool value in return statement
})

s.txs = append(s.txs, tx)
}

Expand Down

0 comments on commit c6e6c35

Please sign in to comment.