1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Update Mroonga to the latest version on 2014-09-21T00:33:44+0900

This commit is contained in:
Kentoku SHIBA
2014-09-21 00:33:45 +09:00
parent 989dd4d9ec
commit 0cc855cdc8
2027 changed files with 460307 additions and 0 deletions

View File

@@ -1455,6 +1455,18 @@ storage/tokudb/ft-index/utils/tokudb_gen
storage/tokudb/ft-index/utils/tokudb_load
storage/connect/connect.cnf
storage/cassandra/cassandra.cnf
storage/mroonga/config.sh
storage/mroonga/mrn_version.h
storage/mroonga/data/install.sql
storage/mroonga/vendor/groonga/config.sh
storage/mroonga/vendor/groonga/groonga.pc
storage/mroonga/vendor/groonga/version.sh
storage/mroonga/vendor/groonga/src/grnslap
storage/mroonga/vendor/groonga/src/groonga
storage/mroonga/vendor/groonga/src/groonga-benchmark
storage/mroonga/vendor/groonga/src/suggest/groonga-suggest-create-dataset
storage/mroonga/vendor/groonga/vendor/plugins/groonga-normalizer-mysql/groonga-normalizer-mysql.pc
libmysql/libmysql.version
libmysql/libmysql_versions.ld
scripts/mysql_config.pl
pcre/pcre_chartables.c

View File

@@ -1269,3 +1269,16 @@
fun:__tls_get_addr
}
{
Mroonga: dlopen leaves some "still reachable"
Memcheck:Leak
fun:malloc
...
fun:dl_open_worker
fun:_dl_catch_error
fun:_dl_open
fun:dlopen_doit
fun:_dl_catch_error
fun:_dlerror_run
fun:dlopen@@GLIBC_2.2.5
}

7
storage/mroonga/AUTHORS Normal file
View File

@@ -0,0 +1,7 @@
Active developers:
* Kentoku SHIBA
* Kouhei Sutou
Inactive developers:
* Tetsuro IKEDA: The original author: Active
* Yoshinori Matsunobu: The original author of information schema

View File

@@ -0,0 +1,380 @@
# -*- indent-tabs-mode: nil -*-
#
# Copyright(C) 2012-2014 Kouhei Sutou <kou@clear-code.com>
# Copyright(C) 2013 Kentoku SHIBA
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
cmake_minimum_required(VERSION 2.6)
project(mroonga)
if(MSVC)
if(MSVC_VERSION LESS 1600)
message(STATUS "Mroonga supports only MSVC 2010 or later")
return()
endif()
endif()
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
set(MRN_BUNDLED FALSE)
else()
set(MRN_BUNDLED TRUE)
endif()
set(MRN_BUNDLED_GROONGA_RELATIVE_DIR "vendor/groonga")
set(MRN_BUNDLED_GROONGA_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/${MRN_BUNDLED_GROONGA_RELATIVE_DIR}")
if(EXISTS "${MRN_BUNDLED_GROONGA_DIR}")
set(MRN_GROONGA_BUNDLED TRUE)
else()
set(MRN_GROONGA_BUNDLED FALSE)
if(MSVC)
message(STATUS "Bundled Mroonga does not support MSVC yet")
return()
endif()
endif()
set(MRN_PLUGIN_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
if(MRN_BUNDLED)
set(MRN_SOURCE_DIR ${CMAKE_SOURCE_DIR}/storage/mroonga)
else()
set(MRN_SOURCE_DIR ${CMAKE_SOURCE_DIR})
endif()
file(READ ${MRN_SOURCE_DIR}/version MRN_VERSION)
file(READ ${MRN_SOURCE_DIR}/version_major MRN_VERSION_MAJOR)
file(READ ${MRN_SOURCE_DIR}/version_minor MRN_VERSION_MINOR)
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)
add_subdirectory("${MRN_BUNDLED_GROONGA_RELATIVE_DIR}")
else()
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)
include(CheckCXXCompilerFlag)
include(${MRN_SOURCE_DIR}/build/cmake_modules/ReadFileList.cmake)
set(MRN_C_COMPILE_FLAGS "")
set(MRN_CXX_COMPILE_FLAGS "")
macro(mrn_check_cflag flag)
set(checking_message "checking for C flag '${flag}'")
check_c_compiler_flag(${flag} is_available)
if(${is_available})
message(STATUS "${checking_message} - available")
set(MRN_C_COMPILE_FLAGS "${MRN_C_COMPILE_FLAGS} ${flag}")
else()
message(STATUS "${checking_message} - not available")
endif()
endmacro()
macro(mrn_check_cxxflag flag)
set(checking_message "checking for CXX flag '${flag}'")
check_cxx_compiler_flag(${flag} is_available)
if(${is_available})
message(STATUS "${checking_message} - available")
set(MRN_CXX_COMPILE_FLAGS "${MRN_CXX_COMPILE_FLAGS} ${flag}")
else()
message(STATUS "${checking_message} - not available")
endif()
endmacro()
macro(mrn_build_flag flag)
mrn_check_cflag(${flag})
mrn_check_cxxflag(${flag})
endmacro()
if(MRN_BUNDLED)
set(MRN_RELATIVE_DIR_PREFIX "${MRN_SOURCE_DIR}/")
else()
set(MRN_RELATIVE_DIR_PREFIX "")
endif()
read_file_list(${CMAKE_CURRENT_SOURCE_DIR}/sources.am MROONGA_SOURCES)
read_file_list(${CMAKE_CURRENT_SOURCE_DIR}/lib/libmrn_no_mysql_sources.am
LIBMRN_NO_MYSQL_SOURCES)
string(REGEX REPLACE "([^;]+)" "${MRN_RELATIVE_DIR_PREFIX}lib/\\1"
LIBMRN_NO_MYSQL_SOURCES "${LIBMRN_NO_MYSQL_SOURCES}")
read_file_list(${CMAKE_CURRENT_SOURCE_DIR}/lib/libmrn_need_mysql_sources.am
LIBMRN_NEED_MYSQL_SOURCES)
string(REGEX REPLACE "([^;]+)" "${MRN_RELATIVE_DIR_PREFIX}lib/\\1"
LIBMRN_NEED_MYSQL_SOURCES "${LIBMRN_NEED_MYSQL_SOURCES}")
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}")
if(MRN_BUNDLED)
set(MYSQL_SOURCE_DIR ${CMAKE_SOURCE_DIR})
set(MYSQL_BUILD_DIR ${MYSQL_SOURCE_DIR})
set(MYSQL_CONFIG ${CMAKE_SOURCE_DIR}/scripts/mysql_config)
else()
set(MYSQL_SOURCE_DIR "/PATH/TO/MYSQL/SOURCE/DIRECTORY/"
CACHE PATH "MySQL source directory")
if(NOT EXISTS ${MYSQL_SOURCE_DIR})
message(FATAL_ERROR
"MySQL source directory (MYSQL_SOURCE_DIR) doesn't exist: <${MYSQL_SOURCE_DIR}>")
endif()
set(MYSQL_BUILD_DIR ${MYSQL_SOURCE_DIR} CACHE PATH "MySQL build directory")
set(MYSQL_CONFIG "mysql_config" CACHE PATH "mysql-config command path")
endif()
find_path(MYSQL_CONFIG "${MYSQL_CONFIG}")
if(EXISTS "${MYSQL_SOURCE_DIR}/pcre")
set(MYSQL_REGEX_INCLUDE_DIR "${MYSQL_SOURCE_DIR}/pcre")
else()
set(MYSQL_REGEX_INCLUDE_DIR "${MYSQL_SOURCE_DIR}/regex")
endif()
set(MYSQL_INCLUDE_DIRS
"${MYSQL_BUILD_DIR}/include"
"${MYSQL_SOURCE_DIR}/sql"
"${MYSQL_SOURCE_DIR}/include"
"${MYSQL_REGEX_INCLUDE_DIR}"
"${MYSQL_SOURCE_DIR}"
CACHE INTERNAL "MySQL include directories")
if(MRN_BUNDLED)
set(MYSQL_PLUGIN_DIR "${INSTALL_PLUGINDIR}")
set(MYSQL_SERVICES_LIB_DIR "${MYSQL_BUILD_DIR}/libservices")
set(MYSQL_CFLAGS "${CMAKE_C_FLAGS}")
set(MYSQL_VERSION "${MYSQL_BASE_VERSION}")
else()
macro(SET_MYSQL_CONFIG_VALUE OPTION VARIABLE)
if(NOT ${VARIABLE})
execute_process(COMMAND "${MYSQL_CONFIG}" ${OPTION}
OUTPUT_VARIABLE MYSQL_CONFIG_OUTPUT)
string(STRIP ${MYSQL_CONFIG_OUTPUT} ${VARIABLE})
endif()
endmacro()
set_mysql_config_value("--plugindir" MYSQL_PLUGIN_DIR)
set_mysql_config_value("--variable=pkglibdir" MYSQL_PKG_LIB_DIR)
set(MYSQL_BUILD_LIBSERVICES_DIR "${MYSQL_BUILD_DIR}/libservices")
if(EXISTS "${MYSQL_BUILD_LIBSERVICES_DIR}/libmysqlservices.a")
set(MYSQL_SERVICES_LIB_DIR "${MYSQL_BUILD_LIBSERVICES_DIR}")
else()
set(MYSQL_SERVICES_LIB_DIR "${MYSQL_PKG_LIB_DIR}")
endif()
set_mysql_config_value("--cflags" MYSQL_CFLAGS)
set_mysql_config_value("--version" MYSQL_VERSION)
endif()
if(${MYSQL_VERSION} VERSION_GREATER "10.0.0" AND
${MYSQL_VERSION} VERSION_LESS "10.0.9")
message(FATAL_ERROR
"Mroonga doesn't support MariaDB 10.0.0-10.0.8: <${MYSQL_VERSION}>")
return()
endif()
if(MRN_GROONGA_BUNDLED)
set(GROONGA_INCLUDE_DIRS "${MRN_BUNDLED_GROONGA_DIR}/include")
set(GROONGA_LIBRARY_DIRS "${MRN_BUNDLED_GROONGA_DIR}/lib")
set(GROONGA_LIBRARIES "libgroonga")
if(EXISTS "${MRN_BUNDLED_GROONGA_DIR}/vendor/plugins/groonga-normalizer-mysql")
set(GROONGA_NORMALIZER_MYSQL_FOUND TRUE)
else()
set(GROONGA_NORMALIZER_MYSQL_FOUND FALSE)
endif()
else()
include(FindPkgConfig)
pkg_check_modules(GROONGA REQUIRED "groonga >= ${REQUIRED_GROONGA_VERSION}")
pkg_check_modules(GROONGA_NORMALIZER_MYSQL
"groonga-normalizer-mysql >= ${REQUIRED_GROONGA_NORMALIZER_MYSQL_VERSION}")
endif()
if(GROONGA_NORMALIZER_MYSQL_FOUND AND MRN_GROONGA_BUNDLED)
read_file_list(${MRN_BUNDLED_GROONGA_DIR}/vendor/plugins/groonga-normalizer-mysql/normalizers/mysql_sources.am MRN_GRN_NORMALIZER_MYSQL_SOURCES)
string(REGEX REPLACE "([^;]+)" "${MRN_BUNDLED_GROONGA_DIR}/vendor/plugins/groonga-normalizer-mysql/normalizers/\\1"
MRN_GRN_NORMALIZER_MYSQL_SOURCES "${MRN_GRN_NORMALIZER_MYSQL_SOURCES}")
endif()
include_directories(
"${PROJECT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}/lib"
${MYSQL_INCLUDE_DIRS}
${GROONGA_INCLUDE_DIRS})
if(WIN32)
set(MYSQL_LIBRARY_DIRS
"${MYSQL_BUILD_DIR}/lib"
"${MYSQL_BUILD_DIR}/libmysqld")
else()
set(MYSQL_LIBRARY_DIRS
"${MYSQL_SERVICES_LIB_DIR}")
endif()
link_directories(
${GROONGA_LIBRARY_DIRS}
${MYSQL_LIBRARY_DIRS})
if(MRN_BUNDLED)
if(GROONGA_NORMALIZER_MYSQL_FOUND AND MRN_GROONGA_BUNDLED)
mysql_add_plugin(ha_mroonga
"${MROONGA_SOURCES};${MRN_UDF_SOURCES};${MRN_GRN_NORMALIZER_MYSQL_SOURCES};${LIBMRN_NEED_MYSQL_SOURCES};${LIBMRN_NO_MYSQL_SOURCES}"
STORAGE_ENGINE MODULE_ONLY
LINK_LIBRARIES ${GROONGA_LIBRARIES}
MODULE_OUTPUT_NAME "ha_mroonga")
else()
mysql_add_plugin(ha_mroonga
"${MROONGA_SOURCES};${MRN_UDF_SOURCES};${LIBMRN_NEED_MYSQL_SOURCES};${LIBMRN_NO_MYSQL_SOURCES}"
STORAGE_ENGINE MODULE_ONLY
LINK_LIBRARIES ${GROONGA_LIBRARIES}
MODULE_OUTPUT_NAME "ha_mroonga")
endif()
set(EXPANDED_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}")
list(FIND
CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
"${EXPANDED_INSTALL_LIBDIR}"
EXPANDED_INSTALL_LIBDIR_INDEX_IN_IMPLICIT_LINK_DIRECTORIES)
if(EXPANDED_INSTALL_LIBDIR_INDEX_IN_IMPLICIT_LINK_DIRECTORIES EQUAL -1)
set_property(TARGET ha_mroonga APPEND PROPERTY
INSTALL_RPATH "${EXPANDED_INSTALL_LIBDIR}")
endif()
else()
add_library(ha_mroonga MODULE
${MROONGA_SOURCES}
${MRN_UDF_SOURCES}
${LIBMRN_NO_MYSQL_SOURCES}
${LIBMRN_NEED_MYSQL_SOURCES})
set(MYSQL_LIBRARIES "mysqlservices")
target_link_libraries(ha_mroonga ${GROONGA_LIBRARIES} ${MYSQL_LIBRARIES})
option(WITH_DEBUG "Enable debug options" OFF)
if(WITH_DEBUG)
set_property(TARGET ha_mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "SAFE_MUTEX")
if(CMAKE_COMPILER_IS_GNUCXX)
set(MRN_C_COMPILE_FLAGS "${MRN_C_COMPILE_FLAGS} -g3 -O0")
set(MRN_CXX_COMPILE_FLAGS "${MRN_CXX_COMPILE_FLAGS} -g3 -O0")
endif()
else()
set_property(TARGET ha_mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "DBUG_OFF")
endif()
option(WITH_DEBUG_FULL "Enable full debug options" OFF)
if(WITH_DEBUG_FULL)
set_property(TARGET ha_mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "SAFE_MUTEX" "SAFEMALLOC")
endif()
option(DISABLE_FAST_MUTEXES "Force disabling fast mutex" OFF)
if(DISABLE_FAST_MUTEXES)
set_property(TARGET ha_mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "FORCE_FAST_MUTEX_DISABLED=1")
endif()
option(WITH_FAST_MUTEXES "Enable fast mutex" OFF)
if(WITH_FAST_MUTEXES)
set_property(TARGET ha_mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "MY_PTHREAD_FASTMUTEX")
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
mrn_build_flag("-Wall")
mrn_build_flag("-Wextra")
mrn_build_flag("-Wno-unused-parameter")
mrn_build_flag("-Wno-strict-aliasing")
mrn_build_flag("-Wno-deprecated")
mrn_check_cxxflag("-fno-implicit-templates")
mrn_check_cxxflag("-fno-exceptions")
mrn_check_cxxflag("-fno-rtti")
mrn_check_cxxflag("-felide-constructors")
endif()
set_source_files_properties(${MROONGA_SOURCES} PROPERTIES
COMPILE_FLAGS "${MYSQL_CFLAGS} ${MRN_CXX_COMPILE_FLAGS}")
set_source_files_properties(${LIBMRN_NEED_MYSQL_SOURCES} PROPERTIES
COMPILE_FLAGS "${MYSQL_CFLAGS} ${MRN_CXX_COMPILE_FLAGS}")
set_source_files_properties(${MRN_UDF_SOURCES} PROPERTIES
COMPILE_FLAGS "${MRN_C_COMPILE_FLAGS}")
set_source_files_properties(${LIBMRN_NO_MYSQL_SOURCES} PROPERTIES
COMPILE_FLAGS "${MRN_C_COMPILE_FLAGS}")
set_property(TARGET ha_mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "MYSQL_DYNAMIC_PLUGIN")
set_target_properties(ha_mroonga PROPERTIES
PREFIX ""
OUTPUT_NAME "ha_mroonga")
install(TARGETS ha_mroonga DESTINATION "${MYSQL_PLUGIN_DIR}")
endif()
if(GROONGA_NORMALIZER_MYSQL_FOUND)
set(WITH_GROONGA_NORMALIZER_MYSQL 1)
set_property(TARGET ha_mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "WITH_GROONGA_NORMALIZER_MYSQL=1")
if(MRN_GROONGA_BUNDLED)
set_property(TARGET ha_mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "GROONGA_NORMALIZER_MYSQL_PLUGIN_IS_BUNDLED_STATIC=1")
else()
set(GROONGA_NORMALIZER_MYSQL_PLUGIN_NAME \"normalizers/mysql\")
set_property(TARGET ha_mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "GROONGA_NORMALIZER_MYSQL_PLUGIN_NAME=\"normalizers/mysql\"")
endif()
endif()
set(DEFAULT_PARSER "TokenBigram" CACHE STRING "The default fulltext parser")
set_property(TARGET ha_mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "MRN_PARSER_DEFAULT=\"${DEFAULT_PARSER}\"")
configure_file(
"${PROJECT_SOURCE_DIR}/mrn_version.h.in"
"${PROJECT_BINARY_DIR}/mrn_version.h")
configure_file(
"${PROJECT_SOURCE_DIR}/config.sh.in"
"${PROJECT_BINARY_DIR}/config.sh")
set(MRN_TEST_SUITE_DIR "${CMAKE_SOURCE_DIR}/mysql-test/suite/mroonga")
if(NOT EXISTS "${MRN_TEST_SUITE_DIR}")
set(MRN_TEST_SUITE_DIR "${PROJECT_SOURCE_DIR}/mysql-test/mroonga")
endif()
configure_file(
"${MRN_TEST_SUITE_DIR}/storage/r/information_schema_plugins.result.in"
"${MRN_TEST_SUITE_DIR}/storage/r/information_schema_plugins.result"
NEWLINE_STYLE LF)
configure_file(
"${MRN_TEST_SUITE_DIR}/storage/r/variable_version.result.in"
"${MRN_TEST_SUITE_DIR}/storage/r/variable_version.result"
NEWLINE_STYLE LF)
configure_file(
"${PROJECT_SOURCE_DIR}/data/install.sql.in"
"${PROJECT_BINARY_DIR}/data/install.sql")
if(MRN_BUNDLED)
set(MRN_DATA_DIR "${INSTALL_MYSQLSHAREDIR}/${PROJECT_NAME}")
else()
set(MRN_DATA_DIR "share/${PROJECT_NAME}")
endif()
install(FILES
"${PROJECT_BINARY_DIR}/data/install.sql"
"${PROJECT_SOURCE_DIR}/data/uninstall.sql"
DESTINATION "${MRN_DATA_DIR}/")

View File

@@ -0,0 +1,3 @@
2009-01-27 Tetsuro IKEDA <ikdttr at gmail.com>
* initial import for development

157
storage/mroonga/Makefile.am Normal file
View File

@@ -0,0 +1,157 @@
AUTOMAKE_OPTIONS = 1.9.7
LOCALES = ja
AM_CPPFLAGS = $(MYSQL_INCLUDES) $(GROONGA_CFLAGS) -I$(top_srcdir)/lib
ACLOCAL_AMFLAGS = $$ACLOCAL_ARGS
include sources.am
libraries = \
$(top_builddir)/udf/libmrn_udf.la \
$(top_builddir)/lib/libmrn_no_mysql.la \
$(top_builddir)/lib/libmrn_need_mysql.la
if WITH_LIBMYSQLSERVICES_COMPAT
libraries += $(top_builddir)/lib/libmysqlservices.la
endif
dynamic_plugin_ldflags = -module $(GROONGA_LIBS) $(MYSQL_LIBS)
dynamic_plugin_cxxflags = $(AM_CXXFLAGS) $(MYSQL_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
dynamic_plugin_cflags = $(AM_CFLAGS) $(MYSQL_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
plugin_LTLIBRARIES = ha_mroonga.la
ha_mroonga_la_LDFLAGS = $(dynamic_plugin_ldflags)
ha_mroonga_la_CXXFLAGS = $(dynamic_plugin_cxxflags)
ha_mroonga_la_CFLAGS = $(dynamic_plugin_cflags)
ha_mroonga_la_SOURCES = $(sources)
ha_mroonga_la_LIBADD = $(libraries)
SUBDIRS = \
build \
lib \
udf \
test \
mysql-test \
doc \
tools \
packages \
data
EXTRA_DIST = \
AUTHORS \
gpg_uid \
plug.in \
CMakeLists.txt
installcheck-local: install
test/run-sql-test.sh
tag:
cd $(top_srcdir) && \
git tag v$(VERSION) -a -m 'Mroonga $(VERSION)!!!'
update-latest-release: misc
@if test -z "$(OLD_RELEASE)"; then \
echo "\$$(OLD_RELEASE) is missing"; \
exit 1; \
fi
@if test -z "$(OLD_RELEASE_DATE)"; then \
echo "\$$(OLD_RELEASE_DATE) is missing"; \
exit 1; \
fi
@if test -z "$(NEW_RELEASE_DATE)"; then \
echo "\$$(NEW_RELEASE_DATE) is missing"; \
exit 1; \
fi
cd $(top_srcdir) && \
misc/update-latest-release.rb \
$(PACKAGE) $(OLD_RELEASE) $(OLD_RELEASE_DATE) \
$(VERSION) $(NEW_RELEASE_DATE) \
packages/rpm/fedora/mysql-mroonga.spec.in \
packages/rpm/fedora/mariadb-mroonga.spec.in \
packages/rpm/centos/mariadb-mroonga.spec.in \
packages/rpm/centos/mysql55-mroonga.spec.in \
packages/rpm/centos/mysql56-community-mroonga.spec.in \
packages/debian/changelog \
doc/source/install/*.rst \
doc/locale/*/LC_MESSAGES/install.po \
$(MROONGA_GITHUB_COM_PATH)/index.html \
$(MROONGA_GITHUB_COM_PATH)/ja/index.html
update-po:
@for lang in $(LOCALES); do \
(cd $(top_srcdir)/doc/locale/$$lang/LC_MESSAGES && make update) \
done
update-document:
@if test -z "$(MROONGA_GITHUB_COM_PATH)"; then \
echo "\$$(MROONGA_GITHUB_COM_PATH) is missing"; \
echo "add --with-mroonga-github-com-path in configure"; \
exit 1; \
fi
rm -rf tmp-doc
mkdir tmp-doc
(cd doc && $(MAKE) clean-html)
(cd doc && $(MAKE) install docdir=$(abs_srcdir)/tmp-doc/install)
ruby $(srcdir)/tools/prepare-sphinx-html.rb tmp-doc/install tmp-doc/dist
rm -rf $(MROONGA_GITHUB_COM_PATH)/docs
mv tmp-doc/dist/en $(MROONGA_GITHUB_COM_PATH)/docs
for locale in `cd tmp-doc/dist; echo *`; do \
dest_base_dir=$(MROONGA_GITHUB_COM_PATH)/$${locale}; \
mkdir -p $${dest_base_dir}; \
dest_dir=$${dest_base_dir}/docs; \
rm -rf $${dest_dir}; \
mv tmp-doc/dist/$${locale} $${dest_dir}; \
done
update-files:
cd $(srcdir)/doc && $(MAKE) update-files
update-version:
@if test -z "$(NEW_VERSION_MAJOR)"; then \
echo "\$$(NEW_VERSION_MAJOR) is missing"; \
exit 1; \
fi
@if test -z "$(NEW_VERSION_MINOR)"; then \
echo "\$$(NEW_VERSION_MINOR) is missing"; \
exit 1; \
fi
@if test -z "$(NEW_VERSION_MICRO)"; then \
echo "\$$(NEW_VERSION_MICRO) is missing"; \
exit 1; \
fi
@echo -n $(NEW_VERSION_MAJOR) > $(srcdir)/version_major
@echo -n $(NEW_VERSION_MINOR) > $(srcdir)/version_minor
@echo -n $(NEW_VERSION_MICRO) > $(srcdir)/version_micro
@echo -n $(NEW_VERSION_MAJOR).$(NEW_VERSION_MINOR)$(NEW_VERSION_MICRO) \
> $(srcdir)/version
@if test $(NEW_VERSION_MINOR) -eq 0 ; then \
printf "0x%02x%02x" \
$(NEW_VERSION_MAJOR) $(NEW_VERSION_MICRO) \
> $(srcdir)/version_in_hex; \
printf "%d.%d" \
$(NEW_VERSION_MAJOR) $(NEW_VERSION_MICRO) \
> $(srcdir)/plugin_version; \
else \
printf "0x%02x%02x" \
$(NEW_VERSION_MAJOR) $(NEW_VERSION_MINOR)$(NEW_VERSION_MICRO) \
> $(srcdir)/version_in_hex; \
printf "%d.%d" \
$(NEW_VERSION_MAJOR) $(NEW_VERSION_MINOR)$(NEW_VERSION_MICRO) \
> $(srcdir)/plugin_version; \
fi
upload-to-github:
ruby $(srcdir)/tools/upload-to-github.rb \
$$USER $(PACKAGE)-$(VERSION).tar.gz
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

1
storage/mroonga/NEWS Normal file
View File

@@ -0,0 +1 @@
See doc/source/news.txt or http://mroonga.github.com/docs/news.html.

1
storage/mroonga/README Normal file
View File

@@ -0,0 +1 @@
See doc/locale/en/html/index.html or doc/locale/ja/html/index.html

116
storage/mroonga/autogen.sh Executable file
View File

@@ -0,0 +1,116 @@
#!/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
;;
FreeBSD)
ACLOCAL_ARGS="$ACLOCAL_ARGS -I /usr/local/share/aclocal/"
;;
esac
# 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

View File

@@ -0,0 +1,2 @@
SUBDIRS = \
cmake_modules

View File

@@ -0,0 +1,2 @@
EXTRA_DIST = \
ReadFileList.cmake

View File

@@ -0,0 +1,27 @@
# Copyright(C) 2012 Brazil
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1 as published by the Free Software Foundation.
#
# 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
macro(read_file_list file_name output_variable)
file(READ ${file_name} ${output_variable})
# Remove variable declaration at the first line:
# "libgroonga_la_SOURCES = \" -> ""
string(REGEX REPLACE "^.*=[ \t]*\\\\" ""
${output_variable} "${${output_variable}}")
# Remove white spaces: " com.c \\\n com.h \\\n" -> "com.c\\com.h"
string(REGEX REPLACE "[ \t\n]" "" ${output_variable} "${${output_variable}}")
# Convert string to list: "com.c\\com.h" -> "com.c;com.h"
# NOTE: List in CMake is ";" separated string.
string(REGEX REPLACE "\\\\" ";" ${output_variable} "${${output_variable}}")
endmacro()

View File

@@ -0,0 +1,5 @@
BUILT_SOURCES =
EXTRA_DIST =
SUFFIXES =
include $(top_srcdir)/build/makefiles/gettext.am

View File

@@ -0,0 +1,73 @@
include $(top_srcdir)/doc/files.am
include $(top_srcdir)/build/makefiles/sphinx-build.am
EXTRA_DIST += \
$(po_files)
if DOCUMENT_AVAILABLE
EXTRA_DIST += \
$(mo_files)
endif
if DOCUMENT_BUILDABLE
BUILT_SOURCES += \
pot-build-stamp \
edit-po-build-stamp \
$(mo_files)
endif
SUFFIXES += .pot .po .mo .edit
.PHONY: gettext update build
.pot.edit:
if test -f $*.po; then \
msgmerge \
--quiet \
--sort-by-file \
--output-file=$@.tmp \
$*.po \
$<; \
else \
msginit \
--input=$< \
--output-file=$@.tmp \
--locale=$(LOCALE) \
--no-translator; \
fi
(echo "# -*- po -*-"; \
GREP_OPTIONS= grep -v '^# -\*- po -\*-' $@.tmp | \
GREP_OPTIONS= grep -v '^"POT-Creation-Date:') > $@
rm $@.tmp
.edit.po:
msgcat --no-location --output $@ $<
.po.mo:
msgfmt -o $@ $<
if DOCUMENT_BUILDABLE
update: pot-build-stamp edit-po-build-stamp
build: update $(mo_files)
else
update:
build:
endif
html: build
man: build
pdf: build
gettext:
rm *.pot || true
$(SPHINX_BUILD_COMMAND) -d doctrees -b gettext $(ALLSPHINXOPTS) .
xgettext --language Python --output conf.pot \
$(top_srcdir)/doc/source/conf.py
pot-build-stamp: $(absolute_source_files)
$(MAKE) gettext
@touch $@
edit-po-build-stamp: $(absolute_source_files)
$(MAKE) $(edit_po_files)
@touch $@

View File

@@ -0,0 +1,12 @@
SUBDIRS = LC_MESSAGES
BUILT_SOURCES =
EXTRA_DIST =
include $(top_srcdir)/build/makefiles/sphinx.am
init:
cd LC_MESSAGES && $(MAKE) $@
update-po:
cd LC_MESSAGES && $(MAKE) update

View File

@@ -0,0 +1,19 @@
# You can set these variables from the command line.
DOCTREES_BASE = doctrees
SPHINXOPTS =
PAPER =
# Internal variables.
SOURCE_DIR = $(abs_top_srcdir)/doc/source
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)

View File

@@ -0,0 +1,179 @@
include $(top_srcdir)/doc/files.am
include $(top_srcdir)/build/makefiles/sphinx-build.am
$(html_files): html-build-stamp
$(html_files_relative_from_locale_dir): html-build-stamp
$(man_files): man-build-stamp
am__nobase_dist_doc_locale_DATA_DIST =
if DOCUMENT_AVAILABLE
doc_localedir = $(docdir)/$(LOCALE)
nobase_dist_doc_locale_DATA = \
$(html_files_relative_from_locale_dir)
am__nobase_dist_doc_locale_DATA_DIST += \
$(nobase_dist_doc_locale_DATA)
endif
document_source_files = \
$(absolute_source_files) \
$(absolute_theme_files) \
$(po_files_relative_from_locale_dir) \
$(mo_files_relative_from_locale_dir)
required_build_stamps = \
html-build-stamp \
man-build-stamp \
mo-build-stamp
if DOCUMENT_BUILDABLE
EXTRA_DIST += $(required_build_stamps)
endif
man_files = \
man/$(PACKAGE_NAME).1
generated_files = \
$(DOCTREES_BASE) \
man \
man-build-stamp \
html \
html-build-stamp \
pdf \
pdf-build-stamp \
dirhtml \
dirhtml-build-stamp \
pickle \
pikcle-build-stamp \
json \
json-build-stamp \
htmlhelp \
htmlhelp-build-stamp \
qthelp \
qthelp-build-stamp \
latex \
latex-build-stamp \
changes \
changes-build-stamp \
linkcheck \
linkcheck-build-stamp \
doctest
$(mo_files_relative_from_locale_dir): mo-build-stamp
mo-build-stamp: $(po_files_relative_from_locale_dir)
cd LC_MESSAGES && $(MAKE) build
@touch $@
if DOCUMENT_BUILDABLE
clean-local: $(clean_targets) clean-doctrees
clean-doctrees:
rm -rf $(DOCTREES_BASE)
maintainer-clean-local:
rm -rf -- $(generated_files)
endif
.PHONY: help
.PHONY: man clean-man
.PHONY: html clean-html
.PHONY: pdf
.PHONY: dirhtml
.PHONY: pickle
.PHONY: json
.PHONY: htmlhelp
.PHONY: qthelp
.PHONY: latex
.PHONY: changes
.PHONY: linkcheck
.PHONY: doctest
if DOCUMENT_BUILDABLE
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " man to make man files"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " rdoc to make RDoc files"
@echo " textile to make Textile files"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
man: man-build-stamp
html: html-build-stamp
dirhtml: dirhtml-build-stamp
pickle: pickle-build-stamp
json: json-build-stamp
htmlhelp: htmlhelp-build-stamp
qthelp: qthelp-build-stamp
latex: latex-build-stamp
rdoc: rdoc-build-stamp
textile: textile-build-stamp
changes: changes-build-stamp
linkcheck: linkcheck-build-stamp
doctest: doctest-build-stamp
clean_targets = \
clean-man \
clean-html \
clean-dirhtml \
clean-pickle \
clean-json \
clean-htmlhelp \
clean-qthelp \
clean-latex \
clean-rdoc \
clean-textile \
clean-changes \
clean-linkcheck \
clean-doctest
$(clean_targets):
target=`echo $@ | sed -e 's/^clean-//'`; \
rm -rf $${target}-build-stamp $${target}
build_stamps = \
man-build-stamp \
html-build-stamp \
dirhtml-build-stamp \
pickle-build-stamp \
json-build-stamp \
htmlhelp-build-stamp \
qthelp-build-stamp \
latex-build-stamp \
rdoc-build-stamp \
textile-build-stamp \
changes-build-stamp \
linkcheck-build-stamp \
doctest-build-stamp
$(build_stamps): $(document_source_files)
target=`echo $@ | sed -e 's/-build-stamp$$//'`; \
$(SPHINX_BUILD_COMMAND) \
-Dlanguage=$(LOCALE) \
-d $(DOCTREES_BASE)/$${target} \
-b $${target} \
$(ALLSPHINXOPTS) \
$${target}
@touch $@
qthelp: qthelp-message
qthelp-message: qthelp-build-stamp
@echo "Build finished; now you can run 'qcollectiongenerator' with the" \
".qhcp project file in qthelp/*, like this:"
@echo "# qcollectiongenerator qthelp/groonga.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile qthelp/groonga.qhc"
latex: latex-message
latex-message: latex-build-stamp
@echo "Build finished; the LaTeX files are in latex/*."
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
"run these through (pdf)latex."
endif

View File

@@ -0,0 +1,20 @@
# Copyright(C) 2012 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
MYSQL_SOURCE_DIR="@MYSQL_SOURCE_DIR@"
MYSQL_BUILD_DIR="@MYSQL_BUILD_DIR@"
MYSQL_VERSION="@MYSQL_VERSION@"
MRN_BUNDLED="@MRN_BUNDLED@"

View File

@@ -0,0 +1,492 @@
AC_PREREQ(2.59)
m4_define([mrn_version_major], m4_include(version_major))
m4_define([mrn_version_minor], m4_include(version_minor))
m4_define([mrn_version_micro], m4_include(version_micro))
m4_define([mrn_version], m4_include(version))
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_HEADERS([config.h])
AM_INIT_AUTOMAKE([tar-pax foreign subdir-objects])
MRN_VERSION=mrn_version
MRN_VERSION_MAJOR=mrn_version_major
MRN_VERSION_MINOR=mrn_version_minor
MRN_VERSION_MICRO=mrn_version_micro
MRN_VERSION_IN_HEX=mrn_version_in_hex
MRN_PLUGIN_VERSION=mrn_plugin_version
AC_SUBST([MRN_VERSION])
AC_SUBST([MRN_VERSION_MAJOR])
AC_SUBST([MRN_VERSION_MINOR])
AC_SUBST([MRN_VERSION_MICRO])
AC_SUBST([MRN_VERSION_IN_HEX])
AC_SUBST([MRN_PLUGIN_VERSION])
MRN_PACKAGE_STRING="$PACKAGE_STRING"
AC_SUBST([MRN_PACKAGE_STRING])
MRN_BUNDLED=FALSE
AC_SUBST([MRN_BUNDLED])
AC_C_BIGENDIAN
AC_PROG_CC
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_LIBTOOL
m4_ifdef([LT_OUTPUT], [LT_OUTPUT])
AC_DEFUN([CHECK_CFLAG], [
AC_MSG_CHECKING([if gcc supports $1])
old_CFLAGS=$CFLAGS
flag=`echo '$1' | sed -e 's,^-Wno-,-W,'`
CFLAGS="$CFLAGS $flag -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[check_cflag=yes],
[check_cflag=no])
CFLAGS="$old_CFLAGS"
if test "x$check_cflag" = "xyes"; then
CFLAGS="$CFLAGS $1"
fi
AC_MSG_RESULT([$check_cflag])
])
AC_DEFUN([CHECK_CXXFLAG], [
AC_MSG_CHECKING([if g++ supports $1])
old_CXXFLAGS=$CXXFLAGS
flag=`echo '$1' | sed -e 's,^-Wno-,-W,'`
CXXFLAGS="$CXXFLAGS $flag -Werror"
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[check_cxxflag=yes],
[check_cxxflag=no])
AC_LANG_POP([C++])
CXXFLAGS="$old_CXXFLAGS"
if test "x$check_cxxflag" = "xyes"; then
CXXFLAGS="$CXXFLAGS $1"
fi
AC_MSG_RESULT([$check_cxxflag])
])
AC_DEFUN([CHECK_BUILD_FLAG], [
CHECK_CFLAG([$1])
CHECK_CXXFLAG([$1])
])
if test "$GCC" = "yes"; then
CHECK_BUILD_FLAG([-Wall])
CHECK_BUILD_FLAG([-Wextra])
CHECK_BUILD_FLAG([-Wno-unused-parameter])
CHECK_BUILD_FLAG([-Wno-strict-aliasing])
# REMOVEME: workaround for MySQL/MariaDB 5.5.22 :<
# They use deprecated MYSQL::generate_name style in class definition.
CHECK_BUILD_FLAG([-Wno-deprecated])
fi
AC_MSG_CHECKING(for the suffix of plugin shared libraries)
shrext_cmds=$(./libtool --config | grep '^shrext_cmds=')
eval $shrext_cmds
module=yes eval MRN_PLUGIN_SUFFIX="$shrext_cmds"
AC_MSG_RESULT($MRN_PLUGIN_SUFFIX)
if test -z "$MRN_PLUGIN_SUFFIX"; then
AC_MSG_ERROR([can't detect plugin suffix])
fi
AC_SUBST(MRN_PLUGIN_SUFFIX)
AC_ARG_WITH(libmysqlservices-compat,
[AS_HELP_STRING([--with-libmysqlservices-compat],
[Use libmysqlservices compatible library for missing libmysqlservices.a])
],
[with_libmysqlservices_compat=$withval],
[with_libmysqlservices_compat=no])
AM_CONDITIONAL([WITH_LIBMYSQLSERVICES_COMPAT], [test "${with_libmysqlservices_compat}" != "no"])
AC_DEFUN([CONFIG_OPTION_MYSQL],[
AC_MSG_CHECKING([mysql source])
ac_mysql_source_dir=
AC_ARG_WITH([mysql-source],
[AS_HELP_STRING([--with-mysql-source=PATH], [MySQL source directory PATH])],
[
ac_mysql_source_dir="$withval"
if test -f "$ac_mysql_source_dir/sql/handler.h"; then
case "$ac_mysql_source_dir" in
/*)
:
;;
*)
ac_mysql_source_dir="$ac_pwd/$ac_mysql_source_dir"
;;
esac
AC_MSG_RESULT([yes])
else
AC_MSG_ERROR([invalid MySQL source directory])
fi
],
[AC_MSG_ERROR([--with-mysql-source=PATH is required])]
)
MYSQL_SOURCE_DIR="$ac_mysql_source_dir"
AC_SUBST(MYSQL_SOURCE_DIR)
ac_mysql_build_dir=
AC_ARG_WITH([mysql-build],
[AS_HELP_STRING([--with-mysql-build=PATH], [MySQL build directory PATH])],
[ac_mysql_build_dir="$withval"],
[ac_mysql_build_dir="$ac_mysql_source_dir"]
)
case "$ac_mysql_build_dir" in
/*)
:
;;
*)
ac_mysql_build_dir="$ac_pwd/$ac_mysql_build_dir"
;;
esac
MYSQL_BUILD_DIR="$ac_mysql_build_dir"
AC_SUBST(MYSQL_BUILD_DIR)
AC_MSG_CHECKING([mysql_config])
AC_ARG_WITH([mysql-config],
[AS_HELP_STRING([--with-mysql-config=PATH],
[mysql_config PATH])],
[ac_mysql_config="$withval"],
[ac_mysql_config=])
if test -z "$ac_mysql_config"; then
AC_PATH_PROG(ac_mysql_config, mysql_config, mysql-config-not-found)
fi
if test "$ac_mysql_config" = "mysql-config-not-found"; then
AC_MSG_ERROR([can't detect mysql_config. Please specify mysql_config path by --with-mysql-config=PATH.])
fi
AC_MSG_RESULT([$ac_mysql_config])
plugindir="$($ac_mysql_config --plugindir)"
if test $? -ne 0; then
AC_MSG_ERROR([failed to run "$ac_mysql_config": $plugindir])
fi
AC_SUBST(plugindir)
MYSQL_CFLAGS="$MYSQL_CFLAGS $($ac_mysql_config --cflags)"
AC_SUBST(MYSQL_CFLAGS)
MYSQL_INCLUDES=""
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_build_dir/include"
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_source_dir/sql"
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_source_dir/include"
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"
MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_source_dir"
MYSQL_INCLUDES="$MYSQL_INCLUDES $($ac_mysql_config --include)"
AC_SUBST(MYSQL_INCLUDES)
MYSQL_VERSION="$($ac_mysql_config --version)"
AC_SUBST(MYSQL_VERSION)
if test "${with_libmysqlservices_compat}" = "no"; then
MYSQL_MAJOR_MINOR_VERSION=["$(echo $MYSQL_VERSION | sed -e 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*[a-z]*\)$/\1.\2/')"]
case "$MYSQL_MAJOR_MINOR_VERSION" in
5.1)
MYSQL_LIBS=""
;;
*)
AC_MSG_CHECKING([for libmysqlservices.a directory])
pkglibdir="$($ac_mysql_config --variable=pkglibdir)"
mysql_build_libservices_dir="${MYSQL_BUILD_DIR}/libservices"
if test -f "${mysql_build_libservices_dir}/libmysqlservices.a"; then
mysql_services_lib_dir="${mysql_build_libservices_dir}"
else
if test -f "${pkglibdir}/libmysqlservices.a"; then
mysql_services_lib_dir="${pkglibdir}"
elif test -f "${pkglibdir}/mysql/libmysqlservices.a"; then
mysql_services_lib_dir="${pkglibdir}/mysql"
else
AC_MSG_ERROR([libmysqlservices.a is not found in <${pkglibdir}/> and <${pkglibdir}/mysql/>])
fi
fi
AC_MSG_RESULT([$mysql_services_lib_dir])
MYSQL_LIBS="$MYSQL_LIBS -L\"$mysql_services_lib_dir\" -lmysqlservices"
;;
esac
AC_SUBST(MYSQL_LIBS)
fi
])
m4_define([mrn_required_groonga_version], m4_include(required_groonga_version))
REQUIRED_GROONGA_VERSION=mrn_required_groonga_version
AC_SUBST(REQUIRED_GROONGA_VERSION)
AC_DEFUN([CONFIG_OPTION_GROONGA],[
PKG_CHECK_MODULES(GROONGA, groonga >= ${REQUIRED_GROONGA_VERSION})
_PKG_CONFIG(GROONGA_VERSION, variable=groonga_version, groonga)
GROONGA_VERSION=$pkg_cv_GROONGA_VERSION
AC_SUBST(GROONGA_VERSION)
])
m4_define([mrn_required_groonga_normalizer_mysql_version],
m4_include(required_groonga_normalizer_mysql_version))
REQUIRED_GROONGA_NORMALIZER_MYSQL_VERSION=mrn_required_groonga_normalizer_mysql_version
AC_DEFUN([CONFIG_OPTION_GROONGA_NORMALIZER_MYSQL], [
AC_MSG_CHECKING([for groonga-normalizer-mysql])
PKG_CHECK_EXISTS([groonga-normalizer-mysql >= ${REQUIRED_GROONGA_NORMALIZER_MYSQL_VERSION}],
[WITH_GROONGA_NORMALIZER_MYSQL=yes],
[WITH_GROONGA_NORMALIZER_MYSQL=no])
AC_MSG_RESULT($WITH_GROONGA_NORMALIZER_MYSQL)
if test "$WITH_GROONGA_NORMALIZER_MYSQL" = "yes"; then
AC_DEFINE([WITH_GROONGA_NORMALIZER_MYSQL],
[1],
[Use MySQL normalizer plugin for groonga])
_PKG_CONFIG(plugin_name, variable=plugin_name, groonga-normalizer-mysql)
GROONGA_NORMALIZER_MYSQL_PLUGIN_NAME=$pkg_cv_plugin_name
AC_DEFINE_UNQUOTED([GROONGA_NORMALIZER_MYSQL_PLUGIN_NAME],
"${GROONGA_NORMALIZER_MYSQL_PLUGIN_NAME}",
[Name of MySQL normalizer plugin for groonga])
fi
])
AC_ARG_WITH(debug,
[dnl
AS_HELP_STRING([--with-debug],
[Add debug code])
AS_HELP_STRING([--with-debug=full],
[Add debug code (adds memory checker, very slow)])dnl
],
[with_debug=$withval],
[with_debug=no])
if test "$with_debug" = "yes"
then
# Medium debug.
AC_DEFINE([DBUG_ON], [1], [Use libdbug])
CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC -DSAFE_MUTEX $CFLAGS -O0 -g3"
CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DSAFE_MUTEX $CXXFLAGS -O0 -g3"
elif test "$with_debug" = "full"
then
# Full debug. Very slow in some cases
AC_DEFINE([DBUG_ON], [1], [Use libdbug])
CFLAGS="$DEBUG_CFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS -O0 -g3"
CXXFLAGS="$DEBUG_CXXFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS -O0 -g3"
else
# Optimized version. No debug
AC_DEFINE([DBUG_OFF], [1], [Don't use libdbug])
CFLAGS="$OPTIMIZE_CFLAGS $CFLAGS"
CXXFLAGS="$OPTIMIZE_CXXFLAGS $CXXFLAGS"
fi
AC_ARG_WITH(valgrind,
[AS_HELP_STRING([--with-valgrind], [Use valgrind. [default=no]])],
[with_valgrind="$withval"],
[with_valgrind="no"])
if test "$with_valgrind" != "no"; then
CFLAGS="-DHAVE_valgrind $CFLAGS"
CXXFLAGS="-DHAVE_valgrind $CXXFLAGS"
fi
CONFIG_OPTION_MYSQL
CONFIG_OPTION_GROONGA
CONFIG_OPTION_GROONGA_NORMALIZER_MYSQL
AC_ARG_WITH(default_parser,
[AS_HELP_STRING([--with-default-parser=PARSER],
[specify the default fulltext parser like
--with-default-parser=TokenMecab.
(default: TokenBigram)])],
[default_parser=$withval],
[default_parser=no])
if test x"$default_parser" != x"no"; then
AC_DEFINE_UNQUOTED(MRN_PARSER_DEFAULT,
"$default_parser",
"specified default fulltext parser")
MRN_DEFAULT_PARSER=$default_parser
else
MRN_DEFAULT_PARSER=TokenBigram
fi
AC_SUBST(MRN_DEFAULT_PARSER)
AC_ARG_ENABLE(fast_mutexes,
[AS_HELP_STRING([--disable-fast-mutexes],
[Force disable fast mutex.
[default: use mysql_config output]])],
[enable_fast_mutexes=$enableval],
[enable_fast_mutexes=auto])
if test "$enable_fast_mutexes" = "no"; then
AC_DEFINE(FORCE_FAST_MUTEX_DISABLED, [1],
[Define to 1 if force fast mutexes disabled])
elif test "$enable_fast_mutexes" = "yes"; then
AC_DEFINE(MY_PTHREAD_FASTMUTEX, [1],
[Define to 1 if fast mutexes enabled])
fi
AC_ARG_ENABLE(dtrace,
[AS_HELP_STRING([--enable-dtrace],
[Enable DTrace. [default: no]])],
[enable_dtrace=$enableval],
[enable_dtrace=no])
if test "$enable_dtrace" = "no"; then
AC_DEFINE(DISABLE_DTRACE, [1], [Define to 1 if DTrace is disabled])
fi
# check Cutter with C++ support if available
REQUIRED_MINIMUM_CUTTER_VERSION=1.1.3
m4_ifdef([AC_CHECK_CPPCUTTER], [
AC_CHECK_CPPCUTTER(>= $REQUIRED_MINIMUM_CUTTER_VERSION)
],
[ac_cv_use_cutter="no"])
AM_CONDITIONAL([WITH_CUTTER], [test "$ac_cv_use_cutter" != "no"])
# For mroonga.github.com
AC_ARG_WITH(mroonga-github-com-path,
[AS_HELP_STRING([--with-mroonga-github-com-path=PATH],
[specify mroonga.github.com path to update mroonga.github.com.])],
[MROONGA_GITHUB_COM_PATH="$withval"],
[MROONGA_GITHUB_COM_PATH=""])
AC_SUBST(MROONGA_GITHUB_COM_PATH)
# For package
AC_ARG_WITH(rsync-path,
[AS_HELP_STRING([--with-rsync-path=PATH],
[specify rsync path to upload mroonga packages.])],
[RSYNC_PATH="$withval"],
[RSYNC_PATH="packages@packages.groonga.org:public"])
AC_SUBST(RSYNC_PATH)
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.])],
[LAUNCHPAD_UPLOADER_PGP_KEY="$withval"],
[LAUNCHPAD_UPLOADER_PGP_KEY=""])
AC_SUBST(LAUNCHPAD_UPLOADER_PGP_KEY)
GPG_UID=m4_include(gpg_uid)
AC_SUBST(GPG_UID)
# For update-version
AC_ARG_WITH(cutter-source-path,
[AS_HELP_STRING([--with-cutter-source-path=PATH],
[specify Cutter source path for mroonga's release manager.])],
[CUTTER_SOURCE_PATH="$withval"])
case "$CUTTER_SOURCE_PATH" in
""|/*)
: # do nothing
;;
*)
CUTTER_SOURCE_PATH="\$(top_builddir)/${CUTTER_SOURCE_PATH}"
;;
esac
AC_SUBST(CUTTER_SOURCE_PATH)
# Document
AC_MSG_CHECKING([whether enable document])
AC_ARG_ENABLE(document,
[AS_HELP_STRING([--enable-document],
[enable document generation by Sphinx. [default=auto]])],
[enable_document="$enableval"],
[enable_document="auto"])
AC_MSG_RESULT($enable_document)
document_available=no
document_buildable=no
have_built_document=no
if test x"$enable_document" != x"no"; then
if test -f "$srcdir/doc/build-stamp"; then
document_available=yes
have_built_document=yes
fi
if test x"$enable_document" = x"yes"; 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
AC_MSG_ERROR([
sphinx-build is old: $sphinx_build_version
Sphinx 1.2 or later is required.])
fi
document_available=yes
document_buildable=yes
else
AC_MSG_ERROR([
No sphinx-build found.
Install it and try again.
How to install sphinx-build:
For Debian GNU/Linux based system like Ubuntu:
% sudo apt-get install -y python-pip
% sudo pip install sphinx
For Red Hat based system like CentOS:
% sudo yum install -y python-pip
% sudo pip install sphinx])
fi
AC_SUBST(SPHINX_BUILD)
fi
fi
AM_CONDITIONAL([DOCUMENT_AVAILABLE],
[test "${document_available}" = "yes"])
AC_MSG_CHECKING([whether document available])
AC_MSG_RESULT($document_available)
AM_CONDITIONAL([DOCUMENT_BUILDABLE],
[test "${document_buildable}" = "yes"])
AC_MSG_CHECKING([whether document buildable])
AC_MSG_RESULT($document_buildable)
AM_CONDITIONAL([HAVE_BUILT_DOCUMENT],
[test "${have_built_document}" = "yes"])
AC_MSG_CHECKING([whether having built document])
AC_MSG_RESULT($have_built_document)
DOCUMENT_VERSION=mrn_version
DOCUMENT_VERSION_FULL="$DOCUMENT_VERSION"
AC_SUBST(DOCUMENT_VERSION)
AC_SUBST(DOCUMENT_VERSION_FULL)
CFLAGS="$CFLAGS"
CXXFLAGS="$CXXFLAGS -fno-implicit-templates -fno-exceptions -fno-rtti -felide-constructors"
AC_CONFIG_FILES([
Makefile
build/Makefile
build/cmake_modules/Makefile
lib/Makefile
udf/Makefile
test/Makefile
test/unit/Makefile
mysql-test/Makefile
packages/Makefile
packages/rpm/Makefile
packages/rpm/centos/Makefile
packages/rpm/fedora/Makefile
packages/yum/Makefile
packages/apt/Makefile
packages/source/Makefile
packages/ubuntu/Makefile
packages/windows/Makefile
tools/Makefile
doc/Makefile
doc/locale/Makefile
doc/locale/en/Makefile
doc/locale/en/LC_MESSAGES/Makefile
doc/locale/ja/Makefile
doc/locale/ja/LC_MESSAGES/Makefile
data/Makefile
])
AC_OUTPUT([
config.sh
mrn_version.h
mysql-test/mroonga/storage/information_schema/r/plugins.result
mysql-test/mroonga/storage/variable/r/version.result
packages/debian/control
packages/rpm/centos/mysql55-mroonga.spec
packages/rpm/centos/mysql56-community-mroonga.spec
packages/rpm/centos/mariadb-mroonga.spec
packages/rpm/fedora/mysql-mroonga.spec
packages/rpm/fedora/mariadb-mroonga.spec
packages/yum/env.sh
data/install.sql
])

View File

@@ -0,0 +1,4 @@
sqldir = $(pkgdatadir)
dist_sql_DATA = \
install.sql \
uninstall.sql

View File

@@ -0,0 +1,19 @@
DELETE IGNORE FROM mysql.plugin WHERE dl = 'ha_mroonga@MRN_PLUGIN_SUFFIX@';
INSTALL PLUGIN Mroonga SONAME 'ha_mroonga@MRN_PLUGIN_SUFFIX@';
DROP FUNCTION IF EXISTS last_insert_grn_id;
CREATE FUNCTION last_insert_grn_id RETURNS INTEGER
SONAME 'ha_mroonga@MRN_PLUGIN_SUFFIX@';
DROP FUNCTION IF EXISTS mroonga_snippet;
CREATE FUNCTION mroonga_snippet RETURNS STRING
SONAME 'ha_mroonga@MRN_PLUGIN_SUFFIX@';
DROP FUNCTION IF EXISTS mroonga_command;
CREATE FUNCTION mroonga_command RETURNS STRING
SONAME 'ha_mroonga@MRN_PLUGIN_SUFFIX@';
DROP FUNCTION IF EXISTS mroonga_escape;
CREATE FUNCTION mroonga_escape RETURNS STRING
SONAME 'ha_mroonga@MRN_PLUGIN_SUFFIX@';

View File

@@ -0,0 +1,8 @@
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;
UNINSTALL PLUGIN Mroonga;
FLUSH TABLES;

1
storage/mroonga/gpg_uid Normal file
View File

@@ -0,0 +1 @@
45499429

15536
storage/mroonga/ha_mroonga.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
LIBRARY ha_mroonga
VERSION 1.0
EXPORTS
last_insert_grn_id
last_insert_grn_id_init
last_insert_grn_id_deinit
mroonga_snippet
mroonga_snippet_init
mroonga_snippet_deinit
mroonga_command
mroonga_command_init
mroonga_command_deinit
mroonga_escape
mroonga_escape_init
mroonga_escape_deinit

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,23 @@
AM_CPPFLAGS = \
-I$(top_builddir) \
-I$(top_srcdir) \
$(MYSQL_INCLUDES) \
$(GROONGA_CFLAGS) \
$(MYSQL_VERSION_CFLAGS)
libmrn_need_mysql_la_CXXFLAGS = $(AM_CXXFLAGS) $(MYSQL_CFLAGS)
if WITH_LIBMYSQLSERVICES_COMPAT
LIBMYSQLSERVICES_COMPAT = libmysqlservices.la
endif
noinst_LTLIBRARIES = \
$(LIBMYSQLSERVICES_COMPAT) \
libmrn_no_mysql.la \
libmrn_need_mysql.la
include libmrn_no_mysql_sources.am
include libmrn_need_mysql_sources.am
if WITH_LIBMYSQLSERVICES_COMPAT
include libmysqlservices_compat_sources.am
endif

View File

@@ -0,0 +1,25 @@
libmrn_need_mysql_la_SOURCES = \
mrn_index_table_name.cpp \
mrn_index_table_name.hpp \
mrn_index_column_name.cpp \
mrn_index_column_name.hpp \
mrn_debug_column_access.cpp \
mrn_debug_column_access.hpp \
mrn_auto_increment_value_lock.cpp \
mrn_auto_increment_value_lock.hpp \
mrn_external_lock.cpp \
mrn_external_lock.hpp \
mrn_multiple_column_key_codec.cpp \
mrn_multiple_column_key_codec.hpp \
mrn_field_normalizer.cpp \
mrn_field_normalizer.hpp \
mrn_encoding.cpp \
mrn_encoding.hpp \
mrn_parameters_parser.cpp \
mrn_parameters_parser.hpp \
mrn_lock.cpp \
mrn_lock.hpp \
mrn_condition_converter.cpp \
mrn_condition_converter.hpp \
mrn_time_converter.cpp \
mrn_time_converter.hpp

View File

@@ -0,0 +1,8 @@
libmrn_no_mysql_la_SOURCES = \
mrn_match_escalation_threshold_scope.cpp \
mrn_match_escalation_threshold_scope.hpp \
mrn_path_mapper.cpp \
mrn_path_mapper.hpp \
mrn_windows.hpp \
mrn_smart_grn_obj.cpp \
mrn_smart_grn_obj.hpp

View File

@@ -0,0 +1,2 @@
libmysqlservices_la_SOURCES = \
mrn_mysqlservices.cpp

View File

@@ -0,0 +1,42 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2012 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_auto_increment_value_lock.hpp"
#if MYSQL_VERSION_ID >= 50500
# define AUTO_INCREMENT_VALUE_MUTEX(table_share) (&(table_share->LOCK_ha_data))
#else
# define AUTO_INCREMENT_VALUE_MUTEX(table_share) (&(table_share->mutex))
#endif
namespace mrn {
AutoIncrementValueLock::AutoIncrementValueLock(TABLE_SHARE *table_share)
: table_share_(table_share),
need_lock_(table_share_->tmp_table == NO_TMP_TABLE) {
if (need_lock_) {
mysql_mutex_lock(AUTO_INCREMENT_VALUE_MUTEX(table_share_));
}
}
AutoIncrementValueLock::~AutoIncrementValueLock() {
if (need_lock_) {
mysql_mutex_unlock(AUTO_INCREMENT_VALUE_MUTEX(table_share_));
}
}
}

View File

@@ -0,0 +1,36 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2012 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_AUTO_INCREMENT_VALUE_LOCK_HPP_
#define MRN_AUTO_INCREMENT_VALUE_LOCK_HPP_
#include <mrn_mysql.h>
#include <mrn_mysql_compat.h>
namespace mrn {
class AutoIncrementValueLock {
TABLE_SHARE *table_share_;
bool need_lock_;
public:
AutoIncrementValueLock(TABLE_SHARE *table_share);
~AutoIncrementValueLock();
};
}
#endif // MRN_AUTO_INCREMENT_VALUE_LOCK_HPP_

View File

@@ -0,0 +1,608 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2013-2014 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
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "mrn_condition_converter.hpp"
#include "mrn_time_converter.hpp"
#include "mrn_smart_grn_obj.hpp"
// for debug
#define MRN_CLASS_NAME "mrn::ConditionConverter"
#ifdef MRN_ITEM_HAVE_ITEM_NAME
# define MRN_ITEM_FIELD_GET_NAME(item) ((item)->item_name.ptr())
# define MRN_ITEM_FIELD_GET_NAME_LENGTH(item) ((item)->item_name.length())
#else
# define MRN_ITEM_FIELD_GET_NAME(item) ((item)->name)
# define MRN_ITEM_FIELD_GET_NAME_LENGTH(item) (strlen((item)->name))
#endif
namespace mrn {
ConditionConverter::ConditionConverter(grn_ctx *ctx, grn_obj *table,
bool is_storage_mode)
: ctx_(ctx),
table_(table),
is_storage_mode_(is_storage_mode) {
GRN_TEXT_INIT(&column_name_, 0);
GRN_VOID_INIT(&value_);
}
ConditionConverter::~ConditionConverter() {
grn_obj_unlink(ctx_, &column_name_);
grn_obj_unlink(ctx_, &value_);
}
bool ConditionConverter::is_convertable(const Item *item) {
MRN_DBUG_ENTER_METHOD();
if (!item) {
DBUG_RETURN(false);
}
switch (item->type()) {
case Item::COND_ITEM:
{
const Item_cond *cond_item = reinterpret_cast<const Item_cond *>(item);
bool convertable = is_convertable(cond_item);
DBUG_RETURN(convertable);
}
break;
case Item::FUNC_ITEM:
{
const Item_func *func_item = reinterpret_cast<const Item_func *>(item);
bool convertable = is_convertable(func_item);
DBUG_RETURN(convertable);
}
break;
default:
DBUG_RETURN(false);
break;
}
DBUG_RETURN(false);
}
bool ConditionConverter::is_convertable(const Item_cond *cond_item) {
MRN_DBUG_ENTER_METHOD();
if (!is_storage_mode_) {
DBUG_RETURN(false);
}
if (cond_item->functype() != Item_func::COND_AND_FUNC) {
DBUG_RETURN(false);
}
List<Item> *argument_list =
const_cast<Item_cond *>(cond_item)->argument_list();
List_iterator<Item> iterator(*argument_list);
const Item *sub_item;
while ((sub_item = iterator++)) {
if (!is_convertable(sub_item)) {
DBUG_RETURN(false);
}
}
DBUG_RETURN(true);
}
bool ConditionConverter::is_convertable(const Item_func *func_item) {
MRN_DBUG_ENTER_METHOD();
switch (func_item->functype()) {
case Item_func::EQ_FUNC:
case Item_func::LT_FUNC:
case Item_func::LE_FUNC:
case Item_func::GE_FUNC:
case Item_func::GT_FUNC:
if (!is_storage_mode_) {
DBUG_RETURN(false);
}
{
Item **arguments = func_item->arguments();
Item *left_item = arguments[0];
Item *right_item = arguments[1];
if (left_item->type() != Item::FIELD_ITEM) {
DBUG_RETURN(false);
}
if (!right_item->basic_const_item()) {
DBUG_RETURN(false);
}
bool convertable =
is_convertable_binary_operation(static_cast<Item_field *>(left_item),
right_item,
func_item->functype());
DBUG_RETURN(convertable);
}
break;
case Item_func::FT_FUNC:
DBUG_RETURN(true);
break;
case Item_func::BETWEEN:
if (!is_storage_mode_) {
DBUG_RETURN(false);
}
{
Item **arguments = func_item->arguments();
Item *target_item = arguments[0];
Item *min_item = arguments[1];
Item *max_item = arguments[2];
if (target_item->type() != Item::FIELD_ITEM) {
DBUG_RETURN(false);
}
if (!min_item->basic_const_item()) {
DBUG_RETURN(false);
}
if (!max_item->basic_const_item()) {
DBUG_RETURN(false);
}
bool convertable =
is_convertable_between(static_cast<Item_field *>(target_item),
min_item,
max_item);
DBUG_RETURN(convertable);
}
default:
DBUG_RETURN(false);
break;
}
DBUG_RETURN(true);
}
bool ConditionConverter::is_convertable_binary_operation(
const Item_field *field_item,
Item *value_item,
Item_func::Functype func_type) {
MRN_DBUG_ENTER_METHOD();
bool convertable = false;
enum_field_types field_type = field_item->field_type();
NormalizedType normalized_type = normalize_field_type(field_type);
switch (normalized_type) {
case STRING_TYPE:
if (value_item->type() == Item::STRING_ITEM &&
func_type == Item_func::EQ_FUNC) {
convertable = have_index(field_item, GRN_OP_EQUAL);
}
break;
case INT_TYPE:
convertable = value_item->type() == Item::INT_ITEM;
break;
case TIME_TYPE:
if (is_valid_time_value(field_item, value_item)) {
convertable = have_index(field_item, func_type);
}
break;
case UNSUPPORTED_TYPE:
break;
}
DBUG_RETURN(convertable);
}
bool ConditionConverter::is_convertable_between(const Item_field *field_item,
Item *min_item,
Item *max_item) {
MRN_DBUG_ENTER_METHOD();
bool convertable = false;
enum_field_types field_type = field_item->field_type();
NormalizedType normalized_type = normalize_field_type(field_type);
switch (normalized_type) {
case STRING_TYPE:
if (min_item->type() == Item::STRING_ITEM &&
max_item->type() == Item::STRING_ITEM) {
convertable = have_index(field_item, GRN_OP_LESS);
}
break;
case INT_TYPE:
if (min_item->type() == Item::INT_ITEM &&
max_item->type() == Item::INT_ITEM) {
convertable = have_index(field_item, GRN_OP_LESS);
}
break;
case TIME_TYPE:
if (is_valid_time_value(field_item, min_item) &&
is_valid_time_value(field_item, max_item)) {
convertable = have_index(field_item, GRN_OP_LESS);
}
break;
case UNSUPPORTED_TYPE:
break;
}
DBUG_RETURN(convertable);
}
bool ConditionConverter::is_valid_time_value(const Item_field *field_item,
Item *value_item) {
MRN_DBUG_ENTER_METHOD();
MYSQL_TIME mysql_time;
bool error = get_time_value(field_item, value_item, &mysql_time);
DBUG_RETURN(!error);
}
bool ConditionConverter::get_time_value(const Item_field *field_item,
Item *value_item,
MYSQL_TIME *mysql_time) {
MRN_DBUG_ENTER_METHOD();
bool error;
Item *real_value_item = value_item->real_item();
switch (field_item->field_type()) {
case MYSQL_TYPE_TIME:
error = real_value_item->get_time(mysql_time);
break;
case MYSQL_TYPE_YEAR:
mysql_time->year = static_cast<int>(value_item->val_int());
mysql_time->month = 1;
mysql_time->day = 1;
mysql_time->hour = 0;
mysql_time->hour = 0;
mysql_time->minute = 0;
mysql_time->second_part = 0;
mysql_time->neg = false;
mysql_time->time_type = MYSQL_TIMESTAMP_DATE;
error = false;
break;
default:
error = real_value_item->get_date(mysql_time, TIME_FUZZY_DATE);
break;
}
DBUG_RETURN(error);
}
ConditionConverter::NormalizedType
ConditionConverter::normalize_field_type(enum_field_types field_type) {
MRN_DBUG_ENTER_METHOD();
NormalizedType type = UNSUPPORTED_TYPE;
switch (field_type) {
case MYSQL_TYPE_DECIMAL:
type = STRING_TYPE;
break;
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_LONG:
type = INT_TYPE;
break;
case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_DOUBLE:
type = UNSUPPORTED_TYPE;
break;
case MYSQL_TYPE_NULL:
type = UNSUPPORTED_TYPE;
break;
case MYSQL_TYPE_TIMESTAMP:
type = TIME_TYPE;
break;
case MYSQL_TYPE_LONGLONG:
case MYSQL_TYPE_INT24:
type = INT_TYPE;
break;
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_TIME:
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_YEAR:
case MYSQL_TYPE_NEWDATE:
type = TIME_TYPE;
break;
case MYSQL_TYPE_VARCHAR:
type = STRING_TYPE;
break;
case MYSQL_TYPE_BIT:
type = INT_TYPE;
break;
#ifdef MRN_HAVE_MYSQL_TYPE_TIMESTAMP2
case MYSQL_TYPE_TIMESTAMP2:
type = TIME_TYPE;
break;
#endif
#ifdef MRN_HAVE_MYSQL_TYPE_DATETIME2
case MYSQL_TYPE_DATETIME2:
type = TIME_TYPE;
break;
#endif
#ifdef MRN_HAVE_MYSQL_TYPE_TIME2
case MYSQL_TYPE_TIME2:
type = TIME_TYPE;
break;
#endif
case MYSQL_TYPE_NEWDECIMAL:
type = STRING_TYPE;
break;
case MYSQL_TYPE_ENUM:
type = INT_TYPE;
break;
case MYSQL_TYPE_SET:
type = INT_TYPE;
break;
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_STRING:
type = STRING_TYPE;
break;
case MYSQL_TYPE_GEOMETRY:
type = UNSUPPORTED_TYPE;
break;
}
DBUG_RETURN(type);
}
bool ConditionConverter::have_index(const Item_field *field_item,
grn_operator _operator) {
MRN_DBUG_ENTER_METHOD();
grn_obj *column;
column = grn_obj_column(ctx_, table_,
MRN_ITEM_FIELD_GET_NAME(field_item),
MRN_ITEM_FIELD_GET_NAME_LENGTH(field_item));
if (!column) {
DBUG_RETURN(false);
}
mrn::SmartGrnObj smart_column(ctx_, column);
int n_indexes = grn_column_index(ctx_, column, _operator, NULL, 0, NULL);
bool convertable = (n_indexes > 0);
DBUG_RETURN(convertable);
}
bool ConditionConverter::have_index(const Item_field *field_item,
Item_func::Functype func_type) {
MRN_DBUG_ENTER_METHOD();
bool have = false;
switch (func_type) {
case Item_func::EQ_FUNC:
have = have_index(field_item, GRN_OP_EQUAL);
break;
case Item_func::LT_FUNC:
have = have_index(field_item, GRN_OP_LESS);
break;
case Item_func::LE_FUNC:
have = have_index(field_item, GRN_OP_LESS_EQUAL);
break;
case Item_func::GE_FUNC:
have = have_index(field_item, GRN_OP_GREATER_EQUAL);
break;
case Item_func::GT_FUNC:
have = have_index(field_item, GRN_OP_GREATER);
break;
default:
break;
}
DBUG_RETURN(have);
}
const Item_func *ConditionConverter::find_match_against(const Item *item) {
MRN_DBUG_ENTER_METHOD();
if (!item) {
DBUG_RETURN(NULL);
}
switch (item->type()) {
case Item::COND_ITEM:
if (is_storage_mode_) {
Item_cond *cond_item = (Item_cond *)item;
if (cond_item->functype() == Item_func::COND_AND_FUNC) {
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);
}
}
}
}
break;
case Item::FUNC_ITEM:
{
const Item_func *func_item = (const Item_func *)item;
switch (func_item->functype()) {
case Item_func::FT_FUNC:
DBUG_RETURN(func_item);
break;
default:
break;
}
}
break;
default:
break;
}
DBUG_RETURN(NULL);
}
void ConditionConverter::convert(const Item *where, grn_obj *expression) {
MRN_DBUG_ENTER_METHOD();
if (!where || where->type() != Item::COND_ITEM) {
DBUG_VOID_RETURN;
}
Item_cond *cond_item = (Item_cond *)where;
List_iterator<Item> iterator(*((cond_item)->argument_list()));
const Item *sub_item;
while ((sub_item = iterator++)) {
switch (sub_item->type()) {
case Item::FUNC_ITEM:
{
const Item_func *func_item = (const Item_func *)sub_item;
switch (func_item->functype()) {
case Item_func::EQ_FUNC:
convert_binary_operation(func_item, expression, GRN_OP_EQUAL);
break;
case Item_func::LT_FUNC:
convert_binary_operation(func_item, expression, GRN_OP_LESS);
break;
case Item_func::LE_FUNC:
convert_binary_operation(func_item, expression, GRN_OP_LESS_EQUAL);
break;
case Item_func::GE_FUNC:
convert_binary_operation(func_item, expression,
GRN_OP_GREATER_EQUAL);
break;
case Item_func::GT_FUNC:
convert_binary_operation(func_item, expression, GRN_OP_GREATER);
break;
case Item_func::BETWEEN:
convert_between(func_item, expression);
break;
default:
break;
}
}
break;
default:
break;
}
}
DBUG_VOID_RETURN;
}
void ConditionConverter::convert_binary_operation(const Item_func *func_item,
grn_obj *expression,
grn_operator _operator) {
Item **arguments = func_item->arguments();
Item *left_item = arguments[0];
Item *right_item = arguments[1];
if (left_item->type() == Item::FIELD_ITEM) {
const Item_field *field_item = static_cast<const Item_field *>(left_item);
append_field_value(field_item, expression);
append_const_item(field_item, right_item, expression);
grn_expr_append_op(ctx_, expression, _operator, 2);
grn_expr_append_op(ctx_, expression, GRN_OP_AND, 2);
}
}
void ConditionConverter::convert_between(const Item_func *func_item,
grn_obj *expression) {
MRN_DBUG_ENTER_METHOD();
Item **arguments = func_item->arguments();
Item *target_item = arguments[0];
Item *min_item = arguments[1];
Item *max_item = arguments[2];
grn_obj *between_func = grn_ctx_get(ctx_, "between", strlen("between"));
grn_expr_append_obj(ctx_, expression, between_func, GRN_OP_PUSH, 1);
const Item_field *field_item = static_cast<const Item_field *>(target_item);
append_field_value(field_item, expression);
grn_obj include;
mrn::SmartGrnObj smart_include(ctx_, &include);
GRN_TEXT_INIT(&include, 0);
GRN_TEXT_PUTS(ctx_, &include, "include");
append_const_item(field_item, min_item, expression);
grn_expr_append_const(ctx_, expression, &include, GRN_OP_PUSH, 1);
append_const_item(field_item, max_item, expression);
grn_expr_append_const(ctx_, expression, &include, GRN_OP_PUSH, 1);
grn_expr_append_op(ctx_, expression, GRN_OP_CALL, 5);
grn_expr_append_op(ctx_, expression, GRN_OP_AND, 2);
DBUG_VOID_RETURN;
}
void ConditionConverter::append_field_value(const Item_field *field_item,
grn_obj *expression) {
MRN_DBUG_ENTER_METHOD();
GRN_BULK_REWIND(&column_name_);
GRN_TEXT_PUT(ctx_, &column_name_,
MRN_ITEM_FIELD_GET_NAME(field_item),
MRN_ITEM_FIELD_GET_NAME_LENGTH(field_item));
grn_expr_append_const(ctx_, expression, &column_name_,
GRN_OP_PUSH, 1);
grn_expr_append_op(ctx_, expression, GRN_OP_GET_VALUE, 1);
DBUG_VOID_RETURN;
}
void ConditionConverter::append_const_item(const Item_field *field_item,
Item *const_item,
grn_obj *expression) {
MRN_DBUG_ENTER_METHOD();
enum_field_types field_type = field_item->field_type();
NormalizedType normalized_type = normalize_field_type(field_type);
switch (normalized_type) {
case STRING_TYPE:
grn_obj_reinit(ctx_, &value_, GRN_DB_TEXT, 0);
{
String *string;
string = const_item->val_str(NULL);
GRN_TEXT_SET(ctx_, &value_, string->ptr(), string->length());
}
break;
case INT_TYPE:
grn_obj_reinit(ctx_, &value_, GRN_DB_INT64, 0);
GRN_INT64_SET(ctx_, &value_, const_item->val_int());
break;
case TIME_TYPE:
grn_obj_reinit(ctx_, &value_, GRN_DB_TIME, 0);
{
MYSQL_TIME mysql_time;
get_time_value(field_item, const_item, &mysql_time);
bool truncated = false;
TimeConverter time_converter;
long long int time =
time_converter.mysql_time_to_grn_time(&mysql_time, &truncated);
GRN_TIME_SET(ctx_, &value_, time);
}
break;
case UNSUPPORTED_TYPE:
// Should not be occurred.
DBUG_PRINT("error",
("mroonga: append_const_item: unsupported type: <%d> "
"This case should not be occurred.",
field_type));
grn_obj_reinit(ctx_, &value_, GRN_DB_VOID, 0);
break;
}
grn_expr_append_const(ctx_, expression, &value_, GRN_OP_PUSH, 1);
DBUG_VOID_RETURN;
}
}

View File

@@ -0,0 +1,82 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2013 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_CONDITION_CONVERTER_HPP_
#define MRN_CONDITION_CONVERTER_HPP_
#include <groonga.h>
#include <mrn_mysql_compat.h>
namespace mrn {
class ConditionConverter {
public:
ConditionConverter(grn_ctx *ctx, grn_obj *table, bool is_storage_mode);
~ConditionConverter();
bool is_convertable(const Item *item);
const Item_func *find_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);
private:
enum NormalizedType {
STRING_TYPE,
INT_TYPE,
TIME_TYPE,
UNSUPPORTED_TYPE,
};
grn_ctx *ctx_;
grn_obj *table_;
bool is_storage_mode_;
grn_obj column_name_;
grn_obj value_;
bool is_convertable(const Item_cond *cond_item);
bool is_convertable(const Item_func *func_item);
bool is_convertable_binary_operation(const Item_field *field_item,
Item *value_item,
Item_func::Functype func_type);
bool is_convertable_between(const Item_field *field_item,
Item *min_item,
Item *max_item);
bool is_valid_time_value(const Item_field *field_item,
Item *value_item);
bool get_time_value(const Item_field *field_item,
Item *value_item,
MYSQL_TIME *mysql_time);
bool have_index(const Item_field *field_item, grn_operator _operator);
bool have_index(const Item_field *field_item, Item_func::Functype func_type);
NormalizedType normalize_field_type(enum_field_types field_type);
void convert_binary_operation(const Item_func *func_item,
grn_obj *expression,
grn_operator _operator);
void convert_between(const Item_func *func_item, grn_obj *expression);
void append_field_value(const Item_field *field_item,
grn_obj *expression);
void append_const_item(const Item_field *field_item,
Item *const_item,
grn_obj *expression);
};
}
#endif /* MRN_CONDITION_CONVERTER_HPP_ */

View File

@@ -0,0 +1,36 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2012 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_debug_column_access.hpp"
namespace mrn {
DebugColumnAccess::DebugColumnAccess(TABLE *table, MY_BITMAP *bitmap)
: table_(table),
bitmap_(bitmap) {
#ifndef DBUG_OFF
map_ = dbug_tmp_use_all_columns(table_, bitmap_);
#endif
}
DebugColumnAccess::~DebugColumnAccess() {
#ifndef DBUG_OFF
dbug_tmp_restore_column_map(bitmap_, map_);
#endif
}
}

View File

@@ -0,0 +1,38 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2012 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_DEBUG_COLUMN_ACCESS_HPP_
#define MRN_DEBUG_COLUMN_ACCESS_HPP_
#include <mrn_mysql.h>
namespace mrn {
class DebugColumnAccess {
TABLE *table_;
MY_BITMAP *bitmap_;
#ifndef DBUG_OFF
my_bitmap_map *map_;
#endif
public:
DebugColumnAccess(TABLE *table, MY_BITMAP *bitmap);
~DebugColumnAccess();
};
}
#endif // MRN_DEBUG_COLUMN_ACCESS_HPP_

View File

@@ -0,0 +1,222 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2013 Kouhei Sutou <kou@clear-code.com>
Copyright(C) 2011-2013 Kentoku SHIBA
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_err.h>
#include "mrn_encoding.hpp"
namespace mrn {
namespace encoding {
CHARSET_INFO *mrn_charset_utf8 = NULL;
CHARSET_INFO *mrn_charset_utf8mb4 = NULL;
CHARSET_INFO *mrn_charset_binary = NULL;
CHARSET_INFO *mrn_charset_ascii = NULL;
CHARSET_INFO *mrn_charset_latin1_1 = NULL;
CHARSET_INFO *mrn_charset_latin1_2 = NULL;
CHARSET_INFO *mrn_charset_cp932 = NULL;
CHARSET_INFO *mrn_charset_sjis = NULL;
CHARSET_INFO *mrn_charset_eucjpms = NULL;
CHARSET_INFO *mrn_charset_ujis = NULL;
CHARSET_INFO *mrn_charset_koi8r = NULL;
void init(void) {
CHARSET_INFO **cs;
MRN_DBUG_ENTER_FUNCTION();
for (cs = all_charsets; cs < all_charsets + MY_ALL_CHARSETS_SIZE; cs++)
{
if (!cs[0])
continue;
if (!strcmp(cs[0]->csname, "utf8"))
{
DBUG_PRINT("info", ("mroonga: %s is %s [%p]",
cs[0]->name, cs[0]->csname, cs[0]->cset));
if (!mrn_charset_utf8)
mrn_charset_utf8 = cs[0];
else if (mrn_charset_utf8->cset != cs[0]->cset)
DBUG_ASSERT(0);
continue;
}
if (!strcmp(cs[0]->csname, "utf8mb4"))
{
DBUG_PRINT("info", ("mroonga: %s is %s [%p]",
cs[0]->name, cs[0]->csname, cs[0]->cset));
if (!mrn_charset_utf8mb4)
mrn_charset_utf8mb4 = cs[0];
else if (mrn_charset_utf8mb4->cset != cs[0]->cset)
DBUG_ASSERT(0);
continue;
}
if (!strcmp(cs[0]->csname, "binary"))
{
DBUG_PRINT("info", ("mroonga: %s is %s [%p]",
cs[0]->name, cs[0]->csname, cs[0]->cset));
if (!mrn_charset_binary)
mrn_charset_binary = cs[0];
else if (mrn_charset_binary->cset != cs[0]->cset)
DBUG_ASSERT(0);
continue;
}
if (!strcmp(cs[0]->csname, "ascii"))
{
DBUG_PRINT("info", ("mroonga: %s is %s [%p]",
cs[0]->name, cs[0]->csname, cs[0]->cset));
if (!mrn_charset_ascii)
mrn_charset_ascii = cs[0];
else if (mrn_charset_ascii->cset != cs[0]->cset)
DBUG_ASSERT(0);
continue;
}
if (!strcmp(cs[0]->csname, "latin1"))
{
DBUG_PRINT("info", ("mroonga: %s is %s [%p]",
cs[0]->name, cs[0]->csname, cs[0]->cset));
if (!mrn_charset_latin1_1)
mrn_charset_latin1_1 = cs[0];
else if (mrn_charset_latin1_1->cset != cs[0]->cset)
{
if (!mrn_charset_latin1_2)
mrn_charset_latin1_2 = cs[0];
else if (mrn_charset_latin1_2->cset != cs[0]->cset)
DBUG_ASSERT(0);
}
continue;
}
if (!strcmp(cs[0]->csname, "cp932"))
{
DBUG_PRINT("info", ("mroonga: %s is %s [%p]",
cs[0]->name, cs[0]->csname, cs[0]->cset));
if (!mrn_charset_cp932)
mrn_charset_cp932 = cs[0];
else if (mrn_charset_cp932->cset != cs[0]->cset)
DBUG_ASSERT(0);
continue;
}
if (!strcmp(cs[0]->csname, "sjis"))
{
DBUG_PRINT("info", ("mroonga: %s is %s [%p]",
cs[0]->name, cs[0]->csname, cs[0]->cset));
if (!mrn_charset_sjis)
mrn_charset_sjis = cs[0];
else if (mrn_charset_sjis->cset != cs[0]->cset)
DBUG_ASSERT(0);
continue;
}
if (!strcmp(cs[0]->csname, "eucjpms"))
{
DBUG_PRINT("info", ("mroonga: %s is %s [%p]",
cs[0]->name, cs[0]->csname, cs[0]->cset));
if (!mrn_charset_eucjpms)
mrn_charset_eucjpms = cs[0];
else if (mrn_charset_eucjpms->cset != cs[0]->cset)
DBUG_ASSERT(0);
continue;
}
if (!strcmp(cs[0]->csname, "ujis"))
{
DBUG_PRINT("info", ("mroonga: %s is %s [%p]",
cs[0]->name, cs[0]->csname, cs[0]->cset));
if (!mrn_charset_ujis)
mrn_charset_ujis = cs[0];
else if (mrn_charset_ujis->cset != cs[0]->cset)
DBUG_ASSERT(0);
continue;
}
if (!strcmp(cs[0]->csname, "koi8r"))
{
DBUG_PRINT("info", ("mroonga: %s is %s [%p]",
cs[0]->name, cs[0]->csname, cs[0]->cset));
if (!mrn_charset_koi8r)
mrn_charset_koi8r = cs[0];
else if (mrn_charset_koi8r->cset != cs[0]->cset)
DBUG_ASSERT(0);
continue;
}
DBUG_PRINT("info", ("mroonga: %s[%s][%p] is not supported",
cs[0]->name, cs[0]->csname, cs[0]->cset));
}
DBUG_VOID_RETURN;
}
bool set(grn_ctx *ctx, const CHARSET_INFO *charset) {
MRN_DBUG_ENTER_FUNCTION();
if (!charset)
{
GRN_CTX_SET_ENCODING(ctx, GRN_ENC_NONE);
DBUG_RETURN(true);
}
if (charset->cset == mrn_charset_utf8->cset)
{
GRN_CTX_SET_ENCODING(ctx, GRN_ENC_UTF8);
DBUG_RETURN(true);
}
if (mrn_charset_utf8mb4 && charset->cset == mrn_charset_utf8mb4->cset)
{
GRN_CTX_SET_ENCODING(ctx, GRN_ENC_UTF8);
DBUG_RETURN(true);
}
if (charset->cset == mrn_charset_cp932->cset)
{
GRN_CTX_SET_ENCODING(ctx, GRN_ENC_SJIS);
DBUG_RETURN(true);
}
if (charset->cset == mrn_charset_eucjpms->cset)
{
GRN_CTX_SET_ENCODING(ctx, GRN_ENC_EUC_JP);
DBUG_RETURN(true);
}
if (charset->cset == mrn_charset_latin1_1->cset)
{
GRN_CTX_SET_ENCODING(ctx, GRN_ENC_LATIN1);
DBUG_RETURN(true);
}
if (charset->cset == mrn_charset_latin1_2->cset)
{
GRN_CTX_SET_ENCODING(ctx, GRN_ENC_LATIN1);
DBUG_RETURN(true);
}
if (charset->cset == mrn_charset_koi8r->cset)
{
GRN_CTX_SET_ENCODING(ctx, GRN_ENC_KOI8R);
DBUG_RETURN(true);
}
if (charset->cset == mrn_charset_binary->cset)
{
GRN_CTX_SET_ENCODING(ctx, GRN_ENC_NONE);
DBUG_RETURN(true);
}
if (charset->cset == mrn_charset_ascii->cset)
{
GRN_CTX_SET_ENCODING(ctx, GRN_ENC_UTF8);
DBUG_RETURN(true);
}
if (charset->cset == mrn_charset_sjis->cset)
{
GRN_CTX_SET_ENCODING(ctx, GRN_ENC_SJIS);
DBUG_RETURN(true);
}
if (charset->cset == mrn_charset_ujis->cset)
{
GRN_CTX_SET_ENCODING(ctx, GRN_ENC_EUC_JP);
DBUG_RETURN(true);
}
GRN_CTX_SET_ENCODING(ctx, GRN_ENC_NONE);
DBUG_RETURN(false);
}
}
}

View File

@@ -0,0 +1,35 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2013 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_ENCODING_HPP_
#define MRN_ENCODING_HPP_
#include <groonga.h>
#include <mrn_mysql.h>
#include <mrn_mysql_compat.h>
namespace mrn {
namespace encoding {
void init(void);
bool set(grn_ctx *ctx, const CHARSET_INFO *charset);
}
}
#endif // MRN_ENCODING_HPP_

View File

@@ -0,0 +1,43 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2012 Kentoku SHIBA
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_external_lock.hpp"
namespace mrn {
ExternalLock::ExternalLock(THD *thd, handler *handler, int lock_type)
: thd_(thd),
handler_(handler),
lock_type_(lock_type) {
if (lock_type_ != F_UNLCK) {
error_ = handler_->ha_external_lock(thd_, lock_type);
} else {
error_ = 0;
}
}
ExternalLock::~ExternalLock() {
if (lock_type_ != F_UNLCK) {
handler_->ha_external_lock(thd_, F_UNLCK);
}
}
int ExternalLock::error() {
return error_;
}
}

View File

@@ -0,0 +1,38 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2012 Kentoku SHIBA
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_EXTERNAL_LOCK_HPP_
#define MRN_EXTERNAL_LOCK_HPP_
#include <mrn_mysql.h>
namespace mrn {
class ExternalLock {
THD *thd_;
handler *handler_;
int lock_type_;
int error_;
public:
ExternalLock(THD *thd, handler *handler, int lock_type);
~ExternalLock();
int error();
};
}
#endif // MRN_EXTERNAL_LOCK_HPP_

View File

@@ -0,0 +1,142 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2013 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_field_normalizer.hpp"
#include "mrn_encoding.hpp"
// for debug
#define MRN_CLASS_NAME "mrn::FieldNormalizer"
namespace mrn {
FieldNormalizer::FieldNormalizer(grn_ctx *ctx, THD *thread, Field *field)
: ctx_(ctx),
thread_(thread),
field_(field) {
}
FieldNormalizer::~FieldNormalizer() {
}
bool FieldNormalizer::should_normalize() {
MRN_DBUG_ENTER_METHOD();
DBUG_PRINT("info",
("mroonga: result_type = %u", field_->result_type()));
DBUG_PRINT("info",
("mroonga: charset->name = %s", field_->charset()->name));
DBUG_PRINT("info",
("mroonga: charset->csname = %s", field_->charset()->csname));
DBUG_PRINT("info",
("mroonga: charset->state = %u", field_->charset()->state));
bool need_normalize_p;
if (field_->charset()->state & (MY_CS_BINSORT | MY_CS_CSSORT)) {
need_normalize_p = false;
DBUG_PRINT("info",
("mroonga: should_normalize: false: sort is required"));
} else {
if (is_text_type()) {
need_normalize_p = true;
DBUG_PRINT("info", ("mroonga: should_normalize: true: text type"));
} else {
need_normalize_p = false;
DBUG_PRINT("info", ("mroonga: should_normalize: false: no text type"));
}
}
DBUG_RETURN(need_normalize_p);
}
bool FieldNormalizer::is_text_type() {
MRN_DBUG_ENTER_METHOD();
bool text_type_p;
switch (field_->type()) {
case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_VAR_STRING:
text_type_p = true;
break;
case MYSQL_TYPE_STRING:
switch (field_->real_type()) {
case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_SET:
text_type_p = false;
break;
default:
text_type_p = true;
break;
}
break;
default:
text_type_p = false;
break;
}
DBUG_RETURN(text_type_p);
}
grn_obj *FieldNormalizer::normalize(const char *string,
unsigned int string_length) {
MRN_DBUG_ENTER_METHOD();
grn_obj *normalizer = find_grn_normalizer();
int flags = 0;
grn_encoding original_encoding = GRN_CTX_GET_ENCODING(ctx_);
encoding::set(ctx_, field_->charset());
grn_obj *grn_string = grn_string_open(ctx_, string, string_length,
normalizer, flags);
GRN_CTX_SET_ENCODING(ctx_, original_encoding);
DBUG_RETURN(grn_string);
}
grn_obj *FieldNormalizer::find_grn_normalizer() {
MRN_DBUG_ENTER_METHOD();
const CHARSET_INFO *charset_info = field_->charset();
const char *normalizer_name = NULL;
const char *default_normalizer_name = "NormalizerAuto";
if ((strcmp(charset_info->name, "utf8_general_ci") == 0) ||
(strcmp(charset_info->name, "utf8mb4_general_ci") == 0)) {
normalizer_name = "NormalizerMySQLGeneralCI";
} else if ((strcmp(charset_info->name, "utf8_unicode_ci") == 0) ||
(strcmp(charset_info->name, "utf8mb4_unicode_ci") == 0)) {
normalizer_name = "NormalizerMySQLUnicodeCI";
}
grn_obj *normalizer = NULL;
if (normalizer_name) {
normalizer = grn_ctx_get(ctx_, normalizer_name, -1);
if (!normalizer) {
char error_message[MRN_MESSAGE_BUFFER_SIZE];
snprintf(error_message, MRN_MESSAGE_BUFFER_SIZE,
"%s normalizer isn't found for %s. "
"Install groonga-normalizer-mysql normalizer. "
"%s is used as fallback.",
normalizer_name,
charset_info->name,
default_normalizer_name);
push_warning(thread_, Sql_condition::WARN_LEVEL_WARN,
HA_ERR_UNSUPPORTED, error_message);
}
}
if (!normalizer) {
normalizer = grn_ctx_get(ctx_, default_normalizer_name, -1);
}
DBUG_RETURN(normalizer);
}
}

View File

@@ -0,0 +1,47 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2013 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_FIELD_NORMALIZER_HPP_
#define MRN_FIELD_NORMALIZER_HPP_
#include <groonga.h>
#include <mrn_mysql.h>
#include <mrn_mysql_compat.h>
namespace mrn {
class FieldNormalizer {
public:
FieldNormalizer(grn_ctx *ctx, THD *thread, Field *field);
~FieldNormalizer();
bool should_normalize();
grn_obj *normalize(const char *string, unsigned int string_length);
grn_obj *find_grn_normalizer();
private:
grn_ctx *ctx_;
THD *thread_;
Field *field_;
bool is_text_type();
};
}
#endif // MRN_FIELD_NORMALIZER_HPP_

View File

@@ -0,0 +1,96 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2011-2013 Kentoku SHIBA
Copyright(C) 2011-2012 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_index_column_name.hpp"
#define MRN_MIN_INDEX_COLUMN_NAME_LENGTH 65
// for debug
#define MRN_CLASS_NAME "mrn::IndexColumnName"
namespace mrn {
IndexColumnName::IndexColumnName(const char *table_name,
const char *mysql_column_name)
: table_name_(table_name),
mysql_column_name_(mysql_column_name) {
uchar encoded_mysql_column_name_multibyte[MRN_MAX_KEY_SIZE];
const uchar *mysql_column_name_multibyte =
reinterpret_cast<const uchar *>(mysql_column_name_);
encode(encoded_mysql_column_name_multibyte,
encoded_mysql_column_name_multibyte + MRN_MAX_KEY_SIZE,
mysql_column_name_multibyte,
mysql_column_name_multibyte + strlen(mysql_column_name_));
snprintf(name_, MRN_MAX_KEY_SIZE,
"%s-%s", table_name_, encoded_mysql_column_name_multibyte);
length_ = strlen(name_);
if (length_ < MRN_MIN_INDEX_COLUMN_NAME_LENGTH) {
memset(name_ + length_, '-', MRN_MIN_INDEX_COLUMN_NAME_LENGTH - length_);
length_ = MRN_MIN_INDEX_COLUMN_NAME_LENGTH;
name_[length_] = '\0';
}
}
const char *IndexColumnName::c_str() {
return name_;
}
size_t IndexColumnName::length() {
return length_;
}
uint IndexColumnName::encode(uchar *encoded_start,
uchar *encoded_end,
const uchar *mysql_string_start,
const uchar *mysql_string_end) {
MRN_DBUG_ENTER_METHOD();
my_charset_conv_mb_wc mb_wc = system_charset_info->cset->mb_wc;
my_charset_conv_wc_mb wc_mb = my_charset_filename.cset->wc_mb;
DBUG_PRINT("info", ("mroonga: in=%s", mysql_string_start));
encoded_end--;
uchar *encoded = encoded_start;
const uchar *mysql_string = mysql_string_start;
while (mysql_string < mysql_string_end && encoded < encoded_end) {
my_wc_t wc;
int mb_wc_converted_length;
int wc_mb_converted_length;
mb_wc_converted_length =
(*mb_wc)(NULL, &wc, mysql_string, mysql_string_end);
if (mb_wc_converted_length > 0) {
wc_mb_converted_length = (*wc_mb)(NULL, wc, encoded, encoded_end);
if (wc_mb_converted_length <= 0) {
break;
}
} else if (mb_wc_converted_length == MY_CS_ILSEQ) {
*encoded = *mysql_string;
mb_wc_converted_length = 1;
wc_mb_converted_length = 1;
} else {
break;
}
mysql_string += mb_wc_converted_length;
encoded += wc_mb_converted_length;
}
*encoded = '\0';
DBUG_PRINT("info", ("mroonga: out=%s", encoded_start));
DBUG_RETURN(encoded - encoded_start);
}
}

View File

@@ -0,0 +1,43 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2011-2013 Kentoku SHIBA
Copyright(C) 2011-2012 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_INDEX_COLUMN_NAME_HPP_
#define MRN_INDEX_COLUMN_NAME_HPP_
#include <mrn_constants.hpp>
namespace mrn {
class IndexColumnName {
public:
IndexColumnName(const char *table_name, const char *mysql_column_name);
const char *c_str();
size_t length();
private:
const char *table_name_;
const char *mysql_column_name_;
char name_[MRN_MAX_KEY_SIZE];
size_t length_;
uint encode(uchar *encoded_start, uchar *encoded_end,
const uchar *mysql_string_start, const uchar *mysql_string_end);
};
}
#endif /* MRN_INDEX_COLUMN_NAME_HPP_ */

View File

@@ -0,0 +1,89 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2011 Kentoku SHIBA
Copyright(C) 2011-2012 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_index_table_name.hpp"
// for debug
#define MRN_CLASS_NAME "mrn::IndexTableName"
namespace mrn {
IndexTableName::IndexTableName(const char *table_name,
const char *mysql_index_name)
: table_name_(table_name),
mysql_index_name_(mysql_index_name) {
uchar encoded_mysql_index_name_multibyte[MRN_MAX_KEY_SIZE];
const uchar *mysql_index_name_multibyte =
reinterpret_cast<const uchar *>(mysql_index_name_);
encode(encoded_mysql_index_name_multibyte,
encoded_mysql_index_name_multibyte + MRN_MAX_KEY_SIZE,
mysql_index_name_multibyte,
mysql_index_name_multibyte + strlen(mysql_index_name_));
snprintf(name_, MRN_MAX_KEY_SIZE,
"%s-%s", table_name_, encoded_mysql_index_name_multibyte);
length_ = strlen(name_);
}
const char *IndexTableName::c_str() {
return name_;
}
size_t IndexTableName::length() {
return length_;
}
uint IndexTableName::encode(uchar *encoded_start,
uchar *encoded_end,
const uchar *mysql_string_start,
const uchar *mysql_string_end) {
MRN_DBUG_ENTER_METHOD();
my_charset_conv_mb_wc mb_wc = system_charset_info->cset->mb_wc;
my_charset_conv_wc_mb wc_mb = my_charset_filename.cset->wc_mb;
DBUG_PRINT("info", ("mroonga: in=%s", mysql_string_start));
encoded_end--;
uchar *encoded = encoded_start;
const uchar *mysql_string = mysql_string_start;
while (mysql_string < mysql_string_end && encoded < encoded_end) {
my_wc_t wc;
int mb_wc_converted_length;
int wc_mb_converted_length;
mb_wc_converted_length =
(*mb_wc)(NULL, &wc, mysql_string, mysql_string_end);
if (mb_wc_converted_length > 0) {
wc_mb_converted_length = (*wc_mb)(NULL, wc, encoded, encoded_end);
if (wc_mb_converted_length <= 0) {
break;
}
} else if (mb_wc_converted_length == MY_CS_ILSEQ) {
*encoded = *mysql_string;
mb_wc_converted_length = 1;
wc_mb_converted_length = 1;
} else {
break;
}
mysql_string += mb_wc_converted_length;
encoded += wc_mb_converted_length;
}
*encoded = '\0';
DBUG_PRINT("info", ("mroonga: out=%s", encoded_start));
DBUG_RETURN(encoded - encoded_start);
}
}

View File

@@ -0,0 +1,43 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2011 Kentoku SHIBA
Copyright(C) 2011-2012 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_INDEX_TABLE_NAME_HPP_
#define MRN_INDEX_TABLE_NAME_HPP_
#include <mrn_constants.hpp>
namespace mrn {
class IndexTableName {
public:
IndexTableName(const char *table_name, const char *mysql_index_name);
const char *c_str();
size_t length();
private:
const char *table_name_;
const char *mysql_index_name_;
char name_[MRN_MAX_KEY_SIZE];
size_t length_;
uint encode(uchar *encoded_start, uchar *encoded_end,
const uchar *mysql_string_start, const uchar *mysql_string_end);
};
}
#endif /* MRN_INDEX_TABLE_NAME_HPP_ */

View File

@@ -0,0 +1,31 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2013 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_lock.hpp"
namespace mrn {
Lock::Lock(pthread_mutex_t *mutex)
: mutex_(mutex) {
pthread_mutex_lock(mutex_);
}
Lock::~Lock() {
pthread_mutex_unlock(mutex_);
}
}

View File

@@ -0,0 +1,36 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2013 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_LOCK_HPP_
#define MRN_LOCK_HPP_
#include <mrn_mysql.h>
#include <mrn_mysql_compat.h>
namespace mrn {
class Lock {
public:
Lock(pthread_mutex_t *mutex);
~Lock();
private:
pthread_mutex_t *mutex_;
};
}
#endif /* MRN_LOCK_HPP_ */

View File

@@ -0,0 +1,33 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2012 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_match_escalation_threshold_scope.hpp"
namespace mrn {
MatchEscalationThresholdScope::MatchEscalationThresholdScope(
grn_ctx *ctx, long long int threshold)
: ctx_(ctx),
original_threshold_(grn_ctx_get_match_escalation_threshold(ctx_)) {
grn_ctx_set_match_escalation_threshold(ctx_, threshold);
}
MatchEscalationThresholdScope::~MatchEscalationThresholdScope() {
grn_ctx_set_match_escalation_threshold(ctx_, original_threshold_);
}
}

View File

@@ -0,0 +1,35 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2012 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_MATCH_ESCALATION_THRESHOLD_SCOPE_HPP_
#define MRN_MATCH_ESCALATION_THRESHOLD_SCOPE_HPP_
#include <groonga.h>
namespace mrn {
class MatchEscalationThresholdScope {
grn_ctx *ctx_;
long long int original_threshold_;
public:
MatchEscalationThresholdScope(grn_ctx *ctx, long long int threshold);
~MatchEscalationThresholdScope();
};
}
#endif // MRN_MATCH_ESCALATION_THRESHOLD_SCOPE_HPP_

View File

@@ -0,0 +1,548 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2012-2014 Kouhei Sutou <kou@clear-code.com>
Copyright(C) 2013 Kentoku SHIBA
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_multiple_column_key_codec.hpp"
#include "mrn_field_normalizer.hpp"
#include "mrn_smart_grn_obj.hpp"
// for debug
#define MRN_CLASS_NAME "mrn::MultipleColumnKeyCodec"
#ifdef WORDS_BIGENDIAN
#define mrn_byte_order_host_to_network(buf, key, size) \
{ \
uint32 size_ = (uint32)(size); \
uint8 *buf_ = (uint8 *)(buf); \
uint8 *key_ = (uint8 *)(key); \
while (size_--) { *buf_++ = *key_++; } \
}
#else /* WORDS_BIGENDIAN */
#define mrn_byte_order_host_to_network(buf, key, size) \
{ \
uint32 size_ = (uint32)(size); \
uint8 *buf_ = (uint8 *)(buf); \
uint8 *key_ = (uint8 *)(key) + size_; \
while (size_--) { *buf_++ = *(--key_); } \
}
#endif /* WORDS_BIGENDIAN */
namespace mrn {
MultipleColumnKeyCodec::MultipleColumnKeyCodec(grn_ctx *ctx,
THD *thread,
KEY *key_info)
: ctx_(ctx),
thread_(thread),
key_info_(key_info) {
}
MultipleColumnKeyCodec::~MultipleColumnKeyCodec() {
}
int MultipleColumnKeyCodec::encode(const uchar *mysql_key,
uint mysql_key_length,
uchar *grn_key,
uint *grn_key_length) {
MRN_DBUG_ENTER_METHOD();
int error = 0;
const uchar *current_mysql_key = mysql_key;
const uchar *mysql_key_end = mysql_key + mysql_key_length;
uchar *current_grn_key = grn_key;
int n_key_parts = KEY_N_KEY_PARTS(key_info_);
DBUG_PRINT("info", ("mroonga: n_key_parts=%d", n_key_parts));
*grn_key_length = 0;
for (int i = 0; i < n_key_parts && current_mysql_key < mysql_key_end; i++) {
KEY_PART_INFO *key_part = &(key_info_->key_part[i]);
Field *field = key_part->field;
DBUG_PRINT("info", ("mroonga: key_part->length=%u", key_part->length));
if (field->null_bit) {
DBUG_PRINT("info", ("mroonga: field has null bit"));
*current_grn_key = 0;
current_mysql_key += 1;
current_grn_key += 1;
(*grn_key_length)++;
}
DataType data_type = TYPE_UNKNOWN;
uint data_size = 0;
get_key_info(key_part, &data_type, &data_size);
switch (data_type) {
case TYPE_UNKNOWN:
// TODO: This will not be happen. This is just for
// suppressing warnings by gcc -O2. :<
error = HA_ERR_UNSUPPORTED;
break;
case TYPE_LONG_LONG_NUMBER:
{
long long int long_long_value = 0;
switch (data_size) {
case 3:
long_long_value = (long long int)sint3korr(current_mysql_key);
break;
case 8:
long_long_value = (long long int)sint8korr(current_mysql_key);
break;
}
mrn_byte_order_host_to_network(current_grn_key, &long_long_value,
data_size);
*((uint8 *)(current_grn_key)) ^= 0x80;
}
break;
case TYPE_NUMBER:
mrn_byte_order_host_to_network(current_grn_key, current_mysql_key, data_size);
{
Field_num *number_field = (Field_num *)field;
if (!number_field->unsigned_flag) {
*((uint8 *)(current_grn_key)) ^= 0x80;
}
}
break;
case TYPE_FLOAT:
{
float value;
float4get(value, current_mysql_key);
encode_float(value, data_size, current_grn_key);
}
break;
case TYPE_DOUBLE:
{
double value;
float8get(value, current_mysql_key);
encode_double(value, data_size, current_grn_key);
}
break;
case TYPE_BYTE_SEQUENCE:
memcpy(current_grn_key, current_mysql_key, data_size);
break;
case TYPE_BYTE_REVERSE:
encode_reverse(current_mysql_key, data_size, current_grn_key);
break;
case TYPE_BYTE_BLOB:
encode_blob(field, current_mysql_key, current_grn_key, &data_size);
break;
}
if (error) {
break;
}
current_mysql_key += data_size;
current_grn_key += data_size;
*grn_key_length += data_size;
}
DBUG_RETURN(error);
}
int MultipleColumnKeyCodec::decode(const uchar *grn_key,
uint grn_key_length,
uchar *mysql_key,
uint *mysql_key_length) {
MRN_DBUG_ENTER_METHOD();
int error = 0;
const uchar *current_grn_key = grn_key;
const uchar *grn_key_end = grn_key + grn_key_length;
uchar *current_mysql_key = mysql_key;
int n_key_parts = KEY_N_KEY_PARTS(key_info_);
DBUG_PRINT("info", ("mroonga: n_key_parts=%d", n_key_parts));
*mysql_key_length = 0;
for (int i = 0; i < n_key_parts && current_grn_key < grn_key_end; i++) {
KEY_PART_INFO *key_part = &(key_info_->key_part[i]);
Field *field = key_part->field;
DBUG_PRINT("info", ("mroonga: key_part->length=%u", key_part->length));
if (field->null_bit) {
DBUG_PRINT("info", ("mroonga: field has null bit"));
*current_mysql_key = 0;
current_grn_key += 1;
current_mysql_key += 1;
(*mysql_key_length)++;
}
DataType data_type = TYPE_UNKNOWN;
uint data_size = 0;
get_key_info(key_part, &data_type, &data_size);
switch (data_type) {
case TYPE_UNKNOWN:
// TODO: This will not be happen. This is just for
// suppressing warnings by gcc -O2. :<
error = HA_ERR_UNSUPPORTED;
break;
case TYPE_LONG_LONG_NUMBER:
{
long long int long_long_value = 0;
switch (data_size) {
case 3:
long_long_value = (long long int)sint3korr(current_grn_key);
break;
case 8:
long_long_value = (long long int)sint8korr(current_grn_key);
break;
}
*((uint8 *)(&long_long_value)) ^= 0x80;
mrn_byte_order_host_to_network(current_mysql_key, &long_long_value,
data_size);
}
break;
case TYPE_NUMBER:
{
uchar buffer[8];
memcpy(buffer, current_grn_key, data_size);
Field_num *number_field = (Field_num *)field;
if (!number_field->unsigned_flag) {
buffer[0] ^= 0x80;
}
mrn_byte_order_host_to_network(current_mysql_key, buffer,
data_size);
}
break;
case TYPE_FLOAT:
decode_float(current_grn_key, current_mysql_key, data_size);
break;
case TYPE_DOUBLE:
decode_double(current_grn_key, current_mysql_key, data_size);
break;
case TYPE_BYTE_SEQUENCE:
memcpy(current_mysql_key, current_grn_key, data_size);
break;
case TYPE_BYTE_REVERSE:
decode_reverse(current_grn_key, current_mysql_key, data_size);
break;
case TYPE_BYTE_BLOB:
memcpy(current_mysql_key,
current_grn_key + data_size,
HA_KEY_BLOB_LENGTH);
memcpy(current_mysql_key + HA_KEY_BLOB_LENGTH,
current_grn_key,
data_size);
data_size += HA_KEY_BLOB_LENGTH;
break;
}
if (error) {
break;
}
current_grn_key += data_size;
current_mysql_key += data_size;
*mysql_key_length += data_size;
}
DBUG_RETURN(error);
}
uint MultipleColumnKeyCodec::size() {
MRN_DBUG_ENTER_METHOD();
int n_key_parts = KEY_N_KEY_PARTS(key_info_);
DBUG_PRINT("info", ("mroonga: n_key_parts=%d", n_key_parts));
uint total_size = 0;
for (int i = 0; i < n_key_parts; ++i) {
KEY_PART_INFO *key_part = &(key_info_->key_part[i]);
Field *field = key_part->field;
DBUG_PRINT("info", ("mroonga: key_part->length=%u", key_part->length));
if (field->null_bit) {
DBUG_PRINT("info", ("mroonga: field has null bit"));
++total_size;
}
DataType data_type = TYPE_UNKNOWN;
uint data_size = 0;
get_key_info(key_part, &data_type, &data_size);
total_size += data_size;
if (data_type == TYPE_BYTE_BLOB) {
total_size += HA_KEY_BLOB_LENGTH;
}
}
DBUG_RETURN(total_size);
}
void MultipleColumnKeyCodec::get_key_info(KEY_PART_INFO *key_part,
DataType *data_type,
uint *data_size) {
MRN_DBUG_ENTER_METHOD();
*data_type = TYPE_UNKNOWN;
*data_size = 0;
Field *field = key_part->field;
switch (field->real_type()) {
case MYSQL_TYPE_DECIMAL:
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_DECIMAL"));
*data_type = TYPE_BYTE_SEQUENCE;
*data_size = key_part->length;
break;
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_YEAR:
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_TINY"));
*data_type = TYPE_NUMBER;
*data_size = 1;
break;
case MYSQL_TYPE_SHORT:
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_SHORT"));
*data_type = TYPE_NUMBER;
*data_size = 2;
break;
case MYSQL_TYPE_LONG:
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_LONG"));
*data_type = TYPE_NUMBER;
*data_size = 4;
break;
case MYSQL_TYPE_FLOAT:
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_FLOAT"));
*data_type = TYPE_FLOAT;
*data_size = 4;
break;
case MYSQL_TYPE_DOUBLE:
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_DOUBLE"));
*data_type = TYPE_DOUBLE;
*data_size = 8;
break;
case MYSQL_TYPE_NULL:
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_NULL"));
*data_type = TYPE_NUMBER;
*data_size = 1;
break;
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_NEWDATE:
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_DATETIME"));
*data_type = TYPE_BYTE_REVERSE;
*data_size = key_part->length;
break;
case MYSQL_TYPE_LONGLONG:
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_LONGLONG"));
*data_type = TYPE_NUMBER;
*data_size = 8;
break;
case MYSQL_TYPE_INT24:
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_INT24"));
*data_type = TYPE_NUMBER;
*data_size = 3;
break;
case MYSQL_TYPE_TIME:
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_TIME"));
*data_type = TYPE_LONG_LONG_NUMBER;
*data_size = 3;
break;
case MYSQL_TYPE_VARCHAR:
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_VARCHAR"));
*data_type = TYPE_BYTE_BLOB;
*data_size = key_part->length;
break;
case MYSQL_TYPE_BIT:
// TODO
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_BIT"));
*data_type = TYPE_NUMBER;
*data_size = 1;
break;
#ifdef MRN_HAVE_MYSQL_TYPE_TIMESTAMP2
case MYSQL_TYPE_TIMESTAMP2:
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_TIMESTAMP2"));
*data_type = TYPE_BYTE_SEQUENCE;
*data_size = key_part->length;
break;
#endif
#ifdef MRN_HAVE_MYSQL_TYPE_DATETIME2
case MYSQL_TYPE_DATETIME2:
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_DATETIME2"));
*data_type = TYPE_BYTE_SEQUENCE;
*data_size = key_part->length;
break;
#endif
#ifdef MRN_HAVE_MYSQL_TYPE_TIME2
case MYSQL_TYPE_TIME2:
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_TIME2"));
*data_type = TYPE_BYTE_SEQUENCE;
*data_size = key_part->length;
break;
#endif
case MYSQL_TYPE_NEWDECIMAL:
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_NEWDECIMAL"));
*data_type = TYPE_BYTE_SEQUENCE;
*data_size = key_part->length;
break;
case MYSQL_TYPE_ENUM:
// TODO
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_ENUM"));
*data_type = TYPE_NUMBER;
*data_size = 1;
break;
case MYSQL_TYPE_SET:
// TODO
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_SET"));
*data_type = TYPE_NUMBER;
*data_size = 1;
break;
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_BLOB:
// TODO
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_BLOB"));
*data_type = TYPE_BYTE_BLOB;
*data_size = key_part->length;
break;
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_STRING:
// TODO
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_STRING"));
*data_type = TYPE_BYTE_SEQUENCE;
*data_size = key_part->length;
break;
case MYSQL_TYPE_GEOMETRY:
// TODO
DBUG_PRINT("info", ("mroonga: MYSQL_TYPE_GEOMETRY"));
*data_type = TYPE_BYTE_SEQUENCE;
*data_size = key_part->length;
break;
}
DBUG_VOID_RETURN;
}
void MultipleColumnKeyCodec::encode_float(volatile float value, uint data_size,
uchar *grn_key) {
MRN_DBUG_ENTER_METHOD();
int n_bits = (data_size * 8 - 1);
volatile int *int_value_pointer = (int *)(&value);
int int_value = *int_value_pointer;
int_value ^= ((int_value >> n_bits) | (1 << n_bits));
mrn_byte_order_host_to_network(grn_key, &int_value, data_size);
DBUG_VOID_RETURN;
}
void MultipleColumnKeyCodec::decode_float(const uchar *grn_key,
uchar *mysql_key,
uint data_size) {
MRN_DBUG_ENTER_METHOD();
int int_value;
mrn_byte_order_host_to_network(&int_value, grn_key, data_size);
int max_bit = (data_size * 8 - 1);
*((int *)mysql_key) =
int_value ^ (((int_value ^ (1 << max_bit)) >> max_bit) |
(1 << max_bit));
DBUG_VOID_RETURN;
}
void MultipleColumnKeyCodec::encode_double(volatile double value, uint data_size,
uchar *grn_key) {
MRN_DBUG_ENTER_METHOD();
int n_bits = (data_size * 8 - 1);
volatile long long int *long_long_value_pointer = (long long int *)(&value);
volatile long long int long_long_value = *long_long_value_pointer;
long_long_value ^= ((long_long_value >> n_bits) | (1LL << n_bits));
mrn_byte_order_host_to_network(grn_key, &long_long_value, data_size);
DBUG_VOID_RETURN;
}
void MultipleColumnKeyCodec::decode_double(const uchar *grn_key,
uchar *mysql_key,
uint data_size) {
MRN_DBUG_ENTER_METHOD();
long long int long_long_value;
mrn_byte_order_host_to_network(&long_long_value, grn_key, data_size);
int max_bit = (data_size * 8 - 1);
*((long long int *)mysql_key) =
long_long_value ^ (((long_long_value ^ (1LL << max_bit)) >> max_bit) |
(1LL << max_bit));
DBUG_VOID_RETURN;
}
void MultipleColumnKeyCodec::encode_reverse(const uchar *mysql_key, uint data_size,
uchar *grn_key) {
MRN_DBUG_ENTER_METHOD();
for (uint i = 0; i < data_size; i++) {
grn_key[i] = mysql_key[data_size - i - 1];
}
DBUG_VOID_RETURN;
}
void MultipleColumnKeyCodec::decode_reverse(const uchar *grn_key,
uchar *mysql_key,
uint data_size) {
MRN_DBUG_ENTER_METHOD();
for (uint i = 0; i < data_size; i++) {
mysql_key[i] = grn_key[data_size - i - 1];
}
DBUG_VOID_RETURN;
}
void MultipleColumnKeyCodec::encode_blob(Field *field,
const uchar *mysql_key,
uchar *grn_key,
uint *data_size) {
FieldNormalizer normalizer(ctx_, thread_, field);
if (normalizer.should_normalize()) {
#if HA_KEY_BLOB_LENGTH != 2
# error "TODO: support HA_KEY_BLOB_LENGTH != 2 case if it is needed"
#endif
const char *blob_data =
reinterpret_cast<const char *>(mysql_key + HA_KEY_BLOB_LENGTH);
uint16 blob_data_length = *((uint16 *)(mysql_key));
grn_obj *grn_string = normalizer.normalize(blob_data,
blob_data_length);
mrn::SmartGrnObj smart_grn_string(ctx_, grn_string);
const char *normalized;
unsigned int normalized_length = 0;
grn_string_get_normalized(ctx_, grn_string,
&normalized, &normalized_length, NULL);
uint16 new_blob_data_length;
if (normalized_length <= UINT_MAX16) {
memcpy(grn_key, normalized, normalized_length);
if (normalized_length < *data_size) {
memset(grn_key + normalized_length,
'\0', *data_size - normalized_length);
}
new_blob_data_length = normalized_length;
} else {
push_warning_printf(thread_,
Sql_condition::WARN_LEVEL_WARN,
WARN_DATA_TRUNCATED,
"normalized data truncated "
"for multiple column index: "
"normalized-data-size: <%u> "
"max-data-size: <%u> "
"column-name: <%s> "
"data: <%.*s>",
normalized_length,
UINT_MAX16,
field->field_name,
blob_data_length, blob_data);
memcpy(grn_key, normalized, blob_data_length);
new_blob_data_length = blob_data_length;
}
memcpy(grn_key + *data_size, &new_blob_data_length, HA_KEY_BLOB_LENGTH);
} else {
memcpy(grn_key + *data_size, mysql_key, HA_KEY_BLOB_LENGTH);
memcpy(grn_key, mysql_key + HA_KEY_BLOB_LENGTH, *data_size);
}
*data_size += HA_KEY_BLOB_LENGTH;
}
}

View File

@@ -0,0 +1,70 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2012-2013 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_MULTIPLE_COLUMN_KEY_CODEC_HPP_
#define MRN_MULTIPLE_COLUMN_KEY_CODEC_HPP_
#include <groonga.h>
#include <mrn_mysql.h>
#include <mrn_mysql_compat.h>
namespace mrn {
class MultipleColumnKeyCodec {
public:
MultipleColumnKeyCodec(grn_ctx *ctx, THD *thread, KEY *key_info);
~MultipleColumnKeyCodec();
int encode(const uchar *mysql_key, uint mysql_key_length,
uchar *grn_key, uint *grn_key_length);
int decode(const uchar *grn_key, uint grn_key_length,
uchar *mysql_key, uint *mysql_key_length);
uint size();
private:
enum DataType {
TYPE_UNKNOWN,
TYPE_LONG_LONG_NUMBER,
TYPE_NUMBER,
TYPE_FLOAT,
TYPE_DOUBLE,
TYPE_BYTE_SEQUENCE,
TYPE_BYTE_REVERSE,
TYPE_BYTE_BLOB
};
grn_ctx *ctx_;
THD *thread_;
KEY *key_info_;
void get_key_info(KEY_PART_INFO *key_part,
DataType *data_type, uint *data_size);
void encode_float(volatile float value, uint data_size, uchar *grn_key);
void decode_float(const uchar *grn_key, uchar *mysql_key, uint data_size);
void encode_double(volatile double value, uint data_size, uchar *grn_key);
void decode_double(const uchar *grn_key, uchar *mysql_key, uint data_size);
void encode_reverse(const uchar *mysql_key, uint data_size, uchar *grn_key);
void decode_reverse(const uchar *grn_key, uchar *mysql_key, uint data_size);
void encode_blob(Field *field,
const uchar *mysql_key, uchar *grn_key, uint *data_size);
};
}
#endif // MRN_MULTIPLE_COLUMN_KEY_CODEC_HPP_

View File

@@ -0,0 +1,32 @@
/* -*- c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Copyright(C) 2011-2013 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
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <mrn_mysql.h>
#include <mrn_mysql_compat.h>
/*
void *thd_alloc(MYSQL_THD thd, unsigned int size)
{
return thd->alloc(size);
}
*/

View File

@@ -0,0 +1,176 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2011-2013 Kentoku SHIBA
Copyright(C) 2011-2013 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_parameters_parser.hpp"
#include <mrn_mysql_compat.h>
namespace mrn {
class Parameter {
public:
char *key_;
char *value_;
Parameter(const char *key, unsigned int key_length,
const char *value, unsigned int value_length)
: key_(my_strndup(key, key_length, MYF(0))),
value_(my_strndup(value, value_length, MYF(0))) {
};
~Parameter() {
if (key_) {
my_free(key_, MYF(0));
}
if (value_) {
my_free(value_, MYF(0));
}
};
};
ParametersParser::ParametersParser(const char *input,
unsigned int input_length)
: input_(input),
input_length_(input_length),
parameters_(NULL) {
}
ParametersParser::~ParametersParser() {
for (LIST *next = parameters_; next; next = next->next) {
Parameter *parameter = static_cast<Parameter *>(next->data);
delete parameter;
}
list_free(parameters_, false);
}
void ParametersParser::parse() {
const char *current = input_;
const char *end = input_ + input_length_;
for (; current < end; ++current) {
if (is_white_space(current[0])) {
continue;
}
const char *key = current;
unsigned int key_length = 0;
while (current < end &&
!is_white_space(current[0]) &&
current[0] != '\'' && current[0] != '"' && current[0] != ',') {
++current;
++key_length;
}
if (current == end) {
break;
}
while (current < end && is_white_space(current[0])) {
++current;
}
if (current == end) {
break;
}
current = parse_value(current, end, key, key_length);
if (!current) {
break;
}
while (current < end && is_white_space(current[0])) {
++current;
}
if (current == end) {
break;
}
if (current[0] != ',') {
// TODO: report error
break;
}
}
}
const char *ParametersParser::parse_value(const char *current,
const char *end,
const char *key,
unsigned int key_length) {
char quote = current[0];
if (quote != '\'' && quote != '"') {
// TODO: report error
return NULL;
}
++current;
bool found = false;
static const unsigned int max_value_length = 4096;
char value[max_value_length];
unsigned int value_length = 0;
for (; current < end && value_length < max_value_length; ++current) {
if (current[0] == quote) {
Parameter *parameter = new Parameter(key, key_length,
value, value_length);
list_push(parameters_, parameter);
found = true;
++current;
break;
}
switch (current[0]) {
case '\\':
if (current + 1 == end) {
break;
}
switch (current[1]) {
case 'b':
value[value_length] = '\b';
break;
case 'n':
value[value_length] = '\n';
break;
case 'r':
value[value_length] = '\r';
break;
case 't':
value[value_length] = '\t';
break;
default:
value[value_length] = current[1];
break;
}
break;
default:
value[value_length] = current[0];
break;
}
++value_length;
}
if (!found) {
// TODO: report error
}
return current;
}
const char *ParametersParser::operator[](const char *key) {
for (LIST *next = parameters_; next; next = next->next) {
Parameter *parameter = static_cast<Parameter *>(next->data);
if (strcasecmp(parameter->key_, key) == 0) {
return parameter->value_;
}
}
return NULL;
}
}

View File

@@ -0,0 +1,59 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2011-2013 Kentoku SHIBA
Copyright(C) 2011-2013 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_PARAMETERS_PARSER_HPP_
#define MRN_PARAMETERS_PARSER_HPP_
#include <mrn_mysql.h>
#include <my_list.h>
namespace mrn {
class ParametersParser {
public:
ParametersParser(const char *input, unsigned int input_length);
~ParametersParser();
void parse();
const char *operator[](const char *key);
private:
const char *input_;
unsigned int input_length_;
LIST *parameters_;
bool is_white_space(char character) {
switch (character) {
case ' ':
case '\r':
case '\n':
case '\t':
return true;
break;
default:
return false;
break;
}
};
const char *parse_value(const char *current, const char *end,
const char *key, unsigned int key_length);
};
}
#endif /* MRN_PARAMETERS_PARSER_HPP_ */

View File

@@ -0,0 +1,196 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2010 Tetsuro IKEDA
Copyright(C) 2011-2013 Kentoku SHIBA
Copyright(C) 2011-2012 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
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "mrn_path_mapper.hpp"
#include <string.h>
#include <mrn_mysql.h>
namespace mrn {
char *PathMapper::default_path_prefix = NULL;
char *PathMapper::default_mysql_data_home_path = NULL;
PathMapper::PathMapper(const char *mysql_path,
const char *path_prefix,
const char *mysql_data_home_path)
: mysql_path_(mysql_path),
path_prefix_(path_prefix),
mysql_data_home_path_(mysql_data_home_path) {
db_path_[0] = '\0';
db_name_[0] = '\0';
table_name_[0] = '\0';
mysql_table_name_[0] = '\0';
}
/**
* "./${db}/${table}" ==> "${db}.mrn"
* "./${db}/" ==> "${db}.mrn"
* "/tmp/mysql-test/var/tmp/mysqld.1/#sql27c5_1_0" ==>
* "/tmp/mysql-test/var/tmp/mysqld.1/#sql27c5_1_0.mrn"
*/
const char *PathMapper::db_path() {
if (db_path_[0] != '\0') {
return db_path_;
}
if (mysql_path_[0] == FN_CURLIB && mysql_path_[1] == FN_LIBCHAR) {
if (path_prefix_) {
strcpy(db_path_, path_prefix_);
}
int i = 2, j = strlen(db_path_), len;
len = strlen(mysql_path_);
while (mysql_path_[i] != FN_LIBCHAR && i < len) {
db_path_[j++] = mysql_path_[i++];
}
db_path_[j] = '\0';
} else if (mysql_data_home_path_) {
int len = strlen(mysql_path_);
int mysql_data_home_len = strlen(mysql_data_home_path_);
if (len > mysql_data_home_len &&
!strncmp(mysql_path_, mysql_data_home_path_, mysql_data_home_len)) {
int i = mysql_data_home_len, j;
if (path_prefix_ && path_prefix_[0] == FN_LIBCHAR) {
strcpy(db_path_, path_prefix_);
j = strlen(db_path_);
} else {
memcpy(db_path_, mysql_data_home_path_, mysql_data_home_len);
if (path_prefix_) {
if (path_prefix_[0] == FN_CURLIB &&
path_prefix_[1] == FN_LIBCHAR) {
strcpy(&db_path_[mysql_data_home_len], &path_prefix_[2]);
} else {
strcpy(&db_path_[mysql_data_home_len], path_prefix_);
}
j = strlen(db_path_);
} else {
j = mysql_data_home_len;
}
}
while (mysql_path_[i] != FN_LIBCHAR && i < len) {
db_path_[j++] = mysql_path_[i++];
}
if (i == len) {
memcpy(db_path_, mysql_path_, len);
} else {
db_path_[j] = '\0';
}
} else {
strcpy(db_path_, mysql_path_);
}
} else {
strcpy(db_path_, mysql_path_);
}
strcat(db_path_, MRN_DB_FILE_SUFFIX);
return db_path_;
}
/**
* "./${db}/${table}" ==> "${db}"
* "./${db}/" ==> "${db}"
* "/tmp/mysql-test/var/tmp/mysqld.1/#sql27c5_1_0" ==>
* "/tmp/mysql-test/var/tmp/mysqld.1/#sql27c5_1_0"
*/
const char *PathMapper::db_name() {
if (db_name_[0] != '\0') {
return db_name_;
}
if (mysql_path_[0] == FN_CURLIB && mysql_path_[1] == FN_LIBCHAR) {
int i = 2, j = 0, len;
len = strlen(mysql_path_);
while (mysql_path_[i] != FN_LIBCHAR && i < len) {
db_name_[j++] = mysql_path_[i++];
}
db_name_[j] = '\0';
} else if (mysql_data_home_path_) {
int len = strlen(mysql_path_);
int mysql_data_home_len = strlen(mysql_data_home_path_);
if (len > mysql_data_home_len &&
!strncmp(mysql_path_, mysql_data_home_path_, mysql_data_home_len)) {
int i = mysql_data_home_len, j = 0;
while (mysql_path_[i] != FN_LIBCHAR && i < len) {
db_name_[j++] = mysql_path_[i++];
}
if (i == len) {
memcpy(db_name_, mysql_path_, len);
} else {
db_name_[j] = '\0';
}
} else {
strcpy(db_name_, mysql_path_);
}
} else {
strcpy(db_name_, mysql_path_);
}
return db_name_;
}
/**
* "./${db}/${table}" ==> "${table}" (with encoding first '_')
*/
const char *PathMapper::table_name() {
if (table_name_[0] != '\0') {
return table_name_;
}
int len = strlen(mysql_path_);
int i = len, j = 0;
for (; mysql_path_[--i] != FN_LIBCHAR ;) {}
if (mysql_path_[i + 1] == '_') {
table_name_[j++] = '@';
table_name_[j++] = '0';
table_name_[j++] = '0';
table_name_[j++] = '5';
table_name_[j++] = 'f';
i++;
}
for (; i < len ;) {
table_name_[j++] = mysql_path_[++i];
}
table_name_[j] = '\0';
return table_name_;
}
/**
* "./${db}/${table}" ==> "${table}" (without encoding first '_')
*/
const char *PathMapper::mysql_table_name() {
if (mysql_table_name_[0] != '\0') {
return mysql_table_name_;
}
int len = strlen(mysql_path_);
int i = len, j = 0;
for (; mysql_path_[--i] != FN_LIBCHAR ;) {}
for (; i < len ;) {
mysql_table_name_[j++] = mysql_path_[++i];
}
mysql_table_name_[j] = '\0';
return mysql_table_name_;
}
}

View File

@@ -0,0 +1,51 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2010 Tetsuro IKEDA
Copyright(C) 2010-2013 Kentoku SHIBA
Copyright(C) 2011-2012 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_PATH_MAPPER_HPP_
#define MRN_PATH_MAPPER_HPP_
#include <mrn_constants.hpp>
namespace mrn {
class PathMapper {
public:
static char *default_path_prefix;
static char *default_mysql_data_home_path;
PathMapper(const char *mysql_path,
const char *path_prefix=default_path_prefix,
const char *mysql_data_home_path=default_mysql_data_home_path);
const char *db_path();
const char *db_name();
const char *table_name();
const char *mysql_table_name();
private:
const char *mysql_path_;
const char *path_prefix_;
const char *mysql_data_home_path_;
char db_path_[MRN_MAX_PATH_SIZE];
char db_name_[MRN_MAX_PATH_SIZE];
char table_name_[MRN_MAX_PATH_SIZE];
char mysql_table_name_[MRN_MAX_PATH_SIZE];
};
}
#endif /* MRN_PATH_MAPPER_HPP_ */

View File

@@ -0,0 +1,53 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2014 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 <string.h>
#include "mrn_smart_grn_obj.hpp"
namespace mrn {
SmartGrnObj::SmartGrnObj(grn_ctx *ctx, grn_obj *obj)
: ctx_(ctx),
obj_(obj) {
}
SmartGrnObj::SmartGrnObj(grn_ctx *ctx, const char *name, int name_size)
: ctx_(ctx),
obj_(NULL) {
if (name_size < 0) {
name_size = strlen(name);
}
obj_ = grn_ctx_get(ctx_, name, name_size);
}
SmartGrnObj::SmartGrnObj(grn_ctx *ctx, grn_id id)
: ctx_(ctx),
obj_(grn_ctx_at(ctx_, id)) {
}
SmartGrnObj::~SmartGrnObj() {
if (obj_) {
grn_obj_unlink(ctx_, obj_);
}
}
grn_obj *SmartGrnObj::get() {
return obj_;
}
}

View File

@@ -0,0 +1,39 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2014 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_SMART_GRN_OBJ_HPP_
#define MRN_SMART_GRN_OBJ_HPP_
#include <groonga.h>
namespace mrn {
class SmartGrnObj {
grn_ctx *ctx_;
grn_obj *obj_;
public:
SmartGrnObj(grn_ctx *ctx, grn_obj *obj);
SmartGrnObj(grn_ctx *ctx, const char *name, int name_size=-1);
SmartGrnObj(grn_ctx *ctx, grn_id id);
~SmartGrnObj();
grn_obj *get();
};
}
#endif // MRN_SMART_GRN_OBJ_HPP_

View File

@@ -0,0 +1,260 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2010-2013 Kentoku SHIBA
Copyright(C) 2011-2013 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
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "mrn_time_converter.hpp"
#ifdef min
# undef min
#endif
#ifdef max
# undef max
#endif
#include <limits>
// for debug
#define MRN_CLASS_NAME "mrn::TimeConverter"
namespace mrn {
TimeConverter::TimeConverter() {
}
TimeConverter::~TimeConverter() {
}
time_t TimeConverter::tm_to_time_gm(struct tm *time, bool *truncated) {
MRN_DBUG_ENTER_METHOD();
*truncated = true;
struct tm gmdate;
time->tm_yday = -1;
time->tm_isdst = -1;
time_t sec_t = mktime(time);
if (time->tm_yday == -1) {
DBUG_RETURN(-1);
}
if (!gmtime_r(&sec_t, &gmdate)) {
DBUG_RETURN(-1);
}
int32 mrn_utc_diff_in_seconds =
(
time->tm_mday > 25 && gmdate.tm_mday == 1 ? -1 :
time->tm_mday == 1 && gmdate.tm_mday > 25 ? 1 :
time->tm_mday - gmdate.tm_mday
) * 24 * 60 * 60 +
(time->tm_hour - gmdate.tm_hour) * 60 * 60 +
(time->tm_min - gmdate.tm_min) * 60 +
(time->tm_sec - gmdate.tm_sec);
DBUG_PRINT("info", ("mroonga: time->tm_year=%d", time->tm_year));
DBUG_PRINT("info", ("mroonga: time->tm_mon=%d", time->tm_mon));
DBUG_PRINT("info", ("mroonga: time->tm_mday=%d", time->tm_mday));
DBUG_PRINT("info", ("mroonga: time->tm_hour=%d", time->tm_hour));
DBUG_PRINT("info", ("mroonga: time->tm_min=%d", time->tm_min));
DBUG_PRINT("info", ("mroonga: time->tm_sec=%d", time->tm_sec));
DBUG_PRINT("info", ("mroonga: mrn_utc_diff_in_seconds=%d",
mrn_utc_diff_in_seconds));
if (mrn_utc_diff_in_seconds > 0) {
if (sec_t > std::numeric_limits<time_t>::max() - mrn_utc_diff_in_seconds) {
DBUG_RETURN(-1);
}
} else {
if (sec_t < std::numeric_limits<time_t>::min() - mrn_utc_diff_in_seconds) {
DBUG_RETURN(-1);
}
}
*truncated = false;
DBUG_RETURN(sec_t + mrn_utc_diff_in_seconds);
}
long long int TimeConverter::tm_to_grn_time(struct tm *time, int usec,
bool *truncated) {
MRN_DBUG_ENTER_METHOD();
long long int sec = tm_to_time_gm(time, truncated);
DBUG_PRINT("info", ("mroonga: sec=%lld", sec));
DBUG_PRINT("info", ("mroonga: usec=%d", usec));
long long int grn_time = *truncated ? 0 : GRN_TIME_PACK(sec, usec);
DBUG_RETURN(grn_time);
}
long long int TimeConverter::mysql_time_to_grn_time(MYSQL_TIME *mysql_time,
bool *truncated) {
MRN_DBUG_ENTER_METHOD();
int usec = mysql_time->second_part;
long long int grn_time = 0;
*truncated = false;
switch (mysql_time->time_type) {
case MYSQL_TIMESTAMP_DATE:
{
DBUG_PRINT("info", ("mroonga: MYSQL_TIMESTAMP_DATE"));
struct tm date;
memset(&date, 0, sizeof(struct tm));
date.tm_year = mysql_time->year - TM_YEAR_BASE;
if (mysql_time->month > 0) {
date.tm_mon = mysql_time->month - 1;
} else {
date.tm_mon = 0;
*truncated = true;
}
if (mysql_time->day > 0) {
date.tm_mday = mysql_time->day;
} else {
date.tm_mday = 1;
*truncated = true;
}
DBUG_PRINT("info", ("mroonga: tm_year=%d", date.tm_year));
DBUG_PRINT("info", ("mroonga: tm_mon=%d", date.tm_mon));
DBUG_PRINT("info", ("mroonga: tm_mday=%d", date.tm_mday));
bool tm_truncated = false;
grn_time = tm_to_grn_time(&date, usec, &tm_truncated);
if (tm_truncated) {
*truncated = true;
}
}
break;
case MYSQL_TIMESTAMP_DATETIME:
{
DBUG_PRINT("info", ("mroonga: MYSQL_TIMESTAMP_DATETIME"));
struct tm datetime;
memset(&datetime, 0, sizeof(struct tm));
datetime.tm_year = mysql_time->year - TM_YEAR_BASE;
if (mysql_time->month > 0) {
datetime.tm_mon = mysql_time->month - 1;
} else {
datetime.tm_mon = 0;
*truncated = true;
}
if (mysql_time->day > 0) {
datetime.tm_mday = mysql_time->day;
} else {
datetime.tm_mday = 1;
*truncated = true;
}
datetime.tm_hour = mysql_time->hour;
datetime.tm_min = mysql_time->minute;
datetime.tm_sec = mysql_time->second;
DBUG_PRINT("info", ("mroonga: tm_year=%d", datetime.tm_year));
DBUG_PRINT("info", ("mroonga: tm_mon=%d", datetime.tm_mon));
DBUG_PRINT("info", ("mroonga: tm_mday=%d", datetime.tm_mday));
DBUG_PRINT("info", ("mroonga: tm_hour=%d", datetime.tm_hour));
DBUG_PRINT("info", ("mroonga: tm_min=%d", datetime.tm_min));
DBUG_PRINT("info", ("mroonga: tm_sec=%d", datetime.tm_sec));
bool tm_truncated = false;
grn_time = tm_to_grn_time(&datetime, usec, &tm_truncated);
if (tm_truncated) {
*truncated = true;
}
}
break;
case MYSQL_TIMESTAMP_TIME:
{
DBUG_PRINT("info", ("mroonga: MYSQL_TIMESTAMP_TIME"));
int sec =
mysql_time->hour * 60 * 60 +
mysql_time->minute * 60 +
mysql_time->second;
DBUG_PRINT("info", ("mroonga: sec=%d", sec));
grn_time = GRN_TIME_PACK(sec, usec);
if (mysql_time->neg) {
grn_time = -grn_time;
}
}
break;
default:
DBUG_PRINT("info", ("mroonga: default"));
grn_time = 0;
break;
}
DBUG_RETURN(grn_time);
}
void TimeConverter::grn_time_to_mysql_time(long long int grn_time,
MYSQL_TIME *mysql_time) {
MRN_DBUG_ENTER_METHOD();
long long int sec;
int usec;
GRN_TIME_UNPACK(grn_time, sec, usec);
DBUG_PRINT("info", ("mroonga: sec=%lld", sec));
DBUG_PRINT("info", ("mroonga: usec=%d", usec));
switch (mysql_time->time_type) {
case MYSQL_TIMESTAMP_DATE:
{
DBUG_PRINT("info", ("mroonga: MYSQL_TIMESTAMP_DATE"));
struct tm date;
time_t sec_t = sec;
// TODO: Add error check
gmtime_r(&sec_t, &date);
DBUG_PRINT("info", ("mroonga: tm_year=%d", date.tm_year));
mysql_time->year = date.tm_year + TM_YEAR_BASE;
DBUG_PRINT("info", ("mroonga: tm_mon=%d", date.tm_mon));
mysql_time->month = date.tm_mon + 1;
DBUG_PRINT("info", ("mroonga: tm_mday=%d", date.tm_mday));
mysql_time->day = date.tm_mday;
}
break;
case MYSQL_TIMESTAMP_DATETIME:
{
DBUG_PRINT("info", ("mroonga: MYSQL_TIMESTAMP_DATETIME"));
struct tm date;
time_t sec_t = sec;
// TODO: Add error check
gmtime_r(&sec_t, &date);
DBUG_PRINT("info", ("mroonga: tm_year=%d", date.tm_year));
mysql_time->year = date.tm_year + TM_YEAR_BASE;
DBUG_PRINT("info", ("mroonga: tm_mon=%d", date.tm_mon));
mysql_time->month = date.tm_mon + 1;
DBUG_PRINT("info", ("mroonga: tm_mday=%d", date.tm_mday));
mysql_time->day = date.tm_mday;
DBUG_PRINT("info", ("mroonga: tm_hour=%d", date.tm_hour));
mysql_time->hour = date.tm_hour;
DBUG_PRINT("info", ("mroonga: tm_min=%d", date.tm_min));
mysql_time->minute = date.tm_min;
DBUG_PRINT("info", ("mroonga: tm_sec=%d", date.tm_sec));
mysql_time->second = date.tm_sec;
mysql_time->second_part = usec;
}
break;
case MYSQL_TIMESTAMP_TIME:
DBUG_PRINT("info", ("mroonga: MYSQL_TIMESTAMP_TIME"));
if (sec < 0) {
mysql_time->neg = true;
sec = -sec;
}
mysql_time->hour = static_cast<unsigned int>(sec / 60 / 60);
mysql_time->minute = sec / 60 % 60;
mysql_time->second = sec % 60;
mysql_time->second_part = usec;
break;
default:
DBUG_PRINT("info", ("mroonga: default"));
break;
}
DBUG_VOID_RETURN;
}
}

View File

@@ -0,0 +1,47 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2010-2013 Kentoku SHIBA
Copyright(C) 2011-2013 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_TIME_CONVERTER_HPP_
#define MRN_TIME_CONVERTER_HPP_
#include <groonga.h>
#include <mrn_mysql_compat.h>
namespace mrn {
class TimeConverter {
public:
static const long long int TM_YEAR_BASE = 1900;
TimeConverter();
~TimeConverter();
long long int mysql_time_to_grn_time(MYSQL_TIME *mysql_time,
bool *truncated);
long long int tm_to_grn_time(struct tm *time, int usec, bool *truncated);
void grn_time_to_mysql_time(long long int grn_time, MYSQL_TIME *mysql_time);
private:
time_t tm_to_time_gm(struct tm *time, bool *truncated);
};
}
#endif /* MRN_TIME_CONVERTER_HPP_ */

View File

@@ -0,0 +1,31 @@
/* -*- c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Copyright(C) 2010 Tetsuro IKEDA
Copyright(C) 2010-2013 Kentoku SHIBA
Copyright(C) 2011-2013 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_WINDOWS_HPP_
#define MRN_WINDOWS_HPP_
#if defined(_WIN32) || defined(_WIN64)
# define MRN_API __declspec(dllexport)
#else
# define MRN_API
#endif
#endif /* MRN_WINDOWS_HPP_ */

View File

@@ -0,0 +1,47 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2010 Tetsuro IKEDA
Copyright(C) 2011 Kentoku SHIBA
Copyright(C) 2011-2012 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_CONSTANTS_HPP_
#define MRN_CONSTANTS_HPP_
#include <groonga.h>
#define MRN_BUFFER_SIZE 1024
#define MRN_MAX_KEY_SIZE GRN_TABLE_MAX_KEY_SIZE
#if defined(MAX_PATH)
# define MRN_MAX_PATH_SIZE (MAX_PATH + 1)
#elif defined(PATH_MAX)
# define MRN_MAX_PATH_SIZE (PATH_MAX)
#elif defined(MAXPATHLEN)
# define MRN_MAX_PATH_SIZE (MAXPATHLEN)
#else
# define MRN_MAX_PATH_SIZE (256)
#endif
#define MRN_DB_FILE_SUFFIX ".mrn"
#define MRN_LOG_FILE_PATH "groonga.log"
#define MRN_COLUMN_NAME_ID "_id"
#define MRN_COLUMN_NAME_KEY "_key"
#define MRN_COLUMN_NAME_SCORE "_score"
#ifndef MRN_PARSER_DEFAULT
# define MRN_PARSER_DEFAULT "TokenBigram"
#endif
#endif /* MRN_CONSTANTS_HPP_ */

32
storage/mroonga/mrn_err.h Normal file
View File

@@ -0,0 +1,32 @@
/* Copyright(C) 2011 Kentoku SHIBA
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_ERR_H_
#define MRN_ERR_H_
#define ER_MRN_INVALID_TABLE_PARAM_NUM 16501
#define ER_MRN_INVALID_TABLE_PARAM_STR "The table parameter '%-.64s' is invalid"
#define ER_MRN_CHARSET_NOT_SUPPORT_NUM 16502
#define ER_MRN_CHARSET_NOT_SUPPORT_STR "The character set '%s[%s]' is not supported by groonga"
#define ER_MRN_GEOMETRY_NOT_SUPPORT_NUM 16503
#define ER_MRN_GEOMETRY_NOT_SUPPORT_STR "This geometry type is not supported. Groonga is supported point only"
#define ER_MRN_ERROR_FROM_GROONGA_NUM 16504
#define ER_MRN_ERROR_FROM_GROONGA_STR "Error from Groonga [%s]"
#define ER_MRN_INVALID_NULL_VALUE_NUM 16505
#define ER_MRN_INVALID_NULL_VALUE_STR "NULL value can't be used for %s"
#endif /* MRN_ERR_H_ */

View File

@@ -0,0 +1,30 @@
/*
Copyright(C) 2012 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_MACRO_HPP_
#define MRN_MACRO_HPP_
#ifdef __cplusplus
# define MRN_BEGIN_DECLS extern "C" {
# define MRN_END_DECLS }
#else
# define MRN_BEGIN_DECLS
# define MRN_END_DECLS
#endif
#endif /* MRN_MACRO_HPP_ */

View File

@@ -0,0 +1,83 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2011-2013 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_MYSQL_H_
#define MRN_MYSQL_H_
#ifdef HAVE_CONFIG_H
# include <config.h>
/* We need to undefine them because my_config.h defines them. :< */
# undef VERSION
# undef PACKAGE
# undef PACKAGE_BUGREPORT
# undef PACKAGE_NAME
# undef PACKAGE_STRING
# undef PACKAGE_TARNAME
# undef PACKAGE_VERSION
#endif
#include <mrn_version.h>
#ifdef FORCE_FAST_MUTEX_DISABLED
# ifdef MY_PTHREAD_FASTMUTEX
# undef MY_PTHREAD_FASTMUTEX
# endif
#endif
#define MYSQL_SERVER 1
#include <mysql_version.h>
#if MYSQL_VERSION_ID < 50500
# include <mysql_priv.h>
# include <mysql/plugin.h>
#else
# include <sql_priv.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
#if MYSQL_VERSION_ID >= 50607
# if !defined(MRN_MARIADB_P)
# define MRN_HAVE_SQL_OPTIMIZER_H
# endif
#endif
#define MRN_MESSAGE_BUFFER_SIZE 1024
#define MRN_DBUG_ENTER_FUNCTION() DBUG_ENTER(__FUNCTION__)
#if !defined(DBUG_OFF) && !defined(_lint)
# define MRN_DBUG_ENTER_METHOD() \
char method_name[MRN_MESSAGE_BUFFER_SIZE]; \
method_name[0] = '\0'; \
strcat(method_name, MRN_CLASS_NAME); \
strcat(method_name, "::"); \
strcat(method_name, __FUNCTION__); \
DBUG_ENTER(method_name)
#else
# define MRN_DBUG_ENTER_METHOD() MRN_DBUG_ENTER_FUNCTION()
#endif
#endif /* MRN_MYSQL_H_ */

View File

@@ -0,0 +1,143 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2011-2013 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_MYSQL_COMPAT_H_
#define MRN_MYSQL_COMPAT_H_
#include "mrn_mysql.h"
#if MYSQL_VERSION_ID >= 50500
# define my_free(PTR, FLAG) my_free(PTR)
#endif
#if MYSQL_VERSION_ID < 50500
# define mysql_mutex_lock(mutex) pthread_mutex_lock(mutex)
# define mysql_mutex_unlock(mutex) pthread_mutex_unlock(mutex)
#endif
#if MYSQL_VERSION_ID >= 50604
# define MRN_HAVE_MYSQL_TYPE_TIMESTAMP2
# define MRN_HAVE_MYSQL_TYPE_DATETIME2
# define MRN_HAVE_MYSQL_TYPE_TIME2
#endif
#if MYSQL_VERSION_ID < 50603
typedef MYSQL_ERROR Sql_condition;
#endif
#if defined(MRN_MARIADB_P)
# if MYSQL_VERSION_ID >= 50302 && MYSQL_VERSION_ID < 100000
typedef COST_VECT Cost_estimate;
# endif
#endif
#if MYSQL_VERSION_ID >= 50516
# define MRN_PLUGIN_HAVE_FLAGS 1
#endif
// for MySQL < 5.5
#ifndef MY_ALL_CHARSETS_SIZE
# define MY_ALL_CHARSETS_SIZE 256
#endif
#ifndef MRN_MARIADB_P
typedef char *range_id_t;
#endif
#if MYSQL_VERSION_ID >= 50609
# define MRN_KEY_HAS_USER_DEFINED_KEYPARTS
#endif
#ifdef MRN_KEY_HAS_USER_DEFINED_KEYPARTS
# define KEY_N_KEY_PARTS(key) (key)->user_defined_key_parts
#else
# define KEY_N_KEY_PARTS(key) (key)->key_parts
#endif
#if MYSQL_VERSION_ID < 100000 || !defined(MRN_MARIADB_P)
# define init_alloc_root(PTR, SZ1, SZ2, FLAG) init_alloc_root(PTR, SZ1, SZ2)
#endif
#if MYSQL_VERSION_ID < 100002 || !defined(MRN_MARIADB_P)
# define GTS_TABLE 0
#endif
/* For MySQL 5.1. MySQL 5.1 doesn't have FN_LIBCHAR2. */
#ifndef FN_LIBCHAR2
# define FN_LIBCHAR2 FN_LIBCHAR
#endif
#if MYSQL_VERSION_ID >= 50607
# if MYSQL_VERSION_ID >= 100007 && defined(MRN_MARIADB_P)
# define MRN_GET_ERROR_MESSAGE thd_get_error_message(current_thd)
# define MRN_GET_CURRENT_ROW_FOR_WARNING(thd) thd_get_error_row(thd)
# else
# define MRN_GET_ERROR_MESSAGE current_thd->get_stmt_da()->message()
# define MRN_GET_CURRENT_ROW_FOR_WARNING(thd) thd->get_stmt_da()->current_row_for_warning()
# endif
#else
# if MYSQL_VERSION_ID >= 50500
# define MRN_GET_ERROR_MESSAGE current_thd->stmt_da->message()
# define MRN_GET_CURRENT_ROW_FOR_WARNING(thd) thd->warning_info->current_row_for_warning()
# else
# define MRN_GET_ERROR_MESSAGE current_thd->main_da.message()
# define MRN_GET_CURRENT_ROW_FOR_WARNING(thd) thd->row_count
# endif
#endif
#if MYSQL_VERSION_ID >= 50607 && !defined(MRN_MARIADB_P)
# define MRN_ITEM_HAVE_ITEM_NAME
#endif
#if MYSQL_VERSION_ID >= 50500 && MYSQL_VERSION_ID < 50700
# define MRN_HAVE_TABLE_DEF_CACHE
#endif
#if defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100009
# define MRN_HAVE_TDC_ACQUIRE_SHARE
#endif
#if MYSQL_VERSION_ID >= 50613
# define MRN_HAVE_ALTER_INFO
#endif
#if MYSQL_VERSION_ID >= 50603
# define MRN_HAVE_GET_TABLE_DEF_KEY
#endif
#if defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100004
# define MRN_TABLE_SHARE_HAVE_LOCK_SHARE
#endif
#if MYSQL_VERSION_ID >= 50404
# define MRN_TABLE_SHARE_HAVE_LOCK_HA_DATA
#endif
#ifndef TIME_FUZZY_DATE
/* For MariaDB 10. */
# ifdef TIME_FUZZY_DATES
# define TIME_FUZZY_DATE TIME_FUZZY_DATES
# endif
#endif
#if MYSQL_VERSION_ID >= 100007 && defined(MRN_MARIADB_P)
# define MRN_USE_MYSQL_DATA_HOME
#endif
#endif /* MRN_MYSQL_COMPAT_H_ */

View File

@@ -0,0 +1,88 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2010 Tetsuro IKEDA
Copyright(C) 2011-2012 Kentoku SHIBA
Copyright(C) 2011 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
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "mrn_sys.hpp"
bool mrn_hash_put(grn_ctx *ctx, grn_hash *hash, const char *key, grn_obj *value)
{
int added;
bool succeed;
void *buf;
grn_hash_add(ctx, hash, (const char *)key, strlen(key), &buf, &added);
// duplicate check
if (added == 0) {
GRN_LOG(ctx, GRN_LOG_WARNING, "hash put duplicated (key=%s)", key);
succeed = false;
} else {
// store address of value
memcpy(buf, &value, sizeof(grn_obj *));
GRN_LOG(ctx, GRN_LOG_DEBUG, "hash put (key=%s)", key);
succeed = true;
}
return succeed;
}
bool mrn_hash_get(grn_ctx *ctx, grn_hash *hash, const char *key, grn_obj **value)
{
bool found;
grn_id id;
void *buf;
id = grn_hash_get(ctx, hash, (const char *)key, strlen(key), &buf);
// key not found
if (id == GRN_ID_NIL) {
GRN_LOG(ctx, GRN_LOG_DEBUG, "hash get not found (key=%s)", key);
found = false;
} else {
// restore address of value
memcpy(value, buf, sizeof(grn_obj *));
found = true;
}
return found;
}
bool mrn_hash_remove(grn_ctx *ctx, grn_hash *hash, const char *key)
{
bool succeed;
grn_rc rc;
grn_id id;
id = grn_hash_get(ctx, hash, (const char*) key, strlen(key), NULL);
if (id == GRN_ID_NIL) {
GRN_LOG(ctx, GRN_LOG_WARNING, "hash remove not found (key=%s)", key);
succeed = false;
} else {
rc = grn_hash_delete_by_id(ctx, hash, id, NULL);
if (rc != GRN_SUCCESS) {
GRN_LOG(ctx, GRN_LOG_ERROR, "hash remove error (key=%s)", key);
succeed = false;
} else {
GRN_LOG(ctx, GRN_LOG_DEBUG, "hash remove (key=%s)", key);
succeed = true;
}
}
return succeed;
}

View File

@@ -0,0 +1,36 @@
/*
Copyright(C) 2010 Tetsuro IKEDA
Copyright(C) 2011 Kentoku SHIBA
Copyright(C) 2011-2012 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_SYS_HPP_
#define MRN_SYS_HPP_
#include <groonga.h>
#include "mrn_macro.hpp"
MRN_BEGIN_DECLS
/* functions */
bool mrn_hash_put(grn_ctx *ctx, grn_hash *hash, const char *key, grn_obj *value);
bool mrn_hash_get(grn_ctx *ctx, grn_hash *hash, const char *key, grn_obj **value);
bool mrn_hash_remove(grn_ctx *ctx, grn_hash *hash, const char *key);
MRN_END_DECLS
#endif /* MRN_SYS_HPP_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,172 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2011-2013 Kentoku SHIBA
Copyright(C) 2011-2013 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_TABLE_HPP_
#define MRN_TABLE_HPP_
#ifdef __cplusplus
extern "C" {
#endif
#include <groonga.h>
typedef struct st_mroonga_long_term_share
{
char *table_name;
uint table_name_length;
// for auto_increment (storage mode only)
pthread_mutex_t auto_inc_mutex;
bool auto_inc_inited;
ulonglong auto_inc_value;
} MRN_LONG_TERM_SHARE;
typedef struct st_mroonga_share
{
char *table_name;
uint table_name_length;
uint use_count;
pthread_mutex_t mutex;
THR_LOCK lock;
TABLE_SHARE *table_share;
TABLE_SHARE *wrap_table_share;
MRN_LONG_TERM_SHARE *long_term_share;
char *engine;
int engine_length;
char *default_tokenizer;
int default_tokenizer_length;
plugin_ref plugin;
handlerton *hton;
char **index_table;
char **key_parser;
char **col_flags;
char **col_type;
uint *index_table_length;
uint *key_parser_length;
uint *col_flags_length;
uint *col_type_length;
uint *wrap_key_nr;
uint wrap_keys;
uint base_keys;
KEY *wrap_key_info;
KEY *base_key_info;
uint wrap_primary_key;
uint base_primary_key;
bool wrapper_mode;
bool disable_keys;
} MRN_SHARE;
struct st_mrn_alter_share
{
char path[FN_REFLEN + 1];
TABLE_SHARE *alter_share;
st_mrn_alter_share *next;
};
struct st_mrn_slot_data
{
grn_id last_insert_record_id;
st_mrn_alter_share *first_alter_share;
HA_CREATE_INFO *alter_create_info;
HA_CREATE_INFO *disable_keys_create_info;
char *alter_connect_string;
char *alter_comment;
};
#define MRN_SET_WRAP_ALTER_KEY(file, ha_alter_info) \
Alter_inplace_info::HA_ALTER_FLAGS base_handler_flags = ha_alter_info->handler_flags; \
KEY *base_key_info_buffer = ha_alter_info->key_info_buffer; \
uint base_key_count = ha_alter_info->key_count; \
uint base_index_drop_count = ha_alter_info->index_drop_count; \
KEY **base_index_drop_buffer = ha_alter_info->index_drop_buffer; \
uint base_index_add_count = ha_alter_info->index_add_count; \
uint *base_index_add_buffer = ha_alter_info->index_add_buffer; \
ha_alter_info->handler_flags = file->alter_handler_flags; \
ha_alter_info->key_info_buffer = file->alter_key_info_buffer; \
ha_alter_info->key_count = file->alter_key_count; \
ha_alter_info->index_drop_count = file->alter_index_drop_count; \
ha_alter_info->index_drop_buffer = &file->alter_index_drop_buffer; \
ha_alter_info->index_add_count = file->alter_index_add_count; \
ha_alter_info->index_add_buffer = file->alter_index_add_buffer;
#define MRN_SET_BASE_ALTER_KEY(share, table_share) \
ha_alter_info->handler_flags = base_handler_flags; \
ha_alter_info->key_info_buffer = base_key_info_buffer; \
ha_alter_info->key_count = base_key_count; \
ha_alter_info->index_drop_count = base_index_drop_count; \
ha_alter_info->index_drop_buffer = base_index_drop_buffer; \
ha_alter_info->index_add_count = base_index_add_count; \
ha_alter_info->index_add_buffer = base_index_add_buffer;
#define MRN_SET_WRAP_SHARE_KEY(share, table_share)
/*
table_share->keys = share->wrap_keys; \
table_share->key_info = share->wrap_key_info; \
table_share->primary_key = share->wrap_primary_key;
*/
#define MRN_SET_BASE_SHARE_KEY(share, table_share)
/*
table_share->keys = share->base_keys; \
table_share->key_info = share->base_key_info; \
table_share->primary_key = share->base_primary_key;
*/
#define MRN_SET_WRAP_TABLE_KEY(file, table) \
table->key_info = file->wrap_key_info; \
table->s = share->wrap_table_share;
#define MRN_SET_BASE_TABLE_KEY(file, table) \
table->key_info = file->base_key_info; \
table->s = share->table_share;
#ifdef WITH_PARTITION_STORAGE_ENGINE
void mrn_get_partition_info(const char *table_name, uint table_name_length,
const TABLE *table, partition_element **part_elem,
partition_element **sub_elem);
#endif
int mrn_parse_table_param(MRN_SHARE *share, TABLE *table);
bool mrn_is_geo_key(const KEY *key_info);
int mrn_add_index_param(MRN_SHARE *share, KEY *key_info, int i);
int mrn_parse_index_param(MRN_SHARE *share, TABLE *table);
int mrn_add_column_param(MRN_SHARE *share, Field *field, int i);
int mrn_parse_column_param(MRN_SHARE *share, TABLE *table);
MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error);
int mrn_free_share_alloc(MRN_SHARE *share);
int mrn_free_share(MRN_SHARE *share);
MRN_LONG_TERM_SHARE *mrn_get_long_term_share(const char *table_name,
uint table_name_length,
int *error);
void mrn_free_long_term_share(MRN_LONG_TERM_SHARE *long_term_share);
TABLE_SHARE *mrn_get_table_share(TABLE_LIST *table_list, int *error);
TABLE_SHARE *mrn_create_tmp_table_share(TABLE_LIST *table_list, const char *path,
int *error);
void mrn_free_tmp_table_share(TABLE_SHARE *table_share);
KEY *mrn_create_key_info_for_table(MRN_SHARE *share, TABLE *table, int *error);
void mrn_set_bitmap_by_key(MY_BITMAP *map, KEY *key_info);
st_mrn_slot_data *mrn_get_slot_data(THD *thd, bool can_create);
void mrn_clear_alter_share(THD *thd);
#ifdef __cplusplus
}
#endif
#endif /* MRN_TABLE_HPP_ */

View File

@@ -0,0 +1,40 @@
/*
Copyright(C) 2011 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_VERSION_H_
#define MRN_VERSION_H_
/* Define mroonga version in string */
#define MRN_VERSION "@MRN_VERSION@"
/* Define mroonga version in hex */
#define MRN_VERSION_IN_HEX @MRN_VERSION_IN_HEX@
/* Define mroonga major version */
#define MRN_VERSION_MAJOR @MRN_VERSION_MAJOR@
/* Define mroonga minor version */
#define MRN_VERSION_MINOR @MRN_VERSION_MINOR@
/* Define mroonga micro version */
#define MRN_VERSION_MICRO @MRN_VERSION_MICRO@
/* Define to the full name and version of this package. */
#define MRN_PACKAGE_STRING "@MRN_PACKAGE_STRING@"
#endif /* MRN_VERSION_H_ */

View File

@@ -0,0 +1,8 @@
dist-hook:
if [ -n "`find mroonga -name '*.reject'`" ]; then \
echo "reject files exist"; \
exit 1; \
fi
EXTRA_DIST = \
mroonga

View File

@@ -0,0 +1,19 @@
# Copyright(C) 2014 Kenji Maruyama <mmmaru777@gmail.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--disable_query_log
let $VERSION_COMPILE_OS_FREEBSD=`SELECT IF(@@version_compile_os like 'FREEBSD%', 1, 0);`;
--enable_query_log

View File

@@ -0,0 +1,26 @@
# Copyright(C) 2013 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_windows.inc
--disable_query_log
if ($VERSION_COMPILE_OS_WIN) {
let ha_mroonga_so='ha_mroonga.dll';
}
if (!$VERSION_COMPILE_OS_WIN) {
let ha_mroonga_so='ha_mroonga.so';
}
--enable_query_log

View File

@@ -0,0 +1,19 @@
# Copyright(C) 2012 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--disable_query_log
let $mariadb = `SELECT LOCATE('MariaDB', @@global.version) > 0`;
--enable_query_log

View File

@@ -0,0 +1,19 @@
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--disable_query_log
let $VERSION_COMPILE_OS_OSX=`SELECT IF(@@version_compile_os like 'osx%', 1, 0);`;
--enable_query_log

View File

@@ -0,0 +1,28 @@
# Copyright(C) 2012-2013 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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_100 = `SELECT $version_major_minor = 10.0`;
let $version_55_or_later = `SELECT $version_major_minor >= 5.5`;
let $version_56_or_later = `SELECT $version_major_minor >= 5.6`;
let $version_100_or_later = `SELECT $version_major_minor >= 10.0`;
--enable_query_log

View File

@@ -0,0 +1,20 @@
# Copyright(C) 2013 Kentoku SHIBA
# Copyright(C) 2013 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--disable_query_log
let $VERSION_COMPILE_OS_WIN=`SELECT IF(@@version_compile_os like 'Win%', 1, 0)`;
--enable_query_log

View File

@@ -0,0 +1,28 @@
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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;
}

View File

@@ -0,0 +1,25 @@
# Copyright(C) 2013 Kentoku SHIBA
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 64 binary;
}

View File

@@ -0,0 +1,32 @@
# Copyright(C) 2012 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_mariadb.inc
--source ../../include/mroonga/check_version.inc
if ($mariadb) {
let $fractional_seconds = 1;
}
if (!$mariadb) {
if ($version_56) {
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;
}

View File

@@ -0,0 +1,21 @@
# Copyright(C) 2014 Kenji Maruyama <mmmaru777@gmail.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_freebsd.inc
if (!$VERSION_COMPILE_OS_FREEBSD) {
skip Need OS FreeBSD;
}

View File

@@ -0,0 +1,25 @@
# Copyright(C) 2012 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_version.inc
if ($version_55_or_later) {
let $fulltext_index_comment = 1;
}
if (!$fulltext_index_comment) {
skip Fulltext index comment is available in version 5.5 or later;
}

View File

@@ -0,0 +1,44 @@
# Copyright(C) 2010 Tetsuro IKEDA
# Copyright(C) 2013-2014 Kentoku SHIBA
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_ha_mroonga_so.inc
disable_query_log;
let have_mroonga_storage_engine=`SELECT 1 FROM information_schema.plugins WHERE plugin_name = "mroonga"`;
if (!$have_mroonga_storage_engine) {
eval INSTALL PLUGIN mroonga SONAME $ha_mroonga_so;
eval INSTALL PLUGIN mroonga_stats SONAME $ha_mroonga_so;
}
let have_default_storage_engine_variable=`SELECT 1 FROM information_schema.global_variables WHERE variable_name = "default_storage_engine"`;
if ($have_default_storage_engine_variable) {
let original_default_storage_engine=`SELECT variable_value FROM information_schema.global_variables WHERE variable_name = "default_storage_engine"`;
set default_storage_engine=Mroonga;
}
if (!$have_default_storage_engine_variable) {
let original_storage_engine=`SELECT variable_value FROM information_schema.global_variables WHERE variable_name = "storage_engine"`;
set storage_engine=Mroonga;
}
let have_default_tmp_storage_engine_variable=`SELECT 1 FROM information_schema.global_variables WHERE variable_name = "default_tmp_storage_engine"`;
if ($have_default_tmp_storage_engine_variable) {
let original_default_tmp_storage_engine=`SELECT variable_value FROM information_schema.global_variables WHERE variable_name = "default_tmp_storage_engine"`;
set default_tmp_storage_engine=Mroonga;
}
enable_query_log;

View File

@@ -0,0 +1,36 @@
# Copyright(C) 2010-2014 Kentoku SHIBA
# Copyright(C) 2011 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
disable_query_log;
if ($have_default_storage_engine_variable) {
eval set default_storage_engine=$original_default_storage_engine;
}
if (!$have_default_storage_engine_variable) {
eval set storage_engine=$original_storage_engine;
}
if ($have_default_tmp_storage_engine_variable) {
eval set default_tmp_storage_engine=$original_default_tmp_storage_engine;
}
if (!$have_mroonga_storage_engine) {
UNINSTALL PLUGIN mroonga_stats;
UNINSTALL PLUGIN mroonga;
}
enable_query_log;

View File

@@ -0,0 +1,17 @@
# Copyright(C) 2011 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
let $MYSQLD_DATADIR= `select @@datadir`;

View File

@@ -0,0 +1,21 @@
# Copyright(C) 2012 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_mariadb.inc
if ($mariadb) {
skip This test is for MySQL;
}

View File

@@ -0,0 +1,21 @@
# Copyright(C) 2013 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_version.inc
if (!$version_100) {
skip This test is for MariaDB version 10.0.x;
}

View File

@@ -0,0 +1,21 @@
# Copyright(C) 2013 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_version.inc
if (!$version_100_or_later) {
skip This test is for MariaDB version 10.0.x or later;
}

View File

@@ -0,0 +1,21 @@
# Copyright(C) 2012 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_version.inc
if (!$version_55) {
skip This test is for MySQL version 5.5.x;
}

View File

@@ -0,0 +1,21 @@
# Copyright(C) 2012 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_version.inc
if (!$version_56) {
skip This test is for MySQL version 5.6.x;
}

View File

@@ -0,0 +1,21 @@
# Copyright(C) 2013 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_version.inc
if (!$version_56_or_later) {
skip This test is for MySQL version 5.6.x or later;
}

View File

@@ -0,0 +1,24 @@
# Copyright(C) 2013 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_ha_mroonga_so.inc
--disable_query_log
eval CREATE FUNCTION last_insert_grn_id RETURNS INTEGER SONAME $ha_mroonga_so;
eval CREATE FUNCTION mroonga_snippet RETURNS STRING SONAME $ha_mroonga_so;
eval CREATE FUNCTION mroonga_command RETURNS STRING SONAME $ha_mroonga_so;
eval CREATE FUNCTION mroonga_escape RETURNS STRING SONAME $ha_mroonga_so;
--enable_query_log

View File

@@ -0,0 +1,21 @@
# Copyright(C) 2014 Kenji Maruyama <mmmaru777@gmail.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_freebsd.inc
if ($VERSION_COMPILE_OS_FREEBSD) {
skip This test is not for FreeBSD;
}

View File

@@ -0,0 +1,24 @@
# Copyright(C) 2012-2013 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_version.inc
--source ../../include/mroonga/check_mariadb.inc
if ($version_55) {
if ($mariadb) {
skip This test is not for MariaDB 5.5.x;
}
}

View File

@@ -0,0 +1,21 @@
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_osx.inc
if ($VERSION_COMPILE_OS_OSX) {
skip This test is not for OSX;
}

View File

@@ -0,0 +1,22 @@
# Copyright(C) 2013 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--disable_query_log
DROP FUNCTION last_insert_grn_id;
DROP FUNCTION mroonga_snippet;
DROP FUNCTION mroonga_command;
DROP FUNCTION mroonga_escape;
--enable_query_log

View File

@@ -0,0 +1,26 @@
DROP TABLE IF EXISTS diaries;
CREATE TABLE diaries (
id INT PRIMARY KEY AUTO_INCREMENT,
body TEXT
) DEFAULT CHARSET UTF8;
SHOW CREATE TABLE diaries;
Table Create Table
diaries CREATE TABLE `diaries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`body` text,
PRIMARY KEY (`id`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8
ALTER TABLE diaries ADD title TEXT AFTER id;
SHOW CREATE TABLE diaries;
Table Create Table
diaries CREATE TABLE `diaries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` text,
`body` text,
PRIMARY KEY (`id`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8
INSERT INTO diaries (title, body) values ("groonga (1)", "starting groonga.");
SELECT * FROM diaries;
id title body
1 groonga (1) starting groonga.
DROP TABLE diaries;

View File

@@ -0,0 +1,26 @@
DROP TABLE IF EXISTS diaries;
CREATE TABLE diaries (
id INT PRIMARY KEY AUTO_INCREMENT,
body TEXT
) DEFAULT CHARSET UTF8;
SHOW CREATE TABLE diaries;
Table Create Table
diaries CREATE TABLE `diaries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`body` text,
PRIMARY KEY (`id`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8
ALTER TABLE diaries ADD title TEXT FIRST;
SHOW CREATE TABLE diaries;
Table Create Table
diaries CREATE TABLE `diaries` (
`title` text,
`id` int(11) NOT NULL AUTO_INCREMENT,
`body` text,
PRIMARY KEY (`id`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8
INSERT INTO diaries (title, body) values ("groonga (1)", "starting groonga.");
SELECT * FROM diaries;
title id body
groonga (1) 1 starting groonga.
DROP TABLE diaries;

Some files were not shown because too many files have changed in this diff Show More