Skip to content

Commit

Permalink
Issue #6450: DatabaseSchema_mysql::fieldExists() does not escape the …
Browse files Browse the repository at this point in the history
…column name and should be removed together DatabaseSchema_mysql::tableExists()
  • Loading branch information
kiamlaluno committed Apr 10, 2024
1 parent 266a501 commit 3bb4364
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions core/includes/database/mysql/schema.inc
Expand Up @@ -502,23 +502,6 @@ class DatabaseSchema_mysql extends DatabaseSchema {
return preg_replace('/; InnoDB free:.*$/', '', $comment);
}

public function tableExists($table) {
// The information_schema table is very slow to query under MySQL 5.0.
// Instead, we try to select from the table in question. If it fails,
// the most likely reason is that it does not exist. That is dramatically
// faster than using information_schema.
// @link http://bugs.mysql.com/bug.php?id=19588
// @todo: This override should be removed once we require a version of MySQL
// that has that bug fixed.
try {
$this->connection->queryRange("SELECT 1 FROM {" . $table . "}", 0, 1);
return TRUE;
}
catch (Exception $e) {
return FALSE;
}
}

public function findTables($table_expression) {
// Back-ticks need to be removed when selecting from the information_schema
// table. These may be added if using DatabaseConnection::prefixTables() on
Expand All @@ -527,23 +510,6 @@ class DatabaseSchema_mysql extends DatabaseSchema {
return parent::findTables($table_expression);
}

public function fieldExists($table, $column) {
// The information_schema table is very slow to query under MySQL 5.0.
// Instead, we try to select from the table and field in question. If it
// fails, the most likely reason is that it does not exist. That is
// dramatically faster than using information_schema.
// @link http://bugs.mysql.com/bug.php?id=19588
// @todo: This override should be removed once we require a version of MySQL
// that has that bug fixed.
try {
$this->connection->queryRange("SELECT $column FROM {" . $table . "}", 0, 1);
return TRUE;
}
catch (Exception $e) {
return FALSE;
}
}

}

/**
Expand Down

0 comments on commit 3bb4364

Please sign in to comment.