The MySQL server is a large multi-threaded program primarily written in the C++ programming language. Unfortunately, data races and deadlocks in concurrent C++ programs are common. Fortunately, the Thread Sanitizer can be used to find data races and deadlocks. MySQL 5.7 does not support the Thread Sanitizer, but is is easy to add to the MySQL configuration using a simple build procedure. When MySQL 5.7 is built with the Thread Sanitizer and database …
[Read more]
Showing entries 1 to 2
Dec
07
2015
Mar
21
2012
The other day, I was troubleshooting a deadlock, and I wondered if any of the table’s columns were referenced by any foreign keys (fks) from any other tables in the instance.
Well, this is actually very simple with information_schema (I_S):
SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME='parent';
Where `parent` is the name of the table you’re searching for.
Note this query does not restrict on the database, or schema, name, but that could easily be added (or any other number of conditions). Here is an example where I only return the most useful columns (which could be useful for determining said conditions):
SELECT CONSTRAINT_SCHEMA, CONSTRAINT_NAME, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_SCHEMA, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME='parent';
If there …
[Read more]
Showing entries 1 to 2