Simply said I have to write an application to synchronise several database tables. Because of the requirements the changes should be put into a queue (in form of a SQL statement) and here lies the problem: I’m not able to change the existing application which uses the database to add the executed query directly into the queue. Therefore I need to catch all data changing SQL queries of specific tables (> 20 tables) in the database.
I though about the following solutions:
- To catch directly the MySQL query with triggers like it is described Can a trigger access the query string (best answer for this case I could find!), but I couldn’t get the query that actives the trigger – only the query that I used within it.
- To active the General Query Log. But I read about heavy performance considerations and so it isn’t an arguable solution, because it would log even the tables I don’t need (> 120 tables) and a lot of simple queries run on the database.
- To use a history table filled by trigger. With this I wouldn’t save the SQL statement of the queries with this solution (which would slow down my current concept of synchronisation), but it would be possible to realise.
Does someone know any other solution or how I could do the impossible by accessing the query within a trigger?
I’m grateful about any suggestion!
Related questions:
Can a trigger access the query string
Log mysql db changing queries and users
you could setup mysql proxy https://launchpad.net/mysql-proxy between existing application and mysql server. And intercept/modify/add any queries in the proxy.