mirror of https://github.com/jackc/pgx.git
36 lines
795 B
Go
36 lines
795 B
Go
package pgtype
|
|
|
|
import "fmt"
|
|
|
|
func (Int4) BinaryFormatSupported() bool {
|
|
return true
|
|
}
|
|
|
|
func (Int4) TextFormatSupported() bool {
|
|
return true
|
|
}
|
|
|
|
func (Int4) PreferredFormat() int16 {
|
|
return BinaryFormatCode
|
|
}
|
|
|
|
func (dst *Int4) DecodeResult(ci *ConnInfo, oid uint32, format int16, src []byte) error {
|
|
switch format {
|
|
case BinaryFormatCode:
|
|
return dst.DecodeBinary(ci, src)
|
|
case TextFormatCode:
|
|
return dst.DecodeText(ci, src)
|
|
}
|
|
return fmt.Errorf("unknown format code %d", format)
|
|
}
|
|
|
|
func (src Int4) EncodeParam(ci *ConnInfo, oid uint32, format int16, buf []byte) (newBuf []byte, err error) {
|
|
switch format {
|
|
case BinaryFormatCode:
|
|
return src.EncodeBinary(ci, buf)
|
|
case TextFormatCode:
|
|
return src.EncodeText(ci, buf)
|
|
}
|
|
return nil, fmt.Errorf("unknown format code %d", format)
|
|
}
|