Add Composite type for inplace row() values handling
Composite() function returns a private type, which should be registered with ConnInfo.RegisterDataType for the composite type's OID. All subsequent interaction with Composite types is to be done via Row(...) function. Function return value can be either passed as a query argument to build SQL composite value out of individual fields or passed to Scan to read SQL composite value back. When passed to Scan, Row() should have first argument of type *bool to flag NULL values returned from query.
This commit is contained in:
@@ -167,6 +167,15 @@ func (f BinaryDecoderFunc) DecodeBinary(ci *ConnInfo, src []byte) error {
|
||||
return f(ci, src)
|
||||
}
|
||||
|
||||
//The BinaryEncoderFunc type is an adapter to allow the use of ordinary functions as BinaryDecoder types.
|
||||
// If f is a function with the appropriate signature, BinaryEncoderFunc(f) is a BinaryDecoder that calls f.
|
||||
type BinaryEncoderFunc func(ci *ConnInfo, buf []byte) ([]byte, error)
|
||||
|
||||
// EncodeBinary calls f(ci, buf)
|
||||
func (f BinaryEncoderFunc) EncodeBinary(ci *ConnInfo, buf []byte) (newBuf []byte, err error) {
|
||||
return f(ci, buf)
|
||||
}
|
||||
|
||||
var errUndefined = errors.New("cannot encode status undefined")
|
||||
var errBadStatus = errors.New("invalid status")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user