fixed invalid num_rows and free for MySQL