Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions tidb/src/tidb/bank.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
(defn insert-bank-record! [conn {:keys [from to amount]}]
(c/execute! conn ["insert into records(account_id, amount) values (?, ?), (?, ?)"
from (- amount)
to amount]
{:transaction? false}))
to amount]))

(defn single-stmt-transfer! [conn test op]
(let [{:keys [from to amount]} (:value op)]
Expand Down Expand Up @@ -82,9 +81,11 @@
(let [{:keys [from to amount]} (:value op)]
(insert-bank-record! c {:from from :to to :amount amount})
op))]
; the :txn-info from fk-op is attached as :fk-txn-info
(cond-> op
(:txn-info fk-op) (assoc :fk-txn-info (:txn-info fk-op))))
; set the auto-commit back to true after the foreign key txn
(c/set-auto-commit! conn true)
; the :txn-info from fk-op is attached as :fk-txn-info
(cond-> op
(:txn-info fk-op) (assoc :fk-txn-info (:txn-info fk-op))))
op)]

(with-txn op [c conn {:isolation (util/isolation-level test)
Expand Down