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-01-15 14:02:02 +0100
committerLibravatar GitHub <noreply@github.com>2024-01-15 14:02:02 +0100
commit637a57f2deb099d4be8b369f817a886642df79a6 (patch)
tree149d45ef15407570f2bd8af6cb4d4f4f6f8c62b9 /vendor/github.com/jackc/pgx/v5/large_objects.go
parent[chore]: Bump golang.org/x/net from 0.19.0 to 0.20.0 (#2533) (diff)
downloadgotosocial-637a57f2deb099d4be8b369f817a886642df79a6.tar.xz
[chore]: Bump github.com/jackc/pgx/v5 from 5.5.1 to 5.5.2 (#2532)
Bumps [github.com/jackc/pgx/v5](https://github.com/jackc/pgx) from 5.5.1 to 5.5.2. - [Changelog](https://github.com/jackc/pgx/blob/master/CHANGELOG.md) - [Commits](https://github.com/jackc/pgx/compare/v5.5.1...v5.5.2) --- updated-dependencies: - dependency-name: github.com/jackc/pgx/v5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/jackc/pgx/v5/large_objects.go')
-rw-r--r--vendor/github.com/jackc/pgx/v5/large_objects.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/vendor/github.com/jackc/pgx/v5/large_objects.go b/vendor/github.com/jackc/pgx/v5/large_objects.go
index c238ab9c2..676667450 100644
--- a/vendor/github.com/jackc/pgx/v5/large_objects.go
+++ b/vendor/github.com/jackc/pgx/v5/large_objects.go
@@ -67,6 +67,10 @@ type LargeObject struct {
}
// Write writes p to the large object and returns the number of bytes written and an error if not all of p was written.
+//
+// Write is implemented with a single call to lowrite. The PostgreSQL wire protocol has a limit of 1 GB - 1 per message.
+// See definition of PQ_LARGE_MESSAGE_LIMIT in the PostgreSQL source code. To allow for the other data in the message,
+// len(p) should be no larger than 1 GB - 1 KB.
func (o *LargeObject) Write(p []byte) (int, error) {
var n int
err := o.tx.QueryRow(o.ctx, "select lowrite($1, $2)", o.fd, p).Scan(&n)
@@ -82,6 +86,10 @@ func (o *LargeObject) Write(p []byte) (int, error) {
}
// Read reads up to len(p) bytes into p returning the number of bytes read.
+//
+// Read is implemented with a single call to loread. PostgreSQL internally allocates a single buffer for the response.
+// The largest buffer PostgreSQL will allocate is 1 GB - 1. See definition of MaxAllocSize in the PostgreSQL source
+// code. To allow for the other data in the message, len(p) should be no larger than 1 GB - 1 KB.
func (o *LargeObject) Read(p []byte) (int, error) {
var res []byte
err := o.tx.QueryRow(o.ctx, "select loread($1, $2)", o.fd, len(p)).Scan(&res)