Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Bugfix/purgeengine regex #11258

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion www/class/centreonPurgeEngine.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private function checkTablesPartitioned()
$row = $DBRESULT->fetchRow();
$matches = [];
// dont care of MAXVALUE
if (preg_match_all('/PARTITION `(.*?)` VALUES LESS THAN \((.*?)\)/', $row['Create Table'], $matches)) {
if (preg_match_all('/PARTITION (.*?) VALUES LESS THAN \((.*?)\)/', $row['Create Table'], $matches)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (preg_match_all('/PARTITION (.*?) VALUES LESS THAN \((.*?)\)/', $row['Create Table'], $matches)) {
if (preg_match_all('/PARTITION [^a-zA-Z\d\s:]?(\w+)[^a-zA-Z\d\s:]? VALUES LESS THAN [^a-zA-Z\d\s:]?(\w+)[^a-zA-Z\d\s:]?/', $row['Create Table'], $matches)) {

Copy link
Contributor

@TamazC TamazC Sep 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depending on database vendor backquote sign could be there.
So I suggest to add expression [^a-zA-Z\d\s:]? for match this sign and ( ) signs in SHOW CREATE TABLE output.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->tablesToPurge[$name]['is_partitioned'] = true;
$this->tablesToPurge[$name]['partitions'] = [];
for ($i = 0; isset($matches[1][$i]); $i++) {
Expand Down