1
|
|
|
package postgres |
2
|
|
|
|
3
|
|
|
import ( |
4
|
|
|
"database/sql/driver" |
5
|
|
|
|
6
|
|
|
"github.com/jackc/pgtype" |
7
|
|
|
) |
8
|
|
|
|
9
|
|
|
// XID8 represents a PostgreSQL xid8 (64-bit transaction ID) type |
10
|
|
|
type XID8 pguint64 |
11
|
|
|
|
12
|
|
|
// pgSnapshot represents a PostgreSQL snapshot type |
13
|
|
|
type pgSnapshot struct { |
14
|
|
|
pgtype.Value |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
// Set sets the XID8 value from various input types |
18
|
|
|
func (x *XID8) Set(src interface{}) error { |
19
|
|
|
return (*pguint64)(x).Set(src) |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
// Get returns the underlying value |
23
|
|
|
func (x XID8) Get() interface{} { |
24
|
|
|
return (pguint64)(x).Get() |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
// AssignTo assigns the value to the destination |
28
|
|
|
func (x *XID8) AssignTo(dst interface{}) error { |
29
|
|
|
return (*pguint64)(x).AssignTo(dst) |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
// DecodeText decodes text format |
33
|
|
|
func (x *XID8) DecodeText(ci *pgtype.ConnInfo, src []byte) error { |
34
|
|
|
return (*pguint64)(x).DecodeText(ci, src) |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
// DecodeBinary decodes binary format |
38
|
|
|
func (x *XID8) DecodeBinary(ci *pgtype.ConnInfo, src []byte) error { |
39
|
|
|
return (*pguint64)(x).DecodeBinary(ci, src) |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
// EncodeText encodes to text format |
43
|
|
|
func (x XID8) EncodeText(ci *pgtype.ConnInfo, buf []byte) ([]byte, error) { |
44
|
|
|
return (pguint64)(x).EncodeText(ci, buf) |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
// EncodeBinary encodes to binary format |
48
|
|
|
func (x XID8) EncodeBinary(ci *pgtype.ConnInfo, buf []byte) ([]byte, error) { |
49
|
|
|
return (pguint64)(x).EncodeBinary(ci, buf) |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
// Scan implements the database/sql Scanner interface |
53
|
|
|
func (x *XID8) Scan(src interface{}) error { |
54
|
|
|
return (*pguint64)(x).Scan(src) |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
// Value implements the database/sql/driver Valuer interface |
58
|
|
|
func (x XID8) Value() (driver.Value, error) { |
59
|
|
|
return (pguint64)(x).Value() |
60
|
|
|
} |
61
|
|
|
|