summaryrefslogtreecommitdiff
path: root/vendor/github.com/jackc/pgx/v5/pgproto3/data_row.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2024-03-11 10:13:33 +0000
committerLibravatar GitHub <noreply@github.com>2024-03-11 10:13:33 +0000
commitd115f9ebc4444c628269297f6d7ec427f7e5cf00 (patch)
tree242411bdcdf7c988700a52cc275eec20304db9c2 /vendor/github.com/jackc/pgx/v5/pgproto3/data_row.go
parent[chore]: Bump github.com/gin-contrib/cors from 1.5.0 to 1.7.0 (#2745) (diff)
downloadgotosocial-d115f9ebc4444c628269297f6d7ec427f7e5cf00.tar.xz
[chore]: Bump github.com/jackc/pgx/v5 from 5.5.3 to 5.5.5 (#2747)
Diffstat (limited to 'vendor/github.com/jackc/pgx/v5/pgproto3/data_row.go')
-rw-r--r--vendor/github.com/jackc/pgx/v5/pgproto3/data_row.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/vendor/github.com/jackc/pgx/v5/pgproto3/data_row.go b/vendor/github.com/jackc/pgx/v5/pgproto3/data_row.go
index 4de779772..fdfb0f7f6 100644
--- a/vendor/github.com/jackc/pgx/v5/pgproto3/data_row.go
+++ b/vendor/github.com/jackc/pgx/v5/pgproto3/data_row.go
@@ -4,6 +4,8 @@ import (
"encoding/binary"
"encoding/hex"
"encoding/json"
+ "errors"
+ "math"
"github.com/jackc/pgx/v5/internal/pgio"
)
@@ -63,11 +65,12 @@ func (dst *DataRow) Decode(src []byte) error {
}
// Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
-func (src *DataRow) Encode(dst []byte) []byte {
- dst = append(dst, 'D')
- sp := len(dst)
- dst = pgio.AppendInt32(dst, -1)
+func (src *DataRow) Encode(dst []byte) ([]byte, error) {
+ dst, sp := beginMessage(dst, 'D')
+ if len(src.Values) > math.MaxUint16 {
+ return nil, errors.New("too many values")
+ }
dst = pgio.AppendUint16(dst, uint16(len(src.Values)))
for _, v := range src.Values {
if v == nil {
@@ -79,9 +82,7 @@ func (src *DataRow) Encode(dst []byte) []byte {
dst = append(dst, v...)
}
- pgio.SetInt32(dst[sp:], int32(len(dst[sp:])))
-
- return dst
+ return finishMessage(dst, sp)
}
// MarshalJSON implements encoding/json.Marshaler.