Skip to content

Commit

Permalink
Finalizing #5434 - Remove these two settings entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWitness committed Aug 4, 2023
1 parent 9e01ad6 commit 68117e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 56 deletions.
50 changes: 1 addition & 49 deletions cacti.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,56 +27,8 @@

DELIMITER //

--- Remove this legacy function if it exists
DROP FUNCTION IF EXISTS NOAUTOCREATENEEDED//
CREATE FUNCTION NOAUTOCREATENEEDED()
RETURNS BOOL
READS SQL DATA
DETERMINISTIC
BEGIN

DECLARE ret BOOL;
DECLARE ismaria BOOL;

DECLARE majv INT;
DECLARE medv INT;
DECLARE minv INT;

DECLARE realversion VARCHAR(16);

DECLARE majn INT;
DECLARE medn INT;
DECLARE minn INT;

SET ret = TRUE;


SELECT LOCATE('MariaDB', @@version) > 0 INTO ismaria;

IF ismaria THEN
-- MariaDB version NO_AUTO_CREATE_USER started to be default
SET majn = 10;
SET medn = 1;
SET minn = 7;
ELSE
-- MySQL version it started to be default (8.0.11)
SET majn = 8;
SET medn = 0;
SET minn = 11;
END IF;

SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(@@VERSION, '.', 3),'-',1) INTO realversion;
SELECT CONVERT(SUBSTRING_INDEX(realversion, '.', 1), SIGNED INTEGER) INTO majv;
SELECT CONVERT(SUBSTRING_INDEX(SUBSTRING_INDEX(realversion, '.', 2), '.', -1), SIGNED INTEGER) INTO medv;
SELECT CONVERT(SUBSTRING_INDEX(SUBSTRING_INDEX(realversion, '.', 3), '.', -1), SIGNED INTEGER) INTO minv;

IF majv >= majn AND medv >= medn AND minv >= minn THEN
SET ret = FALSE;
END IF;

RETURN ret;
END //

DELIMITER ;

SET @sqlmode= "";
SET SESSION sql_mode = @sqlmode;
Expand Down
17 changes: 10 additions & 7 deletions lib/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ function db_connect_real($device, $user, $pass, $db_name, $db_type = 'mysql', $p
'NO_ZERO_DATE',
'NO_ZERO_IN_DATE',
'ONLY_FULL_GROUP_BY',
'NO_AUTO_VALUE_ON_ZERO',
'NO_ENGINE_SUBSTITUTION',
'NO_AUTO_CREATE_USER'
'NO_AUTO_VALUE_ON_ZERO'
);

$database_sessions["$odevice:$port:$db_name"] = $cnn_id;
Expand Down Expand Up @@ -160,12 +158,18 @@ function db_connect_real($device, $user, $pass, $db_name, $db_type = 'mysql', $p
if (strpos($ver, 'MariaDB') !== false) {
$srv = 'MariaDB';
$ver = str_replace('-MariaDB', '', $ver);
$required_modes[] = 'NO_ENGINE_SUBSTITUTION';
} else {
$srv = 'MySQL';
}

if (version_compare('8.0.0', $ver, '<=')) {
$bad_modes[] = 'NO_AUTO_CREATE_USER';
if (version_compare('8.0.0', $ver, '<=')) {
$bad_modes[] = 'NO_AUTO_CREATE_USER';
$required_modes[] = 'NO_ENGINE_SUBSTITUTION';
}

if (version_compare('8.1.0', $ver, '<=')) {
$bad_modes[] = 'NO_ENGINE_SUBSTITUTION';
}
}

// Get rid of bad modes
Expand All @@ -180,7 +184,6 @@ function db_connect_real($device, $user, $pass, $db_name, $db_type = 'mysql', $p

// Add Required modes
$required_modes[] = 'ALLOW_INVALID_DATES';
$required_modes[] = 'NO_ENGINE_SUBSTITUTION';

foreach ($required_modes as $mode) {
if (array_search($mode, $new_modes, true) === false) {
Expand Down

0 comments on commit 68117e3

Please sign in to comment.