Skip to content

Commit 3d0980c

Browse files
authored
update getNextAutoincrement
update getNextAutoincrement to not use showTableStatus for performants reasons. See also OpenMage#1712
1 parent 7f84c55 commit 3d0980c

File tree

1 file changed

+13
-4
lines changed
  • app/code/core/Mage/ImportExport/Model/Resource/Helper

1 file changed

+13
-4
lines changed

app/code/core/Mage/ImportExport/Model/Resource/Helper/Mysql4.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,21 @@ public function getMaxDataSize()
6161
*/
6262
public function getNextAutoincrement($tableName)
6363
{
64-
$adapter = $this->_getReadAdapter();
65-
$entityStatus = $adapter->showTableStatus($tableName);
64+
$connection = $this->getConnection();
65+
$entityStatus = $connection->showTableStatus($tableName);
6666

6767
if (empty($entityStatus['Auto_increment'])) {
68-
Mage::throwException(Mage::helper('importexport')->__('Cannot get autoincrement value'));
68+
$sql = sprintf(
69+
'SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = %s AND TABLE_SCHEMA = DATABASE()',
70+
$this->quote($tableName)
71+
);
72+
$entityStatus = $connection->fetchRow($sql);
73+
if (empty($entityStatus['AUTO_INCREMENT']))
74+
{
75+
throw new \Magento\Framework\Exception\LocalizedException(__('Cannot get autoincrement value'));
6976
}
70-
return $entityStatus['Auto_increment'];
77+
78+
return $entityStatus['AUTO_INCREMENT'];
79+
7180
}
7281
}

0 commit comments

Comments
 (0)