5
5
# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
6
6
7
7
8
- cdef txid_snapshot_encode (CodecContext settings, WriteBuffer buf, obj):
8
+ cdef pg_snapshot_encode (CodecContext settings, WriteBuffer buf, obj):
9
9
cdef:
10
10
ssize_t nxip
11
- int64_t xmin
12
- int64_t xmax
11
+ uint64_t xmin
12
+ uint64_t xmax
13
13
int i
14
14
WriteBuffer xip_buf = WriteBuffer.new()
15
15
@@ -29,32 +29,34 @@ cdef txid_snapshot_encode(CodecContext settings, WriteBuffer buf, obj):
29
29
xmax = obj[1 ]
30
30
31
31
for i in range (nxip):
32
- xip_buf.write_int64(obj[2 ][i])
32
+ xip_buf.write_int64(
33
+ < int64_t> cpython.PyLong_AsUnsignedLongLong(obj[2 ][i]))
33
34
34
35
buf.write_int32(20 + xip_buf.len())
35
36
36
37
buf.write_int32(< int32_t> nxip)
37
- buf.write_int64(obj[ 0 ] )
38
- buf.write_int64(obj[ 1 ] )
38
+ buf.write_int64(< int64_t > xmin )
39
+ buf.write_int64(< int64_t > xmax )
39
40
buf.write_buffer(xip_buf)
40
41
41
42
42
- cdef txid_snapshot_decode (CodecContext settings, FRBuffer * buf):
43
+ cdef pg_snapshot_decode (CodecContext settings, FRBuffer * buf):
43
44
cdef:
44
45
int32_t nxip
45
- int64_t xmin
46
- int64_t xmax
46
+ uint64_t xmin
47
+ uint64_t xmax
47
48
tuple xip_tup
48
49
int32_t i
49
50
object xip
50
51
51
52
nxip = hton.unpack_int32(frb_read(buf, 4 ))
52
- xmin = hton.unpack_int64(frb_read(buf, 8 ))
53
- xmax = hton.unpack_int64(frb_read(buf, 8 ))
53
+ xmin = < uint64_t > hton.unpack_int64(frb_read(buf, 8 ))
54
+ xmax = < uint64_t > hton.unpack_int64(frb_read(buf, 8 ))
54
55
55
56
xip_tup = cpython.PyTuple_New(nxip)
56
57
for i in range (nxip):
57
- xip = cpython.PyLong_FromLongLong(hton.unpack_int64(frb_read(buf, 8 )))
58
+ xip = cpython.PyLong_FromUnsignedLongLong(
59
+ < uint64_t> hton.unpack_int64(frb_read(buf, 8 )))
58
60
cpython.Py_INCREF(xip)
59
61
cpython.PyTuple_SET_ITEM(xip_tup, i, xip)
60
62
0 commit comments