Smart SQL for iOS

Merged smart_sql to unstable20 in my fork. And doing a pull request from there.