Commit d5178864 authored by Sergei Golubchik's avatar Sergei Golubchik

Merge branch 'bb-10.1-serg' into 10.1

parents 53623d93 26f249f6
...@@ -1033,11 +1033,13 @@ inline_mysql_socket_accept ...@@ -1033,11 +1033,13 @@ inline_mysql_socket_accept
SOCK_CLOEXEC); SOCK_CLOEXEC);
#else #else
socket_accept.fd= accept(socket_listen.fd, addr, &addr_length); socket_accept.fd= accept(socket_listen.fd, addr, &addr_length);
#ifdef FD_CLOEXEC
flags= fcntl(socket_accept.fd, F_GETFD); flags= fcntl(socket_accept.fd, F_GETFD);
if (flags != -1) { if (flags != -1) {
flags |= FD_CLOEXEC; flags |= FD_CLOEXEC;
fcntl(socket_accept.fd, F_SETFD, flags); fcntl(socket_accept.fd, F_SETFD, flags);
} }
#endif
#endif #endif
/* Instrumentation end */ /* Instrumentation end */
...@@ -1053,11 +1055,13 @@ inline_mysql_socket_accept ...@@ -1053,11 +1055,13 @@ inline_mysql_socket_accept
SOCK_CLOEXEC); SOCK_CLOEXEC);
#else #else
socket_accept.fd= accept(socket_listen.fd, addr, &addr_length); socket_accept.fd= accept(socket_listen.fd, addr, &addr_length);
#ifdef FD_CLOEXEC
flags= fcntl(socket_accept.fd, F_GETFD); flags= fcntl(socket_accept.fd, F_GETFD);
if (flags != -1) { if (flags != -1) {
flags |= FD_CLOEXEC; flags |= FD_CLOEXEC;
fcntl(socket_accept.fd, F_SETFD, flags); fcntl(socket_accept.fd, F_SETFD, flags);
} }
#endif
#endif #endif
} }
......
...@@ -77,10 +77,11 @@ ...@@ -77,10 +77,11 @@
#define WARN_DEPRECATED_NO_REPLACEMENT(Thd,Old) \ #define WARN_DEPRECATED_NO_REPLACEMENT(Thd,Old) \
do { \ do { \
if (((THD *) Thd) != NULL) \ THD *thd_= ((THD*) Thd); \
push_warning_printf(((THD *) Thd), Sql_condition::WARN_LEVEL_WARN, \ if (thd_ != NULL) \
push_warning_printf(thd_, Sql_condition::WARN_LEVEL_WARN, \
ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT, \ ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT, \
ER_THD(((THD *) Thd), ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT), \ ER_THD(thd_, ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT), \
(Old)); \ (Old)); \
else \ else \
sql_print_warning("'%s' is deprecated and will be removed " \ sql_print_warning("'%s' is deprecated and will be removed " \
......
...@@ -17,11 +17,12 @@ ...@@ -17,11 +17,12 @@
#define WSREP_XID_H #define WSREP_XID_H
#include <my_config.h> #include <my_config.h>
#include "../wsrep/wsrep_api.h"
#include "handler.h" // XID typedef
#ifdef WITH_WSREP #ifdef WITH_WSREP
#include "../wsrep/wsrep_api.h"
#include "handler.h" // XID typedef
void wsrep_xid_init(xid_t*, const wsrep_uuid_t&, wsrep_seqno_t); void wsrep_xid_init(xid_t*, const wsrep_uuid_t&, wsrep_seqno_t);
const wsrep_uuid_t* wsrep_xid_uuid(const XID&); const wsrep_uuid_t* wsrep_xid_uuid(const XID&);
wsrep_seqno_t wsrep_xid_seqno(const XID&); wsrep_seqno_t wsrep_xid_seqno(const XID&);
......
...@@ -39,11 +39,6 @@ if(BIG_ENDIAN) ...@@ -39,11 +39,6 @@ if(BIG_ENDIAN)
endif() endif()
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
message(STATUS "Mroonga is not supported on Solaris")
return()
endif()
if(MSVC) if(MSVC)
if(MSVC_VERSION LESS 1800) if(MSVC_VERSION LESS 1800)
set(MRN_OLD_MSVC_MESSAGE "Mroonga supports only MSVC 2013 or later") set(MRN_OLD_MSVC_MESSAGE "Mroonga supports only MSVC 2013 or later")
...@@ -115,6 +110,8 @@ if(MRN_GROONGA_BUNDLED) ...@@ -115,6 +110,8 @@ if(MRN_GROONGA_BUNDLED)
add_subdirectory("${MRN_BUNDLED_GROONGA_RELATIVE_DIR}") add_subdirectory("${MRN_BUNDLED_GROONGA_RELATIVE_DIR}")
else() else()
set(MRN_GROONGA_EMBED OFF)
file(READ ${MRN_SOURCE_DIR}/required_groonga_version REQUIRED_GROONGA_VERSION) file(READ ${MRN_SOURCE_DIR}/required_groonga_version REQUIRED_GROONGA_VERSION)
string(STRIP "${REQUIRED_GROONGA_VERSION}" REQUIRED_GROONGA_VERSION) string(STRIP "${REQUIRED_GROONGA_VERSION}" REQUIRED_GROONGA_VERSION)
...@@ -323,8 +320,7 @@ set(MRN_ALL_SOURCES ...@@ -323,8 +320,7 @@ set(MRN_ALL_SOURCES
if(MRN_BUNDLED) if(MRN_BUNDLED)
mysql_add_plugin(mroonga mysql_add_plugin(mroonga
${MRN_ALL_SOURCES} ${MRN_ALL_SOURCES}
STORAGE_ENGINE MODULE_ONLY DISABLED # see MDEV-7246 STORAGE_ENGINE MODULE_ONLY
RECOMPILE_FOR_EMBEDDED
LINK_LIBRARIES ${MRN_LIBRARIES}) LINK_LIBRARIES ${MRN_LIBRARIES})
else() else()
add_library(mroonga MODULE ${MRN_ALL_SOURCES}) add_library(mroonga MODULE ${MRN_ALL_SOURCES})
...@@ -334,28 +330,33 @@ else() ...@@ -334,28 +330,33 @@ else()
option(WITH_DEBUG "Enable debug options" OFF) option(WITH_DEBUG "Enable debug options" OFF)
if(WITH_DEBUG) if(WITH_DEBUG)
add_definitions("-DSAFE_MUTEX") set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "SAFE_MUTEX")
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX)
set(MRN_C_COMPILE_FLAGS "${MRN_C_COMPILE_FLAGS} -g3 -O0") set(MRN_C_COMPILE_FLAGS "${MRN_C_COMPILE_FLAGS} -g3 -O0")
set(MRN_CXX_COMPILE_FLAGS "${MRN_CXX_COMPILE_FLAGS} -g3 -O0") set(MRN_CXX_COMPILE_FLAGS "${MRN_CXX_COMPILE_FLAGS} -g3 -O0")
endif() endif()
else() else()
add_definitions("-DDBUG_OFF") set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "DBUG_OFF")
endif() endif()
option(WITH_DEBUG_FULL "Enable full debug options" OFF) option(WITH_DEBUG_FULL "Enable full debug options" OFF)
if(WITH_DEBUG_FULL) if(WITH_DEBUG_FULL)
add_definitions("-DSAFE_MUTEX" "SAFEMALLOC") set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "SAFE_MUTEX" "SAFEMALLOC")
endif() endif()
option(DISABLE_FAST_MUTEXES "Force disabling fast mutex" OFF) option(DISABLE_FAST_MUTEXES "Force disabling fast mutex" OFF)
if(DISABLE_FAST_MUTEXES) if(DISABLE_FAST_MUTEXES)
add_definitions("-DFORCE_FAST_MUTEX_DISABLED=1") set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "FORCE_FAST_MUTEX_DISABLED=1")
endif() endif()
option(WITH_FAST_MUTEXES "Enable fast mutex" OFF) option(WITH_FAST_MUTEXES "Enable fast mutex" OFF)
if(WITH_FAST_MUTEXES) if(WITH_FAST_MUTEXES)
add_definitions("-DMY_PTHREAD_FASTMUTEX") set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "MY_PTHREAD_FASTMUTEX")
endif() endif()
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX)
...@@ -381,7 +382,8 @@ else() ...@@ -381,7 +382,8 @@ else()
COMPILE_FLAGS "${MRN_CXX_COMPILE_FLAGS}") COMPILE_FLAGS "${MRN_CXX_COMPILE_FLAGS}")
set_source_files_properties(${LIBMRN_NO_MYSQL_SOURCES} PROPERTIES set_source_files_properties(${LIBMRN_NO_MYSQL_SOURCES} PROPERTIES
COMPILE_FLAGS "${MRN_CXX_COMPILE_FLAGS}") COMPILE_FLAGS "${MRN_CXX_COMPILE_FLAGS}")
add_definitions("-DMYSQL_DYNAMIC_PLUGIN") set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "MYSQL_DYNAMIC_PLUGIN")
set_target_properties(mroonga PROPERTIES set_target_properties(mroonga PROPERTIES
PREFIX "" PREFIX ""
OUTPUT_NAME "ha_mroonga") OUTPUT_NAME "ha_mroonga")
...@@ -390,16 +392,33 @@ else() ...@@ -390,16 +392,33 @@ else()
endif() endif()
if(GROONGA_NORMALIZER_MYSQL_FOUND) if(GROONGA_NORMALIZER_MYSQL_FOUND)
add_definitions("-DWITH_GROONGA_NORMALIZER_MYSQL=1") set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "WITH_GROONGA_NORMALIZER_MYSQL=1")
if(MRN_GROONGA_NORMALIZER_MYSQL_EMBED) if(MRN_GROONGA_NORMALIZER_MYSQL_EMBED)
add_definitions("-DMRN_GROONGA_NORMALIZER_MYSQL_EMBED") set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "MRN_GROONGA_NORMALIZER_MYSQL_EMBEDDED")
else() else()
add_definitions("-DGROONGA_NORMALIZER_MYSQL_PLUGIN_NAME=\"normalizers/mysql\"") set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "GROONGA_NORMALIZER_MYSQL_PLUGIN_NAME=\"normalizers/mysql\"")
endif() endif()
endif() endif()
set(MRN_DEFAULT_PARSER "TokenBigram" CACHE STRING "The default fulltext parser") if(MRN_GROONGA_EMBED)
add_definitions("-DMRN_PARSER_DEFAULT=\"${MRN_DEFAULT_PARSER}\"") set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "MRN_GROONGA_EMBEDDED")
endif()
set(MRN_DEFAULT_PARSER "" CACHE STRING
"The default fulltext parser (Deprecated. Use MRN_DEFAULT_TOKENIZER instead.)")
set(MRN_DEFAULT_TOKENIZER "" CACHE STRING
"The default tokenizer for fulltext index")
if(NOT ${MRN_DEFAULT_TOKENIZER} STREQUAL "")
set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "MRN_DEFAULT_TOKENIZER=\"${MRN_DEFAULT_TOKENIZER}\"")
elseif(NOT ${MRN_DEFAULT_PARSER} STREQUAL "")
set_property(TARGET mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "MRN_DEFAULT_TOKENIZER=\"${MRN_DEFAULT_PARSER}\"")
endif()
configure_file( configure_file(
"${PROJECT_SOURCE_DIR}/mrn_version.h.in" "${PROJECT_SOURCE_DIR}/mrn_version.h.in"
......
...@@ -3,16 +3,16 @@ clone_depth: 10 ...@@ -3,16 +3,16 @@ clone_depth: 10
install: install:
- cd .. - cd ..
- choco install -y curl 7zip.commandline - choco install -y curl 7zip.commandline
- curl -O http://mirror.jmu.edu/pub/mariadb/mariadb-10.0.17/source/mariadb-10.0.17.tar.gz - curl -O http://mirror.jmu.edu/pub/mariadb/mariadb-10.0.20/source/mariadb-10.0.20.tar.gz
- 7z x mariadb-10.0.17.tar.gz - 7z x mariadb-10.0.20.tar.gz
- 7z x mariadb-10.0.17.tar > nul - 7z x mariadb-10.0.20.tar > nul
- cd mariadb-10.0.17 - cd mariadb-10.0.20
- rmdir /S /Q storage\mroonga\ - rmdir /S /Q storage\mroonga\
- move ..\mroonga storage\mroonga - move ..\mroonga storage\mroonga
- git clone --quiet --depth 1 https://github.com/groonga/groonga.git ..\groonga - git clone --quiet --depth 1 https://github.com/groonga/groonga.git ..\groonga
- cd ..\groonga - cd ..\groonga
- git submodule update --init - git submodule update --init
- cd ..\mariadb-10.0.17 - cd ..\mariadb-10.0.20
- rmdir /S /Q ..\groonga\test\ - rmdir /S /Q ..\groonga\test\
- mkdir storage\mroonga\vendor - mkdir storage\mroonga\vendor
- move ..\groonga storage\mroonga\vendor\groonga - move ..\groonga storage\mroonga\vendor\groonga
......
include $(top_srcdir)/doc/files.am include $(top_srcdir)/doc/files.am
include $(top_srcdir)/build/makefiles/sphinx-build.am include $(top_srcdir)/build/makefiles/sphinx-build.am
CLEANFILES =
EXTRA_DIST += \ EXTRA_DIST += \
$(po_files) $(po_files)
...@@ -11,9 +13,11 @@ endif ...@@ -11,9 +13,11 @@ endif
if DOCUMENT_BUILDABLE if DOCUMENT_BUILDABLE
BUILT_SOURCES += \ BUILT_SOURCES += \
mo-build-stamp
CLEANFILES += \
pot-build-stamp \ pot-build-stamp \
edit-po-build-stamp \ edit-po-build-stamp \
$(mo_files) mo-build-stamp
endif endif
SUFFIXES += .pot .po .mo .edit SUFFIXES += .pot .po .mo .edit
...@@ -47,8 +51,8 @@ SUFFIXES += .pot .po .mo .edit ...@@ -47,8 +51,8 @@ SUFFIXES += .pot .po .mo .edit
msgfmt -o $@ $< msgfmt -o $@ $<
if DOCUMENT_BUILDABLE if DOCUMENT_BUILDABLE
update: pot-build-stamp edit-po-build-stamp update: edit-po-build-stamp
build: update $(mo_files) build: mo-build-stamp
else else
update: update:
build: build:
...@@ -68,6 +72,15 @@ pot-build-stamp: $(absolute_source_files) ...@@ -68,6 +72,15 @@ pot-build-stamp: $(absolute_source_files)
$(MAKE) gettext $(MAKE) gettext
@touch $@ @touch $@
edit-po-build-stamp: $(absolute_source_files) edit-po-build-stamp: pot-build-stamp
$(MAKE) $(edit_po_files) $(MAKE) $(edit_po_files)
@touch $@ @touch $@
mo_build_stamp_dependencies = edit-po-build-stamp
if DOCUMENT_BUILDABLE
mo_build_stamp_dependencies += $(edit_po_files)
endif
mo-build-stamp: $(mo_build_stamp_dependencies)
$(MAKE) $(mo_files)
@touch $@
...@@ -106,7 +106,7 @@ help: ...@@ -106,7 +106,7 @@ help:
@echo " doctest to run all doctests embedded in the documentation (if enabled)" @echo " doctest to run all doctests embedded in the documentation (if enabled)"
man: man-build-stamp man: man-build-stamp
html: html-build-stamp html: html-recursive html-build-stamp
dirhtml: dirhtml-build-stamp dirhtml: dirhtml-build-stamp
pickle: pickle-build-stamp pickle: pickle-build-stamp
json: json-build-stamp json: json-build-stamp
......
...@@ -309,20 +309,30 @@ CONFIG_OPTION_GROONGA_NORMALIZER_MYSQL ...@@ -309,20 +309,30 @@ CONFIG_OPTION_GROONGA_NORMALIZER_MYSQL
AC_ARG_WITH(default_parser, AC_ARG_WITH(default_parser,
[AS_HELP_STRING([--with-default-parser=PARSER], [AS_HELP_STRING([--with-default-parser=PARSER],
[specify the default fulltext parser like [Deprecated. Use --with-default-tokenizer=TOKENIZER instead.
specify the default fulltext parser like
--with-default-parser=TokenMecab. --with-default-parser=TokenMecab.
(default: TokenBigram)])], (default: TokenBigram)])],
[default_parser=$withval], [default_parser=$withval],
[default_parser=no]) [default_parser=no])
if test x"$default_parser" != x"no"; then if test x"$default_parser" != x"no"; then
AC_DEFINE_UNQUOTED(MRN_PARSER_DEFAULT, AC_DEFINE_UNQUOTED(MRN_TOKENIZER_DEFAULT,
"$default_parser", "$default_parser",
"specified default fulltext parser") "specified the default tokenizer for fulltext index")
MRN_DEFAULT_PARSER=$default_parser fi
else
MRN_DEFAULT_PARSER=TokenBigram AC_ARG_WITH(default_tokenizer,
[AS_HELP_STRING([--with-default-tokenizer=TOKENIZER],
[specify the default tokenizer for fulltext index like
--with-default-tokenizer=TokenMecab.
(default: TokenBigram)])],
[default_tokenizer=$withval],
[default_tokenizer=no])
if test x"$default_tokenizer" != x"no"; then
AC_DEFINE_UNQUOTED(MRN_DEFAULT_TOKENIZER,
"$default_tokenizer",
"specified the default tokenizer for fulltext index")
fi fi
AC_SUBST(MRN_DEFAULT_PARSER)
AC_ARG_ENABLE(fast_mutexes, AC_ARG_ENABLE(fast_mutexes,
[AS_HELP_STRING([--disable-fast-mutexes], [AS_HELP_STRING([--disable-fast-mutexes],
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -33,18 +33,11 @@ extern "C" { ...@@ -33,18 +33,11 @@ extern "C" {
#include <groonga.h> #include <groonga.h>
#include "mrn_mysql_compat.h" #include "mrn_mysql_compat.h"
#if (MYSQL_VERSION_ID >= 50603) || \
(MYSQL_VERSION_ID >= 50513 && MYSQL_VERSION_ID < 50600) || \
(MYSQL_VERSION_ID >= 50158 && MYSQL_VERSION_ID < 50500)
# define MRN_HANDLER_CLONE_NEED_NAME 1
#endif
#if (MYSQL_VERSION_ID >= 50514 && MYSQL_VERSION_ID < 50600) #if (MYSQL_VERSION_ID >= 50514 && MYSQL_VERSION_ID < 50600)
# define MRN_HANDLER_HAVE_FINAL_ADD_INDEX 1 # define MRN_HANDLER_HAVE_FINAL_ADD_INDEX 1
#endif #endif
#if (MYSQL_VERSION_ID >= 50603) || \ #if (MYSQL_VERSION_ID >= 50603) || defined(MRN_MARIADB_P)
(defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 50209)
# define MRN_HANDLER_HAVE_HA_RND_NEXT 1 # define MRN_HANDLER_HAVE_HA_RND_NEXT 1
# define MRN_HANDLER_HAVE_HA_RND_POS 1 # define MRN_HANDLER_HAVE_HA_RND_POS 1
# define MRN_HANDLER_HAVE_HA_INDEX_READ_MAP 1 # define MRN_HANDLER_HAVE_HA_INDEX_READ_MAP 1
...@@ -56,8 +49,7 @@ extern "C" { ...@@ -56,8 +49,7 @@ extern "C" {
# define MRN_HANDLER_HAVE_HA_INDEX_NEXT_SAME 1 # define MRN_HANDLER_HAVE_HA_INDEX_NEXT_SAME 1
#endif #endif
#if (MYSQL_VERSION_ID >= 50604) || \ #if (MYSQL_VERSION_ID >= 50604) || defined(MRN_MARIADB_P)
(defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 50302)
# define MRN_HANDLER_HAVE_HA_CLOSE 1 # define MRN_HANDLER_HAVE_HA_CLOSE 1
# define MRN_HANDLER_HAVE_MULTI_RANGE_READ 1 # define MRN_HANDLER_HAVE_MULTI_RANGE_READ 1
#endif #endif
...@@ -77,15 +69,10 @@ extern "C" { ...@@ -77,15 +69,10 @@ extern "C" {
# endif # endif
#endif #endif
#if (defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 50302) #ifdef MRN_MARIADB_P
# define MRN_HANDLER_HAVE_MULTI_RANGE_READ_INFO_KEY_PARTS # define MRN_HANDLER_HAVE_MULTI_RANGE_READ_INFO_KEY_PARTS
#endif #endif
#if MYSQL_VERSION_ID >= 50500
# define MRN_HANDLER_HAVE_TRUNCATE
# define MRN_HANDLER_HAVE_GET_PARENT_FOREIGN_KEY_LIST
#endif
#if MYSQL_VERSION_ID < 50600 #if MYSQL_VERSION_ID < 50600
# define MRN_HANDLER_HAVE_GET_TABLESPACE_NAME # define MRN_HANDLER_HAVE_GET_TABLESPACE_NAME
#endif #endif
...@@ -94,10 +81,6 @@ extern "C" { ...@@ -94,10 +81,6 @@ extern "C" {
# define MRN_HANDLER_HAVE_SET_HA_SHARE_REF # define MRN_HANDLER_HAVE_SET_HA_SHARE_REF
#endif #endif
#if MYSQL_VERSION_ID >= 50500
# define MRN_TABLE_LIST_INIT_REQUIRE_ALIAS
#endif
#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P) #if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
# define MRN_BIG_TABLES # define MRN_BIG_TABLES
#elif defined(BIG_TABLES) #elif defined(BIG_TABLES)
...@@ -110,17 +93,10 @@ extern "C" { ...@@ -110,17 +93,10 @@ extern "C" {
# define MRN_HA_ROWS_FORMAT "lu" # define MRN_HA_ROWS_FORMAT "lu"
#endif #endif
#if (MYSQL_VERSION_ID < 50519) || \ #ifdef MRN_MARIADB_P
defined(MRN_MARIADB_P) || \
(50600 <= MYSQL_VERSION_ID && MYSQL_VERSION_ID < 50604)
# define MRN_NEED_FREE_STRING_MEMALLOC_PLUGIN_VAR # define MRN_NEED_FREE_STRING_MEMALLOC_PLUGIN_VAR
#endif #endif
#if MYSQL_VERSION_ID >= 50500
# define MRN_HAVE_HA_EXTRA_ADD_CHILDREN_LIST
# define MRN_HAVE_HA_EXTRA_IS_ATTACHED_CHILDREN
#endif
#ifdef MRN_MARIADB_P #ifdef MRN_MARIADB_P
# define MRN_HAVE_HA_EXTRA_DETACH_CHILD # define MRN_HAVE_HA_EXTRA_DETACH_CHILD
# define MRN_HAVE_HA_EXTRA_PREPARE_FOR_FORCED_CLOSE # define MRN_HAVE_HA_EXTRA_PREPARE_FOR_FORCED_CLOSE
...@@ -147,10 +123,6 @@ extern "C" { ...@@ -147,10 +123,6 @@ extern "C" {
# define MRN_FIELD_STORE_TIME_NEED_TYPE # define MRN_FIELD_STORE_TIME_NEED_TYPE
#endif #endif
#if MYSQL_VERSION_ID < 50500
# define MRN_HAVE_TL_WRITE_ALLOW_READ
#endif
#if MYSQL_VERSION_ID < 50706 || defined(MRN_MARIADB_P) #if MYSQL_VERSION_ID < 50706 || defined(MRN_MARIADB_P)
# define MRN_HAVE_TL_WRITE_DELAYED # define MRN_HAVE_TL_WRITE_DELAYED
#endif #endif
...@@ -159,9 +131,7 @@ extern "C" { ...@@ -159,9 +131,7 @@ extern "C" {
# define MRN_HAVE_TL_WRITE_CONCURRENT_DEFAULT # define MRN_HAVE_TL_WRITE_CONCURRENT_DEFAULT
#endif #endif
#if (defined(MRN_MARIADB_P) && \ #ifdef MRN_MARIADB_P
((MYSQL_VERSION_ID >= 50306 && MYSQL_VERSION_ID < 50500) || \
MYSQL_VERSION_ID >= 50523))
# define MRN_HANDLER_AUTO_REPAIR_HAVE_ERROR # define MRN_HANDLER_AUTO_REPAIR_HAVE_ERROR
#endif #endif
...@@ -191,6 +161,9 @@ extern "C" { ...@@ -191,6 +161,9 @@ extern "C" {
#if (defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100010) #if (defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100010)
# define MRN_HAVE_TDC_LOCK_TABLE_SHARE # define MRN_HAVE_TDC_LOCK_TABLE_SHARE
# if MYSQL_VERSION_ID >= 100100
# define MRN_TABLE_SHARE_TDC_IS_POINTER
# endif
#endif #endif
#ifdef MRN_MARIADB_P #ifdef MRN_MARIADB_P
...@@ -256,6 +229,22 @@ struct st_mrn_ft_info ...@@ -256,6 +229,22 @@ struct st_mrn_ft_info
ha_mroonga *mroonga; ha_mroonga *mroonga;
}; };
#ifdef MRN_SUPPORT_CUSTOM_OPTIONS
struct ha_field_option_struct
{
const char *groonga_type;
const char *flags;
};
struct ha_index_option_struct
{
const char *tokenizer;
const char *normalizer;
const char *token_filters;
const char *flags;
};
#endif
/* handler class */ /* handler class */
class ha_mroonga: public handler class ha_mroonga: public handler
{ {
...@@ -446,11 +435,7 @@ public: ...@@ -446,11 +435,7 @@ public:
int reset(); int reset();
#ifdef MRN_HANDLER_CLONE_NEED_NAME
handler *clone(const char *name, MEM_ROOT *mem_root); handler *clone(const char *name, MEM_ROOT *mem_root);
#else
handler *clone(MEM_ROOT *mem_root);
#endif
uint8 table_cache_type(); uint8 table_cache_type();
#ifdef MRN_HANDLER_HAVE_MULTI_RANGE_READ #ifdef MRN_HANDLER_HAVE_MULTI_RANGE_READ
ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
...@@ -481,9 +466,7 @@ public: ...@@ -481,9 +466,7 @@ public:
#endif #endif
int end_bulk_insert(); int end_bulk_insert();
int delete_all_rows(); int delete_all_rows();
#ifdef MRN_HANDLER_HAVE_TRUNCATE
int truncate(); int truncate();
#endif // MRN_HANDLER_HAVE_TRUNCATE
double scan_time(); double scan_time();
double read_time(uint index, uint ranges, ha_rows rows); double read_time(uint index, uint ranges, ha_rows rows);
const key_map *keys_to_use_for_scanning(); const key_map *keys_to_use_for_scanning();
...@@ -567,9 +550,7 @@ protected: ...@@ -567,9 +550,7 @@ protected:
#endif #endif
bool can_switch_engines(); bool can_switch_engines();
int get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list); int get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
#ifdef MRN_HANDLER_HAVE_GET_PARENT_FOREIGN_KEY_LIST
int get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list); int get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
#endif
uint referenced_by_foreign_key(); uint referenced_by_foreign_key();
void init_table_handle_for_HANDLER(); void init_table_handle_for_HANDLER();
void free_foreign_key_create_info(char* str); void free_foreign_key_create_info(char* str);
...@@ -597,6 +578,8 @@ private: ...@@ -597,6 +578,8 @@ private:
void mkdir_p(const char *directory); void mkdir_p(const char *directory);
ulonglong file_size(const char *path); ulonglong file_size(const char *path);
bool have_unique_index();
void push_warning_unsupported_spatial_index_search(enum ha_rkey_function flag); void push_warning_unsupported_spatial_index_search(enum ha_rkey_function flag);
void clear_cursor(); void clear_cursor();
void clear_cursor_geo(); void clear_cursor_geo();
...@@ -604,14 +587,23 @@ private: ...@@ -604,14 +587,23 @@ private:
void clear_search_result(); void clear_search_result();
void clear_search_result_geo(); void clear_search_result_geo();
void clear_indexes(); void clear_indexes();
int alter_share_add(const char *path, TABLE_SHARE *table_share); int add_wrap_hton(const char *path, handlerton *wrap_handlerton);
void remove_related_files(const char *base_path); void remove_related_files(const char *base_path);
void remove_grn_obj_force(const char *name); void remove_grn_obj_force(const char *name);
int drop_index(MRN_SHARE *target_share, uint key_index); int drop_index(MRN_SHARE *target_share, uint key_index);
int drop_indexes_normal(const char *table_name, grn_obj *table);
int drop_indexes_multiple(const char *table_name, grn_obj *table);
int drop_indexes(const char *table_name);
bool find_column_flags(Field *field, MRN_SHARE *mrn_share, int i,
grn_obj_flags *column_flags);
grn_obj *find_column_type(Field *field, MRN_SHARE *mrn_share, int i,
int error_code);
grn_obj *find_tokenizer(KEY *key, MRN_SHARE *mrn_share, int i);
grn_obj *find_tokenizer(const char *name, int name_length); grn_obj *find_tokenizer(const char *name, int name_length);
grn_obj *find_normalizer(KEY *key_info); grn_obj *find_normalizer(KEY *key);
bool find_index_column_flags(KEY *key_info, grn_obj_flags *index_column_flags); grn_obj *find_normalizer(KEY *key, const char *name);
bool find_token_filters(KEY *key_info, grn_obj *token_filters); bool find_index_column_flags(KEY *key, grn_obj_flags *index_column_flags);
bool find_token_filters(KEY *key, grn_obj *token_filters);
bool find_token_filters_put(grn_obj *token_filters, bool find_token_filters_put(grn_obj *token_filters,
const char *token_filter_name, const char *token_filter_name,
int token_filter_name_length); int token_filter_name_length);
...@@ -788,12 +780,9 @@ private: ...@@ -788,12 +780,9 @@ private:
int close_databases(); int close_databases();
int ensure_database_open(const char *name); int ensure_database_open(const char *name);
int ensure_database_remove(const char *name); int ensure_database_remove(const char *name);
int wrapper_delete_table(const char *name, MRN_SHARE *tmp_share, int wrapper_delete_table(const char *name, handlerton *wrap_handlerton,
const char *table_name);
int wrapper_delete_index(const char *name, MRN_SHARE *tmp_share,
const char *table_name);
int storage_delete_table(const char *name, MRN_SHARE *tmp_share,
const char *table_name); const char *table_name);
int generic_delete_table(const char *name, const char *table_name);
int wrapper_open(const char *name, int mode, uint test_if_locked); int wrapper_open(const char *name, int mode, uint test_if_locked);
int wrapper_open_indexes(const char *name); int wrapper_open_indexes(const char *name);
int storage_open(const char *name, int mode, uint test_if_locked); int storage_open(const char *name, int mode, uint test_if_locked);
...@@ -987,13 +976,8 @@ private: ...@@ -987,13 +976,8 @@ private:
void storage_cond_pop(); void storage_cond_pop();
bool wrapper_get_error_message(int error, String *buf); bool wrapper_get_error_message(int error, String *buf);
bool storage_get_error_message(int error, String *buf); bool storage_get_error_message(int error, String *buf);
#ifdef MRN_HANDLER_CLONE_NEED_NAME
handler *wrapper_clone(const char *name, MEM_ROOT *mem_root); handler *wrapper_clone(const char *name, MEM_ROOT *mem_root);
handler *storage_clone(const char *name, MEM_ROOT *mem_root); handler *storage_clone(const char *name, MEM_ROOT *mem_root);
#else
handler *wrapper_clone(MEM_ROOT *mem_root);
handler *storage_clone(MEM_ROOT *mem_root);
#endif
uint8 wrapper_table_cache_type(); uint8 wrapper_table_cache_type();
uint8 storage_table_cache_type(); uint8 storage_table_cache_type();
#ifdef MRN_HANDLER_HAVE_MULTI_RANGE_READ #ifdef MRN_HANDLER_HAVE_MULTI_RANGE_READ
...@@ -1049,9 +1033,7 @@ private: ...@@ -1049,9 +1033,7 @@ private:
const char *function_name); const char *function_name);
int wrapper_delete_all_rows(); int wrapper_delete_all_rows();
int storage_delete_all_rows(); int storage_delete_all_rows();
#ifdef MRN_HANDLER_HAVE_TRUNCATE
int wrapper_truncate(); int wrapper_truncate();
#endif // MRN_HANDLER_HAVE_TRUNCATE
int wrapper_truncate_index(); int wrapper_truncate_index();
int storage_truncate(); int storage_truncate();
int storage_truncate_index(); int storage_truncate_index();
...@@ -1216,10 +1198,8 @@ private: ...@@ -1216,10 +1198,8 @@ private:
bool storage_can_switch_engines(); bool storage_can_switch_engines();
int wrapper_get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list); int wrapper_get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
int storage_get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list); int storage_get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
#ifdef MRN_HANDLER_HAVE_GET_PARENT_FOREIGN_KEY_LIST
int wrapper_get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list); int wrapper_get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
int storage_get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list); int storage_get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
#endif
uint wrapper_referenced_by_foreign_key(); uint wrapper_referenced_by_foreign_key();
uint storage_referenced_by_foreign_key(); uint storage_referenced_by_foreign_key();
void wrapper_init_table_handle_for_HANDLER(); void wrapper_init_table_handle_for_HANDLER();
......
...@@ -17,10 +17,6 @@ ...@@ -17,10 +17,6 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 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_condition_converter.hpp"
#include "mrn_time_converter.hpp" #include "mrn_time_converter.hpp"
#include "mrn_smart_grn_obj.hpp" #include "mrn_smart_grn_obj.hpp"
......
...@@ -20,11 +20,12 @@ ...@@ -20,11 +20,12 @@
#ifndef MRN_CONDITION_CONVERTER_HPP_ #ifndef MRN_CONDITION_CONVERTER_HPP_
#define MRN_CONDITION_CONVERTER_HPP_ #define MRN_CONDITION_CONVERTER_HPP_
#include <groonga.h>
#include <mrn_mysql_compat.h> #include <mrn_mysql_compat.h>
#include <item_cmpfunc.h> #include <item_cmpfunc.h>
#include <groonga.h>
namespace mrn { namespace mrn {
class ConditionConverter { class ConditionConverter {
public: public:
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* /*
Copyright(C) 2010 Tetsuro IKEDA Copyright(C) 2010 Tetsuro IKEDA
Copyright(C) 2010-2013 Kentoku SHIBA Copyright(C) 2010-2013 Kentoku SHIBA
Copyright(C) 2011-2014 Kouhei Sutou <kou@clear-code.com> Copyright(C) 2011-2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
...@@ -126,13 +126,12 @@ namespace mrn { ...@@ -126,13 +126,12 @@ namespace mrn {
mapper.db_name(), strlen(mapper.db_name()), mapper.db_name(), strlen(mapper.db_name()),
&db_address, NULL); &db_address, NULL);
memcpy(db_address, db, sizeof(grn_obj *)); memcpy(db_address, db, sizeof(grn_obj *));
error = ensure_normalizers_registered(*db);
} else { } else {
memcpy(db, db_address, sizeof(grn_obj *)); memcpy(db, db_address, sizeof(grn_obj *));
grn_ctx_use(ctx_, *db); grn_ctx_use(ctx_, *db);
} }
error = ensure_normalizers_registered(*db);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
...@@ -313,18 +312,18 @@ namespace mrn { ...@@ -313,18 +312,18 @@ namespace mrn {
int error = 0; int error = 0;
#ifdef WITH_GROONGA_NORMALIZER_MYSQL #ifdef WITH_GROONGA_NORMALIZER_MYSQL
{ {
# ifdef MRN_GROONGA_NORMALIZER_MYSQL_EMBEDDED
GRN_PLUGIN_IMPL_NAME_TAGGED(init, normalizers_mysql)(ctx_);
GRN_PLUGIN_IMPL_NAME_TAGGED(register, normalizers_mysql)(ctx_);
# else
grn_obj *mysql_normalizer; grn_obj *mysql_normalizer;
mysql_normalizer = grn_ctx_get(ctx_, "NormalizerMySQLGeneralCI", -1); mysql_normalizer = grn_ctx_get(ctx_, "NormalizerMySQLGeneralCI", -1);
if (mysql_normalizer) { if (mysql_normalizer) {
grn_obj_unlink(ctx_, mysql_normalizer); grn_obj_unlink(ctx_, mysql_normalizer);
} else { } else {
# ifdef MRN_GROONGA_NORMALIZER_MYSQL_EMBED
GRN_PLUGIN_IMPL_NAME_TAGGED(init, normalizers_mysql)(ctx_);
GRN_PLUGIN_IMPL_NAME_TAGGED(register, normalizers_mysql)(ctx_);
# else
grn_plugin_register(ctx_, GROONGA_NORMALIZER_MYSQL_PLUGIN_NAME); grn_plugin_register(ctx_, GROONGA_NORMALIZER_MYSQL_PLUGIN_NAME);
# endif
} }
# endif
} }
#endif #endif
......
...@@ -233,7 +233,7 @@ namespace mrn { ...@@ -233,7 +233,7 @@ namespace mrn {
bool *succeeded = static_cast<bool *>(user_data); bool *succeeded = static_cast<bool *>(user_data);
if (grn_db_recover(ctx_, db) != GRN_SUCCESS) { if (grn_db_recover(ctx_, db) != GRN_SUCCESS) {
push_warning_printf(thd_, push_warning_printf(thd_,
Sql_condition::WARN_LEVEL_WARN, MRN_SEVERITY_WARNING,
ER_NOT_KEYFILE, ER_NOT_KEYFILE,
"mroonga: repair: " "mroonga: repair: "
"Failed to recover database: <%s>: <%s>", "Failed to recover database: <%s>: <%s>",
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include <mrn_mysql.h>
#include <mrn_err.h> #include <mrn_err.h>
#include "mrn_encoding.hpp" #include "mrn_encoding.hpp"
......
/* -*- c-basic-offset: 2 -*- */ /* -*- c-basic-offset: 2 -*- */
/* /*
Copyright(C) 2013 Kouhei Sutou <kou@clear-code.com> Copyright(C) 2013-2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
...@@ -20,11 +20,11 @@ ...@@ -20,11 +20,11 @@
#ifndef MRN_ENCODING_HPP_ #ifndef MRN_ENCODING_HPP_
#define MRN_ENCODING_HPP_ #define MRN_ENCODING_HPP_
#include <groonga.h>
#include <mrn_mysql.h> #include <mrn_mysql.h>
#include <mrn_mysql_compat.h> #include <mrn_mysql_compat.h>
#include <groonga.h>
namespace mrn { namespace mrn {
namespace encoding { namespace encoding {
void init(void); void init(void);
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include <mrn_mysql.h>
#include "mrn_field_normalizer.hpp" #include "mrn_field_normalizer.hpp"
#include "mrn_encoding.hpp" #include "mrn_encoding.hpp"
......
/* -*- c-basic-offset: 2 -*- */ /* -*- c-basic-offset: 2 -*- */
/* /*
Copyright(C) 2013 Kouhei Sutou <kou@clear-code.com> Copyright(C) 2013-2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
...@@ -20,11 +20,11 @@ ...@@ -20,11 +20,11 @@
#ifndef MRN_FIELD_NORMALIZER_HPP_ #ifndef MRN_FIELD_NORMALIZER_HPP_
#define MRN_FIELD_NORMALIZER_HPP_ #define MRN_FIELD_NORMALIZER_HPP_
#include <groonga.h>
#include <mrn_mysql.h> #include <mrn_mysql.h>
#include <mrn_mysql_compat.h> #include <mrn_mysql_compat.h>
#include <groonga.h>
namespace mrn { namespace mrn {
class FieldNormalizer { class FieldNormalizer {
public: public:
......
...@@ -26,6 +26,32 @@ ...@@ -26,6 +26,32 @@
#define MRN_CLASS_NAME "mrn::IndexTableName" #define MRN_CLASS_NAME "mrn::IndexTableName"
namespace mrn { namespace mrn {
const char *IndexTableName::SEPARATOR = "-";
bool IndexTableName::is_custom_name(const char *table_name,
size_t table_name_length,
const char *index_table_name,
size_t index_table_name_length)
{
MRN_DBUG_ENTER_METHOD();
if (index_table_name_length <= (table_name_length + strlen(SEPARATOR))) {
DBUG_RETURN(true);
}
if (strncmp(table_name, index_table_name, table_name_length) != 0) {
DBUG_RETURN(true);
}
if (strncmp(SEPARATOR,
index_table_name + table_name_length,
strlen(SEPARATOR)) != 0) {
DBUG_RETURN(true);
}
DBUG_RETURN(false);
}
IndexTableName::IndexTableName(const char *table_name, IndexTableName::IndexTableName(const char *table_name,
const char *mysql_index_name) const char *mysql_index_name)
: table_name_(table_name), : table_name_(table_name),
...@@ -38,7 +64,10 @@ namespace mrn { ...@@ -38,7 +64,10 @@ namespace mrn {
mysql_index_name_multibyte, mysql_index_name_multibyte,
mysql_index_name_multibyte + strlen(mysql_index_name_)); mysql_index_name_multibyte + strlen(mysql_index_name_));
snprintf(name_, MRN_MAX_KEY_SIZE, snprintf(name_, MRN_MAX_KEY_SIZE,
"%s-%s", table_name_, encoded_mysql_index_name_multibyte); "%s%s%s",
table_name_,
SEPARATOR,
encoded_mysql_index_name_multibyte);
length_ = strlen(name_); length_ = strlen(name_);
} }
......
...@@ -26,6 +26,13 @@ ...@@ -26,6 +26,13 @@
namespace mrn { namespace mrn {
class IndexTableName { class IndexTableName {
public: public:
static const char *SEPARATOR;
static bool is_custom_name(const char *table_name,
size_t table_name_length,
const char *index_table_name,
size_t index_table_name_length);
IndexTableName(const char *table_name, const char *mysql_index_name); IndexTableName(const char *table_name, const char *mysql_index_name);
const char *c_str(); const char *c_str();
size_t length(); size_t length();
......
/* -*- c-basic-offset: 2 -*- */ /* -*- c-basic-offset: 2 -*- */
/* /*
Copyright(C) 2013 Kouhei Sutou <kou@clear-code.com> Copyright(C) 2013-2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
...@@ -20,12 +20,17 @@ ...@@ -20,12 +20,17 @@
#include "mrn_lock.hpp" #include "mrn_lock.hpp"
namespace mrn { namespace mrn {
Lock::Lock(mysql_mutex_t *mutex) Lock::Lock(mysql_mutex_t *mutex, bool execute)
: mutex_(mutex) { : mutex_(mutex),
execute_(execute) {
if (execute_) {
mysql_mutex_lock(mutex_); mysql_mutex_lock(mutex_);
} }
}
Lock::~Lock() { Lock::~Lock() {
if (execute_) {
mysql_mutex_unlock(mutex_); mysql_mutex_unlock(mutex_);
} }
}
} }
/* -*- c-basic-offset: 2 -*- */ /* -*- c-basic-offset: 2 -*- */
/* /*
Copyright(C) 2013 Kouhei Sutou <kou@clear-code.com> Copyright(C) 2013-2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
...@@ -26,10 +26,11 @@ ...@@ -26,10 +26,11 @@
namespace mrn { namespace mrn {
class Lock { class Lock {
public: public:
Lock(mysql_mutex_t *mutex); Lock(mysql_mutex_t *mutex, bool execute=true);
~Lock(); ~Lock();
private: private:
mysql_mutex_t *mutex_; mysql_mutex_t *mutex_;
bool execute_;
}; };
} }
......
...@@ -44,6 +44,10 @@ namespace mrn { ...@@ -44,6 +44,10 @@ namespace mrn {
TYPE_NUMBER, TYPE_NUMBER,
TYPE_FLOAT, TYPE_FLOAT,
TYPE_DOUBLE, TYPE_DOUBLE,
TYPE_DATETIME,
#ifdef MRN_HAVE_MYSQL_TYPE_DATETIME2
TYPE_DATETIME2,
#endif
TYPE_BYTE_SEQUENCE, TYPE_BYTE_SEQUENCE,
TYPE_BYTE_REVERSE, TYPE_BYTE_REVERSE,
TYPE_BYTE_BLOB TYPE_BYTE_BLOB
...@@ -56,14 +60,40 @@ namespace mrn { ...@@ -56,14 +60,40 @@ namespace mrn {
void get_key_info(KEY_PART_INFO *key_part, void get_key_info(KEY_PART_INFO *key_part,
DataType *data_type, uint *data_size); DataType *data_type, uint *data_size);
void encode_float(volatile float value, uint data_size, uchar *grn_key); void encode_number(const uchar *mysql_key,
void decode_float(const uchar *grn_key, uchar *mysql_key, uint data_size); uint mysql_key_size,
void encode_double(volatile double value, uint data_size, uchar *grn_key); bool is_signed,
void decode_double(const uchar *grn_key, uchar *mysql_key, uint data_size); uchar *grn_key);
void encode_reverse(const uchar *mysql_key, uint data_size, uchar *grn_key); void decode_number(const uchar *grn_key,
void decode_reverse(const uchar *grn_key, uchar *mysql_key, uint data_size); uint grn_key_size,
void encode_blob(Field *field, bool is_signed,
const uchar *mysql_key, uchar *grn_key, uint *data_size); uchar *mysql_key);
void encode_long_long_int(volatile long long int value,
uchar *grn_key);
void decode_long_long_int(const uchar *grn_key,
long long int *value);
void encode_float(volatile float value,
uint value_size,
uchar *grn_key);
void decode_float(const uchar *grn_key,
uint grn_key_size,
uchar *mysql_key);
void encode_double(volatile double value,
uint value_size,
uchar *grn_key);
void decode_double(const uchar *grn_key,
uint grn_key_size,
uchar *mysql_key);
void encode_reverse(const uchar *mysql_key,
uint mysql_key_size,
uchar *grn_key);
void decode_reverse(const uchar *grn_key,
uint grn_key_size,
uchar *mysql_key);
void encode_blob(const uchar *mysql_key,
uint *mysql_key_size,
Field *field,
uchar *grn_key);
}; };
} }
......
...@@ -17,10 +17,6 @@ ...@@ -17,10 +17,6 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 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.h>
#include <mrn_mysql_compat.h> #include <mrn_mysql_compat.h>
......
...@@ -50,4 +50,10 @@ namespace mrn { ...@@ -50,4 +50,10 @@ namespace mrn {
grn_obj *SmartGrnObj::get() { grn_obj *SmartGrnObj::get() {
return obj_; return obj_;
} }
grn_obj *SmartGrnObj::release() {
grn_obj *obj = obj_;
obj_ = NULL;
return obj;
}
} }
...@@ -33,6 +33,7 @@ namespace mrn { ...@@ -33,6 +33,7 @@ namespace mrn {
~SmartGrnObj(); ~SmartGrnObj();
grn_obj *get(); grn_obj *get();
grn_obj *release();
}; };
} }
......
/* -*- c-basic-offset: 2 -*- */ /* -*- c-basic-offset: 2 -*- */
/* /*
Copyright(C) 2010-2013 Kentoku SHIBA Copyright(C) 2010-2013 Kentoku SHIBA
Copyright(C) 2011-2013 Kouhei Sutou <kou@clear-code.com> Copyright(C) 2011-2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
...@@ -18,10 +18,6 @@ ...@@ -18,10 +18,6 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 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" #include "mrn_time_converter.hpp"
#ifdef min #ifdef min
...@@ -257,4 +253,43 @@ namespace mrn { ...@@ -257,4 +253,43 @@ namespace mrn {
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
long long int TimeConverter::mysql_datetime_to_grn_time(long long int mysql_datetime,
bool *truncated) {
MRN_DBUG_ENTER_METHOD();
MYSQL_TIME mysql_time;
mysql_time.time_type = MYSQL_TIMESTAMP_DATETIME;
mysql_time.neg = 0;
mysql_time.second_part = 0;
mysql_time.second = (mysql_datetime % 100);
mysql_time.minute = (mysql_datetime / 100 % 100);
mysql_time.hour = (mysql_datetime / 10000 % 100);
mysql_time.day = (mysql_datetime / 1000000 % 100);
mysql_time.month = (mysql_datetime / 100000000 % 100);
mysql_time.year = (mysql_datetime / 10000000000LL % 10000);
long long int grn_time = mysql_time_to_grn_time(&mysql_time, truncated);
DBUG_RETURN(grn_time);
}
long long int TimeConverter::grn_time_to_mysql_datetime(long long int grn_time) {
MRN_DBUG_ENTER_METHOD();
MYSQL_TIME mysql_time;
mysql_time.time_type = MYSQL_TIMESTAMP_DATETIME;
grn_time_to_mysql_time(grn_time, &mysql_time);
long long int mysql_datetime =
(mysql_time.second * 1) +
(mysql_time.minute * 100) +
(mysql_time.hour * 10000) +
(mysql_time.day * 1000000) +
(mysql_time.month * 100000000) +
(mysql_time.year * 10000000000LL);
DBUG_RETURN(mysql_datetime);
}
} }
/* -*- c-basic-offset: 2 -*- */ /* -*- c-basic-offset: 2 -*- */
/* /*
Copyright(C) 2010-2013 Kentoku SHIBA Copyright(C) 2010-2013 Kentoku SHIBA
Copyright(C) 2011-2013 Kouhei Sutou <kou@clear-code.com> Copyright(C) 2011-2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
...@@ -21,9 +21,10 @@ ...@@ -21,9 +21,10 @@
#ifndef MRN_TIME_CONVERTER_HPP_ #ifndef MRN_TIME_CONVERTER_HPP_
#define MRN_TIME_CONVERTER_HPP_ #define MRN_TIME_CONVERTER_HPP_
#include <groonga.h>
#include <mrn_mysql_compat.h> #include <mrn_mysql_compat.h>
#include <groonga.h>
namespace mrn { namespace mrn {
class TimeConverter { class TimeConverter {
public: public:
...@@ -34,10 +35,13 @@ namespace mrn { ...@@ -34,10 +35,13 @@ namespace mrn {
long long int mysql_time_to_grn_time(MYSQL_TIME *mysql_time, long long int mysql_time_to_grn_time(MYSQL_TIME *mysql_time,
bool *truncated); bool *truncated);
long long int mysql_datetime_to_grn_time(long long int mysql_datetime,
bool *truncated);
long long int tm_to_grn_time(struct tm *time, int usec, 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); void grn_time_to_mysql_time(long long int grn_time, MYSQL_TIME *mysql_time);
long long int grn_time_to_mysql_datetime(long long int grn_time);
private: private:
time_t tm_to_time_gm(struct tm *time, bool *truncated); time_t tm_to_time_gm(struct tm *time, bool *truncated);
......
...@@ -57,6 +57,17 @@ namespace mrn { ...@@ -57,6 +57,17 @@ namespace mrn {
double value; double value;
float8get(value, source); float8get(value, source);
*dest = value; *dest = value;
#endif
DBUG_VOID_RETURN;
}
void decode(long long int *dest, const uchar *source) {
MRN_DBUG_ENTER_FUNCTION();
#ifdef MRN_DEST_IS_POINTER
longlongget(dest, source);
#else
long long int value;
longlongget(value, source);
*dest = value;
#endif #endif
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -27,6 +27,7 @@ namespace mrn { ...@@ -27,6 +27,7 @@ namespace mrn {
void decode(uint16 *dest, const uchar *source); void decode(uint16 *dest, const uchar *source);
void decode(float *dest, const uchar *source); void decode(float *dest, const uchar *source);
void decode(double *dest, const uchar *source); void decode(double *dest, const uchar *source);
void decode(long long int *dest, const uchar *source);
} }
} }
......
...@@ -42,8 +42,8 @@ ...@@ -42,8 +42,8 @@
#define MRN_COLUMN_NAME_ID "_id" #define MRN_COLUMN_NAME_ID "_id"
#define MRN_COLUMN_NAME_KEY "_key" #define MRN_COLUMN_NAME_KEY "_key"
#define MRN_COLUMN_NAME_SCORE "_score" #define MRN_COLUMN_NAME_SCORE "_score"
#ifndef MRN_PARSER_DEFAULT #ifndef MRN_DEFAULT_TOKENIZER
# define MRN_PARSER_DEFAULT "TokenBigram" # define MRN_DEFAULT_TOKENIZER "TokenBigram"
#endif #endif
#endif /* MRN_CONSTANTS_HPP_ */ #endif /* MRN_CONSTANTS_HPP_ */
/* Copyright(C) 2011 Kentoku SHIBA /*
Copyright(C) 2011 Kentoku SHIBA
Copyright(C) 2014-2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
...@@ -33,7 +35,7 @@ ...@@ -33,7 +35,7 @@
"The column flag '%-.64s' is unsupported. It is ignored" "The column flag '%-.64s' is unsupported. It is ignored"
#define ER_MRN_INVALID_COLUMN_FLAG_NUM 16507 #define ER_MRN_INVALID_COLUMN_FLAG_NUM 16507
#define ER_MRN_INVALID_COLUMN_FLAG_STR \ #define ER_MRN_INVALID_COLUMN_FLAG_STR \
"The column flag '%-.64s' is invalid. '%-64s' is used instead" "The column flag '%-.64s' is invalid. It is ignored"
#define ER_MRN_INVALID_INDEX_FLAG_NUM 16508 #define ER_MRN_INVALID_INDEX_FLAG_NUM 16508
#define ER_MRN_INVALID_INDEX_FLAG_STR \ #define ER_MRN_INVALID_INDEX_FLAG_STR \
"The index flag '%-.64s' is invalid. It is ignored" "The index flag '%-.64s' is invalid. It is ignored"
......
...@@ -33,20 +33,11 @@ ...@@ -33,20 +33,11 @@
#endif #endif
#if defined(MRN_MARIADB_P) #if defined(MRN_MARIADB_P)
# if MYSQL_VERSION_ID >= 50302 && MYSQL_VERSION_ID < 100000 # if MYSQL_VERSION_ID < 100000
typedef COST_VECT Cost_estimate; typedef COST_VECT Cost_estimate;
# endif # endif
#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 #ifndef MRN_MARIADB_P
typedef char *range_id_t; typedef char *range_id_t;
#endif #endif
...@@ -79,9 +70,11 @@ ...@@ -79,9 +70,11 @@
#if MYSQL_VERSION_ID >= 50607 #if MYSQL_VERSION_ID >= 50607
# if MYSQL_VERSION_ID >= 100007 && defined(MRN_MARIADB_P) # if MYSQL_VERSION_ID >= 100007 && defined(MRN_MARIADB_P)
# define MRN_GET_ERROR_MESSAGE thd_get_error_message(current_thd) # define MRN_GET_ERROR_MESSAGE thd_get_error_message(current_thd)
# define MRN_GET_ERROR_NUMBER thd_get_error_number(current_thd)
# define MRN_GET_CURRENT_ROW_FOR_WARNING(thd) thd_get_error_row(thd) # define MRN_GET_CURRENT_ROW_FOR_WARNING(thd) thd_get_error_row(thd)
# else # else
# define MRN_GET_ERROR_MESSAGE current_thd->get_stmt_da()->message() # define MRN_GET_ERROR_MESSAGE current_thd->get_stmt_da()->message()
# define MRN_GET_ERROR_NUMBER current_thd->get_stmt_da()->sql_errno()
# if MYSQL_VERSION_ID >= 50706 # if MYSQL_VERSION_ID >= 50706
# define MRN_GET_CURRENT_ROW_FOR_WARNING(thd) \ # define MRN_GET_CURRENT_ROW_FOR_WARNING(thd) \
thd->get_stmt_da()->current_row_for_condition() thd->get_stmt_da()->current_row_for_condition()
...@@ -91,20 +84,16 @@ ...@@ -91,20 +84,16 @@
# endif # endif
# endif # endif
#else #else
# if MYSQL_VERSION_ID >= 50500
# define MRN_GET_ERROR_MESSAGE current_thd->stmt_da->message() # define MRN_GET_ERROR_MESSAGE current_thd->stmt_da->message()
# define MRN_GET_ERROR_NUMBER current_thd->stmt_da->sql_errno()
# define MRN_GET_CURRENT_ROW_FOR_WARNING(thd) thd->warning_info->current_row_for_warning() # 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 #endif
#if MYSQL_VERSION_ID >= 50607 && !defined(MRN_MARIADB_P) #if MYSQL_VERSION_ID >= 50607 && !defined(MRN_MARIADB_P)
# define MRN_ITEM_HAVE_ITEM_NAME # define MRN_ITEM_HAVE_ITEM_NAME
#endif #endif
#if MYSQL_VERSION_ID >= 50500 && MYSQL_VERSION_ID < 100000 #if MYSQL_VERSION_ID < 100000
# define MRN_HAVE_TABLE_DEF_CACHE # define MRN_HAVE_TABLE_DEF_CACHE
#endif #endif
...@@ -124,10 +113,6 @@ ...@@ -124,10 +113,6 @@
# define MRN_TABLE_SHARE_HAVE_LOCK_SHARE # define MRN_TABLE_SHARE_HAVE_LOCK_SHARE
#endif #endif
#if MYSQL_VERSION_ID >= 50404
# define MRN_TABLE_SHARE_HAVE_LOCK_HA_DATA
#endif
#ifndef TIME_FUZZY_DATE #ifndef TIME_FUZZY_DATE
/* For MariaDB 10. */ /* For MariaDB 10. */
# ifdef TIME_FUZZY_DATES # ifdef TIME_FUZZY_DATES
...@@ -217,4 +202,42 @@ ...@@ -217,4 +202,42 @@
# define MRN_FORMAT_STRING_LENGTH "u" # define MRN_FORMAT_STRING_LENGTH "u"
#endif #endif
#ifdef MRN_MARIADB_P
# define MRN_SUPPORT_CUSTOM_OPTIONS
#endif
#if defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100000
# if MYSQL_VERSION_ID >= 100104
# define mrn_init_sql_alloc(thd, mem_root) \
init_sql_alloc(mem_root, \
TABLE_ALLOC_BLOCK_SIZE, \
0, \
MYF(thd->slave_thread ? 0 : MY_THREAD_SPECIFIC))
# else
# define mrn_init_sql_alloc(thd, mem_root) \
init_sql_alloc(mem_root, \
TABLE_ALLOC_BLOCK_SIZE, \
0, \
MYF(0))
# endif
#else
# define mrn_init_sql_alloc(thd, mem_root) \
init_sql_alloc(mem_root, \
TABLE_ALLOC_BLOCK_SIZE, \
0)
#endif
#ifdef MRN_MARIADB_P
# define MRN_ABORT_ON_WARNING(thd) thd->abort_on_warning
#else
# if MYSQL_VERSION_ID >= 50706
# define MRN_ABORT_ON_WARNING(thd) false
# else
# define MRN_ABORT_ON_WARNING(thd) thd->abort_on_warning
# endif
#endif
#define MRN_ERROR_CODE_DATA_TRUNCATE(thd) \
(MRN_ABORT_ON_WARNING(thd) ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED)
#endif /* MRN_MYSQL_COMPAT_H_ */ #endif /* MRN_MYSQL_COMPAT_H_ */
...@@ -35,10 +35,18 @@ ...@@ -35,10 +35,18 @@
#include "mrn_variables.hpp" #include "mrn_variables.hpp"
#include <mrn_lock.hpp> #include <mrn_lock.hpp>
#if MYSQL_VERSION_ID >= 50603 #ifdef MRN_MARIADB_P
# if MYSQL_VERSION_ID >= 100100
# define MRN_HA_RESOLVE_BY_NAME(name) ha_resolve_by_name(NULL, (name), TRUE) # define MRN_HA_RESOLVE_BY_NAME(name) ha_resolve_by_name(NULL, (name), TRUE)
# else
# define MRN_HA_RESOLVE_BY_NAME(name) ha_resolve_by_name(NULL, (name))
# endif
#else #else
# if MYSQL_VERSION_ID >= 50603
# define MRN_HA_RESOLVE_BY_NAME(name) ha_resolve_by_name(NULL, (name), TRUE)
# else
# define MRN_HA_RESOLVE_BY_NAME(name) ha_resolve_by_name(NULL, (name)) # define MRN_HA_RESOLVE_BY_NAME(name) ha_resolve_by_name(NULL, (name))
# endif
#endif #endif
#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P) #if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
...@@ -68,10 +76,8 @@ extern "C" { ...@@ -68,10 +76,8 @@ extern "C" {
# ifdef MRN_TABLE_SHARE_HAVE_LOCK_SHARE # ifdef MRN_TABLE_SHARE_HAVE_LOCK_SHARE
extern PSI_mutex_key *mrn_table_share_lock_share; extern PSI_mutex_key *mrn_table_share_lock_share;
# endif # endif
# ifdef MRN_TABLE_SHARE_HAVE_LOCK_HA_DATA
extern PSI_mutex_key *mrn_table_share_lock_ha_data; extern PSI_mutex_key *mrn_table_share_lock_ha_data;
# endif # endif
# endif
extern PSI_mutex_key mrn_share_mutex_key; extern PSI_mutex_key mrn_share_mutex_key;
extern PSI_mutex_key mrn_long_term_share_auto_inc_mutex_key; extern PSI_mutex_key mrn_long_term_share_auto_inc_mutex_key;
#endif #endif
...@@ -80,7 +86,7 @@ extern HASH mrn_open_tables; ...@@ -80,7 +86,7 @@ extern HASH mrn_open_tables;
extern mysql_mutex_t mrn_open_tables_mutex; extern mysql_mutex_t mrn_open_tables_mutex;
extern HASH mrn_long_term_share; extern HASH mrn_long_term_share;
extern mysql_mutex_t mrn_long_term_share_mutex; extern mysql_mutex_t mrn_long_term_share_mutex;
extern char *mrn_default_parser; extern char *mrn_default_tokenizer;
extern char *mrn_default_wrapper_engine; extern char *mrn_default_wrapper_engine;
extern handlerton *mrn_hton_ptr; extern handlerton *mrn_hton_ptr;
extern HASH mrn_allocated_thds; extern HASH mrn_allocated_thds;
...@@ -333,8 +339,8 @@ int mrn_parse_table_param(MRN_SHARE *share, TABLE *table) ...@@ -333,8 +339,8 @@ int mrn_parse_table_param(MRN_SHARE *share, TABLE *table)
for (i = 2; i > 0; i--) for (i = 2; i > 0; i--)
#endif #endif
{ {
const char *params_string_value; const char *params_string_value = NULL;
uint params_string_length; uint params_string_length = 0;
switch (i) switch (i)
{ {
#ifdef WITH_PARTITION_STORAGE_ENGINE #ifdef WITH_PARTITION_STORAGE_ENGINE
...@@ -515,16 +521,16 @@ int mrn_add_index_param(MRN_SHARE *share, KEY *key_info, int i) ...@@ -515,16 +521,16 @@ int mrn_add_index_param(MRN_SHARE *share, KEY *key_info, int i)
#if MYSQL_VERSION_ID >= 50500 #if MYSQL_VERSION_ID >= 50500
if (key_info->comment.length == 0) if (key_info->comment.length == 0)
{ {
if (share->key_parser[i]) { if (share->key_tokenizer[i]) {
my_free(share->key_parser[i]); my_free(share->key_tokenizer[i]);
} }
if ( share->key_tokenizer[i] = mrn_my_strdup(mrn_default_tokenizer, MYF(MY_WME));
!(share->key_parser[i] = mrn_my_strdup(mrn_default_parser, MYF(MY_WME))) if (!share->key_tokenizer[i]) {
) {
error = HA_ERR_OUT_OF_MEM; error = HA_ERR_OUT_OF_MEM;
goto error; goto error;
} }
share->key_parser_length[i] = strlen(share->key_parser[i]); share->key_tokenizer_length[i] = strlen(share->key_tokenizer[i]);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
DBUG_PRINT("info", ("mroonga create comment string")); DBUG_PRINT("info", ("mroonga create comment string"));
...@@ -572,21 +578,23 @@ int mrn_add_index_param(MRN_SHARE *share, KEY *key_info, int i) ...@@ -572,21 +578,23 @@ int mrn_add_index_param(MRN_SHARE *share, KEY *key_info, int i)
MRN_PARAM_STR_LIST("table", index_table, i); MRN_PARAM_STR_LIST("table", index_table, i);
break; break;
case 6: case 6:
MRN_PARAM_STR_LIST("parser", key_parser, i); MRN_PARAM_STR_LIST("parser", key_tokenizer, i);
break;
case 9:
MRN_PARAM_STR_LIST("tokenizer", key_tokenizer, i);
break; break;
default: default:
break; break;
} }
} }
#endif #endif
if (!share->key_parser[i]) { if (!share->key_tokenizer[i]) {
if ( share->key_tokenizer[i] = mrn_my_strdup(mrn_default_tokenizer, MYF(MY_WME));
!(share->key_parser[i] = mrn_my_strdup(mrn_default_parser, MYF(MY_WME))) if (!share->key_tokenizer[i]) {
) {
error = HA_ERR_OUT_OF_MEM; error = HA_ERR_OUT_OF_MEM;
goto error; goto error;
} }
share->key_parser_length[i] = strlen(share->key_parser[i]); share->key_tokenizer_length[i] = strlen(share->key_tokenizer[i]);
} }
if (param_string) if (param_string)
...@@ -687,6 +695,9 @@ int mrn_add_column_param(MRN_SHARE *share, Field *field, int i) ...@@ -687,6 +695,9 @@ int mrn_add_column_param(MRN_SHARE *share, Field *field, int i)
case 5: case 5:
MRN_PARAM_STR_LIST("flags", col_flags, i); MRN_PARAM_STR_LIST("flags", col_flags, i);
break; break;
case 12:
MRN_PARAM_STR_LIST("groonga_type", col_type, i);
break;
default: default:
break; break;
} }
...@@ -741,8 +752,8 @@ int mrn_free_share_alloc( ...@@ -741,8 +752,8 @@ int mrn_free_share_alloc(
{ {
if (share->index_table && share->index_table[i]) if (share->index_table && share->index_table[i])
my_free(share->index_table[i]); my_free(share->index_table[i]);
if (share->key_parser[i]) if (share->key_tokenizer[i])
my_free(share->key_parser[i]); my_free(share->key_tokenizer[i]);
} }
for (i = 0; i < share->table_share->fields; i++) for (i = 0; i < share->table_share->fields; i++)
{ {
...@@ -817,9 +828,9 @@ error_alloc_long_term_share: ...@@ -817,9 +828,9 @@ error_alloc_long_term_share:
MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error) MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error)
{ {
MRN_SHARE *share; MRN_SHARE *share;
char *tmp_name, **index_table, **key_parser, **col_flags, **col_type; char *tmp_name, **index_table, **key_tokenizer, **col_flags, **col_type;
uint length, *wrap_key_nr, *index_table_length; uint length, *wrap_key_nr, *index_table_length;
uint *key_parser_length, *col_flags_length, *col_type_length, i, j; uint *key_tokenizer_length, *col_flags_length, *col_type_length, i, j;
KEY *wrap_key_info; KEY *wrap_key_info;
TABLE_SHARE *wrap_table_share; TABLE_SHARE *wrap_table_share;
MRN_DBUG_ENTER_FUNCTION(); MRN_DBUG_ENTER_FUNCTION();
...@@ -834,8 +845,8 @@ MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error) ...@@ -834,8 +845,8 @@ MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error)
&tmp_name, length + 1, &tmp_name, length + 1,
&index_table, sizeof(char *) * table->s->keys, &index_table, sizeof(char *) * table->s->keys,
&index_table_length, sizeof(uint) * table->s->keys, &index_table_length, sizeof(uint) * table->s->keys,
&key_parser, sizeof(char *) * table->s->keys, &key_tokenizer, sizeof(char *) * table->s->keys,
&key_parser_length, sizeof(uint) * table->s->keys, &key_tokenizer_length, sizeof(uint) * table->s->keys,
&col_flags, sizeof(char *) * table->s->fields, &col_flags, sizeof(char *) * table->s->fields,
&col_flags_length, sizeof(uint) * table->s->fields, &col_flags_length, sizeof(uint) * table->s->fields,
&col_type, sizeof(char *) * table->s->fields, &col_type, sizeof(char *) * table->s->fields,
...@@ -853,8 +864,8 @@ MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error) ...@@ -853,8 +864,8 @@ MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error)
share->table_name = tmp_name; share->table_name = tmp_name;
share->index_table = index_table; share->index_table = index_table;
share->index_table_length = index_table_length; share->index_table_length = index_table_length;
share->key_parser = key_parser; share->key_tokenizer = key_tokenizer;
share->key_parser_length = key_parser_length; share->key_tokenizer_length = key_tokenizer_length;
share->col_flags = col_flags; share->col_flags = col_flags;
share->col_flags_length = col_flags_length; share->col_flags_length = col_flags_length;
share->col_type = col_type; share->col_type = col_type;
...@@ -903,6 +914,7 @@ MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error) ...@@ -903,6 +914,7 @@ MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error)
share->wrap_primary_key = MAX_KEY; share->wrap_primary_key = MAX_KEY;
} }
memcpy(wrap_table_share, table->s, sizeof(*wrap_table_share)); memcpy(wrap_table_share, table->s, sizeof(*wrap_table_share));
mrn_init_sql_alloc(current_thd, &(wrap_table_share->mem_root));
wrap_table_share->keys = share->wrap_keys; wrap_table_share->keys = share->wrap_keys;
wrap_table_share->key_info = share->wrap_key_info; wrap_table_share->key_info = share->wrap_key_info;
wrap_table_share->primary_key = share->wrap_primary_key; wrap_table_share->primary_key = share->wrap_primary_key;
...@@ -917,20 +929,18 @@ MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error) ...@@ -917,20 +929,18 @@ MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error)
&(wrap_table_share->LOCK_share), MY_MUTEX_INIT_SLOW); &(wrap_table_share->LOCK_share), MY_MUTEX_INIT_SLOW);
# endif # endif
#endif #endif
#ifdef MRN_TABLE_SHARE_HAVE_LOCK_HA_DATA #ifdef WIN32
# ifdef WIN32
mysql_mutex_init(*mrn_table_share_lock_ha_data, mysql_mutex_init(*mrn_table_share_lock_ha_data,
&(wrap_table_share->LOCK_ha_data), MY_MUTEX_INIT_FAST); &(wrap_table_share->LOCK_ha_data), MY_MUTEX_INIT_FAST);
# else #else
mysql_mutex_init(key_TABLE_SHARE_LOCK_ha_data, mysql_mutex_init(key_TABLE_SHARE_LOCK_ha_data,
&(wrap_table_share->LOCK_ha_data), MY_MUTEX_INIT_FAST); &(wrap_table_share->LOCK_ha_data), MY_MUTEX_INIT_FAST);
# endif
#endif #endif
share->wrap_table_share = wrap_table_share; share->wrap_table_share = wrap_table_share;
} }
if (mysql_mutex_init(mrn_share_mutex_key, if (mysql_mutex_init(mrn_share_mutex_key,
&share->mutex, &share->record_mutex,
MY_MUTEX_INIT_FAST) != 0) MY_MUTEX_INIT_FAST) != 0)
{ {
*error = HA_ERR_OUT_OF_MEM; *error = HA_ERR_OUT_OF_MEM;
...@@ -953,7 +963,7 @@ MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error) ...@@ -953,7 +963,7 @@ MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error)
error_hash_insert: error_hash_insert:
error_get_long_term_share: error_get_long_term_share:
mysql_mutex_destroy(&share->mutex); mysql_mutex_destroy(&share->record_mutex);
error_init_mutex: error_init_mutex:
error_parse_table_param: error_parse_table_param:
mrn_free_share_alloc(share); mrn_free_share_alloc(share);
...@@ -973,14 +983,13 @@ int mrn_free_share(MRN_SHARE *share) ...@@ -973,14 +983,13 @@ int mrn_free_share(MRN_SHARE *share)
plugin_unlock(NULL, share->plugin); plugin_unlock(NULL, share->plugin);
mrn_free_share_alloc(share); mrn_free_share_alloc(share);
thr_lock_delete(&share->lock); thr_lock_delete(&share->lock);
mysql_mutex_destroy(&share->mutex); mysql_mutex_destroy(&share->record_mutex);
if (share->wrapper_mode) { if (share->wrapper_mode) {
#ifdef MRN_TABLE_SHARE_HAVE_LOCK_SHARE #ifdef MRN_TABLE_SHARE_HAVE_LOCK_SHARE
mysql_mutex_destroy(&(share->wrap_table_share->LOCK_share)); mysql_mutex_destroy(&(share->wrap_table_share->LOCK_share));
#endif #endif
#ifdef MRN_TABLE_SHARE_HAVE_LOCK_HA_DATA
mysql_mutex_destroy(&(share->wrap_table_share->LOCK_ha_data)); mysql_mutex_destroy(&(share->wrap_table_share->LOCK_ha_data));
#endif free_root(&(share->wrap_table_share->mem_root), MYF(0));
} }
my_free(share); my_free(share);
} }
...@@ -1114,7 +1123,7 @@ st_mrn_slot_data *mrn_get_slot_data(THD *thd, bool can_create) ...@@ -1114,7 +1123,7 @@ st_mrn_slot_data *mrn_get_slot_data(THD *thd, bool can_create)
if (slot_data == NULL) { if (slot_data == NULL) {
slot_data = (st_mrn_slot_data*) malloc(sizeof(st_mrn_slot_data)); slot_data = (st_mrn_slot_data*) malloc(sizeof(st_mrn_slot_data));
slot_data->last_insert_record_id = GRN_ID_NIL; slot_data->last_insert_record_id = GRN_ID_NIL;
slot_data->first_alter_share = NULL; slot_data->first_wrap_hton = NULL;
slot_data->alter_create_info = NULL; slot_data->alter_create_info = NULL;
slot_data->disable_keys_create_info = NULL; slot_data->disable_keys_create_info = NULL;
slot_data->alter_connect_string = NULL; slot_data->alter_connect_string = NULL;
...@@ -1132,22 +1141,21 @@ st_mrn_slot_data *mrn_get_slot_data(THD *thd, bool can_create) ...@@ -1132,22 +1141,21 @@ st_mrn_slot_data *mrn_get_slot_data(THD *thd, bool can_create)
DBUG_RETURN(slot_data); DBUG_RETURN(slot_data);
} }
void mrn_clear_alter_share(THD *thd) void mrn_clear_slot_data(THD *thd)
{ {
MRN_DBUG_ENTER_FUNCTION(); MRN_DBUG_ENTER_FUNCTION();
st_mrn_slot_data *slot_data = mrn_get_slot_data(thd, FALSE); st_mrn_slot_data *slot_data = mrn_get_slot_data(thd, FALSE);
if (slot_data) { if (slot_data) {
if (slot_data->first_alter_share) { if (slot_data->first_wrap_hton) {
st_mrn_alter_share *tmp_alter_share; st_mrn_wrap_hton *tmp_wrap_hton;
st_mrn_alter_share *alter_share = slot_data->first_alter_share; st_mrn_wrap_hton *wrap_hton = slot_data->first_wrap_hton;
while (alter_share) while (wrap_hton)
{ {
tmp_alter_share = alter_share->next; tmp_wrap_hton = wrap_hton->next;
mrn_free_tmp_table_share(alter_share->alter_share); free(wrap_hton);
free(alter_share); wrap_hton = tmp_wrap_hton;
alter_share = tmp_alter_share;
} }
slot_data->first_alter_share = NULL; slot_data->first_wrap_hton = NULL;
} }
slot_data->alter_create_info = NULL; slot_data->alter_create_info = NULL;
slot_data->disable_keys_create_info = NULL; slot_data->disable_keys_create_info = NULL;
......
/* -*- c-basic-offset: 2 -*- */ /* -*- c-basic-offset: 2 -*- */
/* /*
Copyright(C) 2011-2013 Kentoku SHIBA Copyright(C) 2011-2013 Kentoku SHIBA
Copyright(C) 2011-2013 Kouhei Sutou <kou@clear-code.com> Copyright(C) 2011-2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
...@@ -43,7 +43,7 @@ typedef struct st_mroonga_share ...@@ -43,7 +43,7 @@ typedef struct st_mroonga_share
char *table_name; char *table_name;
uint table_name_length; uint table_name_length;
uint use_count; uint use_count;
mysql_mutex_t mutex; mysql_mutex_t record_mutex;
THR_LOCK lock; THR_LOCK lock;
TABLE_SHARE *table_share; TABLE_SHARE *table_share;
TABLE_SHARE *wrap_table_share; TABLE_SHARE *wrap_table_share;
...@@ -60,11 +60,11 @@ typedef struct st_mroonga_share ...@@ -60,11 +60,11 @@ typedef struct st_mroonga_share
plugin_ref plugin; plugin_ref plugin;
handlerton *hton; handlerton *hton;
char **index_table; char **index_table;
char **key_parser; char **key_tokenizer;
char **col_flags; char **col_flags;
char **col_type; char **col_type;
uint *index_table_length; uint *index_table_length;
uint *key_parser_length; uint *key_tokenizer_length;
uint *col_flags_length; uint *col_flags_length;
uint *col_type_length; uint *col_type_length;
uint *wrap_key_nr; uint *wrap_key_nr;
...@@ -78,17 +78,17 @@ typedef struct st_mroonga_share ...@@ -78,17 +78,17 @@ typedef struct st_mroonga_share
bool disable_keys; bool disable_keys;
} MRN_SHARE; } MRN_SHARE;
struct st_mrn_alter_share struct st_mrn_wrap_hton
{ {
char path[FN_REFLEN + 1]; char path[FN_REFLEN + 1];
TABLE_SHARE *alter_share; handlerton *hton;
st_mrn_alter_share *next; st_mrn_wrap_hton *next;
}; };
struct st_mrn_slot_data struct st_mrn_slot_data
{ {
grn_id last_insert_record_id; grn_id last_insert_record_id;
st_mrn_alter_share *first_alter_share; st_mrn_wrap_hton *first_wrap_hton;
HA_CREATE_INFO *alter_create_info; HA_CREATE_INFO *alter_create_info;
HA_CREATE_INFO *disable_keys_create_info; HA_CREATE_INFO *disable_keys_create_info;
char *alter_connect_string; char *alter_connect_string;
...@@ -167,7 +167,7 @@ void mrn_free_tmp_table_share(TABLE_SHARE *table_share); ...@@ -167,7 +167,7 @@ void mrn_free_tmp_table_share(TABLE_SHARE *table_share);
KEY *mrn_create_key_info_for_table(MRN_SHARE *share, TABLE *table, int *error); 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); 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); st_mrn_slot_data *mrn_get_slot_data(THD *thd, bool can_create);
void mrn_clear_alter_share(THD *thd); void mrn_clear_slot_data(THD *thd);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
# Copyright(C) 2015 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--disable_query_log
let $libgroonga_embedded = `SELECT @@mroonga_libgroonga_embedded;`;
--enable_query_log
# Copyright(C) 2015 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_libgroonga_embedded.inc
if ($libgroonga_embedded) {
--source ../../include/mroonga/have_mroonga_deinit.inc
skip "This test requires plugin_register of Groonga. libgroonga embedded build doesn't support it.";
}
# Copyright(C) 2012 Kouhei Sutou <kou@clear-code.com> # Copyright(C) 2015 Kouhei Sutou <kou@clear-code.com>
# #
# This library is free software; you can redistribute it and/or # This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # modify it under the terms of the GNU Lesser General Public
...@@ -14,12 +14,8 @@ ...@@ -14,12 +14,8 @@
# License along with this library; if not, write to the Free Software # License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # 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_or_later) { if (!$mariadb) {
let $fulltext_index_comment = 1; skip This test is for MariaDB;
}
if (!$fulltext_index_comment) {
skip Fulltext index comment is available in version 5.5 or later;
} }
...@@ -38,6 +38,9 @@ if (!$have_default_storage_engine_variable) { ...@@ -38,6 +38,9 @@ if (!$have_default_storage_engine_variable) {
let have_default_tmp_storage_engine_variable=`SELECT 1 FROM information_schema.global_variables WHERE variable_name = "default_tmp_storage_engine"`; 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) { 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"`; let original_default_tmp_storage_engine=`SELECT variable_value FROM information_schema.global_variables WHERE variable_name = "default_tmp_storage_engine"`;
if (!$original_default_tmp_storage_engine) {
let original_default_tmp_storage_engine=NULL;
}
set default_tmp_storage_engine=Mroonga; set default_tmp_storage_engine=Mroonga;
} }
......
CREATE TABLE tags (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
) DEFAULT CHARSET=utf8;
ALTER TABLE tags ADD COLUMN name VARCHAR(64) FLAGS='COLUMN_VECTOR';
SHOW CREATE TABLE tags;
Table Create Table
tags CREATE TABLE `tags` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(64) DEFAULT NULL `FLAGS`='COLUMN_VECTOR',
PRIMARY KEY (`id`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create tags TABLE_PAT_KEY UInt32
column_create tags id COLUMN_SCALAR UInt32
column_create tags name COLUMN_VECTOR ShortText
DROP TABLE tags;
CREATE TABLE tags (
id INT UNSIGNED PRIMARY KEY
) DEFAULT CHARSET=utf8;
CREATE TABLE bugs (
id INT UNSIGNED PRIMARY KEY
) DEFAULT CHARSET=utf8;
ALTER TABLE bugs ADD COLUMN name VARCHAR(64) COMMENT 'groonga_type "tags"';
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create tags TABLE_PAT_KEY UInt32
column_create tags id COLUMN_SCALAR UInt32
table_create bugs TABLE_PAT_KEY UInt32
column_create bugs id COLUMN_SCALAR UInt32
column_create bugs name COLUMN_SCALAR tags
DROP TABLE bugs;
DROP TABLE tags;
CREATE TABLE tags (
id INT UNSIGNED PRIMARY KEY
) DEFAULT CHARSET=utf8;
CREATE TABLE bugs (
id INT UNSIGNED PRIMARY KEY
) DEFAULT CHARSET=utf8;
ALTER TABLE bugs ADD COLUMN name VARCHAR(64) GROONGA_TYPE='tags';
SHOW CREATE TABLE bugs;
Table Create Table
bugs CREATE TABLE `bugs` (
`id` int(10) unsigned NOT NULL,
`name` varchar(64) DEFAULT NULL `GROONGA_TYPE`='tags',
PRIMARY KEY (`id`),
CONSTRAINT `name` FOREIGN KEY (`name`) REFERENCES `test`.`tags` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=Mroonga DEFAULT CHARSET=utf8
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create tags TABLE_PAT_KEY UInt32
column_create tags id COLUMN_SCALAR UInt32
table_create bugs TABLE_PAT_KEY UInt32
column_create bugs id COLUMN_SCALAR UInt32
column_create bugs name COLUMN_SCALAR tags
DROP TABLE bugs;
DROP TABLE tags;
SELECT mroonga_command("register token_filters/stop_word"); SELECT mroonga_command("plugin_register token_filters/stop_word");
mroonga_command("register token_filters/stop_word") mroonga_command("plugin_register token_filters/stop_word")
true true
SET NAMES utf8; SET NAMES utf8;
CREATE TABLE memos ( CREATE TABLE memos (
......
SELECT mroonga_command("register token_filters/stop_word"); SELECT mroonga_command("plugin_register token_filters/stop_word");
mroonga_command("register token_filters/stop_word") mroonga_command("plugin_register token_filters/stop_word")
true true
CREATE TABLE terms ( CREATE TABLE terms (
term VARCHAR(64) NOT NULL PRIMARY KEY, term VARCHAR(64) NOT NULL PRIMARY KEY,
......
DROP TABLE IF EXISTS timestamps;
CREATE TABLE timestamps (
id INT PRIMARY KEY AUTO_INCREMENT,
create_dt DATETIME
) DEFAULT CHARSET UTF8;
SHOW CREATE TABLE timestamps;
Table Create Table
timestamps CREATE TABLE `timestamps` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`create_dt` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8
SET sql_mode='STRICT_TRANS_TABLES';
INSERT INTO timestamps (create_dt) VALUES ("0000-00-00 00:00:00");
ERROR 22003: Out of range value for column 'create_dt' at row 1
SET sql_mode=default;
SELECT * FROM timestamps;
id create_dt
INSERT INTO timestamps (create_dt) VALUES ("2015-06-17 00:00:00");
SELECT * FROM timestamps;
id create_dt
2 2015-06-17 00:00:00
DROP TABLE timestamps;
CREATE TABLE bugs (
id INT UNSIGNED PRIMARY KEY,
tags TEXT FLAGS='COLUMN_VECTOR'
) DEFAULT CHARSET=utf8;
SHOW CREATE TABLE bugs;
Table Create Table
bugs CREATE TABLE `bugs` (
`id` int(10) unsigned NOT NULL,
`tags` text `FLAGS`='COLUMN_VECTOR',
PRIMARY KEY (`id`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create bugs TABLE_PAT_KEY UInt32
column_create bugs id COLUMN_SCALAR UInt32
column_create bugs tags COLUMN_VECTOR LongText
DROP TABLE bugs;
CREATE TABLE tags (
name VARCHAR(64) PRIMARY KEY
) DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE bugs (
id INT UNSIGNED PRIMARY KEY,
tag VARCHAR(64) COMMENT 'groonga_type "tags"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create tags TABLE_PAT_KEY ShortText
column_create tags name COLUMN_SCALAR ShortText
table_create bugs TABLE_PAT_KEY UInt32
column_create bugs id COLUMN_SCALAR UInt32
column_create bugs tag COLUMN_SCALAR tags
DROP TABLE bugs;
DROP TABLE tags;
DROP TABLE IF EXISTS bugs;
CREATE TABLE bugs (
id INT UNSIGNED PRIMARY KEY,
tag VARCHAR(64) COMMENT 'groonga_type "Nonexistent"'
) DEFAULT CHARSET=utf8mb4;
ERROR HY000: unknown custom Groonga type name for <tag> column: <Nonexistent>
CREATE TABLE tags (
name VARCHAR(64) PRIMARY KEY
) DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE bugs (
id INT UNSIGNED PRIMARY KEY,
tag VARCHAR(64) GROONGA_TYPE='tags'
) DEFAULT CHARSET=utf8;
SHOW CREATE TABLE bugs;
Table Create Table
bugs CREATE TABLE `bugs` (
`id` int(10) unsigned NOT NULL,
`tag` varchar(64) DEFAULT NULL `GROONGA_TYPE`='tags',
PRIMARY KEY (`id`),
CONSTRAINT `tag` FOREIGN KEY (`tag`) REFERENCES `test`.`tags` (`name`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=Mroonga DEFAULT CHARSET=utf8
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create tags TABLE_PAT_KEY ShortText
column_create tags name COLUMN_SCALAR ShortText
table_create bugs TABLE_PAT_KEY UInt32
column_create bugs id COLUMN_SCALAR UInt32
column_create bugs tag COLUMN_SCALAR tags
DROP TABLE bugs;
DROP TABLE tags;
DROP TABLE IF EXISTS bugs;
CREATE TABLE bugs (
id INT UNSIGNED PRIMARY KEY,
tag VARCHAR(64) COMMENT 'type "Nonexistent"'
) DEFAULT CHARSET=utf8mb4;
ERROR HY000: unknown custom Groonga type name for <tag> column: <Nonexistent>
SET NAMES utf8;
CREATE TABLE memos (
content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) COMMENT 'flags "WITH_POSITION|WITH_WEIGHT"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump --dump_plugins no --dump_schema no");
mroonga_command("dump --dump_plugins no --dump_schema no")
column_create memos-content index COLUMN_INDEX|WITH_WEIGHT|WITH_POSITION memos content
DROP TABLE memos;
SET NAMES utf8; SET NAMES utf8;
CREATE TABLE memos ( CREATE TABLE memos (
content VARCHAR(64) NOT NULL, content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) COMMENT 'index_flags "NONE"' FULLTEXT INDEX (content) COMMENT 'flags "NONE"'
) DEFAULT CHARSET=utf8; ) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump --dump_plugins no --dump_schema no"); SELECT mroonga_command("dump --dump_plugins no --dump_schema no");
mroonga_command("dump --dump_plugins no --dump_schema no") mroonga_command("dump --dump_plugins no --dump_schema no")
......
SET NAMES utf8;
CREATE TABLE memos (
content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) FLAGS='WITH_POSITION|WITH_WEIGHT'
) DEFAULT CHARSET=utf8;
SHOW CREATE TABLE memos;
Table Create Table
memos CREATE TABLE `memos` (
`content` varchar(64) NOT NULL,
FULLTEXT KEY `content` (`content`) `FLAGS`='WITH_POSITION|WITH_WEIGHT'
) ENGINE=Mroonga DEFAULT CHARSET=utf8
SELECT mroonga_command("dump --dump_plugins no --dump_schema no");
mroonga_command("dump --dump_plugins no --dump_schema no")
column_create memos-content index COLUMN_INDEX|WITH_WEIGHT|WITH_POSITION memos content
DROP TABLE memos;
SET NAMES utf8;
CREATE TABLE memos (
content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) COMMENT 'index_flags "NONE"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump --dump_plugins no --dump_schema no");
mroonga_command("dump --dump_plugins no --dump_schema no")
column_create memos-content index COLUMN_INDEX memos content
DROP TABLE memos;
DROP TABLE IF EXISTS memos;
SET NAMES utf8;
CREATE TABLE memos (
id INT NOT NULL PRIMARY KEY,
content TEXT NOT NULL,
FULLTEXT INDEX (content) NORMALIZER='NormalizerAuto'
) DEFAULT CHARSET=utf8;
SHOW CREATE TABLE memos;
Table Create Table
memos CREATE TABLE `memos` (
`id` int(11) NOT NULL,
`content` text NOT NULL,
PRIMARY KEY (`id`),
FULLTEXT KEY `content` (`content`) `NORMALIZER`='NormalizerAuto'
) ENGINE=Mroonga DEFAULT CHARSET=utf8
INSERT INTO memos VALUES (1, "1日の消費㌍は約2000㌔㌍");
SELECT * FROM memos
WHERE MATCH (content) AGAINST ("+カロリー" IN BOOLEAN MODE);
id content
1 1日の消費㌍は約2000㌔㌍
DROP TABLE memos;
DROP TABLE IF EXISTS diaries;
CREATE TABLE diaries (
id int PRIMARY KEY AUTO_INCREMENT,
body text,
FULLTEXT INDEX body_index (body)
COMMENT 'parser "TokenBigramSplitSymbolAlphaDigit"'
) 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`),
FULLTEXT KEY `body_index` (`body`) COMMENT 'parser "TokenBigramSplitSymbolAlphaDigit"'
) ENGINE=Mroonga DEFAULT CHARSET=utf8
INSERT INTO diaries (body) VALUES ("will start Groonga!");
INSERT INTO diaries (body) VALUES ("starting Groonga...");
INSERT INTO diaries (body) VALUES ("started Groonga.");
SELECT * FROM diaries;
id body
1 will start Groonga!
2 starting Groonga...
3 started Groonga.
SELECT * FROM diaries
WHERE MATCH(body) AGAINST("+start" IN BOOLEAN MODE)
ORDER BY id;
id body
1 will start Groonga!
2 starting Groonga...
3 started Groonga.
DROP TABLE diaries;
...@@ -14,20 +14,20 @@ diaries CREATE TABLE `diaries` ( ...@@ -14,20 +14,20 @@ diaries CREATE TABLE `diaries` (
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
FULLTEXT KEY `body_index` (`body`) FULLTEXT KEY `body_index` (`body`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8 ) ENGINE=Mroonga DEFAULT CHARSET=utf8
insert into diaries (body) values ("will start groonga!"); insert into diaries (body) values ("will start Groonga!");
insert into diaries (body) values ("starting groonga..."); insert into diaries (body) values ("starting Groonga...");
insert into diaries (body) values ("started groonga."); insert into diaries (body) values ("started Groonga.");
insert into diaries (body) values ("finished groonga."); insert into diaries (body) values ("finished Groonga.");
select * from diaries; select * from diaries;
id body id body
1 will start groonga! 1 will start Groonga!
2 starting groonga... 2 starting Groonga...
3 started groonga. 3 started Groonga.
4 finished groonga. 4 finished Groonga.
select * from diaries where match(body) against("start"); select * from diaries where match(body) against("+start" IN BOOLEAN MODE) order by id;
id body id body
1 will start groonga! 1 will start Groonga!
2 starting groonga... 2 starting Groonga...
3 started groonga. 3 started Groonga.
drop table diaries; drop table diaries;
set global mroonga_default_parser=@mroonga_default_parser_backup; set global mroonga_default_parser=@mroonga_default_parser_backup;
SELECT mroonga_command("register token_filters/stop_word"); SELECT mroonga_command("plugin_register token_filters/stop_word");
mroonga_command("register token_filters/stop_word") mroonga_command("plugin_register token_filters/stop_word")
true true
SET NAMES utf8; SET NAMES utf8;
CREATE TABLE memos ( CREATE TABLE memos (
......
SELECT mroonga_command("register token_filters/stop_word"); SELECT mroonga_command("plugin_register token_filters/stop_word");
mroonga_command("register token_filters/stop_word") mroonga_command("plugin_register token_filters/stop_word")
true true
SET NAMES utf8; SET NAMES utf8;
CREATE TABLE memos ( CREATE TABLE memos (
......
SELECT mroonga_command("plugin_register token_filters/stop_word");
mroonga_command("plugin_register token_filters/stop_word")
true
SET NAMES utf8;
CREATE TABLE memos (
content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) TOKEN_FILTERS='TokenFilterStopWord,TokenFilterStopWord'
) DEFAULT CHARSET=utf8;
SHOW CREATE TABLE memos;
Table Create Table
memos CREATE TABLE `memos` (
`content` varchar(64) NOT NULL,
FULLTEXT KEY `content` (`content`) `TOKEN_FILTERS`='TokenFilterStopWord,TokenFilterStopWord'
) ENGINE=Mroonga DEFAULT CHARSET=utf8
SELECT mroonga_command("dump --dump_plugins no");
mroonga_command("dump --dump_plugins no")
table_create memos TABLE_NO_KEY
column_create memos content COLUMN_SCALAR ShortText
table_create memos-content TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerMySQLGeneralCI --token_filters TokenFilterStopWord,TokenFilterStopWord
column_create memos-content index COLUMN_INDEX|WITH_POSITION memos content
DROP TABLE memos;
DROP TABLE IF EXISTS diaries;
CREATE TABLE diaries (
id int PRIMARY KEY AUTO_INCREMENT,
body text,
FULLTEXT INDEX body_index (body)
COMMENT 'tokenizer "TokenBigramSplitSymbolAlphaDigit"'
) 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`),
FULLTEXT KEY `body_index` (`body`) COMMENT 'tokenizer "TokenBigramSplitSymbolAlphaDigit"'
) ENGINE=Mroonga DEFAULT CHARSET=utf8
INSERT INTO diaries (body) VALUES ("will start Groonga!");
INSERT INTO diaries (body) VALUES ("starting Groonga...");
INSERT INTO diaries (body) VALUES ("started Groonga.");
SELECT * FROM diaries;
id body
1 will start Groonga!
2 starting Groonga...
3 started Groonga.
SELECT * FROM diaries
WHERE MATCH(body) AGAINST("+start" IN BOOLEAN MODE)
ORDER BY id;
id body
1 will start Groonga!
2 starting Groonga...
3 started Groonga.
DROP TABLE diaries;
drop table if exists diaries; drop table if exists diaries;
set @mroonga_default_tokenizer_backup=@@mroonga_default_tokenizer;
set global mroonga_default_tokenizer=TokenBigramSplitSymbolAlphaDigit;
create table diaries ( create table diaries (
id int primary key auto_increment, id int primary key auto_increment,
body text, body text,
fulltext index body_index (body) fulltext index body_index (body)
comment 'parser "TokenBigramSplitSymbolAlphaDigit"'
) default charset utf8; ) default charset utf8;
show create table diaries; show create table diaries;
Table Create Table Table Create Table
...@@ -11,19 +12,22 @@ diaries CREATE TABLE `diaries` ( ...@@ -11,19 +12,22 @@ diaries CREATE TABLE `diaries` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`body` text, `body` text,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
FULLTEXT KEY `body_index` (`body`) COMMENT 'parser "TokenBigramSplitSymbolAlphaDigit"' FULLTEXT KEY `body_index` (`body`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8 ) ENGINE=Mroonga DEFAULT CHARSET=utf8
insert into diaries (body) values ("will start groonga!"); insert into diaries (body) values ("will start Groonga!");
insert into diaries (body) values ("starting groonga..."); insert into diaries (body) values ("starting Groonga...");
insert into diaries (body) values ("started groonga."); insert into diaries (body) values ("started Groonga.");
insert into diaries (body) values ("finished Groonga.");
select * from diaries; select * from diaries;
id body id body
1 will start groonga! 1 will start Groonga!
2 starting groonga... 2 starting Groonga...
3 started groonga. 3 started Groonga.
select * from diaries where match(body) against("start"); 4 finished Groonga.
select * from diaries where match(body) against("+start" IN BOOLEAN MODE) order by id;
id body id body
1 will start groonga! 1 will start Groonga!
2 starting groonga... 2 starting Groonga...
3 started groonga. 3 started Groonga.
drop table diaries; drop table diaries;
set global mroonga_default_tokenizer=@mroonga_default_tokenizer_backup;
DROP TABLE IF EXISTS variables;
CREATE TABLE variables (
id INT PRIMARY KEY AUTO_INCREMENT,
name TEXT,
FULLTEXT INDEX (name) COMMENT 'tokenizer "off"'
) DEFAULT CHARSET=utf8;
SHOW CREATE TABLE variables;
Table Create Table
variables CREATE TABLE `variables` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` text,
PRIMARY KEY (`id`),
FULLTEXT KEY `name` (`name`) COMMENT 'tokenizer "off"'
) ENGINE=Mroonga DEFAULT CHARSET=utf8
INSERT INTO variables (name) VALUES ("mroonga_database_path_prefix");
INSERT INTO variables (name) VALUES ("mroonga_default_tokenizer");
INSERT INTO variables (name) VALUES ("mroonga_default_wrapper_engine");
INSERT INTO variables (name) VALUES ("mroonga_dry_write");
INSERT INTO variables (name) VALUES ("mroonga_enable_optimization");
INSERT INTO variables (name) VALUES ("mroonga_libgroonga_version");
INSERT INTO variables (name) VALUES ("mroonga_log_file");
INSERT INTO variables (name) VALUES ("mroonga_log_level");
INSERT INTO variables (name) VALUES ("mroonga_match_escalation_threshold");
INSERT INTO variables (name) VALUES ("mroonga_version");
SELECT * FROM variables;
id name
1 mroonga_database_path_prefix
2 mroonga_default_tokenizer
3 mroonga_default_wrapper_engine
4 mroonga_dry_write
5 mroonga_enable_optimization
6 mroonga_libgroonga_version
7 mroonga_log_file
8 mroonga_log_level
9 mroonga_match_escalation_threshold
10 mroonga_version
SELECT * FROM variables
WHERE MATCH (name) AGAINST ("mroonga_default*" IN BOOLEAN MODE);
id name
3 mroonga_default_wrapper_engine
2 mroonga_default_tokenizer
DROP TABLE variables;
DROP TABLE IF EXISTS diaries;
CREATE TABLE diaries (
id int PRIMARY KEY AUTO_INCREMENT,
body text,
FULLTEXT INDEX body_index (body) TOKENIZER='TokenBigramSplitSymbolAlphaDigit'
) 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`),
FULLTEXT KEY `body_index` (`body`) `TOKENIZER`='TokenBigramSplitSymbolAlphaDigit'
) ENGINE=Mroonga DEFAULT CHARSET=utf8
INSERT INTO diaries (body) VALUES ("will start Groonga!");
INSERT INTO diaries (body) VALUES ("starting Groonga...");
INSERT INTO diaries (body) VALUES ("started Groonga.");
SELECT * FROM diaries;
id body
1 will start Groonga!
2 starting Groonga...
3 started Groonga.
SELECT * FROM diaries
WHERE MATCH(body) AGAINST("+start" IN BOOLEAN MODE)
ORDER BY id;
id body
1 will start Groonga!
2 starting Groonga...
3 started Groonga.
DROP TABLE diaries;
SELECT mroonga_command("register token_filters/stop_word"); SELECT mroonga_command("plugin_register token_filters/stop_word");
mroonga_command("register token_filters/stop_word") mroonga_command("plugin_register token_filters/stop_word")
true true
CREATE TABLE terms ( CREATE TABLE terms (
term VARCHAR(64) NOT NULL PRIMARY KEY, term VARCHAR(64) NOT NULL PRIMARY KEY,
......
SELECT mroonga_command("register token_filters/stop_word"); SELECT mroonga_command("plugin_register token_filters/stop_word");
mroonga_command("register token_filters/stop_word") mroonga_command("plugin_register token_filters/stop_word")
true true
CREATE TABLE terms ( CREATE TABLE terms (
term VARCHAR(64) NOT NULL PRIMARY KEY, term VARCHAR(64) NOT NULL PRIMARY KEY,
......
SELECT mroonga_command("register token_filters/stop_word"); SELECT mroonga_command("plugin_register token_filters/stop_word");
mroonga_command("register token_filters/stop_word") mroonga_command("plugin_register token_filters/stop_word")
true true
CREATE TABLE terms ( CREATE TABLE terms (
term VARCHAR(64) NOT NULL PRIMARY KEY, term VARCHAR(64) NOT NULL PRIMARY KEY,
......
...@@ -10,9 +10,10 @@ INSERT INTO memos VALUES ("Today is fine."); ...@@ -10,9 +10,10 @@ INSERT INTO memos VALUES ("Today is fine.");
INSERT INTO memos VALUES ("Tomorrow will be fine."); INSERT INTO memos VALUES ("Tomorrow will be fine.");
INSERT INTO memos VALUES ("Yesterday was fine."); INSERT INTO memos VALUES ("Yesterday was fine.");
SELECT * FROM memos SELECT * FROM memos
WHERE MATCH (content) AGAINST ("*DOR today good" IN BOOLEAN MODE); WHERE MATCH (content) AGAINST ("*DOR today good" IN BOOLEAN MODE)
ORDER BY content;
content content
Today is good day.
Today is fine. Today is fine.
Today is good day.
Tomorrow will be good day. Tomorrow will be good day.
DROP TABLE memos; DROP TABLE memos;
...@@ -10,9 +10,10 @@ INSERT INTO memos VALUES ("Today is fine."); ...@@ -10,9 +10,10 @@ INSERT INTO memos VALUES ("Today is fine.");
INSERT INTO memos VALUES ("Tomorrow will be fine."); INSERT INTO memos VALUES ("Tomorrow will be fine.");
INSERT INTO memos VALUES ("Yesterday was fine."); INSERT INTO memos VALUES ("Yesterday was fine.");
SELECT * FROM memos SELECT * FROM memos
WHERE MATCH (content) AGAINST ("*DOR today -good tomorrow" IN BOOLEAN MODE); WHERE MATCH (content) AGAINST ("*DOR today -good tomorrow" IN BOOLEAN MODE)
ORDER BY content;
content content
Tomorrow will be good day.
Today is fine. Today is fine.
Tomorrow will be fine. Tomorrow will be fine.
Tomorrow will be good day.
DROP TABLE memos; DROP TABLE memos;
...@@ -10,9 +10,10 @@ INSERT INTO memos VALUES ("Today is fine."); ...@@ -10,9 +10,10 @@ INSERT INTO memos VALUES ("Today is fine.");
INSERT INTO memos VALUES ("Tomorrow will be fine."); INSERT INTO memos VALUES ("Tomorrow will be fine.");
INSERT INTO memos VALUES ("Yesterday was fine."); INSERT INTO memos VALUES ("Yesterday was fine.");
SELECT * FROM memos SELECT * FROM memos
WHERE MATCH (content) AGAINST ("*DOR today +good tomorrow" IN BOOLEAN MODE); WHERE MATCH (content) AGAINST ("*DOR today +good tomorrow" IN BOOLEAN MODE)
ORDER BY content;
content content
Today is good day. Today is good day.
Tomorrow will be good day.
Tomorrow will be fine. Tomorrow will be fine.
Tomorrow will be good day.
DROP TABLE memos; DROP TABLE memos;
DROP TABLE IF EXISTS memos;
SET NAMES utf8;
CREATE TABLE memos (
content TEXT,
FULLTEXT INDEX (content)
) DEFAULT CHARSET=utf8;
INSERT INTO memos VALUES ("Today is good day.");
INSERT INTO memos VALUES ("Tomorrow will be good day.");
INSERT INTO memos VALUES ("Today is fine.");
SELECT * FROM memos
WHERE MATCH (content) AGAINST ("*D+ today fi*" IN BOOLEAN MODE);
content
Today is fine.
DROP TABLE memos;
...@@ -18,21 +18,21 @@ c1 c2 c3 ...@@ -18,21 +18,21 @@ c1 c2 c3
6 20 ka ki ku ke ko 6 20 ka ki ku ke ko
7 20 aa ii uu ee oo 7 20 aa ii uu ee oo
8 20 ka ki ku ke ko 8 20 ka ki ku ke ko
select * from t1 where match(c3) against("uu"); select * from t1 where match(c3) against("+uu" in boolean mode) order by c1;
c1 c2 c3 c1 c2 c3
1 10 aa ii uu ee oo 1 10 aa ii uu ee oo
3 10 aa ii uu ee oo 3 10 aa ii uu ee oo
5 20 aa ii uu ee oo 5 20 aa ii uu ee oo
7 20 aa ii uu ee oo 7 20 aa ii uu ee oo
select * from t1 where not match(c3) against("uu"); select * from t1 where not match(c3) against("+uu" in boolean mode) order by c1;
c1 c2 c3 c1 c2 c3
2 10 ka ki ku ke ko 2 10 ka ki ku ke ko
4 10 ka ki ku ke ko 4 10 ka ki ku ke ko
6 20 ka ki ku ke ko 6 20 ka ki ku ke ko
8 20 ka ki ku ke ko 8 20 ka ki ku ke ko
select * from t1 where match(c3) against("dummy"); select * from t1 where match(c3) against("+dummy" in boolean mode) order by c1;
c1 c2 c3 c1 c2 c3
select * from t1 where not match(c3) against("dummy"); select * from t1 where not match(c3) against("+dummy" in boolean mode) order by c1;
c1 c2 c3 c1 c2 c3
1 10 aa ii uu ee oo 1 10 aa ii uu ee oo
2 10 ka ki ku ke ko 2 10 ka ki ku ke ko
...@@ -42,26 +42,26 @@ c1 c2 c3 ...@@ -42,26 +42,26 @@ c1 c2 c3
6 20 ka ki ku ke ko 6 20 ka ki ku ke ko
7 20 aa ii uu ee oo 7 20 aa ii uu ee oo
8 20 ka ki ku ke ko 8 20 ka ki ku ke ko
select * from t1 where c1 = 4 and not match(c3) against("uu"); select * from t1 where c1 = 4 and not match(c3) against("+uu" in boolean mode) order by c1;
c1 c2 c3 c1 c2 c3
4 10 ka ki ku ke ko 4 10 ka ki ku ke ko
select * from t1 where c1 <= 4 and not match(c3) against("uu"); select * from t1 where c1 <= 4 and not match(c3) against("+uu" in boolean mode) order by c1;
c1 c2 c3 c1 c2 c3
2 10 ka ki ku ke ko 2 10 ka ki ku ke ko
4 10 ka ki ku ke ko 4 10 ka ki ku ke ko
select * from t1 where c1 > 4 and not match(c3) against("uu"); select * from t1 where c1 > 4 and not match(c3) against("+uu" in boolean mode) order by c1;
c1 c2 c3 c1 c2 c3
6 20 ka ki ku ke ko 6 20 ka ki ku ke ko
8 20 ka ki ku ke ko 8 20 ka ki ku ke ko
select * from t1 where c2 = 10 and not match(c3) against("uu"); select * from t1 where c2 = 10 and not match(c3) against("+uu" in boolean mode) order by c1;
c1 c2 c3 c1 c2 c3
2 10 ka ki ku ke ko 2 10 ka ki ku ke ko
4 10 ka ki ku ke ko 4 10 ka ki ku ke ko
select * from t1 where c2 >= 15 and not match(c3) against("uu"); select * from t1 where c2 >= 15 and not match(c3) against("+uu" in boolean mode) order by c1;
c1 c2 c3 c1 c2 c3
6 20 ka ki ku ke ko 6 20 ka ki ku ke ko
8 20 ka ki ku ke ko 8 20 ka ki ku ke ko
select * from t1 where c2 < 15 and not match(c3) against("uu"); select * from t1 where c2 < 15 and not match(c3) against("+uu" in boolean mode) order by c1;
c1 c2 c3 c1 c2 c3
2 10 ka ki ku ke ko 2 10 ka ki ku ke ko
4 10 ka ki ku ke ko 4 10 ka ki ku ke ko
......
DROP TABLE IF EXISTS ranges;
CREATE TABLE ranges (
id int PRIMARY KEY,
start datetime,
end datetime,
UNIQUE KEY range_key(start, end)
);
INSERT INTO ranges VALUES (1, "1990-00-00 00:00:00", "2012-10-05 23:59:59");
Warnings:
Warning 1265 Data truncated for column 'start' at row 1
SELECT * FROM ranges;
id start end
1 1990-01-01 00:00:00 2012-10-05 23:59:59
DELETE FROM ranges WHERE id = 1;
INSERT INTO ranges VALUES (1, "1990-00-00 00:00:00", "2012-10-05 23:59:59");
Warnings:
Warning 1265 Data truncated for column 'start' at row 1
SELECT * FROM ranges;
id start end
1 1990-01-01 00:00:00 2012-10-05 23:59:59
DROP TABLE ranges;
...@@ -31,7 +31,8 @@ SELECT v.id, v.video_id, v.description, NULL ...@@ -31,7 +31,8 @@ SELECT v.id, v.video_id, v.description, NULL
FROM videos_master AS v FROM videos_master AS v
WHERE v.video_id = (video_id); WHERE v.video_id = (video_id);
SELECT *, MATCH(description) AGAINST("my") FROM videos_groonga SELECT *, MATCH(description) AGAINST("my") FROM videos_groonga
WHERE MATCH(description) AGAINST("my"); WHERE MATCH(description) AGAINST("my")
ORDER BY id;
id video_id description tags_unpack MATCH(description) AGAINST("my") id video_id description tags_unpack MATCH(description) AGAINST("my")
1 video-1 My Familly 209716 1 video-1 My Familly 209716
2 video-2 My Cat 209716 2 video-2 My Cat 209716
......
...@@ -6,5 +6,5 @@ content text, ...@@ -6,5 +6,5 @@ content text,
FULLTEXT INDEX (content) FULLTEXT INDEX (content)
) DEFAULT CHARSET=utf8; ) DEFAULT CHARSET=utf8;
REPLACE INTO diaries(content) VALUES("Hello"); REPLACE INTO diaries(content) VALUES("Hello");
ERROR HY000: primary key is empty Got one of the listed errors
DROP TABLE diaries; DROP TABLE diaries;
...@@ -31,15 +31,18 @@ id year month day title content ...@@ -31,15 +31,18 @@ id year month day title content
1 2011 11 9 Hello 今日からはじめました。 1 2011 11 9 Hello 今日からはじめました。
2 2011 11 10 天気 明日の富士山の天気について 2 2011 11 10 天気 明日の富士山の天気について
3 2011 11 11 富士山 今日も天気がよくてきれいに見える。 3 2011 11 11 富士山 今日も天気がよくてきれいに見える。
SELECT * FROM diaries WHERE MATCH(content) AGAINST("今日 天気" IN BOOLEAN MODE); SELECT * FROM diaries
WHERE MATCH(content) AGAINST("+今日" IN BOOLEAN MODE)
ORDER BY id;
id year month day title content id year month day title content
1 2011 11 9 Hello 今日からはじめました。 1 2011 11 9 Hello 今日からはじめました。
3 2011 11 11 富士山 今日も天気がよくてきれいに見える。 3 2011 11 11 富士山 今日も天気がよくてきれいに見える。
2 2011 11 10 天気 明日の富士山の天気について
TRUNCATE TABLE diaries; TRUNCATE TABLE diaries;
SELECT * FROM diaries; SELECT * FROM diaries;
id year month day title content id year month day title content
SELECT * FROM diaries WHERE MATCH(content) AGAINST("今日 天気" IN BOOLEAN MODE); SELECT * FROM diaries
WHERE MATCH(content) AGAINST("+今日" IN BOOLEAN MODE)
ORDER BY id;
id year month day title content id year month day title content
INSERT INTO diaries VALUES(1, 2011, 11, 11, "帰り道", "つかれたー"); INSERT INTO diaries VALUES(1, 2011, 11, 11, "帰り道", "つかれたー");
INSERT INTO diaries VALUES(2, 2011, 12, 1, "久しぶり", "天気が悪いからずっと留守番。"); INSERT INTO diaries VALUES(2, 2011, 12, 1, "久しぶり", "天気が悪いからずっと留守番。");
...@@ -49,7 +52,9 @@ id year month day title content ...@@ -49,7 +52,9 @@ id year month day title content
1 2011 11 11 帰り道 つかれたー 1 2011 11 11 帰り道 つかれたー
2 2011 12 1 久しぶり 天気が悪いからずっと留守番。 2 2011 12 1 久しぶり 天気が悪いからずっと留守番。
3 2011 12 2 初雪 今年はじめての雪! 3 2011 12 2 初雪 今年はじめての雪!
SELECT * FROM diaries WHERE MATCH(content) AGAINST("悪い" IN BOOLEAN MODE); SELECT * FROM diaries
WHERE MATCH(content) AGAINST("+悪い" IN BOOLEAN MODE)
ORDER BY id;
id year month day title content id year month day title content
2 2011 12 1 久しぶり 天気が悪いからずっと留守番。 2 2011 12 1 久しぶり 天気が悪いからずっと留守番。
DROP TABLE diaries; DROP TABLE diaries;
...@@ -5,12 +5,7 @@ package My::Suite::Mroonga; ...@@ -5,12 +5,7 @@ package My::Suite::Mroonga;
return "No Mroonga engine" unless $ENV{HA_MROONGA_SO} or return "No Mroonga engine" unless $ENV{HA_MROONGA_SO} or
$::mysqld_variables{'mroonga'} eq "ON"; $::mysqld_variables{'mroonga'} eq "ON";
# RECOMPILE_FOR_EMBEDDED also means that a plugin sub is_default { not $::opt_embedded_server }
# cannot be dynamically loaded into embedded
return "Not run for embedded server" if $::opt_embedded_server and
$ENV{HA_MROONGA_SO};
sub is_default { 1 }
my $groonga_normalizer_mysql_dir=$::basedir . '/storage/mroonga/vendor/groonga/vendor/plugins/groonga-normalizer-mysql'; my $groonga_normalizer_mysql_dir=$::basedir . '/storage/mroonga/vendor/groonga/vendor/plugins/groonga-normalizer-mysql';
my $groonga_normalizer_mysql_install_dir=$::basedir . '/lib/groonga/plugins'; my $groonga_normalizer_mysql_install_dir=$::basedir . '/lib/groonga/plugins';
......
# Copyright(C) 2014 Kenji Maruyama <mmmaru777@gmail.com>
# Copyright(C) 2015 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/have_mariadb.inc
--source include/not_embedded.inc
--source ../../include/mroonga/have_mroonga.inc
--source ../../include/mroonga/load_mroonga_functions.inc
--disable_query_log
DROP DATABASE test;
CREATE DATABASE test;
USE test;
--enable_query_log
CREATE TABLE tags (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
) DEFAULT CHARSET=utf8;
ALTER TABLE tags ADD COLUMN name VARCHAR(64) FLAGS='COLUMN_VECTOR';
SHOW CREATE TABLE tags;
SELECT mroonga_command("dump --dump_plugins no");
DROP TABLE tags;
--source ../../include/mroonga/unload_mroonga_functions.inc
--source ../../include/mroonga/have_mroonga_deinit.inc
# Copyright(C) 2014 Kenji Maruyama <mmmaru777@gmail.com>
# Copyright(C) 2015 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source ../../include/mroonga/have_mroonga.inc
--source ../../include/mroonga/load_mroonga_functions.inc
--disable_query_log
DROP DATABASE test;
CREATE DATABASE test;
USE test;
--enable_query_log
CREATE TABLE tags (
id INT UNSIGNED PRIMARY KEY
) DEFAULT CHARSET=utf8;
CREATE TABLE bugs (
id INT UNSIGNED PRIMARY KEY
) DEFAULT CHARSET=utf8;
ALTER TABLE bugs ADD COLUMN name VARCHAR(64) COMMENT 'groonga_type "tags"';
SELECT mroonga_command("dump --dump_plugins no");
DROP TABLE bugs;
DROP TABLE tags;
--source ../../include/mroonga/unload_mroonga_functions.inc
--source ../../include/mroonga/have_mroonga_deinit.inc
# Copyright(C) 2014 Kenji Maruyama <mmmaru777@gmail.com>
# Copyright(C) 2015 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/have_mariadb.inc
--source ../../include/mroonga/have_version_56_or_later.inc
--source include/not_embedded.inc
--source ../../include/mroonga/have_mroonga.inc
--source ../../include/mroonga/load_mroonga_functions.inc
--disable_query_log
DROP DATABASE test;
CREATE DATABASE test;
USE test;
--enable_query_log
CREATE TABLE tags (
id INT UNSIGNED PRIMARY KEY
) DEFAULT CHARSET=utf8;
CREATE TABLE bugs (
id INT UNSIGNED PRIMARY KEY
) DEFAULT CHARSET=utf8;
ALTER TABLE bugs ADD COLUMN name VARCHAR(64) GROONGA_TYPE='tags';
SHOW CREATE TABLE bugs;
SELECT mroonga_command("dump --dump_plugins no");
DROP TABLE bugs;
DROP TABLE tags;
--source ../../include/mroonga/unload_mroonga_functions.inc
--source ../../include/mroonga/have_mroonga_deinit.inc
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/have_mroonga.inc --source ../../include/mroonga/have_mroonga.inc
--source ../../include/mroonga/have_groonga_plugin_register.inc
--source ../../include/mroonga/load_mroonga_functions.inc --source ../../include/mroonga/load_mroonga_functions.inc
--disable_query_log --disable_query_log
...@@ -23,7 +24,7 @@ CREATE DATABASE test; ...@@ -23,7 +24,7 @@ CREATE DATABASE test;
USE test; USE test;
--enable_query_log --enable_query_log
SELECT mroonga_command("register token_filters/stop_word"); SELECT mroonga_command("plugin_register token_filters/stop_word");
SET NAMES utf8; SET NAMES utf8;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/have_mroonga.inc --source ../../include/mroonga/have_mroonga.inc
--source ../../include/mroonga/have_groonga_plugin_register.inc
--source ../../include/mroonga/load_mroonga_functions.inc --source ../../include/mroonga/load_mroonga_functions.inc
--disable_query_log --disable_query_log
...@@ -23,7 +24,7 @@ CREATE DATABASE test; ...@@ -23,7 +24,7 @@ CREATE DATABASE test;
USE test; USE test;
--enable_query_log --enable_query_log
SELECT mroonga_command("register token_filters/stop_word"); SELECT mroonga_command("plugin_register token_filters/stop_word");
CREATE TABLE terms ( CREATE TABLE terms (
term VARCHAR(64) NOT NULL PRIMARY KEY, term VARCHAR(64) NOT NULL PRIMARY KEY,
......
# Copyright(C) 2015 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/have_mroonga.inc
--disable_warnings
DROP TABLE IF EXISTS timestamps;
--enable_warnings
CREATE TABLE timestamps (
id INT PRIMARY KEY AUTO_INCREMENT,
create_dt DATETIME
) DEFAULT CHARSET UTF8;
SHOW CREATE TABLE timestamps;
SET sql_mode='STRICT_TRANS_TABLES';
--error ER_WARN_DATA_OUT_OF_RANGE
INSERT INTO timestamps (create_dt) VALUES ("0000-00-00 00:00:00");
SET sql_mode=default;
SELECT * FROM timestamps;
INSERT INTO timestamps (create_dt) VALUES ("2015-06-17 00:00:00");
SELECT * FROM timestamps;
DROP TABLE timestamps;
--source ../../include/mroonga/have_mroonga_deinit.inc
# Copyright(C) 2013-2015 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/have_mariadb.inc
--source include/not_embedded.inc
--source ../../include/mroonga/have_mroonga.inc
--source ../../include/mroonga/load_mroonga_functions.inc
--disable_query_log
DROP DATABASE test;
CREATE DATABASE test;
USE test;
--enable_query_log
CREATE TABLE bugs (
id INT UNSIGNED PRIMARY KEY,
tags TEXT FLAGS='COLUMN_VECTOR'
) DEFAULT CHARSET=utf8;
SHOW CREATE TABLE bugs;
SELECT mroonga_command("dump --dump_plugins no");
DROP TABLE bugs;
--source ../../include/mroonga/unload_mroonga_functions.inc
--source ../../include/mroonga/have_mroonga_deinit.inc
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment