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
changes/92/35392/2
Kirill Solomko 6 years ago
parent 549d2c71a2
commit 406b4cb645

@ -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(<<SQL)
@ -217,13 +216,24 @@ SQL
open(my $sql_stream, "<", \$out)
or die "Cannot open sql stream: $ERRNO\n";
binmode($sql_stream);
local $RS = ";\n";
$dbh->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(<<SQL, undef, $tzinfo_version, $tzinfo_version)
@ -232,10 +242,9 @@ INSERT INTO ngcp.tzinfo_version SET version = ?
SQL
or die "Cannot insert into ngcp.tzinfo_version: $DBI::errstr\n";
};
local $RS = $p_rs;
$err = $EVAL_ERROR;
if ($err) {
print $err,"sql: $sql\n";
print $err;
$dbh->rollback();
return;
}

Loading…
Cancel
Save