db: move function_ptr to raw SQL