MDEV-6575: main.view --ps-protocol fails in ANALYZE code

- After PREPARE is done, save the value of thd->select_number
  (this is what will be assigned to next select_lex object)
- Restore the value at each execution of the prepared statement.
Merge branch '10.1' of github.com:MariaDB/server into 10.1