Skip to content

Commit fe12f0a

Browse files
committed
AC-8402: Ensure compatibility with the latest MariaDB patch versions
1 parent aff4435 commit fe12f0a

File tree

9 files changed

+184
-0
lines changed

9 files changed

+184
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
// @codingStandardsIgnoreFile
7+
return [
8+
'auto_increment_test' => 'CREATE TABLE `auto_increment_test` (
9+
`int_auto_increment_with_nullable` int(10) unsigned NOT NULL AUTO_INCREMENT,
10+
`int_disabled_auto_increment` smallint(5) unsigned DEFAULT 0,
11+
UNIQUE KEY `AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE` (`int_auto_increment_with_nullable`)
12+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci',
13+
'reference_table' => 'CREATE TABLE `reference_table` (
14+
`tinyint_ref` tinyint(4) NOT NULL AUTO_INCREMENT,
15+
`tinyint_without_padding` tinyint(4) NOT NULL DEFAULT 0,
16+
`bigint_without_padding` bigint(20) NOT NULL DEFAULT 0,
17+
`smallint_without_padding` smallint(6) NOT NULL DEFAULT 0,
18+
`integer_without_padding` int(11) NOT NULL DEFAULT 0,
19+
`smallint_with_big_padding` smallint(6) NOT NULL DEFAULT 0,
20+
`smallint_without_default` smallint(6) DEFAULT NULL,
21+
`int_without_unsigned` int(11) DEFAULT NULL,
22+
`int_unsigned` int(10) unsigned DEFAULT NULL,
23+
`bigint_default_nullable` bigint(20) unsigned DEFAULT 1,
24+
`bigint_not_default_not_nullable` bigint(20) unsigned NOT NULL,
25+
`smallint_ref` smallint(6) NOT NULL DEFAULT 0,
26+
PRIMARY KEY (`tinyint_ref`,`smallint_ref`),
27+
UNIQUE KEY `REFERENCE_TABLE_SMALLINT_REF` (`smallint_ref`)
28+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci',
29+
'test_table' => 'CREATE TABLE `test_table` (
30+
`smallint` smallint(6) DEFAULT NULL,
31+
`tinyint` tinyint(4) DEFAULT NULL,
32+
`bigint` bigint(20) DEFAULT 0,
33+
`float` float(12,10) DEFAULT 0.0000000000,
34+
`double` double(245,10) DEFAULT 11111111.1111110000,
35+
`decimal` decimal(15,4) DEFAULT 0.0000,
36+
`date` date DEFAULT NULL,
37+
`timestamp` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
38+
`datetime` datetime DEFAULT \'0000-00-00 00:00:00\',
39+
`longtext` longtext DEFAULT NULL,
40+
`mediumtext` mediumtext DEFAULT NULL,
41+
`varchar` varchar(254) DEFAULT NULL,
42+
`char` char(255) DEFAULT NULL,
43+
`mediumblob` mediumblob DEFAULT NULL,
44+
`blob` blob DEFAULT NULL,
45+
`boolean` tinyint(1) DEFAULT NULL,
46+
`integer_main` int(10) unsigned DEFAULT NULL,
47+
`smallint_main` smallint(6) NOT NULL DEFAULT 0,
48+
UNIQUE KEY `TEST_TABLE_SMALLINT_FLOAT` (`smallint`,`float`),
49+
UNIQUE KEY `TEST_TABLE_DOUBLE` (`double`),
50+
KEY `TEST_TABLE_TINYINT_BIGINT` (`tinyint`,`bigint`),
51+
KEY `TEST_TABLE_SMALLINT_MAIN_REFERENCE_TABLE_SMALLINT_REF` (`smallint_main`),
52+
KEY `FK_FB77604C299EB8612D01E4AF8D9931F2` (`integer_main`),
53+
CONSTRAINT `FK_FB77604C299EB8612D01E4AF8D9931F2` FOREIGN KEY (`integer_main`) REFERENCES `auto_increment_test` (`int_auto_increment_with_nullable`) ON DELETE CASCADE,
54+
CONSTRAINT `TEST_TABLE_SMALLINT_MAIN_REFERENCE_TABLE_SMALLINT_REF` FOREIGN KEY (`smallint_main`) REFERENCES `reference_table` (`smallint_ref`) ON DELETE CASCADE,
55+
CONSTRAINT `TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF` FOREIGN KEY (`tinyint`) REFERENCES `reference_table` (`tinyint_ref`) ON DELETE SET NULL
56+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci',
57+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
// @codingStandardsIgnoreFile
9+
return [
10+
'before' => [
11+
'store' => 'CREATE TABLE `store` (
12+
`store_owner_id` smallint(6) DEFAULT NULL COMMENT \'Store Owner Reference\',
13+
KEY `STORE_STORE_OWNER_ID_STORE_OWNER_OWNER_ID` (`store_owner_id`),
14+
CONSTRAINT `STORE_STORE_OWNER_ID_STORE_OWNER_OWNER_ID` FOREIGN KEY (`store_owner_id`) REFERENCES `store_owner` (`owner_id`) ON DELETE SET NULL
15+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci',
16+
'store_owner' => 'CREATE TABLE `store_owner` (
17+
`owner_id` smallint(6) NOT NULL AUTO_INCREMENT,
18+
`store_owner_name` varchar(255) DEFAULT NULL COMMENT \'Store Owner Name\',
19+
PRIMARY KEY (`owner_id`)
20+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT=\'Store owner information\''
21+
],
22+
'after' => [
23+
'store' => 'CREATE TABLE `store` (
24+
`store_owner` varchar(255) DEFAULT NULL COMMENT \'Store Owner Name\'
25+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'
26+
]
27+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
return [
7+
'auto_increment_test' => 'CREATE TABLE `auto_increment_test` (
8+
`int_auto_increment_with_nullable` int(10) unsigned NOT NULL AUTO_INCREMENT,
9+
`int_disabled_auto_increment` smallint(5) unsigned DEFAULT 0,
10+
UNIQUE KEY `AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE` (`int_auto_increment_with_nullable`)
11+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'
12+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
return [
9+
'before' => 'CREATE TABLE `some_table` (
10+
`some_column` varchar(255) DEFAULT NULL COMMENT \'Some Column Name\'
11+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci',
12+
'after' => 'CREATE TABLE `some_table_renamed` (
13+
`some_column` varchar(255) DEFAULT NULL COMMENT \'Some Column Name\'
14+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci',
15+
];
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
return [
7+
'test_table_one' => 'CREATE TABLE `test_table_one` (
8+
`smallint` smallint(6) NOT NULL AUTO_INCREMENT,
9+
`varchar` varchar(254) DEFAULT NULL,
10+
PRIMARY KEY (`smallint`)
11+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci',
12+
'test_table_two' => 'CREATE TABLE `test_table_two` (
13+
`smallint` smallint(6) NOT NULL AUTO_INCREMENT,
14+
`varchar` varchar(254) DEFAULT NULL,
15+
PRIMARY KEY (`smallint`)
16+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci',
17+
'reference_table' => 'CREATE TABLE `reference_table` (
18+
`tinyint_ref` tinyint(4) NOT NULL AUTO_INCREMENT,
19+
`tinyint_without_padding` tinyint(4) NOT NULL DEFAULT 0,
20+
`bigint_without_padding` bigint(20) NOT NULL DEFAULT 0,
21+
`smallint_without_padding` smallint(6) NOT NULL DEFAULT 0,
22+
`integer_without_padding` int(11) NOT NULL DEFAULT 0,
23+
`smallint_with_big_padding` smallint(6) NOT NULL DEFAULT 0,
24+
`smallint_without_default` smallint(6) DEFAULT NULL,
25+
`int_without_unsigned` int(11) DEFAULT NULL,
26+
`int_unsigned` int(10) unsigned DEFAULT NULL,
27+
`bigint_default_nullable` bigint(20) unsigned DEFAULT 1,
28+
`bigint_not_default_not_nullable` bigint(20) unsigned NOT NULL,
29+
PRIMARY KEY (`tinyint_ref`)
30+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci',
31+
'auto_increment_test' => 'CREATE TABLE `auto_increment_test` (
32+
`int_auto_increment_with_nullable` int(10) unsigned NOT NULL AUTO_INCREMENT,
33+
`int_disabled_auto_increment` smallint(5) unsigned DEFAULT 0,
34+
UNIQUE KEY `AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE` (`int_auto_increment_with_nullable`)
35+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'
36+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
return [
9+
'auto_increment_test' => 'CREATE TABLE `auto_increment_test` (
10+
`int_auto_increment_with_nullable` int(10) unsigned NOT NULL AUTO_INCREMENT,
11+
`int_disabled_auto_increment` smallint(5) unsigned DEFAULT 0,
12+
UNIQUE KEY `AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE` (`int_auto_increment_with_nullable`)
13+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'
14+
];

dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/DataProviderFromFile.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class DataProviderFromFile
3030
SqlVersionProvider::MARIA_DB_10_4_VERSION => 'mariadb10',
3131
SqlVersionProvider::MARIA_DB_10_6_VERSION => 'mariadb106',
3232
SqlVersionProvider::MYSQL_8_0_29_VERSION => 'mysql829',
33+
SqlVersionProvider::MARIA_DB_10_4_27_VERSION => 'mariadb10427',
3334
SqlVersionProvider::MARIA_DB_10_6_11_VERSION => 'mariadb10611'
3435
];
3536

dev/tests/setup-integration/framework/Magento/TestFramework/TestCase/SetupTestCase.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ private function getDbKey(): string
110110
if ($this->sqlVersionProvider->isMysqlGte8029()) {
111111
$this->dbKey = DataProviderFromFile::POSSIBLE_SUFFIXES[SqlVersionProvider::MYSQL_8_0_29_VERSION];
112112
break;
113+
} elseif ($this->sqlVersionProvider->isMariaDBGte10_4_27()) {
114+
$this->dbKey = DataProviderFromFile::POSSIBLE_SUFFIXES[SqlVersionProvider::MARIA_DB_10_4_27_VERSION];
115+
break;
113116
} elseif ($this->sqlVersionProvider->isMariaDBGte10_6_11()) {
114117
$this->dbKey = DataProviderFromFile::POSSIBLE_SUFFIXES[SqlVersionProvider::MARIA_DB_10_6_11_VERSION];
115118
break;

lib/internal/Magento/Framework/DB/Adapter/SqlVersionProvider.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class SqlVersionProvider
3333

3434
public const MARIA_DB_10_6_11_VERSION = '10.6.11';
3535

36+
public const MARIA_DB_10_4_27_VERSION = '10.4.27';
37+
3638
/**#@-*/
3739

3840
/**
@@ -158,4 +160,21 @@ public function isMariaDBGte10_6_11(): bool
158160
}
159161
return false;
160162
}
163+
164+
/**
165+
* Check if MariaDB version is greater than equal to 10.4.27
166+
*
167+
* @return bool
168+
* @throws ConnectionException
169+
*/
170+
public function isMariaDBGte10_4_27(): bool
171+
{
172+
$sqlVersion = $this->getSqlVersion();
173+
$isMariaDB = str_contains($sqlVersion, SqlVersionProvider::MARIA_DB_10_VERSION);
174+
$sqlExactVersion = $this->fetchSqlVersion(ResourceConnection::DEFAULT_CONNECTION);
175+
if ($isMariaDB && version_compare($sqlExactVersion, '10.4.27', '>=')) {
176+
return true;
177+
}
178+
return false;
179+
}
161180
}

0 commit comments

Comments
 (0)