Testing the MySQL JSON Labs Release Using MySQL Sandbox
The MySQL 5.7.7 release candidate has been available for several months, but it doesn’t include the new JSON datatype or built-in JSONfunctions. Those are currently only available in the MySQL JSON Labs Release. Unlike the regular 5.7.7 release, the MySQL JSON Labs Release is only available in two download formats:
In order to try out the new JSON data type and functions on my Mac laptop, I need to build it from source.
Read on to see how I did that with the help of MySQL Sandbox.
12345678910111213141516
# Download the tarball
cd ~
wget http://downloads.mysql.com/snapshots/pb/mysql-5.7.7-labs-json/mysql-5.7.7-labs-json.tar.gz
# Extract the tarball contents
tar xvf mysql-5.7.7-labs-json.tar.gz
# Build a new tarball for my OS
cd ~/mysql-5.7.7-labs-json/
mkdir bld
cd bld
cmake .. -DBUILD_CONFIG=mysql_release -DDOWNLOAD_BOOST=1 -DWITH_BOOST=~/my_boost/
make && ./scripts/make_binary_distribution
# Create a sandbox server
make_sandbox --add_prefix=json --export_binaries mysql-5.7.7-labs-json-osx10.8-x86_64.tar.gz
Next I connect to my sandbox, verify the version, and run a quick test using the new JSON datatype and JSON functions:
$HOME/sandboxes/msb_json5_7_7/use
mysql [localhost] {msandbox} ((none)) > select version();
+-----------------+
| version() |
+-----------------+
| 5.7.7-labs-json |
+-----------------+
1 row in set (0.00 sec)
mysql [localhost] {msandbox} ((none)) > use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql [localhost] {msandbox} (test) > create table json_table (json_string json);
Query OK, 0 rows affected (0.06 sec)
mysql [localhost] {msandbox} (test) > insert into json_table (json_string)
-> values ('{"a":["hello world","goodbye world"]}');
Query OK, 1 row affected (0.00 sec)
mysql [localhost] {msandbox} (test) > select jsn_extract(json_string,'$.a[0]')
-> from json_table;
+-----------------------------------+
| jsn_extract(json_string,'$.a[0]') |
+-----------------------------------+
| "hello world" |
+-----------------------------------+
1 row in set (0.00 sec)