ThinkPart

Andrey's blog

 

mysql client cmdline option which easies the life of the connector developer

 

MySQL 5.1 was released as GA not long ago (current version 5.1.32). I work at SUN/MySQL as a connector developer. Currently working on Connector/C++, previously I used to develop mysqlnd of the PHP fame, currently I maintain it. Every single day I work with the MySQL Server and like everything in this world, it's imperfect. You know perpetuum mobile doesn't exist.

During the early days of mysqlnd development I needed to sniff the network traffic with ethereal, now wireshark, to know what flows between libmysql and the server. The MySQL client/server protocol is not very well documented and there are many blank spaces in the documentation, especially in regard to the prepared statements. MySQL 5.1's command line client `mysql` comes with a new option built-in to dump the result metadata which the server sends.

--column-type-info     Display column type information

andrey@winnie:/work/m51/client$ ./mysql --column-type-info
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2023
Server version: 5.0.80-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> create table tbl1(a int);
Query OK, 0 rows affected (0.03 sec)

mysql> insert into tbl1 values(123);
Query OK, 1 row affected (0.04 sec)

mysql> select * from tbl1;
Field   1:  `a`
Catalog:    `def`
Database:   `test`
Table:      `tbl1`
Org_table:  `tbl1`
Type:       LONG
Collation:  binary (63)
Length:     11
Max_length: 3
Decimals:   0
Flags:      NUM


+------+
| a    |
+------+
|  123 |
+------+
1 row in set (0.00 sec)

Leave a reply

Comments are disabled for this post.