sql query in post-auth - segmentation fault