43
43
exit 1;
44
44
}
45
45
46
- my $sth = $dbh -> prepare(qq{ SELECT table_name, partition_name, lower(partition_method) as partition_method,
47
- rtrim(ltrim(partition_expression)) as partition_expression,
48
- partition_description, table_rows
46
+ my $sth = $dbh -> prepare(qq{ SELECT table_name as table_name, partition_name as partition_name,
47
+ lower(partition_method) as partition_method,
48
+ rtrim(ltrim(partition_expression)) as partition_expression,
49
+ partition_description as partition_description, table_rows
49
50
FROM information_schema.partitions
50
51
WHERE partition_name IS NOT NULL AND table_schema = ?} );
51
52
$sth -> execute($db_schema );
72
73
73
74
sub check_have_partition {
74
75
my $result = 0;
76
+
75
77
# MySQL 5.5
76
- # my $sth = $dbh->prepare(qq{SELECT variable_value FROM information_schema.global_variables WHERE variable_name = 'have_partitioning'});
77
- # MySQL 5.6 + MariaDB
78
- my $sth = $dbh -> prepare(qq{ SELECT plugin_status FROM information_schema.plugins WHERE plugin_name = 'partition'} );
78
+ # #my $sth = $dbh->prepare(qq{SELECT variable_value FROM information_schema.global_variables WHERE variable_name = 'have_partitioning'});
79
+ # return 1 if $row eq 'YES';
79
80
81
+ # MySQL 5.6 + MariaDB
82
+ # my $sth = $dbh->prepare(qq{SELECT plugin_status FROM information_schema.plugins WHERE plugin_name = 'partition'});
83
+ #
84
+ # $sth->execute();
85
+ #
86
+ # my $row = $sth->fetchrow_array();
87
+ #
88
+ # $sth->finish();
89
+ # return 1 if $row eq 'ACTIVE';
90
+
91
+ # MySQL 8.x (NOT MariaDB!)
92
+ my $sth = $dbh -> prepare(qq{ select version();} );
80
93
$sth -> execute();
81
-
82
94
my $row = $sth -> fetchrow_array();
83
-
95
+
84
96
$sth -> finish();
97
+ return 1 if $row >= 8;
85
98
86
- # MySQL 5.5
87
- # return 1 if $row eq 'YES';
88
- # MySQL 5.6 + MariaDB
89
- return 1 if $row eq ' ACTIVE' ;
99
+ # Do not uncomment last }
90
100
}
91
101
92
102
sub create_next_partition {
@@ -97,7 +107,6 @@ sub create_next_partition {
97
107
for (my $curr_part = 0; $curr_part < $amount_partitions ; $curr_part ++) {
98
108
my $next_name = name_next_part($tables -> {$table_name }-> {' period' }, $curr_part );
99
109
my $found = 0;
100
-
101
110
foreach my $partition (sort keys %{$table_part }) {
102
111
if ($next_name eq $partition ) {
103
112
syslog(LOG_INFO, " Next partition for $table_name table has already been created. It is $next_name " );
0 commit comments