Fix SQL related crash