[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
parent 07b0aa8f52
commit 8bc714a2b1
2 changed files with 33 additions and 23 deletions

View File

@ -517,24 +517,31 @@ class MysqlSchema extends Schema
$map = [
'integer' => 'int',
'numeric' => 'decimal',
'blob' => 'longblob',
];
$type = $column['type'];
if (isset($map[$type])) {
if (array_key_exists($type, $map)) {
$type = $map[$type];
}
if (!empty($column['size'])) {
$size = $column['size'];
if ($type == 'int' &&
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'])) {
$size = $column['size'] ?? null;
switch ($type) {
case 'int':
if (in_array($size, ['tiny', 'small', 'medium', 'big'])) {
$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;

View File

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