Fix jemalloc stats under perfschema builds

Summary:
Mark found this build error, and just disabled building this unittest.

This reverts that diff, and adds a more correct fix in its place.

This adds MYSQLD_LDFLAGS, if present, to this unittest's linking step.

Test Plan:
mysqlbuild.sh --perfschema --clean
mysqlbuild.sh --clean
cmake && make

Reviewers: santoshb

Reviewed By: santoshb
Fix a few build warnings.

Summary:
Some warnings are hidden by the build system, so we didn't see these.

Now we run all our builds in maintainer mode (-Werror).

Test Plan:
Built with the maintainer mode build setting, in all three modes
(Release, Debug, and Valgrind).
Jenkins followed up with a full test set, all is clean.

Reviewers: santoshb

Reviewed By: santoshb
Add -std=c++11 to gcc builds

Summary:
We build with this, but pass it in from our build scripts.

This should be set on all C++ builds, so it should be done here.

Test Plan:
Built with it, with this option removed from our build tools.

Reviewers: santoshb

Reviewed By: santoshb
More basic code fixes.

Summary:
This is a non-change.

It only fixed whitespace issues, comment errors, and some simple syntax
issues, introduced by our changes.

These changes will be folded into the diffs which contained these errors
in future branches, but, for this branch, they are all here.

Test Plan:
Jenkins
git diff -w shows only non-functional changes.

Reviewers: rudradevbasak

Reviewed By: rudradevbasak
Change to C99 mode and disable a warning incompatible with C99

Summary:
Subject says it all.  -Wdeclaration-after-statement isn't
compatible with C99 (since it's a warning about a feature now
allowed in C99), so it needs to be removed.

Test Plan:
A change that didn't like -Wdeclaration-after-statement now
builds.  Also confirmed with ps that -std=c99 is on the gcc
command lines.

Reviewers: steaphan

Reviewed By: steaphan
Fix trivial output typo.

Summary:
An extra comma slipped into an output line.  Remove it.

Test Plan: Jenkins

Reviewers: santoshb

Reviewed By: santoshb
Remove stats histograms

Summary:
Revert stat histogram diffs - these need to be redone.

Test Plan: arc unit

Reviewers: steaphan

Reviewed By: steaphan
Fix innodb_doublewrite test.

Summary:
innodb_doublewrite tests the functionality of the doublewrite
buffer in full-durability and reduced-durability mode. In order
to do this, it invokes the innodb_corrupt_doublewrite_pages.py
script which corrupts pages that were on the doublewrite buffer
on disk. The problem is that innodb accesses the files using
O_DIRECT but the python script accesses them through FS cache.
This meant that sometimes the corruption (or un-corruption)
performed by the python script was not seen by innodb. In order
to fix this problem we enforce flushing of the file by calling
flush() and fsync().

Test Plan:
Run the test repeatedly using the following command:

  ../srpm/mysqltest.sh --release --repeat=16 --parallel=4 innodb.innodb_doublewrite innodb.innodb_doublewrite_odirect innodb.innodb_doublewrite innodb.innodb_doublewrite_odirect

Reviewers: steaphan, rongrong

Reviewed By: rongrong
Fix warnings detected by gcc-4.8.1

Summary:
These errors are all from upstream 5.6.12, not our changes.

Test Plan: Built (with -Wall -Werror), works now.

Reviewers: rudradevbasak

Reviewed By: rudradevbasak
Fix errors detected by ASan at compile time.

Summary: Compiles cleanly with ASan now.

Test Plan: Built it with ASan, no warnings/errors.

Reviewers: rudradevbasak

Reviewed By: rudradevbasak
Fix errors detected by ASan at runtime

Summary:
Half of these are from upstream.  Good news is most of them corresponded
to changes between 5.6.12 and 5.6.14, so it seems Oracle already ran
some of this.  I've back-ported those same fixes to resolve those.
In the case of sql/sql_error.*, I just copied the entire files, as
they had no irrelevant changes.

I fixed one other upstream one as well, with the minimum (good) change
I could see.

Four errors are ours (two from Table Stats, one from Semi-Sync, and one
from the Reduced Double-Write mode).  I fixed these too.

Test Plan:
Ran a special ASan-Enabled 'arc unit', all passed in Release and Debug,
except the expected failures.  Also running 'arc unit --everything' now.

Expected failures under ASan:

1) Valgrind and ASan don't get along, at least not yet, so it is
   expected that all the Valgrind+ASan test runs will fail.

2) The XtraBackup build setup does't support ASan yet.  So, all of
   those builds will fail, well before the tests even run.

3) JEMalloc doesn't work with ASan yet, so that test will (quite
   correctly) fail to confirm the presense of jemalloc.

Reviewers: rudradevbasak

Reviewed By: rudradevbasak
Fix asan failure in log padding

Summary:
There is a possibility that data + padding exceeds the boundry of
log_sys->buf.

Make the buffer larger so padding always land in valid memory.

Test Plan: asan tests.

Reviewers: steaphan

Reviewed By: steaphan
Add -DWITH_ASAN cmake option, to enable ASan checking

Summary: Passing -DWITH_ASAN will add the "-fsanitize=address" compiler option.

Test Plan:
Built with -DWITH_ASAN, with intentional ASan failures, works.
Built without -DWITH_ASAN, confirmed it is not enabled.

Reviewers: rudradevbasak, santoshb

Reviewed By: rudradevbasak
Add -Wall -Werror to xtrabackup's mysql build too

Summary:
We also want to build this in maintainer mode.

This build system will hopefully, one day, be unified.

But, for now, it is not.

Test Plan: Build xtrabackup, ran the xtrabackup tests, works.

Reviewers: rudradevbasak

Reviewed By: rudradevbasak
Stop valgrind from complaining about uninitilialized variables.

Summary:
innodb.innodb_alter_table_defragment fails in valgrind runs. The report sort of suggesting a
corrupted page but it's not clear. For example, one of the conditional jump based on uninitalized
variables report points to page_type, which is a ulint initialized from the page. Adding debug output
will make the error disappear so it's hard to do any further analysis. Changing the word "SECOND" in
defragment statement "alter table t1 defragment index SECOND" to "second" seem to avoid the error.
It's not clear as of why this happens. Actually, in the original form, the first valgrind error happens
before the statement is executed. So this diff is only to make valgrind stop complaining, not really
solving the problem.

Test Plan: mysqltest.sh --valgrind innodb.innodb_alter_table_defragment

Reviewers: steaphan

Reviewed By: steaphan
Free transaction pool at shutdown

Summary:
Fix memory leak reported by Valgrind by freeing the transaction pool
at shutdown.

Test Plan: Jenkins Valgrind run, once leak checking works.

Reviewers: steaphan

Reviewed By: steaphan
Fix leaked memory, os_support

Summary:
We introduce a new allocation, os_support, but we do not free it.
Valgrind complains. Fix that.

Test Plan: Jenkins

Reviewers: steaphan

Reviewed By: steaphan
Fix leak of os_aio_thread_buffer under Valgrind

Summary:
Valgrind complains that we're not freeing the os_aio_thread_buffers.
Fix valgrind builds so that we do.

Test Plan: Jenkins

Reviewers: rongrong, santoshb

Reviewed By: santoshb
Update valgrind suppression for current tools / libraries

Summary:
Existing valgrind suppression isn't getting triggered because
the call stack is slightly different now.

Test Plan: Jenkins

Reviewers: santoshb

Reviewed By: santoshb
fix leak in read_gtids_from_binlog

Summary:
The last event allocatted is not freed if the condition
ev->log_pos <= max_pos is false and the while loop exits.
Fixed it

Test Plan:
mysqltest.sh --valgrind xtrabackup.xb_gtid.
Failed before this patch but passed after this patch

Reviewers: jtolmer, rudradevbasak, steaphan

Reviewed By: steaphan