jump to navigation

Mysql Internals

My Mysql Book

I bought the book “Expert MySql” by Charles A.Bell last week to get to know mysql under the hood. The book has been written in an excellent way and care has been taken to present all the dificult concepts in a very incremental manner which makes it highly easy to understand. Within a few days I was able to make very good progress, something I had been trying over the past 2 weeks by reading the online Mysql Internal tutorials from the wiki.

Test-Driven Mysql Development

Here is an example of how u can use the mysql Test suite to develop ur own tests. Create the test-file as given below and save it in t/cab.test

test-file = /mysql-test/t/cab.test

#
#Sample test to demonstrate MySQL Test Suite
#
–disable_warnings
SHOW DATABASES;
–enable_warnings
CREATE TABLE characters (ID INTEGER PRIMARY KEY,LastName    varchar(40),FirstName     varchar(20),Gender    varchar(2))TYPE = MYISAM;
EXPLAIN characters;
#
Insert into characters Values
(3,’Flintstone’,’Fred’,’M’),
(5,’Rubble’,’Barney’,’M’),
(7,’Flintstone’,’Wilma’,’F’),
(9,’Flintstone’,’Dino’,’M’),
(4,’Flintstone’,’Pebbles’,’F’),
(1,’Rubble’,’Betty’,’F’),
(6,’Rubble’,’Bam-Bam’,’M’),
(8,’Jetson’,’George’,’M’);
#
Select * from characters;
#
Select * from characters where FirstName=’Fred’;
#
Explain    (Select distinct lastname from characters);
#
Select Distinct Lastname from characters;
#
#Cleanup
#
Drop Table characters;
# … and we’re done.

Now a sample execution :

$ ./mysql-test-run.pl cab
Logging: ./mysql-test-run.pl cab
MySQL Version 5.1.24


Killing Possible Leftover Processes
Removing Stale Files
Creating Directories

….
Installing Master Database
=======================================================

TEST                           RESULT         TIME (ms)
——————————————————-

main.cab                       [ fail ]

….

mysqltest: Result content mismatch
….
Aborting: main.cab failed in default mode.
To continue, re-run with ‘–force’.
Stopping All Servers

$cp   r/cab.reject   r/cab.result

$ ./mysql-test-run.pl cab
Logging: ./mysql-test-run.pl cab
MySQL Version 5.1.24

Killing Possible Leftover Processes
Removing Stale Files
Creating Directories
Installing Master Database
=======================================================

TEST                           RESULT         TIME (ms)
——————————————————-

main.cab                       [ pass ]            181
——————————————————-
Stopping All Servers
All 1 tests were successful.
The servers were restarted 1 times
Spent 0.181 of 3 seconds executing testcases
$

Thus in the above manner we create a test to test anyone functionality on the mysql server.

Advertisements

Comments»

No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: