Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new msyql80 feature to add indices without table lock #6366

Open
wants to merge 1 commit into
base: 4.1.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/Platforms/MySQL80Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Exception\InvalidArgumentException;
use Doctrine\DBAL\Platforms\Keywords\KeywordList;
use Doctrine\DBAL\Platforms\Keywords\MySQL80Keywords;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\SQL\Builder\SelectSQLBuilder;

/**
Expand All @@ -22,4 +24,28 @@
{
return AbstractPlatform::createSelectSQLBuilder();
}

public function getCreateIndexSQL(Index $index, string $table): string
{
$name = $index->getQuotedName($this);
$columns = $index->getColumns();

if (count($columns) === 0) {

Check failure on line 33 in src/Platforms/MySQL80Platform.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Function count() should not be referenced via a fallback global name, but via a use statement.
throw new InvalidArgumentException(sprintf(

Check failure on line 34 in src/Platforms/MySQL80Platform.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Function sprintf() should not be referenced via a fallback global name, but via a use statement.
'Incomplete or invalid index definition %s on table %s',
$name,
$table,
));
}

if ($index->isPrimary()) {
return $this->getCreatePrimaryKeySQL($index, $table);
}

$query = 'ALTER TABLE ' .$name . ' ADD' . $this->getCreateIndexSQLFlags($index) . 'INDEX ';

Check failure on line 45 in src/Platforms/MySQL80Platform.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Expected at least 1 space after "."; 0 found

Check failure on line 45 in src/Platforms/MySQL80Platform.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Concat operator must be surrounded by a single space
$query .= ' (' . implode(', ', $index->getQuotedColumns($this)) . ')' . $this->getPartialIndexSQL($index);

Check failure on line 46 in src/Platforms/MySQL80Platform.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Function implode() should not be referenced via a fallback global name, but via a use statement.
$query .= ', ALGORITHM=INPLACE, LOCK=NONE';

return $query;
}
}