@@ -234,7 +234,9 @@ cdef class BaseThinDbObjectTypeCache:
234234 typ_impl.collection_flags = TNS_OBJ_HAS_INDEXES
235235 buf.skip_to(pos)
236236 typ_impl.element_dbtype = self ._parse_tds_attr(
237- buf, & typ_impl._element_preferred_num_type
237+ buf, & typ_impl.element_precision, & typ_impl.element_scale,
238+ & typ_impl.element_max_size,
239+ & typ_impl._element_preferred_num_type
238240 )
239241 if typ_impl.element_dbtype is DB_TYPE_CLOB:
240242 return self ._get_element_type_clob(typ_impl)
@@ -244,16 +246,22 @@ cdef class BaseThinDbObjectTypeCache:
244246 # handle objects with attributes
245247 else :
246248 for i, attr_impl in enumerate (typ_impl.attrs):
247- self ._parse_tds_attr(buf, & attr_impl._preferred_num_type)
249+ self ._parse_tds_attr(buf, & attr_impl.precision,
250+ & attr_impl.scale, & attr_impl.max_size,
251+ & attr_impl._preferred_num_type)
248252
249- cdef DbType _parse_tds_attr(self , TDSBuffer buf, int * preferred_num_type):
253+ cdef DbType _parse_tds_attr(self , TDSBuffer buf, int8_t* precision,
254+ int8_t* scale, uint32_t * max_size,
255+ int * preferred_num_type):
250256 """
251257 Parses a TDS attribute from the buffer.
252258 """
253259 cdef:
254260 uint8_t attr_type, ora_type_num = 0 , csfrm = 0
261+ int8_t temp_precision, temp_scale
255262 int temp_preferred_num_type
256- int8_t precision, scale
263+ uint32_t temp_max_size
264+ uint16_t temp16
257265
258266 # skip until a type code that is of interest
259267 while True :
@@ -266,14 +274,16 @@ cdef class BaseThinDbObjectTypeCache:
266274 # process the type code
267275 if attr_type == TNS_OBJ_TDS_TYPE_NUMBER:
268276 ora_type_num = TNS_DATA_TYPE_NUMBER
269- buf.read_sb1(& precision)
270- buf.read_sb1(& scale)
271- preferred_num_type[0 ] = get_preferred_num_type(precision, scale)
277+ buf.read_sb1(precision)
278+ buf.read_sb1(scale)
279+ preferred_num_type[0 ] = \
280+ get_preferred_num_type(precision[0 ], scale[0 ])
272281 elif attr_type == TNS_OBJ_TDS_TYPE_FLOAT:
273282 ora_type_num = TNS_DATA_TYPE_NUMBER
274283 buf.skip_raw_bytes(1 ) # precision
275284 elif attr_type in (TNS_OBJ_TDS_TYPE_VARCHAR, TNS_OBJ_TDS_TYPE_CHAR):
276- buf.skip_raw_bytes(2 ) # maximum length
285+ buf.read_uint16(& temp16) # maximum length
286+ max_size[0 ] = temp16
277287 buf.read_ub1(& csfrm)
278288 csfrm = csfrm & 0x7f
279289 buf.skip_raw_bytes(2 ) # character set
@@ -282,7 +292,8 @@ cdef class BaseThinDbObjectTypeCache:
282292 else :
283293 ora_type_num = TNS_DATA_TYPE_CHAR
284294 elif attr_type == TNS_OBJ_TDS_TYPE_RAW:
285- buf.skip_raw_bytes(2 ) # maximum length
295+ buf.read_uint16(& temp16) # maximum length
296+ max_size[0 ] = temp16
286297 ora_type_num = TNS_DATA_TYPE_RAW
287298 elif attr_type == TNS_OBJ_TDS_TYPE_BINARY_FLOAT:
288299 ora_type_num = TNS_DATA_TYPE_BINARY_FLOAT
@@ -311,7 +322,9 @@ cdef class BaseThinDbObjectTypeCache:
311322 buf.skip_raw_bytes(5 ) # offset and code
312323 elif attr_type == TNS_OBJ_TDS_TYPE_START_EMBED_ADT:
313324 ora_type_num = TNS_DATA_TYPE_INT_NAMED
314- while self ._parse_tds_attr(buf, & temp_preferred_num_type):
325+ while self ._parse_tds_attr(buf, & temp_precision, & temp_scale,
326+ & temp_max_size,
327+ & temp_preferred_num_type):
315328 pass
316329 elif attr_type == TNS_OBJ_TDS_TYPE_END_EMBED_ADT:
317330 return None
0 commit comments