Move calls to sqlite3_*_bytes to before others.

Calls to this function can cause pointers to become invalid.
Use sqlite3_errmsg where possible.

It gives better error messages than sqlite3_errstr.
Remove needless error checking from regex function.