Allow SQL_NO_FCACHE to also work for nested queries

Summary:
Between 5.1 and 5.6 Oracle refactored the parsing of nested queries.
The result is that nested queries do not go through the select_option
rule like they did in 5.1. Move the SQL_NO_FCACHE handling to the
query_expression_options rule, which is used for both top-level and
nested queries.

Test Plan: Jenkins run of newly added test case

Reviewers: steaphan, santoshb

Reviewed By: santoshb
Fix main.connect test

Summary:
This is a fix for the test for the fix for: http://bugs.mysql.com/70026

The main.connect mtr test fails with error 2013 sometimes.  Using
wait_until_connected_again.inc after enable_reconnect in the test case
fixes this issue.

Test Plan:
mysqltest.sh --repeat=32 --parallel=32 main.connect

Reviewers: jtolmer, steaphan

Reviewed By: steaphan
store gtid of the last transaction in innodb system header

Summary:
This is useful in reusing crashed master with enhance semi-sync as
a slave immediately. For DDL queries no gtid is stored in innondb
system header since DDL's doesn't go through innondb commit.
This will not work with multi-master topologies since we are not storing
entire @gtid_executed set. Storing entire @gtid_executed in innodb system
header is not a good idea since @gtid_executed may be very big.

Test Plan:
Crashed the master in the test case and verified the
gtid printed in the error log during crashing recovery.

mysqltest.sh --valgrind

Reviewers: rudradevbasak, jtolmer, steaphan

Reviewed By: rudradevbasak
Improve optimizer row estimates for partitioned tables.

Summary:
This fixes:  bugs.mysql.com/70265

This reverts the change in this diff:
	http://bazaar.launchpad.net/~mysql/mysql-server/5.6/revision/2661.835.1#sql/ha_partition.cc

It makes the behavior more like in 5.1, but instead of a fixed maximum of
10 partitions, the new variable "part_scan_max" controls this, though
it still defaults to 10.

This version also scans from the last partition to the first, as was
recommended by db-perf.

Test Plan:
I verified all the test changes do not indicate any failures of what the
original tests were intended to check.  All the changes still do scare be
a bit, but I can find no concrete reason to be worried.

Jenkins - all tests pass, including --big tests.

New mtr test added - passes.

Reviewers: santoshb, rudradevbasak, jtolmer

Reviewed By: rudradevbasak, jtolmer