Skip to content

Instantly share code, notes, and snippets.

View lefred's full-sized avatar

Frédéric Descamps lefred

View GitHub Profile
@lefred
lefred / addtion_to_sys_8.0.2.sql
Last active September 12, 2025 19:03
Addition to MySQL SYS table 8.0.2 for routing GR
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
@lefred
lefred / check_mysql.sh
Created February 15, 2018 21:07
MySQL InnoDB Cluster Consul check
# 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
@lefred
lefred / check_async_mysql.sh
Last active February 19, 2023 11:24
Consul Asynchronous Slave Check
# 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")
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
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,
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;
@lefred
lefred / index.php
Last active May 28, 2021 11:54
php example
<html>
<header>
<title>PHP on OCI with MySQL Database Service</title>
</header>
<body>
<center><h1>PHP on OCI with MySQL Database Service</h1></center>
<hr>
<?php
$user = "";
$pwd = "";
@lefred
lefred / binlog_to_object_storage.sh
Last active September 10, 2021 09:21
streaming binlogs from MDS to Object Storage
#!/bin/bash
if [ $# -eq 0 ]
then
echo "A configuration file is required"
exit 1
fi
CONF_FILE=$1
@lefred
lefred / binlog_to_object_storage.sh
Last active September 10, 2021 10:02
streaming binlogs from MDS HA to Object Storage
#!/bin/bash
if [ $# -eq 0 ]
then
echo "A configuration file is required"
exit 1
fi
CONF_FILE=$1
@lefred
lefred / mds_functions.sql
Last active January 12, 2023 10:55
Addition to MDS
create database mds;
SET GLOBAL log_bin_trust_function_creators = 1;
USE mds;
DROP FUNCTION IF EXISTS get_gtid_to_skip;
DELIMITER |
CREATE FUNCTION get_gtid_to_skip()
RETURNS LONGTEXT
BEGIN