@@ -791,14 +791,20 @@ cdef class Buffer:
791791 cdef const char_type * ptr = self ._get_raw(4 )
792792 value[0 ] = unpack_uint32(ptr, byte_order)
793793
794- cdef object read_xmltype(self ):
794+ cdef object read_xmltype(self , ThinConnImpl conn_impl ):
795795 """
796796 Reads an XMLType value from the buffer and returns the string value.
797797 The XMLType object is a special DbObjectType and is handled separately
798798 since the structure is a bit different.
799799 """
800800 cdef:
801+ uint8_t image_flags, image_version
802+ DbObjectPickleBuffer buf
803+ ThinLobImpl lob_impl
804+ const char_type * ptr
801805 uint32_t num_bytes
806+ ssize_t bytes_left
807+ uint32_t xml_flag
802808 bytes packed_data
803809 self .read_ub4(& num_bytes)
804810 if num_bytes > 0 : # type OID
@@ -814,7 +820,22 @@ cdef class Buffer:
814820 self .skip_ub2() # flags
815821 if num_bytes > 0 :
816822 packed_data = self .read_bytes()
817- return packed_data[12 :].decode()
823+ buf = DbObjectPickleBuffer.__new__ (DbObjectPickleBuffer)
824+ buf._populate_from_bytes(packed_data)
825+ buf.read_header(& image_flags, & image_version)
826+ buf.skip_raw_bytes(1 ) # XML version
827+ buf.read_uint32(& xml_flag)
828+ if xml_flag & TNS_XML_TYPE_FLAG_SKIP_NEXT_4:
829+ buf.skip_raw_bytes(4 )
830+ bytes_left = buf.bytes_left()
831+ ptr = buf.read_raw_bytes(bytes_left)
832+ if xml_flag & TNS_XML_TYPE_STRING:
833+ return ptr[:bytes_left].decode()
834+ elif xml_flag & TNS_XML_TYPE_LOB:
835+ lob_impl = ThinLobImpl._create(conn_impl, DB_TYPE_CLOB,
836+ ptr[:bytes_left])
837+ return PY_TYPE_LOB._from_impl(lob_impl)
838+ errors._raise_err(errors.ERR_UNEXPECTED_XML_TYPE, flag = xml_flag)
818839
819840 cdef int skip_raw_bytes(self , ssize_t num_bytes) except - 1 :
820841 """
0 commit comments