original_string: public function add_index($xmldb_table, $xmldb_intex) {
          if (!$this->table_exists($xmldb_table)) {
              throw new ddl_table_missing_exception($xmldb_table->getName());
          }
  
          // Check index doesn't exist
          if ($this->index_exists($xmldb_table, $xmldb_intex)) {
              throw new ddl_exception('ddlunknownerror', null,
                        'Index ' . $xmldb_table->getName() . '->' . $xmldb_intex->getName() .
                        ' already exists. Create skipped');
          }
  
          if (!$sqlarr = $this->generator->getAddIndexSQL($xmldb_table, $xmldb_intex)) {
              throw new ddl_exception('ddlunknownerror', null, 'add_index sql not generated');
          }
  
          try {
              $this->execute_sql_arr($sqlarr, array($xmldb_table->getName()));
          } catch (ddl_change_structure_exception $e) {
              // There could be a problem with the index length related to the row format of the table.
              // If we are using utf8mb4 and the row format is 'compact' or 'redundant' then we need to change it over to
              // 'compressed' or 'dynamic'.
              if (method_exists($this->mdb, 'convert_table_row_format')) {
                  $this->mdb->convert_table_row_format($xmldb_table->getName());
                  $this->execute_sql_arr($sqlarr, array($xmldb_table->getName()));
              } else {
                  // It's some other problem that we are currently not handling.
                  throw $e;
              }
          }
      }
code: public function add_index($xmldb_table, $xmldb_intex) {
          if (!$this->table_exists($xmldb_table)) {
              throw new ddl_table_missing_exception($xmldb_table->getName());
          }
  
          // Check index doesn't exist
          if ($this->index_exists($xmldb_table, $xmldb_intex)) {
              throw new ddl_exception('ddlunknownerror', null,
                        'Index ' . $xmldb_table->getName() . '->' . $xmldb_intex->getName() .
                        ' already exists. Create skipped');
          }
  
          if (!$sqlarr = $this->generator->getAddIndexSQL($xmldb_table, $xmldb_intex)) {
              throw new ddl_exception('ddlunknownerror', null, 'add_index sql not generated');
          }
  
          try {
              $this->execute_sql_arr($sqlarr, array($xmldb_table->getName()));
          } catch (ddl_change_structure_exception $e) {
              // There could be a problem with the index length related to the row format of the table.
              // If we are using utf8mb4 and the row format is 'compact' or 'redundant' then we need to change it over to
              // 'compressed' or 'dynamic'.
              if (method_exists($this->mdb, 'convert_table_row_format')) {
                  $this->mdb->convert_table_row_format($xmldb_table->getName());
                  $this->execute_sql_arr($sqlarr, array($xmldb_table->getName()));
              } else {
                  // It's some other problem that we are currently not handling.
                  throw $e;
              }
          }
      }
code_tokens: public function add_index ( $ xmldb_table , $ xmldb_intex ) { if ( ! $ this -> table_exists ( $ xmldb_table ) ) { throw new ddl_table_missing_exception ( $ xmldb_table -> getName ( ) ) ; } // Check index doesn't exist if ( $ this -> index_exists ( $ xmldb_table , $ xmldb_intex ) ) { throw new ddl_exception ( 'ddlunknownerror' , null , 'Index ' . $ xmldb_table -> getName ( ) . '->' . $ xmldb_intex -> getName ( ) . ' already exists. Create skipped' ) ; } if ( ! $ sqlarr = $ this -> generator -> getAddIndexSQL ( $ xmldb_table , $ xmldb_intex ) ) { throw new ddl_exception ( 'ddlunknownerror' , null , 'add_index sql not generated' ) ; } try { $ this -> execute_sql_arr ( $ sqlarr , array ( $ xmldb_table -> getName ( ) ) ) ; } catch ( ddl_change_structure_exception $ e ) { // There could be a problem with the index length related to the row format of the table. // If we are using utf8mb4 and the row format is 'compact' or 'redundant' then we need to change it over to // 'compressed' or 'dynamic'. if ( method_exists ( $ this -> mdb , 'convert_table_row_format' ) ) { $ this -> mdb -> convert_table_row_format ( $ xmldb_table -> getName ( ) ) ; $ this -> execute_sql_arr ( $ sqlarr , array ( $ xmldb_table -> getName ( ) ) ) ; } else { // It's some other problem that we are currently not handling. throw $ e ; } } }
docstring: This function will create the index in the table passed as arguments
  Before creating the index, the function will check it doesn't exists
  
  @param xmldb_table $xmldb_table Table object (just the name is mandatory).
  @param xmldb_index $xmldb_intex Index object (full specs are required).
  @return void
docstring_tokens: This function will create the index in the table passed as arguments Before creating the index the function will check it doesn t exists