@@ -269,6 +269,38 @@ parse_schema_space_value(struct schema_space_value *space_string,
269269 return -1 ;
270270}
271271
272+ /**
273+ * 1.6.6-1.7.5
274+ * Decode parts array from tuple field.
275+ */
276+ static int
277+ decode_index_parts_166 (struct schema_field_value * parts , uint32_t part_count ,
278+ const char * * data )
279+ {
280+ for (uint32_t i = 0 ; i < part_count ; ++ i ) {
281+ struct schema_field_value * part = & parts [i ];
282+ if (mp_typeof (* * data ) != MP_ARRAY )
283+ return -1 ;
284+ uint32_t item_count = mp_decode_array (data );
285+ if (item_count < 2 )
286+ return -1 ;
287+
288+ if (mp_typeof (* * data ) != MP_UINT )
289+ return -1 ;
290+ part -> field_number = mp_decode_uint (data );
291+
292+ if (mp_typeof (* * data ) != MP_STR )
293+ return -1 ;
294+ uint32_t len ;
295+ const char * str = mp_decode_str (data , & len );
296+ part -> field_type = parse_field_type (str , len );
297+
298+ for (uint32_t j = 2 ; j < item_count ; ++ j )
299+ mp_next (data );
300+ }
301+ return 0 ;
302+ }
303+
272304static int
273305parse_schema_index_value (struct schema_index_value * index_string ,
274306 const char * * tuple ) {
@@ -283,23 +315,12 @@ parse_schema_index_value(struct schema_index_value *index_string,
283315 goto error ;
284316 memset (index_string -> index_parts , 0 , part_count *
285317 sizeof (struct schema_field_value ));
286- int i = 0 ;
287- for (i = 0 ; i < part_count ; ++ i ) {
288- if (mp_typeof (* * tuple ) != MP_ARRAY )
289- goto error ;
290- if (mp_decode_array (tuple ) != 2 )
291- goto error ;
292- struct schema_field_value * val = & (index_string -> index_parts [i ]);
293- if (mp_typeof (* * tuple ) != MP_UINT )
294- goto error ;
295- val -> field_number = mp_decode_uint (tuple );
296- uint32_t sfield_len = 0 ;
297- if (mp_typeof (* * tuple ) != MP_STR )
298- goto error ;
299- const char * sfield = mp_decode_str (tuple , & sfield_len );
300- val -> field_type = parse_field_type (sfield , sfield_len );
318+
319+ if (mp_typeof (* * tuple ) == MP_ARRAY ) {
320+ return decode_index_parts_166 (index_string -> index_parts ,
321+ part_count , tuple );
301322 }
302- return 0 ;
323+
303324error :
304325 return -1 ;
305326}
0 commit comments