get_sql + IF NOT 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)