= 50700; } // @see https://mariadb.com/kb/en/alter-table/#rename-indexkey if (self::isMariaDb()) { return $serverVersion >= 100502; } return false; } public static function isIntegersLengthRestricted(DatabaseInterface $dbi): bool { // MySQL made restrictions on the integer types' length from versions >= 8.0.18 // See: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-19.html $serverType = Util::getServerType(); $serverVersion = $dbi->getVersion(); return $serverType === 'MySQL' && $serverVersion >= 80018; } public static function supportsReferencesPrivilege(DatabaseInterface $dbi): bool { // See: https://mariadb.com/kb/en/grant/#table-privileges // Unused if ($dbi->isMariaDB()) { return false; } // https://dev.mysql.com/doc/refman/5.6/en/privileges-provided.html#priv_references // This privilege is unused before MySQL 5.6.22. // As of 5.6.22, creation of a foreign key constraint // requires at least one of the SELECT, INSERT, UPDATE, DELETE, // or REFERENCES privileges for the parent table. return $dbi->getVersion() >= 50622; } public static function isIntegersSupportLength(string $type, string $length, DatabaseInterface $dbi): bool { // MySQL Removed the Integer types' length from versions >= 8.0.18 // except TINYINT(1). // See: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-19.html $integerTypes = ['SMALLINT', 'MEDIUMINT', 'INT', 'BIGINT']; $typeLengthNotAllowed = in_array($type, $integerTypes, true) || $type === 'TINYINT' && $length !== '1'; return ! (self::isIntegersLengthRestricted($dbi) && $typeLengthNotAllowed); } /** * Returns whether the database server supports virtual columns */ public static function isVirtualColumnsSupported(int $serverVersion): bool { // @see: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-6.html if (self::isMySqlOrPerconaDb()) { return $serverVersion >= 50706; } // @see https://mariadb.com/kb/en/changes-improvements-in-mariadb-52/#new-features if (self::isMariaDb()) { return $serverVersion >= 50200; } return false; } /** * Check whether the database supports UUID data type * true if uuid is supported */ public static function isUUIDSupported(DatabaseInterface $dbi): bool { // @see: https://mariadb.com/kb/en/mariadb-1070-release-notes/#uuid return $dbi->isMariaDB() && $dbi->getVersion() >= 100700; // 10.7.0 } /** * Returns whether the database server supports virtual columns */ public static function supportsStoredKeywordForVirtualColumns(int $serverVersion): bool { // @see: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-6.html if (self::isMySqlOrPerconaDb()) { return $serverVersion >= 50706; } // @see https://mariadb.com/kb/en/generated-columns/#mysql-compatibility-support if (self::isMariaDb()) { return $serverVersion >= 100201; } return false; } /** * Returns whether the database server supports compressed columns */ public static function supportsCompressedColumns(int $serverVersion): bool { // @see https://mariadb.com/kb/en/innodb-page-compression/#comment_1992 // Comment: Page compression is only available in MariaDB >= 10.1. [...] if (self::isMariaDb()) { return $serverVersion >= 100100; } return false; } /** * @see https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-6.html#mysqld-5-7-6-account-management * @see https://mariadb.com/kb/en/mariadb-1042-release-notes/#notable-changes * * @psalm-pure */ public static function hasAccountLocking(bool $isMariaDb, int $version): bool { return $isMariaDb && $version >= 100402 || ! $isMariaDb && $version >= 50706; } /** @return non-empty-string */ public static function getShowBinLogStatusStmt(DbalInterface $dbal): string { if ($dbal->isMySql() && $dbal->getVersion() >= 80200) { return 'SHOW BINARY LOG STATUS'; } if ($dbal->isMariaDB() && $dbal->getVersion() >= 100502) { return 'SHOW BINLOG STATUS'; } return 'SHOW MASTER STATUS'; } }