Skip to content

Commit 46a1a4b

Browse files
jonashremfballiano
authored andcommitted
update getNextAutoincrement
update getNextAutoincrement to not use showTableStatus for performants reasons. See also OpenMage#1712
1 parent 111a92f commit 46a1a4b

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
@@ -54,12 +54,21 @@ public function getMaxDataSize()
5454
*/
5555
public function getNextAutoincrement($tableName)
5656
{
57-
$adapter = $this->_getReadAdapter();
58-
$entityStatus = $adapter->showTableStatus($tableName);
57+
$connection = $this->getConnection();
58+
$entityStatus = $connection->showTableStatus($tableName);
5959

6060
if (empty($entityStatus['Auto_increment'])) {
61-
Mage::throwException(Mage::helper('importexport')->__('Cannot get autoincrement value'));
61+
$sql = sprintf(
62+
'SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = %s AND TABLE_SCHEMA = DATABASE()',
63+
$this->quote($tableName)
64+
);
65+
$entityStatus = $connection->fetchRow($sql);
66+
if (empty($entityStatus['AUTO_INCREMENT']))
67+
{
68+
throw new \Magento\Framework\Exception\LocalizedException(__('Cannot get autoincrement value'));
6269
}
63-
return $entityStatus['Auto_increment'];
70+
71+
return $entityStatus['AUTO_INCREMENT'];
72+
6473
}
6574
}

0 commit comments

Comments
 (0)