summaryrefslogtreecommitdiff
path: root/vendor/github.com/jackc/pgx/v5/large_objects.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2024-05-27 09:35:41 +0000
committerLibravatar GitHub <noreply@github.com>2024-05-27 09:35:41 +0000
commit0a18c0d802ce76cac5eb4cf2dae53c6e42536601 (patch)
tree8d28ddc527edcb323cbdba9330e7b705bdcf6c59 /vendor/github.com/jackc/pgx/v5/large_objects.go
parent[performance] update storage backend and make use of seek syscall when availa... (diff)
downloadgotosocial-0a18c0d802ce76cac5eb4cf2dae53c6e42536601.tar.xz
[chore]: Bump github.com/jackc/pgx/v5 from 5.5.5 to 5.6.0 (#2929)
Diffstat (limited to 'vendor/github.com/jackc/pgx/v5/large_objects.go')
-rw-r--r--vendor/github.com/jackc/pgx/v5/large_objects.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/vendor/github.com/jackc/pgx/v5/large_objects.go b/vendor/github.com/jackc/pgx/v5/large_objects.go
index a3028b638..9d21afdce 100644
--- a/vendor/github.com/jackc/pgx/v5/large_objects.go
+++ b/vendor/github.com/jackc/pgx/v5/large_objects.go
@@ -4,6 +4,8 @@ import (
"context"
"errors"
"io"
+
+ "github.com/jackc/pgx/v5/pgtype"
)
// The PostgreSQL wire protocol has a limit of 1 GB - 1 per message. See definition of
@@ -115,9 +117,10 @@ func (o *LargeObject) Read(p []byte) (int, error) {
expected = maxLargeObjectMessageLength
}
- var res []byte
+ res := pgtype.PreallocBytes(p[nTotal:])
err := o.tx.QueryRow(o.ctx, "select loread($1, $2)", o.fd, expected).Scan(&res)
- copy(p[nTotal:], res)
+ // We compute expected so that it always fits into p, so it should never happen
+ // that PreallocBytes's ScanBytes had to allocate a new slice.
nTotal += len(res)
if err != nil {
return nTotal, err