A couple of comments:
Re: "the standard linux-user-name-matches-the-mysql-account-name authentication" - I assume you mean using the unix_socket plugin for authentication. This only works on localhost, i.e. the user has to be logged in on the database server.
There is no MariaDB 5.7, but there is however a MySQL 5.7.
There is no need to build your own RPM ...
FROM ( full text of query 1 )
WHERE (condition 1)
FROM ( full text of query 2 )
WHERE (condition 2)
AND NOT (condition 1)
Neither condition must give NULL (due to NULL in field/variable values) in NOT.
Outer SELECTs for each separate subquery in UNION may be excess if separate queries are not complex.
For the code shown in ...
Don't compare a VARCHAR to a numeric literal. It cannot use an index. Either change session to BIGINT or add quotes to the comparison:
AND session = '1564752045544'
PRIMARY KEY(amount, session, win_digit) -- if it is unique
Simplify the "RIGHT" tests. I think the 3 OR items can be changed to simply
AND `user_given_numbers`.`input_digit` =...
SP can be like (draft code):
CREATE PROCEDURE DeleteFromGeneralLogs (IN DeleteTill DATETIME)
DECLARE done INT DEFAULT 0;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done:=1;
-- IF DeleteTill IS NULL THEN LEAVE;
WHILE done = 0 DO
SELECT SLEEP(1) INTO done; -- small pause between chunks
This is yet another installment of the MySQL sql_mode = only_full_group_by saga.
The problem is that MySQL's default (till 8) will return results which, depending on the order of the records being INSERTed into the table (and/or PRIMARY KEY ordering), will vary and be correct or wrong DEPENDING. This is absolutely the worst sort of difficult to ...