Fix #414 stack overflow on sqlite