Blog

Issues with the Latest Version of MariaDB and Long Indexing

Analysis of issues with long product indexing in the latest version of MariaDB and proposed solution.

In the latest version of MariaDB, there have been issues with extremely long product list indexing.

After analysis, it was discovered that the problem lies with type casting by the database. Below is a quick fix that can be applied in the file Magento/Framework/DB/Adapter/Pdo/Mysql.php:

1public function quoteInto($text, $value, $type = null, $count = null)
2{
3 if (is_array($value)) {
4 foreach($value as &$val) {
5 $val = $this->castNumeric($val);
6 }
7 } else {
8 $value = $this->castNumeric($value);
9 }
10
11 if (is_array($value) && empty($value)) {
12 $value = new \Zend_Db_Expr('NULL');
13 }
14
15 if ($value instanceof \DateTimeInterface) {
16 $value = $value->format('Y-m-d H:i:s');
17 }
18
19 return parent::quoteInto($text, $value, $type, $count);
20}
21
22private function castNumeric($val)
23{
24 if (is_numeric($val)) {
25 return $val + 0;
26 }
27 return $val;
28}



Solution based on:

https://github.com/magento/magento2/pull/25212/commits/b4a6b68e2d4ad403b1e85e8abdf829fb14dd2138

avatar
Mateusz Lasak
Jan 14, 2020
News