mirror of
https://github.com/MariaDB/server.git
synced 2026-05-17 20:37:12 +02:00
Update Mroonga to the latest version on 2015-02-17T13:34:27+0900
This commit is contained in:
parent
162446a621
commit
f5dabd7aca
416 changed files with 46277 additions and 7137 deletions
|
|
@ -26,6 +26,8 @@
|
|||
#include "mrn_lock.hpp"
|
||||
#include "mrn_path_mapper.hpp"
|
||||
|
||||
#include <groonga/plugin.h>
|
||||
|
||||
// for debug
|
||||
#define MRN_CLASS_NAME "mrn::DatabaseManager"
|
||||
|
||||
|
|
@ -38,19 +40,19 @@
|
|||
# define MRN_MKDIR(pathname, mode) mkdir((pathname), (mode))
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
grn_rc GRN_PLUGIN_IMPL_NAME_TAGGED(init, normalizers_mysql)(grn_ctx *ctx);
|
||||
grn_rc GRN_PLUGIN_IMPL_NAME_TAGGED(register, normalizers_mysql)(grn_ctx *ctx);
|
||||
}
|
||||
|
||||
namespace mrn {
|
||||
DatabaseManager::DatabaseManager(grn_ctx *ctx)
|
||||
DatabaseManager::DatabaseManager(grn_ctx *ctx, mysql_mutex_t *mutex)
|
||||
: ctx_(ctx),
|
||||
cache_(NULL),
|
||||
mutex_(),
|
||||
mutex_initialized_(false) {
|
||||
mutex_(mutex) {
|
||||
}
|
||||
|
||||
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, {
|
||||
|
|
@ -75,13 +77,6 @@ namespace mrn {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +87,7 @@ namespace mrn {
|
|||
*db = NULL;
|
||||
|
||||
mrn::PathMapper mapper(path);
|
||||
mrn::Lock lock(&mutex_);
|
||||
mrn::Lock lock(mutex_);
|
||||
|
||||
error = mrn::encoding::set(ctx_, system_charset_info);
|
||||
if (error) {
|
||||
|
|
@ -145,7 +140,7 @@ namespace mrn {
|
|||
MRN_DBUG_ENTER_METHOD();
|
||||
|
||||
mrn::PathMapper mapper(path);
|
||||
mrn::Lock lock(&mutex_);
|
||||
mrn::Lock lock(mutex_);
|
||||
|
||||
grn_id id;
|
||||
void *db_address;
|
||||
|
|
@ -171,7 +166,7 @@ namespace mrn {
|
|||
MRN_DBUG_ENTER_METHOD();
|
||||
|
||||
mrn::PathMapper mapper(path);
|
||||
mrn::Lock lock(&mutex_);
|
||||
mrn::Lock lock(mutex_);
|
||||
|
||||
grn_id id;
|
||||
void *db_address;
|
||||
|
|
@ -211,7 +206,7 @@ namespace mrn {
|
|||
|
||||
int error = 0;
|
||||
|
||||
mrn::Lock lock(&mutex_);
|
||||
mrn::Lock lock(mutex_);
|
||||
|
||||
grn_hash_cursor *cursor;
|
||||
cursor = grn_hash_cursor_open(ctx_, cache_,
|
||||
|
|
@ -323,15 +318,12 @@ namespace mrn {
|
|||
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
|
||||
# ifdef MRN_GROONGA_NORMALIZER_MYSQL_EMBED
|
||||
GRN_PLUGIN_IMPL_NAME_TAGGED(init, normalizers_mysql)(ctx_);
|
||||
GRN_PLUGIN_IMPL_NAME_TAGGED(register, normalizers_mysql)(ctx_);
|
||||
# else
|
||||
grn_plugin_register(ctx_, GROONGA_NORMALIZER_MYSQL_PLUGIN_NAME);
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
namespace mrn {
|
||||
class DatabaseManager {
|
||||
public:
|
||||
DatabaseManager(grn_ctx *ctx);
|
||||
DatabaseManager(grn_ctx *ctx, mysql_mutex_t *mutex);
|
||||
~DatabaseManager(void);
|
||||
bool init(void);
|
||||
int open(const char *path, grn_obj **db);
|
||||
|
|
@ -38,8 +38,7 @@ namespace mrn {
|
|||
private:
|
||||
grn_ctx *ctx_;
|
||||
grn_hash *cache_;
|
||||
pthread_mutex_t mutex_;
|
||||
bool mutex_initialized_;
|
||||
mysql_mutex_t *mutex_;
|
||||
|
||||
void mkdir_p(const char *directory);
|
||||
void ensure_database_directory(void);
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@
|
|||
#include "mrn_lock.hpp"
|
||||
|
||||
namespace mrn {
|
||||
Lock::Lock(pthread_mutex_t *mutex)
|
||||
Lock::Lock(mysql_mutex_t *mutex)
|
||||
: mutex_(mutex) {
|
||||
pthread_mutex_lock(mutex_);
|
||||
mysql_mutex_lock(mutex_);
|
||||
}
|
||||
|
||||
Lock::~Lock() {
|
||||
pthread_mutex_unlock(mutex_);
|
||||
mysql_mutex_unlock(mutex_);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@
|
|||
namespace mrn {
|
||||
class Lock {
|
||||
public:
|
||||
Lock(pthread_mutex_t *mutex);
|
||||
Lock(mysql_mutex_t *mutex);
|
||||
~Lock();
|
||||
private:
|
||||
pthread_mutex_t *mutex_;
|
||||
mysql_mutex_t *mutex_;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@ namespace mrn {
|
|||
};
|
||||
~Parameter() {
|
||||
if (key_) {
|
||||
my_free(key_, MYF(0));
|
||||
my_free(key_);
|
||||
}
|
||||
if (value_) {
|
||||
my_free(value_, MYF(0));
|
||||
my_free(value_);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/*
|
||||
Copyright(C) 2010 Tetsuro IKEDA
|
||||
Copyright(C) 2011-2013 Kentoku SHIBA
|
||||
Copyright(C) 2011-2012 Kouhei Sutou <kou@clear-code.com>
|
||||
Copyright(C) 2011-2015 Kouhei Sutou <kou@clear-code.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -184,6 +184,9 @@ namespace mrn {
|
|||
int i = len, j = 0;
|
||||
for (; mysql_path_[--i] != FN_LIBCHAR ;) {}
|
||||
for (; i < len ;) {
|
||||
if (len - i - 1 >= 3 && strncmp(mysql_path_ + i + 1, "#P#", 3) == 0) {
|
||||
break;
|
||||
}
|
||||
mysql_table_name_[j++] = mysql_path_[++i];
|
||||
}
|
||||
mysql_table_name_[j] = '\0';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue