You are here

public function DatabaseSchema_sqlsrv::compressPrimaryKeyIndex in Drupal driver for SQL Server and SQL Azure 7.2

Same name and namespace in other branches
  1. 7.3 sqlsrv/schema.inc \DatabaseSchema_sqlsrv::compressPrimaryKeyIndex()

Sometimes the size of a table's primary key index needs to be reduced to allow for Primary XML Indexes.

Parameters

string $table:

int $limit:

2 calls to DatabaseSchema_sqlsrv::compressPrimaryKeyIndex()
DatabaseSchema_sqlsrv::addIndex in sqlsrv/schema.inc
Override DatabaseSchema::addIndex().
DatabaseSchema_sqlsrv::dropIndex in sqlsrv/schema.inc
Override DatabaseSchema::dropIndex().

File

sqlsrv/schema.inc, line 1073
Database schema code for Microsoft SQL Server database servers.

Class

DatabaseSchema_sqlsrv

Code

public function compressPrimaryKeyIndex($table, $limit = 900) {

  // Introspect the schema and save the current primary key if the column
  // we are modifying is part of it.
  $primary_key_fields = $this
    ->introspectPrimaryKeyFields($table);

  // SQL Server supports transactional DDL, so we can just start a transaction
  // here and pray for the best.
  $transaction = $this->connection
    ->startTransaction(NULL, DatabaseTransactionSettings::GetDDLCompatibleDefaults());

  // Clear current Primary Key.
  $this
    ->cleanUpPrimaryKey($table);

  // Recreate the Primary Key with the given limit size.
  $this
    ->createPrimaryKey($table, $primary_key_fields, $limit);
  $transaction
    ->commit();

  // Refresh introspection for this table.
  $this
    ->queryColumnInformation($table, TRUE);
}