Commit 5a931d59 authored by IKEDA Soji's avatar IKEDA Soji
Browse files

MySQL: probe_db() cannot update int fields with MySQL 8.0.17 or later (#1252)

parent 9d31cceb
......@@ -430,6 +430,31 @@ sub error {
return undef;
}
# Old name: Sympa::DatabaseManager::_check_db_field_type().
sub is_sufficient_field_type {
my $self = shift;
my $required = shift;
my $effective = shift;
my ($required_type, $required_size, $effective_type, $effective_size);
if ($required =~ /^(\w+)(\((\d+)\))?$/) {
($required_type, $required_size) = ($1, $3);
}
if ($effective =~ /^(\w+)(\((\d+)\))?$/) {
($effective_type, $effective_size) = ($1, $3);
}
if ( ($effective_type // '') eq ($required_type // '')
and (not defined $required_size or $effective_size >= $required_size))
{
return 1;
}
return 0;
}
sub set_persistent {
my $self = shift;
my $flag = shift;
......
......@@ -330,6 +330,20 @@ sub get_primary_key {
return \%found_keys;
}
sub is_sufficient_field_type {
my $self = shift;
my $required = shift;
my $actual = shift;
# As of MySQL 8.0.17, the display width attribute is deprecated for
# integer data types (MeriaDB has not).
if ($required =~ /\A((?:tiny|small|medium|big)?int)(?:[(]\d+[)])?\z/
and $actual eq $1) {
return 1;
}
return $self->SUPER::is_sufficient_field_type($required, $actual);
}
sub unset_primary_key {
my $self = shift;
my $param = shift;
......
......@@ -361,9 +361,9 @@ sub _check_fields {
## Change DB types if different and if update_db_types enabled
if ($may_update) {
unless (
_check_db_field_type(
effective_format => $real_struct{$t}{$f},
required_format => $db_struct->{$t}->{$f}
$sdm->is_sufficient_field_type(
$db_struct->{$t}->{$f},
$real_struct{$t}{$f}
)
) {
push @{$report_ref},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment