Skip to content

Commit c47f5c5

Browse files
committed
Replaced CREATE TEMPORARY TABLE ... LIKE with different approach that doesn't conflict with MySQL 8
1 parent 1e46eec commit c47f5c5

File tree

1 file changed

+4
-2
lines changed
  • lib/internal/Magento/Framework/DB/Adapter/Pdo

1 file changed

+4
-2
lines changed

lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,10 +2233,12 @@ public function createTemporaryTable(\Magento\Framework\DB\Ddl\Table $table)
22332233
*/
22342234
public function createTemporaryTableLike($temporaryTableName, $originTableName, $ifNotExists = false)
22352235
{
2236-
$ifNotExistsSql = ($ifNotExists ? 'IF NOT EXISTS' : '');
2236+
$ifNotExistsSql = ($ifNotExists ? ' IF NOT EXISTS' : '');
22372237
$temporaryTable = $this->quoteIdentifier($this->_getTableName($temporaryTableName));
22382238
$originTable = $this->quoteIdentifier($this->_getTableName($originTableName));
2239-
$sql = sprintf('CREATE TEMPORARY TABLE %s %s LIKE %s', $ifNotExistsSql, $temporaryTable, $originTable);
2239+
$originCreate = $this->fetchPairs(sprintf('SHOW CREATE TABLE %s', $originTable));
2240+
$sql = str_replace('CREATE TABLE', 'CREATE TEMPORARY TABLE' . $ifNotExistsSql, reset($originCreate));
2241+
$sql = str_replace($originTable, $temporaryTable, $sql);
22402242

22412243
return $this->query($sql);
22422244
}

0 commit comments

Comments
 (0)