55# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
66
77
8- cdef txid_snapshot_encode (CodecContext settings, WriteBuffer buf, obj):
8+ cdef pg_snapshot_encode (CodecContext settings, WriteBuffer buf, obj):
99 cdef:
1010 ssize_t nxip
11- int64_t xmin
12- int64_t xmax
11+ uint64_t xmin
12+ uint64_t xmax
1313 int i
1414 WriteBuffer xip_buf = WriteBuffer.new()
1515
@@ -29,32 +29,34 @@ cdef txid_snapshot_encode(CodecContext settings, WriteBuffer buf, obj):
2929 xmax = obj[1 ]
3030
3131 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]))
3334
3435 buf.write_int32(20 + xip_buf.len())
3536
3637 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 )
3940 buf.write_buffer(xip_buf)
4041
4142
42- cdef txid_snapshot_decode (CodecContext settings, FRBuffer * buf):
43+ cdef pg_snapshot_decode (CodecContext settings, FRBuffer * buf):
4344 cdef:
4445 int32_t nxip
45- int64_t xmin
46- int64_t xmax
46+ uint64_t xmin
47+ uint64_t xmax
4748 tuple xip_tup
4849 int32_t i
4950 object xip
5051
5152 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 ))
5455
5556 xip_tup = cpython.PyTuple_New(nxip)
5657 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 )))
5860 cpython.Py_INCREF(xip)
5961 cpython.PyTuple_SET_ITEM(xip_tup, i, xip)
6062
0 commit comments