From 1614f370d5307e031336655f309ea3dc43366e30 Mon Sep 17 00:00:00 2001 From: Juan Ibarra Date: Fri, 2 Aug 2019 16:28:39 +0000 Subject: [PATCH] INT-14517: Adding a new check for row_format=COMPRESSED being unsupported by AuroraDB --- lib/dml/mysqli_native_moodle_database.php | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/dml/mysqli_native_moodle_database.php b/lib/dml/mysqli_native_moodle_database.php index 9d60f855cdb..bb197ef4a5a 100644 --- a/lib/dml/mysqli_native_moodle_database.php +++ b/lib/dml/mysqli_native_moodle_database.php @@ -390,6 +390,10 @@ class mysqli_native_moodle_database extends moodle_database { } else if ($this->get_row_format() !== 'Barracuda') { $this->compressedrowformatsupported = false; + } else if (!is_null($this->is_auroradb())) { + // Amazon Aurora DB (Version 2.04) does not support compressed row format. + $this->compressedrowformatsupported = false; + } else { // All the tests passed, we can safely use ROW_FORMAT=Compressed in sql statements. $this->compressedrowformatsupported = true; @@ -398,6 +402,29 @@ class mysqli_native_moodle_database extends moodle_database { return $this->compressedrowformatsupported; } + /** + * Check if moodle is inside an instance of Amazon Aurora DB. + * From doc: "Amazon Aurora MySQL does not support compressed table (that is, tables created with ROW_FORMAT=COMPRESSED)". + * https://docs.aws.amazon.com/dms/latest/sbs/CHAP_MySQL2Aurora.RDSMySQL.html#CHAP_MySQL2Aurora.RDSMySQL.Snapshot.PreImport + * @return mixed|null + * @throws ddl_change_structure_exception + * @throws dml_read_exception + * @throws dml_write_exception + */ + public function is_auroradb() { + $auroraversion = null; + $sql = 'SHOW VARIABLES LIKE "aurora_version"'; + $this->query_start($sql, NULL, SQL_QUERY_AUX); + $result = $this->mysqli->query($sql); + $this->query_end($result); + if ($rec = $result->fetch_assoc()) { + $auroraversion = $rec['Value']; + } + $result->close(); + + return $auroraversion; + } + /** * Check the database to see if innodb_file_per_table is on. * -- 2.19.0