common_schema, revision 178 is now released, with major additions. This revision turns common_schema into a framework, rather than a set of views and functions.
common_schema provides with query scripting, analysis & informational views, and a function library, allowing for easier administration and diagnostics for MySQL. It introduces SQL based tools which simplify otherwise complex shell and client scripts, allowing the DBA to be independent of operating system, installed packages and dependencies.
There’s no Perl nor Python, and no dependencies to install. It’s just a schema.
Some highlights for the new revision:
- foreach(), aka $(): loop through a collection, execute callback commands per element.
- repeat_exec(): a repeat-until device: execute queries until some condition holds.
- exec_file(): execute files a-la SOURCE, but on server side
- Query analysis: analyze query text, view or routine definitions to detect dependency objects.
- Improvements to views and routines, new routines introduced.
Let’s take a closer look:
rpbouman
I’m very happy to have Roland Bouman working on this project. He introduced some sophisticated code without which some functionality could not take place. I’m sure I don’t need to introduce his great capabilities; I’ll just pass the note that it is very good working with him!
foreach()
Introducing a looping device which can iterate a collection and execute callback commands.
What’s a collection? A range of numbers; a set of constants; the result set of a SELECT query; tables in your database and more.
What is a callback? A query or set of queries to invoke on the specific elements in the collection. For example:
call foreach('table in sakila', 'ALTER TABLE ${schema}.${table} ENGINE=InnoDB ROW_FORMAT=COMPRESSED');
I’ll publish dedicated posts on foreach(), aka $(), following this post. Official documentation is here.
repeat_exec()
Repeat executing queries in a given interval, until some condition holds.
What kind of condition? You can loop forever, or until a given time has passed, a given number of iteration has passed. Continue reading » “common_schema, rev. 178: foreach(), repeat_exec(), Roland Bouman, query analysis”