Skip to content

Commit

Permalink
Merge branch 'QA_4_0'
Browse files Browse the repository at this point in the history
  • Loading branch information
madhuracj committed Sep 25, 2013
2 parents 511a005 + e144e3e commit 47b6d8d
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions tbl_operations.php
Expand Up @@ -236,28 +236,33 @@
/**
* Order the table
*/
require_once 'libraries/Index.class.php';
$indexes = PMA_Index::getFromTable($GLOBALS['table'], $GLOBALS['db']);
$hasNotNullUniqueIdx = false;
foreach ($indexes as $name => $idx) {
if ($name == 'PRIMARY') {
$hasNotNullUniqueIdx = true;
} elseif (! $idx->getNonUnique()) {
$hasNotNullUniqueIdx = true;
foreach ($idx->getColumns() as $column) {
if ($column->getNull()) {
$hasNotNullUniqueIdx = false;
$hideOrderTable = false;
// `ALTER TABLE ORDER BY` does not make sense for InnoDB tables that contain
// a user-defined clustered index (PRIMARY KEY or NOT NULL UNIQUE index).
// InnoDB always orders table rows according to such an index if one is present.
if ($tbl_storage_engine == 'INNODB') {
include_once 'libraries/Index.class.php';
$indexes = PMA_Index::getFromTable($GLOBALS['table'], $GLOBALS['db']);
foreach ($indexes as $name => $idx) {
if ($name == 'PRIMARY') {
$hideOrderTable = true;
break;
} elseif (! $idx->getNonUnique()) {
$notNull = true;
foreach ($idx->getColumns() as $column) {
if ($column->getNull()) {
$notNull = false;
break;
}
}
if ($notNull) {
$hideOrderTable = true;
break;
}
}
}
if ($hasNotNullUniqueIdx) {
break;
}
}
// `ALTER TABLE ORDER BY` does not make sense for InnoDB tables that contain
// a user-defined clustered index (PRIMARY KEY or NOT NULL UNIQUE index).
// InnoDB always orders table rows according to such an index if one is present.
if (! ($tbl_storage_engine == 'INNODB' && $hasNotNullUniqueIdx)) {
if (! $hideOrderTable) {
$response->addHTML(PMA_getHtmlForOrderTheTable($columns));
}

Expand Down

0 comments on commit 47b6d8d

Please sign in to comment.