[mysql] check db state before select.