Reinitializable database

It is now possible to init_db, run sql functions, close_db and then
init_db and run sql functions again. The prepcache stmt pointer had to
be changed to point to the actual static pointer in the sql functions to
be able to reset them to NULL when they are freed by close_db.