mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Update Mroonga to the latest version on 2014-10-21T04:51:38+0900
This commit is contained in:
@@ -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 "")
|
|||||||
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
|
|||||||
"${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)
|
|||||||
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:
|
|||||||
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([
|
|||||||
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
|
||||||
|
@@ -49,7 +49,6 @@
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
# include <math.h>
|
# include <math.h>
|
||||||
# include <direct.h>
|
# include <direct.h>
|
||||||
# define MRN_MKDIR(pathname, mode) _mkdir((pathname))
|
|
||||||
# define MRN_ALLOCATE_VARIABLE_LENGTH_ARRAYS(type, variable_name, variable_size) \
|
# define MRN_ALLOCATE_VARIABLE_LENGTH_ARRAYS(type, variable_name, variable_size) \
|
||||||
type *variable_name = (type *)_malloca(sizeof(type) * (variable_size))
|
type *variable_name = (type *)_malloca(sizeof(type) * (variable_size))
|
||||||
# define MRN_FREE_VARIABLE_LENGTH_ARRAYS(variable_name) _freea(variable_name)
|
# define MRN_FREE_VARIABLE_LENGTH_ARRAYS(variable_name) _freea(variable_name)
|
||||||
@@ -65,7 +64,6 @@
|
|||||||
#else
|
#else
|
||||||
# include <dirent.h>
|
# include <dirent.h>
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# define MRN_MKDIR(pathname, mode) mkdir((pathname), (mode))
|
|
||||||
# define MRN_ALLOCATE_VARIABLE_LENGTH_ARRAYS(type, variable_name, variable_size) \
|
# define MRN_ALLOCATE_VARIABLE_LENGTH_ARRAYS(type, variable_name, variable_size) \
|
||||||
type variable_name[variable_size]
|
type variable_name[variable_size]
|
||||||
# define MRN_FREE_VARIABLE_LENGTH_ARRAYS(variable_name)
|
# define MRN_FREE_VARIABLE_LENGTH_ARRAYS(variable_name)
|
||||||
@@ -89,6 +87,8 @@
|
|||||||
#include <mrn_condition_converter.hpp>
|
#include <mrn_condition_converter.hpp>
|
||||||
#include <mrn_time_converter.hpp>
|
#include <mrn_time_converter.hpp>
|
||||||
#include <mrn_smart_grn_obj.hpp>
|
#include <mrn_smart_grn_obj.hpp>
|
||||||
|
#include <mrn_database_manager.hpp>
|
||||||
|
#include <mrn_grn.hpp>
|
||||||
|
|
||||||
#ifdef MRN_SUPPORT_FOREIGN_KEYS
|
#ifdef MRN_SUPPORT_FOREIGN_KEYS
|
||||||
# include <sql_table.h>
|
# include <sql_table.h>
|
||||||
@@ -103,17 +103,17 @@
|
|||||||
|
|
||||||
#ifdef MRN_HAVE_TDC_LOCK_TABLE_SHARE
|
#ifdef MRN_HAVE_TDC_LOCK_TABLE_SHARE
|
||||||
# define mrn_open_mutex(share) &((share)->tdc.LOCK_table_share)
|
# define mrn_open_mutex(share) &((share)->tdc.LOCK_table_share)
|
||||||
# define mrn_open_mutex_lock(share) do { \
|
# define mrn_open_mutex_lock(share) do { \
|
||||||
TABLE_SHARE *share_ = share; \
|
TABLE_SHARE *share_ = share; \
|
||||||
if (share_) { \
|
if (share_ && share_->tmp_table == NO_TMP_TABLE) { \
|
||||||
mysql_mutex_lock(mrn_open_mutex(share_)); \
|
mysql_mutex_lock(mrn_open_mutex(share_)); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
# define mrn_open_mutex_unlock(share) do { \
|
# define mrn_open_mutex_unlock(share) do { \
|
||||||
TABLE_SHARE *share_ = share; \
|
TABLE_SHARE *share_ = share; \
|
||||||
if (share_) { \
|
if (share_ && share_->tmp_table == NO_TMP_TABLE) { \
|
||||||
mysql_mutex_unlock(mrn_open_mutex(share_)); \
|
mysql_mutex_unlock(mrn_open_mutex(share_)); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#else
|
#else
|
||||||
# if MYSQL_VERSION_ID >= 50500
|
# if MYSQL_VERSION_ID >= 50500
|
||||||
@@ -156,7 +156,7 @@ static pthread_mutex_t *mrn_LOCK_open;
|
|||||||
# define st_mysql_plugin st_maria_plugin
|
# define st_mysql_plugin st_maria_plugin
|
||||||
# define mrn_declare_plugin(NAME) maria_declare_plugin(NAME)
|
# define mrn_declare_plugin(NAME) maria_declare_plugin(NAME)
|
||||||
# define mrn_declare_plugin_end maria_declare_plugin_end
|
# define mrn_declare_plugin_end maria_declare_plugin_end
|
||||||
# define MRN_PLUGIN_LAST_VALUES MRN_VERSION, MariaDB_PLUGIN_MATURITY_BETA
|
# define MRN_PLUGIN_LAST_VALUES MRN_VERSION, MariaDB_PLUGIN_MATURITY_STABLE
|
||||||
# define MRN_ABORT_ON_WARNING(thd) thd_kill_level(thd)
|
# define MRN_ABORT_ON_WARNING(thd) thd_kill_level(thd)
|
||||||
#else
|
#else
|
||||||
# define mrn_declare_plugin(NAME) mysql_declare_plugin(NAME)
|
# define mrn_declare_plugin(NAME) mysql_declare_plugin(NAME)
|
||||||
@@ -204,12 +204,10 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* groonga's internal functions */
|
/* groonga's internal functions */
|
||||||
const char *grn_obj_get_value_(grn_ctx *ctx, grn_obj *obj, grn_id id, uint32 *size);
|
|
||||||
int grn_atoi(const char *nptr, const char *end, const char **rest);
|
int grn_atoi(const char *nptr, const char *end, const char **rest);
|
||||||
uint grn_atoui(const char *nptr, const char *end, const char **rest);
|
uint grn_atoui(const char *nptr, const char *end, const char **rest);
|
||||||
|
|
||||||
/* global variables */
|
/* global variables */
|
||||||
static pthread_mutex_t mrn_db_mutex;
|
|
||||||
static pthread_mutex_t mrn_log_mutex;
|
static pthread_mutex_t mrn_log_mutex;
|
||||||
handlerton *mrn_hton_ptr;
|
handlerton *mrn_hton_ptr;
|
||||||
HASH mrn_open_tables;
|
HASH mrn_open_tables;
|
||||||
@@ -220,7 +218,8 @@ pthread_mutex_t mrn_long_term_share_mutex;
|
|||||||
/* internal variables */
|
/* internal variables */
|
||||||
static grn_ctx mrn_ctx;
|
static grn_ctx mrn_ctx;
|
||||||
static grn_obj *mrn_db;
|
static grn_obj *mrn_db;
|
||||||
static grn_hash *mrn_hash;
|
static grn_ctx mrn_db_manager_ctx;
|
||||||
|
mrn::DatabaseManager *mrn_db_manager = NULL;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
static inline double round(double x)
|
static inline double round(double x)
|
||||||
@@ -236,20 +235,7 @@ static void mrn_init_encoding_map()
|
|||||||
|
|
||||||
static int mrn_change_encoding(grn_ctx *ctx, const CHARSET_INFO *charset)
|
static int mrn_change_encoding(grn_ctx *ctx, const CHARSET_INFO *charset)
|
||||||
{
|
{
|
||||||
int error = 0;
|
return mrn::encoding::set(ctx, charset);
|
||||||
if (!mrn::encoding::set(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);
|
|
||||||
}
|
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(DBUG_OFF) && !defined(_lint)
|
#if !defined(DBUG_OFF) && !defined(_lint)
|
||||||
@@ -1001,32 +987,10 @@ static handler *mrn_handler_create(handlerton *hton, TABLE_SHARE *share, MEM_ROO
|
|||||||
DBUG_RETURN(new_handler);
|
DBUG_RETURN(new_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mrn_drop_db(const char *path)
|
|
||||||
{
|
|
||||||
MRN_DBUG_ENTER_FUNCTION();
|
|
||||||
mrn::PathMapper mapper(path);
|
|
||||||
mrn::Lock lock(&mrn_db_mutex);
|
|
||||||
grn_obj *db = NULL;
|
|
||||||
if (!mrn_hash_get(&mrn_ctx, mrn_hash, mapper.db_name(), &db)) {
|
|
||||||
struct stat dummy;
|
|
||||||
if (stat(mapper.db_path(), &dummy) == 0) {
|
|
||||||
db = grn_db_open(&mrn_ctx, mapper.db_path());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (db) {
|
|
||||||
if (grn_obj_remove(&mrn_ctx, db)) {
|
|
||||||
GRN_LOG(&mrn_ctx, GRN_LOG_ERROR,
|
|
||||||
"cannot drop database (%s)", mapper.db_path());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mrn_hash_remove(&mrn_ctx, mrn_hash, mapper.db_name());
|
|
||||||
DBUG_VOID_RETURN;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mrn_drop_database(handlerton *hton, char *path)
|
static void mrn_drop_database(handlerton *hton, char *path)
|
||||||
{
|
{
|
||||||
MRN_DBUG_ENTER_FUNCTION();
|
MRN_DBUG_ENTER_FUNCTION();
|
||||||
mrn_drop_db(path);
|
mrn_db_manager->drop(path);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1270,7 +1234,8 @@ static int mrn_set_geometry(grn_ctx *ctx, grn_obj *buf,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint mrn_alter_table_flags(uint flags) {
|
static uint mrn_alter_table_flags(uint flags)
|
||||||
|
{
|
||||||
uint alter_flags = 0;
|
uint alter_flags = 0;
|
||||||
#ifdef HA_INPLACE_ADD_INDEX_NO_READ_WRITE
|
#ifdef HA_INPLACE_ADD_INDEX_NO_READ_WRITE
|
||||||
bool is_inplace_index_change;
|
bool is_inplace_index_change;
|
||||||
@@ -1391,17 +1356,11 @@ static int mrn_init(void *p)
|
|||||||
}
|
}
|
||||||
grn_ctx_use(ctx, mrn_db);
|
grn_ctx_use(ctx, mrn_db);
|
||||||
|
|
||||||
// init hash
|
grn_ctx_init(&mrn_db_manager_ctx, 0);
|
||||||
if (!(mrn_hash = grn_hash_create(ctx, NULL,
|
grn_logger_set(&mrn_db_manager_ctx, &mrn_logger);
|
||||||
MRN_MAX_KEY_SIZE, sizeof(grn_obj *),
|
mrn_db_manager = new mrn::DatabaseManager(&mrn_db_manager_ctx);
|
||||||
GRN_OBJ_KEY_VAR_SIZE))) {
|
if (!mrn_db_manager->init()) {
|
||||||
GRN_LOG(ctx, GRN_LOG_ERROR, "cannot init hash, exiting");
|
goto err_db_manager_init;
|
||||||
goto err_hash_create;
|
|
||||||
}
|
|
||||||
|
|
||||||
// init lock
|
|
||||||
if ((pthread_mutex_init(&mrn_db_mutex, NULL) != 0)) {
|
|
||||||
goto err_db_mutex_init;
|
|
||||||
}
|
}
|
||||||
if ((pthread_mutex_init(&mrn_allocated_thds_mutex, NULL) != 0)) {
|
if ((pthread_mutex_init(&mrn_allocated_thds_mutex, NULL) != 0)) {
|
||||||
goto err_allocated_thds_mutex_init;
|
goto err_allocated_thds_mutex_init;
|
||||||
@@ -1442,10 +1401,9 @@ err_allocated_open_tables_mutex_init:
|
|||||||
error_allocated_thds_hash_init:
|
error_allocated_thds_hash_init:
|
||||||
pthread_mutex_destroy(&mrn_allocated_thds_mutex);
|
pthread_mutex_destroy(&mrn_allocated_thds_mutex);
|
||||||
err_allocated_thds_mutex_init:
|
err_allocated_thds_mutex_init:
|
||||||
pthread_mutex_destroy(&mrn_db_mutex);
|
err_db_manager_init:
|
||||||
err_db_mutex_init:
|
delete mrn_db_manager;
|
||||||
grn_hash_close(ctx, mrn_hash);
|
grn_ctx_fin(&mrn_db_manager_ctx);
|
||||||
err_hash_create:
|
|
||||||
grn_obj_unlink(ctx, mrn_db);
|
grn_obj_unlink(ctx, mrn_db);
|
||||||
err_db_create:
|
err_db_create:
|
||||||
if (mrn_log_file_opened) {
|
if (mrn_log_file_opened) {
|
||||||
@@ -1466,7 +1424,6 @@ static int mrn_deinit(void *p)
|
|||||||
{
|
{
|
||||||
THD *thd = current_thd, *tmp_thd;
|
THD *thd = current_thd, *tmp_thd;
|
||||||
grn_ctx *ctx = &mrn_ctx;
|
grn_ctx *ctx = &mrn_ctx;
|
||||||
void *value;
|
|
||||||
MRN_LONG_TERM_SHARE *long_term_share;
|
MRN_LONG_TERM_SHARE *long_term_share;
|
||||||
|
|
||||||
GRN_LOG(ctx, GRN_LOG_NOTICE, "%s deinit", MRN_PACKAGE_STRING);
|
GRN_LOG(ctx, GRN_LOG_NOTICE, "%s deinit", MRN_PACKAGE_STRING);
|
||||||
@@ -1498,15 +1455,10 @@ static int mrn_deinit(void *p)
|
|||||||
pthread_mutex_destroy(&mrn_open_tables_mutex);
|
pthread_mutex_destroy(&mrn_open_tables_mutex);
|
||||||
my_hash_free(&mrn_allocated_thds);
|
my_hash_free(&mrn_allocated_thds);
|
||||||
pthread_mutex_destroy(&mrn_allocated_thds_mutex);
|
pthread_mutex_destroy(&mrn_allocated_thds_mutex);
|
||||||
pthread_mutex_destroy(&mrn_db_mutex);
|
delete mrn_db_manager;
|
||||||
GRN_HASH_EACH(ctx, mrn_hash, id, NULL, 0, &value, {
|
grn_ctx_fin(&mrn_db_manager_ctx);
|
||||||
grn_obj *db;
|
|
||||||
memcpy(&db, value, sizeof(grn_obj *));
|
|
||||||
grn_obj_unlink(ctx, db);
|
|
||||||
});
|
|
||||||
grn_hash_close(ctx, mrn_hash);
|
|
||||||
grn_obj_unlink(ctx, mrn_db);
|
|
||||||
|
|
||||||
|
grn_obj_unlink(ctx, mrn_db);
|
||||||
grn_ctx_fin(ctx);
|
grn_ctx_fin(ctx);
|
||||||
grn_fin();
|
grn_fin();
|
||||||
|
|
||||||
@@ -2284,7 +2236,6 @@ ulonglong ha_mroonga::storage_table_flags() const
|
|||||||
HA_CAN_INDEX_BLOBS |
|
HA_CAN_INDEX_BLOBS |
|
||||||
HA_STATS_RECORDS_IS_EXACT |
|
HA_STATS_RECORDS_IS_EXACT |
|
||||||
HA_CAN_FULLTEXT |
|
HA_CAN_FULLTEXT |
|
||||||
HA_CAN_INSERT_DELAYED |
|
|
||||||
HA_BINLOG_FLAGS |
|
HA_BINLOG_FLAGS |
|
||||||
HA_CAN_BIT_FIELD |
|
HA_CAN_BIT_FIELD |
|
||||||
HA_DUPLICATE_POS |
|
HA_DUPLICATE_POS |
|
||||||
@@ -2628,6 +2579,16 @@ int ha_mroonga::wrapper_create_index_fulltext(const char *grn_table_name,
|
|||||||
grn_obj_unlink(ctx, tokenizer);
|
grn_obj_unlink(ctx, tokenizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
grn_obj token_filters;
|
||||||
|
GRN_PTR_INIT(&token_filters, GRN_OBJ_VECTOR, 0);
|
||||||
|
if (find_token_filters(key_info, &token_filters)) {
|
||||||
|
grn_obj_set_info(ctx, index_table,
|
||||||
|
GRN_INFO_TOKEN_FILTERS, &token_filters);
|
||||||
|
}
|
||||||
|
grn_obj_unlink(ctx, &token_filters);
|
||||||
|
}
|
||||||
|
|
||||||
if (should_normalize(&key_info->key_part->field[0])) {
|
if (should_normalize(&key_info->key_part->field[0])) {
|
||||||
grn_info_type info_type = GRN_INFO_NORMALIZER;
|
grn_info_type info_type = GRN_INFO_NORMALIZER;
|
||||||
grn_obj *normalizer = find_normalizer(key_info);
|
grn_obj *normalizer = find_normalizer(key_info);
|
||||||
@@ -2724,7 +2685,7 @@ int ha_mroonga::wrapper_create_index(const char *name, TABLE *table,
|
|||||||
MRN_DBUG_ENTER_METHOD();
|
MRN_DBUG_ENTER_METHOD();
|
||||||
|
|
||||||
int error = 0;
|
int error = 0;
|
||||||
error = ensure_database_create(name);
|
error = ensure_database_open(name);
|
||||||
if (error)
|
if (error)
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
|
|
||||||
@@ -2807,7 +2768,7 @@ int ha_mroonga::storage_create(const char *name, TABLE *table,
|
|||||||
if (error)
|
if (error)
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
|
|
||||||
error = ensure_database_create(name);
|
error = ensure_database_open(name);
|
||||||
if (error)
|
if (error)
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
|
|
||||||
@@ -2875,15 +2836,22 @@ int ha_mroonga::storage_create(const char *name, TABLE *table,
|
|||||||
KEY key_info = table->s->key_info[pkey_nr];
|
KEY key_info = table->s->key_info[pkey_nr];
|
||||||
int key_parts = KEY_N_KEY_PARTS(&key_info);
|
int key_parts = KEY_N_KEY_PARTS(&key_info);
|
||||||
if (key_parts == 1) {
|
if (key_parts == 1) {
|
||||||
Field *field = &(key_info.key_part->field[0]);
|
grn_obj *normalizer = NULL;
|
||||||
if (should_normalize(field)) {
|
if (tmp_share->normalizer) {
|
||||||
grn_obj *normalizer = find_normalizer(&key_info);
|
normalizer = grn_ctx_get(ctx,
|
||||||
if (normalizer) {
|
tmp_share->normalizer,
|
||||||
grn_info_type info_type = GRN_INFO_NORMALIZER;
|
tmp_share->normalizer_length);
|
||||||
grn_obj_set_info(ctx, table_obj, info_type, normalizer);
|
} else {
|
||||||
grn_obj_unlink(ctx, normalizer);
|
Field *field = &(key_info.key_part->field[0]);
|
||||||
|
if (should_normalize(field)) {
|
||||||
|
normalizer = find_normalizer(&key_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (normalizer) {
|
||||||
|
grn_info_type info_type = GRN_INFO_NORMALIZER;
|
||||||
|
grn_obj_set_info(ctx, table_obj, info_type, normalizer);
|
||||||
|
grn_obj_unlink(ctx, normalizer);
|
||||||
|
}
|
||||||
if (tmp_share->default_tokenizer) {
|
if (tmp_share->default_tokenizer) {
|
||||||
grn_obj *default_tokenizer =
|
grn_obj *default_tokenizer =
|
||||||
grn_ctx_get(ctx,
|
grn_ctx_get(ctx,
|
||||||
@@ -2895,6 +2863,17 @@ int ha_mroonga::storage_create(const char *name, TABLE *table,
|
|||||||
grn_obj_unlink(ctx, default_tokenizer);
|
grn_obj_unlink(ctx, default_tokenizer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (tmp_share->token_filters) {
|
||||||
|
grn_obj token_filters;
|
||||||
|
GRN_PTR_INIT(&token_filters, GRN_OBJ_VECTOR, 0);
|
||||||
|
if (find_token_filters_fill(&token_filters,
|
||||||
|
tmp_share->token_filters,
|
||||||
|
tmp_share->token_filters_length)) {
|
||||||
|
grn_obj_set_info(ctx, table_obj,
|
||||||
|
GRN_INFO_TOKEN_FILTERS, &token_filters);
|
||||||
|
}
|
||||||
|
grn_obj_unlink(ctx, &token_filters);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3303,6 +3282,16 @@ int ha_mroonga::storage_create_index_table(TABLE *table,
|
|||||||
grn_obj_set_info(ctx, index_table, info_type, tokenizer);
|
grn_obj_set_info(ctx, index_table, info_type, tokenizer);
|
||||||
grn_obj_unlink(ctx, tokenizer);
|
grn_obj_unlink(ctx, tokenizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
grn_obj token_filters;
|
||||||
|
GRN_PTR_INIT(&token_filters, GRN_OBJ_VECTOR, 0);
|
||||||
|
if (find_token_filters(key_info, &token_filters)) {
|
||||||
|
grn_obj_set_info(ctx, index_table,
|
||||||
|
GRN_INFO_TOKEN_FILTERS, &token_filters);
|
||||||
|
}
|
||||||
|
grn_obj_unlink(ctx, &token_filters);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -3471,175 +3460,18 @@ int ha_mroonga::storage_create_indexes(TABLE *table, const char *grn_table_name,
|
|||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ha_mroonga::close_databases()
|
|
||||||
{
|
|
||||||
MRN_DBUG_ENTER_METHOD();
|
|
||||||
|
|
||||||
int error = 0;
|
|
||||||
mrn::Lock lock(&mrn_db_mutex);
|
|
||||||
|
|
||||||
grn_hash_cursor *hash_cursor;
|
|
||||||
hash_cursor = grn_hash_cursor_open(&mrn_ctx, mrn_hash,
|
|
||||||
NULL, 0, NULL, 0,
|
|
||||||
0, -1, 0);
|
|
||||||
if (mrn_ctx.rc) {
|
|
||||||
my_message(ER_ERROR_ON_READ, mrn_ctx.errbuf, MYF(0));
|
|
||||||
DBUG_RETURN(ER_ERROR_ON_READ);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (grn_hash_cursor_next(&mrn_ctx, hash_cursor) != GRN_ID_NIL) {
|
|
||||||
if (mrn_ctx.rc) {
|
|
||||||
error = ER_ERROR_ON_READ;
|
|
||||||
my_message(error, mrn_ctx.errbuf, MYF(0));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
void *value;
|
|
||||||
grn_obj *db;
|
|
||||||
grn_hash_cursor_get_value(&mrn_ctx, hash_cursor, &value);
|
|
||||||
memcpy(&db, value, sizeof(grn_obj *));
|
|
||||||
grn_rc rc = grn_hash_cursor_delete(&mrn_ctx, hash_cursor, NULL);
|
|
||||||
if (rc)
|
|
||||||
{
|
|
||||||
error = ER_ERROR_ON_READ;
|
|
||||||
my_message(error, mrn_ctx.errbuf, MYF(0));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
grn_obj_close(&mrn_ctx, db);
|
|
||||||
}
|
|
||||||
grn_hash_cursor_close(&mrn_ctx, hash_cursor);
|
|
||||||
|
|
||||||
DBUG_RETURN(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ha_mroonga::ensure_database_directory()
|
|
||||||
{
|
|
||||||
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 ha_mroonga::ensure_normalizers_register()
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ha_mroonga::ensure_database_create(const char *name)
|
|
||||||
{
|
|
||||||
int error;
|
|
||||||
|
|
||||||
MRN_DBUG_ENTER_METHOD();
|
|
||||||
/* before creating table, we must check if database is alreadly opened, created */
|
|
||||||
grn_obj *db;
|
|
||||||
struct stat db_stat;
|
|
||||||
|
|
||||||
error = mrn_change_encoding(ctx, system_charset_info);
|
|
||||||
if (error)
|
|
||||||
DBUG_RETURN(error);
|
|
||||||
|
|
||||||
mrn::PathMapper mapper(name);
|
|
||||||
{
|
|
||||||
mrn::Lock lock(&mrn_db_mutex);
|
|
||||||
if (!mrn_hash_get(&mrn_ctx, mrn_hash, mapper.db_name(), &db)) {
|
|
||||||
if (stat(mapper.db_path(), &db_stat)) {
|
|
||||||
// creating new database
|
|
||||||
GRN_LOG(ctx, GRN_LOG_INFO,
|
|
||||||
"database not found. creating...(%s)", mapper.db_path());
|
|
||||||
if (name[0] == FN_CURLIB &&
|
|
||||||
(name[1] == FN_LIBCHAR || name[1] == FN_LIBCHAR2)) {
|
|
||||||
ensure_database_directory();
|
|
||||||
}
|
|
||||||
db = grn_db_create(&mrn_ctx, mapper.db_path(), NULL);
|
|
||||||
if (mrn_ctx.rc) {
|
|
||||||
error = ER_CANT_CREATE_TABLE;
|
|
||||||
my_message(error, mrn_ctx.errbuf, MYF(0));
|
|
||||||
DBUG_RETURN(error);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// opening existing database
|
|
||||||
db = grn_db_open(&mrn_ctx, mapper.db_path());
|
|
||||||
if (mrn_ctx.rc) {
|
|
||||||
error = ER_CANT_OPEN_FILE;
|
|
||||||
my_message(error, mrn_ctx.errbuf, MYF(0));
|
|
||||||
DBUG_RETURN(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mrn_hash_put(&mrn_ctx, mrn_hash, mapper.db_name(), db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
grn_ctx_use(ctx, db);
|
|
||||||
error = ensure_normalizers_register();
|
|
||||||
|
|
||||||
DBUG_RETURN(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ha_mroonga::ensure_database_open(const char *name)
|
int ha_mroonga::ensure_database_open(const char *name)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
MRN_DBUG_ENTER_METHOD();
|
MRN_DBUG_ENTER_METHOD();
|
||||||
grn_obj *db;
|
|
||||||
|
|
||||||
error = mrn_change_encoding(ctx, system_charset_info);
|
grn_obj *db;
|
||||||
|
error = mrn_db_manager->open(name, &db);
|
||||||
if (error)
|
if (error)
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
|
|
||||||
mrn::PathMapper mapper(name);
|
|
||||||
{
|
|
||||||
mrn::Lock lock(&mrn_db_mutex);
|
|
||||||
if (!mrn_hash_get(&mrn_ctx, mrn_hash, mapper.db_name(), &db)) {
|
|
||||||
db = grn_db_open(&mrn_ctx, mapper.db_path());
|
|
||||||
if (mrn_ctx.rc) {
|
|
||||||
error = ER_CANT_OPEN_FILE;
|
|
||||||
my_message(error, mrn_ctx.errbuf, MYF(0));
|
|
||||||
DBUG_RETURN(error);
|
|
||||||
}
|
|
||||||
mrn_hash_put(&mrn_ctx, mrn_hash, mapper.db_name(), db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
grn_ctx_use(ctx, db);
|
grn_ctx_use(ctx, db);
|
||||||
error = ensure_normalizers_register();
|
|
||||||
|
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
@@ -3654,15 +3486,9 @@ int ha_mroonga::ensure_database_remove(const char *name)
|
|||||||
if (error)
|
if (error)
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
|
|
||||||
|
mrn_db_manager->close(name);
|
||||||
|
|
||||||
mrn::PathMapper mapper(name);
|
mrn::PathMapper mapper(name);
|
||||||
{
|
|
||||||
mrn::Lock lock(&mrn_db_mutex);
|
|
||||||
grn_obj *db;
|
|
||||||
if (mrn_hash_get(&mrn_ctx, mrn_hash, mapper.db_name(), &db)) {
|
|
||||||
mrn_hash_remove(&mrn_ctx, mrn_hash, mapper.db_name());
|
|
||||||
grn_obj_close(&mrn_ctx, db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
remove_related_files(mapper.db_path());
|
remove_related_files(mapper.db_path());
|
||||||
|
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
@@ -3708,7 +3534,7 @@ int ha_mroonga::wrapper_open(const char *name, int mode, uint test_if_locked)
|
|||||||
error = ensure_database_remove(name);
|
error = ensure_database_remove(name);
|
||||||
if (error)
|
if (error)
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
error = ensure_database_create(name);
|
error = ensure_database_open(name);
|
||||||
if (error)
|
if (error)
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
grn_table = NULL;
|
grn_table = NULL;
|
||||||
@@ -4354,7 +4180,7 @@ int ha_mroonga::close()
|
|||||||
mrn::Lock lock(&mrn_open_tables_mutex);
|
mrn::Lock lock(&mrn_open_tables_mutex);
|
||||||
if (!mrn_open_tables.records)
|
if (!mrn_open_tables.records)
|
||||||
{
|
{
|
||||||
int tmp_error = close_databases();
|
int tmp_error = mrn_db_manager->clear();
|
||||||
if (tmp_error)
|
if (tmp_error)
|
||||||
error = tmp_error;
|
error = tmp_error;
|
||||||
}
|
}
|
||||||
@@ -4543,7 +4369,7 @@ int ha_mroonga::delete_table(const char *name)
|
|||||||
mrn_free_tmp_table_share(tmp_table_share);
|
mrn_free_tmp_table_share(tmp_table_share);
|
||||||
mrn_open_mutex_unlock(NULL);
|
mrn_open_mutex_unlock(NULL);
|
||||||
if (is_temporary_table_name(name)) {
|
if (is_temporary_table_name(name)) {
|
||||||
mrn_drop_db(name);
|
mrn_db_manager->drop(name);
|
||||||
}
|
}
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
@@ -6374,7 +6200,10 @@ int ha_mroonga::storage_prepare_delete_row_unique_index(const uchar *buf,
|
|||||||
uint32 ukey_size = 0;
|
uint32 ukey_size = 0;
|
||||||
MRN_DBUG_ENTER_METHOD();
|
MRN_DBUG_ENTER_METHOD();
|
||||||
if (KEY_N_KEY_PARTS(key_info) == 1) {
|
if (KEY_N_KEY_PARTS(key_info) == 1) {
|
||||||
ukey = grn_obj_get_value_(ctx, index_column, record_id, &ukey_size);
|
GRN_BULK_REWIND(&key_buffer);
|
||||||
|
grn_obj_get_value(ctx, index_column, record_id, &key_buffer);
|
||||||
|
ukey = GRN_TEXT_VALUE(&key_buffer);
|
||||||
|
ukey_size = GRN_TEXT_LEN(&key_buffer);
|
||||||
} else {
|
} else {
|
||||||
mrn_change_encoding(ctx, NULL);
|
mrn_change_encoding(ctx, NULL);
|
||||||
uchar key[MRN_MAX_KEY_SIZE];
|
uchar key[MRN_MAX_KEY_SIZE];
|
||||||
@@ -6777,12 +6606,32 @@ int ha_mroonga::storage_index_read_map(uchar *buf, const uchar *key,
|
|||||||
bool is_multiple_column_index = KEY_N_KEY_PARTS(&key_info) > 1;
|
bool is_multiple_column_index = KEY_N_KEY_PARTS(&key_info) > 1;
|
||||||
if (is_multiple_column_index) {
|
if (is_multiple_column_index) {
|
||||||
mrn_change_encoding(ctx, NULL);
|
mrn_change_encoding(ctx, NULL);
|
||||||
flags |= GRN_CURSOR_PREFIX;
|
|
||||||
uint key_length = calculate_key_len(table, active_index, key, keypart_map);
|
uint key_length = calculate_key_len(table, active_index, key, keypart_map);
|
||||||
key_min = key_min_entity;
|
DBUG_PRINT("info",
|
||||||
storage_encode_multiple_column_key(&key_info,
|
("mroonga: multiple column index: "
|
||||||
key, key_length,
|
"search key length=<%u>, "
|
||||||
key_min, &size_min);
|
"multiple column index key length=<%u>",
|
||||||
|
key_length, key_info.key_length));
|
||||||
|
if (key_length == key_info.key_length) {
|
||||||
|
if (find_flag == HA_READ_BEFORE_KEY ||
|
||||||
|
find_flag == HA_READ_PREFIX_LAST_OR_PREV) {
|
||||||
|
key_max = key_max_entity;
|
||||||
|
storage_encode_multiple_column_key(&key_info,
|
||||||
|
key, key_length,
|
||||||
|
key_max, &size_max);
|
||||||
|
} else {
|
||||||
|
key_min = key_min_entity;
|
||||||
|
storage_encode_multiple_column_key(&key_info,
|
||||||
|
key, key_length,
|
||||||
|
key_min, &size_min);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
flags |= GRN_CURSOR_PREFIX;
|
||||||
|
key_min = key_min_entity;
|
||||||
|
storage_encode_multiple_column_key(&key_info,
|
||||||
|
key, key_length,
|
||||||
|
key_min, &size_min);
|
||||||
|
}
|
||||||
} else if (mrn_is_geo_key(&key_info)) {
|
} else if (mrn_is_geo_key(&key_info)) {
|
||||||
error = mrn_change_encoding(ctx, key_info.key_part->field->charset());
|
error = mrn_change_encoding(ctx, key_info.key_part->field->charset());
|
||||||
if (error)
|
if (error)
|
||||||
@@ -6819,10 +6668,8 @@ int ha_mroonga::storage_index_read_map(uchar *buf, const uchar *key,
|
|||||||
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (find_flag == HA_READ_BEFORE_KEY ||
|
||||||
find_flag == HA_READ_BEFORE_KEY ||
|
find_flag == HA_READ_PREFIX_LAST_OR_PREV) {
|
||||||
find_flag == HA_READ_PREFIX_LAST_OR_PREV
|
|
||||||
) {
|
|
||||||
key_max = key_max_entity;
|
key_max = key_max_entity;
|
||||||
storage_encode_key(field, key, key_max_entity, &size_max);
|
storage_encode_key(field, key, key_max_entity, &size_max);
|
||||||
} else {
|
} else {
|
||||||
@@ -8264,49 +8111,6 @@ bool ha_mroonga::get_error_message(int error, String *buf)
|
|||||||
DBUG_RETURN(temporary_error);
|
DBUG_RETURN(temporary_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ha_mroonga::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;
|
|
||||||
}
|
|
||||||
|
|
||||||
ulonglong ha_mroonga::file_size(const char *path)
|
ulonglong ha_mroonga::file_size(const char *path)
|
||||||
{
|
{
|
||||||
MRN_DBUG_ENTER_METHOD();
|
MRN_DBUG_ENTER_METHOD();
|
||||||
@@ -8636,6 +8440,117 @@ grn_obj *ha_mroonga::find_normalizer(KEY *key_info)
|
|||||||
DBUG_RETURN(normalizer);
|
DBUG_RETURN(normalizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ha_mroonga::find_token_filters(KEY *key_info, grn_obj *token_filters)
|
||||||
|
{
|
||||||
|
MRN_DBUG_ENTER_METHOD();
|
||||||
|
bool found = false;
|
||||||
|
#if MYSQL_VERSION_ID >= 50500
|
||||||
|
if (key_info->comment.length > 0) {
|
||||||
|
mrn::ParametersParser parser(key_info->comment.str,
|
||||||
|
key_info->comment.length);
|
||||||
|
parser.parse();
|
||||||
|
const char *names = parser["token_filters"];
|
||||||
|
if (names) {
|
||||||
|
found = find_token_filters_fill(token_filters, names, strlen(names));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
DBUG_RETURN(found);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ha_mroonga::find_token_filters_put(grn_obj *token_filters,
|
||||||
|
const char *token_filter_name,
|
||||||
|
int token_filter_name_length)
|
||||||
|
{
|
||||||
|
grn_obj *token_filter;
|
||||||
|
|
||||||
|
token_filter = grn_ctx_get(ctx,
|
||||||
|
token_filter_name,
|
||||||
|
token_filter_name_length);
|
||||||
|
if (token_filter) {
|
||||||
|
GRN_PTR_PUT(ctx, token_filters, token_filter);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
char message[MRN_BUFFER_SIZE];
|
||||||
|
sprintf(message,
|
||||||
|
"nonexistent token filter: <%.*s>",
|
||||||
|
token_filter_name_length, token_filter_name);
|
||||||
|
push_warning(ha_thd(),
|
||||||
|
Sql_condition::WARN_LEVEL_WARN, ER_UNSUPPORTED_EXTENSION,
|
||||||
|
message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ha_mroonga::find_token_filters_fill(grn_obj *token_filters,
|
||||||
|
const char *token_filter_names,
|
||||||
|
int token_filter_names_length)
|
||||||
|
{
|
||||||
|
const char *start, *current, *end;
|
||||||
|
const char *name_start, *name_end;
|
||||||
|
const char *last_name_end;
|
||||||
|
|
||||||
|
start = token_filter_names;
|
||||||
|
end = start + token_filter_names_length;
|
||||||
|
current = start;
|
||||||
|
name_start = NULL;
|
||||||
|
name_end = NULL;
|
||||||
|
last_name_end = start;
|
||||||
|
while (current < end) {
|
||||||
|
switch (current[0]) {
|
||||||
|
case ' ' :
|
||||||
|
if (name_start && !name_end) {
|
||||||
|
name_end = current;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ',' :
|
||||||
|
if (!name_start) {
|
||||||
|
goto break_loop;
|
||||||
|
}
|
||||||
|
if (!name_end) {
|
||||||
|
name_end = current;
|
||||||
|
}
|
||||||
|
find_token_filters_put(token_filters,
|
||||||
|
name_start,
|
||||||
|
name_end - name_start);
|
||||||
|
last_name_end = name_end + 1;
|
||||||
|
name_start = NULL;
|
||||||
|
name_end = NULL;
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
if (!name_start) {
|
||||||
|
name_start = current;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
current++;
|
||||||
|
}
|
||||||
|
|
||||||
|
break_loop:
|
||||||
|
if (!name_start) {
|
||||||
|
char message[MRN_BUFFER_SIZE];
|
||||||
|
sprintf(message,
|
||||||
|
"empty token filter name: "
|
||||||
|
"<%.*s|%.*s|%.*s>",
|
||||||
|
(int)(last_name_end - start), start,
|
||||||
|
(int)(current - last_name_end), last_name_end,
|
||||||
|
(int)(end - current), current);
|
||||||
|
push_warning(ha_thd(),
|
||||||
|
Sql_condition::WARN_LEVEL_WARN, ER_UNSUPPORTED_EXTENSION,
|
||||||
|
message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!name_end) {
|
||||||
|
name_end = current;
|
||||||
|
}
|
||||||
|
find_token_filters_put(token_filters,
|
||||||
|
name_start,
|
||||||
|
name_end - name_start);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int ha_mroonga::wrapper_get_record(uchar *buf, const uchar *key)
|
int ha_mroonga::wrapper_get_record(uchar *buf, const uchar *key)
|
||||||
{
|
{
|
||||||
MRN_DBUG_ENTER_METHOD();
|
MRN_DBUG_ENTER_METHOD();
|
||||||
@@ -9664,8 +9579,8 @@ void ha_mroonga::storage_store_field_integer(Field *field,
|
|||||||
field_value = *((unsigned char *)value);
|
field_value = *((unsigned char *)value);
|
||||||
field->store(field_value, is_unsigned);
|
field->store(field_value, is_unsigned);
|
||||||
} else {
|
} else {
|
||||||
char field_value;
|
signed char field_value;
|
||||||
field_value = *((char *)value);
|
field_value = *((signed char *)value);
|
||||||
field->store(field_value, is_unsigned);
|
field->store(field_value, is_unsigned);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -10079,6 +9994,60 @@ void ha_mroonga::storage_store_field(Field *field,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ha_mroonga::storage_store_field_column(Field *field,
|
||||||
|
int nth_column, grn_id record_id)
|
||||||
|
{
|
||||||
|
MRN_DBUG_ENTER_METHOD();
|
||||||
|
|
||||||
|
grn_obj *column = grn_columns[nth_column];
|
||||||
|
grn_id range_id = grn_obj_get_range(ctx, column);
|
||||||
|
grn_obj *range = grn_column_ranges[nth_column];
|
||||||
|
grn_obj *value = &new_value_buffer;
|
||||||
|
|
||||||
|
if (mrn::grn::is_table(range)) {
|
||||||
|
if (mrn::grn::is_vector_column(column)) {
|
||||||
|
grn_obj_reinit(ctx, value, range_id, GRN_OBJ_VECTOR);
|
||||||
|
grn_obj_get_value(ctx, column, record_id, value);
|
||||||
|
|
||||||
|
// TODO: Check whether reference type or not
|
||||||
|
grn_obj unvectored_value;
|
||||||
|
GRN_TEXT_INIT(&unvectored_value, 0);
|
||||||
|
int n_ids = GRN_BULK_VSIZE(value) / sizeof(grn_id);
|
||||||
|
for (int i = 0; i < n_ids; i++) {
|
||||||
|
grn_id id = GRN_RECORD_VALUE_AT(value, i);
|
||||||
|
if (i > 0) {
|
||||||
|
GRN_TEXT_PUTS(ctx, &unvectored_value, mrn_vector_column_delimiter);
|
||||||
|
}
|
||||||
|
char key[GRN_TABLE_MAX_KEY_SIZE];
|
||||||
|
int key_length;
|
||||||
|
key_length = grn_table_get_key(ctx, range, id,
|
||||||
|
&key, GRN_TABLE_MAX_KEY_SIZE);
|
||||||
|
GRN_TEXT_PUT(ctx, &unvectored_value, key, key_length);
|
||||||
|
}
|
||||||
|
storage_store_field(field,
|
||||||
|
GRN_TEXT_VALUE(&unvectored_value),
|
||||||
|
GRN_TEXT_LEN(&unvectored_value));
|
||||||
|
GRN_OBJ_FIN(ctx, &unvectored_value);
|
||||||
|
} else {
|
||||||
|
grn_obj_reinit(ctx, value, range_id, 0);
|
||||||
|
grn_obj_get_value(ctx, column, record_id, value);
|
||||||
|
|
||||||
|
grn_id id = GRN_RECORD_VALUE(value);
|
||||||
|
char key[GRN_TABLE_MAX_KEY_SIZE];
|
||||||
|
int key_length;
|
||||||
|
key_length = grn_table_get_key(ctx, range, id,
|
||||||
|
&key, GRN_TABLE_MAX_KEY_SIZE);
|
||||||
|
storage_store_field(field, key, key_length);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
grn_obj_reinit(ctx, value, range_id, 0);
|
||||||
|
grn_obj_get_value(ctx, column, record_id, value);
|
||||||
|
storage_store_field(field, GRN_BULK_HEAD(value), GRN_BULK_VSIZE(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
|
}
|
||||||
|
|
||||||
void ha_mroonga::storage_store_fields(uchar *buf, grn_id record_id)
|
void ha_mroonga::storage_store_fields(uchar *buf, grn_id record_id)
|
||||||
{
|
{
|
||||||
MRN_DBUG_ENTER_METHOD();
|
MRN_DBUG_ENTER_METHOD();
|
||||||
@@ -10124,49 +10093,7 @@ void ha_mroonga::storage_store_fields(uchar *buf, grn_id record_id)
|
|||||||
&key, GRN_TABLE_MAX_KEY_SIZE);
|
&key, GRN_TABLE_MAX_KEY_SIZE);
|
||||||
storage_store_field(field, key, key_length);
|
storage_store_field(field, key, key_length);
|
||||||
} else {
|
} else {
|
||||||
// actual column
|
storage_store_field_column(field, i ,record_id);
|
||||||
const char *value;
|
|
||||||
uint32 value_length;
|
|
||||||
value = grn_obj_get_value_(ctx, grn_columns[i], record_id,
|
|
||||||
&value_length);
|
|
||||||
DBUG_PRINT("info", ("mroonga: value_length=%u",value_length));
|
|
||||||
grn_obj *range = grn_column_ranges[i];
|
|
||||||
// TODO: create mrn::is_grn_table() and use it.
|
|
||||||
if (GRN_TABLE_HASH_KEY <= range->header.type &&
|
|
||||||
range->header.type <= GRN_DB) {
|
|
||||||
// TODO: extract as a method
|
|
||||||
if (((grn_columns[i]->header.flags & GRN_OBJ_COLUMN_TYPE_MASK) ==
|
|
||||||
GRN_OBJ_COLUMN_VECTOR)) {
|
|
||||||
// TODO: Check whether reference type or not
|
|
||||||
grn_obj unvectored_value;
|
|
||||||
GRN_TEXT_INIT(&unvectored_value, 0);
|
|
||||||
grn_id *ids = (grn_id *)value;
|
|
||||||
for (int i = 0; i * sizeof(grn_id) < value_length; i++) {
|
|
||||||
grn_id id = ids[i];
|
|
||||||
if (i > 0) {
|
|
||||||
GRN_TEXT_PUTS(ctx, &unvectored_value, mrn_vector_column_delimiter);
|
|
||||||
}
|
|
||||||
char key[GRN_TABLE_MAX_KEY_SIZE];
|
|
||||||
int key_length;
|
|
||||||
key_length = grn_table_get_key(ctx, range, id,
|
|
||||||
&key, GRN_TABLE_MAX_KEY_SIZE);
|
|
||||||
GRN_TEXT_PUT(ctx, &unvectored_value, key, key_length);
|
|
||||||
}
|
|
||||||
storage_store_field(field,
|
|
||||||
GRN_TEXT_VALUE(&unvectored_value),
|
|
||||||
GRN_TEXT_LEN(&unvectored_value));
|
|
||||||
GRN_OBJ_FIN(ctx, &unvectored_value);
|
|
||||||
} else {
|
|
||||||
grn_id id = *((grn_id *)value);
|
|
||||||
char key[GRN_TABLE_MAX_KEY_SIZE];
|
|
||||||
int key_length;
|
|
||||||
key_length = grn_table_get_key(ctx, range, id,
|
|
||||||
&key, GRN_TABLE_MAX_KEY_SIZE);
|
|
||||||
storage_store_field(field, key, key_length);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
storage_store_field(field, value, value_length);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
field->move_field_offset(-ptr_diff);
|
field->move_field_offset(-ptr_diff);
|
||||||
}
|
}
|
||||||
@@ -10216,20 +10143,20 @@ void ha_mroonga::storage_store_fields_for_prep_update(const uchar *old_data,
|
|||||||
) {
|
) {
|
||||||
mrn::DebugColumnAccess debug_column_access(table, table->write_set);
|
mrn::DebugColumnAccess debug_column_access(table, table->write_set);
|
||||||
DBUG_PRINT("info", ("mroonga: store column %d(%d)",i,field->field_index));
|
DBUG_PRINT("info", ("mroonga: store column %d(%d)",i,field->field_index));
|
||||||
const char *value;
|
grn_obj value;
|
||||||
uint32 value_length;
|
GRN_OBJ_INIT(&value, GRN_BULK, 0, grn_obj_get_range(ctx, grn_columns[i]));
|
||||||
value = grn_obj_get_value_(ctx, grn_columns[i], record_id,
|
grn_obj_get_value(ctx, grn_columns[i], record_id, &value);
|
||||||
&value_length);
|
|
||||||
// old column
|
// old column
|
||||||
field->move_field_offset(ptr_diff_old);
|
field->move_field_offset(ptr_diff_old);
|
||||||
storage_store_field(field, value, value_length);
|
storage_store_field(field, GRN_BULK_HEAD(&value), GRN_BULK_VSIZE(&value));
|
||||||
field->move_field_offset(-ptr_diff_old);
|
field->move_field_offset(-ptr_diff_old);
|
||||||
if (new_data) {
|
if (new_data) {
|
||||||
// new column
|
// new column
|
||||||
field->move_field_offset(ptr_diff_new);
|
field->move_field_offset(ptr_diff_new);
|
||||||
storage_store_field(field, value, value_length);
|
storage_store_field(field, GRN_BULK_HEAD(&value), GRN_BULK_VSIZE(&value));
|
||||||
field->move_field_offset(-ptr_diff_new);
|
field->move_field_offset(-ptr_diff_new);
|
||||||
}
|
}
|
||||||
|
GRN_OBJ_FIN(ctx, &value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13483,6 +13410,8 @@ bool ha_mroonga::storage_inplace_alter_table_index(
|
|||||||
grn_table_size(ctx, index_tables[key_pos])
|
grn_table_size(ctx, index_tables[key_pos])
|
||||||
) {
|
) {
|
||||||
error = HA_ERR_FOUND_DUPP_UNIQUE;
|
error = HA_ERR_FOUND_DUPP_UNIQUE;
|
||||||
|
my_printf_error(ER_DUP_UNIQUE, ER(ER_DUP_UNIQUE), MYF(0),
|
||||||
|
table_share->table_name);
|
||||||
++i;
|
++i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -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:
|
|||||||
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:
|
|||||||
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:
|
|||||||
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 = \
|
|||||||
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 = \
|
|||||||
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
|
||||||
|
341
storage/mroonga/lib/mrn_database_manager.cpp
Normal file
341
storage/mroonga/lib/mrn_database_manager.cpp
Normal file
@@ -0,0 +1,341 @@
|
|||||||
|
/* -*- 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);
|
||||||
|
}
|
||||||
|
}
|
50
storage/mroonga/lib/mrn_database_manager.hpp
Normal file
50
storage/mroonga/lib/mrn_database_manager.hpp
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/* -*- 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MRN_DATABASE_MANAGER_HPP_
|
||||||
|
#define MRN_DATABASE_MANAGER_HPP_
|
||||||
|
|
||||||
|
#include <groonga.h>
|
||||||
|
|
||||||
|
namespace mrn {
|
||||||
|
class DatabaseManager {
|
||||||
|
public:
|
||||||
|
DatabaseManager(grn_ctx *ctx);
|
||||||
|
~DatabaseManager(void);
|
||||||
|
bool init(void);
|
||||||
|
int open(const char *path, grn_obj **db);
|
||||||
|
void close(const char *path);
|
||||||
|
bool drop(const char *path);
|
||||||
|
int clear(void);
|
||||||
|
|
||||||
|
private:
|
||||||
|
grn_ctx *ctx_;
|
||||||
|
grn_hash *cache_;
|
||||||
|
pthread_mutex_t mutex_;
|
||||||
|
bool mutex_initialized_;
|
||||||
|
|
||||||
|
void mkdir_p(const char *directory);
|
||||||
|
void ensure_database_directory(void);
|
||||||
|
int ensure_normalizers_registered(grn_obj *db);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* MRN_DATABASE_MANAGER_HPP_ */
|
@@ -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 @@
|
|||||||
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 {
|
|||||||
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);
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
|
/* -*- 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 @@
|
|||||||
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 {
|
||||||
|
bool is_table(grn_obj *obj) {
|
||||||
|
grn_id type = obj->header.type;
|
||||||
|
return GRN_TABLE_HASH_KEY <= type && obj->header.type <= GRN_DB;
|
||||||
|
}
|
||||||
|
|
||||||
/* functions */
|
bool is_vector_column(grn_obj *column) {
|
||||||
bool mrn_hash_put(grn_ctx *ctx, grn_hash *hash, const char *key, grn_obj *value);
|
int column_type = (column->header.flags & GRN_OBJ_COLUMN_TYPE_MASK);
|
||||||
bool mrn_hash_get(grn_ctx *ctx, grn_hash *hash, const char *key, grn_obj **value);
|
return column_type == GRN_OBJ_COLUMN_VECTOR;
|
||||||
bool mrn_hash_remove(grn_ctx *ctx, grn_hash *hash, const char *key);
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MRN_END_DECLS
|
#endif // MRN_GRN_HPP_
|
||||||
|
|
||||||
#endif /* MRN_SYS_HPP_ */
|
|
@@ -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 @@
|
|||||||
# 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>
|
||||||
|
@@ -1,88 +0,0 @@
|
|||||||
/* -*- c-basic-offset: 2 -*- */
|
|
||||||
/*
|
|
||||||
Copyright(C) 2010 Tetsuro IKEDA
|
|
||||||
Copyright(C) 2011-2012 Kentoku SHIBA
|
|
||||||
Copyright(C) 2011 Kouhei Sutou <kou@clear-code.com>
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "mrn_sys.hpp"
|
|
||||||
|
|
||||||
bool mrn_hash_put(grn_ctx *ctx, grn_hash *hash, const char *key, grn_obj *value)
|
|
||||||
{
|
|
||||||
int added;
|
|
||||||
bool succeed;
|
|
||||||
void *buf;
|
|
||||||
grn_hash_add(ctx, hash, (const char *)key, strlen(key), &buf, &added);
|
|
||||||
// duplicate check
|
|
||||||
if (added == 0) {
|
|
||||||
GRN_LOG(ctx, GRN_LOG_WARNING, "hash put duplicated (key=%s)", key);
|
|
||||||
succeed = false;
|
|
||||||
} else {
|
|
||||||
// store address of value
|
|
||||||
memcpy(buf, &value, sizeof(grn_obj *));
|
|
||||||
GRN_LOG(ctx, GRN_LOG_DEBUG, "hash put (key=%s)", key);
|
|
||||||
succeed = true;
|
|
||||||
}
|
|
||||||
return succeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool mrn_hash_get(grn_ctx *ctx, grn_hash *hash, const char *key, grn_obj **value)
|
|
||||||
{
|
|
||||||
bool found;
|
|
||||||
grn_id id;
|
|
||||||
void *buf;
|
|
||||||
id = grn_hash_get(ctx, hash, (const char *)key, strlen(key), &buf);
|
|
||||||
// key not found
|
|
||||||
if (id == GRN_ID_NIL) {
|
|
||||||
GRN_LOG(ctx, GRN_LOG_DEBUG, "hash get not found (key=%s)", key);
|
|
||||||
found = false;
|
|
||||||
} else {
|
|
||||||
// restore address of value
|
|
||||||
memcpy(value, buf, sizeof(grn_obj *));
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool mrn_hash_remove(grn_ctx *ctx, grn_hash *hash, const char *key)
|
|
||||||
{
|
|
||||||
bool succeed;
|
|
||||||
grn_rc rc;
|
|
||||||
grn_id id;
|
|
||||||
id = grn_hash_get(ctx, hash, (const char*) key, strlen(key), NULL);
|
|
||||||
if (id == GRN_ID_NIL) {
|
|
||||||
GRN_LOG(ctx, GRN_LOG_WARNING, "hash remove not found (key=%s)", key);
|
|
||||||
succeed = false;
|
|
||||||
} else {
|
|
||||||
rc = grn_hash_delete_by_id(ctx, hash, id, NULL);
|
|
||||||
if (rc != GRN_SUCCESS) {
|
|
||||||
GRN_LOG(ctx, GRN_LOG_ERROR, "hash remove error (key=%s)", key);
|
|
||||||
succeed = false;
|
|
||||||
} else {
|
|
||||||
GRN_LOG(ctx, GRN_LOG_DEBUG, "hash remove (key=%s)", key);
|
|
||||||
succeed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return succeed;
|
|
||||||
}
|
|
@@ -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 @@
|
|||||||
# 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,
|
|||||||
|
|
||||||
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)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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(
|
|||||||
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
|
|||||||
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;
|
||||||
|
@@ -0,0 +1,24 @@
|
|||||||
|
# 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;
|
||||||
|
}
|
||||||
|
}
|
7
storage/mroonga/mysql-test/mroonga/storage/disabled.def
Normal file
7
storage/mroonga/mysql-test/mroonga/storage/disabled.def
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
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.
|
@@ -0,0 +1,19 @@
|
|||||||
|
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;
|
@@ -0,0 +1,17 @@
|
|||||||
|
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;
|
@@ -0,0 +1,32 @@
|
|||||||
|
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;
|
@@ -1,4 +1,3 @@
|
|||||||
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
|
||||||
|
@@ -0,0 +1,18 @@
|
|||||||
|
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;
|
@@ -0,0 +1,15 @@
|
|||||||
|
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;
|
@@ -0,0 +1,15 @@
|
|||||||
|
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;
|
@@ -0,0 +1,23 @@
|
|||||||
|
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;
|
@@ -0,0 +1,23 @@
|
|||||||
|
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;
|
@@ -1,4 +1,3 @@
|
|||||||
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"'
|
||||||
|
@@ -0,0 +1,23 @@
|
|||||||
|
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;
|
@@ -0,0 +1,28 @@
|
|||||||
|
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;
|
@@ -0,0 +1,30 @@
|
|||||||
|
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;
|
@@ -0,0 +1,29 @@
|
|||||||
|
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;
|
@@ -0,0 +1,30 @@
|
|||||||
|
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;
|
@@ -1,4 +1,4 @@
|
|||||||
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
|
||||||
|
@@ -0,0 +1,9 @@
|
|||||||
|
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;
|
@@ -1,3 +1,3 @@
|
|||||||
show variables like 'mroonga_version';
|
show variables like 'mroonga_version';
|
||||||
Variable_name Value
|
Variable_name Value
|
||||||
mroonga_version 4.05
|
mroonga_version 4.06
|
||||||
|
@@ -0,0 +1,43 @@
|
|||||||
|
# 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
|
@@ -0,0 +1,38 @@
|
|||||||
|
# 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
|
@@ -0,0 +1,49 @@
|
|||||||
|
# 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 @@
|
|||||||
--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
|
||||||
|
@@ -0,0 +1,46 @@
|
|||||||
|
# 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
|
@@ -0,0 +1,40 @@
|
|||||||
|
# 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
|
@@ -0,0 +1,40 @@
|
|||||||
|
# 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
|
@@ -0,0 +1,45 @@
|
|||||||
|
# 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
|
@@ -0,0 +1,45 @@
|
|||||||
|
# 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 @@
|
|||||||
--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 @@
|
|||||||
# 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
|
||||||
|
@@ -0,0 +1,52 @@
|
|||||||
|
# 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
|
@@ -0,0 +1,44 @@
|
|||||||
|
# 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
|
@@ -0,0 +1,44 @@
|
|||||||
|
# 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
|
@@ -0,0 +1,44 @@
|
|||||||
|
# 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
|
@@ -0,0 +1,44 @@
|
|||||||
|
# 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
|
@@ -0,0 +1,35 @@
|
|||||||
|
# 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
|
2
storage/mroonga/mysql-test/mroonga/wrapper/disabled.def
Normal file
2
storage/mroonga/mysql-test/mroonga/wrapper/disabled.def
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
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.
|
@@ -0,0 +1,15 @@
|
|||||||
|
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;
|
@@ -0,0 +1,15 @@
|
|||||||
|
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
|
|||||||
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
|
||||||
|
@@ -0,0 +1,42 @@
|
|||||||
|
# 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
|
@@ -0,0 +1,42 @@
|
|||||||
|
# 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");
|
|||||||
|
|
||||||
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 @@
|
|||||||
|
|
||||||
--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 @@
|
|||||||
|
|
||||||
--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
|
|||||||
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:
|
|||||||
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
|
|||||||
); \
|
); \
|
||||||
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
|
||||||
|
|
||||||
../$(PACKAGE)-$(VERSION).tar.gz:
|
prepare-build-package-deb: source env.sh
|
||||||
ln -s $(abs_top_builddir)/$(PACKAGE)-$(VERSION).tar.gz ../
|
cp env.sh tmp/
|
||||||
|
rm -rf tmp/debian
|
||||||
|
cp -rp $(srcdir)/../debian tmp/
|
||||||
|
|
||||||
|
source: tmp/$(PACKAGE)-$(VERSION).tar.gz
|
||||||
|
|
||||||
|
tmp/$(PACKAGE)-$(VERSION).tar.gz: $(abs_top_builddir)/$(PACKAGE)-$(VERSION).tar.gz
|
||||||
|
mkdir -p tmp
|
||||||
|
cp $(abs_top_builddir)/$(PACKAGE)-$(VERSION).tar.gz $@
|
||||||
|
30
storage/mroonga/packages/apt/Vagrantfile
vendored
Normal file
30
storage/mroonga/packages/apt/Vagrantfile
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# -*- 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,120 +2,77 @@
|
|||||||
|
|
||||||
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()
|
||||||
{
|
{
|
||||||
"$@"
|
"$@"
|
||||||
if test $? -ne 0; then
|
if test $? -ne 0; then
|
||||||
echo "Failed $@"
|
echo "Failed $@"
|
||||||
exit 1
|
exit 1
|
||||||
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)
|
|
||||||
|
distribution=$(lsb_release --id --short | tr 'A-Z' 'a-z')
|
||||||
code_name=$(lsb_release --codename --short)
|
code_name=$(lsb_release --codename --short)
|
||||||
|
case "${distribution}" in
|
||||||
groonga_list=/etc/apt/sources.list.d/groonga.list
|
debian)
|
||||||
if [ ! -f "${groonga_list}" ]; then
|
component=main
|
||||||
case ${distribution} in
|
run cat <<EOF > /etc/apt/sources.list.d/groonga.list
|
||||||
Debian)
|
deb http://packages.groonga.org/debian/ wheezy main
|
||||||
component=main
|
deb-src http://packages.groonga.org/debian/ wheezy main
|
||||||
if [ "$code_name" = "sid" ]; then
|
|
||||||
code_name=unstable
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
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
|
||||||
Ubuntu)
|
run apt-get install -y --allow-unauthenticated groonga-keyring
|
||||||
cat <<EOF > "${security_list}"
|
run apt-get update
|
||||||
|
;;
|
||||||
|
ubuntu)
|
||||||
|
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 add-apt-repository -y universe
|
||||||
|
run add-apt-repository -y ppa:groonga/ppa
|
||||||
run apt-get update
|
run apt-get update
|
||||||
run apt-get upgrade -V -y
|
;;
|
||||||
fi
|
esac
|
||||||
|
|
||||||
universe_list=/etc/apt/sources.list.d/universe.list
|
run apt-get install -V -y build-essential devscripts ${DEPENDED_PACKAGES}
|
||||||
if [ ! -f "$universe_list}" ]; then
|
|
||||||
case ${distribution} in
|
|
||||||
Ubuntu)
|
|
||||||
sed -e 's/main/universe/' /etc/apt/sources.list > ${universe_list}
|
|
||||||
run apt-get update
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
run apt-get install -V -y 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 mkdir -p build
|
||||||
run useradd -m $USER_NAME
|
run cp /vagrant/tmp/${PACKAGE}-${VERSION}.tar.gz \
|
||||||
fi
|
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 -
|
||||||
|
|
||||||
cat <<EOF > $BUILD_SCRIPT
|
package_initial=$(echo "${PACKAGE}" | sed -e 's/\(.\).*/\1/')
|
||||||
#!/bin/sh
|
pool_dir="/vagrant/repositories/${distribution}/pool/${code_name}/${component}/${package_initial}/${PACKAGE}"
|
||||||
|
run mkdir -p "${pool_dir}/"
|
||||||
rm -rf build
|
run cp *.tar.gz *.dsc *.deb "${pool_dir}/"
|
||||||
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 su - $USER_NAME $BUILD_SCRIPT
|
|
||||||
|
@@ -1,134 +0,0 @@
|
|||||||
#!/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
|
|
@@ -1,3 +1,6 @@
|
|||||||
|
PACKAGE=@PACKAGE@
|
||||||
|
VERSION=@VERSION@
|
||||||
|
DEPENDED_PACKAGES="
|
||||||
debhelper
|
debhelper
|
||||||
autotools-dev
|
autotools-dev
|
||||||
libgroonga-dev
|
libgroonga-dev
|
||||||
@@ -9,3 +12,4 @@ libmysqld-dev
|
|||||||
libssl-dev
|
libssl-dev
|
||||||
groonga-normalizer-mysql
|
groonga-normalizer-mysql
|
||||||
wget
|
wget
|
||||||
|
"
|
@@ -1,3 +1,9 @@
|
|||||||
|
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
|
|||||||
%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
|
|||||||
%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.
|
||||||
|
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
%{!?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
|
|||||||
%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
|
|||||||
%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
|
|||||||
%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.
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
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 = \
|
|||||||
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()
|
|||||||
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)"
|
||||||
|
@@ -1 +1 @@
|
|||||||
4.5
|
4.6
|
@@ -1,7 +1,5 @@
|
|||||||
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 \
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
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 = \
|
|||||||
$(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
|
||||||
|
|
||||||
|
@@ -1,95 +0,0 @@
|
|||||||
/* -*- 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));
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,6 +1,6 @@
|
|||||||
#!/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 @@
|
|||||||
# 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
|
|||||||
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 ./
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#!/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
|
|||||||
. "${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()
|
||||||
{
|
{
|
||||||
make -j${n_processors} > /dev/null
|
if [ "${MROONGA_BUNDLED}" = "yes" ]; then
|
||||||
|
make > /dev/null
|
||||||
|
else
|
||||||
|
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()
|
|||||||
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 @@
|
|||||||
#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,
|
|||||||
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,
|
|||||||
|
|
||||||
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)
|
|||||||
{
|
{
|
||||||
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,
|
|||||||
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;
|
||||||
|
28
storage/mroonga/vendor/groonga/CMakeLists.txt
vendored
28
storage/mroonga/vendor/groonga/CMakeLists.txt
vendored
@@ -1,4 +1,4 @@
|
|||||||
# 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
|
|||||||
"${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)
|
|||||||
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)
|
|||||||
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()
|
|||||||
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")
|
|||||||
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()
|
||||||
|
2
storage/mroonga/vendor/groonga/base_version
vendored
2
storage/mroonga/vendor/groonga/base_version
vendored
@@ -1 +1 @@
|
|||||||
4.0.5
|
4.0.6
|
@@ -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)
|
|||||||
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
|
|||||||
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)
|
||||||
|
274
storage/mroonga/vendor/groonga/benchmark/bench-range-select.c
vendored
Normal file
274
storage/mroonga/vendor/groonga/benchmark/bench-range-select.c
vendored
Normal file
@@ -0,0 +1,274 @@
|
|||||||
|
/* -*- 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)
|
|||||||
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 @@
|
|||||||
#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
|
||||||
|
26
storage/mroonga/vendor/groonga/configure.ac
vendored
26
storage/mroonga/vendor/groonga/configure.ac
vendored
@@ -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([
|
|||||||
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:
|
|||||||
|
|
||||||
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)
|
|||||||
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)
|
|||||||
# 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
|
|||||||
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)
|
|||||||
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([
|
|||||||
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
|
||||||
|
BIN
storage/mroonga/vendor/groonga/data/account/conoha.gpg.kou
vendored
Normal file
BIN
storage/mroonga/vendor/groonga/data/account/conoha.gpg.kou
vendored
Normal file
Binary file not shown.
@@ -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
|
|||||||
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
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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,
|
|||||||
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
|
|||||||
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
|
||||||
|
71
storage/mroonga/vendor/groonga/include/groonga/token_filter.h
vendored
Normal file
71
storage/mroonga/vendor/groonga/include/groonga/token_filter.h
vendored
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/* -*- 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 */
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user