Skip to content

Commit

Permalink
MDL-66110 dml: Undo table name fix when table name's used as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Aug 22, 2019
1 parent a0d8aef commit ddc3699
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/dml/mysqli_native_moodle_database.php
Expand Up @@ -326,10 +326,9 @@ public function get_row_format($table = null) {
$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.
Expand Down Expand Up @@ -721,11 +720,10 @@ public function get_columns($table, $usecache=true) {

$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);
Expand All @@ -749,6 +747,7 @@ public function get_columns($table, $usecache=true) {
} 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);
Expand Down

0 comments on commit ddc3699

Please sign in to comment.