Follow-up for the patch for bugs #12472/#15137 "CREATE TABLE ... SELECT ... which explicitly or implicitly uses stored function gives 'Table not locked' error"
Follow-up for the patch for bugs #12472/#15137 "CREATE TABLE ... SELECT ...
which explicitly or implicitly uses stored function gives 'Table not locked'
error"

Test case for these bugs crashed in --ps-protocol mode. The crash was caused
by incorrect usage of check_grant() routine from create_table_precheck()
routine. The former assumes that either number of tables to be inspected by
it is limited explicitly (i.e. is is not UINT_MAX) or table list used and
thd->lex->query_tables_own_last value correspond to each other.
create_table_precheck() was not fulfilling this condition and crash happened.
The fix simply sets number of tables to be inspected by check_grant() to 1.


sql/sql_parse.cc:
  create_table_precheck():
    At the moment when create_table_precheck() is called TABLE_LIST element
    representing table to be created does not belong to global table list
    therefore we should limit number of tables to be inspected by check_grant()
    explicitly (as in this case table list passed to this function does not
    correspond to thd->lex->query_tables_own_last value).

flynn1973/mariadb-aix,flynn1973/mariadb-aix,flynn1973/mariadb-aix,natsys/mariadb_10.2,ollie314/server,natsys/mariadb_10.2,slanterns/server,davidl-zend/zenddbi,flynn1973/mariadb-aix,davidl-zend/zenddbi,ollie314/server,davidl-zend/zenddbi,flynn1973/mariadb-aix,davidl-zend/zenddbi,natsys/mariadb_10.2,ollie314/server,ollie314/server,natsys/mariadb_10.2,natsys/mariadb_10.2,davidl-zend/zenddbi,flynn1973/mariadb-aix,natsys/mariadb_10.2,flynn1973/mariadb-aix,davidl-zend/zenddbi,flynn1973/mariadb-aix,flynn1973/mariadb-aix,davidl-zend/zenddbi,davidl-zend/zenddbi,natsys/mariadb_10.2,natsys/mariadb_10.2,flynn1973/mariadb-aix,ollie314/server,ollie314/server,natsys/mariadb_10.2,davidl-zend/zenddbi,ollie314/server,davidl-zend/zenddbi,ollie314/server,flynn1973/mariadb-aix,ollie314/server,natsys/mariadb_10.2,natsys/mariadb_10.2,ollie314/server,davidl-zend/zenddbi,ollie314/server