Skip to content

Commit

Permalink
Fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
ncruces committed Nov 29, 2024
1 parent d2445c1 commit af38f9d
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions bulk.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (b *Bulk) Flush() error {
}

func (b *Bulk) AppendRow(args ...any) error {
retry:
buf := b.buffer

if off := len(buf); off != 0 {
Expand All @@ -71,18 +72,13 @@ func (b *Bulk) AppendRow(args ...any) error {
}
buf = append(buf, ')')

if len(buf)+len(b.suffix) >= cap(b.buffer)-len(b.buffer) {
if err := b.Flush(); err != nil {
return err
}
if buf[0] == ',' {
buf = buf[1:]
}
}
if len(buf)+len(b.suffix) >= cap(b.buffer)-len(b.buffer) {
return TOOBIG
if len(buf)+len(b.suffix) < cap(b.buffer)-len(b.buffer) {
b.buffer = b.buffer[:len(b.buffer)+len(buf)]
return nil
}

b.buffer = append(b.buffer, buf...)
return nil
if err := b.Flush(); err != nil {
return err
}
goto retry
}

0 comments on commit af38f9d

Please sign in to comment.