Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Vladimir Barsukov
zGo
Commits
480486a6
Commit
480486a6
authored
Aug 08, 2025
by
Vladimir Barsukov
Browse files
transaction
parent
40169f67
Changes
1
Show whitespace changes
Inline
Side-by-side
zdb/tx.go
View file @
480486a6
...
@@ -24,6 +24,12 @@ func (d *Pool) TxNew(ctx context.Context) (*Tx, error) {
...
@@ -24,6 +24,12 @@ func (d *Pool) TxNew(ctx context.Context) (*Tx, error) {
return
&
Tx
{
tx
:
pgTx
,
ctx
:
ctx
,
pool
:
d
},
err
return
&
Tx
{
tx
:
pgTx
,
ctx
:
ctx
,
pool
:
d
},
err
}
}
func
(
d
*
Pool
)
TxNewOpts
(
ctx
context
.
Context
,
opts
pgx
.
TxOptions
)
(
*
Tx
,
error
)
{
pgTx
,
err
:=
d
.
SrvMaster
.
BeginTx
(
ctx
,
opts
)
return
&
Tx
{
tx
:
pgTx
,
ctx
:
ctx
,
pool
:
d
},
err
}
func
(
d
*
Pool
)
MustTx
()
*
Tx
{
func
(
d
*
Pool
)
MustTx
()
*
Tx
{
tx
,
_
:=
d
.
TxNew
(
d
.
ctx
)
tx
,
_
:=
d
.
TxNew
(
d
.
ctx
)
...
@@ -53,7 +59,13 @@ func (t *Tx) Invoke(fn func(*Tx) error) error {
...
@@ -53,7 +59,13 @@ func (t *Tx) Invoke(fn func(*Tx) error) error {
return
err
return
err
}
}
return
t
.
Commit
()
if
err
:=
t
.
Commit
();
err
!=
nil
{
_
=
t
.
Rollback
()
return
err
}
return
nil
}
}
func
(
t
*
Tx
)
Get
(
dst
any
,
sql
string
,
args
...
any
)
error
{
func
(
t
*
Tx
)
Get
(
dst
any
,
sql
string
,
args
...
any
)
error
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment