Avoid test for innodb_defragment_fill_factor with 32KB pages

Summary:
Since the behavior of these two parameters vary with different page size,
this test is only enabled for 16k pages. For larger page size like 32k,
innodb_defragment_fill_factor_n_recs is more likely to be the one used.
The logic is not related to page size so it should be ok to only test
for 16k page and expect it to not cause problems for other page size.

Test Plan: Jenkins

Reviewers: steaphan

Reviewed By: steaphan
Fix innodb.innodb_alter_table_defragment test for 32KB pages

Summary:
The test is flaky on 32k page. Make it stable.

Also removed the "order by" part of the query validating number of
pages. The order by was used during debuging. When we only want to
confirm a count it's not needed.

Test Plan: mysqltest.sh --repeat=8 --parallel=8 innodb.innodb_alter_table_defragment innodb.innodb_alter_table_defragment innodb.innodb_alter_table_defragment innodb.innodb_alter_table_defragment innodb.innodb_alter_table_defragment innodb.innodb_alter_table_defragment innodb.innodb_alter_table_defragment innodb.innodb_alter_table_defragment --mysqld=--innodb-page-size=32k

Reviewers: steaphan

Reviewed By: steaphan
Make innodb.innodb_lru_retention_show_innodb_status more stable

Summary:
It seems that some times we get the difference number slightly less than 1 second (1000) when
sleep(1) in between two queries. Relax the condition to 0.99 second (990).

Test Plan: mysqltest.sh --parallel=8 --repeat=8 innodb.innodb_lru_retention_show_innodb_status innodb.innodb_lru_retention_show_innodb_status innodb.innodb_lru_retention_show_innodb_status innodb.innodb_lru_retention_show_innodb_status innodb.innodb_lru_retention_show_innodb_status innodb.innodb_lru_retention_show_innodb_status innodb.innodb_lru_retention_show_innodb_status innodb.innodb_lru_retention_show_innodb_status

Reviewers: steaphan

Reviewed By: steaphan
Disable ibuf and other stuff in xtrabackup

Summary:
I don't believe we need the insert buffer, purge thread, and other things
in the xtrabackup run.  Disabling them seems to solve the problem with
some of our copies failing with "lsn in the future" errors.

Though, this seems to cause other issues, so this is not the final fix.

Test Plan:
Jenkins
Also ran this to copy some prouction instances, and it worked,
including on an instance which often fails with this error.

Reviewers: ebergen, rongrong

Reviewed By: rongrong
Add JSON builtin functions to MySQL

Summary:
This patch adds four JSON builtin functions to MySQL. The implementation
uses the open-source library "rapidjson" as the underlying JSON string
parser (https://github.com/miloyip/rapidjson).

The syntaxes and examples of the new JSON functions are listed below,
which covers most used JSON queries. The functions take JSON as BLOB,
TEXT/VARCHAR, or CHAR types.

 - json_valid (json)
Returns true if the string is a valid json doc, or otherwise returns
false.

 - json_extract (json, key1[, key2, ...])
Given the key path (key1, ...), it returns the corresponding value in
the json.  Returns NULL if the key path doesn't exist.
 - Notes:
 -- You need to provide at least one key to the function.
 -- JSON keys are case sensitive.
 -- Array index is 1-based

 - json_contains_key (json, key1[, key2, ...])
Returns true if the key path exists, or otherwise false.

 - json_array_length (json)
Returns the size of the json array. NULL if the string is not a valid
json array type.

Added two new error codes: ER_INVALID_JSON and ER_INVALID_JSON_ARRAY.

Some additional notes on JSON objects:
 - A valid JSON object is either an object type (enclosed by "{}") or an
   array type (enclosed by "[]").
 - Both empty object and empty array are valid JSON objects.
 - An object type contains key-value pairs.
 -- A key must be strings
 -- A value can be object type, array type, or base types.
 -- Base types are: string, boolean, number, float, and null.
 - An array contains a list of JSON values. Array index is 1-based.

Test Plan:
Added lots of unit test cases in func_json.test. Tested functions on
literal strings and tables of different data types (blob, text, char).

Reviewers: jtolmer, pengt

Reviewed By: pengt
Using the safe version String::c_ptr_safe() in item_jsonfunc.cc

Summary:
This patch changes functions in item_jsonfunc.cc to use String::c_ptr_safe()
instead of c_ptr(), to avoid potential memory access violations (caught by
Valgrind tests).

Test Plan:
Ran and passed full unit tests (arc unit --everything):

http://ci-builds.fb.com/view/MySQL/job/mysql-precommit-big/295/

Reviewers: pengt

Reviewed By: pengt
Refactor btr_defragment into separate file.

Summary:
Defragmentation should be a separate feature, thus deserve its own files. Also it's using C++ stl
which looks weird in the btr0btr surroudings. Factor them out.

Test Plan: jenkins

Reviewers: steaphan

Reviewed By: steaphan
Stop Rotate_log_event from updating last_master_timestamp

Summary:
Rotate_log_events updated last_master_timestamp in the
Relay_log with a potentially old value causing a spike in the
Seconds_behind_master statistic.

0 is now passed as the new_ts argument to the
reset_notified_checkpoint so that last_master_timestamp is not
changed.

Test Plan:
Verified that Rotate events indeed have old timestamps in the relay log of a slave.

Excerpt from a relay log:

#140710  9:48:17 server id 127963191  end_log_pos 120   Start: binlog v 4, server v 5.6.12-fb-log created 140710  9:48:17 at startup
ROLLBACK/*!*/;
BINLOG '
0cO+Uw83kKAHdAAAAHgAAAAAAAQANS42LjEyLWZiLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAABAAAAEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAFcl
eqA=
'/*!*/;
# at 353
#140709 17:18:37 server id 0  end_log_pos 403   Rotate to binary-logs-3307.001262  pos: 467
# at 403
#140710  9:48:17 server id 127963191  end_log_pos 511   GTID [commit=yes]
SET @@SESSION.GTID_NEXT= 'a089b52b-f586-11e3-83e4-0002c94e81fc:556555101'/*!*/;

To see whether this issue is fixed, we need to watch the Seconds_behind_master
graph looking for unusual spikes.

Reviewers: santoshb

Reviewed By: santoshb