Set default db charset for MySQL ido resources to latin1

latin1 seems to be the only supported charset for MySQL but the current upstream default charset is utf8mb4 and to be safe it should be set explicitly
This commit is contained in:
Massimiliano Torromeo 2020-04-03 11:40:46 +02:00 committed by Johannes Meyer
parent bf677ac29d
commit 9a29d8f3d4
1 changed files with 5 additions and 1 deletions

View File

@ -222,7 +222,11 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface
public function getResource()
{
if ($this->resource === null) {
$this->resource = ResourceFactory::create($this->config->get('resource'));
$config = ResourceFactory::getResourceConfig($this->config->get('resource'));
if ($this->is('ido') && $config->type === 'db' && $config->db === 'mysql' && $config->charset === null) {
$config->charset = 'latin1';
}
$this->resource = ResourceFactory::createResource($config);
if ($this->is('ido') && $this->resource->getDbType() !== 'oracle') {
// TODO(el): The resource should set the table prefix
$this->resource->setTablePrefix('icinga_');