From c301904ebc3b4d8306d2879ff447b0702326b400 Mon Sep 17 00:00:00 2001 From: cmaffio Date: Wed, 20 Apr 2016 17:07:50 +0200 Subject: [PATCH] sistemazione partizioni --- script/partitioning.pl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/script/partitioning.pl b/script/partitioning.pl index a526b9f..606383b 100755 --- a/script/partitioning.pl +++ b/script/partitioning.pl @@ -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+)'\) .*$/) { - - next if ($1 eq '19700101'); - my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($2); - $ultimo = ($year+1900)."-".i($mon+1)."-".$mday; + 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'); + + $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)) }