Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
gopub
pgxcrud
Commits
5e218ac9
Commit
5e218ac9
authored
4 years ago
by
Carsten Orthbandt
Browse files
Options
Download
Email Patches
Plain Diff
TXID alloc fix
parent
e9e076aa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
item.go
+2
-3
item.go
pgxcrud.go
+12
-0
pgxcrud.go
tx.go
+1
-1
tx.go
with
15 additions
and
4 deletions
+15
-4
item.go
+
2
-
3
View file @
5e218ac9
...
...
@@ -77,10 +77,9 @@ func (u *UUID) Set(s string) bool {
if
t
.
IsValid
()
{
*
u
=
t
return
true
}
else
{
u
.
Clear
()
return
false
}
u
.
Clear
()
return
false
}
// Generate overwrites a UUID with a new RFC4122 version 4 ID
...
...
This diff is collapsed.
Click to expand it.
pgxcrud.go
+
12
-
0
View file @
5e218ac9
...
...
@@ -7,6 +7,7 @@ import (
"reflect"
"sort"
"sync"
"time"
"git.pixeltamer.net/gopub/logfunk"
"github.com/jackc/pgconn"
...
...
@@ -211,7 +212,10 @@ func (env *Env) newTxID() int {
if
env
.
nxttxid
>
99
{
env
.
nxttxid
=
0
}
rep
:=
0
for
{
env
.
nxttxlock
.
Unlock
()
env
.
nxttxlock
.
Lock
()
_
,
ok
:=
env
.
nxttxmap
[
env
.
nxttxid
]
if
!
ok
{
id
:=
env
.
nxttxid
...
...
@@ -219,6 +223,14 @@ func (env *Env) newTxID() int {
env
.
nxttxlock
.
Unlock
()
return
id
}
env
.
nxttxid
++
if
env
.
nxttxid
>
99
{
env
.
nxttxid
=
0
rep
++
if
rep
>
2
{
time
.
Sleep
(
time
.
Millisecond
)
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
tx.go
+
1
-
1
View file @
5e218ac9
...
...
@@ -112,6 +112,7 @@ func (tx *Tx) closePending() {
tx
.
pendingRows
=
nil
}
// ResetErr sets the transaction last-error to nil
func
(
tx
*
Tx
)
ResetErr
()
{
tx
.
Err
=
nil
tx
.
Collision
=
false
...
...
@@ -145,7 +146,6 @@ func (tx *Tx) Commit(options ...OpOpt) error {
// Rollback cancels the transaction
func
(
tx
*
Tx
)
Rollback
(
options
...
OpOpt
)
error
{
defer
tx
.
freeTx
()
tx
.
TxID
+=
1000
ov
,
err
:=
tx
.
ovInit
(
otRollback
,
options
...
)
if
tx
.
Tx
==
nil
{
return
ErrNoTx
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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
Menu
Projects
Groups
Snippets
Help