From 406b4cb6457c88937f61f5a42c61b4ff43a760ab Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Tue, 19 Nov 2019 16:26:53 +0100 Subject: [PATCH] TT#71051 sync-db sync timezone delimiter * add support for MariaDB timezones sync sql delimiter as now in the generated sql stream output there are sections with '\d' changing the delimiter behaviour. Change-Id: If226db7018f431ff4248dcf6ff5a614ff96a45c7 --- helper/sync-db | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/helper/sync-db b/helper/sync-db index 438cc2e7..af662a2c 100755 --- a/helper/sync-db +++ b/helper/sync-db @@ -203,7 +203,6 @@ sub sync_db_timezones { chomp $tzinfo_version; my $sql = ''; - my $p_rs = $RS; eval { $dbh->begin_work() or die "Cannot start tx: $DBI::errstr\n"; my ($cur_tzinfo_version) = $dbh->selectrow_array(<do('USE mysql') or die "Cannot use mysql database: $DBI::errstr\n"; + my $batch; + my $delim = ';'; while ($sql = <$sql_stream>) { - map { - $dbh->do($_) or die "Cannot insert timezone data: $DBI::errstr\n"; - } split /;\s+/, $sql; # multiple one line statements + if ($sql =~ m#^\s*\\d\s+(\S+)#) { + $delim = $1; + } else { + if ($sql =~ /^(.*)\Q$delim\E\s*$/) { + if ($1) { + $batch .= $1; + } + $dbh->do($batch) or die "Cannot insert timezone data: $DBI::errstr\n"; + $batch = undef; + } else { + $batch .= $sql; + } + } } close $sql_stream; $dbh->do(<rollback(); return; }