@@ -629,6 +629,55 @@ int convert_iterator(zval *iter, int all) {
629629 return -1 ;
630630}
631631
632+ int obtain_space_by_spaceno (tarantool_connection * obj , uint32_t space_no ) {
633+ if (tarantool_schema_has_space_no (obj -> schema , space_no )) {
634+ return 0 ;
635+ }
636+
637+ tarantool_tp_update (obj -> tps );
638+ tp_select (obj -> tps , SPACE_SPACE , INDEX_SPACE_NO , 0 , 4096 );
639+ tp_key (obj -> tps , 1 );
640+ tp_encode_uint (obj -> tps , space_no );
641+ tp_reqid (obj -> tps , TARANTOOL_G (sync_counter )++ );
642+
643+ obj -> value -> len = tp_used (obj -> tps );
644+ tarantool_tp_flush (obj -> tps );
645+
646+ if (tarantool_stream_send (obj ) == FAILURE )
647+ return FAILURE ;
648+
649+ char pack_len [5 ] = {0 , 0 , 0 , 0 , 0 };
650+ if (tarantool_stream_read (obj , pack_len , 5 ) == FAILURE )
651+ return FAILURE ;
652+ size_t body_size = php_mp_unpack_package_size (pack_len );
653+ smart_string_ensure (obj -> value , body_size );
654+ if (tarantool_stream_read (obj , obj -> value -> c ,
655+ body_size ) == FAILURE )
656+ return FAILURE ;
657+
658+ struct tnt_response resp ; memset (& resp , 0 , sizeof (struct tnt_response ));
659+ if (php_tp_response (& resp , obj -> value -> c , body_size ) == -1 ) {
660+ tarantool_throw_parsingexception ("query" );
661+ return FAILURE ;
662+ }
663+
664+ if (resp .error ) {
665+ tarantool_throw_clienterror (resp .code , resp .error ,
666+ resp .error_len );
667+ return FAILURE ;
668+ }
669+
670+ if (tarantool_schema_add_spaces (obj -> schema , resp .data , resp .data_len )) {
671+ tarantool_throw_parsingexception ("schema (space)" );
672+ return FAILURE ;
673+ }
674+ if (!tarantool_schema_has_space_no (obj -> schema , space_no )) {
675+ THROW_EXC ("No space %u defined" , space_no );
676+ return FAILURE ;
677+ }
678+ return 0 ;
679+ }
680+
632681int get_spaceno_by_name (tarantool_connection * obj , zval * name ) {
633682 if (Z_TYPE_P (name ) == IS_LONG )
634683 return Z_LVAL_P (name );
@@ -695,6 +744,11 @@ int get_indexno_by_name(tarantool_connection *obj, int space_no,
695744 THROW_EXC ("Index ID must be String or Long" );
696745 return FAILURE ;
697746 }
747+
748+ if (obtain_space_by_spaceno (obj , space_no ) == FAILURE ) {
749+ return FAILURE ;
750+ }
751+
698752 int32_t index_no = tarantool_schema_get_iid_by_string (obj -> schema ,
699753 space_no , Z_STRVAL_P (name ), Z_STRLEN_P (name ));
700754 if (index_no != FAILURE )
0 commit comments