From 1be3cad6e3004b875d85341cb3cf1edac637d2a2 Mon Sep 17 00:00:00 2001 From: "Fawzi E. Abdulfattah" Date: Fri, 22 Jul 2022 19:26:02 +0200 Subject: Supporting the compressed option for MariaDB Ref: #14956 Signed-off-by: Fawzi E. Abdulfattah --- libraries/classes/Types.php | 11 ++++++++++- libraries/classes/Util.php | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'libraries') diff --git a/libraries/classes/Types.php b/libraries/classes/Types.php index 12f7a7e4cf..e2deae064d 100644 --- a/libraries/classes/Types.php +++ b/libraries/classes/Types.php @@ -713,13 +713,22 @@ class Types */ public function getAttributes() { - return [ + $isMariaDB = $this->dbi->isMariaDB(); + $serverVersion = $this->dbi->getVersion(); + + $attributes = [ '', 'BINARY', 'UNSIGNED', 'UNSIGNED ZEROFILL', 'on update CURRENT_TIMESTAMP', ]; + + if ($isMariaDB && $serverVersion >= 100100) { + $attributes[] = 'COMPRESSED=zlib'; + } + + return $attributes; } /** diff --git a/libraries/classes/Util.php b/libraries/classes/Util.php index 8338d8e003..0d39ca8bae 100644 --- a/libraries/classes/Util.php +++ b/libraries/classes/Util.php @@ -1373,6 +1373,7 @@ class Util $binary = false; $unsigned = false; $zerofill = false; + $compressed = false; } else { $enumSetValues = []; @@ -1394,6 +1395,8 @@ class Util $zerofill = ($zerofillCount > 0); $printType = (string) preg_replace('@unsigned@', '', $printType, -1, $unsignedCount); $unsigned = ($unsignedCount > 0); + $printType = (string) preg_replace('@\/\*!100301 compressed\*\/@', '', $printType, -1, $compressedCount); + $compressed = ($compressedCount > 0); $printType = trim($printType); } @@ -1410,6 +1413,10 @@ class Util $attribute = 'UNSIGNED ZEROFILL'; } + if ($compressed) { + $attribute = 'COMPRESSED=zlib'; + } + $canContainCollation = false; if (! $binary && preg_match('@^(char|varchar|text|tinytext|mediumtext|longtext|set|enum)@', $type)) { $canContainCollation = true; -- cgit v1.2.3