get_sql + IF EXISTS warnings

get_sql + IF EXISTS warnings

* get_sql handles invalid mv_id and non-defined mv
* tests for get_sql
* re-ordered tests in code
* suppress if exists warnings (1051) everywhere