MDL-66110 dml: Undo table name fix when table name's used as parameter

This commit is contained in:
Jun Pataleta
2019-08-22 16:18:04 +08:00
parent cdc64ab1dd
commit 14404f91ea
+3 -4
View File
@@ -326,10 +326,9 @@ class mysqli_native_moodle_database extends moodle_database {
$rowformat = null;
if (isset($table)) {
$table = $this->mysqli->real_escape_string($table);
$fixedtable = $this->fix_table_name($table);
$sql = "SELECT row_format
FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema = DATABASE() AND table_name = '$fixedtable'";
WHERE table_schema = DATABASE() AND table_name = '{$this->prefix}$table'";
} else {
if ($this->is_antelope_file_format_no_more_supported()) {
// Breaking change: Antelope file format support has been removed, only Barracuda.
@@ -721,11 +720,10 @@ class mysqli_native_moodle_database extends moodle_database {
$structure = array();
$fixedtable = $this->fix_table_name($table);
$sql = "SELECT column_name, data_type, character_maximum_length, numeric_precision,
numeric_scale, is_nullable, column_type, column_default, column_key, extra
FROM information_schema.columns
WHERE table_name = '" . $fixedtable . "'
WHERE table_name = '" . $this->prefix.$table . "'
AND table_schema = '" . $this->dbname . "'
ORDER BY ordinal_position";
$this->query_start($sql, null, SQL_QUERY_AUX);
@@ -749,6 +747,7 @@ class mysqli_native_moodle_database extends moodle_database {
} else {
// temporary tables are not in information schema, let's try it the old way
$result->close();
$fixedtable = $this->fix_table_name($table);
$sql = "SHOW COLUMNS FROM $fixedtable";
$this->query_start($sql, null, SQL_QUERY_AUX);
$result = $this->mysqli->query($sql);