N°6123 - Fix warnings when launching a backup on MariaDB > v10.6.1 with localhost dbhost

This commit is contained in:
Stephen Abello
2023-07-06 09:28:01 +02:00
parent 6d58adb6dd
commit 246e4a9f50

View File

@@ -307,6 +307,7 @@ class DBBackup
$sPortOption = self::GetMysqliCliSingleOption('port', $this->iDBPort); $sPortOption = self::GetMysqliCliSingleOption('port', $this->iDBPort);
$sTlsOptions = self::GetMysqlCliTlsOptions($this->oConfig); $sTlsOptions = self::GetMysqlCliTlsOptions($this->oConfig);
$sProtocolOption = self::GetMysqlCliTransportOption($this->sDBHost);
$sMysqlVersion = CMDBSource::GetDBVersion(); $sMysqlVersion = CMDBSource::GetDBVersion();
$bIsMysqlSupportUtf8mb4 = (version_compare($sMysqlVersion, self::MYSQL_VERSION_WITH_UTF8MB4_IN_PROGRAMS) === -1); $bIsMysqlSupportUtf8mb4 = (version_compare($sMysqlVersion, self::MYSQL_VERSION_WITH_UTF8MB4_IN_PROGRAMS) === -1);
@@ -327,8 +328,8 @@ EOF;
// Note: opt implicitely sets lock-tables... which cancels the benefit of single-transaction! // Note: opt implicitely sets lock-tables... which cancels the benefit of single-transaction!
// skip-lock-tables compensates and allows for writes during a backup // skip-lock-tables compensates and allows for writes during a backup
$sCommand = "$sMySQLDump --defaults-extra-file=\"$sMySQLDumpCnfFile\" --opt --skip-lock-tables --default-character-set=".$sMysqldumpCharset." --add-drop-database --single-transaction --host=$sHost $sPortOption --user=$sUser $sTlsOptions --result-file=$sTmpFileName $sDBName $sTables 2>&1"; $sCommand = "$sMySQLDump --defaults-extra-file=\"$sMySQLDumpCnfFile\" --opt --skip-lock-tables --default-character-set=".$sMysqldumpCharset." --add-drop-database --single-transaction --host=$sHost $sPortOption $sProtocolOption --user=$sUser $sTlsOptions --result-file=$sTmpFileName $sDBName $sTables 2>&1";
$sCommandDisplay = "$sMySQLDump --defaults-extra-file=\"$sMySQLDumpCnfFile\" --opt --skip-lock-tables --default-character-set=".$sMysqldumpCharset." --add-drop-database --single-transaction --host=$sHost $sPortOption --user=xxxxx $sTlsOptions --result-file=$sTmpFileName $sDBName $sTables"; $sCommandDisplay = "$sMySQLDump --defaults-extra-file=\"$sMySQLDumpCnfFile\" --opt --skip-lock-tables --default-character-set=".$sMysqldumpCharset." --add-drop-database --single-transaction --host=$sHost $sPortOption $sProtocolOption --user=xxxxx $sTlsOptions --result-file=$sTmpFileName $sDBName $sTables";
// Now run the command for real // Now run the command for real
$this->LogInfo("backup: generate data file with command: $sCommandDisplay"); $this->LogInfo("backup: generate data file with command: $sCommandDisplay");
@@ -521,6 +522,24 @@ EOF;
return ' --'.$sCliArgName.'='.self::EscapeShellArg($sData); return ' --'.$sCliArgName.'='.self::EscapeShellArg($sData);
} }
/**
* @param string $sHost
*
* @return string .
* @since 2.7.9 3.0.4 3.1.1 N°6123
*/
public static function GetMysqlCliTransportOption(string $sHost)
{
$sTransportOptions = '';
if($sHost === 'localhost'){
$sTransportOptions = '--protocol=tcp';
}
return $sTransportOptions;
}
/** /**
* @return string the command to launch mysqldump (without its params) * @return string the command to launch mysqldump (without its params)
*/ */