Skip to content

Instantly share code, notes, and snippets.

View abg's full-sized avatar

Andrew Garner abg

  • VMware
  • San Antonio
View GitHub Profile
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
@abg
abg / kikori.sh
Last active September 17, 2018 00:29
kikori - a MySQL binary log archive utility
#!/bin/bash
### kikori - a MySQL binary log archive utility
# Support config options
format="${KIKORI_FORMAT:-directory}"
archive_path="${KIKORI_ARCHIVE_PATH:-/var/log/mysql/archive}"
compression_cmd="${KIKORI_COMPRESSION_CMD:-gzip -1}"
compression_ext="${KIKORI_COMPRESSION_EXT:-.gz}"
@abg
abg / frmsearch.py
Last active August 29, 2015 14:07
Scan .frm files in a MySQL datadir for old DATE/TIME/TIMESTAMP columns
'''
Simple frmsearch command to find tables with pre 5.6 date/time types.
Run this via:
# curl get.dbsake.net > dbsake
# DATADIR=$(mysql -sse 'select @@datadir') PYTHONPATH=$PWD/dbsake python frmsearch.py
ALTER TABLE `mysql`.`procs_priv` FORCE;
ALTER TABLE `mysql`.`columns_priv` FORCE;
ALTER TABLE `mysql`.`general_log` FORCE;
@abg
abg / filters.py
Last active August 29, 2015 14:10
inclusion/exclusion filter implementation
#!/usr/bin/env python
import fnmatch
def inclusion_exclusion_filter(include=(), exclude=()):
"""Create an inclusion exclusion filter
:param include: sequence of glob patterns to include
:param exclude: sequence of glob patterns to exclude
:returns: function(name) that filters strings based on the provided filters
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -17158,6 +17158,11 @@ ib_warn_row_too_big(const dict_table_t* table)
THD* thd = current_thd;
+ /* If current_thd is NULL, don't send a warning to the client */
+ if(thd == NULL) {
+ return;
+ }
@abg
abg / mysql_bug_75245_5622.patch
Created December 18, 2014 16:33
mysql_bug_75245_5622.patch
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -17158,6 +17158,10 @@ ib_warn_row_too_big(const dict_table_t* table)
THD* thd = current_thd;
+ if(thd == NULL) {
+ return;
+ }
+
@abg
abg / mysql.py
Last active September 17, 2018 13:50
Run queries directly against MySQL via subprocess, rather than using MySQLdb
"""Examples fetching data from MySQL via /usr/bin/mysql"""
import subprocess
def get_innodb_log_file_size():
"""Run SELECT @@innodb_log_file_size and return the value as an integer"""
process = subprocess.Popen(['mysql', '-ss'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
'''
Simple frmsearch command to find tables without a primary key
Run this via:
# curl get.dbsake.net > dbsake
# export DATADIR=$(mysql -sse 'select @@datadir') PYTHONPATH=$PWD/dbsake
# python find_nopk.py
!! mysql.slow_log does not appear to have a primary key !!
---
"""
Iterative table checksum of tables with composite keys
This uses an algorithm similar to mk-table-sync's Nibble
algorithm but intended purely for checking if a master/slave
are in sync.
"""
import os, sys
import time
import warnings
@abg
abg / mdev_8865.py
Last active October 30, 2015 05:09
#!/usr/bin/env python
import os
import pprint
import random
import MySQLdb
c = MySQLdb.connect(read_default_file=os.path.abspath('my.sandbox.cnf'), db='test')
cursor = c.cursor()