Date

Last weekend I started a shell that is based on the core libs of the MySQL Proxy and now code is good enough to be really useful.

As the shell is internally driven with a lua-script it is very easy to change the display or the way how the result of a query is processed. A simple feature that comes to mind is appending a SHOW WARNINGSwhenever query resulted in warning.

root@127.0.0.1:3306 []> create table t2 ( id serial ) engine = foo;
OK (warnings: 2, auto-commit: true, affected rows: 0, insert-id: 0)
+---------+------+--------------------------------------------+
|  Level  | Code |                  Message                   |
+---------+------+--------------------------------------------+
| Warning | 1286 | Unknown table engine 'foo'                 |
| Warning | 1266 | Using storage engine MyISAM for table 't2' |
+---------+------+--------------------------------------------+
OK (warnings: 0, auto-commit: true)

This automaticly makes EXPLAIN EXTENDED a lot more useful as we see how it rewrites our queries:

root@127.0.0.1:3306 []> EXPLAIN EXTENDED SELECT (SELECT 1);
+----+-------------+-------+------+---------------+------+---------+------+------+----------+----------------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows | filtered |     Extra      |
+----+-------------+-------+------+---------------+------+---------+------+------+----------+----------------+
|  1 | PRIMARY     |  NULL | NULL |          NULL | NULL |    NULL | NULL | NULL |     NULL | No tables used |
+----+-------------+-------+------+---------------+------+---------+------+------+----------+----------------+
OK (warnings: 2, auto-commit: true)
+-------+------+------------------------------------------+
| Level | Code |                 Message                  |
+-------+------+------------------------------------------+
| Note  | 1249 | Select 2 was reduced during optimization |
| Note  | 1003 | SELECT 1 AS `(SELECT 1)`                 |
+-------+------+------------------------------------------+
OK (warnings: 0, auto-commit: true)

Comments

Enable javascript to load comments.