4343 exit 1;
4444}
4545
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
4950 FROM information_schema.partitions
5051 WHERE partition_name IS NOT NULL AND table_schema = ?} );
5152$sth -> execute($db_schema );
7273
7374sub check_have_partition {
7475 my $result = 0;
76+
7577# 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';
80+ #
81+ # End of Mysql 5.5
7982
83+ # MySQL 5.6 + MariaDB
84+ # my $sth = $dbh->prepare(qq{SELECT plugin_status FROM information_schema.plugins WHERE plugin_name = 'partition'});
85+ #
86+ # $sth->execute();
87+ #
88+ # my $row = $sth->fetchrow_array();
89+ #
90+ # $sth->finish();
91+ # return 1 if $row eq 'ACTIVE';
92+ #
93+ # End of MySQL 5.6 + MariaDB
94+
95+ # MySQL 8.x (NOT MariaDB!)
96+ my $sth = $dbh -> prepare(qq{ select version();} );
8097 $sth -> execute();
81-
8298 my $row = $sth -> fetchrow_array();
83-
99+
84100 $sth -> finish();
101+ return 1 if $row >= 8;
102+ #
103+ # End of MySQL 8.x
85104
86- # MySQL 5.5
87- # return 1 if $row eq 'YES';
88- # MySQL 5.6 + MariaDB
89- return 1 if $row eq ' ACTIVE' ;
105+ # Do not uncomment last }
90106}
91107
92108sub create_next_partition {
@@ -97,7 +113,6 @@ sub create_next_partition {
97113 for (my $curr_part = 0; $curr_part < $amount_partitions ; $curr_part ++) {
98114 my $next_name = name_next_part($tables -> {$table_name }-> {' period' }, $curr_part );
99115 my $found = 0;
100-
101116 foreach my $partition (sort keys %{$table_part }) {
102117 if ($next_name eq $partition ) {
103118 syslog(LOG_INFO, " Next partition for $table_name table has already been created. It is $next_name " );
0 commit comments