Skip to content

Commit f6c25bd

Browse files
committed
AC-8402: Ensure compatibility with the latest MariaDB patch versions
1 parent 3b6828d commit f6c25bd

File tree

10 files changed

+192
-2
lines changed

10 files changed

+192
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
'auto_increment_test' => 'CREATE TABLE `auto_increment_test` (
11+
`int_auto_increment_with_nullable` int(10) unsigned NOT NULL AUTO_INCREMENT,
12+
`int_disabled_auto_increment` smallint(5) unsigned DEFAULT 0,
13+
UNIQUE KEY `AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE` (`int_auto_increment_with_nullable`)
14+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci',
15+
'reference_table' => 'CREATE TABLE `reference_table` (
16+
`tinyint_ref` tinyint(4) NOT NULL AUTO_INCREMENT,
17+
`tinyint_without_padding` tinyint(4) NOT NULL DEFAULT 0,
18+
`bigint_without_padding` bigint(20) NOT NULL DEFAULT 0,
19+
`smallint_without_padding` smallint(6) NOT NULL DEFAULT 0,
20+
`integer_without_padding` int(11) NOT NULL DEFAULT 0,
21+
`smallint_with_big_padding` smallint(6) NOT NULL DEFAULT 0,
22+
`smallint_without_default` smallint(6) DEFAULT NULL,
23+
`int_without_unsigned` int(11) DEFAULT NULL,
24+
`int_unsigned` int(10) unsigned DEFAULT NULL,
25+
`bigint_default_nullable` bigint(20) unsigned DEFAULT 1,
26+
`bigint_not_default_not_nullable` bigint(20) unsigned NOT NULL,
27+
`smallint_ref` smallint(6) NOT NULL DEFAULT 0,
28+
PRIMARY KEY (`tinyint_ref`,`smallint_ref`),
29+
UNIQUE KEY `REFERENCE_TABLE_SMALLINT_REF` (`smallint_ref`)
30+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci',
31+
'test_table' => 'CREATE TABLE `test_table` (
32+
`smallint` smallint(6) DEFAULT NULL,
33+
`tinyint` tinyint(4) DEFAULT NULL,
34+
`bigint` bigint(20) DEFAULT 0,
35+
`float` float(12,10) DEFAULT 0.0000000000,
36+
`double` double(245,10) DEFAULT 11111111.1111110000,
37+
`decimal` decimal(15,4) DEFAULT 0.0000,
38+
`date` date DEFAULT NULL,
39+
`timestamp` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
40+
`datetime` datetime DEFAULT \'0000-00-00 00:00:00\',
41+
`longtext` longtext DEFAULT NULL,
42+
`mediumtext` mediumtext DEFAULT NULL,
43+
`varchar` varchar(254) DEFAULT NULL,
44+
`char` char(255) DEFAULT NULL,
45+
`mediumblob` mediumblob DEFAULT NULL,
46+
`blob` blob DEFAULT NULL,
47+
`boolean` tinyint(1) DEFAULT NULL,
48+
`integer_main` int(10) unsigned DEFAULT NULL,
49+
`smallint_main` smallint(6) NOT NULL DEFAULT 0,
50+
UNIQUE KEY `TEST_TABLE_SMALLINT_FLOAT` (`smallint`,`float`),
51+
UNIQUE KEY `TEST_TABLE_DOUBLE` (`double`),
52+
KEY `TEST_TABLE_TINYINT_BIGINT` (`tinyint`,`bigint`),
53+
KEY `TEST_TABLE_SMALLINT_MAIN_REFERENCE_TABLE_SMALLINT_REF` (`smallint_main`),
54+
KEY `FK_FB77604C299EB8612D01E4AF8D9931F2` (`integer_main`),
55+
CONSTRAINT `FK_FB77604C299EB8612D01E4AF8D9931F2` FOREIGN KEY (`integer_main`) REFERENCES `auto_increment_test` (`int_auto_increment_with_nullable`) ON DELETE CASCADE,
56+
CONSTRAINT `TEST_TABLE_SMALLINT_MAIN_REFERENCE_TABLE_SMALLINT_REF` FOREIGN KEY (`smallint_main`) REFERENCES `reference_table` (`smallint_ref`) ON DELETE CASCADE,
57+
CONSTRAINT `TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF` FOREIGN KEY (`tinyint`) REFERENCES `reference_table` (`tinyint_ref`) ON DELETE SET NULL
58+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci',
59+
];
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=utf8mb3 COLLATE=utf8mb3_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=utf8mb3 COLLATE=utf8mb3_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=utf8mb3 COLLATE=utf8mb3_general_ci'
26+
]
27+
];
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=utf8mb3 COLLATE=utf8mb3_general_ci'
14+
];
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=utf8mb3 COLLATE=utf8mb3_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=utf8mb3 COLLATE=utf8mb3_general_ci',
15+
];
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
'test_table_one' => 'CREATE TABLE `test_table_one` (
10+
`smallint` smallint(6) NOT NULL AUTO_INCREMENT,
11+
`varchar` varchar(254) DEFAULT NULL,
12+
PRIMARY KEY (`smallint`)
13+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci',
14+
'test_table_two' => 'CREATE TABLE `test_table_two` (
15+
`smallint` smallint(6) NOT NULL AUTO_INCREMENT,
16+
`varchar` varchar(254) DEFAULT NULL,
17+
PRIMARY KEY (`smallint`)
18+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci',
19+
'reference_table' => 'CREATE TABLE `reference_table` (
20+
`tinyint_ref` tinyint(4) NOT NULL AUTO_INCREMENT,
21+
`tinyint_without_padding` tinyint(4) NOT NULL DEFAULT 0,
22+
`bigint_without_padding` bigint(20) NOT NULL DEFAULT 0,
23+
`smallint_without_padding` smallint(6) NOT NULL DEFAULT 0,
24+
`integer_without_padding` int(11) NOT NULL DEFAULT 0,
25+
`smallint_with_big_padding` smallint(6) NOT NULL DEFAULT 0,
26+
`smallint_without_default` smallint(6) DEFAULT NULL,
27+
`int_without_unsigned` int(11) DEFAULT NULL,
28+
`int_unsigned` int(10) unsigned DEFAULT NULL,
29+
`bigint_default_nullable` bigint(20) unsigned DEFAULT 1,
30+
`bigint_not_default_not_nullable` bigint(20) unsigned NOT NULL,
31+
PRIMARY KEY (`tinyint_ref`)
32+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci',
33+
'auto_increment_test' => 'CREATE TABLE `auto_increment_test` (
34+
`int_auto_increment_with_nullable` int(10) unsigned NOT NULL AUTO_INCREMENT,
35+
`int_disabled_auto_increment` smallint(5) unsigned DEFAULT 0,
36+
UNIQUE KEY `AUTO_INCREMENT_TEST_INT_AUTO_INCREMENT_WITH_NULLABLE` (`int_auto_increment_with_nullable`)
37+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci'
38+
];
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=utf8mb3 COLLATE=utf8mb3_general_ci'
14+
];

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class DataProviderFromFile
2929
SqlVersionProvider::MYSQL_8_0_VERSION => 'mysql8',
3030
SqlVersionProvider::MARIA_DB_10_4_VERSION => 'mariadb10',
3131
SqlVersionProvider::MARIA_DB_10_6_VERSION => 'mariadb106',
32-
SqlVersionProvider::MYSQL_8_0_29_VERSION => 'mysql829'
32+
SqlVersionProvider::MYSQL_8_0_29_VERSION => 'mysql829',
33+
SqlVersionProvider::MARIA_DB_10_6_11_VERSION => 'mariadb10611'
3334
];
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_6_11()) {
114+
$this->dbKey = DataProviderFromFile::POSSIBLE_SUFFIXES[SqlVersionProvider::MARIA_DB_10_6_11_VERSION];
115+
break;
113116
} elseif (strpos($this->getDatabaseVersion(), (string)$possibleVersion) !== false) {
114117
$this->dbKey = $suffix;
115118
break;

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

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

3232
public const MYSQL_8_0_29_VERSION = '8.0.29';
3333

34+
public const MARIA_DB_10_6_11_VERSION = '10.6.11';
35+
3436
/**#@-*/
3537

3638
/**
@@ -139,4 +141,21 @@ public function isMysqlGte8029(): bool
139141
}
140142
return false;
141143
}
144+
145+
/**
146+
* Check if MariaDB version is greater than equal to 10.6.11
147+
*
148+
* @return bool
149+
* @throws ConnectionException
150+
*/
151+
public function isMariaDBGte10_6_11(): bool
152+
{
153+
$sqlVersion = $this->getSqlVersion();
154+
$isMariaDB = str_contains($sqlVersion, SqlVersionProvider::MARIA_DB_10_VERSION);
155+
$sqlExactVersion = $this->fetchSqlVersion(ResourceConnection::DEFAULT_CONNECTION);
156+
if ($isMariaDB && version_compare($sqlExactVersion, '10.6.11', '>=')) {
157+
return true;
158+
}
159+
return false;
160+
}
142161
}

lib/internal/Magento/Framework/Test/Unit/DB/Adapter/SqlVersionProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function executeDataProvider(): array
107107
{
108108
return [
109109
'MariaDB-10.6' => [
110-
['version' => '10.6.10-MariaDB'],
110+
['version' => '10.6.12-MariaDB'],
111111
'10.6.'
112112
],
113113
'MariaDB-10.4' => [

0 commit comments

Comments
 (0)