sistemazione partizioni
This commit is contained in:
@@ -87,7 +87,6 @@ sub inizializza {
|
||||
}
|
||||
|
||||
sub aggiorna {
|
||||
|
||||
my $dbmysql = shift;
|
||||
my $tabella = shift;
|
||||
my $campo = shift;
|
||||
@@ -103,11 +102,11 @@ sub aggiorna {
|
||||
|
||||
my $ultimo = "";
|
||||
foreach $riga (@risp) {
|
||||
if ($riga =~ /^[\(\s]?PARTITION p(\d+) VALUES LESS THAN \((\d+)'\) .*$/) {
|
||||
if ($riga =~ /^[\(\s]?PARTITION p(\d{4})(\d{2})(\d{2}) VALUES LESS THAN \(\d+\) .*$/) {
|
||||
my $p = "$1$2$3";
|
||||
next if ($p eq '19700101');
|
||||
|
||||
next if ($1 eq '19700101');
|
||||
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($2);
|
||||
$ultimo = ($year+1900)."-".i($mon+1)."-".$mday;
|
||||
$ultimo = "$1-$2-$3";
|
||||
my $diff = diffgg ($ultimo);
|
||||
|
||||
if ($diff > 365) {
|
||||
@@ -128,9 +127,10 @@ sub aggiorna {
|
||||
my @tmp0 = split / /, $ultimo;
|
||||
my @tmp = split /-/, $tmp0[0];
|
||||
my $p = $tmp[0].$tmp[1].$tmp[2];
|
||||
$inquery .= "PARTITION p$p VALUES LESS THAN ('$ultimo'),\n";
|
||||
$inquery .= "PARTITION p$p VALUES LESS THAN ( TO_DAYS('$ultimo') ),\n";
|
||||
}
|
||||
$query = "$prequery$inquery$postquery";
|
||||
print "$query\n" if ($messaggi);
|
||||
$sts = $dbmysql->prepare($query);
|
||||
$sts->execute ();
|
||||
|
||||
@@ -159,5 +159,5 @@ sub addgg {
|
||||
my @part = split /-/, $data;
|
||||
my @tempo = (59, 59, 23, $part[2], $part[1]-1, $part[0]-1900);
|
||||
my $tempo = timelocal(@tempo) + 86400;
|
||||
return strftime('%Y-%m-%d %H:%M:%S',localtime($tempo))
|
||||
return strftime('%Y-%m-%d',localtime($tempo))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user