Commit b8b4d277 authored by Sergey Vojtovich's avatar Sergey Vojtovich

Merge mroonga.

parents 135bf1fc 7f3d5550
...@@ -33,6 +33,12 @@ else() ...@@ -33,6 +33,12 @@ else()
set(MRN_BUNDLED TRUE) set(MRN_BUNDLED TRUE)
endif() endif()
if(MRN_BUNDLED)
if(WITHOUT_HA_MROONGA OR WITHOUT_HA_MROONGA_STORAGE_ENGINE)
return()
endif()
endif()
set(MRN_BUNDLED_GROONGA_RELATIVE_DIR "vendor/groonga") set(MRN_BUNDLED_GROONGA_RELATIVE_DIR "vendor/groonga")
set(MRN_BUNDLED_GROONGA_DIR set(MRN_BUNDLED_GROONGA_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/${MRN_BUNDLED_GROONGA_RELATIVE_DIR}") "${CMAKE_CURRENT_SOURCE_DIR}/${MRN_BUNDLED_GROONGA_RELATIVE_DIR}")
...@@ -85,24 +91,22 @@ set(MRN_C_COMPILE_FLAGS "") ...@@ -85,24 +91,22 @@ set(MRN_C_COMPILE_FLAGS "")
set(MRN_CXX_COMPILE_FLAGS "") set(MRN_CXX_COMPILE_FLAGS "")
macro(mrn_check_cflag flag) macro(mrn_check_cflag flag)
set(checking_message "checking for C flag '${flag}'") string(REGEX REPLACE "[-=]" "_" temporary_variable_name ${flag})
check_c_compiler_flag(${flag} is_available) string(TOUPPER "${temporary_variable_name}" temporary_variable_name)
if(${is_available}) set(temporary_variable_name "CFLAG${temporary_variable_name}")
message(STATUS "${checking_message} - available") check_c_compiler_flag(${flag} ${temporary_variable_name})
if(${temporary_variable_name})
set(MRN_C_COMPILE_FLAGS "${MRN_C_COMPILE_FLAGS} ${flag}") set(MRN_C_COMPILE_FLAGS "${MRN_C_COMPILE_FLAGS} ${flag}")
else()
message(STATUS "${checking_message} - not available")
endif() endif()
endmacro() endmacro()
macro(mrn_check_cxxflag flag) macro(mrn_check_cxxflag flag)
set(checking_message "checking for CXX flag '${flag}'") string(REGEX REPLACE "[-=]" "_" temporary_variable_name ${flag})
check_cxx_compiler_flag(${flag} is_available) string(TOUPPER "${temporary_variable_name}" temporary_variable_name)
if(${is_available}) set(temporary_variable_name "CXXFLAG${temporary_variable_name}")
message(STATUS "${checking_message} - available") check_cxx_compiler_flag(${flag} ${temporary_variable_name})
if(${temporary_variable_name})
set(MRN_CXX_COMPILE_FLAGS "${MRN_CXX_COMPILE_FLAGS} ${flag}") set(MRN_CXX_COMPILE_FLAGS "${MRN_CXX_COMPILE_FLAGS} ${flag}")
else()
message(STATUS "${checking_message} - not available")
endif() endif()
endmacro() endmacro()
...@@ -157,8 +161,7 @@ set(MYSQL_INCLUDE_DIRS ...@@ -157,8 +161,7 @@ set(MYSQL_INCLUDE_DIRS
"${MYSQL_SOURCE_DIR}/sql" "${MYSQL_SOURCE_DIR}/sql"
"${MYSQL_SOURCE_DIR}/include" "${MYSQL_SOURCE_DIR}/include"
"${MYSQL_REGEX_INCLUDE_DIR}" "${MYSQL_REGEX_INCLUDE_DIR}"
"${MYSQL_SOURCE_DIR}" "${MYSQL_SOURCE_DIR}")
CACHE INTERNAL "MySQL include directories")
if(MRN_BUNDLED) if(MRN_BUNDLED)
set(MYSQL_PLUGIN_DIR "${INSTALL_PLUGINDIR}") set(MYSQL_PLUGIN_DIR "${INSTALL_PLUGINDIR}")
...@@ -340,9 +343,9 @@ if(GROONGA_NORMALIZER_MYSQL_FOUND) ...@@ -340,9 +343,9 @@ if(GROONGA_NORMALIZER_MYSQL_FOUND)
endif() endif()
endif() endif()
set(DEFAULT_PARSER "TokenBigram" CACHE STRING "The default fulltext parser") set(MRN_DEFAULT_PARSER "TokenBigram" CACHE STRING "The default fulltext parser")
set_property(TARGET ha_mroonga APPEND PROPERTY set_property(TARGET ha_mroonga APPEND PROPERTY
COMPILE_DEFINITIONS "MRN_PARSER_DEFAULT=\"${DEFAULT_PARSER}\"") COMPILE_DEFINITIONS "MRN_PARSER_DEFAULT=\"${MRN_DEFAULT_PARSER}\"")
configure_file( configure_file(
"${PROJECT_SOURCE_DIR}/mrn_version.h.in" "${PROJECT_SOURCE_DIR}/mrn_version.h.in"
......
...@@ -154,4 +154,3 @@ misc: ...@@ -154,4 +154,3 @@ misc:
exit 1; \ exit 1; \
fi fi
ln -s "$(CUTTER_SOURCE_PATH)/misc" misc ln -s "$(CUTTER_SOURCE_PATH)/misc" misc
...@@ -482,6 +482,7 @@ AC_OUTPUT([ ...@@ -482,6 +482,7 @@ AC_OUTPUT([
mysql-test/mroonga/storage/information_schema/r/plugins.result mysql-test/mroonga/storage/information_schema/r/plugins.result
mysql-test/mroonga/storage/variable/r/version.result mysql-test/mroonga/storage/variable/r/version.result
packages/debian/control packages/debian/control
packages/apt/env.sh
packages/rpm/centos/mysql55-mroonga.spec packages/rpm/centos/mysql55-mroonga.spec
packages/rpm/centos/mysql56-community-mroonga.spec packages/rpm/centos/mysql56-community-mroonga.spec
packages/rpm/centos/mariadb-mroonga.spec packages/rpm/centos/mariadb-mroonga.spec
......
This diff is collapsed.
...@@ -31,7 +31,6 @@ extern "C" { ...@@ -31,7 +31,6 @@ extern "C" {
#endif #endif
#include <groonga.h> #include <groonga.h>
#include "mrn_sys.hpp"
#include "mrn_mysql_compat.h" #include "mrn_mysql_compat.h"
#if (MYSQL_VERSION_ID >= 50603) || \ #if (MYSQL_VERSION_ID >= 50603) || \
...@@ -558,6 +557,13 @@ private: ...@@ -558,6 +557,13 @@ private:
int drop_index(MRN_SHARE *target_share, uint key_index); int drop_index(MRN_SHARE *target_share, uint key_index);
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_info);
bool find_token_filters(KEY *key_info, grn_obj *token_filters);
bool find_token_filters_put(grn_obj *token_filters,
const char *token_filter_name,
int token_filter_name_length);
bool find_token_filters_fill(grn_obj *token_filters,
const char *token_filter_names,
int token_filter_name_length);
int wrapper_get_record(uchar *buf, const uchar *key); int wrapper_get_record(uchar *buf, const uchar *key);
int wrapper_get_next_geo_record(uchar *buf); int wrapper_get_next_geo_record(uchar *buf);
int storage_get_next_record(uchar *buf); int storage_get_next_record(uchar *buf);
...@@ -635,6 +641,8 @@ private: ...@@ -635,6 +641,8 @@ private:
void storage_store_field_geometry(Field *field, void storage_store_field_geometry(Field *field,
const char *value, uint value_length); const char *value, uint value_length);
void storage_store_field(Field *field, const char *value, uint value_length); void storage_store_field(Field *field, const char *value, uint value_length);
void storage_store_field_column(Field *field,
int nth_column, grn_id record_id);
void storage_store_fields(uchar *buf, grn_id record_id); void storage_store_fields(uchar *buf, grn_id record_id);
void storage_store_fields_for_prep_update(const uchar *old_data, void storage_store_fields_for_prep_update(const uchar *old_data,
uchar *new_data, uchar *new_data,
...@@ -723,9 +731,6 @@ private: ...@@ -723,9 +731,6 @@ private:
int storage_create_indexes(TABLE *table, const char *grn_table_name, int storage_create_indexes(TABLE *table, const char *grn_table_name,
grn_obj *grn_table, MRN_SHARE *tmp_share); grn_obj *grn_table, MRN_SHARE *tmp_share);
int close_databases(); int close_databases();
void ensure_database_directory();
int ensure_normalizers_register();
int ensure_database_create(const char *name);
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, MRN_SHARE *tmp_share,
......
...@@ -22,4 +22,6 @@ libmrn_need_mysql_la_SOURCES = \ ...@@ -22,4 +22,6 @@ libmrn_need_mysql_la_SOURCES = \
mrn_condition_converter.cpp \ mrn_condition_converter.cpp \
mrn_condition_converter.hpp \ mrn_condition_converter.hpp \
mrn_time_converter.cpp \ mrn_time_converter.cpp \
mrn_time_converter.hpp mrn_time_converter.hpp \
mrn_database_manager.cpp \
mrn_database_manager.hpp
...@@ -5,4 +5,5 @@ libmrn_no_mysql_la_SOURCES = \ ...@@ -5,4 +5,5 @@ libmrn_no_mysql_la_SOURCES = \
mrn_path_mapper.hpp \ mrn_path_mapper.hpp \
mrn_windows.hpp \ mrn_windows.hpp \
mrn_smart_grn_obj.cpp \ mrn_smart_grn_obj.cpp \
mrn_smart_grn_obj.hpp mrn_smart_grn_obj.hpp \
mrn_grn.hpp
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2010 Tetsuro IKEDA
Copyright(C) 2010-2013 Kentoku SHIBA
Copyright(C) 2011-2014 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <mrn_mysql.h>
#include "mrn_database_manager.hpp"
#include "mrn_encoding.hpp"
#include "mrn_lock.hpp"
#include "mrn_path_mapper.hpp"
// for debug
#define MRN_CLASS_NAME "mrn::DatabaseManager"
#ifdef WIN32
# include <direct.h>
# define MRN_MKDIR(pathname, mode) _mkdir((pathname))
#else
# include <dirent.h>
# include <unistd.h>
# define MRN_MKDIR(pathname, mode) mkdir((pathname), (mode))
#endif
namespace mrn {
DatabaseManager::DatabaseManager(grn_ctx *ctx)
: ctx_(ctx),
cache_(NULL),
mutex_(),
mutex_initialized_(false) {
}
DatabaseManager::~DatabaseManager(void) {
if (mutex_initialized_) {
pthread_mutex_destroy(&mutex_);
}
if (cache_) {
void *db_address;
GRN_HASH_EACH(ctx_, cache_, id, NULL, 0, &db_address, {
grn_obj *db;
memcpy(&db, db_address, sizeof(grn_obj *));
grn_obj_unlink(ctx_, db);
});
grn_hash_close(ctx_, cache_);
}
}
bool DatabaseManager::init(void) {
MRN_DBUG_ENTER_METHOD();
cache_ = grn_hash_create(ctx_,
NULL,
GRN_TABLE_MAX_KEY_SIZE,
sizeof(grn_obj *),
GRN_OBJ_KEY_VAR_SIZE);
if (!cache_) {
GRN_LOG(ctx_, GRN_LOG_ERROR,
"failed to initialize hash table for caching opened databases");
DBUG_RETURN(false);
}
if (pthread_mutex_init(&mutex_, NULL) != 0) {
GRN_LOG(ctx_, GRN_LOG_ERROR,
"failed to initialize mutex for opened database cache hash table");
DBUG_RETURN(false);
}
mutex_initialized_ = true;
DBUG_RETURN(true);
}
int DatabaseManager::open(const char *path, grn_obj **db) {
MRN_DBUG_ENTER_METHOD();
int error = 0;
*db = NULL;
mrn::PathMapper mapper(path);
mrn::Lock lock(&mutex_);
error = mrn::encoding::set(ctx_, system_charset_info);
if (error) {
DBUG_RETURN(error);
}
grn_id id;
void *db_address;
id = grn_hash_get(ctx_, cache_,
mapper.db_name(), strlen(mapper.db_name()),
&db_address);
if (id == GRN_ID_NIL) {
struct stat db_stat;
if (stat(mapper.db_path(), &db_stat)) {
GRN_LOG(ctx_, GRN_LOG_INFO,
"database not found. creating...: <%s>", mapper.db_path());
if (path[0] == FN_CURLIB &&
(path[1] == FN_LIBCHAR || path[1] == FN_LIBCHAR2)) {
ensure_database_directory();
}
*db = grn_db_create(ctx_, mapper.db_path(), NULL);
if (ctx_->rc) {
error = ER_CANT_CREATE_TABLE;
my_message(error, ctx_->errbuf, MYF(0));
DBUG_RETURN(error);
}
} else {
*db = grn_db_open(ctx_, mapper.db_path());
if (ctx_->rc) {
error = ER_CANT_OPEN_FILE;
my_message(error, ctx_->errbuf, MYF(0));
DBUG_RETURN(error);
}
}
grn_hash_add(ctx_, cache_,
mapper.db_name(), strlen(mapper.db_name()),
&db_address, NULL);
memcpy(db_address, db, sizeof(grn_obj *));
} else {
memcpy(db, db_address, sizeof(grn_obj *));
grn_ctx_use(ctx_, *db);
}
error = ensure_normalizers_registered(*db);
DBUG_RETURN(error);
}
void DatabaseManager::close(const char *path) {
MRN_DBUG_ENTER_METHOD();
mrn::PathMapper mapper(path);
mrn::Lock lock(&mutex_);
grn_id id;
void *db_address;
id = grn_hash_get(ctx_, cache_,
mapper.db_name(), strlen(mapper.db_name()),
&db_address);
if (id == GRN_ID_NIL) {
DBUG_VOID_RETURN;
}
grn_obj *db = NULL;
memcpy(&db, db_address, sizeof(grn_obj *));
if (db) {
grn_obj_close(ctx_, db);
}
grn_hash_delete_by_id(ctx_, cache_, id, NULL);
DBUG_VOID_RETURN;
}
bool DatabaseManager::drop(const char *path) {
MRN_DBUG_ENTER_METHOD();
mrn::PathMapper mapper(path);
mrn::Lock lock(&mutex_);
grn_id id;
void *db_address;
id = grn_hash_get(ctx_, cache_,
mapper.db_name(), strlen(mapper.db_name()),
&db_address);
grn_obj *db = NULL;
if (id == GRN_ID_NIL) {
struct stat dummy;
if (stat(mapper.db_path(), &dummy) == 0) {
db = grn_db_open(ctx_, mapper.db_path());
}
} else {
memcpy(&db, db_address, sizeof(grn_obj *));
}
if (!db) {
DBUG_RETURN(false);
}
if (grn_obj_remove(ctx_, db) == GRN_SUCCESS) {
if (id != GRN_ID_NIL) {
grn_hash_delete_by_id(ctx_, cache_, id, NULL);
}
DBUG_RETURN(true);
} else {
GRN_LOG(ctx_, GRN_LOG_ERROR,
"failed to drop database: <%s>: <%s>",
mapper.db_path(), ctx_->errbuf);
DBUG_RETURN(false);
}
}
int DatabaseManager::clear(void) {
MRN_DBUG_ENTER_METHOD();
int error = 0;
mrn::Lock lock(&mutex_);
grn_hash_cursor *cursor;
cursor = grn_hash_cursor_open(ctx_, cache_,
NULL, 0, NULL, 0,
0, -1, 0);
if (ctx_->rc) {
my_message(ER_ERROR_ON_READ, ctx_->errbuf, MYF(0));
DBUG_RETURN(ER_ERROR_ON_READ);
}
while (grn_hash_cursor_next(ctx_, cursor) != GRN_ID_NIL) {
if (ctx_->rc) {
error = ER_ERROR_ON_READ;
my_message(error, ctx_->errbuf, MYF(0));
break;
}
void *db_address;
grn_obj *db;
grn_hash_cursor_get_value(ctx_, cursor, &db_address);
memcpy(&db, db_address, sizeof(grn_obj *));
grn_rc rc = grn_hash_cursor_delete(ctx_, cursor, NULL);
if (rc) {
error = ER_ERROR_ON_READ;
my_message(error, ctx_->errbuf, MYF(0));
break;
}
grn_obj_close(ctx_, db);
}
grn_hash_cursor_close(ctx_, cursor);
DBUG_RETURN(error);
}
void DatabaseManager::mkdir_p(const char *directory) {
MRN_DBUG_ENTER_METHOD();
int i = 0;
char sub_directory[MRN_MAX_PATH_SIZE];
sub_directory[0] = '\0';
while (true) {
if (directory[i] == FN_LIBCHAR ||
directory[i] == FN_LIBCHAR2 ||
directory[i] == '\0') {
sub_directory[i] = '\0';
struct stat directory_status;
if (stat(sub_directory, &directory_status) != 0) {
DBUG_PRINT("info", ("mroonga: creating directory: <%s>", sub_directory));
GRN_LOG(ctx_, GRN_LOG_INFO, "creating directory: <%s>", sub_directory);
if (MRN_MKDIR(sub_directory, S_IRWXU) == 0) {
DBUG_PRINT("info",
("mroonga: created directory: <%s>", sub_directory));
GRN_LOG(ctx_, GRN_LOG_INFO, "created directory: <%s>", sub_directory);
} else {
DBUG_PRINT("error",
("mroonga: failed to create directory: <%s>: <%s>",
sub_directory, strerror(errno)));
GRN_LOG(ctx_, GRN_LOG_ERROR,
"failed to create directory: <%s>: <%s>",
sub_directory, strerror(errno));
DBUG_VOID_RETURN;
}
}
}
if (directory[i] == '\0') {
break;
}
sub_directory[i] = directory[i];
++i;
}
DBUG_VOID_RETURN;
}
void DatabaseManager::ensure_database_directory(void) {
MRN_DBUG_ENTER_METHOD();
const char *path_prefix = mrn::PathMapper::default_path_prefix;
if (!path_prefix)
DBUG_VOID_RETURN;
const char *last_path_separator;
last_path_separator = strrchr(path_prefix, FN_LIBCHAR);
if (!last_path_separator)
last_path_separator = strrchr(path_prefix, FN_LIBCHAR2);
if (!last_path_separator)
DBUG_VOID_RETURN;
if (path_prefix == last_path_separator)
DBUG_VOID_RETURN;
char database_directory[MRN_MAX_PATH_SIZE];
size_t database_directory_length = last_path_separator - path_prefix;
strncpy(database_directory, path_prefix, database_directory_length);
database_directory[database_directory_length] = '\0';
mkdir_p(database_directory);
DBUG_VOID_RETURN;
}
int DatabaseManager::ensure_normalizers_registered(grn_obj *db) {
MRN_DBUG_ENTER_METHOD();
int error = 0;
#ifdef WITH_GROONGA_NORMALIZER_MYSQL
{
grn_obj *mysql_normalizer;
mysql_normalizer = grn_ctx_get(ctx_, "NormalizerMySQLGeneralCI", -1);
if (mysql_normalizer) {
grn_obj_unlink(ctx_, mysql_normalizer);
} else {
#ifdef GROONGA_NORMALIZER_MYSQL_PLUGIN_IS_BUNDLED_STATIC
char ref_path[FN_REFLEN + 1], *tmp;
tmp = strmov(ref_path, opt_plugin_dir);
tmp = strmov(tmp, "/ha_mroonga");
strcpy(tmp, SO_EXT);
grn_plugin_register_by_path(ctx_, ref_path);
#else
grn_plugin_register(ctx_, GROONGA_NORMALIZER_MYSQL_PLUGIN_NAME);
#endif
}
}
#endif
DBUG_RETURN(error);
}
}
/* -*- c-basic-offset: 2 -*- */ /* -*- c-basic-offset: 2 -*- */
/* /*
Copyright(C) 2010 Tetsuro IKEDA Copyright(C) 2010 Tetsuro IKEDA
Copyright(C) 2011-2012 Kentoku SHIBA Copyright(C) 2010-2013 Kentoku SHIBA
Copyright(C) 2011 Kouhei Sutou <kou@clear-code.com> Copyright(C) 2011-2014 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
...@@ -19,70 +19,32 @@ ...@@ -19,70 +19,32 @@
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 #ifndef MRN_DATABASE_MANAGER_HPP_
# include "config.h" #define MRN_DATABASE_MANAGER_HPP_
#endif
#include <groonga.h>
#include <stdlib.h>
#include <stdio.h> namespace mrn {
#include <string.h> class DatabaseManager {
#include "mrn_sys.hpp" public:
DatabaseManager(grn_ctx *ctx);
bool mrn_hash_put(grn_ctx *ctx, grn_hash *hash, const char *key, grn_obj *value) ~DatabaseManager(void);
{ bool init(void);
int added; int open(const char *path, grn_obj **db);
bool succeed; void close(const char *path);
void *buf; bool drop(const char *path);
grn_hash_add(ctx, hash, (const char *)key, strlen(key), &buf, &added); int clear(void);
// duplicate check
if (added == 0) { private:
GRN_LOG(ctx, GRN_LOG_WARNING, "hash put duplicated (key=%s)", key); grn_ctx *ctx_;
succeed = false; grn_hash *cache_;
} else { pthread_mutex_t mutex_;
// store address of value bool mutex_initialized_;
memcpy(buf, &value, sizeof(grn_obj *));
GRN_LOG(ctx, GRN_LOG_DEBUG, "hash put (key=%s)", key); void mkdir_p(const char *directory);
succeed = true; void ensure_database_directory(void);
} int ensure_normalizers_registered(grn_obj *db);
return succeed; };
} }
bool mrn_hash_get(grn_ctx *ctx, grn_hash *hash, const char *key, grn_obj **value) #endif /* MRN_DATABASE_MANAGER_HPP_ */
{
bool found;
grn_id id;
void *buf;
id = grn_hash_get(ctx, hash, (const char *)key, strlen(key), &buf);
// key not found
if (id == GRN_ID_NIL) {
GRN_LOG(ctx, GRN_LOG_DEBUG, "hash get not found (key=%s)", key);
found = false;
} else {
// restore address of value
memcpy(value, buf, sizeof(grn_obj *));
found = true;
}
return found;
}
bool mrn_hash_remove(grn_ctx *ctx, grn_hash *hash, const char *key)
{
bool succeed;
grn_rc rc;
grn_id id;
id = grn_hash_get(ctx, hash, (const char*) key, strlen(key), NULL);
if (id == GRN_ID_NIL) {
GRN_LOG(ctx, GRN_LOG_WARNING, "hash remove not found (key=%s)", key);
succeed = false;
} else {
rc = grn_hash_delete_by_id(ctx, hash, id, NULL);
if (rc != GRN_SUCCESS) {
GRN_LOG(ctx, GRN_LOG_ERROR, "hash remove error (key=%s)", key);
succeed = false;
} else {
GRN_LOG(ctx, GRN_LOG_DEBUG, "hash remove (key=%s)", key);
succeed = true;
}
}
return succeed;
}
...@@ -153,7 +153,27 @@ namespace mrn { ...@@ -153,7 +153,27 @@ namespace mrn {
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
bool set(grn_ctx *ctx, const CHARSET_INFO *charset) { int set(grn_ctx *ctx, const CHARSET_INFO *charset) {
MRN_DBUG_ENTER_FUNCTION();
int error = 0;
if (!set_raw(ctx, charset)) {
const char *name = "<null>";
const char *csname = "<null>";
if (charset) {
name = charset->name;
csname = charset->csname;
}
error = ER_MRN_CHARSET_NOT_SUPPORT_NUM;
my_printf_error(error,
ER_MRN_CHARSET_NOT_SUPPORT_STR,
MYF(0), name, csname);
}
DBUG_RETURN(error);
}
bool set_raw(grn_ctx *ctx, const CHARSET_INFO *charset) {
MRN_DBUG_ENTER_FUNCTION(); MRN_DBUG_ENTER_FUNCTION();
if (!charset) if (!charset)
{ {
......
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
namespace mrn { namespace mrn {
namespace encoding { namespace encoding {
void init(void); void init(void);
bool set(grn_ctx *ctx, const CHARSET_INFO *charset); int set(grn_ctx *ctx, const CHARSET_INFO *charset);
bool set_raw(grn_ctx *ctx, const CHARSET_INFO *charset);
} }
} }
......
...@@ -95,7 +95,7 @@ namespace mrn { ...@@ -95,7 +95,7 @@ namespace mrn {
grn_obj *normalizer = find_grn_normalizer(); grn_obj *normalizer = find_grn_normalizer();
int flags = 0; int flags = 0;
grn_encoding original_encoding = GRN_CTX_GET_ENCODING(ctx_); grn_encoding original_encoding = GRN_CTX_GET_ENCODING(ctx_);
encoding::set(ctx_, field_->charset()); encoding::set_raw(ctx_, field_->charset());
grn_obj *grn_string = grn_string_open(ctx_, string, string_length, grn_obj *grn_string = grn_string_open(ctx_, string, string_length,
normalizer, flags); normalizer, flags);
GRN_CTX_SET_ENCODING(ctx_, original_encoding); GRN_CTX_SET_ENCODING(ctx_, original_encoding);
......
/* -*- c-basic-offset: 2 -*- */
/* /*
Copyright(C) 2010 Tetsuro IKEDA Copyright(C) 2014 Kouhei Sutou <kou@clear-code.com>
Copyright(C) 2011 Kentoku SHIBA
Copyright(C) 2011-2012 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or 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,19 +17,23 @@ ...@@ -18,19 +17,23 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#ifndef MRN_SYS_HPP_ #ifndef MRN_GRN_HPP_
#define MRN_SYS_HPP_ #define MRN_GRN_HPP_
#include <groonga.h> #include <groonga.h>
#include "mrn_macro.hpp"
MRN_BEGIN_DECLS namespace mrn {
namespace grn {
/* functions */ bool is_table(grn_obj *obj) {
bool mrn_hash_put(grn_ctx *ctx, grn_hash *hash, const char *key, grn_obj *value); grn_id type = obj->header.type;
bool mrn_hash_get(grn_ctx *ctx, grn_hash *hash, const char *key, grn_obj **value); return GRN_TABLE_HASH_KEY <= type && obj->header.type <= GRN_DB;
bool mrn_hash_remove(grn_ctx *ctx, grn_hash *hash, const char *key); }
MRN_END_DECLS bool is_vector_column(grn_obj *column) {
int column_type = (column->header.flags & GRN_OBJ_COLUMN_TYPE_MASK);
#endif /* MRN_SYS_HPP_ */ return column_type == GRN_OBJ_COLUMN_VECTOR;
}
}
}
#endif // MRN_GRN_HPP_
...@@ -19,16 +19,12 @@ ...@@ -19,16 +19,12 @@
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 <mrn_mysql.h>
# include <config.h>
#endif
#include "mrn_path_mapper.hpp" #include "mrn_path_mapper.hpp"
#include <string.h> #include <string.h>
#include <mrn_mysql.h>
namespace mrn { namespace mrn {
char *PathMapper::default_path_prefix = NULL; char *PathMapper::default_path_prefix = NULL;
char *PathMapper::default_mysql_data_home_path = NULL; char *PathMapper::default_mysql_data_home_path = NULL;
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
# include <mysql_priv.h> # include <mysql_priv.h>
# include <mysql/plugin.h> # include <mysql/plugin.h>
#else #else
# include <my_global.h>
# include <sql_priv.h> # include <sql_priv.h>
# include <sql_class.h> # include <sql_class.h>
# include <probes_mysql.h> # include <probes_mysql.h>
......
...@@ -18,9 +18,6 @@ ...@@ -18,9 +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 <config.h>
#include <string>
#include "mrn_mysql.h" #include "mrn_mysql.h"
#if MYSQL_VERSION_ID >= 50500 #if MYSQL_VERSION_ID >= 50500
...@@ -28,7 +25,6 @@ ...@@ -28,7 +25,6 @@
# include <sql_base.h> # include <sql_base.h>
#endif #endif
#include "mrn_err.h" #include "mrn_err.h"
#include "mrn_sys.hpp"
#include "mrn_table.hpp" #include "mrn_table.hpp"
#include "mrn_mysql_compat.h" #include "mrn_mysql_compat.h"
#include <mrn_lock.hpp> #include <mrn_lock.hpp>
...@@ -301,10 +297,11 @@ void mrn_get_partition_info(const char *table_name, uint table_name_length, ...@@ -301,10 +297,11 @@ void mrn_get_partition_info(const char *table_name, uint table_name_length,
int mrn_parse_table_param(MRN_SHARE *share, TABLE *table) int mrn_parse_table_param(MRN_SHARE *share, TABLE *table)
{ {
int i, error; int i, error = 0;
int title_length; int title_length;
const char *sprit_ptr[2]; const char *sprit_ptr[2];
const char *tmp_ptr, *start_ptr; const char *tmp_ptr, *start_ptr;
char *params_string = NULL;
#ifdef WITH_PARTITION_STORAGE_ENGINE #ifdef WITH_PARTITION_STORAGE_ENGINE
partition_element *part_elem; partition_element *part_elem;
partition_element *sub_elem; partition_element *sub_elem;
...@@ -371,8 +368,15 @@ int mrn_parse_table_param(MRN_SHARE *share, TABLE *table) ...@@ -371,8 +368,15 @@ int mrn_parse_table_param(MRN_SHARE *share, TABLE *table)
} }
{ {
std::string params_string(params_string_value, params_string_length); params_string = my_strndup(params_string_value,
sprit_ptr[0] = params_string.c_str(); params_string_length,
MYF(MY_WME));
if (!params_string) {
error = HA_ERR_OUT_OF_MEM;
goto error;
}
sprit_ptr[0] = params_string;
while (sprit_ptr[0]) while (sprit_ptr[0])
{ {
if ((sprit_ptr[1] = strchr(sprit_ptr[0], ','))) if ((sprit_ptr[1] = strchr(sprit_ptr[0], ',')))
...@@ -406,6 +410,12 @@ int mrn_parse_table_param(MRN_SHARE *share, TABLE *table) ...@@ -406,6 +410,12 @@ int mrn_parse_table_param(MRN_SHARE *share, TABLE *table)
case 6: case 6:
MRN_PARAM_STR("engine", engine); MRN_PARAM_STR("engine", engine);
break; break;
case 10:
MRN_PARAM_STR("normalizer", normalizer);
break;
case 13:
MRN_PARAM_STR("token_filters", token_filters);
break;
case 17: case 17:
MRN_PARAM_STR("default_tokenizer", default_tokenizer); MRN_PARAM_STR("default_tokenizer", default_tokenizer);
break; break;
...@@ -413,6 +423,9 @@ int mrn_parse_table_param(MRN_SHARE *share, TABLE *table) ...@@ -413,6 +423,9 @@ int mrn_parse_table_param(MRN_SHARE *share, TABLE *table)
break; break;
} }
} }
my_free(params_string, MYF(0));
params_string = NULL;
} }
} }
...@@ -459,9 +472,9 @@ int mrn_parse_table_param(MRN_SHARE *share, TABLE *table) ...@@ -459,9 +472,9 @@ int mrn_parse_table_param(MRN_SHARE *share, TABLE *table)
} }
} }
DBUG_RETURN(0);
error: error:
if (params_string)
my_free(params_string, MYF(0));
DBUG_RETURN(error); DBUG_RETURN(error);
} }
...@@ -704,6 +717,10 @@ int mrn_free_share_alloc( ...@@ -704,6 +717,10 @@ int mrn_free_share_alloc(
my_free(share->engine, MYF(0)); my_free(share->engine, MYF(0));
if (share->default_tokenizer) if (share->default_tokenizer)
my_free(share->default_tokenizer, MYF(0)); my_free(share->default_tokenizer, MYF(0));
if (share->normalizer)
my_free(share->normalizer, MYF(0));
if (share->token_filters)
my_free(share->token_filters, MYF(0));
for (i = 0; i < share->table_share->keys; i++) for (i = 0; i < share->table_share->keys; i++)
{ {
if (share->index_table && share->index_table[i]) if (share->index_table && share->index_table[i])
......
...@@ -53,6 +53,10 @@ typedef struct st_mroonga_share ...@@ -53,6 +53,10 @@ typedef struct st_mroonga_share
int engine_length; int engine_length;
char *default_tokenizer; char *default_tokenizer;
int default_tokenizer_length; int default_tokenizer_length;
char *normalizer;
int normalizer_length;
char *token_filters;
int token_filters_length;
plugin_ref plugin; plugin_ref plugin;
handlerton *hton; handlerton *hton;
char **index_table; char **index_table;
......
# Copyright(C) 2014 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/check_version.inc
--source ../../include/mroonga/check_mariadb.inc
if ($version_55) {
if (!$mariadb) {
skip This test is not for MySQL 5.5.x;
}
}
alter_table_add_index_token_filters_one_token_filter : Bundled Mroonga does not support token filter yet.
alter_table_change_token_filter : Bundled Mroonga does not support token filter yet.
fulltext_token_filters_skip : Bundled Mroonga does not support token filter yet.
create_table_token_filters_index_comment_multiple_token_filters : Bundled Mroonga does not support token filter yet.
create_table_token_filters_index_comment_one_token_filter : Bundled Mroonga does not support token filter yet.
create_table_token_filters_table_comment_multiple_token_filters : Bundled Mroonga does not support token filter yet.
create_table_token_filters_table_comment_one_token_filter : Bundled Mroonga does not support token filter yet.
SELECT mroonga_command("register token_filters/stop_word");
mroonga_command("register token_filters/stop_word")
true
SET NAMES utf8;
CREATE TABLE memos (
content VARCHAR(64) NOT NULL
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
table_create memos TABLE_NO_KEY
column_create memos content COLUMN_SCALAR ShortText
ALTER TABLE memos ADD FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord"';
SELECT mroonga_command("dump");
mroonga_command("dump")
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
column_create memos-content index COLUMN_INDEX|WITH_POSITION memos content
DROP TABLE memos;
DROP TABLE IF EXISTS ids;
CREATE TABLE ids (
id INT
) DEFAULT CHARSET UTF8;
INSERT INTO ids (id) values (1), (1);
ALTER TABLE ids ADD UNIQUE INDEX (id);
ERROR 23000: Can't write, because of unique constraint, to table 'ids'
SHOW CREATE TABLE ids;
Table Create Table
ids CREATE TABLE `ids` (
`id` int(11) DEFAULT NULL
) ENGINE=Mroonga DEFAULT CHARSET=utf8
SELECT * FROM ids;
id
1
1
DROP TABLE ids;
SELECT mroonga_command("register token_filters/stop_word");
mroonga_command("register token_filters/stop_word")
true
CREATE TABLE terms (
term VARCHAR(64) NOT NULL PRIMARY KEY,
is_stop_word BOOL NOT NULL
) COMMENT='default_tokenizer "TokenBigram"' DEFAULT CHARSET=utf8;
CREATE TABLE memos (
id INT NOT NULL PRIMARY KEY,
content TEXT NOT NULL,
FULLTEXT INDEX (content) COMMENT 'table "terms"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
table_create terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerMySQLGeneralCI
column_create terms is_stop_word COLUMN_SCALAR Int8
column_create terms term COLUMN_SCALAR ShortText
table_create memos TABLE_PAT_KEY Int32
column_create memos content COLUMN_SCALAR LongText
column_create memos id COLUMN_SCALAR Int32
column_create terms content COLUMN_INDEX|WITH_POSITION memos content
ALTER TABLE terms COMMENT='default_tokenizer "TokenBigram", token_filters "TokenFilterStopWord"';
SELECT mroonga_command("dump");
mroonga_command("dump")
table_create memos TABLE_PAT_KEY Int32
column_create memos content COLUMN_SCALAR LongText
column_create memos id COLUMN_SCALAR Int32
table_create terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerMySQLGeneralCI --token_filters TokenFilterStopWord
column_create terms is_stop_word COLUMN_SCALAR Int8
column_create terms term COLUMN_SCALAR ShortText
DROP TABLE memos;
DROP TABLE terms;
DROP TABLE IF EXISTS tags;
CREATE TABLE tags ( CREATE TABLE tags (
name VARCHAR(64) PRIMARY KEY name VARCHAR(64) PRIMARY KEY
) DEFAULT CHARSET=utf8 ) DEFAULT CHARSET=utf8
......
DROP TABLE IF EXISTS memos;
DROP TABLE IF EXISTS terms;
SET NAMES utf8;
CREATE TABLE terms (
term VARCHAR(64) NOT NULL PRIMARY KEY
) COMMENT='default_tokenizer "TokenBigram", normalizer "NormalizerAuto"' DEFAULT CHARSET=utf8;
CREATE TABLE memos (
id INT NOT NULL PRIMARY KEY,
content TEXT NOT NULL,
FULLTEXT INDEX (content) COMMENT 'table "terms"'
) 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 terms;
SELECT mroonga_command("register token_filters/stop_word");
mroonga_command("register token_filters/stop_word")
true
SET NAMES utf8;
CREATE TABLE memos (
content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord,TokenFilterStopWord"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
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;
SELECT mroonga_command("register token_filters/stop_word");
mroonga_command("register token_filters/stop_word")
true
SET NAMES utf8;
CREATE TABLE memos (
content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
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
column_create memos-content index COLUMN_INDEX|WITH_POSITION memos content
DROP TABLE memos;
SELECT mroonga_command("register token_filters/stop_word");
mroonga_command("register token_filters/stop_word")
true
CREATE TABLE terms (
term VARCHAR(64) NOT NULL PRIMARY KEY,
is_stop_word BOOL NOT NULL
) COMMENT='default_tokenizer "TokenBigram", token_filters "TokenFilterStopWord,TokenFilterStopWord"' DEFAULT CHARSET=utf8;
CREATE TABLE memos (
id INT NOT NULL PRIMARY KEY,
content TEXT NOT NULL,
FULLTEXT INDEX (content) COMMENT 'table "terms"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
table_create terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerMySQLGeneralCI --token_filters TokenFilterStopWord,TokenFilterStopWord
column_create terms is_stop_word COLUMN_SCALAR Int8
column_create terms term COLUMN_SCALAR ShortText
table_create memos TABLE_PAT_KEY Int32
column_create memos content COLUMN_SCALAR LongText
column_create memos id COLUMN_SCALAR Int32
column_create terms content COLUMN_INDEX|WITH_POSITION memos content
DROP TABLE memos;
DROP TABLE terms;
SELECT mroonga_command("register token_filters/stop_word");
mroonga_command("register token_filters/stop_word")
true
CREATE TABLE terms (
term VARCHAR(64) NOT NULL PRIMARY KEY,
is_stop_word BOOL NOT NULL
) COMMENT='default_tokenizer "TokenBigram", token_filters "TokenFilterStopWord"' DEFAULT CHARSET=utf8;
CREATE TABLE memos (
id INT NOT NULL PRIMARY KEY,
content TEXT NOT NULL,
FULLTEXT INDEX (content) COMMENT 'table "terms"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
table_create terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerMySQLGeneralCI --token_filters TokenFilterStopWord
column_create terms is_stop_word COLUMN_SCALAR Int8
column_create terms term COLUMN_SCALAR ShortText
table_create memos TABLE_PAT_KEY Int32
column_create memos content COLUMN_SCALAR LongText
column_create memos id COLUMN_SCALAR Int32
column_create terms content COLUMN_INDEX|WITH_POSITION memos content
DROP TABLE memos;
DROP TABLE terms;
DROP TABLE IF EXISTS bugs;
CREATE TABLE bugs ( CREATE TABLE bugs (
id INT UNSIGNED PRIMARY KEY, id INT UNSIGNED PRIMARY KEY,
tags TEXT COMMENT 'flags "COLUMN_VECTOR"' tags TEXT COMMENT 'flags "COLUMN_VECTOR"'
......
SELECT mroonga_command("register token_filters/stop_word");
mroonga_command("register token_filters/stop_word")
true
CREATE TABLE terms (
term VARCHAR(64) NOT NULL PRIMARY KEY,
is_stop_word BOOL NOT NULL
) COMMENT='default_tokenizer "TokenBigram", token_filters "TokenFilterStopWord"' DEFAULT CHARSET=utf8;
CREATE TABLE memos (
id INT NOT NULL PRIMARY KEY,
content TEXT NOT NULL,
FULLTEXT INDEX (content) COMMENT 'table "terms"'
) DEFAULT CHARSET=utf8;
INSERT INTO terms VALUES ("and", true);
INSERT INTO memos VALUES (1, "Hello");
INSERT INTO memos VALUES (2, "Hello and Good-bye");
INSERT INTO memos VALUES (3, "Good-bye");
SELECT * FROM memos
WHERE MATCH (content) AGAINST ("+\"Hello and\"" IN BOOLEAN MODE);
id content
1 Hello
2 Hello and Good-bye
DROP TABLE memos;
DROP TABLE terms;
DROP TABLE IF EXISTS items;
CREATE TABLE items (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
score INT,
created_at DATETIME,
INDEX (score, created_at)
) DEFAULT CHARSET=UTF8;
SHOW CREATE TABLE items;
Table Create Table
items CREATE TABLE `items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`score` int(11) DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `score` (`score`,`created_at`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8
INSERT INTO items (score, created_at) VALUES(1, "2014-09-10 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-11 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-11 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-12 00:00:00");
INSERT INTO items (score, created_at) VALUES(3, "2014-09-13 00:00:00");
SELECT *
FROM items
WHERE score = 2 AND created_at > "2014-09-11 00:00:00"
ORDER BY created_at DESC;
id score created_at
4 2 2014-09-12 00:00:00
DROP TABLE items;
DROP TABLE IF EXISTS items;
CREATE TABLE items (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
score INT,
created_at DATETIME,
INDEX (score, created_at)
) DEFAULT CHARSET=UTF8;
SHOW CREATE TABLE items;
Table Create Table
items CREATE TABLE `items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`score` int(11) DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `score` (`score`,`created_at`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8
INSERT INTO items (score, created_at) VALUES(1, "2014-09-10 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-11 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-11 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-12 00:00:00");
INSERT INTO items (score, created_at) VALUES(3, "2014-09-13 00:00:00");
SELECT *
FROM items
WHERE score = 2 AND created_at >= "2014-09-11 00:00:00"
ORDER BY created_at DESC;
id score created_at
4 2 2014-09-12 00:00:00
2 2 2014-09-11 00:00:00
3 2 2014-09-11 00:00:00
DROP TABLE items;
DROP TABLE IF EXISTS items;
CREATE TABLE items (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
score INT,
created_at DATETIME,
INDEX (score, created_at)
) DEFAULT CHARSET=UTF8;
SHOW CREATE TABLE items;
Table Create Table
items CREATE TABLE `items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`score` int(11) DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `score` (`score`,`created_at`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8
INSERT INTO items (score, created_at) VALUES(1, "2014-09-10 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-11 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-11 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-12 00:00:00");
INSERT INTO items (score, created_at) VALUES(3, "2014-09-13 00:00:00");
SELECT *
FROM items
WHERE score = 2 AND created_at < "2014-09-12 00:00:00"
ORDER BY created_at DESC;
id score created_at
2 2 2014-09-11 00:00:00
3 2 2014-09-11 00:00:00
DROP TABLE items;
DROP TABLE IF EXISTS items;
CREATE TABLE items (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
score INT,
created_at DATETIME,
INDEX (score, created_at)
) DEFAULT CHARSET=UTF8;
SHOW CREATE TABLE items;
Table Create Table
items CREATE TABLE `items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`score` int(11) DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `score` (`score`,`created_at`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8
INSERT INTO items (score, created_at) VALUES(1, "2014-09-10 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-11 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-11 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-12 00:00:00");
INSERT INTO items (score, created_at) VALUES(3, "2014-09-13 00:00:00");
SELECT *
FROM items
WHERE score = 2 AND created_at <= "2014-09-12 00:00:00"
ORDER BY created_at DESC;
id score created_at
4 2 2014-09-12 00:00:00
2 2 2014-09-11 00:00:00
3 2 2014-09-11 00:00:00
DROP TABLE items;
select PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_TYPE select PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_TYPE
from information_schema.plugins where plugin_name = "Mroonga"; from information_schema.plugins where plugin_name = "Mroonga";
PLUGIN_NAME PLUGIN_VERSION PLUGIN_TYPE PLUGIN_NAME PLUGIN_VERSION PLUGIN_TYPE
Mroonga 4.5 STORAGE ENGINE Mroonga 4.6 STORAGE ENGINE
DROP TABLE IF EXISTS ids;
CREATE TABLE ids (
id INT PRIMARY KEY
) DEFAULT CHARSET=UTF8;
INSERT DELAYED INTO ids (id) VALUES (1);
ERROR HY000: DELAYED option not supported for table 'ids'
SELECT * FROM ids;
id
DROP TABLE ids;
show variables like 'mroonga_version'; show variables like 'mroonga_version';
Variable_name Value Variable_name Value
mroonga_version 4.05 mroonga_version 4.06
# Copyright(C) 2014 Naoya Murakami <naoya@createfield.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--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
SELECT mroonga_command("register token_filters/stop_word");
SET NAMES utf8;
CREATE TABLE memos (
content VARCHAR(64) NOT NULL
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
ALTER TABLE memos ADD FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord"';
SELECT mroonga_command("dump");
DROP TABLE memos;
--source ../../include/mroonga/unload_mroonga_functions.inc
--source ../../include/mroonga/have_mroonga_deinit.inc
# Copyright(C) 2014 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source ../../include/mroonga/have_mroonga.inc
--disable_warnings
DROP TABLE IF EXISTS ids;
--enable_warnings
CREATE TABLE ids (
id INT
) DEFAULT CHARSET UTF8;
INSERT INTO ids (id) values (1), (1);
--error ER_DUP_UNIQUE
ALTER TABLE ids ADD UNIQUE INDEX (id);
SHOW CREATE TABLE ids;
SELECT * FROM ids;
DROP TABLE ids;
--source ../../include/mroonga/have_mroonga_deinit.inc
# Copyright(C) 2014 Naoya Murakami <naoya@createfield.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--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
SELECT mroonga_command("register token_filters/stop_word");
CREATE TABLE terms (
term VARCHAR(64) NOT NULL PRIMARY KEY,
is_stop_word BOOL NOT NULL
) COMMENT='default_tokenizer "TokenBigram"' DEFAULT CHARSET=utf8;
CREATE TABLE memos (
id INT NOT NULL PRIMARY KEY,
content TEXT NOT NULL,
FULLTEXT INDEX (content) COMMENT 'table "terms"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
ALTER TABLE terms COMMENT='default_tokenizer "TokenBigram", token_filters "TokenFilterStopWord"';
SELECT mroonga_command("dump");
DROP TABLE memos;
DROP TABLE terms;
--source ../../include/mroonga/unload_mroonga_functions.inc
--source ../../include/mroonga/have_mroonga_deinit.inc
...@@ -18,9 +18,11 @@ ...@@ -18,9 +18,11 @@
--source ../../include/mroonga/have_mroonga.inc --source ../../include/mroonga/have_mroonga.inc
--source ../../include/mroonga/load_mroonga_functions.inc --source ../../include/mroonga/load_mroonga_functions.inc
--disable_warnings --disable_query_log
DROP TABLE IF EXISTS tags; DROP DATABASE test;
--enable_warnings CREATE DATABASE test;
USE test;
--enable_query_log
CREATE TABLE tags ( CREATE TABLE tags (
name VARCHAR(64) PRIMARY KEY name VARCHAR(64) PRIMARY KEY
......
# Copyright(C) 2014 Naoya Murakami <naoya@createfield.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/have_mroonga.inc
--source ../../include/mroonga/load_mroonga_functions.inc
--disable_warnings
DROP TABLE IF EXISTS memos;
DROP TABLE IF EXISTS terms;
--enable_warnings
SET NAMES utf8;
CREATE TABLE terms (
term VARCHAR(64) NOT NULL PRIMARY KEY
) COMMENT='default_tokenizer "TokenBigram", normalizer "NormalizerAuto"' DEFAULT CHARSET=utf8;
CREATE TABLE memos (
id INT NOT NULL PRIMARY KEY,
content TEXT NOT NULL,
FULLTEXT INDEX (content) COMMENT 'table "terms"'
) DEFAULT CHARSET=utf8;
INSERT INTO memos VALUES (1, "1日の消費㌍は約2000㌔㌍");
SELECT * FROM memos
WHERE MATCH (content) AGAINST ("+カロリー" IN BOOLEAN MODE);
DROP TABLE memos;
DROP TABLE terms;
--source ../../include/mroonga/unload_mroonga_functions.inc
--source ../../include/mroonga/have_mroonga_deinit.inc
# Copyright(C) 2014 Naoya Murakami <naoya@createfield.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--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
SELECT mroonga_command("register token_filters/stop_word");
SET NAMES utf8;
CREATE TABLE memos (
content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord,TokenFilterStopWord"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
DROP TABLE memos;
--source ../../include/mroonga/unload_mroonga_functions.inc
--source ../../include/mroonga/have_mroonga_deinit.inc
# Copyright(C) 2014 Naoya Murakami <naoya@createfield.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--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
SELECT mroonga_command("register token_filters/stop_word");
SET NAMES utf8;
CREATE TABLE memos (
content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
DROP TABLE memos;
--source ../../include/mroonga/unload_mroonga_functions.inc
--source ../../include/mroonga/have_mroonga_deinit.inc
# Copyright(C) 2014 Naoya Murakami <naoya@createfield.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--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
SELECT mroonga_command("register token_filters/stop_word");
CREATE TABLE terms (
term VARCHAR(64) NOT NULL PRIMARY KEY,
is_stop_word BOOL NOT NULL
) COMMENT='default_tokenizer "TokenBigram", token_filters "TokenFilterStopWord,TokenFilterStopWord"' DEFAULT CHARSET=utf8;
CREATE TABLE memos (
id INT NOT NULL PRIMARY KEY,
content TEXT NOT NULL,
FULLTEXT INDEX (content) COMMENT 'table "terms"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
DROP TABLE memos;
DROP TABLE terms;
--source ../../include/mroonga/unload_mroonga_functions.inc
--source ../../include/mroonga/have_mroonga_deinit.inc
# Copyright(C) 2014 Naoya Murakami <naoya@createfield.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--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
SELECT mroonga_command("register token_filters/stop_word");
CREATE TABLE terms (
term VARCHAR(64) NOT NULL PRIMARY KEY,
is_stop_word BOOL NOT NULL
) COMMENT='default_tokenizer "TokenBigram", token_filters "TokenFilterStopWord"' DEFAULT CHARSET=utf8;
CREATE TABLE memos (
id INT NOT NULL PRIMARY KEY,
content TEXT NOT NULL,
FULLTEXT INDEX (content) COMMENT 'table "terms"'
) DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
DROP TABLE memos;
DROP TABLE terms;
--source ../../include/mroonga/unload_mroonga_functions.inc
--source ../../include/mroonga/have_mroonga_deinit.inc
...@@ -18,9 +18,11 @@ ...@@ -18,9 +18,11 @@
--source ../../include/mroonga/have_mroonga.inc --source ../../include/mroonga/have_mroonga.inc
--source ../../include/mroonga/load_mroonga_functions.inc --source ../../include/mroonga/load_mroonga_functions.inc
--disable_warnings --disable_query_log
DROP TABLE IF EXISTS bugs; DROP DATABASE test;
--enable_warnings CREATE DATABASE test;
USE test;
--enable_query_log
CREATE TABLE bugs ( CREATE TABLE bugs (
id INT UNSIGNED PRIMARY KEY, id INT UNSIGNED PRIMARY KEY,
......
...@@ -14,14 +14,9 @@ ...@@ -14,14 +14,9 @@
# 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/have_version_56.inc --source ../../include/mroonga/skip_mysql_55.inc
--source ../../include/mroonga/check_mariadb.inc --source ../../include/mroonga/skip_mariadb_55.inc
--source include/have_innodb.inc
if ($mariadb)
{
skip This test is for MySQL version 5.6.x;
}
--source ../../include/mroonga/have_mroonga.inc --source ../../include/mroonga/have_mroonga.inc
--disable_warnings --disable_warnings
......
# Copyright(C) 2014 Naoya Murakami <naoya@createfield.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--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
SELECT mroonga_command("register token_filters/stop_word");
CREATE TABLE terms (
term VARCHAR(64) NOT NULL PRIMARY KEY,
is_stop_word BOOL NOT NULL
) COMMENT='default_tokenizer "TokenBigram", token_filters "TokenFilterStopWord"' DEFAULT CHARSET=utf8;
CREATE TABLE memos (
id INT NOT NULL PRIMARY KEY,
content TEXT NOT NULL,
FULLTEXT INDEX (content) COMMENT 'table "terms"'
) DEFAULT CHARSET=utf8;
INSERT INTO terms VALUES ("and", true);
INSERT INTO memos VALUES (1, "Hello");
INSERT INTO memos VALUES (2, "Hello and Good-bye");
INSERT INTO memos VALUES (3, "Good-bye");
SELECT * FROM memos
WHERE MATCH (content) AGAINST ("+\"Hello and\"" IN BOOLEAN MODE);
DROP TABLE memos;
DROP TABLE terms;
--source ../../include/mroonga/unload_mroonga_functions.inc
--source ../../include/mroonga/have_mroonga_deinit.inc
# Copyright(C) 2014 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/have_mroonga.inc
--disable_warnings
DROP TABLE IF EXISTS items;
--enable_warnings
CREATE TABLE items (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
score INT,
created_at DATETIME,
INDEX (score, created_at)
) DEFAULT CHARSET=UTF8;
SHOW CREATE TABLE items;
INSERT INTO items (score, created_at) VALUES(1, "2014-09-10 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-11 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-11 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-12 00:00:00");
INSERT INTO items (score, created_at) VALUES(3, "2014-09-13 00:00:00");
SELECT *
FROM items
WHERE score = 2 AND created_at > "2014-09-11 00:00:00"
ORDER BY created_at DESC;
DROP TABLE items;
--source ../../include/mroonga/have_mroonga_deinit.inc
# Copyright(C) 2014 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/have_mroonga.inc
--disable_warnings
DROP TABLE IF EXISTS items;
--enable_warnings
CREATE TABLE items (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
score INT,
created_at DATETIME,
INDEX (score, created_at)
) DEFAULT CHARSET=UTF8;
SHOW CREATE TABLE items;
INSERT INTO items (score, created_at) VALUES(1, "2014-09-10 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-11 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-11 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-12 00:00:00");
INSERT INTO items (score, created_at) VALUES(3, "2014-09-13 00:00:00");
SELECT *
FROM items
WHERE score = 2 AND created_at >= "2014-09-11 00:00:00"
ORDER BY created_at DESC;
DROP TABLE items;
--source ../../include/mroonga/have_mroonga_deinit.inc
# Copyright(C) 2014 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/have_mroonga.inc
--disable_warnings
DROP TABLE IF EXISTS items;
--enable_warnings
CREATE TABLE items (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
score INT,
created_at DATETIME,
INDEX (score, created_at)
) DEFAULT CHARSET=UTF8;
SHOW CREATE TABLE items;
INSERT INTO items (score, created_at) VALUES(1, "2014-09-10 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-11 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-11 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-12 00:00:00");
INSERT INTO items (score, created_at) VALUES(3, "2014-09-13 00:00:00");
SELECT *
FROM items
WHERE score = 2 AND created_at < "2014-09-12 00:00:00"
ORDER BY created_at DESC;
DROP TABLE items;
--source ../../include/mroonga/have_mroonga_deinit.inc
# Copyright(C) 2014 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source ../../include/mroonga/have_mroonga.inc
--disable_warnings
DROP TABLE IF EXISTS items;
--enable_warnings
CREATE TABLE items (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
score INT,
created_at DATETIME,
INDEX (score, created_at)
) DEFAULT CHARSET=UTF8;
SHOW CREATE TABLE items;
INSERT INTO items (score, created_at) VALUES(1, "2014-09-10 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-11 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-11 00:00:00");
INSERT INTO items (score, created_at) VALUES(2, "2014-09-12 00:00:00");
INSERT INTO items (score, created_at) VALUES(3, "2014-09-13 00:00:00");
SELECT *
FROM items
WHERE score = 2 AND created_at <= "2014-09-12 00:00:00"
ORDER BY created_at DESC;
DROP TABLE items;
--source ../../include/mroonga/have_mroonga_deinit.inc
# Copyright(C) 2014 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/not_embedded.inc
--source ../../include/mroonga/have_mroonga.inc
--disable_warnings
DROP TABLE IF EXISTS ids;
--enable_warnings
CREATE TABLE ids (
id INT PRIMARY KEY
) DEFAULT CHARSET=UTF8;
--error ER_DELAYED_NOT_SUPPORTED
INSERT DELAYED INTO ids (id) VALUES (1);
SELECT * FROM ids;
DROP TABLE ids;
--source ../../include/mroonga/have_mroonga_deinit.inc
create_table_token_filters_index_comment_multiple_token_filters : Bundled Mroonga does not support token filter yet.
create_table_token_filters_index_comment_one_token_filter : Bundled Mroonga does not support token filter yet.
SELECT mroonga_command("register token_filters/stop_word");
mroonga_command("register token_filters/stop_word")
true
SET NAMES utf8;
CREATE TABLE memos (
id INT NOT NULL PRIMARY KEY,
content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord,TokenFilterStopWord"'
) COMMENT='engine "InnoDB"' DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
table_create memos TABLE_HASH_KEY 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
DROP TABLE memos;
SELECT mroonga_command("register token_filters/stop_word");
mroonga_command("register token_filters/stop_word")
true
SET NAMES utf8;
CREATE TABLE memos (
id INT NOT NULL PRIMARY KEY,
content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord"'
) COMMENT='engine "InnoDB"' DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
mroonga_command("dump")
table_create memos TABLE_HASH_KEY ShortText
table_create memos-content TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerMySQLGeneralCI --token_filters TokenFilterStopWord
column_create memos-content index COLUMN_INDEX|WITH_POSITION memos
DROP TABLE memos;
...@@ -25,7 +25,7 @@ id title body ...@@ -25,7 +25,7 @@ id title body
2 groonga (1) starting groonga... 2 groonga (1) starting groonga...
FLUSH TABLES; FLUSH TABLES;
SELECT * FROM diaries WHERE MATCH(body) AGAINST("starting"); SELECT * FROM diaries WHERE MATCH(body) AGAINST("starting");
ERROR HY000: syscall error 'repair_test.mrn' (No such file or directory) ERROR HY000: mroonga: failed to open table: <diaries>
REPAIR TABLE diaries; REPAIR TABLE diaries;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
repair_test.diaries repair status OK repair_test.diaries repair status OK
......
# Copyright(C) 2014 Naoya Murakami <naoya@createfield.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/have_innodb.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
SELECT mroonga_command("register token_filters/stop_word");
SET NAMES utf8;
CREATE TABLE memos (
id INT NOT NULL PRIMARY KEY,
content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord,TokenFilterStopWord"'
) COMMENT='engine "InnoDB"' DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
DROP TABLE memos;
--source ../../include/mroonga/unload_mroonga_functions.inc
--source ../../include/mroonga/have_mroonga_deinit.inc
# Copyright(C) 2014 Naoya Murakami <naoya@createfield.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--source include/have_innodb.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
SELECT mroonga_command("register token_filters/stop_word");
SET NAMES utf8;
CREATE TABLE memos (
id INT NOT NULL PRIMARY KEY,
content VARCHAR(64) NOT NULL,
FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord"'
) COMMENT='engine "InnoDB"' DEFAULT CHARSET=utf8;
SELECT mroonga_command("dump");
DROP TABLE memos;
--source ../../include/mroonga/unload_mroonga_functions.inc
--source ../../include/mroonga/have_mroonga_deinit.inc
...@@ -51,7 +51,7 @@ SELECT * FROM diaries WHERE MATCH(body) AGAINST("starting"); ...@@ -51,7 +51,7 @@ SELECT * FROM diaries WHERE MATCH(body) AGAINST("starting");
FLUSH TABLES; FLUSH TABLES;
# Error ER_CANT_OPEN_FILE syscall error 'repair_test.mrn' (No such file or directory) # Error ER_CANT_OPEN_FILE mroonga: failed to open table: <diaries>
--error ER_CANT_OPEN_FILE --error ER_CANT_OPEN_FILE
SELECT * FROM diaries WHERE MATCH(body) AGAINST("starting"); SELECT * FROM diaries WHERE MATCH(body) AGAINST("starting");
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
--source ../../include/mroonga/have_version_55.inc --source ../../include/mroonga/have_version_55.inc
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/have_perfschema.inc
--source include/not_embedded.inc --source include/not_embedded.inc
--source ../../include/mroonga/have_mroonga.inc --source ../../include/mroonga/have_mroonga.inc
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
--source ../../include/mroonga/have_version_56_or_later.inc --source ../../include/mroonga/have_version_56_or_later.inc
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/have_perfschema.inc
--source include/not_embedded.inc --source include/not_embedded.inc
--source ../../include/mroonga/have_mroonga.inc --source ../../include/mroonga/have_mroonga.inc
......
...@@ -2,7 +2,7 @@ REPOSITORIES_PATH = repositories ...@@ -2,7 +2,7 @@ REPOSITORIES_PATH = repositories
DISTRIBUTIONS = debian DISTRIBUTIONS = debian
CHROOT_BASE = /var/lib/chroot CHROOT_BASE = /var/lib/chroot
ARCHITECTURES = i386 amd64 ARCHITECTURES = i386 amd64
CODES = wheezy jessie unstable CODE_NAMES = wheezy
all: all:
...@@ -21,14 +21,14 @@ download: ...@@ -21,14 +21,14 @@ download:
done done
sign-packages: sign-packages:
./sign-packages.sh '$(GPG_UID)' '$(REPOSITORIES_PATH)/' '$(CODES)' ./sign-packages.sh '$(GPG_UID)' '$(REPOSITORIES_PATH)/' '$(CODE_NAMES)'
update-repository: update-repository:
./update-repository.sh '$(PACKAGE_NAME)' '$(REPOSITORIES_PATH)/' \ ./update-repository.sh '$(PACKAGE_NAME)' '$(REPOSITORIES_PATH)/' \
'$(ARCHITECTURES)' '$(CODES)' '$(ARCHITECTURES)' '$(CODE_NAMES)'
sign-repository: sign-repository:
./sign-repository.sh '$(GPG_UID)' '$(REPOSITORIES_PATH)/' '$(CODES)' ./sign-repository.sh '$(GPG_UID)' '$(REPOSITORIES_PATH)/' '$(CODE_NAMES)'
ensure-rsync-path: ensure-rsync-path:
@if test -z "$(RSYNC_PATH)"; then \ @if test -z "$(RSYNC_PATH)"; then \
...@@ -44,12 +44,25 @@ upload: ensure-rsync-path ...@@ -44,12 +44,25 @@ upload: ensure-rsync-path
); \ ); \
done done
build: source build: build-package-deb
./build-in-chroot.sh \
$(PACKAGE) $(VERSION) $(srcdir)/.. $(REPOSITORIES_PATH)/ \
$(CHROOT_BASE) '$(ARCHITECTURES)' '$(CODES)'
source: ../$(PACKAGE)-$(VERSION).tar.gz build-package-deb: prepare-build-package-deb
vagrant destroy --force
for architecture in $(ARCHITECTURES); do \
for code_name in $(CODE_NAMES); do \
id=debian-$$code_name-$$architecture; \
vagrant up $$id || exit 1; \
vagrant destroy --force $$id; \
done; \
done
prepare-build-package-deb: source env.sh
cp env.sh tmp/
rm -rf tmp/debian
cp -rp $(srcdir)/../debian tmp/
source: tmp/$(PACKAGE)-$(VERSION).tar.gz
../$(PACKAGE)-$(VERSION).tar.gz: tmp/$(PACKAGE)-$(VERSION).tar.gz: $(abs_top_builddir)/$(PACKAGE)-$(VERSION).tar.gz
ln -s $(abs_top_builddir)/$(PACKAGE)-$(VERSION).tar.gz ../ mkdir -p tmp
cp $(abs_top_builddir)/$(PACKAGE)-$(VERSION).tar.gz $@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
vms = [
{
:id => "debian-wheezy-i386",
:box_url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-7.6-i386_chef-provisionerless.box
",
},
{
:id => "debian-wheezy-amd64",
:box_url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-7.6_chef-provisionerless.box",
},
]
vms.each do |vm|
config.vm.define(vm[:id]) do |node|
node.vm.box = vm[:id]
node.vm.box_url = vm[:box_url]
node.vm.provision(:shell, :path => "build-deb.sh")
node.vm.provider("virtualbox") do |virtual_box|
virtual_box.memory = 768
end
end
end
end
...@@ -2,12 +2,6 @@ ...@@ -2,12 +2,6 @@
LANG=C LANG=C
PACKAGE=$(cat /tmp/build-package)
USER_NAME=$(cat /tmp/build-user)
VERSION=$(cat /tmp/build-version)
DEPENDED_PACKAGES=$(cat /tmp/depended-packages)
BUILD_SCRIPT=/tmp/build-deb-in-chroot.sh
mysql_server_package=mysql-server mysql_server_package=mysql-server
run() run()
...@@ -19,103 +13,66 @@ run() ...@@ -19,103 +13,66 @@ run()
fi fi
} }
. /vagrant/tmp/env.sh
grep '^deb ' /etc/apt/sources.list | \ grep '^deb ' /etc/apt/sources.list | \
sed -e 's/^deb /deb-src /' > /etc/apt/sources.list.d/base-source.list sed -e 's/^deb /deb-src /' > /etc/apt/sources.list.d/base-source.list
run apt-get update run apt-get update
run apt-get install -V -y lsb-release run apt-get install -y lsb-release
distribution=$(lsb_release --id --short)
code_name=$(lsb_release --codename --short)
groonga_list=/etc/apt/sources.list.d/groonga.list distribution=$(lsb_release --id --short | tr 'A-Z' 'a-z')
if [ ! -f "${groonga_list}" ]; then code_name=$(lsb_release --codename --short)
case ${distribution} in case "${distribution}" in
Debian) debian)
component=main component=main
if [ "$code_name" = "sid" ]; then run cat <<EOF > /etc/apt/sources.list.d/groonga.list
code_name=unstable deb http://packages.groonga.org/debian/ wheezy main
fi deb-src http://packages.groonga.org/debian/ wheezy main
;;
Ubuntu)
component=universe
;;
esac
downcased_distribtion=$(echo ${distribution} | tr A-Z a-z)
run cat <<EOF | run tee ${groonga_list}
deb http://packages.groonga.org/${downcased_distribtion}/ ${code_name} ${component}
deb-src http://packages.groonga.org/${downcased_distribtion}/ ${code_name} ${component}
EOF EOF
apt-get update if ! grep --quiet security /etc/apt/sources.list; then
run apt-get -V -y --allow-unauthenticated install groonga-keyring run cat <<EOF > /etc/apt/sources.list.d/security.list
fi
run apt-get update
run apt-get upgrade -V -y
security_list=/etc/apt/sources.list.d/security.list
if [ ! -f "${security_list}" ]; then
run apt-get install -V -y lsb-release
case ${distribution} in
Debian)
if [ "${code_name}" = "sid" ]; then
touch "${security_list}"
else
cat <<EOF > "${security_list}"
deb http://security.debian.org/ ${code_name}/updates main deb http://security.debian.org/ ${code_name}/updates main
deb-src http://security.debian.org/ ${code_name}/updates main deb-src http://security.debian.org/ ${code_name}/updates main
EOF EOF
fi fi
run apt-get update
run apt-get install -y --allow-unauthenticated groonga-keyring
run apt-get update
;; ;;
Ubuntu) ubuntu)
cat <<EOF > "${security_list}" component=universe
run cat <<EOF > /etc/apt/sources.list.d/security.list
deb http://security.ubuntu.com/ubuntu ${code_name}-security main restricted deb http://security.ubuntu.com/ubuntu ${code_name}-security main restricted
deb-src http://security.ubuntu.com/ubuntu ${code_name}-security main restricted deb-src http://security.ubuntu.com/ubuntu ${code_name}-security main restricted
EOF EOF
;; run sed -e 's/main/universe/' /etc/apt/sources.list > \
esac /etc/apt/sources.list.d/universe.list
run apt-get -y install software-properties-common
run apt-get update run add-apt-repository -y universe
run apt-get upgrade -V -y run add-apt-repository -y ppa:groonga/ppa
fi
universe_list=/etc/apt/sources.list.d/universe.list
if [ ! -f "$universe_list}" ]; then
case ${distribution} in
Ubuntu)
sed -e 's/main/universe/' /etc/apt/sources.list > ${universe_list}
run apt-get update run apt-get update
;; ;;
esac esac
fi
run apt-get install -V -y devscripts ${DEPENDED_PACKAGES} run apt-get install -V -y build-essential devscripts ${DEPENDED_PACKAGES}
run apt-get build-dep -y ${mysql_server_package} run apt-get build-dep -y ${mysql_server_package}
run apt-get clean
if ! id $USER_NAME >/dev/null 2>&1; then
run useradd -m $USER_NAME
fi
cat <<EOF > $BUILD_SCRIPT
#!/bin/sh
rm -rf build
mkdir -p build
cp /tmp/${PACKAGE}-${VERSION}.tar.gz build/${PACKAGE}_${VERSION}.orig.tar.gz
cd build
tar xfz ${PACKAGE}_${VERSION}.orig.tar.gz
cd ${PACKAGE}-${VERSION}/
cp -rp /tmp/${PACKAGE}-debian debian
# export DEB_BUILD_OPTIONS="noopt nostrip"
MYSQL_PACKAGE_INFO=\$(apt-cache show mysql-server | grep Version | sort | tail -1)
MYSQL_PACKAGE_VERSION=\${MYSQL_PACKAGE_INFO##Version: }
sed -i "s/MYSQL_VERSION/\$MYSQL_PACKAGE_VERSION/" debian/control
debuild -us -uc
EOF
run chmod +x $BUILD_SCRIPT run mkdir -p build
run su - $USER_NAME $BUILD_SCRIPT run cp /vagrant/tmp/${PACKAGE}-${VERSION}.tar.gz \
build/${PACKAGE}_${VERSION}.orig.tar.gz
run cd build
run tar xfz ${PACKAGE}_${VERSION}.orig.tar.gz
run cd ${PACKAGE}-${VERSION}/
run cp -rp /vagrant/tmp/debian debian
# export DEB_BUILD_OPTIONS=noopt
MYSQL_PACKAGE_INFO=$(apt-cache show mysql-server | grep Version | sort | tail -1)
MYSQL_PACKAGE_VERSION=${MYSQL_PACKAGE_INFO##Version: }
sed -i "s/MYSQL_VERSION/$MYSQL_PACKAGE_VERSION/" debian/control
run debuild -us -uc
run cd -
package_initial=$(echo "${PACKAGE}" | sed -e 's/\(.\).*/\1/')
pool_dir="/vagrant/repositories/${distribution}/pool/${code_name}/${component}/${package_initial}/${PACKAGE}"
run mkdir -p "${pool_dir}/"
run cp *.tar.gz *.dsc *.deb "${pool_dir}/"
#!/bin/sh
if [ $# != 7 ]; then
echo "Usage: $0 PACKAGE VERSION SOURCE_DIR DESTINATION CHROOT_BASE ARCHITECTURES CODES"
echo " e.g.: $0 groonga 0.1.9 SOURCE_DIR repositories/ /var/lib/chroot 'i386 amd64' 'lenny unstable hardy karmic'"
exit 1
fi
PACKAGE=$1
VERSION=$2
SOURCE_DIR=$3
DESTINATION=$4
CHROOT_BASE=$5
ARCHITECTURES=$6
CODES=$7
PATH=/usr/local/sbin:/usr/sbin:$PATH
script_base_dir=`dirname $0`
if test "$PARALLEL" = "yes"; then
parallel="yes"
else
parallel="no"
fi
run()
{
"$@"
if test $? -ne 0; then
echo "Failed $@"
exit 1
fi
}
run_sudo()
{
run sudo "$@"
}
build_chroot()
{
architecture=$1
code_name=$2
run_sudo debootstrap --arch $architecture $code_name $base_dir
case $code_name in
squeeze|wheezy|jessie|unstable)
run_sudo sed -i'' -e 's/us/jp/' $base_dir/etc/apt/sources.list
;;
*)
run_sudo sed -i'' \
-e 's,http://archive,http://jp.archive,' \
-e 's/main$/main universe/' \
$base_dir/etc/apt/sources.list
;;
esac
run_sudo sh -c "echo >> /etc/fstab"
run_sudo sh -c "echo /sys ${base_dir}/sys none bind 0 0 >> /etc/fstab"
run_sudo sh -c "echo /dev ${base_dir}/dev none bind 0 0 >> /etc/fstab"
run_sudo sh -c "echo devpts-chroot ${base_dir}/dev/pts devpts defaults 0 0 >> /etc/fstab"
run_sudo sh -c "echo proc-chroot ${base_dir}/proc proc defaults 0 0 >> /etc/fstab"
run_sudo mount ${base_dir}/sys
run_sudo mount ${base_dir}/dev
run_sudo mount ${base_dir}/dev/pts
run_sudo mount ${base_dir}/proc
}
build()
{
architecture=$1
code_name=$2
target=${code_name}-${architecture}
base_dir=${CHROOT_BASE}/${target}
if [ ! -d $base_dir ]; then
run build_chroot $architecture $code_name
fi
case ${code_name} in
squeeze|wheezy|jessie|unstable)
distribution=debian
component=main
;;
*)
distribution=ubuntu
component=universe
;;
esac
source_dir=${SOURCE_DIR}
build_user=${PACKAGE}-build
build_user_dir=${base_dir}/home/$build_user
build_dir=${build_user_dir}/build
pool_base_dir=${DESTINATION}${distribution}/pool/${code_name}/${component}
package_initial=$(echo ${PACKAGE} | sed -e 's/\(.\).*/\1/')
pool_dir=${pool_base_dir}/${package_initial}/${PACKAGE}
run cp $source_dir/${PACKAGE}-${VERSION}.tar.gz \
${CHROOT_BASE}/$target/tmp/
run rm -rf ${CHROOT_BASE}/$target/tmp/${PACKAGE}-debian
run cp -rp $source_dir/debian/ \
${CHROOT_BASE}/$target/tmp/${PACKAGE}-debian
run echo $PACKAGE > ${CHROOT_BASE}/$target/tmp/build-package
run echo $VERSION > ${CHROOT_BASE}/$target/tmp/build-version
run echo $build_user > ${CHROOT_BASE}/$target/tmp/build-user
run cp ${script_base_dir}/${PACKAGE}-depended-packages \
${CHROOT_BASE}/$target/tmp/depended-packages
run cp ${script_base_dir}/build-deb.sh \
${CHROOT_BASE}/$target/tmp/
run_sudo rm -rf $build_dir
run_sudo su -c "/usr/sbin/chroot ${CHROOT_BASE}/$target /tmp/build-deb.sh"
run mkdir -p $pool_dir
for path in $build_dir/*; do
[ -f $path ] && run cp -p $path $pool_dir/
done
}
for architecture in $ARCHITECTURES; do
for code_name in $CODES; do
if test "$parallel" = "yes"; then
build $architecture $code_name &
else
mkdir -p tmp
build_log=tmp/build-$code_name-$architecture.log
build $architecture $code_name 2>&1 | tee $build_log
fi;
done;
done
if test "$parallel" = "yes"; then
wait
fi
PACKAGE=@PACKAGE@
VERSION=@VERSION@
DEPENDED_PACKAGES="
debhelper debhelper
autotools-dev autotools-dev
libgroonga-dev libgroonga-dev
...@@ -9,3 +12,4 @@ libmysqld-dev ...@@ -9,3 +12,4 @@ libmysqld-dev
libssl-dev libssl-dev
groonga-normalizer-mysql groonga-normalizer-mysql
wget wget
"
mroonga (4.06-1) unstable; urgency=low
* New upstream release.
-- Kouhei Sutou <kou@clear-code.com> Mon, 29 Sep 2014 00:00:00 +0900
mroonga (4.05-1) unstable; urgency=low mroonga (4.05-1) unstable; urgency=low
* New upstream release. * New upstream release.
......
...@@ -154,6 +154,9 @@ fi ...@@ -154,6 +154,9 @@ fi
%doc mysql-mroonga-doc/* %doc mysql-mroonga-doc/*
%changelog %changelog
* Mon Sep 29 2014 Kouhei Sutou <kou@clear-code.com> - 4.06-1
- new upstream release.
* Fri Aug 29 2014 Kouhei Sutou <kou@clear-code.com> - 4.05-1 * Fri Aug 29 2014 Kouhei Sutou <kou@clear-code.com> - 4.05-1
- new upstream release. - new upstream release.
......
...@@ -163,6 +163,9 @@ fi ...@@ -163,6 +163,9 @@ fi
%doc mysql-mroonga-doc/* %doc mysql-mroonga-doc/*
%changelog %changelog
* Mon Sep 29 2014 Kouhei Sutou <kou@clear-code.com> - 4.06-1
- new upstream release.
* Fri Aug 29 2014 Kouhei Sutou <kou@clear-code.com> - 4.05-1 * Fri Aug 29 2014 Kouhei Sutou <kou@clear-code.com> - 4.05-1
- new upstream release. - new upstream release.
......
%{!?centos_ver:%define centos_ver 6} %{!?centos_ver:%define centos_ver 6}
%if %{centos_ver} == 7 %if %{centos_ver} == 7
%define mysql_version_default 5.6.20 %define mysql_version_default 5.6.21
%define mysql_release_default 4 %define mysql_release_default 2
%define mysql_dist_default el7 %define mysql_dist_default el7
%define mysql_download_base_url_default http://repo.mysql.com/yum/mysql-5.6-community/el/7/SRPMS %define mysql_download_base_url_default http://repo.mysql.com/yum/mysql-5.6-community/el/7/SRPMS
%define mysql_spec_file_default mysql.spec %define mysql_spec_file_default mysql.spec
%else %else
%define mysql_version_default 5.6.20 %define mysql_version_default 5.6.21
%define mysql_release_default 4 %define mysql_release_default 2
%define mysql_dist_default el6 %define mysql_dist_default el6
%define mysql_download_base_url_default http://repo.mysql.com/yum/mysql-5.6-community/el/6/SRPMS %define mysql_download_base_url_default http://repo.mysql.com/yum/mysql-5.6-community/el/6/SRPMS
%define mysql_spec_file_default mysql.spec %define mysql_spec_file_default mysql.spec
...@@ -158,6 +158,12 @@ fi ...@@ -158,6 +158,12 @@ fi
%doc mysql-mroonga-doc/* %doc mysql-mroonga-doc/*
%changelog %changelog
* Mon Sep 29 2014 Kouhei Sutou <kou@clear-code.com> - 4.06-1
- new upstream release.
* Sat Sep 27 2014 Eiichi Sato <miko@cafelounge.net> - 4.05-2
- build against MySQL 5.6.21-2 on MySQL yum repository.
* Fri Aug 29 2014 Kouhei Sutou <kou@clear-code.com> - 4.05-1 * Fri Aug 29 2014 Kouhei Sutou <kou@clear-code.com> - 4.05-1
- new upstream release. - new upstream release.
......
...@@ -136,6 +136,9 @@ fi ...@@ -136,6 +136,9 @@ fi
%doc mariadb-mroonga-doc/* %doc mariadb-mroonga-doc/*
%changelog %changelog
* Mon Sep 29 2014 Kouhei Sutou <kou@clear-code.com> - 4.06-1
- new upstream release.
* Fri Aug 29 2014 Kouhei Sutou <kou@clear-code.com> - 4.05-1 * Fri Aug 29 2014 Kouhei Sutou <kou@clear-code.com> - 4.05-1
- new upstream release. - new upstream release.
......
...@@ -133,6 +133,9 @@ fi ...@@ -133,6 +133,9 @@ fi
%doc mysql-mroonga-doc/* %doc mysql-mroonga-doc/*
%changelog %changelog
* Mon Sep 29 2014 Kouhei Sutou <kou@clear-code.com> - 4.06-1
- new upstream release.
* Fri Aug 29 2014 Kouhei Sutou <kou@clear-code.com> - 4.05-1 * Fri Aug 29 2014 Kouhei Sutou <kou@clear-code.com> - 4.05-1
- new upstream release. - new upstream release.
......
MROONGA_BASE = $(PACKAGE)-$(VERSION) MROONGA_BASE = $(PACKAGE)-$(VERSION)
MROONGA_TAR_GZ = $(MROONGA_BASE).tar.gz MROONGA_TAR_GZ = $(MROONGA_BASE).tar.gz
GROONGA_VERSION = 4.0.4 GROONGA_VERSION = 4.0.6
GROONGA_BASE = groonga-$(GROONGA_VERSION) GROONGA_BASE = groonga-$(GROONGA_VERSION)
GROONGA_TAR_GZ = $(GROONGA_BASE).tar.gz GROONGA_TAR_GZ = $(GROONGA_BASE).tar.gz
...@@ -11,7 +11,7 @@ GROONGA_NORMALIZER_MYSQL_BASE = \ ...@@ -11,7 +11,7 @@ GROONGA_NORMALIZER_MYSQL_BASE = \
GROONGA_NORMALIZER_MYSQL_TAR_GZ = \ GROONGA_NORMALIZER_MYSQL_TAR_GZ = \
$(GROONGA_NORMALIZER_MYSQL_BASE).tar.gz $(GROONGA_NORMALIZER_MYSQL_BASE).tar.gz
MARIADB_VERSION = 10.0.13 MARIADB_VERSION = 10.0.14
MARIADB_BASE = mariadb-$(MARIADB_VERSION) MARIADB_BASE = mariadb-$(MARIADB_VERSION)
MARIADB_TAR_GZ = $(MARIADB_BASE).tar.gz MARIADB_TAR_GZ = $(MARIADB_BASE).tar.gz
......
...@@ -28,6 +28,14 @@ unsigned_rpms() ...@@ -28,6 +28,14 @@ unsigned_rpms()
done done
} }
if ! gpg --list-keys "${GPG_UID}" > /dev/null 2>&1; then
run gpg --keyserver keyserver.ubuntu.com --recv-key "${GPG_UID}"
fi
run mkdir -p tmp
run gpg --armor --export "${GPG_UID}" > tmp/sign-key
run rpm --import tmp/sign-key
run rm -rf tmp/sign-key
rpms="" rpms=""
for distribution in ${DISTRIBUTIONS}; do for distribution in ${DISTRIBUTIONS}; do
rpms="${rpms} $(find ${DESTINATION}${distribution} -name '*.rpm' | unsigned_rpms)" rpms="${rpms} $(find ${DESTINATION}${distribution} -name '*.rpm' | unsigned_rpms)"
......
4.5 4.6
\ No newline at end of file \ No newline at end of file
sources = \ sources = \
mrn_macro.hpp \ mrn_macro.hpp \
mrn_sys.cpp \
mrn_sys.hpp \
mrn_constants.hpp \ mrn_constants.hpp \
ha_mroonga.cpp \ ha_mroonga.cpp \
ha_mroonga.hpp \ ha_mroonga.hpp \
......
if WITH_CUTTER if WITH_CUTTER
noinst_LTLIBRARIES = \ noinst_LTLIBRARIES = \
test_mrn_sys.la \
test_mrn_path_mapper.la test_mrn_path_mapper.la
endif endif
...@@ -21,12 +20,6 @@ LIBS = \ ...@@ -21,12 +20,6 @@ LIBS = \
$(GROONGA_LIBS) \ $(GROONGA_LIBS) \
$(MECAB_LIBS) $(MECAB_LIBS)
EXTERNAL_SRC = ../../mrn_sys.cpp
test_mrn_sys_la_SOURCES = \
$(EXTERNAL_SRC) \
test_mrn_sys.cpp
test_mrn_path_mapper_la_SOURCES = \ test_mrn_path_mapper_la_SOURCES = \
test_mrn_path_mapper.cpp test_mrn_path_mapper.cpp
......
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2010 Tetsuro IKEDA
Copyright(C) 2011-2012 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <string.h>
#include <cppcutter.h>
#include <mrn_sys.hpp>
static grn_ctx *ctx;
static grn_obj *db;
static grn_hash *hash;
static grn_obj buffer;
namespace test_mrn_sys
{
void cut_startup()
{
ctx = (grn_ctx *)malloc(sizeof(grn_ctx));
grn_init();
grn_ctx_init(ctx, 0);
db = grn_db_create(ctx, NULL, NULL);
grn_ctx_use(ctx, db);
}
void cut_shutdown()
{
grn_obj_unlink(ctx, db);
grn_ctx_fin(ctx);
grn_fin();
free(ctx);
}
void cut_setup()
{
hash = grn_hash_create(ctx, NULL, 1024, sizeof(grn_obj *),
GRN_OBJ_KEY_VAR_SIZE);
GRN_TEXT_INIT(&buffer, 0);
}
void cut_teardown()
{
grn_hash_close(ctx, hash);
grn_obj_unlink(ctx, &buffer);
}
void test_mrn_hash_put()
{
const char *key = "mroonga";
cut_assert_true(mrn_hash_put(ctx, hash, key, &buffer));
cut_assert_false(mrn_hash_put(ctx, hash, key, &buffer));
}
void test_mrn_hash_get()
{
const char *key = "mroonga";
const char *value = "A storage engine based on groonga.";
grn_obj *result;
GRN_TEXT_SETS(ctx, &buffer, value);
GRN_TEXT_PUT(ctx, &buffer, "\0", 1);
mrn_hash_put(ctx, hash, key, &buffer);
cut_assert_true(mrn_hash_get(ctx, hash, key, &result));
cppcut_assert_equal(value, GRN_TEXT_VALUE(&buffer));
}
void test_mrn_hash_remove()
{
const char *key = "mroonga";
mrn_hash_put(ctx, hash, key, &buffer);
cut_assert_false(mrn_hash_remove(ctx, hash, "nonexistent"));
cut_assert_true(mrn_hash_remove(ctx, hash, key));
cut_assert_false(mrn_hash_remove(ctx, hash, key));
}
}
#!/bin/sh #!/bin/bash
# #
# Copyright(C) 2012-2013 Kouhei Sutou <kou@clear-code.com> # Copyright(C) 2012-2014 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
...@@ -19,8 +19,12 @@ ...@@ -19,8 +19,12 @@
# set -x # set -x
set -e set -e
if [ "$MRN_BUNDLED" = "yes" ]; then if [ "${MROONGA_BUNDLED}" = "yes" ]; then
cmake . -DWITH_DEBUG=1 cmake_args=(-DCMAKE_BUILD_TYPE=Debug)
if [ "${MROONGA_TEST_EMBEDDED}" = "yes" ]; then
cmake_args=("${cmake_args[@]}" "-DWITH_EMBEDDED_SERVER=TRUE")
fi
cmake . "${cmake_args[@]}"
else else
./autogen.sh ./autogen.sh
......
...@@ -32,7 +32,7 @@ if [ ! -f /usr/lib/groonga/plugins/tokenizers/mecab.so ]; then ...@@ -32,7 +32,7 @@ if [ ! -f /usr/lib/groonga/plugins/tokenizers/mecab.so ]; then
sudo apt-get -qq -y install groonga-tokenizer-mecab sudo apt-get -qq -y install groonga-tokenizer-mecab
fi fi
if [ "${MRN_BUNDLED}" = "yes" ]; then if [ "${MROONGA_BUNDLED}" = "yes" ]; then
mkdir -p .mroonga mkdir -p .mroonga
mv * .mroonga/ mv * .mroonga/
mv .mroonga/tools ./ mv .mroonga/tools ./
......
#!/bin/bash #!/bin/bash
# #
# Copyright(C) 2012-2013 Kouhei Sutou <kou@clear-code.com> # Copyright(C) 2012-2014 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
...@@ -31,20 +31,24 @@ else ...@@ -31,20 +31,24 @@ else
. "${top_dir}/config.sh" . "${top_dir}/config.sh"
fi fi
if [ "${MRN_BUNDLED}" = "TRUE" ]; then n_processors="$(grep '^processor' /proc/cpuinfo | wc -l)"
n_processors=1 max_n_processors=8
else if (( $n_processors > $max_n_processors )); then
n_processors="$(grep '^processor' /proc/cpuinfo | wc -l)" n_processors=$max_n_processors
fi fi
build() build()
{ {
if [ "${MROONGA_BUNDLED}" = "yes" ]; then
make > /dev/null
else
make -j${n_processors} > /dev/null make -j${n_processors} > /dev/null
fi
} }
run_unit_test() run_unit_test()
{ {
if [ "${MRN_BUNDLED}" != "TRUE" ]; then if [ "${MROONGA_BUNDLED}" != "yes" ]; then
NO_MAKE=yes ${mroonga_dir}/test/run-unit-test.sh NO_MAKE=yes ${mroonga_dir}/test/run-unit-test.sh
fi fi
} }
...@@ -89,12 +93,14 @@ prepare_sql_test() ...@@ -89,12 +93,14 @@ prepare_sql_test()
run_sql_test() run_sql_test()
{ {
test_args=() test_args=()
if [ "${MRN_TEST_EMBEDDED}" = "yes" ]; then if [ "${MROONGA_TEST_EMBEDDED}" = "yes" ]; then
test_args=("${test_args[@]}" "--embedded-server") test_args=("${test_args[@]}" "--embedded-server")
fi fi
if [ "${MRN_BUNDLED}" = "TRUE" ]; then if [ "${MROONGA_BUNDLED}" = "yes" ]; then
${mroonga_dir}/test/run-sql-test.sh "${test_args[@]}" ${mroonga_dir}/test/run-sql-test.sh \
"${test_args[@]}" \
--parallel="${n_processors}"
else else
prepare_sql_test prepare_sql_test
......
...@@ -24,12 +24,17 @@ ...@@ -24,12 +24,17 @@
#include <mrn_path_mapper.hpp> #include <mrn_path_mapper.hpp>
#include <mrn_windows.hpp> #include <mrn_windows.hpp>
#include <mrn_macro.hpp> #include <mrn_macro.hpp>
#include <mrn_database_manager.hpp>
extern mrn::DatabaseManager *mrn_db_manager;
MRN_BEGIN_DECLS MRN_BEGIN_DECLS
struct CommandInfo struct CommandInfo
{ {
grn_ctx ctx; grn_ctx ctx;
grn_obj *db;
bool use_shared_db;
String result; String result;
}; };
...@@ -66,13 +71,17 @@ MRN_API my_bool mroonga_command_init(UDF_INIT *initid, UDF_ARGS *args, ...@@ -66,13 +71,17 @@ MRN_API my_bool mroonga_command_init(UDF_INIT *initid, UDF_ARGS *args,
const char *action; const char *action;
if (current_db_path) { if (current_db_path) {
action = "open database"; action = "open database";
mrn::PathMapper mapper(current_db_path); int error = mrn_db_manager->open(current_db_path, &(info->db));
grn_db_open(&(info->ctx), mapper.db_path()); if (error == 0) {
grn_ctx_use(&(info->ctx), info->db);
info->use_shared_db = true;
}
} else { } else {
action = "create anonymous database"; action = "create anonymous database";
grn_db_create(&(info->ctx), NULL, NULL); info->db = grn_db_create(&(info->ctx), NULL, NULL);
info->use_shared_db = false;
} }
if (info->ctx.rc != GRN_SUCCESS) { if (!info->db) {
sprintf(message, sprintf(message,
"mroonga_command(): failed to %s: %s", "mroonga_command(): failed to %s: %s",
action, action,
...@@ -87,10 +96,8 @@ MRN_API my_bool mroonga_command_init(UDF_INIT *initid, UDF_ARGS *args, ...@@ -87,10 +96,8 @@ MRN_API my_bool mroonga_command_init(UDF_INIT *initid, UDF_ARGS *args,
error: error:
if (info) { if (info) {
grn_obj *db; if (!info->use_shared_db) {
db = grn_ctx_db(&(info->ctx)); grn_obj_close(&(info->ctx), info->db);
if (db) {
grn_obj_close(&(info->ctx), db);
} }
grn_ctx_fin(&(info->ctx)); grn_ctx_fin(&(info->ctx));
my_free(info, MYF(0)); my_free(info, MYF(0));
...@@ -152,9 +159,8 @@ MRN_API void mroonga_command_deinit(UDF_INIT *initid) ...@@ -152,9 +159,8 @@ MRN_API void mroonga_command_deinit(UDF_INIT *initid)
{ {
CommandInfo *info = (CommandInfo *)initid->ptr; CommandInfo *info = (CommandInfo *)initid->ptr;
if (info) { if (info) {
grn_obj *db = grn_ctx_db(&(info->ctx)); if (!info->use_shared_db) {
if (db) { grn_obj_close(&(info->ctx), info->db);
grn_obj_close(&(info->ctx), db);
} }
grn_ctx_fin(&(info->ctx)); grn_ctx_fin(&(info->ctx));
info->result.free(); info->result.free();
......
...@@ -69,7 +69,7 @@ static my_bool mrn_snippet_prepare(st_mrn_snip_info *snip_info, UDF_ARGS *args, ...@@ -69,7 +69,7 @@ static my_bool mrn_snippet_prepare(st_mrn_snip_info *snip_info, UDF_ARGS *args,
goto error; goto error;
} }
} }
if (!mrn::encoding::set(ctx, cs)) { if (!mrn::encoding::set_raw(ctx, cs)) {
snprintf(message, MYSQL_ERRMSG_SIZE, snprintf(message, MYSQL_ERRMSG_SIZE,
"Unsupported charset: <%s>", cs->name); "Unsupported charset: <%s>", cs->name);
goto error; goto error;
......
# Copyright(C) 2012-2013 Brazil # Copyright(C) 2012-2014 Brazil
# #
# 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
...@@ -97,32 +97,22 @@ set(GRN_RUBY_SCRIPTS_DIR ...@@ -97,32 +97,22 @@ set(GRN_RUBY_SCRIPTS_DIR
"${CMAKE_INSTALL_PREFIX}/${GRN_RELATIVE_RUBY_SCRIPTS_DIR}") "${CMAKE_INSTALL_PREFIX}/${GRN_RELATIVE_RUBY_SCRIPTS_DIR}")
macro(check_cflag flag) macro(check_cflag flag)
set(checking_message "checking for C flag '${flag}'")
string(REGEX REPLACE "[-=]" "_" temporary_variable_name ${flag}) string(REGEX REPLACE "[-=]" "_" temporary_variable_name ${flag})
string(TOUPPER "${temporary_variable_name}" temporary_variable_name) string(TOUPPER "${temporary_variable_name}" temporary_variable_name)
set(temporary_variable_name "CFLAG${temporary_variable_name}") set(temporary_variable_name "CFLAG${temporary_variable_name}")
# unset(${temporary_variable_name})
check_c_compiler_flag(${flag} ${temporary_variable_name}) check_c_compiler_flag(${flag} ${temporary_variable_name})
if(${temporary_variable_name}) if(${temporary_variable_name})
message(STATUS "${checking_message} - available")
set(GRN_C_COMPILE_FLAGS "${GRN_C_COMPILE_FLAGS} ${flag}") set(GRN_C_COMPILE_FLAGS "${GRN_C_COMPILE_FLAGS} ${flag}")
else()
message(STATUS "${checking_message} - not available")
endif() endif()
endmacro() endmacro()
macro(check_cxxflag flag) macro(check_cxxflag flag)
set(checking_message "checking for CXX flag '${flag}'")
string(REGEX REPLACE "[-=]" "_" temporary_variable_name ${flag}) string(REGEX REPLACE "[-=]" "_" temporary_variable_name ${flag})
string(TOUPPER "${temporary_variable_name}" temporary_variable_name) string(TOUPPER "${temporary_variable_name}" temporary_variable_name)
set(temporary_variable_name "CXXFLAG${temporary_variable_name}") set(temporary_variable_name "CXXFLAG${temporary_variable_name}")
# unset(${temporary_variable_name})
check_cxx_compiler_flag(${flag} ${temporary_variable_name}) check_cxx_compiler_flag(${flag} ${temporary_variable_name})
if(${temporary_variable_name}) if(${temporary_variable_name})
message(STATUS "${checking_message} - available")
set(GRN_CXX_COMPILE_FLAGS "${GRN_CXX_COMPILE_FLAGS} ${flag}") set(GRN_CXX_COMPILE_FLAGS "${GRN_CXX_COMPILE_FLAGS} ${flag}")
else()
message(STATUS "${checking_message} - not available")
endif() endif()
endmacro() endmacro()
...@@ -187,21 +177,18 @@ macro(ac_check_headers header) ...@@ -187,21 +177,18 @@ macro(ac_check_headers header)
string(REGEX REPLACE "[/.]" "_" output_variable_name ${header}) string(REGEX REPLACE "[/.]" "_" output_variable_name ${header})
string(TOUPPER "${output_variable_name}" output_variable_name) string(TOUPPER "${output_variable_name}" output_variable_name)
set(output_variable_name "HAVE_${output_variable_name}") set(output_variable_name "HAVE_${output_variable_name}")
# unset(${output_variable_name})
check_include_file(${header} ${output_variable_name}) check_include_file(${header} ${output_variable_name})
endmacro() endmacro()
macro(ac_check_funcs function) macro(ac_check_funcs function)
string(TOUPPER "${function}" output_variable_name) string(TOUPPER "${function}" output_variable_name)
set(output_variable_name "HAVE_${output_variable_name}") set(output_variable_name "HAVE_${output_variable_name}")
# unset(${output_variable_name})
check_function_exists(${function} ${output_variable_name}) check_function_exists(${function} ${output_variable_name})
endmacro() endmacro()
macro(ac_check_symbols symbol files) macro(ac_check_symbols symbol files)
string(TOUPPER "${symbol}" output_variable_name) string(TOUPPER "${symbol}" output_variable_name)
set(output_variable_name "HAVE_${output_variable_name}") set(output_variable_name "HAVE_${output_variable_name}")
# unset(${output_variable_name})
check_symbol_exists(${symbol} ${files} ${output_variable_name}) check_symbol_exists(${symbol} ${files} ${output_variable_name})
endmacro() endmacro()
...@@ -210,7 +197,6 @@ macro(ac_check_lib library function) ...@@ -210,7 +197,6 @@ macro(ac_check_lib library function)
string(TOUPPER "${output_variable_base_name}" output_variable_base_name) string(TOUPPER "${output_variable_base_name}" output_variable_base_name)
set(output_variable_name "HAVE_LIB${output_variable_base_name}") set(output_variable_name "HAVE_LIB${output_variable_base_name}")
set(location "${ARG2}") set(location "${ARG2}")
# unset(${output_variable_name})
check_library_exists(${library} ${function} "${location}" check_library_exists(${library} ${function} "${location}"
${output_variable_name}) ${output_variable_name})
if(${output_variable_name}) if(${output_variable_name})
...@@ -332,15 +318,15 @@ endif() ...@@ -332,15 +318,15 @@ endif()
set(GRN_WITH_MECAB "auto" set(GRN_WITH_MECAB "auto"
CACHE STRING "use MeCab for morphological analysis") CACHE STRING "use MeCab for morphological analysis")
if(NOT ${GRN_WITH_MECAB} STREQUAL "no") if(NOT ${GRN_WITH_MECAB} STREQUAL "no")
set(MECAB_CONFIG "mecab-config" CACHE FILEPATH "mecab-config path") set(GRN_MECAB_CONFIG "mecab-config" CACHE FILEPATH "mecab-config path")
if(NOT CMAKE_CROSSCOMPILING) if(NOT CMAKE_CROSSCOMPILING)
find_program(MECAB_CONFIG_ABSOLUTE_PATH "${MECAB_CONFIG}") find_program(GRN_MECAB_CONFIG_ABSOLUTE_PATH "${GRN_MECAB_CONFIG}")
endif() endif()
if(EXISTS "${MECAB_CONFIG_ABSOLUTE_PATH}") if(EXISTS "${GRN_MECAB_CONFIG_ABSOLUTE_PATH}")
execute_process(COMMAND "${MECAB_CONFIG_ABSOLUTE_PATH}" --inc-dir execute_process(COMMAND "${GRN_MECAB_CONFIG_ABSOLUTE_PATH}" --inc-dir
OUTPUT_VARIABLE MECAB_INCLUDE_DIRS OUTPUT_VARIABLE MECAB_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${MECAB_CONFIG_ABSOLUTE_PATH}" --libs-only-L execute_process(COMMAND "${GRN_MECAB_CONFIG_ABSOLUTE_PATH}" --libs-only-L
OUTPUT_VARIABLE MECAB_LIBRARY_DIRS OUTPUT_VARIABLE MECAB_LIBRARY_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
set(MECAB_LIBRARIES "mecab") set(MECAB_LIBRARIES "mecab")
...@@ -358,7 +344,7 @@ if(NOT ${GRN_WITH_MECAB} STREQUAL "no") ...@@ -358,7 +344,7 @@ if(NOT ${GRN_WITH_MECAB} STREQUAL "no")
endif() endif()
else() else()
if(${GRN_WITH_MECAB} STREQUAL "yes") if(${GRN_WITH_MECAB} STREQUAL "yes")
message(FATAL_ERROR "No mecab-config found: <${MECAB_CONFIG}>") message(FATAL_ERROR "No mecab-config found: <${GRN_MECAB_CONFIG}>")
endif() endif()
set(GRN_WITH_MECAB FALSE) set(GRN_WITH_MECAB FALSE)
endif() endif()
......
4.0.5 4.0.6
\ No newline at end of file \ No newline at end of file
...@@ -10,7 +10,8 @@ noinst_PROGRAMS = \ ...@@ -10,7 +10,8 @@ noinst_PROGRAMS = \
bench-geo-distance \ bench-geo-distance \
bench-geo-select \ bench-geo-select \
bench-ctx-create \ bench-ctx-create \
bench-query-optimizer bench-query-optimizer \
bench-range-select
endif endif
EXTRA_DIST = \ EXTRA_DIST = \
...@@ -46,12 +47,16 @@ nodist_EXTRA_bench_ctx_create_SOURCES = $(NONEXISTENT_CXX_SOURCE) ...@@ -46,12 +47,16 @@ nodist_EXTRA_bench_ctx_create_SOURCES = $(NONEXISTENT_CXX_SOURCE)
bench_query_optimizer_SOURCES = bench-query-optimizer.c bench_query_optimizer_SOURCES = bench-query-optimizer.c
nodist_EXTRA_bench_query_optimizer_SOURCES = $(NONEXISTENT_CXX_SOURCE) nodist_EXTRA_bench_query_optimizer_SOURCES = $(NONEXISTENT_CXX_SOURCE)
bench_range_select_SOURCES = bench-range-select.c
nodist_EXTRA_bench_range_select_SOURCES = $(NONEXISTENT_CXX_SOURCE)
benchmarks = \ benchmarks = \
run-bench-table-factory \ run-bench-table-factory \
run-bench-geo-distance \ run-bench-geo-distance \
run-bench-geo-select \ run-bench-geo-select \
run-bench-ctx-create \ run-bench-ctx-create \
run-bench-query-optimizer run-bench-query-optimizer \
run-bench-range-select
run-bench-table-factory: bench-table-factory run-bench-table-factory: bench-table-factory
@echo $@: @echo $@:
...@@ -86,4 +91,12 @@ run-bench-query-optimizer: bench-query-optimizer ...@@ -86,4 +91,12 @@ run-bench-query-optimizer: bench-query-optimizer
GRN_RUBY_SCRIPTS_DIR=$(top_srcdir)/lib/mrb/scripts \ GRN_RUBY_SCRIPTS_DIR=$(top_srcdir)/lib/mrb/scripts \
./bench-query-optimizer ./bench-query-optimizer
run-bench-range-select: bench-range-select
@echo $@:
@[ ! -e tmp ] && ln -s /dev/shm tmp || :
@mkdir -p tmp/range-select
env \
GRN_RUBY_SCRIPTS_DIR=$(top_srcdir)/lib/mrb/scripts \
./bench-range-select
benchmark: $(benchmarks) benchmark: $(benchmarks)
/* -*- c-basic-offset: 2; coding: utf-8 -*- */
/*
Copyright (C) 2014 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License version 2.1 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
Groonga: 09a4c4e00832fb90dee74c5b97b7cf0f5952f85b
CPU Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz (fam: 06, model: 1e, stepping: 05)
CFLAGS: -O0 -g3
% make --quiet -C benchmark run-bench-range-select
run-bench-range-select:
Process 10 times in each pattern
(total) (average) (median)
( 500, 600] ( 1000): with mruby: (0.0058s) (0.5773ms) (0.5830ms)
( 500, 600] ( 1000): without mruby: (0.0062s) (0.6203ms) (0.6200ms)
( 5000, 5100] ( 10000): with mruby: (0.0058s) (0.5827ms) (0.5800ms)
( 5000, 5100] ( 10000): without mruby: (0.0473s) (0.0047s) (0.0048s)
( 50000, 50100] ( 100000): with mruby: (0.0064s) (0.6397ms) (0.6370ms)
( 50000, 50100] ( 100000): without mruby: (0.4498s) (0.0450s) (0.0442s)
(500000, 500100] (1000000): with mruby: (0.0057s) (0.5710ms) (0.5190ms)
(500000, 500100] (1000000): without mruby: (4.3193s) (0.4319s) (0.4306s)
CFLAGS: -O2 -g
% make --quiet -C benchmark run-bench-range-select
run-bench-range-select:
Process 10 times in each pattern
(total) (average) (median)
( 500, 600] ( 1000): with mruby: (0.0031s) (0.3058ms) (0.2890ms)
( 500, 600] ( 1000): without mruby: (0.0031s) (0.3132ms) (0.3090ms)
( 5000, 5100] ( 10000): with mruby: (0.0031s) (0.3063ms) (0.3100ms)
( 5000, 5100] ( 10000): without mruby: (0.0239s) (0.0024s) (0.0023s)
( 50000, 50100] ( 100000): with mruby: (0.0028s) (0.2825ms) (0.2660ms)
( 50000, 50100] ( 100000): without mruby: (0.2117s) (0.0212s) (0.0211s)
(500000, 500100] (1000000): with mruby: (0.0028s) (0.2757ms) (0.2650ms)
(500000, 500100] (1000000): without mruby: (2.0874s) (0.2087s) (0.2092s)
*/
#include <stdio.h>
#include <string.h>
#include <db.h>
#include <groonga.h>
#include "lib/benchmark.h"
#define GET(context, name) (grn_ctx_get(context, name, strlen(name)))
typedef struct _BenchmarkData
{
grn_ctx context;
grn_obj *database;
guint n_records;
grn_bool use_mruby;
const gchar *command;
} BenchmarkData;
static void
run_command(grn_ctx *context, const gchar *command)
{
gchar *response;
unsigned int response_length;
int flags;
grn_ctx_send(context, command, strlen(command), 0);
grn_ctx_recv(context, &response, &response_length, &flags);
}
static void
bench(gpointer user_data)
{
BenchmarkData *data = user_data;
grn_ctx *context = &(data->context);
run_command(context, data->command);
}
static gchar *
get_tmp_dir(void)
{
gchar *current_dir;
gchar *tmp_dir;
current_dir = g_get_current_dir();
tmp_dir = g_build_filename(current_dir, "tmp", NULL);
g_free(current_dir);
return tmp_dir;
}
static void
setup_database(BenchmarkData *data)
{
grn_ctx *context = &(data->context);
gchar *tmp_dir;
gchar *database_last_component_name;
gchar *database_path;
guint i;
tmp_dir = get_tmp_dir();
database_last_component_name =
g_strdup_printf("db-%d-%s-mruby",
data->n_records,
data->use_mruby ? "with" : "without");
database_path = g_build_filename(tmp_dir,
"range-select",
database_last_component_name,
NULL);
g_free(database_last_component_name);
if (g_file_test(database_path, G_FILE_TEST_EXISTS)) {
data->database = grn_db_open(context, database_path);
run_command(context, "dump");
} else {
data->database = grn_db_create(context, database_path, NULL);
run_command(context, "table_create Entries TABLE_NO_KEY");
run_command(context, "column_create Entries rank COLUMN_SCALAR Int32");
run_command(context, "table_create Ranks TABLE_PAT_KEY Int32");
run_command(context,
"column_create Ranks entries_rank COLUMN_INDEX Entries rank");
run_command(context, "load --table Entries");
run_command(context, "[");
for (i = 0; i < data->n_records; i++) {
#define BUFFER_SIZE 4096
gchar buffer[BUFFER_SIZE];
const gchar *separator;
if (i == (data->n_records - 1)) {
separator = "";
} else {
separator = ",";
}
snprintf(buffer, BUFFER_SIZE, "{\"rank\": %u}%s", i, separator);
run_command(context, buffer);
#undef BUFFER_SIZE
}
run_command(context, "]");
}
g_free(database_path);
}
static void
bench_startup(BenchmarkData *data)
{
if (data->use_mruby) {
g_setenv("GRN_MRUBY_ENABLED", "yes", TRUE);
} else {
g_setenv("GRN_MRUBY_ENABLED", "no", TRUE);
}
grn_ctx_init(&(data->context), 0);
setup_database(data);
}
static void
bench_shutdown(BenchmarkData *data)
{
grn_ctx *context = &(data->context);
grn_obj_close(context, data->database);
grn_ctx_fin(context);
}
int
main(int argc, gchar **argv)
{
BenchReporter *reporter;
gint n = 10;
grn_init();
g_print("Process %d times in each pattern\n", n);
bench_init(&argc, &argv);
reporter = bench_reporter_new();
{
BenchmarkData data_small_with_mruby;
BenchmarkData data_small_without_mruby;
BenchmarkData data_medium_with_mruby;
BenchmarkData data_medium_without_mruby;
BenchmarkData data_large_with_mruby;
BenchmarkData data_large_without_mruby;
BenchmarkData data_very_large_with_mruby;
BenchmarkData data_very_large_without_mruby;
#define REGISTER(data, n_records_, min, max, use_mruby_) \
do { \
gchar *label; \
label = g_strdup_printf("(%6d, %6d] (%7d): %7s mruby", \
min, max, n_records_, \
use_mruby_ ? "with" : "without"); \
data.use_mruby = use_mruby_; \
data.n_records = n_records_; \
data.command = \
"select Entries --cache no " \
"--filter 'rank > " #min " && rank <= " #max "'"; \
bench_startup(&data); \
bench_reporter_register(reporter, label, \
n, \
NULL, \
bench, \
NULL, \
&data); \
g_free(label); \
} while(FALSE)
REGISTER(data_small_with_mruby,
1000,
500, 600,
GRN_TRUE);
REGISTER(data_small_without_mruby,
1000,
500, 600,
GRN_FALSE);
REGISTER(data_medium_with_mruby,
10000,
5000, 5100,
GRN_TRUE);
REGISTER(data_medium_without_mruby,
10000,
5000, 5100,
GRN_FALSE);
REGISTER(data_large_with_mruby,
100000,
50000, 50100,
GRN_TRUE);
REGISTER(data_large_without_mruby,
100000,
50000, 50100,
GRN_FALSE);
REGISTER(data_very_large_with_mruby,
1000000,
500000, 500100,
GRN_TRUE);
REGISTER(data_very_large_without_mruby,
1000000,
500000, 500100,
GRN_FALSE);
#undef REGISTER
bench_reporter_run(reporter);
bench_shutdown(&data_small_with_mruby);
bench_shutdown(&data_small_without_mruby);
bench_shutdown(&data_medium_with_mruby);
bench_shutdown(&data_medium_without_mruby);
bench_shutdown(&data_large_with_mruby);
bench_shutdown(&data_large_without_mruby);
bench_shutdown(&data_very_large_with_mruby);
bench_shutdown(&data_very_large_without_mruby);
}
g_object_unref(reporter);
grn_fin();
return 0;
}
...@@ -16,7 +16,6 @@ AC_CHECK_HEADERS(sys/resource.h) ...@@ -16,7 +16,6 @@ AC_CHECK_HEADERS(sys/resource.h)
AC_CHECK_HEADERS(sys/socket.h) AC_CHECK_HEADERS(sys/socket.h)
AC_CHECK_HEADERS(sys/sysctl.h) AC_CHECK_HEADERS(sys/sysctl.h)
AC_CHECK_HEADERS(sys/time.h) AC_CHECK_HEADERS(sys/time.h)
AC_CHECK_HEADERS(sys/timeb.h)
AC_CHECK_HEADERS(sys/types.h) AC_CHECK_HEADERS(sys/types.h)
AC_CHECK_HEADERS(sys/wait.h) AC_CHECK_HEADERS(sys/wait.h)
AC_CHECK_HEADERS(time.h) AC_CHECK_HEADERS(time.h)
......
...@@ -116,7 +116,6 @@ ...@@ -116,7 +116,6 @@
#cmakedefine HAVE_SYS_STAT_H #cmakedefine HAVE_SYS_STAT_H
#cmakedefine HAVE_SYS_SYSCALL_H #cmakedefine HAVE_SYS_SYSCALL_H
#cmakedefine HAVE_SYS_SYSCTL_H #cmakedefine HAVE_SYS_SYSCTL_H
#cmakedefine HAVE_SYS_TIMEB_H
#cmakedefine HAVE_SYS_TIME_H #cmakedefine HAVE_SYS_TIME_H
#cmakedefine HAVE_SYS_TYPES_H #cmakedefine HAVE_SYS_TYPES_H
#cmakedefine HAVE_SYS_WAIT_H #cmakedefine HAVE_SYS_WAIT_H
......
...@@ -75,6 +75,7 @@ AC_MSG_RESULT([$solaris]) ...@@ -75,6 +75,7 @@ AC_MSG_RESULT([$solaris])
AC_C_BIGENDIAN AC_C_BIGENDIAN
AC_PROG_CXX AC_PROG_CXX
AC_PROG_CC AC_PROG_CC
AC_PROG_CC_C99
AM_PROG_CC_C_O AM_PROG_CC_C_O
m4_ifdef([PKG_PROG_PKG_CONFIG], m4_ifdef([PKG_PROG_PKG_CONFIG],
[PKG_PROG_PKG_CONFIG([0.19]) [PKG_PROG_PKG_CONFIG([0.19])
...@@ -233,6 +234,7 @@ AC_CONFIG_FILES([ ...@@ -233,6 +234,7 @@ AC_CONFIG_FILES([
plugins/table/Makefile plugins/table/Makefile
plugins/query_expanders/Makefile plugins/query_expanders/Makefile
plugins/ruby/Makefile plugins/ruby/Makefile
plugins/token_filters/Makefile
examples/Makefile examples/Makefile
examples/dictionary/Makefile examples/dictionary/Makefile
examples/dictionary/edict/Makefile examples/dictionary/edict/Makefile
...@@ -1139,7 +1141,12 @@ For Debian GNU/Linux based system like Ubuntu: ...@@ -1139,7 +1141,12 @@ For Debian GNU/Linux based system like Ubuntu:
For Red Hat based system like CentOS: For Red Hat based system like CentOS:
% sudo yum install -y python-pip % sudo yum install -y python-pip
% sudo pip install sphinx]) % sudo pip install sphinx
For OS X with Homebrew:
% brew install pip
% export PATH="`brew --prefix gettext`/bin:\$PATH"
% pip install sphinx])
fi fi
AC_SUBST(SPHINX_BUILD) AC_SUBST(SPHINX_BUILD)
fi fi
...@@ -1237,6 +1244,9 @@ AC_SUBST(table_pluginsdir) ...@@ -1237,6 +1244,9 @@ AC_SUBST(table_pluginsdir)
ruby_pluginsdir="\${pluginsdir}/ruby" ruby_pluginsdir="\${pluginsdir}/ruby"
AC_SUBST(ruby_pluginsdir) AC_SUBST(ruby_pluginsdir)
token_filter_pluginsdir="\${pluginsdir}/token_filters"
AC_SUBST(token_filter_pluginsdir)
AC_MSG_CHECKING(for the suffix of plugin shared libraries) AC_MSG_CHECKING(for the suffix of plugin shared libraries)
shrext_cmds=$(./libtool --config | grep '^shrext_cmds=') shrext_cmds=$(./libtool --config | grep '^shrext_cmds=')
eval $shrext_cmds eval $shrext_cmds
...@@ -1269,6 +1279,8 @@ AC_SUBST(examples_dictionarydir) ...@@ -1269,6 +1279,8 @@ AC_SUBST(examples_dictionarydir)
# for ruby scripts # for ruby scripts
relative_ruby_scriptsdir_base="\$(PACKAGE)/scripts/ruby" relative_ruby_scriptsdir_base="\$(PACKAGE)/scripts/ruby"
AC_SUBST(relative_ruby_scriptsdir_base) AC_SUBST(relative_ruby_scriptsdir_base)
relative_ruby_scriptsdir="lib/\$(relative_ruby_scriptsdir_base)"
AC_SUBST(relative_ruby_scriptsdir)
ruby_scriptsdir="\${libdir}/\$(relative_ruby_scriptsdir_base)" ruby_scriptsdir="\${libdir}/\$(relative_ruby_scriptsdir_base)"
AC_SUBST(ruby_scriptsdir) AC_SUBST(ruby_scriptsdir)
...@@ -1343,7 +1355,8 @@ fi ...@@ -1343,7 +1355,8 @@ fi
AC_MSG_RESULT($enable_mruby) AC_MSG_RESULT($enable_mruby)
if test "$enable_mruby" = "yes"; then if test "$enable_mruby" = "yes"; then
if test "$ac_cv_ruby_available" != "yes"; then if test ! -f "$srcdir/vendor/mruby/mruby-build.timestamp" -a \
"$ac_cv_ruby_available" != "yes"; then
AC_MSG_ERROR(--enable-ruby requires --with-ruby) AC_MSG_ERROR(--enable-ruby requires --with-ruby)
fi fi
AC_DEFINE(GRN_WITH_MRUBY, [1], [Define to 1 if mruby is enabled.]) AC_DEFINE(GRN_WITH_MRUBY, [1], [Define to 1 if mruby is enabled.])
...@@ -1359,6 +1372,14 @@ AC_SUBST(MRUBY_CFLAGS) ...@@ -1359,6 +1372,14 @@ AC_SUBST(MRUBY_CFLAGS)
AC_SUBST(MRUBY_LIBS) AC_SUBST(MRUBY_LIBS)
AM_CONDITIONAL(WITH_MRUBY, test "$enable_mruby" = "yes") AM_CONDITIONAL(WITH_MRUBY, test "$enable_mruby" = "yes")
# This option is used in vendor/onigmo/configure
AC_ARG_ENABLE(shared-onigmo,
[AS_HELP_STRING([--enable-shared-onigmo],
[use Onigmo as shared library instead of static library. [default=no]])],
[enable_shared_onigmo="$enableval"],
[enable_shared_onigmo="no"])
AM_CONDITIONAL(WITH_SHARED_ONIGMO, test "$enable_shared_onigmo" = "yes")
# PCRE # PCRE
GRN_WITH_PCRE=no GRN_WITH_PCRE=no
AC_ARG_WITH(pcre, AC_ARG_WITH(pcre,
...@@ -1427,6 +1448,7 @@ AC_OUTPUT([ ...@@ -1427,6 +1448,7 @@ AC_OUTPUT([
packages/rpm/centos/groonga.spec packages/rpm/centos/groonga.spec
packages/rpm/fedora/groonga.spec packages/rpm/fedora/groonga.spec
packages/apt/debian/groonga-keyring.postrm packages/apt/debian/groonga-keyring.postrm
packages/apt/env.sh
packages/yum/env.sh packages/yum/env.sh
groonga.pc groonga.pc
config.sh config.sh
......
...@@ -7,6 +7,7 @@ Conflicts=groonga.service ...@@ -7,6 +7,7 @@ Conflicts=groonga.service
Type=forking Type=forking
User=root User=root
Group=root Group=root
ExecStartPre=-/usr/bin/mkdir -p /var/log/groonga/httpd
ExecStart=/usr/sbin/groonga-httpd ExecStart=/usr/sbin/groonga-httpd
ExecStop=/usr/sbin/groonga-httpd -s stop ExecStop=/usr/sbin/groonga-httpd -s stop
......
...@@ -6,4 +6,3 @@ QUERY_LOG_PATH=/var/log/groonga/query-gqtp.log ...@@ -6,4 +6,3 @@ QUERY_LOG_PATH=/var/log/groonga/query-gqtp.log
PROTOCOL=gqtp PROTOCOL=gqtp
PORT=10043 PORT=10043
GRN_QUERY_EXPANDER_TSV_SYNONYMS_FILE=/usr/share/groonga/synonyms.tsv GRN_QUERY_EXPANDER_TSV_SYNONYMS_FILE=/usr/share/groonga/synonyms.tsv
#GRN_JA_SKIP_SAME_VALUE_PUT=yes
...@@ -6,4 +6,3 @@ QUERY_LOG_PATH=/var/log/groonga/query-http.log ...@@ -6,4 +6,3 @@ QUERY_LOG_PATH=/var/log/groonga/query-http.log
PROTOCOL=http PROTOCOL=http
PORT=10041 PORT=10041
GRN_QUERY_EXPANDER_TSV_SYNONYMS_FILE=/usr/share/groonga/synonyms.tsv GRN_QUERY_EXPANDER_TSV_SYNONYMS_FILE=/usr/share/groonga/synonyms.tsv
#GRN_JA_SKIP_SAME_VALUE_PUT=yes
...@@ -116,6 +116,7 @@ typedef enum { ...@@ -116,6 +116,7 @@ typedef enum {
GRN_CAS_ERROR = -70, GRN_CAS_ERROR = -70,
GRN_UNSUPPORTED_COMMAND_VERSION = -71, GRN_UNSUPPORTED_COMMAND_VERSION = -71,
GRN_NORMALIZER_ERROR = -72, GRN_NORMALIZER_ERROR = -72,
GRN_TOKEN_FILTER_ERROR = -73,
} grn_rc; } grn_rc;
GRN_API grn_rc grn_init(void); GRN_API grn_rc grn_init(void);
...@@ -478,7 +479,8 @@ typedef enum { ...@@ -478,7 +479,8 @@ typedef enum {
GRN_PROC_COMMAND, GRN_PROC_COMMAND,
GRN_PROC_FUNCTION, GRN_PROC_FUNCTION,
GRN_PROC_HOOK, GRN_PROC_HOOK,
GRN_PROC_NORMALIZER GRN_PROC_NORMALIZER,
GRN_PROC_TOKEN_FILTER
} grn_proc_type; } grn_proc_type;
GRN_API grn_obj *grn_proc_create(grn_ctx *ctx, GRN_API grn_obj *grn_proc_create(grn_ctx *ctx,
...@@ -790,7 +792,8 @@ typedef enum { ...@@ -790,7 +792,8 @@ typedef enum {
GRN_INFO_II_SPLIT_THRESHOLD, GRN_INFO_II_SPLIT_THRESHOLD,
GRN_INFO_SUPPORT_ZLIB, GRN_INFO_SUPPORT_ZLIB,
GRN_INFO_SUPPORT_LZO, GRN_INFO_SUPPORT_LZO,
GRN_INFO_NORMALIZER GRN_INFO_NORMALIZER,
GRN_INFO_TOKEN_FILTERS
} grn_info_type; } grn_info_type;
GRN_API grn_obj *grn_obj_get_info(grn_ctx *ctx, grn_obj *obj, grn_info_type type, grn_obj *valuebuf); GRN_API grn_obj *grn_obj_get_info(grn_ctx *ctx, grn_obj *obj, grn_info_type type, grn_obj *valuebuf);
...@@ -1692,6 +1695,8 @@ GRN_API grn_obj *grn_expr_append_const_int(grn_ctx *ctx, grn_obj *expr, int i, ...@@ -1692,6 +1695,8 @@ GRN_API grn_obj *grn_expr_append_const_int(grn_ctx *ctx, grn_obj *expr, int i,
grn_operator op, int nargs); grn_operator op, int nargs);
GRN_API grn_rc grn_expr_append_op(grn_ctx *ctx, grn_obj *expr, grn_operator op, int nargs); GRN_API grn_rc grn_expr_append_op(grn_ctx *ctx, grn_obj *expr, grn_operator op, int nargs);
GRN_API grn_rc grn_expr_get_keywords(grn_ctx *ctx, grn_obj *expr, grn_obj *keywords);
GRN_API grn_rc grn_expr_syntax_escape(grn_ctx *ctx, GRN_API grn_rc grn_expr_syntax_escape(grn_ctx *ctx,
const char *query, int query_size, const char *query, int query_size,
const char *target_characters, const char *target_characters,
......
...@@ -2,5 +2,6 @@ groonga_includedir = $(pkgincludedir)/groonga ...@@ -2,5 +2,6 @@ groonga_includedir = $(pkgincludedir)/groonga
groonga_include_HEADERS = \ groonga_include_HEADERS = \
plugin.h \ plugin.h \
tokenizer.h \ tokenizer.h \
token_filter.h \
nfkc.h \ nfkc.h \
normalizer.h normalizer.h
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2014 Brazil
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License version 2.1 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef GRN_PLUGIN_TOKEN_FILTER_H
#define GRN_PLUGIN_TOKEN_FILTER_H
#include <stddef.h>
#include <groonga/tokenizer.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef void *grn_token_filter_init_func(grn_ctx *ctx,
grn_obj *table,
grn_token_mode mode);
typedef void grn_token_filter_filter_func(grn_ctx *ctx,
grn_token *current_token,
grn_token *next_token,
void *user_data);
typedef void grn_token_filter_fin_func(grn_ctx *ctx,
void *user_data);
/*
grn_token_filter_register() registers a plugin to the database which is
associated with `ctx'. `plugin_name_ptr' and `plugin_name_length' specify the
plugin name. Alphabetic letters ('A'-'Z' and 'a'-'z'), digits ('0'-'9') and
an underscore ('_') are capable characters.
`init', `filter' and `fin' specify the plugin functions.
`init' is called for initializing a token_filter for a document or
query.
`filter' is called for filtering tokens one by one.
`fin' is called for finalizing a token_filter.
grn_token_filter_register() returns GRN_SUCCESS on success, an error
code on failure.
*/
GRN_PLUGIN_EXPORT grn_rc grn_token_filter_register(grn_ctx *ctx,
const char *plugin_name_ptr,
int plugin_name_length,
grn_token_filter_init_func *init,
grn_token_filter_filter_func *filter,
grn_token_filter_fin_func *fin);
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif /* GRN_PLUGIN_TOKEN_FILTER_H */
...@@ -29,6 +29,23 @@ extern "C" { ...@@ -29,6 +29,23 @@ extern "C" {
#define GRN_TOKENIZER_TOKENIZED_DELIMITER_UTF8 "\xEF\xBF\xBE" #define GRN_TOKENIZER_TOKENIZED_DELIMITER_UTF8 "\xEF\xBF\xBE"
#define GRN_TOKENIZER_TOKENIZED_DELIMITER_UTF8_LEN 3 #define GRN_TOKENIZER_TOKENIZED_DELIMITER_UTF8_LEN 3
/*
grn_token_mode describes propose for tokenization.
`GRN_TOKEN_GET`: Tokenization for search.
`GRN_TOKEN_ADD`: Tokenization for adding token to index.
`GRN_TOKEN_DEL`: Tokenization for deleting token from index.
@since 4.0.7
*/
typedef enum {
GRN_TOKEN_GET = 0,
GRN_TOKEN_ADD,
GRN_TOKEN_DEL
} grn_token_mode;
/* /*
grn_tokenizer_charlen() returns the length (#bytes) of the first character grn_tokenizer_charlen() returns the length (#bytes) of the first character
in the string specified by `str_ptr' and `str_length'. If the starting bytes in the string specified by `str_ptr' and `str_length'. If the starting bytes
...@@ -84,7 +101,7 @@ struct _grn_tokenizer_query { ...@@ -84,7 +101,7 @@ struct _grn_tokenizer_query {
grn_encoding encoding; grn_encoding encoding;
unsigned int flags; unsigned int flags;
grn_bool have_tokenized_delimiter; grn_bool have_tokenized_delimiter;
unsigned int token_mode; grn_token_mode token_mode;
}; };
/* /*
...@@ -176,6 +193,21 @@ typedef unsigned int grn_tokenizer_status; ...@@ -176,6 +193,21 @@ typedef unsigned int grn_tokenizer_status;
#define GRN_TOKENIZER_CONTINUE GRN_TOKENIZER_TOKEN_CONTINUE #define GRN_TOKENIZER_CONTINUE GRN_TOKENIZER_TOKEN_CONTINUE
#define GRN_TOKENIZER_LAST GRN_TOKENIZER_TOKEN_LAST #define GRN_TOKENIZER_LAST GRN_TOKENIZER_TOKEN_LAST
typedef struct _grn_token grn_token;
GRN_PLUGIN_EXPORT grn_obj *grn_token_get_data(grn_ctx *ctx,
grn_token *token);
GRN_PLUGIN_EXPORT grn_rc grn_token_set_data(grn_ctx *ctx,
grn_token *token,
const char *str_ptr,
int str_length);
GRN_PLUGIN_EXPORT grn_tokenizer_status grn_token_get_status(grn_ctx *ctx,
grn_token *token);
GRN_PLUGIN_EXPORT grn_rc grn_token_set_status(grn_ctx *ctx,
grn_token *token,
grn_tokenizer_status status);
/* /*
grn_tokenizer_token_push() pushes the next token into `token'. Note that grn_tokenizer_token_push() pushes the next token into `token'. Note that
grn_tokenizer_token_push() does not make a copy of the given string. This grn_tokenizer_token_push() does not make a copy of the given string. This
......
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