From dc77e7c2da14312ae3362862f17201fee93f81bc Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 29 Jan 2022 08:17:50 -0600 Subject: [PATCH] Add QueryRow warning to DriverBytes --- pgtype/bytea.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pgtype/bytea.go b/pgtype/bytea.go index 501e0c59..58f3b348 100644 --- a/pgtype/bytea.go +++ b/pgtype/bytea.go @@ -16,8 +16,9 @@ type BytesValuer interface { BytesValue() ([]byte, error) } -// DriverBytes is a byte slice that holds a reference to memory owned by the driver. It is only valid until the next -// database method call. e.g. Any call to a Rows or Conn method invalidates the slice. +// DriverBytes is a byte slice that holds a reference to memory owned by the driver. It is only valid from the time it +// is scanned until Rows.Next or Rows.Close is called. It is safe to use in a function passed to QueryFunc. It is never +// safe to use DriverBytes with QueryRow as Row.Scan internally calls Rows.Close before returning. type DriverBytes []byte func (b *DriverBytes) ScanBytes(v []byte) error {