Fix bzero redefine

Summary:
Since bzero is a macro in newer glibc's, we need to undefine it if it is
already defined.

Test Plan:
mtr

Reviewers: steaphan

Reviewed By: steaphan
Stop spawning dummy threads on client library initialization (5.6)

Summary:
Let's revert the fix for Bug#24507.  To quote Monty from 2006:

"After 1/2 a year, when all glibc versions are updated, we can delete
this code."

Test Plan: jenkins

Reviewers: steaphan

Reviewed By: steaphan
Parse, but ignore, MEMECACHE_DIRTY keyword.

Summary:
Port only the parsing of the MEMECACHE_DIRTY keyword.

Test Plan: MTR tests included.

Reviewers: chip

Reviewed By: chip
Use both upstream and our crc algo, migrating to upstream.

Summary:
Facebook's 5.1 mysql wrote checksums not compatible with mysql 5.6.
This change allows us to read either fb or upstream checksums, but
always writes the new upstream (standard mysql-5.6) checksums.

This calculates both the real crc32c algo, and our addition-based one,
and compares to each on read, accepting either as valid.

On write, it only writes the real crc32c (as used upstream).

This dual implementation should not be much more computationally complex
than only calculating one or the other.

Also updated extra/innochecksum program.

This change handles compressed and uncompressed checksums, which (of
course) differ slightly in their codepath.

Test Plan: mtr as well as running as a slave

Reviewers: chip

Reviewed By: chip
Fix our acl damage in mysql_upgrade

Summary:
For Admission Control, we added two columns to the acl table.
The code to read this in mysql 5.1 and 5.6 is completely terrible.
So, acl table data created by our 5.1 causes 5.6 to explode.

Skip reading the last two acl columns, if there aren't at least 3 there.
This allows us to dodge those we used for admission control in 5.1, since,
if the extra columns from 5.6 are present, there will be at least 3 more.

This works around reading these tables, long enough to run mysql_upgrade.

Also mysql_upgrade now drops these two obsolete Admission Control columns,
if present, before addding the three new 5.6 acl columns.

For this to work, mysql_upgrade also had to ignore:
	ERROR 1091: Can't DROP '<column_name>'; ...
So, this was also added to its expected errors list.

This, in turn, required updating of some perfschema test results,
since they include line numbers of errors.

Note that if mysql_upgrade is not run, things (like new GRANTS) will cause
bad failures in 5.6 if our old 5.1 format tables are used.

Test Plan:
Deployed 5.1 and 5.6 RPMs on a spare, and upgraded cleanly!
Jenkins 'arc unit' likes this too.

Reviewers: jtolmer

Reviewed By: jtolmer
Allow reading of headerless compressed pages.

Summary:
Our 5.1 writes headerless zlib data blobs.

This can read those now, in addition to those with headers.

But, this still writes only with zlib headers, not without.

Test Plan: Tested upgrade with a replica of prod data, worked.

Reviewers: nizamordulu

Reviewed By: nizamordulu
Port v5.1 SQL_NO_FCACHE to 5.6

Summary:
When running full table scans, provide a mechanism to disable
caching in flash so that the working set is not evicted.  This is
particularly useful when doing database dumps and not blowing out the
entire working set for data that most likely will not be read again.
This should also reduce the overall writes performed to the flash,
improving endurance.

Adds Innodb_dblwr_page_number to SHOW GLOBAL STATUS.  This is the page
number at which the doublewrite buffer starts in the system tablespace.
We need this for flashcache.

We turn off caching by default in flashcache and only enable it when a
process asks for it.  As long as the process group has flashcache
enabled, then all members will have it enabled.

Test Plan:
Setup a slave and did the following:
1. SELECT * FROM TABLE INTO OUTFILE 'foo' saw writes to flash.
2. SELECT SQL_NO_FCACHE * FROM TABLE2 INTO OUTFILE 'foo2' and saw no
   writes to flash.
3. SELECT /*!40001 SQL_NO_FCACHE */ * FROM TABLE3 INTO OUTFILE 'foo2'
   and saw no writes to flash.
4. SELECT /*!40001 SQL_NO_CACHE */ /*!40002 SQL_NO_FCACHE */ * FROM
   TABLE4 INTO OUTFILE 'foo2' and saw no writes to flash.
5. Ran mysqldump on a host which supports SQL_NO_FCACHE and it auto
   detected properly
6. Ran mysqldump on a host which does not support SQL_NO_FCACHE and it
   does not add the comment hint to the SQL statement.

Reviewers: chip, mcallaghan

Reviewed By: chip
Fix unsigned arithmetic

Summary:
Fix a bug with unsigned arithmetic and a compile warning

There was an SQL_MODE option for subtracting underflows, but not for
adding negative overflow.  This fixes it by moving the check to the
parent arithmetic class.

Also, allow global NO_UNSIGNED_SUBTRACTION to override sql_mode in
replication thread.

sql_mode is part of replication events, and therefore almost all
sql_mode settings are ignored by the replication thread.  This breaks
replicating from 5.1->5.6 because of behavior of unsigned underflow.
This diff allows NO_UNSIGNED_SUBTRACTION to pierce into the replication
thread if it is set globally.

Test Plan:
mtr,
replicate from 5.1 master, run on 5.6 replica
test against failing replica,
verify properly replicates in statement mode

Reviewers: mcallaghan, steaphan

Reviewed By: mcallaghan
Port Control Cross-Table Access to 5.6

Summary:
Ported our v5.1 sysvar allow_noncurrent_db_rw, which detects when a query
accesses data not in the current database.  Depending on its setting, when
a query tries to read or write to another database, it will:

	ON:
	Allow it.

	LOG:
	Allow it, but log that it occurred.

	LOG_WARN:
	Allow it, log it occurred, and send an error to client.

	OFF:
	Block it, and send an error to the client.

Test Plan:
mtr test: main.allow_noncurrent_db_rw

Reviewers: heyongqiang, mcallaghan, hfisk, steaphan, nponnekanti

Reviewed By: nponnekanti
Port v5.1 super_read_only

Summary:
Implements super_read_only global, which activates read_only,
and also blocks writes by SUPER.

Linked to the read_only global as follows:
* Turning read_only off also turns off super_read_only.
* Turning super_read_only on also turns read_only on.
* All other changes to either one of these have no affect on the other.

Test Plan: New test included, passes.

Reviewers: rongrong

Reviewed By: rongrong