示例#1
0
def getvarsize1B(data, offset):
    if IS_BIGENDIAN:
        return pgstruct.getubyte(
            data, offset + memoffset['varattrib_1b.va_header']) & 0x7F
    else:
        return (pgstruct.getubyte(
            data, offset + memoffset['varattrib_1b.va_header']) >> 1) & 0x7F
示例#2
0
def getvarsize4B(data, offset):
    if IS_BIGENDIAN:
        return pgstruct.getubyte(
            data,
            offset + memoffset['varattrib_4b.va_4byte.va_header']) & 0x3FFFFFFF
    else:
        return (pgstruct.getubyte(
            data, offset + memoffset['varattrib_4b.va_4byte.va_header']) >>
                2) & 0x3FFFFFFF
示例#3
0
    def load(self, pagedata, tupleoff, heaptuplemode=True):
        if heaptuplemode:
            self.xmin = pgstruct.getuint(
                pagedata, tupleoff + memoffset['HeapTupleHeaderData.t_heap'] +
                memoffset['HeapTupleFields.t_xmin'])
            self.xmax = pgstruct.getuint(
                pagedata, tupleoff + memoffset['HeapTupleHeaderData.t_heap'] +
                memoffset['HeapTupleFields.t_xmax'])
            self.field3 = pgstruct.getuint(
                pagedata, tupleoff + memoffset['HeapTupleHeaderData.t_heap'] +
                memoffset['HeapTupleFields.t_field3'])
        else:
            self.datum_len_ = pgstruct.getuint(
                pagedata, tupleoff + memoffset['HeapTupleHeaderData.t_heap'] +
                memoffset['DatumTupleFields.datum_len_'])
            self.datum_typmod = pgstruct.getuint(
                pagedata, tupleoff + memoffset['HeapTupleHeaderData.t_heap'] +
                memoffset['DatumTupleFields.datum_typmod'])
            self.datum_typeid = pgstruct.getuint(
                pagedata, tupleoff + memoffset['HeapTupleHeaderData.t_heap'] +
                memoffset['DatumTupleFields.datum_typeid'])

        self.ctid_blkid_hi = pgstruct.getushort(
            pagedata, tupleoff + memoffset['HeapTupleHeaderData.t_ctid'] +
            memoffset['ItemPointerData.ip_blkid'] +
            memoffset['BlockIdData.bi_hi'])
        self.ctid_blkid_lo = pgstruct.getushort(
            pagedata, tupleoff + memoffset['HeapTupleHeaderData.t_ctid'] +
            memoffset['ItemPointerData.ip_blkid'] +
            memoffset['BlockIdData.bi_lo'])
        self.ctid_posid = pgstruct.getushort(
            pagedata, tupleoff + memoffset['HeapTupleHeaderData.t_ctid'] +
            memoffset['ItemPointerData.ip_posid'])

        self.infomask2 = pgstruct.getushort(
            pagedata, tupleoff + memoffset['HeapTupleHeaderData.t_infomask2'])
        self.infomask = pgstruct.getushort(
            pagedata, tupleoff + memoffset['HeapTupleHeaderData.t_infomask'])

        self.hoff = pgstruct.getubyte(
            pagedata, tupleoff + memoffset['HeapTupleHeaderData.t_hoff'])

        hasoid = (self.infomask & HeapTuple.HEAP_HASOID) != 0
        hasnull = (self.infomask & HeapTuple.HEAP_HASNULL) != 0
        if hasnull:
            nullbitlen = self.hoff - memoffset[
                'HeapTupleHeaderData.t_bits'] - (4 if hasoid else 0)
            self.bits = ctypes.string_at(
                ctypes.byref(
                    pagedata,
                    tupleoff + memoffset['HeapTupleHeaderData.t_bits']),
                nullbitlen)
        else:
            nullbitlen = 0
            self.bits = None
        if hasoid:
            self.oid = pgstruct.getuint(pagedata, tupleoff + self.hoff - 4)
        else:
            self.oid = None
示例#4
0
 def get_transid_status(self, xid):
     pageno = xid / self.CLOG_XACTS_PER_PAGE
     byteno = (xid % self.CLOG_XACTS_PER_PAGE) / self.CLOG_XACTS_PER_BYTE
     bshift = (xid % self.CLOG_XACTS_PER_BYTE) * self.CLOG_BITS_PER_XACT
     try:
         blockdata = self.getlrupage(pageno).data
     except UPgException:
         return TRANSACTION_STATUS_NOTFOUND
     bytevalue = pgstruct.getubyte(blockdata, byteno)
     status = (bytevalue >> bshift) & self.CLOG_XACT_BITMASK;
     return status
示例#5
0
 def get_transid_status(self, xid):
     pageno = xid / self.CLOG_XACTS_PER_PAGE
     byteno = (xid % self.CLOG_XACTS_PER_PAGE) / self.CLOG_XACTS_PER_BYTE
     bshift = (xid % self.CLOG_XACTS_PER_BYTE) * self.CLOG_BITS_PER_XACT
     try:
         blockdata = self.getlrupage(pageno).data
     except UPgException:
         return TRANSACTION_STATUS_NOTFOUND
     bytevalue = pgstruct.getubyte(blockdata, byteno)
     status = (bytevalue >> bshift) & self.CLOG_XACT_BITMASK
     return status
示例#6
0
 def load(self, pagedata, tupleoff, heaptuplemode = True):
     if heaptuplemode:
         self.xmin = pgstruct.getuint(pagedata, 
             tupleoff+memoffset['HeapTupleHeaderData.t_heap']+memoffset['HeapTupleFields.t_xmin'])
         self.xmax = pgstruct.getuint(pagedata, 
             tupleoff+memoffset['HeapTupleHeaderData.t_heap']+memoffset['HeapTupleFields.t_xmax'])
         self.field3 = pgstruct.getuint(pagedata, 
             tupleoff+memoffset['HeapTupleHeaderData.t_heap']+memoffset['HeapTupleFields.t_field3'])
     else:
         self.datum_len_ = pgstruct.getuint(pagedata, 
             tupleoff+memoffset['HeapTupleHeaderData.t_heap']+memoffset['DatumTupleFields.datum_len_'])
         self.datum_typmod = pgstruct.getuint(pagedata, 
             tupleoff+memoffset['HeapTupleHeaderData.t_heap']+memoffset['DatumTupleFields.datum_typmod'])
         self.datum_typeid = pgstruct.getuint(pagedata, 
             tupleoff+memoffset['HeapTupleHeaderData.t_heap']+memoffset['DatumTupleFields.datum_typeid'])
     
     self.ctid_blkid_hi =  pgstruct.getushort(pagedata, 
             tupleoff+memoffset['HeapTupleHeaderData.t_ctid']
             +memoffset['ItemPointerData.ip_blkid'] + memoffset['BlockIdData.bi_hi'])
     self.ctid_blkid_lo =  pgstruct.getushort(pagedata, 
             tupleoff+memoffset['HeapTupleHeaderData.t_ctid']
             +memoffset['ItemPointerData.ip_blkid'] + memoffset['BlockIdData.bi_lo'])
     self.ctid_posid =  pgstruct.getushort(pagedata, 
             tupleoff+memoffset['HeapTupleHeaderData.t_ctid']
             +memoffset['ItemPointerData.ip_posid'])
     
     self.infomask2 = pgstruct.getushort(pagedata, 
             tupleoff+memoffset['HeapTupleHeaderData.t_infomask2'])
     self.infomask = pgstruct.getushort(pagedata, 
             tupleoff+memoffset['HeapTupleHeaderData.t_infomask'])
     
     self.hoff = pgstruct.getubyte(pagedata, 
             tupleoff+memoffset['HeapTupleHeaderData.t_hoff'])
     
     hasoid = (self.infomask & HeapTuple.HEAP_HASOID) != 0
     hasnull = (self.infomask & HeapTuple.HEAP_HASNULL) != 0
     if hasnull:
         nullbitlen = self.hoff - memoffset['HeapTupleHeaderData.t_bits']- (4 if hasoid else 0)
         self.bits = ctypes.string_at(ctypes.byref(pagedata, tupleoff+memoffset['HeapTupleHeaderData.t_bits']), nullbitlen)
     else:
         nullbitlen = 0
         self.bits = None
     if hasoid:
         self.oid = pgstruct.getuint(pagedata, tupleoff+ self.hoff - 4)
     else:
         self.oid = None
示例#7
0
def getvartype(data, offset):
    b = pgstruct.getubyte(data, offset)
    if IS_BIGENDIAN:
        if b & 0x80 == 0:
            return '4B'
        if b & 0xC0 == 0:
            return '4B_U'
        if b & 0xC0 == 0x40:
            return '4B_C'
        if b & 0x80 == 0x80:
            return '1B'
        if b == 0x80:
            return '1B_E'
    else:
        if b & 0x01 == 0:
            return '4B'
        if b & 0x03 == 0:
            return '4B_U'
        if b & 0x03 == 0x02:
            return '4B_C'
        if b & 0x03 == 0x01:
            return '1B'
        if b == 0x01:
            return '1B_E'
示例#8
0
def boolout(data, off, len):
    if pgstruct.getubyte(data, off) != 0:
        return 'True'
    else:
        return 'False'
示例#9
0
def getexternalsize(data, offset):
    tag = pgstruct.getubyte(data, offset + memoffset['varattrib_1b_e.va_tag'])
    return memoffset['varattrib_1b_e.va_data'] + typesize[
        'varatt_indirect'] if tag == VARTAG_INDIRECT else typesize[
            'varatt_external']
示例#10
0
 def attisnull(self, attrnum):
     return not (pgstruct.getubyte(self.bits, attrnum >> 3) & (1 << ((attrnum) & 0x07)))    
示例#11
0
def boolout(data, off, len):
    if pgstruct.getubyte(data, off) != 0:
        return 'True'
    else:
        return 'False'
示例#12
0
 def attisnull(self, attrnum):
     return not (pgstruct.getubyte(self.bits, attrnum >> 3) &
                 (1 << ((attrnum) & 0x07)))