This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET GLOBAL log_bin_trust_function_creators = 1; | |
USE sys; | |
DROP FUNCTION IF EXISTS GTID_IS_EQUAL; | |
DROP FUNCTION IF EXISTS GTID_IS_DISJOINT; | |
DROP FUNCTION IF EXISTS GTID_IS_DISJOINT_UNION; | |
DROP FUNCTION IF EXISTS GTID_NORMALIZE; | |
DROP FUNCTION IF EXISTS GTID_UNION; | |
DROP FUNCTION IF EXISTS GTID_INTERSECTION; | |
DROP FUNCTION IF EXISTS GTID_SYMMETRIC_DIFFERENCE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use sys; | |
DROP VIEW IF EXISTS replication_status; | |
CREATE | |
ALGORITHM = MERGE | |
SQL SECURITY INVOKER | |
VIEW replication_status | |
AS | |
SELECT | |
concat(conn_status.channel_name, ' (', worker_id,')') AS channel, | |
conn_status.service_state AS io_state, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE sys; | |
DELIMITER $$ | |
CREATE FUNCTION my_id() RETURNS TEXT(36) DETERMINISTIC NO SQL RETURN (SELECT @@global.server_uuid as my_id);$$ | |
-- new function, contribution from Bruce DeFrang | |
CREATE FUNCTION gr_member_in_primary_partition() | |
RETURNS VARCHAR(3) | |
DETERMINISTIC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# script used in consul to check if mysql is primary master and asynchronous slave | |
# v.0.1 - lefred 2018-02-16 | |
SLAVEOFDC="dc2" | |
SLAVEUSER="async_repl" | |
SLAVEPWD="asyncpwd" | |
# check if we are the primary one | |
ROLE=$(mysql -h 127.0.0.1 -BNe "select MEMBER_ROLE from performance_schema.replication_group_members where MEMBER_HOST=@@hostname") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# script used in consul | |
# the following addition to sys is required: | |
# https://gist.github.com/lefred/153448f7ea0341d6d0daa2738db6fcd8 | |
# v.0.1 - lefred 2018-02-14 | |
read -r mysql_primary mysql_readonly mysql_tx mysql_cert <<<$(mysql -h 127.0.0.1 -P 6446 -BNe "select * from sys.gr_member_routing_candidate_status") | |
if [[ "${mysql_primary}" == "YES" ]] && [[ "${mysql_readonly}" == "NO" ]] | |
then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE sys; | |
DELIMITER $$ | |
CREATE FUNCTION my_id() RETURNS TEXT(36) DETERMINISTIC NO SQL RETURN (SELECT @@global.server_uuid as my_id);$$ | |
-- previous obsolete function | |
-- CREATE FUNCTION gr_member_in_primary_partition() | |
-- RETURNS VARCHAR(3) | |
-- DETERMINISTIC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE sys; | |
DELIMITER $$ | |
CREATE FUNCTION IFZERO(a INT, b INT) | |
RETURNS INT | |
DETERMINISTIC | |
RETURN IF(a = 0, b, a)$$ | |
CREATE FUNCTION LOCATE2(needle TEXT(10000), haystack TEXT(10000), offset INT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!#/bin/bash | |
# date 2017-01-23 | |
proxy_user=admin | |
proxy_pwd=admin | |
proxy_port=6032 | |
proxy_host=127.0.0.1 | |
username=devel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql2 mysql> select str_to_date('9','%m'); | |
+-----------------------+ | |
| str_to_date('9','%m') | | |
+-----------------------+ | |
| NULL | | |
+-----------------------+ | |
1 row in set, 1 warning (0.00 sec) | |
mysql2 mysql> show variables like 'sql_mode'\G | |
*************************** 1. row *************************** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET GLOBAL wsrep_desync=on; | |
FLUSH TABLES WITH READ LOCK; | |
...wait until the queue rises to be quite high, about 20.000 | |
UNLOCK TABLES; use test; | |
SELECT sum(trx) as transactions, sum(duration) as time, | |
IF(sum(duration) < 5, 'DID NOT TAKE LONG ENOUGH TO BE ACCURATE', | |
ROUND(SUM(trx)/SUM(duration))) | |
AS transactions_per_second | |
FROM | |
(SELECT VARIABLE_VALUE * -1 AS trx, null as duration |