[DATABASE][MariaDB] Always use LONGBLOB for "blob"

"blob" is practically used with the expectation of unlimited length, which is
true with PostgreSQL's bytea, but not with MariaDB's BLOB, which is limited to
64KiB.
So instead use LONGBLOB, which has a maximum of 4GiB, effectively unlimited.
This commit is contained in:
Alexei Sorokin 2020-08-10 10:55:59 +03:00 committed by Diogo Peralta Cordeiro
parent 03e69e8c31
commit 01093e3583
2 changed files with 33 additions and 23 deletions

View File

@ -517,24 +517,31 @@ class MysqlSchema extends Schema
$map = [ $map = [
'integer' => 'int', 'integer' => 'int',
'numeric' => 'decimal', 'numeric' => 'decimal',
'blob' => 'longblob',
]; ];
$type = $column['type']; $type = $column['type'];
if (isset($map[$type])) { if (array_key_exists($type, $map)) {
$type = $map[$type]; $type = $map[$type];
} }
if (!empty($column['size'])) { $size = $column['size'] ?? null;
$size = $column['size']; switch ($type) {
if ($type == 'int' && case 'int':
in_array($size, ['tiny', 'small', 'medium', 'big'])) { if (in_array($size, ['tiny', 'small', 'medium', 'big'])) {
$type = $size . $type;
} elseif ($type == 'float' && $size == 'big') {
$type = 'double';
} elseif (in_array($type, ['blob', 'text']) &&
in_array($size, ['tiny', 'medium', 'long'])) {
$type = $size . $type; $type = $size . $type;
} }
break;
case 'float':
if ($size === 'big') {
$type = 'double';
}
break;
case 'text':
if (in_array($size, ['tiny', 'medium', 'long'])) {
$type = $size . $type;
}
break;
} }
return $type; return $type;

View File

@ -419,12 +419,13 @@ class PgsqlSchema extends Schema
]; ];
$type = $column['type']; $type = $column['type'];
if (isset($map[$type])) { if (array_key_exists($type, $map)) {
$type = $map[$type]; $type = $map[$type];
} }
$size = $column['size'] ?? null; $size = $column['size'] ?? null;
if ($type === 'int') { switch ($type) {
case 'int':
if (in_array($size, ['tiny', 'small'])) { if (in_array($size, ['tiny', 'small'])) {
$type = 'int2'; $type = 'int2';
} elseif ($size === 'big') { } elseif ($size === 'big') {
@ -432,8 +433,10 @@ class PgsqlSchema extends Schema
} else { } else {
$type = 'int4'; $type = 'int4';
} }
} elseif ($type === 'float') { break;
case 'float':
$type = ($size !== 'big') ? 'float4' : 'float8'; $type = ($size !== 'big') ? 'float4' : 'float8';
break;
} }
return $type; return $type;