Commit d79fd5ba authored by Sergei Golubchik's avatar Sergei Golubchik

Merge branch 'ks-10.1-mroonga' into 10.1

parents 53c7aaf3 ac12ab8f

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -15,7 +15,7 @@
#
# 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 02111-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
cmake_minimum_required(VERSION 2.6)
project(mroonga)
......@@ -51,6 +51,14 @@ if(MSVC)
endif()
endif()
if(MRN_BUNDLED)
if(WITHOUT_MROONGA OR
WITHOUT_MROONGA_STORAGE_ENGINE OR
"${PLUGIN_MROONGA}" STREQUAL "NO")
return()
endif()
endif()
set(MRN_BUNDLED_GROONGA_RELATIVE_DIR "vendor/groonga")
set(MRN_BUNDLED_GROONGA_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/${MRN_BUNDLED_GROONGA_RELATIVE_DIR}")
......@@ -79,6 +87,58 @@ file(READ ${MRN_SOURCE_DIR}/version_micro MRN_VERSION_MICRO)
file(READ ${MRN_SOURCE_DIR}/version_in_hex MRN_VERSION_IN_HEX)
file(READ ${MRN_SOURCE_DIR}/plugin_version MRN_PLUGIN_VERSION)
if(MRN_GROONGA_BUNDLED)
option(MRN_GROONGA_EMBED
"Embed libgroonga"
ON)
if(MRN_GROONGA_EMBED)
set(GRN_EMBED ON)
endif()
set(MRN_BUNDLED_GROONGA_NORMALIZER_MYSQL_DIR
"${MRN_BUNDLED_GROONGA_DIR}/vendor/plugins/groonga-normalizer-mysql")
option(MRN_GROONGA_NORMALIZER_MYSQL_EMBED
"Embed groonga-normalizer-mysql Groonga plugin"
ON)
if(EXISTS ${MRN_BUNDLED_GROONGA_NORMALIZER_MYSQL_DIR})
set(GROONGA_NORMALIZER_MYSQL_FOUND ON)
else()
set(GROONGA_NORMALIZER_MYSQL_FOUND OFF)
set(MRN_GROONGA_NORMALIZER_MYSQL_EMBED OFF)
endif()
if(MRN_GROONGA_NORMALIZER_MYSQL_EMBED)
set(GROONGA_NORMALIZER_MYSQL_EMBED ON)
endif()
file(READ "${MRN_BUNDLED_GROONGA_DIR}/bundled_lz4_version"
MRN_BUNDLED_LZ4_VERSION)
string(STRIP
"${MRN_BUNDLED_LZ4_VERSION}"
MRN_BUNDLED_LZ4_VERSION)
set(MRN_BUNDLED_LZ4_DIR
"${MRN_BUNDLED_GROONGA_DIR}/vendor/lz4-${MRN_BUNDLED_LZ4_VERSION}")
if(EXISTS ${MRN_BUNDLED_LZ4_DIR})
set(GRN_WITH_BUNDLED_LZ4 ON)
set(GRN_WITH_LZ4 "yes")
else()
set(GRN_WITH_LZ4 "no")
endif()
add_subdirectory("${MRN_BUNDLED_GROONGA_RELATIVE_DIR}")
else()
set(MRN_GROONGA_EMBED OFF)
file(READ ${MRN_SOURCE_DIR}/required_groonga_version REQUIRED_GROONGA_VERSION)
string(STRIP "${REQUIRED_GROONGA_VERSION}" REQUIRED_GROONGA_VERSION)
file(READ
${MRN_SOURCE_DIR}/required_groonga_normalizer_mysql_version
REQUIRED_GROONGA_NORMALIZER_MYSQL_VERSION)
string(STRIP
"${REQUIRED_GROONGA_NORMALIZER_MYSQL_VERSION}"
REQUIRED_GROONGA_NORMALIZER_MYSQL_VERSION)
endif()
set(MRN_PACKAGE_STRING "${PROJECT_NAME} ${MRN_VERSION}")
include(CheckCCompilerFlag)
......@@ -107,18 +167,7 @@ read_file_list(${CMAKE_CURRENT_SOURCE_DIR}/udf/sources.am MRN_UDF_SOURCES)
string(REGEX REPLACE "([^;]+)" "${MRN_RELATIVE_DIR_PREFIX}udf/\\1"
MRN_UDF_SOURCES "${MRN_UDF_SOURCES}")
set(MRN_ALL_SOURCES
${MRN_SOURCES}
${MRN_UDF_SOURCES}
${LIBMRN_NO_MYSQL_SOURCES}
${LIBMRN_NEED_MYSQL_SOURCES})
if(MRN_BUNDLED)
mysql_add_plugin(mroonga ${MRN_ALL_SOURCES} STORAGE_ENGINE MODULE_ONLY)
if(NOT TARGET mroonga)
return()
endif()
set(MYSQL_SOURCE_DIR ${CMAKE_SOURCE_DIR})
set(MYSQL_BUILD_DIR ${MYSQL_SOURCE_DIR})
set(MYSQL_CONFIG ${CMAKE_SOURCE_DIR}/scripts/mysql_config)
......@@ -134,44 +183,6 @@ else()
endif()
find_path(MYSQL_CONFIG "${MYSQL_CONFIG}")
if(MRN_GROONGA_BUNDLED)
option(MRN_GROONGA_EMBED
"Embed libgroonga"
ON)
if(MRN_GROONGA_EMBED)
set(GRN_EMBED ON)
endif()
set(MRN_BUNDLED_GROONGA_NORMALIZER_MYSQL_DIR
"${MRN_BUNDLED_GROONGA_DIR}/vendor/plugins/groonga-normalizer-mysql")
option(MRN_GROONGA_NORMALIZER_MYSQL_EMBED
"Embed groonga-normalizer-mysql Groonga plugin"
ON)
if(EXISTS ${MRN_BUNDLED_GROONGA_NORMALIZER_MYSQL_DIR})
set(GROONGA_NORMALIZER_MYSQL_FOUND ON)
else()
set(GROONGA_NORMALIZER_MYSQL_FOUND OFF)
set(MRN_GROONGA_NORMALIZER_MYSQL_EMBED OFF)
endif()
if(MRN_GROONGA_NORMALIZER_MYSQL_EMBED)
set(GROONGA_NORMALIZER_MYSQL_EMBED ON)
endif()
add_subdirectory("${MRN_BUNDLED_GROONGA_RELATIVE_DIR}")
else()
set(MRN_GROONGA_EMBED OFF)
file(READ ${MRN_SOURCE_DIR}/required_groonga_version REQUIRED_GROONGA_VERSION)
string(STRIP "${REQUIRED_GROONGA_VERSION}" REQUIRED_GROONGA_VERSION)
file(READ
${MRN_SOURCE_DIR}/required_groonga_normalizer_mysql_version
REQUIRED_GROONGA_NORMALIZER_MYSQL_VERSION)
string(STRIP
"${REQUIRED_GROONGA_NORMALIZER_MYSQL_VERSION}"
REQUIRED_GROONGA_NORMALIZER_MYSQL_VERSION)
endif()
if(EXISTS "${MYSQL_SOURCE_DIR}/storage/maria")
set(MYSQL_VARIANT "MariaDB")
else()
......@@ -194,6 +205,7 @@ if(EXISTS "${MYSQL_SOURCE_DIR}/libbinlogevents")
set(MYSQL_LIBBINLOGEVENTS_EXPORT_DIR
"${MYSQL_SOURCE_DIR}/libbinlogevents/export")
set(MYSQL_LIBBINLOGEVENTS_INCLUDE_DIR
"${MYSQL_BUILD_DIR}/libbinlogevents/include"
"${MYSQL_SOURCE_DIR}/libbinlogevents/include")
else()
set(MYSQL_LIBBINLOGEVENTS_EXPORT_DIR)
......@@ -270,6 +282,7 @@ else()
set(MRN_LIBRARY_DIRS
${MRN_LIBRARY_DIRS}
${GROONGA_LIBRARY_DIRS})
set(MRN_LIBRARIES ${GROONGA_LIBRARIES})
endif()
include_directories(
......@@ -291,11 +304,17 @@ link_directories(
${MRN_LIBRARY_DIRS}
${MYSQL_LIBRARY_DIRS})
set(MRN_ALL_SOURCES
${MRN_SOURCES}
${MRN_UDF_SOURCES}
${LIBMRN_NO_MYSQL_SOURCES}
${LIBMRN_NEED_MYSQL_SOURCES})
if(MRN_BUNDLED)
target_link_libraries(mroonga ${MRN_LIBRARIES})
if(NOT TARGET mroonga)
return()
endif()
mysql_add_plugin(mroonga
${MRN_ALL_SOURCES}
STORAGE_ENGINE MODULE_ONLY
LINK_LIBRARIES ${MRN_LIBRARIES})
else()
add_library(mroonga MODULE ${MRN_ALL_SOURCES})
......@@ -340,8 +359,12 @@ else()
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-strict-aliasing")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-deprecated")
MY_CHECK_AND_SET_COMPILER_FLAG("-fno-implicit-templates")
MY_CHECK_AND_SET_COMPILER_FLAG("-fno-exceptions")
MY_CHECK_AND_SET_COMPILER_FLAG("-fno-rtti")
if(("${MYSQL_VARIANT}" STREQUAL "MariaDB") OR
("${MYSQL_VARIANT}" STREQUAL "MySQL" AND
${MYSQL_VERSION} VERSION_LESS "5.7.0"))
MY_CHECK_AND_SET_COMPILER_FLAG("-fno-exceptions")
MY_CHECK_AND_SET_COMPILER_FLAG("-fno-rtti")
endif()
MY_CHECK_AND_SET_COMPILER_FLAG("-felide-constructors")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-implicit-fallthrough")
endif()
......@@ -362,10 +385,20 @@ else()
install(TARGETS mroonga DESTINATION "${MYSQL_PLUGIN_DIR}")
endif()
option(MRN_BUILD_FOR_EMBEDDED_SERVER
"Whether to build Mroonga for embedded server or not. You can't use Mroonga built for embedded server with non embedded server."
OFF)
if(MRN_BUILD_FOR_EMBEDDED_SERVER)
set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "EMBEDDED_LIBRARY")
endif()
if(GROONGA_NORMALIZER_MYSQL_FOUND)
add_definitions("-DWITH_GROONGA_NORMALIZER_MYSQL=1")
set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "WITH_GROONGA_NORMALIZER_MYSQL=1")
if(MRN_GROONGA_NORMALIZER_MYSQL_EMBED)
add_definitions("-DMRN_GROONGA_NORMALIZER_MYSQL_EMBEDDED")
set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "MRN_GROONGA_NORMALIZER_MYSQL_EMBEDDED")
else()
set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "GROONGA_NORMALIZER_MYSQL_PLUGIN_NAME=\"normalizers/mysql\"")
......@@ -373,7 +406,8 @@ if(GROONGA_NORMALIZER_MYSQL_FOUND)
endif()
if(MRN_GROONGA_EMBED)
add_definitions("-DMRN_GROONGA_EMBEDDED")
set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "MRN_GROONGA_EMBEDDED")
endif()
set(MRN_DEFAULT_PARSER "" CACHE STRING
......@@ -419,6 +453,8 @@ else()
set(MRN_DATA_DIR "share/${PROJECT_NAME}")
endif()
install(FILES
"${PROJECT_SOURCE_DIR}/AUTHORS"
"${PROJECT_SOURCE_DIR}/COPYING"
"${PROJECT_BINARY_DIR}/data/install.sql"
"${PROJECT_SOURCE_DIR}/data/uninstall.sql"
DESTINATION "${MRN_DATA_DIR}/")
This diff is collapsed.
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_ARGS}
AUTOMAKE_OPTIONS = 1.9.7
LOCALES = ja
AM_CPPFLAGS = $(MYSQL_INCLUDES) $(GROONGA_CFLAGS) -I$(top_srcdir)/lib
ACLOCAL_AMFLAGS = $$ACLOCAL_ARGS
include sources.am
......@@ -49,7 +49,13 @@ tag:
cd $(top_srcdir) && \
git tag v$(VERSION) -a -m 'Mroonga $(VERSION)!!!'
update-latest-release: misc
ensure-cutter-source-path:
@if test -z "$(CUTTER_SOURCE_PATH)"; then \
echo "\$$(CUTTER_SOURCE_PATH) is missing"; \
exit 1; \
fi
update-latest-release: ensure-cutter-source-path
@if test -z "$(OLD_RELEASE)"; then \
echo "\$$(OLD_RELEASE) is missing"; \
exit 1; \
......@@ -63,17 +69,40 @@ update-latest-release: misc
exit 1; \
fi
cd $(top_srcdir) && \
misc/update-latest-release.rb \
"$(CUTTER_SOURCE_PATH)/misc/update-latest-release.rb" \
$(PACKAGE) $(OLD_RELEASE) $(OLD_RELEASE_DATE) \
$(VERSION) $(NEW_RELEASE_DATE) \
packages/rpm/centos/mariadb-mroonga.spec.in \
packages/rpm/centos/mariadb-10.1-mroonga.spec.in \
packages/rpm/centos/mariadb-10.2-mroonga.spec.in \
packages/rpm/centos/mysql55-mroonga.spec.in \
packages/rpm/centos/mysql56-community-mroonga.spec.in \
packages/debian/changelog \
packages/rpm/centos/mysql57-community-mroonga.spec.in \
packages/rpm/centos/percona-server-56-mroonga.spec.in \
packages/rpm/centos/percona-server-57-mroonga.spec.in \
doc/source/install/*.rst \
doc/locale/*/LC_MESSAGES/install.po \
$(MROONGA_GITHUB_COM_PATH)/index.html \
$(MROONGA_GITHUB_COM_PATH)/ja/index.html
$(MROONGA_GITHUB_COM_PATH)/_config.yml
cd $(top_srcdir) && \
"$(CUTTER_SOURCE_PATH)/misc/update-latest-release.rb" \
$(PACKAGE)-5.5 $(OLD_RELEASE) $(OLD_RELEASE_DATE) \
$(VERSION) $(NEW_RELEASE_DATE) \
packages/debian-5.5/changelog
cd $(top_srcdir) && \
"$(CUTTER_SOURCE_PATH)/misc/update-latest-release.rb" \
$(PACKAGE)-5.6 $(OLD_RELEASE) $(OLD_RELEASE_DATE) \
$(VERSION) $(NEW_RELEASE_DATE) \
packages/debian-5.6/changelog
cd $(top_srcdir) && \
"$(CUTTER_SOURCE_PATH)/misc/update-latest-release.rb" \
$(PACKAGE)-5.7 $(OLD_RELEASE) $(OLD_RELEASE_DATE) \
$(VERSION) $(NEW_RELEASE_DATE) \
packages/debian-5.7/changelog
cd $(top_srcdir) && \
"$(CUTTER_SOURCE_PATH)/misc/update-latest-release.rb" \
$(PACKAGE)-mariadb-10.0 $(OLD_RELEASE) $(OLD_RELEASE_DATE) \
$(VERSION) $(NEW_RELEASE_DATE) \
packages/debian-mariadb-10.0/changelog
update-po:
@for lang in $(LOCALES); do \
......@@ -144,10 +173,3 @@ upload-to-github:
echo-cutter:
echo $(CUTTER)
misc:
@if test -z "$(CUTTER_SOURCE_PATH)"; then \
echo "\$$(CUTTER_SOURCE_PATH) is missing"; \
exit 1; \
fi
ln -s "$(CUTTER_SOURCE_PATH)/misc" misc
version: "{build}"
clone_depth: 10
environment:
global:
MARIADB_VERSION: 10.1.26
matrix:
- CMAKE_GENERATOR_NAME: "Visual Studio 14 2015"
- CMAKE_GENERATOR_NAME: "Visual Studio 14 2015 Win64"
install:
- cd ..
- choco install -y curl 7zip.commandline
- curl -O http://mirror.jmu.edu/pub/mariadb/mariadb-10.0.20/source/mariadb-10.0.20.tar.gz
- 7z x mariadb-10.0.20.tar.gz
- 7z x mariadb-10.0.20.tar > nul
- cd mariadb-10.0.20
- curl -O http://mirror.jmu.edu/pub/mariadb/mariadb-%MARIADB_VERSION%/source/mariadb-%MARIADB_VERSION%.tar.gz
- 7z x mariadb-%MARIADB_VERSION%.tar.gz
- 7z x mariadb-%MARIADB_VERSION%.tar > nul
- cd mariadb-%MARIADB_VERSION%
- rmdir /S /Q storage\mroonga\
- move ..\mroonga storage\mroonga
- git clone --quiet --depth 1 https://github.com/groonga/groonga.git ..\groonga
- cd ..\groonga
- git submodule update --init
- cd ..\mariadb-10.0.20
- git clone --quiet --depth 1 --recursive https://github.com/groonga/groonga.git ..\groonga
- rmdir /S /Q ..\groonga\test\
- cd ..\groonga\vendor
- c:\Ruby22-x64\bin\ruby -v download_lz4.rb
- c:\Ruby22-x64\bin\ruby -v download_mecab.rb
- cd ..\..\mariadb-%MARIADB_VERSION%
- mkdir storage\mroonga\vendor
- move ..\groonga storage\mroonga\vendor\groonga
- git clone --quiet --depth 1 https://github.com/groonga/groonga-normalizer-mysql.git storage\mroonga\vendor\groonga\vendor\plugins\groonga-normalizer-mysql
build_script:
- "echo # > win\\packaging\\CMakeLists.txt"
- cmake . -G "Visual Studio 12 Win64"
- cmake . -G "%CMAKE_GENERATOR_NAME%"
-DCMAKE_BUILD_TYPE=Debug
-DWITHOUT_ARCHIVE=ON
-DWITHOUT_BLACKHOLE=ON
-DWITHOUT_CASSANDRA=ON
-DWITHOUT_CONNECT=ON
-DWITHOUT_CSV=ON
-DWITHOUT_EXAMPLE=ON
-DWITHOUT_FEDERATED=ON
-DWITHOUT_FEDERATEDX=ON
-DWITHOUT_HEAP=ON
-DWITHOUT_INNOBASE=ON
-DWITHOUT_MYISAM=ON
-DWITHOUT_MYISAMMRG=ON
-DWITHOUT_OQGRAPH=ON
-DWITHOUT_PERFSCHEMA=OFF
-DWITHOUT_SEQUENCE=ON
-DWITHOUT_SPHINX=ON
-DWITHOUT_SPIDER=ON
-DWITHOUT_TEST_SQL_DISCOVERY=ON
-DWITHOUT_TOKUDB=ON
-DWITHOUT_XTRADB=ON
-DPLUGIN_ARCHIVE=NO
-DPLUGIN_BLACKHOLE=NO
-DPLUGIN_CASSANDRA=NO
-DPLUGIN_CONNECT=NO
-DPLUGIN_CSV=NO
-DPLUGIN_EXAMPLE=NO
-DPLUGIN_FEDERATED=NO
-DPLUGIN_FEDERATEDX=NO
-DPLUGIN_HEAP=NO
-DPLUGIN_INNOBASE=NO
-DPLUGIN_MYISAM=NO
-DPLUGIN_MYISAMMRG=NO
-DPLUGIN_OQGRAPH=NO
-DPLUGIN_PERFSCHEMA=NO
-DPLUGIN_SEQUENCE=NO
-DPLUGIN_SPHINX=NO
-DPLUGIN_SPIDER=NO
-DPLUGIN_TEST_SQL_DISCOVERY=NO
-DPLUGIN_TOKUDB=NO
-DPLUGIN_XTRADB=NO
-DWITH_UNIT_TESTS=OFF
-DWITH_MARIABACKUP=OFF
-DGRN_WITH_BUNDLED_MECAB=ON
- cmake --build . --config Debug
notifications:
- provider: Email
to:
- groonga-mysql-commit@lists.sourceforge.jp
- kou@clear-code.com
on_build_status_changed: true
test: off
#!/bin/sh
warn() {
echo " WARNING: $@" 1>&2
}
# init
LIBTOOLIZE=libtoolize
ACLOCAL=aclocal
AUTOCONF=autoconf
AUTOHEADER=autoheader
AUTOMAKE=automake
case `uname -s` in
Darwin)
LIBTOOLIZE=glibtoolize
;;
case $(uname -s) in
FreeBSD)
ACLOCAL_ARGS="$ACLOCAL_ARGS -I /usr/local/share/aclocal/"
;;
ACLOCAL_ARGS="$ACLOCAL_ARGS -I /usr/local/share/aclocal/"
;;
esac
mkdir -p m4
# libtoolize
echo "Searching libtoolize..."
if [ `which $LIBTOOLIZE` ] ; then
echo " FOUND: libtoolize -> $LIBTOOLIZE"
else
warn "Cannot Found libtoolize... input libtool command"
read LIBTOOLIZE
LIBTOOLIZE=`which $LIBTOOLIZE`
if [ `which $LIBTOOLIZE` ] ; then
echo " SET: libtoolize -> $LIBTOOLIZE"
else
warn "$LIBTOOLIZE: Command not found."
exit 1;
fi
fi
# aclocal
echo "Searching aclocal..."
if [ `which $ACLOCAL` ] ; then
echo " FOUND: aclocal -> $ACLOCAL"
else
warn "Cannot Found aclocal... input aclocal command"
read ACLOCAL
ACLOCAL=`which $ACLOCAL`
if [ `which $ACLOCAL` ] ; then
echo " SET: aclocal -> $ACLOCAL"
else
warn "$ACLOCAL: Command not found."
exit 1;
fi
fi
# automake
echo "Searching automake..."
if [ `which $AUTOMAKE` ] ; then
echo " FOUND: automake -> $AUTOMAKE"
else
warn "Cannot Found automake... input automake command"
read AUTOMAKE
ACLOCAL=`which $AUTOMAKE`
if [ `which $AUTOMAKE` ] ; then
echo " SET: automake -> $AUTOMAKE"
else
warn "$AUTOMAKE: Command not found."
exit 1;
fi
fi
# autoheader
echo "Searching autoheader..."
if [ `which $AUTOHEADER` ] ; then
echo " FOUND: autoheader -> $AUTOHEADER"
else
warn "Cannot Found autoheader... input autoheader command"
read AUTOHEADER
ACLOCAL=`which $AUTOHEADER`
if [ `which $AUTOHEADER` ] ; then
echo " SET: autoheader -> $AUTOHEADER"
else
warn "$AUTOHEADER: Command not found."
exit 1;
fi
fi
# autoconf
echo "Searching autoconf..."
if [ `which $AUTOCONF` ] ; then
echo " FOUND: autoconf -> $AUTOCONF"
else
warn "Cannot Found autoconf... input autoconf command"
read AUTOCONF
ACLOCAL=`which $AUTOCONF`
if [ `which $AUTOCONF` ] ; then
echo " SET: autoconf -> $AUTOCONF"
else
warn "$AUTOCONF: Command not found."
exit 1;
fi
fi
set -e
echo "Running libtoolize ..."
$LIBTOOLIZE --force --copy
echo "Running aclocal ..."
$ACLOCAL ${ACLOCAL_ARGS}
echo "Running autoheader..."
$AUTOHEADER
echo "Running automake ..."
$AUTOMAKE --add-missing --copy
echo "Running autoconf ..."
$AUTOCONF
${AUTORECONF:-autoreconf} --force --install "$@"
......@@ -10,10 +10,8 @@ PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = $(PAPEROPT_$(PAPER)) -E $(SPHINXOPTS) $(SOURCE_DIR)
SPHINX_DIR = $(abs_top_builddir)/doc/sphinx
SPHINX_BUILD_COMMAND = \
DOCUMENT_VERSION="$(DOCUMENT_VERSION)" \
DOCUMENT_VERSION_FULL="$(DOCUMENT_VERSION_FULL)" \
LOCALE="$(LOCALE)" \
PYTHONPATH="$(SPHINX_DIR):$$PYTHONPATH" \
$(SPHINX_BUILD)
......@@ -12,7 +12,7 @@
#
# 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 02111-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
MYSQL_SOURCE_DIR="@MYSQL_SOURCE_DIR@"
MYSQL_BUILD_DIR="@MYSQL_BUILD_DIR@"
......
......@@ -8,6 +8,7 @@ m4_define([mrn_version_in_hex], m4_include(version_in_hex))
m4_define([mrn_plugin_version], m4_include(plugin_version))
AC_INIT([mroonga], [mrn_version], [groonga-talk@lists.sourceforge.net])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([tar-pax foreign subdir-objects])
......@@ -173,18 +174,27 @@ AC_DEFUN([CONFIG_OPTION_MYSQL],[
MYSQL_INCLUDES=""
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_build_dir/include"
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_source_dir/sql"
if test -d "$ac_mysql_source_dir/sql/auth"; then
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_source_dir/sql/auth"
fi
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_source_dir/include"
if test -d "$ac_mysql_source_dir/extra/rapidjson"; then
mysql_rapidjson_include_dir="$ac_mysql_source_dir/extra/rapidjson/include"
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$mysql_rapidjson_include_dir"
fi
if test -d "$ac_mysql_source_dir/pcre"; then
mysql_regex_include_dir="$ac_mysql_source_dir/pcre"
if test -d "$ac_mysql_source_dir/extra/regex"; then
mysql_regex_include_dir="$ac_mysql_source_dir/extra/regex"
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$mysql_regex_include_dir"
else
mysql_regex_include_dir="$ac_mysql_source_dir/regex"
if test -d "$ac_mysql_source_dir/pcre"; then
mysql_regex_include_dir="$ac_mysql_source_dir/pcre"
else
mysql_regex_include_dir="$ac_mysql_source_dir/regex"
fi
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$mysql_regex_include_dir"
fi
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$mysql_regex_include_dir"
if test -d "$ac_mysql_source_dir/libbinlogevents"; then
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_build_dir/libbinlogevents/include"
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_source_dir/libbinlogevents/export"
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_source_dir/libbinlogevents/include"
fi
......@@ -199,7 +209,7 @@ AC_DEFUN([CONFIG_OPTION_MYSQL],[
MYSQL_CXXFLAGS="-fno-implicit-templates -felide-constructors"
case "$MYSQL_MAJOR_MINOR_VERSION" in
5.7)
5.7|8.*)
:
;;
*)
......@@ -381,6 +391,13 @@ AC_ARG_WITH(rsync-path,
[RSYNC_PATH="packages@packages.groonga.org:public"])
AC_SUBST(RSYNC_PATH)
AC_ARG_WITH(launchpad-ppa,
[AS_HELP_STRING([--with-launchpad-ppa=PPA],
[specify Launchpad Personal Package Archive. [default=groonga-ppa]])],
[LAUNCHPAD_PPA="$withval"],
[LAUNCHPAD_PPA="groonga-ppa"])
AC_SUBST(LAUNCHPAD_PPA)
AC_ARG_WITH(launchpad-uploader-pgp-key,
[AS_HELP_STRING([--with-launchpad-uploader-pgp-key=KEY],
[specify PGP key UID to upload Groonga packages to Launchpad.])],
......@@ -429,7 +446,7 @@ if test x"$enable_document" != x"no"; then
AC_PATH_PROG(SPHINX_BUILD, sphinx-build, [])
if test -n "$SPHINX_BUILD"; then
sphinx_build_version=`"$SPHINX_BUILD" --version`
if ! echo "$sphinx_build_version" | grep -q ' 1\.[[23]]'; then
if ! echo "$sphinx_build_version" | grep -q ' 1\.[[2-6]]'; then
AC_MSG_ERROR([
sphinx-build is old: $sphinx_build_version
Sphinx 1.2 or later is required.])
......@@ -509,12 +526,19 @@ AC_OUTPUT([
mrn_version.h
mysql-test/mroonga/storage/information_schema/r/plugins.result
mysql-test/mroonga/storage/variable/r/version.result
packages/debian/control
packages/debian-5.5/control
packages/debian-5.6/control
packages/debian-5.7/control
packages/debian-mariadb-10.0/control
packages/apt/env.sh
packages/rpm/centos/mysql55-mroonga.spec
packages/rpm/centos/mysql56-community-mroonga.spec
packages/rpm/centos/mysql57-community-mroonga.spec
packages/rpm/centos/mariadb-mroonga.spec
packages/rpm/centos/mariadb-10.1-mroonga.spec
packages/rpm/centos/mariadb-10.2-mroonga.spec
packages/rpm/centos/percona-server-56-mroonga.spec
packages/rpm/centos/percona-server-57-mroonga.spec
packages/yum/env.sh
data/install.sql
])
......@@ -17,3 +17,19 @@ CREATE FUNCTION mroonga_command RETURNS STRING
DROP FUNCTION IF EXISTS mroonga_escape;
CREATE FUNCTION mroonga_escape RETURNS STRING
SONAME 'ha_mroonga@MRN_PLUGIN_SUFFIX@';
DROP FUNCTION IF EXISTS mroonga_snippet_html;
CREATE FUNCTION mroonga_snippet_html RETURNS STRING
SONAME 'ha_mroonga@MRN_PLUGIN_SUFFIX@';
DROP FUNCTION IF EXISTS mroonga_normalize;
CREATE FUNCTION mroonga_normalize RETURNS STRING
SONAME 'ha_mroonga@MRN_PLUGIN_SUFFIX@';
DROP FUNCTION IF EXISTS mroonga_highlight_html;
CREATE FUNCTION mroonga_highlight_html RETURNS STRING
SONAME 'ha_mroonga@MRN_PLUGIN_SUFFIX@';
DROP FUNCTION IF EXISTS mroonga_query_expand;
CREATE FUNCTION mroonga_query_expand RETURNS STRING
SONAME 'ha_mroonga@MRN_PLUGIN_SUFFIX@';
......@@ -2,6 +2,10 @@ DROP FUNCTION IF EXISTS last_insert_grn_id;
DROP FUNCTION IF EXISTS mroonga_snippet;
DROP FUNCTION IF EXISTS mroonga_command;
DROP FUNCTION IF EXISTS mroonga_escape;
DROP FUNCTION IF EXISTS mroonga_snippet_html;
DROP FUNCTION IF EXISTS mroonga_normalize;
DROP FUNCTION IF EXISTS mroonga_highlight_html;
DROP FUNCTION IF EXISTS mroonga_query_expand;
UNINSTALL PLUGIN Mroonga;
......
This diff is collapsed.
......@@ -13,3 +13,6 @@ EXPORTS
mroonga_escape
mroonga_escape_init
mroonga_escape_deinit
mroonga_normalize
mroonga_normalize_init
mroonga_normalize_deinit
This diff is collapsed.
......@@ -28,4 +28,23 @@ libmrn_need_mysql_la_SOURCES = \
mrn_value_decoder.cpp \
mrn_value_decoder.hpp \
mrn_database_repairer.cpp \
mrn_database_repairer.hpp
mrn_database_repairer.hpp \
mrn_context_pool.cpp \
mrn_context_pool.hpp \
mrn_operations.cpp \
mrn_operations.hpp \
mrn_operation.cpp \
mrn_operation.hpp \
mrn_database.cpp \
mrn_database.hpp \
mrn_column_name.cpp \
mrn_column_name.hpp \
mrn_count_skip_checker.cpp \
mrn_count_skip_checker.hpp \
mrn_query_parser.cpp \
mrn_query_parser.hpp \
mrn_current_thread.hpp \
mrn_smart_bitmap.cpp \
mrn_smart_bitmap.hpp \
mrn_table_fields_offset_mover.cpp \
mrn_table_fields_offset_mover.hpp
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2016 Kouhei Sutou <kou@clear-code.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
*/
#include <mrn_mysql.h>
#include <mrn_mysql_compat.h>
#include "mrn_column_name.hpp"
#include <strfunc.h>
#include <string.h>
// for debug
#define MRN_CLASS_NAME "mrn::ColumnName"
namespace mrn {
ColumnName::ColumnName(const char *mysql_name)
: mysql_name_(mysql_name) {
encode();
}
const char *ColumnName::mysql_name() {
return mysql_name_;
}
const char *ColumnName::c_str() {
return name_;
}
size_t ColumnName::length() {
return length_;
}
void ColumnName::encode() {
MRN_DBUG_ENTER_METHOD();
uint errors;
length_ = mrn_strconvert(system_charset_info,
mysql_name_,
strlen(mysql_name_),
&my_charset_filename,
name_,
MRN_MAX_PATH_SIZE,
&errors);
name_[length_] = '\0';
DBUG_VOID_RETURN;
}
}
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2016 Kouhei Sutou <kou@clear-code.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
*/
#pragma once
#include <mrn_constants.hpp>
namespace mrn {
class ColumnName {
public:
ColumnName(const char *mysql_name);
const char *mysql_name();
const char *c_str();
size_t length();
private:
const char *mysql_name_;
char name_[MRN_MAX_PATH_SIZE];
size_t length_;
void encode();
};
}
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2013-2014 Kouhei Sutou <kou@clear-code.com>
Copyright(C) 2013-2017 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -175,7 +175,7 @@ namespace mrn {
bool convertable = false;
enum_field_types field_type = field_item->field_type();
enum_field_types field_type = field_item->field->real_type();
NormalizedType normalized_type = normalize_field_type(field_type);
switch (normalized_type) {
case STRING_TYPE:
......@@ -185,7 +185,12 @@ namespace mrn {
}
break;
case INT_TYPE:
convertable = value_item->type() == Item::INT_ITEM;
if (field_type == MYSQL_TYPE_ENUM) {
convertable = (value_item->type() == Item::STRING_ITEM ||
value_item->type() == Item::INT_ITEM);
} else {
convertable = value_item->type() == Item::INT_ITEM;
}
break;
case TIME_TYPE:
if (is_valid_time_value(field_item, value_item)) {
......@@ -206,7 +211,7 @@ namespace mrn {
bool convertable = false;
enum_field_types field_type = field_item->field_type();
enum_field_types field_type = field_item->field->type();
NormalizedType normalized_type = normalize_field_type(field_type);
switch (normalized_type) {
case STRING_TYPE:
......@@ -251,7 +256,7 @@ namespace mrn {
bool error;
Item *real_value_item = value_item->real_item();
switch (field_item->field_type()) {
switch (field_item->field->type()) {
case MYSQL_TYPE_TIME:
error = real_value_item->get_time(mysql_time);
break;
......@@ -352,6 +357,11 @@ namespace mrn {
case MYSQL_TYPE_GEOMETRY:
type = UNSUPPORTED_TYPE;
break;
#ifdef MRN_HAVE_MYSQL_TYPE_JSON
case MYSQL_TYPE_JSON:
type = STRING_TYPE;
break;
#endif
}
DBUG_RETURN(type);
......@@ -404,11 +414,11 @@ namespace mrn {
DBUG_RETURN(have);
}
const Item_func *ConditionConverter::find_match_against(const Item *item) {
unsigned int ConditionConverter::count_match_against(const Item *item) {
MRN_DBUG_ENTER_METHOD();
if (!item) {
DBUG_RETURN(NULL);
DBUG_RETURN(0);
}
switch (item->type()) {
......@@ -416,14 +426,13 @@ namespace mrn {
if (is_storage_mode_) {
Item_cond *cond_item = (Item_cond *)item;
if (cond_item->functype() == Item_func::COND_AND_FUNC) {
unsigned int n_match_againsts = 0;
List_iterator<Item> iterator(*((cond_item)->argument_list()));
const Item *sub_item;
while ((sub_item = iterator++)) {
const Item_func *match_against = find_match_against(sub_item);
if (match_against) {
DBUG_RETURN(match_against);
}
n_match_againsts += count_match_against(sub_item);
}
DBUG_RETURN(n_match_againsts);
}
}
break;
......@@ -432,7 +441,7 @@ namespace mrn {
const Item_func *func_item = (const Item_func *)item;
switch (func_item->functype()) {
case Item_func::FT_FUNC:
DBUG_RETURN(func_item);
DBUG_RETURN(1);
break;
default:
break;
......@@ -443,7 +452,7 @@ namespace mrn {
break;
}
DBUG_RETURN(NULL);
DBUG_RETURN(0);
}
void ConditionConverter::convert(const Item *where, grn_obj *expression) {
......@@ -560,7 +569,7 @@ namespace mrn {
grn_obj *expression) {
MRN_DBUG_ENTER_METHOD();
enum_field_types field_type = field_item->field_type();
enum_field_types field_type = field_item->field->real_type();
NormalizedType normalized_type = normalize_field_type(field_type);
switch (normalized_type) {
......@@ -574,7 +583,21 @@ namespace mrn {
break;
case INT_TYPE:
grn_obj_reinit(ctx_, &value_, GRN_DB_INT64, 0);
GRN_INT64_SET(ctx_, &value_, const_item->val_int());
if (field_type == MYSQL_TYPE_ENUM) {
if (const_item->type() == Item::STRING_ITEM) {
String *string;
string = const_item->val_str(NULL);
Field_enum *enum_field = static_cast<Field_enum *>(field_item->field);
int enum_value = find_type(string->c_ptr(),
enum_field->typelib,
FIND_TYPE_BASIC);
GRN_INT64_SET(ctx_, &value_, enum_value);
} else {
GRN_INT64_SET(ctx_, &value_, const_item->val_int());
}
} else {
GRN_INT64_SET(ctx_, &value_, const_item->val_int());
}
break;
case TIME_TYPE:
grn_obj_reinit(ctx_, &value_, GRN_DB_TIME, 0);
......
......@@ -33,7 +33,7 @@ namespace mrn {
~ConditionConverter();
bool is_convertable(const Item *item);
const Item_func *find_match_against(const Item *item);
unsigned int count_match_against(const Item *item);
// caller must check "where" can be convertable by
// is_convertable(). This method doesn't validate "where".
void convert(const Item *where, grn_obj *expression);
......
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2015 Kouhei Sutou <kou@clear-code.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
*/
#include "mrn_context_pool.hpp"
#include "mrn_lock.hpp"
#include <time.h>
namespace mrn {
// for debug
#define MRN_CLASS_NAME "mrn::ContextPool::Impl"
class ContextPool::Impl {
public:
Impl(mysql_mutex_t *mutex)
: mutex_(mutex),
pool_(NULL),
last_pull_time_(0) {
}
~Impl(void) {
clear();
}
grn_ctx *pull(void) {
MRN_DBUG_ENTER_METHOD();
grn_ctx *ctx = NULL;
{
time_t now;
time(&now);
mrn::Lock lock(mutex_);
if (pool_) {
ctx = static_cast<grn_ctx *>(pool_->data);
list_pop(pool_);
if ((now - last_pull_time_) >= CLEAR_THREATHOLD_IN_SECONDS) {
clear();
}
}
last_pull_time_ = now;
}
if (!ctx) {
ctx = grn_ctx_open(0);
}
DBUG_RETURN(ctx);
}
void release(grn_ctx *ctx) {
MRN_DBUG_ENTER_METHOD();
{
mrn::Lock lock(mutex_);
list_push(pool_, ctx);
grn_ctx_use(ctx, NULL);
}
DBUG_VOID_RETURN;
}
private:
static const unsigned int CLEAR_THREATHOLD_IN_SECONDS = 60 * 5;
mysql_mutex_t *mutex_;
LIST *pool_;
time_t last_pull_time_;
void clear(void) {
MRN_DBUG_ENTER_METHOD();
while (pool_) {
grn_ctx *ctx = static_cast<grn_ctx *>(pool_->data);
grn_ctx_close(ctx);
list_pop(pool_);
}
DBUG_VOID_RETURN;
}
};
// For debug
#undef MRN_CLASS_NAME
#define MRN_CLASS_NAME "mrn::ContextPool"
ContextPool::ContextPool(mysql_mutex_t *mutex)
: impl_(new Impl(mutex)) {
}
ContextPool::~ContextPool(void) {
delete impl_;
}
grn_ctx *ContextPool::pull(void) {
MRN_DBUG_ENTER_METHOD();
grn_ctx *ctx = impl_->pull();
DBUG_RETURN(ctx);
}
void ContextPool::release(grn_ctx *ctx) {
MRN_DBUG_ENTER_METHOD();
impl_->release(ctx);
DBUG_VOID_RETURN;
}
}
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2015 Kouhei Sutou <kou@clear-code.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
*/
#ifndef MRN_CONTEXT_POOL_HPP_
#define MRN_CONTEXT_POOL_HPP_
#include <mrn_mysql.h>
#include <groonga.h>
namespace mrn {
class ContextPool {
public:
ContextPool(mysql_mutex_t *mutex);
~ContextPool(void);
grn_ctx *pull(void);
void release(grn_ctx *context);
private:
class Impl;
Impl *impl_;
};
}
#endif /* MRN_CONTEXT_POOL_HPP_ */
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2010-2013 Kentoku SHIBA
Copyright(C) 2011-2017 Kouhei Sutou <kou@clear-code.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
*/
#include "mrn_count_skip_checker.hpp"
#include <item_sum.h>
// for debug
#define MRN_CLASS_NAME "mrn::CountSkipChecker"
namespace mrn {
CountSkipChecker::CountSkipChecker(grn_ctx *ctx,
TABLE *table,
SELECT_LEX *select_lex,
KEY *key_info,
key_part_map target_key_part_map,
bool is_storage_mode)
: ctx_(ctx),
table_(table),
select_lex_(select_lex),
key_info_(key_info),
target_key_part_map_(target_key_part_map),
is_storage_mode_(is_storage_mode) {
}
CountSkipChecker::~CountSkipChecker() {
}
bool CountSkipChecker::check() {
MRN_DBUG_ENTER_METHOD();
if (select_lex_->item_list.elements != 1) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] not only one item: %u",
select_lex_->item_list.elements);
DBUG_RETURN(false);
}
if (select_lex_->group_list.elements > 0) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] have groups: %u",
select_lex_->group_list.elements);
DBUG_RETURN(false);
}
if (MRN_SELECT_LEX_GET_HAVING_COND(select_lex_)) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] have HAVING");
DBUG_RETURN(false);
}
if (select_lex_->table_list.elements != 1) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] not only one table: %u",
select_lex_->table_list.elements);
DBUG_RETURN(false);
}
Item *info = static_cast<Item *>(select_lex_->item_list.first_node()->info);
if (info->type() != Item::SUM_FUNC_ITEM) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] item isn't sum function: %u",
info->type());
DBUG_RETURN(false);
}
Item_sum *sum_item = static_cast<Item_sum *>(info);
if (sum_item->sum_func() != Item_sum::COUNT_FUNC) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] not COUNT: %u",
sum_item->sum_func());
DBUG_RETURN(false);
}
if (ITEM_SUM_GET_NEST_LEVEL(sum_item) != 0 ||
ITEM_SUM_GET_AGGR_LEVEL(sum_item) != 0 ||
ITEM_SUM_GET_MAX_AGGR_LEVEL(sum_item) != -1 ||
sum_item->max_sum_func_level != -1) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] not simple COUNT(*): %d:%d:%d:%d",
ITEM_SUM_GET_NEST_LEVEL(sum_item),
ITEM_SUM_GET_AGGR_LEVEL(sum_item),
ITEM_SUM_GET_MAX_AGGR_LEVEL(sum_item),
sum_item->max_sum_func_level);
DBUG_RETURN(false);
}
Item *where = MRN_SELECT_LEX_GET_WHERE_COND(select_lex_);
if (!where) {
if (is_storage_mode_) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][true] no condition");
DBUG_RETURN(true);
} else {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] no condition with wrapper mode");
DBUG_RETURN(false);
}
}
bool skippable = is_skippable(where);
DBUG_RETURN(skippable);
}
bool CountSkipChecker::is_skippable(Item *where) {
MRN_DBUG_ENTER_METHOD();
bool skippable = false;
switch (where->type()) {
case Item::COND_ITEM:
{
Item_cond *cond_item = static_cast<Item_cond *>(where);
skippable = is_skippable(cond_item);
if (skippable) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][true] skippable multiple conditions");
}
}
break;
case Item::FUNC_ITEM:
{
Item_func *func_item = static_cast<Item_func *>(where);
if (func_item->functype() == Item_func::FT_FUNC) {
if (select_lex_->select_n_where_fields == 1) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][true] "
"only one full text search condition");
DBUG_RETURN(true);
} else {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] "
"full text search condition and more conditions: %u",
select_lex_->select_n_where_fields);
DBUG_RETURN(false);
}
} else {
skippable = is_skippable(func_item);
if (skippable) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][true] skippable condition");
}
}
}
break;
default:
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] unsupported top level item: %u",
where->type());
break;
}
DBUG_RETURN(skippable);
}
bool CountSkipChecker::is_skippable(Item_cond *cond_item) {
MRN_DBUG_ENTER_METHOD();
List_iterator<Item> iterator(*(cond_item->argument_list()));
Item *sub_item;
while ((sub_item = iterator++)) {
if (sub_item->type() != Item::FUNC_ITEM) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] "
"sub condition isn't function item: %u",
sub_item->type());
DBUG_RETURN(false);
}
if (!is_skippable(static_cast<Item_func *>(sub_item))) {
DBUG_RETURN(false);
}
}
DBUG_RETURN(true);
}
bool CountSkipChecker::is_skippable(Item_func *func_item) {
MRN_DBUG_ENTER_METHOD();
switch (func_item->functype()) {
case Item_func::EQ_FUNC:
case Item_func::EQUAL_FUNC:
case Item_func::NE_FUNC:
case Item_func::LT_FUNC:
case Item_func::LE_FUNC:
case Item_func::GE_FUNC:
case Item_func::GT_FUNC:
{
Item **arguments = func_item->arguments();
Item *left_item = arguments[0];
if (left_item->type() != Item::FIELD_ITEM) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] not field: %u:%u",
func_item->functype(),
left_item->type());
DBUG_RETURN(false);
}
bool skippable = is_skippable(static_cast<Item_field *>(left_item));
DBUG_RETURN(skippable);
}
break;
case Item_func::BETWEEN:
{
Item **arguments = func_item->arguments();
Item *target_item = arguments[0];
if (target_item->type() != Item::FIELD_ITEM) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] BETWEEN target isn't field: %u",
target_item->type());
DBUG_RETURN(false);
}
bool skippable = is_skippable(static_cast<Item_field *>(target_item));
DBUG_RETURN(skippable);
}
break;
case Item_func::MULT_EQUAL_FUNC:
#ifdef MRN_HAVE_ITEM_EQUAL_FIELDS_ITERATOR
{
Item_equal *equal_item = static_cast<Item_equal *>(func_item);
Item_equal_fields_iterator iterator(*equal_item);
Item *field_item;
while ((field_item = iterator++)) {
bool skippable = is_skippable(static_cast<Item_field *>(field_item));
if (!skippable) {
DBUG_RETURN(skippable);
}
}
DBUG_RETURN(true);
}
#endif
break;
default:
break;
}
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] unsupported function item: %u",
func_item->functype());
DBUG_RETURN(false);
}
bool CountSkipChecker::is_skippable(Item_field *field_item) {
MRN_DBUG_ENTER_METHOD();
Field *field = field_item->field;
if (!field) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] field is missing");
DBUG_RETURN(false);
}
if (field->table != table_) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] external table's field");
DBUG_RETURN(false);
}
if (!key_info_) {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] no active index: <%s>:<%s>",
*(field->table_name),
field->field_name);
DBUG_RETURN(false);
}
uint i;
KEY_PART_INFO *key_part = key_info_->key_part;
for (i = 0; i < KEY_N_KEY_PARTS(key_info_); i++) {
if (key_part[i].field == field) {
if ((target_key_part_map_ >> i) & 1) {
DBUG_RETURN(true);
} else {
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] "
"field's index are out of key part map: %u:%lu: <%s>:<%s>",
i,
target_key_part_map_,
*(field->table_name),
field->field_name);
DBUG_RETURN(false);
}
}
}
GRN_LOG(ctx_, GRN_LOG_DEBUG,
"[mroonga][count-skip][false] field isn't indexed: <%s>:<%s>",
*(field->table_name),
field->field_name);
DBUG_RETURN(false);
}
}
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2016 Kouhei Sutou <kou@clear-code.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
*/
#ifndef MRN_COUNT_SKIP_CHECKER_HPP_
#define MRN_COUNT_SKIP_CHECKER_HPP_
#include <mrn_mysql_compat.h>
#include <item_cmpfunc.h>
#include <groonga.h>
namespace mrn {
class CountSkipChecker {
public:
CountSkipChecker(grn_ctx *ctx,
TABLE *table,
SELECT_LEX *select_lex,
KEY *key_info,
key_part_map target_key_part_map,
bool is_storage_mode);
~CountSkipChecker();
bool check();
private:
grn_ctx *ctx_;
TABLE *table_;
SELECT_LEX *select_lex_;
KEY *key_info_;
key_part_map target_key_part_map_;
bool is_storage_mode_;
bool is_skippable(Item *where);
bool is_skippable(Item_cond *cond_item);
bool is_skippable(Item_func *func_item);
bool is_skippable(Item_field *field_item);
};
}
#endif /* MRN_COUNT_SKIP_CHECKER_HPP_ */
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2017 Kouhei Sutou <kou@clear-code.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
*/
#pragma once
#include <mrn_mysql.h>
#include <mrn_mysql_compat.h>
#if (!defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 80002)
# include <current_thd.h>
#endif
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2015 Kouhei Sutou <kou@clear-code.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
*/
#include <mrn_mysql.h>
#include "mrn_database.hpp"
#include "mrn_operations.hpp"
// for debug
#define MRN_CLASS_NAME "mrn::Database"
namespace mrn {
Database::Database(grn_ctx *ctx, grn_obj *db)
: ctx_(ctx),
db_(db),
broken_table_names_(NULL),
is_broken_(false) {
Operations operations(ctx_);
broken_table_names_ = operations.collect_processing_table_names();
is_broken_ = operations.is_locked();
}
Database::~Database(void) {
close();
}
void Database::close() {
MRN_DBUG_ENTER_METHOD();
if (db_) {
grn_hash_close(ctx_, broken_table_names_);
broken_table_names_ = NULL;
grn_obj_close(ctx_, db_);
db_ = NULL;
}
DBUG_VOID_RETURN;
}
grn_rc Database::remove() {
MRN_DBUG_ENTER_METHOD();
grn_rc rc = GRN_SUCCESS;
if (db_) {
grn_hash_close(ctx_, broken_table_names_);
broken_table_names_ = NULL;
rc = grn_obj_remove(ctx_, db_);
if (rc == GRN_SUCCESS) {
db_ = NULL;
}
}
DBUG_RETURN(rc);
}
grn_obj *Database::get() {
MRN_DBUG_ENTER_METHOD();
DBUG_RETURN(db_);
}
bool Database::is_broken() {
MRN_DBUG_ENTER_METHOD();
DBUG_RETURN(is_broken_);
}
bool Database::is_broken_table(const char *name, size_t name_size) {
MRN_DBUG_ENTER_METHOD();
grn_id id = grn_hash_get(ctx_, broken_table_names_, name, name_size, NULL);
DBUG_RETURN(id != GRN_ID_NIL);
}
void Database::mark_table_repaired(const char *name, size_t name_size) {
MRN_DBUG_ENTER_METHOD();
grn_hash_delete(ctx_, broken_table_names_, name, name_size, NULL);
DBUG_VOID_RETURN;
}
}
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2015 Kouhei Sutou <kou@clear-code.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
*/
#ifndef MRN_DATABASE_HPP_
#define MRN_DATABASE_HPP_
#include <groonga.h>
namespace mrn {
class Database {
public:
Database(grn_ctx *ctx, grn_obj *db);
~Database(void);
void close();
grn_rc remove();
grn_obj *get();
bool is_broken();
bool is_broken_table(const char *name, size_t name_size);
void mark_table_repaired(const char *name, size_t name_size);
private:
grn_ctx *ctx_;
grn_obj *db_;
grn_hash *broken_table_names_;
bool is_broken_;
};
}
#endif /* MRN_DATABASE_HPP_ */
......@@ -56,9 +56,9 @@ namespace mrn {
if (cache_) {
void *db_address;
GRN_HASH_EACH(ctx_, cache_, id, NULL, 0, &db_address, {
grn_obj *db;
Database *db;
memcpy(&db, db_address, sizeof(grn_obj *));
grn_obj_unlink(ctx_, db);
delete db;
});
grn_hash_close(ctx_, cache_);
}
......@@ -80,7 +80,7 @@ namespace mrn {
DBUG_RETURN(true);
}
int DatabaseManager::open(const char *path, grn_obj **db) {
int DatabaseManager::open(const char *path, Database **db) {
MRN_DBUG_ENTER_METHOD();
int error = 0;
......@@ -100,36 +100,54 @@ namespace mrn {
mapper.db_name(), strlen(mapper.db_name()),
&db_address);
if (id == GRN_ID_NIL) {
grn_obj *grn_db;
struct stat db_stat;
if (stat(mapper.db_path(), &db_stat)) {
GRN_LOG(ctx_, GRN_LOG_INFO,
"database not found. creating...: <%s>", mapper.db_path());
if (path[0] == FN_CURLIB &&
(path[1] == FN_LIBCHAR || path[1] == FN_LIBCHAR2)) {
mrn_is_directory_separator(path[1])) {
ensure_database_directory();
}
*db = grn_db_create(ctx_, mapper.db_path(), NULL);
grn_db = grn_db_create(ctx_, mapper.db_path(), NULL);
if (ctx_->rc) {
error = ER_CANT_CREATE_TABLE;
my_message(error, ctx_->errbuf, MYF(0));
DBUG_RETURN(error);
}
} else {
*db = grn_db_open(ctx_, mapper.db_path());
grn_db = grn_db_open(ctx_, mapper.db_path());
if (ctx_->rc) {
error = ER_CANT_OPEN_FILE;
my_message(error, ctx_->errbuf, MYF(0));
DBUG_RETURN(error);
}
}
*db = new Database(ctx_, grn_db);
grn_hash_add(ctx_, cache_,
mapper.db_name(), strlen(mapper.db_name()),
&db_address, NULL);
memcpy(db_address, db, sizeof(grn_obj *));
error = ensure_normalizers_registered(*db);
memcpy(db_address, db, sizeof(Database *));
error = ensure_normalizers_registered((*db)->get());
if (!error) {
if ((*db)->is_broken()) {
error = ER_CANT_OPEN_FILE;
char error_message[MRN_MESSAGE_BUFFER_SIZE];
snprintf(error_message, MRN_MESSAGE_BUFFER_SIZE,
"mroonga: database: open: "
"The database maybe broken. "
"We recommend you to recreate the database. "
"If the database isn't broken, "
"you can remove this error by running "
"'groonga %s table_remove mroonga_operations' "
"on server. But the latter isn't recommended.",
mapper.db_path());
my_message(error, error_message, MYF(0));
}
}
} else {
memcpy(db, db_address, sizeof(grn_obj *));
grn_ctx_use(ctx_, *db);
memcpy(db, db_address, sizeof(Database *));
grn_ctx_use(ctx_, (*db)->get());
}
DBUG_RETURN(error);
......@@ -150,10 +168,11 @@ namespace mrn {
DBUG_VOID_RETURN;
}
grn_obj *db = NULL;
memcpy(&db, db_address, sizeof(grn_obj *));
Database *db = NULL;
memcpy(&db, db_address, sizeof(Database *));
grn_ctx_use(ctx_, db->get());
if (db) {
grn_obj_close(ctx_, db);
delete db;
}
grn_hash_delete_by_id(ctx_, cache_, id, NULL);
......@@ -173,29 +192,35 @@ namespace mrn {
mapper.db_name(), strlen(mapper.db_name()),
&db_address);
grn_obj *db = NULL;
Database *db = NULL;
if (id == GRN_ID_NIL) {
struct stat dummy;
if (stat(mapper.db_path(), &dummy) == 0) {
db = grn_db_open(ctx_, mapper.db_path());
grn_obj *grn_db = grn_db_open(ctx_, mapper.db_path());
db = new Database(ctx_, grn_db);
}
} else {
memcpy(&db, db_address, sizeof(grn_obj *));
memcpy(&db, db_address, sizeof(Database *));
grn_ctx_use(ctx_, db->get());
}
if (!db) {
DBUG_RETURN(false);
}
if (grn_obj_remove(ctx_, db) == GRN_SUCCESS) {
if (db->remove() == GRN_SUCCESS) {
if (id != GRN_ID_NIL) {
grn_hash_delete_by_id(ctx_, cache_, id, NULL);
}
delete db;
DBUG_RETURN(true);
} else {
GRN_LOG(ctx_, GRN_LOG_ERROR,
"failed to drop database: <%s>: <%s>",
mapper.db_path(), ctx_->errbuf);
if (id == GRN_ID_NIL) {
delete db;
}
DBUG_RETURN(false);
}
}
......@@ -223,22 +248,28 @@ namespace mrn {
break;
}
void *db_address;
grn_obj *db;
Database *db;
grn_hash_cursor_get_value(ctx_, cursor, &db_address);
memcpy(&db, db_address, sizeof(grn_obj *));
memcpy(&db, db_address, sizeof(Database *));
grn_ctx_use(ctx_, db->get());
grn_rc rc = grn_hash_cursor_delete(ctx_, cursor, NULL);
if (rc) {
error = ER_ERROR_ON_READ;
my_message(error, ctx_->errbuf, MYF(0));
break;
}
grn_obj_close(ctx_, db);
delete db;
}
grn_hash_cursor_close(ctx_, cursor);
DBUG_RETURN(error);
}
const char *DatabaseManager::error_message() {
MRN_DBUG_ENTER_METHOD();
DBUG_RETURN(ctx_->errbuf);
}
void DatabaseManager::mkdir_p(const char *directory) {
MRN_DBUG_ENTER_METHOD();
......@@ -246,8 +277,7 @@ namespace mrn {
char sub_directory[MRN_MAX_PATH_SIZE];
sub_directory[0] = '\0';
while (true) {
if (directory[i] == FN_LIBCHAR ||
directory[i] == FN_LIBCHAR2 ||
if (mrn_is_directory_separator(directory[i]) ||
directory[i] == '\0') {
sub_directory[i] = '\0';
struct stat directory_status;
......@@ -290,8 +320,10 @@ namespace mrn {
const char *last_path_separator;
last_path_separator = strrchr(path_prefix, FN_LIBCHAR);
#ifdef FN_LIBCHAR2
if (!last_path_separator)
last_path_separator = strrchr(path_prefix, FN_LIBCHAR2);
#endif
if (!last_path_separator)
DBUG_VOID_RETURN;
if (path_prefix == last_path_separator)
......
......@@ -22,6 +22,8 @@
#ifndef MRN_DATABASE_MANAGER_HPP_
#define MRN_DATABASE_MANAGER_HPP_
#include "mrn_database.hpp"
#include <groonga.h>
namespace mrn {
......@@ -30,10 +32,11 @@ namespace mrn {
DatabaseManager(grn_ctx *ctx, mysql_mutex_t *mutex);
~DatabaseManager(void);
bool init(void);
int open(const char *path, grn_obj **db);
int open(const char *path, Database **db);
void close(const char *path);
bool drop(const char *path);
int clear(void);
const char *error_message();
private:
grn_ctx *ctx_;
......
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2015 Kouhei Sutou <kou@clear-code.com>
Copyright(C) 2015-2017 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -36,6 +36,16 @@
#endif
namespace mrn {
struct CheckResult {
CheckResult() :
is_crashed(false),
is_corrupt(false) {
}
bool is_crashed;
bool is_corrupt;
};
DatabaseRepairer::DatabaseRepairer(grn_ctx *ctx, THD *thd)
: ctx_(ctx),
thd_(thd),
......@@ -53,10 +63,19 @@ namespace mrn {
bool DatabaseRepairer::is_crashed(void) {
MRN_DBUG_ENTER_METHOD();
bool is_crashed = false;
each_database(&DatabaseRepairer::is_crashed_body, &is_crashed);
CheckResult result;
each_database(&DatabaseRepairer::check_body, &result);
DBUG_RETURN(result.is_crashed);
}
bool DatabaseRepairer::is_corrupt(void) {
MRN_DBUG_ENTER_METHOD();
CheckResult result;
each_database(&DatabaseRepairer::check_body, &result);
DBUG_RETURN(is_crashed);
DBUG_RETURN(result.is_corrupt);
}
bool DatabaseRepairer::repair(void) {
......@@ -81,9 +100,19 @@ namespace mrn {
DBUG_VOID_RETURN;
}
do {
each_database_body(data.cFileName, each_body_func, user_data);
} while (FindNextFile(finder, &data) != 0);
grn_ctx ctx;
grn_rc rc = grn_ctx_init(&ctx, 0);
if (rc == GRN_SUCCESS) {
do {
each_database_body(data.cFileName, &ctx, each_body_func, user_data);
} while (FindNextFile(finder, &data) != 0);
grn_ctx_fin(&ctx);
} else {
GRN_LOG(ctx_, GRN_LOG_WARNING,
"[mroonga][database][repairer][each] "
"failed to initialize grn_ctx: %d: %s",
rc, grn_rc_to_string(rc));
}
FindClose(finder);
#else
DIR *dir = opendir(base_directory_);
......@@ -91,8 +120,18 @@ namespace mrn {
DBUG_VOID_RETURN;
}
while (struct dirent *entry = readdir(dir)) {
each_database_body(entry->d_name, each_body_func, user_data);
grn_ctx ctx;
grn_rc rc = grn_ctx_init(&ctx, 0);
if (rc == GRN_SUCCESS) {
while (struct dirent *entry = readdir(dir)) {
each_database_body(entry->d_name, &ctx, each_body_func, user_data);
}
grn_ctx_fin(&ctx);
} else {
GRN_LOG(ctx_, GRN_LOG_WARNING,
"[mroonga][database][repairer][each] "
"failed to initialize grn_ctx: %d: %s",
rc, grn_rc_to_string(rc));
}
closedir(dir);
#endif
......@@ -101,6 +140,7 @@ namespace mrn {
}
void DatabaseRepairer::each_database_body(const char *base_path,
grn_ctx *ctx,
EachBodyFunc each_body_func,
void *user_data) {
MRN_DBUG_ENTER_METHOD();
......@@ -123,14 +163,14 @@ namespace mrn {
char db_path[MRN_MAX_PATH_SIZE];
snprintf(db_path, MRN_MAX_PATH_SIZE,
"%s%c%s", base_directory_, FN_LIBCHAR, base_path);
grn_obj *db = grn_db_open(ctx_, db_path);
grn_obj *db = grn_db_open(ctx, db_path);
if (!db) {
DBUG_VOID_RETURN;
}
(this->*each_body_func)(db, db_path, user_data);
(this->*each_body_func)(ctx, db, db_path, user_data);
grn_obj_close(ctx_, db);
grn_obj_close(ctx, db);
DBUG_VOID_RETURN;
}
......@@ -150,8 +190,7 @@ namespace mrn {
size_t raw_path_prefix_length = strlen(raw_path_prefix);
size_t separator_position = raw_path_prefix_length;
for (; separator_position > 0; separator_position--) {
if (base_directory_buffer_[separator_position] == FN_LIBCHAR ||
base_directory_buffer_[separator_position] == FN_LIBCHAR2) {
if (mrn_is_directory_separator(base_directory_buffer_[separator_position])) {
break;
}
}
......@@ -169,34 +208,46 @@ namespace mrn {
DBUG_VOID_RETURN;
}
void DatabaseRepairer::is_crashed_body(grn_obj *db,
const char *db_path,
void *user_data) {
void DatabaseRepairer::check_body(grn_ctx *ctx,
grn_obj *db,
const char *db_path,
void *user_data) {
MRN_DBUG_ENTER_METHOD();
bool *is_crashed = static_cast<bool *>(user_data);
CheckResult *result = static_cast<CheckResult *>(user_data);
if (grn_obj_is_locked(ctx_, db)) {
*is_crashed = true;
if (grn_obj_is_locked(ctx, db)) {
result->is_crashed = true;
result->is_corrupt = true;
DBUG_VOID_RETURN;
}
grn_table_cursor *cursor;
cursor = grn_table_cursor_open(ctx_, db,
cursor = grn_table_cursor_open(ctx, db,
NULL, 0,
NULL, 0,
0, -1, GRN_CURSOR_BY_ID);
if (!cursor) {
*is_crashed = true;
result->is_crashed = true;
result->is_corrupt = true;
DBUG_VOID_RETURN;
}
grn_id id;
while ((id = grn_table_cursor_next(ctx_, cursor)) != GRN_ID_NIL) {
grn_obj *object = grn_ctx_at(ctx_, id);
while ((id = grn_table_cursor_next(ctx, cursor)) != GRN_ID_NIL) {
if (grn_id_is_builtin(ctx, id)) {
continue;
}
grn_obj *object = grn_ctx_at(ctx, id);
if (!object) {
continue;
if (ctx->rc == GRN_SUCCESS) {
continue;
} else {
result->is_corrupt = true;
break;
}
}
switch (object->header.type) {
......@@ -207,37 +258,40 @@ namespace mrn {
case GRN_COLUMN_FIX_SIZE:
case GRN_COLUMN_VAR_SIZE:
case GRN_COLUMN_INDEX:
grn_obj_is_locked(ctx_, object);
*is_crashed = true;
if (grn_obj_is_locked(ctx_, object)) {
result->is_crashed = true;
result->is_corrupt = true;
}
break;
default:
break;
}
grn_obj_unlink(ctx_, object);
grn_obj_unlink(ctx, object);
if (*is_crashed) {
if (result->is_crashed || result->is_corrupt) {
break;
}
}
grn_table_cursor_close(ctx_, cursor);
grn_table_cursor_close(ctx, cursor);
DBUG_VOID_RETURN;
}
void DatabaseRepairer::repair_body(grn_obj *db,
void DatabaseRepairer::repair_body(grn_ctx *ctx,
grn_obj *db,
const char *db_path,
void *user_data) {
MRN_DBUG_ENTER_METHOD();
bool *succeeded = static_cast<bool *>(user_data);
if (grn_db_recover(ctx_, db) != GRN_SUCCESS) {
if (grn_db_recover(ctx, db) != GRN_SUCCESS) {
push_warning_printf(thd_,
MRN_SEVERITY_WARNING,
ER_NOT_KEYFILE,
"mroonga: repair: "
"Failed to recover database: <%s>: <%s>",
db_path, ctx_->errbuf);
db_path, ctx->errbuf);
*succeeded = false;
}
......
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2015 Kouhei Sutou <kou@clear-code.com>
Copyright(C) 2015-2017 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -28,6 +28,7 @@ namespace mrn {
DatabaseRepairer(grn_ctx *ctx, THD *thd);
~DatabaseRepairer(void);
bool is_crashed(void);
bool is_corrupt(void);
bool repair(void);
private:
......@@ -40,18 +41,26 @@ namespace mrn {
size_t path_prefix_length_;
size_t mrn_db_file_suffix_length_;
typedef void (DatabaseRepairer::*EachBodyFunc)(grn_obj *db,
typedef void (DatabaseRepairer::*EachBodyFunc)(grn_ctx *ctx,
grn_obj *db,
const char *db_path,
void *user_data);
void each_database(EachBodyFunc each_body_func, void *user_data);
void each_database_body(const char *base_path,
grn_ctx *ctx,
EachBodyFunc each_body_func,
void *user_data);
void detect_paths(void);
void is_crashed_body(grn_obj *db, const char *db_path, void *user_data);
void repair_body(grn_obj *db, const char *db_path, void *user_data);
void check_body(grn_ctx *ctx,
grn_obj *db,
const char *db_path,
void *user_data);
void repair_body(grn_ctx *ctx,
grn_obj *db,
const char *db_path,
void *user_data);
};
}
......
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2011 Kentoku SHIBA
Copyright(C) 2011-2012 Kouhei Sutou <kou@clear-code.com>
Copyright(C) 2011-2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -26,7 +26,8 @@
#define MRN_CLASS_NAME "mrn::IndexTableName"
namespace mrn {
const char *IndexTableName::SEPARATOR = "-";
const char *IndexTableName::SEPARATOR = "#";
const char *IndexTableName::OLD_SEPARATOR = "-";
bool IndexTableName::is_custom_name(const char *table_name,
size_t table_name_length,
......@@ -43,9 +44,12 @@ namespace mrn {
DBUG_RETURN(true);
}
if (strncmp(SEPARATOR,
index_table_name + table_name_length,
strlen(SEPARATOR)) != 0) {
if ((strncmp(OLD_SEPARATOR,
index_table_name + table_name_length,
strlen(OLD_SEPARATOR)) != 0) &&
(strncmp(SEPARATOR,
index_table_name + table_name_length,
strlen(SEPARATOR)) != 0)) {
DBUG_RETURN(true);
}
......@@ -63,6 +67,12 @@ namespace mrn {
encoded_mysql_index_name_multibyte + MRN_MAX_KEY_SIZE,
mysql_index_name_multibyte,
mysql_index_name_multibyte + strlen(mysql_index_name_));
snprintf(old_name_, MRN_MAX_KEY_SIZE,
"%s%s%s",
table_name_,
OLD_SEPARATOR,
encoded_mysql_index_name_multibyte);
old_length_ = strlen(old_name_);
snprintf(name_, MRN_MAX_KEY_SIZE,
"%s%s%s",
table_name_,
......@@ -79,6 +89,14 @@ namespace mrn {
return length_;
}
const char *IndexTableName::old_c_str() {
return old_name_;
}
size_t IndexTableName::old_length() {
return old_length_;
}
uint IndexTableName::encode(uchar *encoded_start,
uchar *encoded_end,
const uchar *mysql_string_start,
......
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2011 Kentoku SHIBA
Copyright(C) 2011-2012 Kouhei Sutou <kou@clear-code.com>
Copyright(C) 2011-2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -27,6 +27,7 @@ namespace mrn {
class IndexTableName {
public:
static const char *SEPARATOR;
static const char *OLD_SEPARATOR;
static bool is_custom_name(const char *table_name,
size_t table_name_length,
......@@ -36,9 +37,13 @@ namespace mrn {
IndexTableName(const char *table_name, const char *mysql_index_name);
const char *c_str();
size_t length();
const char *old_c_str();
size_t old_length();
private:
const char *table_name_;
const char *mysql_index_name_;
char old_name_[MRN_MAX_KEY_SIZE];
size_t old_length_;
char name_[MRN_MAX_KEY_SIZE];
size_t length_;
......
......@@ -288,6 +288,7 @@ namespace mrn {
decode_long_long_int(current_grn_key, &grn_time);
TimeConverter time_converter;
MYSQL_TIME mysql_time;
mysql_time.neg = FALSE;
mysql_time.time_type = MYSQL_TIMESTAMP_DATETIME;
time_converter.grn_time_to_mysql_time(grn_time, &mysql_time);
long long int mysql_datetime_packed =
......@@ -518,6 +519,14 @@ namespace mrn {
*data_type = TYPE_BYTE_SEQUENCE;
*data_size = key_part->length;
break;
#ifdef MRN_HAVE_MYSQL_TYPE_JSON
case MYSQL_TYPE_JSON:
// TODO
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_JSON"));
*data_type = TYPE_BYTE_SEQUENCE;
*data_size = key_part->length;
break;
#endif
}
DBUG_VOID_RETURN;
}
......
......@@ -20,11 +20,11 @@
#ifndef MRN_MULTIPLE_COLUMN_KEY_CODEC_HPP_
#define MRN_MULTIPLE_COLUMN_KEY_CODEC_HPP_
#include <groonga.h>
#include <mrn_mysql.h>
#include <mrn_mysql_compat.h>
#include <groonga.h>
namespace mrn {
class MultipleColumnKeyCodec {
public:
......
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2015 Kouhei Sutou <kou@clear-code.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
*/
#include <mrn_mysql.h>
#include "mrn_operation.hpp"
// for debug
#define MRN_CLASS_NAME "mrn::Operation"
namespace mrn {
Operation::Operation(mrn::Operations *operations,
const char *type,
const char *table_name,
size_t table_name_size)
: operations_(operations),
id_(operations_->start(type, table_name, table_name_size)) {
}
Operation::~Operation() {
MRN_DBUG_ENTER_METHOD();
operations_->finish(id_);
DBUG_VOID_RETURN;
}
void Operation::record_target(grn_id record_id) {
MRN_DBUG_ENTER_METHOD();
operations_->record_target(id_, record_id);
DBUG_VOID_RETURN;
}
}
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2015 Kouhei Sutou <kou@clear-code.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
*/
#ifndef MRN_OPERATION_HPP_
#define MRN_OPERATION_HPP_
#include <mrn_operations.hpp>
namespace mrn {
class Operation {
public:
Operation(mrn::Operations *operations,
const char *type,
const char *table_name,
size_t table_name_size);
~Operation();
void record_target(grn_id record_id);
private:
mrn::Operations *operations_;
grn_id id_;
};
}
#endif /* MRN_OPERATION_HPP_ */
This diff is collapsed.
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2015 Kouhei Sutou <kou@clear-code.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
*/
#ifndef MRN_OPERATIONS_HPP_
#define MRN_OPERATIONS_HPP_
#include <groonga.h>
namespace mrn {
class Operations {
public:
Operations(grn_ctx *ctx);
~Operations();
bool is_locked();
grn_id start(const char *type,
const char *table_name, size_t table_name_size);
void record_target(grn_id id, grn_id target_id);
void finish(grn_id id);
void enable_recording();
void disable_recording();
grn_hash *collect_processing_table_names();
int repair(const char *table_name, size_t table_name_size);
int clear(const char *table_name, size_t table_name_size);
private:
grn_ctx *ctx_;
grn_obj text_buffer_;
grn_obj id_buffer_;
grn_obj *table_;
struct {
grn_obj *type_;
grn_obj *table_;
grn_obj *record_;
} columns_;
bool is_enabled_recording_;
};
}
#endif /* MRN_OPERATIONS_HPP_ */
......@@ -222,4 +222,8 @@ namespace mrn {
mysql_path_[i] = '\0';
return mysql_path_;
}
bool PathMapper::is_internal_table_name() {
return mysql_table_name()[0] == '#';
}
}
......@@ -38,6 +38,8 @@ namespace mrn {
const char *table_name();
const char *mysql_table_name();
const char *mysql_path();
bool is_internal_table_name();
bool is_temporary_table_name();
private:
const char *original_mysql_path_;
const char *path_prefix_;
......
This diff is collapsed.
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2017 Kouhei Sutou <kou@clear-code.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
*/
#pragma once
#include <mrn_mysql.h>
#include <mrn_mysql_compat.h>
#include <groonga.h>
namespace mrn {
class QueryParser {
public:
QueryParser(grn_ctx *ctx,
THD *thd,
grn_obj *expression,
grn_obj *default_column,
uint n_sections,
grn_obj *match_columns=NULL);
~QueryParser();
grn_rc parse(const char *query, size_t query_length);
void parse_pragma(const char *query,
size_t query_length,
const char **raw_query,
size_t *raw_query_length,
grn_operator *default_operator,
grn_expr_flags *flags);
private:
grn_ctx *ctx_;
THD *thd_;
grn_obj *expression_;
grn_obj *default_column_;
uint n_sections_;
grn_obj *match_columns_;
bool parse_pragma_w(const char *query,
size_t query_length,
size_t *consumed_query_length);
void append_section(uint section,
grn_obj *section_value_buffer,
int weight,
uint n_weights);
bool parse_pragma_d(const char *query,
size_t query_length,
grn_operator *default_operator,
size_t *consumed_query_length);
grn_expr_flags default_expression_flags();
};
}
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2017 Kouhei Sutou <kou@clear-code.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
*/
#include "mrn_smart_bitmap.hpp"
namespace mrn {
SmartBitmap::SmartBitmap(MY_BITMAP *bitmap)
: bitmap_(bitmap) {
}
SmartBitmap::~SmartBitmap() {
if (bitmap_) {
bitmap_free(bitmap_);
}
}
MY_BITMAP *SmartBitmap::get() {
return bitmap_;
}
MY_BITMAP *SmartBitmap::release() {
MY_BITMAP *bitmap = bitmap_;
bitmap_ = NULL;
return bitmap;
}
}
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2017 Kouhei Sutou <kou@clear-code.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
*/
#pragma once
#include <mrn_mysql.h>
#include <my_bitmap.h>
namespace mrn {
class SmartBitmap {
public:
SmartBitmap(MY_BITMAP *bitmap);
~SmartBitmap();
MY_BITMAP *get();
MY_BITMAP *release();
private:
MY_BITMAP *bitmap_;
};
}
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2017 Kouhei Sutou <kou@clear-code.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
*/
#include "mrn_table_fields_offset_mover.hpp"
namespace mrn {
TableFieldsOffsetMover::TableFieldsOffsetMover(TABLE *table,
my_ptrdiff_t diff)
: table_(table),
diff_(diff) {
uint n_columns = table_->s->fields;
for (uint i = 0; i < n_columns; ++i) {
Field *field = table_->field[i];
field->move_field_offset(diff_);
}
}
TableFieldsOffsetMover::~TableFieldsOffsetMover() {
uint n_columns = table_->s->fields;
for (uint i = 0; i < n_columns; ++i) {
Field *field = table_->field[i];
field->move_field_offset(-diff_);
}
}
}
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2017 Kouhei Sutou <kou@clear-code.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
*/
#pragma once
#include <mrn_mysql.h>
namespace mrn {
class TableFieldsOffsetMover {
public:
TableFieldsOffsetMover(TABLE *table, my_ptrdiff_t diff);
~TableFieldsOffsetMover();
private:
TABLE *table_;
my_ptrdiff_t diff_;
};
}
......@@ -39,5 +39,8 @@
#define ER_MRN_INVALID_INDEX_FLAG_NUM 16508
#define ER_MRN_INVALID_INDEX_FLAG_STR \
"The index flag '%-.64s' is invalid. It is ignored"
#define ER_MRN_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN_NUM 16509
#define ER_MRN_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN_STR \
"Index for virtual generated column is not supported: %s"
#endif /* MRN_ERR_H_ */
......@@ -43,21 +43,18 @@
#define MYSQL_SERVER 1
#include <mysql_version.h>
#if MYSQL_VERSION_ID < 50500
# include <mysql_priv.h>
# include <mysql/plugin.h>
#else
# include <sql_const.h>
# include <sql_class.h>
# include <probes_mysql.h>
# include <sql_partition.h>
#endif
#include <rpl_filter.h>
#ifdef MARIADB_BASE_VERSION
# define MRN_MARIADB_P 1
#endif
#include <sql_const.h>
#include <sql_class.h>
#if (!defined(MRN_MARIADB_P) && MYSQL_VERSION_ID < 80002)
# include <probes_mysql.h>
#endif
#include <sql_partition.h>
#include <rpl_filter.h>
#define MRN_MESSAGE_BUFFER_SIZE 1024
#define MRN_DBUG_ENTER_FUNCTION() DBUG_ENTER(__FUNCTION__)
......
This diff is collapsed.
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2011-2013 Kentoku SHIBA
Copyright(C) 2011-2015 Kouhei Sutou <kou@clear-code.com>
Copyright(C) 2011-2017 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -202,7 +202,6 @@ void mrn_get_partition_info(const char *table_name, uint table_name_length,
const TABLE *table, partition_element **part_elem,
partition_element **sub_elem)
{
char tmp_name[FN_REFLEN + 1];
partition_info *part_info = table->part_info;
partition_element *tmp_part_elem = NULL, *tmp_sub_elem = NULL;
bool tmp_flg = FALSE, tmp_find_flg = FALSE;
......@@ -224,18 +223,24 @@ void mrn_get_partition_info(const char *table_name, uint table_name_length,
List_iterator<partition_element> sub_it((*part_elem)->subpartitions);
while ((*sub_elem = sub_it++))
{
if (create_subpartition_name(tmp_name, sizeof(tmp_name), table->s->path.str,
(*part_elem)->partition_name, (*sub_elem)->partition_name,
NORMAL_PART_NAME))
char subpartition_name[FN_REFLEN + 1];
int error = mrn_create_subpartition_name(subpartition_name,
sizeof(subpartition_name),
table->s->path.str,
(*part_elem)->partition_name,
(*sub_elem)->partition_name,
NORMAL_PART_NAME);
if (error != 0)
DBUG_VOID_RETURN;
DBUG_PRINT("info", ("mroonga tmp_name=%s", tmp_name));
if (table_name && !memcmp(table_name, tmp_name, table_name_length + 1))
DBUG_PRINT("info", ("mroonga subpartition name=%s", subpartition_name));
if (table_name &&
memcmp(table_name, subpartition_name, table_name_length + 1) == 0)
DBUG_VOID_RETURN;
if (
tmp_flg &&
table_name &&
*(tmp_name + table_name_length - 5) == '\0' &&
!memcmp(table_name, tmp_name, table_name_length - 5)
*(subpartition_name + table_name_length - 5) == '\0' &&
memcmp(table_name, subpartition_name, table_name_length - 5) == 0
) {
tmp_part_elem = *part_elem;
tmp_sub_elem = *sub_elem;
......@@ -244,17 +249,24 @@ void mrn_get_partition_info(const char *table_name, uint table_name_length,
}
}
} else {
if (create_partition_name(tmp_name, sizeof(tmp_name), table->s->path.str,
(*part_elem)->partition_name, NORMAL_PART_NAME, TRUE))
char partition_name[FN_REFLEN + 1];
int error = mrn_create_partition_name(partition_name,
sizeof(partition_name),
table->s->path.str,
(*part_elem)->partition_name,
NORMAL_PART_NAME,
TRUE);
if (error != 0)
DBUG_VOID_RETURN;
DBUG_PRINT("info", ("mroonga tmp_name=%s", tmp_name));
if (table_name && !memcmp(table_name, tmp_name, table_name_length + 1))
DBUG_PRINT("info", ("mroonga partition name=%s", partition_name));
if (table_name &&
memcmp(table_name, partition_name, table_name_length + 1) == 0)
DBUG_VOID_RETURN;
if (
tmp_flg &&
table_name &&
*(tmp_name + table_name_length - 5) == '\0' &&
!memcmp(table_name, tmp_name, table_name_length - 5)
*(partition_name + table_name_length - 5) == '\0' &&
memcmp(table_name, partition_name, table_name_length - 5) == 0
) {
tmp_part_elem = *part_elem;
tmp_flg = FALSE;
......@@ -518,6 +530,7 @@ int mrn_add_index_param(MRN_SHARE *share, KEY *key_info, int i)
char *sprit_ptr[2];
char *tmp_ptr, *start_ptr;
#endif
THD *thd = current_thd;
MRN_DBUG_ENTER_FUNCTION();
#if MYSQL_VERSION_ID >= 50500
......@@ -580,6 +593,10 @@ int mrn_add_index_param(MRN_SHARE *share, KEY *key_info, int i)
MRN_PARAM_STR_LIST("table", index_table, i);
break;
case 6:
push_warning_printf(thd, MRN_SEVERITY_WARNING,
ER_WARN_DEPRECATED_SYNTAX,
ER(ER_WARN_DEPRECATED_SYNTAX),
"parser", "tokenizer");
MRN_PARAM_STR_LIST("parser", key_tokenizer, i);
break;
case 9:
......@@ -1000,29 +1017,34 @@ int mrn_free_share(MRN_SHARE *share)
TABLE_SHARE *mrn_get_table_share(TABLE_LIST *table_list, int *error)
{
uint key_length;
TABLE_SHARE *share;
THD *thd = current_thd;
MRN_DBUG_ENTER_FUNCTION();
#ifdef MRN_HAVE_GET_TABLE_DEF_KEY
#if defined(MRN_HAVE_TDC_ACQUIRE_SHARE) && \
!defined(MRN_TDC_ACQUIRE_SHARE_REQUIRE_KEY)
share = tdc_acquire_share(thd, table_list, GTS_TABLE);
#else
uint key_length;
# ifdef MRN_HAVE_GET_TABLE_DEF_KEY
const char *key;
key_length = get_table_def_key(table_list, &key);
#else
# else
char key[MAX_DBKEY_LENGTH];
key_length = create_table_def_key(thd, key, table_list, FALSE);
#endif
#ifdef MRN_HAVE_TABLE_DEF_CACHE
# endif
# ifdef MRN_HAVE_TABLE_DEF_CACHE
my_hash_value_type hash_value;
hash_value = my_calc_hash(mrn_table_def_cache, (uchar*) key, key_length);
share = get_table_share(thd, table_list, key, key_length, 0, error,
hash_value);
#elif defined(MRN_HAVE_TDC_ACQUIRE_SHARE)
# elif defined(MRN_HAVE_TDC_ACQUIRE_SHARE)
share = tdc_acquire_share(thd, table_list->db, table_list->table_name, key,
key_length,
table_list->mdl_request.key.tc_hash_value(),
GTS_TABLE, NULL);
#else
# else
share = get_table_share(thd, table_list, key, key_length, 0, error);
# endif
#endif
DBUG_RETURN(share);
}
......@@ -1053,7 +1075,7 @@ TABLE_SHARE *mrn_create_tmp_table_share(TABLE_LIST *table_list, const char *path
*error = ER_CANT_OPEN_FILE;
DBUG_RETURN(NULL);
}
share->tmp_table = INTERNAL_TMP_TABLE; // TODO: is this right?
share->tmp_table = NO_TMP_TABLE; // TODO: is this right?
share->path.str = (char *) path;
share->path.length = strlen(share->path.str);
share->normalized_path.str = mrn_my_strdup(path, MYF(MY_WME));
......
......@@ -26,4 +26,28 @@
extern PSI_memory_key mrn_memory_key;
#endif
namespace mrn {
namespace variables {
enum BooleanModeSyntaxFlag {
BOOLEAN_MODE_SYNTAX_FLAG_DEFAULT = (1 << 0),
BOOLEAN_MODE_SYNTAX_FLAG_SYNTAX_QUERY = (1 << 1),
BOOLEAN_MODE_SYNTAX_FLAG_SYNTAX_SCRIPT = (1 << 2),
BOOLEAN_MODE_SYNTAX_FLAG_ALLOW_COLUMN = (1 << 3),
BOOLEAN_MODE_SYNTAX_FLAG_ALLOW_UPDATE = (1 << 4),
BOOLEAN_MODE_SYNTAX_FLAG_ALLOW_LEADING_NOT = (1 << 5)
};
ulonglong get_boolean_mode_syntax_flags(THD *thd);
enum ActionOnError {
ACTION_ON_ERROR_ERROR,
ACTION_ON_ERROR_ERROR_AND_LOG,
ACTION_ON_ERROR_IGNORE,
ACTION_ON_ERROR_IGNORE_AND_LOG,
};
ActionOnError get_action_on_fulltext_query_error(THD *thd);
}
}
#endif /* MRN_VARIABLES_HPP_ */
......@@ -12,14 +12,11 @@
#
# 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 02111-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
disable_query_log;
disable_warnings;
let $VERSION_COMPILE_64BIT=
`SELECT IF(@@version_compile_machine like '%64%', 1, 0)`;
let $version_compile_64bit=
`SELECT IF(@@version_compile_machine LIKE '%64%', 1, 0)`;
enable_warnings;
enable_query_log;
if (!$VERSION_COMPILE_64BIT) {
skip Need a 64 binary;
}
......@@ -12,8 +12,9 @@
#
# 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 02111-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--disable_query_log
let $VERSION_COMPILE_OS_FREEBSD=`SELECT IF(@@version_compile_os like 'FREEBSD%', 1, 0);`;
let $version_compile_os_freebsd=
`SELECT IF(@@version_compile_os LIKE '%freebsd%', 1, 0);`;
--enable_query_log
......@@ -12,7 +12,7 @@
#
# 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 02111-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--source ../../include/mroonga/check_windows.inc
......
......@@ -12,7 +12,7 @@
#
# 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 02111-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--disable_query_log
let $libgroonga_embedded = `SELECT @@mroonga_libgroonga_embedded;`;
......
......@@ -12,7 +12,7 @@
#
# 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 02111-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--disable_query_log
let $libgroonga_support_lz4 =
......
......@@ -12,7 +12,7 @@
#
# 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 02111-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--disable_query_log
let $libgroonga_support_zlib =
......
# 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
......@@ -12,7 +12,7 @@
#
# 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 02111-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--disable_query_log
let $mariadb = `SELECT LOCATE('MariaDB', @@global.version) > 0`;
......
# Copyright(C) 2014 Toshihisa Tashiro
# Copyright(C) 2016 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
......@@ -12,8 +13,19 @@
#
# 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 02111-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--disable_query_log
let $VERSION_COMPILE_OS_OSX=`SELECT IF(@@version_compile_os like 'osx%', 1, 0);`;
let $version_compile_os_osx=`SELECT IF(@@version_compile_os like 'osx%', 1, 0);`;
if ($version_compile_os_osx) {
let $version_compile_os_osx_10_8_or_later=
`SELECT IF(@@version_compile_os = 'osx10.6', 0, 1);`;
if ($version_compile_os_osx_10_8_or_later) {
let $version_compile_os_osx_10_8_or_later=
`SELECT IF(@@version_compile_os = 'osx10.7', 0, 1);`;
}
}
if (!$version_comiple_os_osx) {
let $version_compile_os_osx_10_8_or_later=0;
}
--enable_query_log
# Copyright(C) 2016 Kouhei Sutou <kou@clear-code.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 $version_compile_os_solaris=
`SELECT IF(@@version_compile_os LIKE 'sun-solaris%', 1, 0);`;
--enable_query_log
# Copyright(C) 2017 Kouhei Sutou <kou@clear-code.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 $strict_sql_mode =
`SELECT @@sql_mode LIKE '%STRICT_TRANS_TABLES%' OR
@@sql_mode LIKE '%STRICT_ALL_TABLES%'`;
--enable_query_log
# Copyright(C) 2012-2015 Kouhei Sutou <kou@clear-code.com>
# Copyright(C) 2012-2017 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
......@@ -12,19 +12,22 @@
#
# 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 02111-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--disable_query_log
let $version_major_minor =
`SELECT CAST(SUBSTRING_INDEX(@@global.version, '.', 2) AS DECIMAL(4, 2))`;
let $version_55 = `SELECT $version_major_minor = 5.5`;
let $version_56 = `SELECT $version_major_minor = 5.6`;
let $version_57 = `SELECT $version_major_minor = 5.7`;
let $version_100 = `SELECT $version_major_minor = 10.0`;
let $version_5_5 = `SELECT $version_major_minor = 5.5`;
let $version_5_6 = `SELECT $version_major_minor = 5.6`;
let $version_5_7 = `SELECT $version_major_minor = 5.7`;
let $version_10_0 = `SELECT $version_major_minor = 10.0`;
let $version_10_1 = `SELECT $version_major_minor = 10.1`;
let $version_10_2 = `SELECT $version_major_minor = 10.2`;
let $version_55_or_later = `SELECT $version_major_minor >= 5.5`;
let $version_56_or_later = `SELECT $version_major_minor >= 5.6`;
let $version_57_or_later = `SELECT $version_major_minor >= 5.7`;
let $version_100_or_later = `SELECT $version_major_minor >= 10.0`;
let $version_5_5_or_later = `SELECT $version_major_minor >= 5.5`;
let $version_5_6_or_later = `SELECT $version_major_minor >= 5.6`;
let $version_5_7_or_later = `SELECT $version_major_minor >= 5.7`;
let $version_10_0_or_later = `SELECT $version_major_minor >= 10.0`;
let $version_10_2_or_later = `SELECT $version_major_minor >= 10.2`;
--enable_query_log
......@@ -13,7 +13,7 @@
#
# 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 02111-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--disable_query_log
let $VERSION_COMPILE_OS_WIN=`SELECT IF(@@version_compile_os like 'Win%', 1, 0)`;
......
# Copyright(C) 2013 Kentoku SHIBA
# Copyright(C) 2014 Toshihisa Tashiro
#
# 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 02111-1301 USA
--source ../../include/mroonga/skip_osx.inc
disable_query_log;
disable_warnings;
let $VERSION_COMPILE_64BIT=
`SELECT IF(@@version_compile_machine like '%64%', 1, 0)`;
enable_warnings;
enable_query_log;
if ($VERSION_COMPILE_64BIT) {
skip Need a 32 bit machine/binary;
}
......@@ -12,7 +12,7 @@
#
# 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 02111-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--source ../../include/mroonga/check_mariadb.inc
--source ../../include/mroonga/check_version.inc
......@@ -22,11 +22,11 @@ if ($mariadb) {
}
if (!$mariadb) {
if ($version_56) {
if ($version_5_6) {
let $fractional_seconds = `SELECT @@global.version >= '5.6'`;
}
}
if (!$fractional_seconds) {
skip fractional seconds in time values are available in MySQL version 5.6 or later or MariaDB;
--skip fractional seconds in time values are available in MySQL version 5.6 or later or MariaDB
}
......@@ -12,10 +12,10 @@
#
# 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 02111-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--source ../../include/mroonga/check_freebsd.inc
if (!$VERSION_COMPILE_OS_FREEBSD) {
skip Need OS FreeBSD;
if (!$version_compile_os_freebsd) {
--skip Need OS FreeBSD
}
......@@ -12,11 +12,11 @@
#
# 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 02111-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--source ../../include/mroonga/check_libgroonga_embedded.inc
if ($libgroonga_embedded) {
--source ../../include/mroonga/have_mroonga_deinit.inc
skip "This test requires plugin_register of Groonga. libgroonga embedded build doesn't support it.";
--skip This test requires plugin_register of Groonga. libgroonga embedded build doesn't support it.
}
......@@ -12,10 +12,10 @@
#
# 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 02111-1301 USA
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
--source ../../include/mroonga/check_mariadb.inc
if (!$mariadb) {
skip This test is for MariaDB;
--skip This test is for MariaDB
}
# Copyright(C) 2017 Kouhei Sutou <kou@clear-code.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_version.inc
--source ../../include/mroonga/check_mariadb.inc
if (!$mariadb) {
--skip This test is for MariaDB version 10.2.x or later
}
if (!$version_10_2_or_later) {
--skip This test is for MariaDB version 10.2.x or later
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment