Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #133 from naoa/support-zstd
Browse files Browse the repository at this point in the history
Support zstd flag

Patch by Naoya Murakami. Thanks!!!
  • Loading branch information
kou committed Mar 24, 2017
2 parents deb6c82 + 012dee8 commit 373bd07
Show file tree
Hide file tree
Showing 10 changed files with 222 additions and 0 deletions.
12 changes: 12 additions & 0 deletions doc/locale/ja/LC_MESSAGES/reference.po
Expand Up @@ -1219,6 +1219,18 @@ msgid ""
msgstr ""
"Groongaライブラリーがzlibをサポートしているかを確認するためのSQL例です::"

msgid "``mroonga_libgroonga_support_zstd``"
msgstr ""

msgid "The status of libgroonga supports Zstandard."
msgstr "GroongaライブラリーのZstandardサポート状況"

msgid ""
"Here is an example SQL to confirm the status of libgroonga supports "
"Zstandard::"
msgstr ""
"GroongaライブラリーがZstandardをサポートしているかを確認するためのSQL例です::"

msgid "``mroonga_libgroonga_version``"
msgstr ""

Expand Down
16 changes: 16 additions & 0 deletions doc/source/reference/server_variables.rst
Expand Up @@ -265,6 +265,22 @@ Here is an example SQL to confirm the status of libgroonga supports zlib::
| mroonga_libgroonga_support_zlib | ON |
+---------------------------------+-------+

.. _server-variable-mroonga-libgroonga-support-zstd:

``mroonga_libgroonga_support_zstd``
----------------------------------

The status of libgroonga supports Zstandard.

Here is an example SQL to confirm the status of libgroonga supports Zstandard::

mysql> SHOW GLOBAL VARIABLES LIKE 'mroonga_libgroonga_support_zstd';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| mroonga_libgroonga_support_zstd | ON |
+---------------------------------+-------+

.. _serer-variable-mroonga-libgroonga-version:


Expand Down
34 changes: 34 additions & 0 deletions ha_mroonga.cpp
Expand Up @@ -589,6 +589,7 @@ static char *mrn_version = const_cast<char *>(MRN_VERSION);
static char *mrn_vector_column_delimiter = NULL;
static my_bool mrn_libgroonga_support_zlib = FALSE;
static my_bool mrn_libgroonga_support_lz4 = FALSE;
static my_bool mrn_libgroonga_support_zstd = FALSE;
typedef enum {
MRN_BOOLEAN_MODE_SYNTAX_FLAG_DEFAULT = (1 << 0),
MRN_BOOLEAN_MODE_SYNTAX_FLAG_SYNTAX_QUERY = (1 << 1),
Expand Down Expand Up @@ -1040,6 +1041,20 @@ static my_bool grn_check_lz4_support()
return is_lz4_support;
}

static my_bool grn_check_zstd_support()
{
bool is_zstd_support = false;
grn_obj grn_support_p;

GRN_BOOL_INIT(&grn_support_p, 0);
grn_obj_get_info(&mrn_ctx, NULL, GRN_INFO_SUPPORT_ZSTD, &grn_support_p);
is_zstd_support = (GRN_BOOL_VALUE(&grn_support_p));
grn_obj_unlink(&mrn_ctx, &grn_support_p);

return is_zstd_support;
}


static MYSQL_SYSVAR_BOOL(libgroonga_support_zlib, mrn_libgroonga_support_zlib,
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
"The status of libgroonga supports zlib",
Expand All @@ -1054,6 +1069,13 @@ static MYSQL_SYSVAR_BOOL(libgroonga_support_lz4, mrn_libgroonga_support_lz4,
NULL,
grn_check_lz4_support());

static MYSQL_SYSVAR_BOOL(libgroonga_support_zstd, mrn_libgroonga_support_zstd,
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
"The status of libgroonga supports Zstandard",
NULL,
NULL,
grn_check_zstd_support());

#ifdef MRN_SUPPORT_THDVAR_SET
static MYSQL_THDVAR_SET(boolean_mode_syntax_flags,
PLUGIN_VAR_RQCMDARG,
Expand Down Expand Up @@ -1106,6 +1128,7 @@ static struct st_mysql_sys_var *mrn_system_variables[] =
MYSQL_SYSVAR(vector_column_delimiter),
MYSQL_SYSVAR(libgroonga_support_zlib),
MYSQL_SYSVAR(libgroonga_support_lz4),
MYSQL_SYSVAR(libgroonga_support_zstd),
#ifdef MRN_SUPPORT_THDVAR_SET
MYSQL_SYSVAR(boolean_mode_syntax_flags),
#endif
Expand Down Expand Up @@ -1466,6 +1489,17 @@ static bool mrn_parse_grn_column_create_flags(THD *thd,
"COMPRESS_LZ4");
}
flag_names += 12;
} else if (rest_length >= 13 && !memcmp(flag_names, "COMPRESS_ZSTD", 13)) {
if (mrn_libgroonga_support_zstd) {
*column_flags |= GRN_OBJ_COMPRESS_ZSTD;
found = true;
} else {
push_warning_printf(thd, MRN_SEVERITY_WARNING,
ER_MRN_UNSUPPORTED_COLUMN_FLAG_NUM,
ER_MRN_UNSUPPORTED_COLUMN_FLAG_STR,
"COMPRESS_ZSTD");
}
flag_names += 13;
} else {
char invalid_flag_name[MRN_MESSAGE_BUFFER_SIZE];
snprintf(invalid_flag_name, MRN_MESSAGE_BUFFER_SIZE,
Expand Down
@@ -0,0 +1,20 @@
# Copyright(C) 2017 Naoya Murakami <naoya@createfield.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

--disable_query_log
let $libgroonga_support_zstd =
`SELECT @@mroonga_libgroonga_support_zstd;`;
--enable_query_log
22 changes: 22 additions & 0 deletions mysql-test/mroonga/include/mroonga/support_libgroonga_zstd.inc
@@ -0,0 +1,22 @@
# Copyright(C) 2017 Naoya Murakami <naoya@createfield.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

--source ../../include/mroonga/check_libgroonga_support_zstd.inc

if (!$libgroonga_support_zstd) {
--source ../../include/mroonga/have_mroonga_deinit.inc
skip "This test is for libgroonga supports zstd";
}
22 changes: 22 additions & 0 deletions mysql-test/mroonga/include/mroonga/unsupport_libgroonga_zstd.inc
@@ -0,0 +1,22 @@
# Copyright(C) 2017 Naoya Murakami <naoya@createfield.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

--source ../../include/mroonga/check_libgroonga_support_zstd.inc

if ($libgroonga_support_zstd) {
--source ../../include/mroonga/have_mroonga_deinit.inc
skip "This test is for libgroonga doesn't support zstd";
}
@@ -0,0 +1,10 @@
DROP TABLE IF EXISTS entries;
CREATE TABLE entries (
id INT UNSIGNED PRIMARY KEY,
content TEXT COMMENT 'flags "COLUMN_SCALAR|COMPRESS_ZSTD"'
) DEFAULT CHARSET=utf8;
INSERT INTO entries (id, content) VALUES (1, "I found Mroonga that is a MySQL storage engine to use Groonga!");
SELECT * FROM entries;
id content
1 I found Mroonga that is a MySQL storage engine to use Groonga!
DROP TABLE entries;
@@ -0,0 +1,12 @@
DROP TABLE IF EXISTS entries;
CREATE TABLE entries (
id INT UNSIGNED PRIMARY KEY,
content TEXT COMMENT 'flags "COLUMN_SCALAR|COMPRESS_ZSTD"'
) DEFAULT CHARSET=utf8;
Warnings:
Warning 16506 The column flag 'COMPRESS_ZSTD' is unsupported. It is ignored
INSERT INTO entries (id, content) VALUES (1, "I found Mroonga that is a MySQL storage engine to use Groonga!");
SELECT * FROM entries;
id content
1 I found Mroonga that is a MySQL storage engine to use Groonga!
DROP TABLE entries;
@@ -0,0 +1,37 @@
# Copyright(C) 2017 Naoya Murakami <naoya@createfield.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

--source ../../../../../include/mroonga/have_mroonga.inc
--source ../../../../../include/mroonga/support_libgroonga_zstd.inc
--source ../../../../../include/mroonga/load_mroonga_functions.inc

--disable_warnings
DROP TABLE IF EXISTS entries;
--enable_warnings

CREATE TABLE entries (
id INT UNSIGNED PRIMARY KEY,
content TEXT COMMENT 'flags "COLUMN_SCALAR|COMPRESS_ZSTD"'
) DEFAULT CHARSET=utf8;

INSERT INTO entries (id, content) VALUES (1, "I found Mroonga that is a MySQL storage engine to use Groonga!");

SELECT * FROM entries;

DROP TABLE entries;

--source ../../../../../include/mroonga/unload_mroonga_functions.inc
--source ../../../../../include/mroonga/have_mroonga_deinit.inc
@@ -0,0 +1,37 @@
# Copyright(C) 2017 Naoya Murakami <naoya@createfield.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

--source ../../../../../include/mroonga/have_mroonga.inc
--source ../../../../../include/mroonga/unsupport_libgroonga_zstd.inc
--source ../../../../../include/mroonga/load_mroonga_functions.inc

--disable_warnings
DROP TABLE IF EXISTS entries;
--enable_warnings

CREATE TABLE entries (
id INT UNSIGNED PRIMARY KEY,
content TEXT COMMENT 'flags "COLUMN_SCALAR|COMPRESS_ZSTD"'
) DEFAULT CHARSET=utf8;

INSERT INTO entries (id, content) VALUES (1, "I found Mroonga that is a MySQL storage engine to use Groonga!");

SELECT * FROM entries;

DROP TABLE entries;

--source ../../../../../include/mroonga/unload_mroonga_functions.inc
--source ../../../../../include/mroonga/have_mroonga_deinit.inc

0 comments on commit 373bd07

Please sign in to comment.