Fix subquery syntax error on Android 2.3

Prompted by [this bug report](https://github.com/pouchdb/pouchdb/issues/2434#issuecomment-48587941).

For the `rowsAffected` compatibility logic, I forgot to account for the case of subqueries. Also, I forgot to wrap the `prepareStatement` in a try/catch, meaning if the SELECT query throws, then the whole thing fails.  This fixes both problems and adds some unit tests to verify.

Tested on Android 4.4, Android 2.3, and iOS 7, no regressions.