From d6ef699edef55da42bedcd29799a5c613c667838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=BCnig?= Date: Tue, 6 Jul 2021 17:34:23 +0200 Subject: [PATCH] rewrite isTableExists for performance reasons faster implementation of isTableExists withous "showtablestatus" --- lib/Varien/Db/Adapter/Pdo/Mysql.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Varien/Db/Adapter/Pdo/Mysql.php b/lib/Varien/Db/Adapter/Pdo/Mysql.php index 5a5ae13dff7..f87078d8c6d 100644 --- a/lib/Varien/Db/Adapter/Pdo/Mysql.php +++ b/lib/Varien/Db/Adapter/Pdo/Mysql.php @@ -2630,7 +2630,22 @@ public function truncateTable($tableName, $schemaName = null) */ public function isTableExists($tableName, $schemaName = null) { - return $this->showTableStatus($tableName, $schemaName) !== false; + $fromDbName = 'DATABASE()'; + if ($schemaName !== null) { + $fromDbName = $this->quote($schemaName); + } + + $sql = sprintf( + 'SELECT COUNT(1) AS tbl_exists FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = %s AND TABLE_SCHEMA = %s', + $this->quote($tableName), + $fromDbName + ); + $ddl = $this->rawFetchRow($sql, 'tbl_exists'); + if ($ddl) { + return true; + } + + return false; } /**