mirror of
https://github.com/MariaDB/server.git
synced 2026-05-17 20:37:12 +02:00
Merge branch '10.5' into 10.6
This commit is contained in:
commit
272828a171
1195 changed files with 48764 additions and 27709 deletions
|
|
@ -932,7 +932,7 @@ MRN_SHARE *mrn_get_share(const char *table_name, TABLE *table, int *error)
|
|||
share->wrap_key_info = NULL;
|
||||
share->wrap_primary_key = MAX_KEY;
|
||||
}
|
||||
memcpy(wrap_table_share, table->s, sizeof(*wrap_table_share));
|
||||
*wrap_table_share= *table->s;
|
||||
mrn_init_sql_alloc(current_thd, &(wrap_table_share->mem_root));
|
||||
wrap_table_share->keys = share->wrap_keys;
|
||||
wrap_table_share->key_info = share->wrap_key_info;
|
||||
|
|
@ -1080,6 +1080,7 @@ TABLE_SHARE *mrn_create_tmp_table_share(TABLE_LIST *table_list, const char *path
|
|||
if (open_table_def(thd, share, GTS_TABLE))
|
||||
{
|
||||
*error = ER_CANT_OPEN_FILE;
|
||||
mrn_free_tmp_table_share(share);
|
||||
DBUG_RETURN(NULL);
|
||||
}
|
||||
DBUG_RETURN(share);
|
||||
|
|
|
|||
4
storage/mroonga/vendor/groonga/lib/com.c
vendored
4
storage/mroonga/vendor/groonga/lib/com.c
vendored
|
|
@ -343,7 +343,7 @@ grn_com_event_add(grn_ctx *ctx, grn_com_event *ev, grn_sock fd, int events, grn_
|
|||
{
|
||||
grn_com *c;
|
||||
/* todo : expand events */
|
||||
if (!ev || *ev->hash->n_entries == ev->max_nevents) {
|
||||
if (!ev || *ev->hash->n_entries == (uint32_t) ev->max_nevents) {
|
||||
if (ev) { GRN_LOG(ctx, GRN_LOG_ERROR, "too many connections (%d)", ev->max_nevents); }
|
||||
return GRN_INVALID_ARGUMENT;
|
||||
}
|
||||
|
|
@ -757,7 +757,7 @@ grn_com_send(grn_ctx *ctx, grn_com *cs,
|
|||
rc = ctx->rc;
|
||||
}
|
||||
}
|
||||
if (ret != whole_size) {
|
||||
if ((size_t) ret != whole_size) {
|
||||
GRN_LOG(ctx, GRN_LOG_ERROR,
|
||||
"sendmsg(%" GRN_FMT_SOCKET "): %" GRN_FMT_LLD " < %" GRN_FMT_LLU,
|
||||
cs->fd, (long long int)ret, (unsigned long long int)whole_size);
|
||||
|
|
|
|||
2
storage/mroonga/vendor/groonga/lib/config.c
vendored
2
storage/mroonga/vendor/groonga/lib/config.c
vendored
|
|
@ -51,7 +51,7 @@ grn_config_set(grn_ctx *ctx,
|
|||
if (value_size == -1) {
|
||||
value_size = strlen(value);
|
||||
}
|
||||
if (value_size > GRN_CONFIG_MAX_VALUE_SIZE) {
|
||||
if (value_size > (int32_t) GRN_CONFIG_MAX_VALUE_SIZE) {
|
||||
ERR(GRN_INVALID_ARGUMENT,
|
||||
"[config][set] too large value: max=<%" GRN_FMT_SIZE ">: <%d>",
|
||||
GRN_CONFIG_MAX_VALUE_SIZE, value_size);
|
||||
|
|
|
|||
39
storage/mroonga/vendor/groonga/lib/db.c
vendored
39
storage/mroonga/vendor/groonga/lib/db.c
vendored
|
|
@ -445,6 +445,9 @@ grn_db_close(grn_ctx *ctx, grn_obj *db)
|
|||
|
||||
ctx_used_db = ctx->impl && ctx->impl->db == db;
|
||||
if (ctx_used_db) {
|
||||
#ifdef GRN_WITH_MECAB
|
||||
grn_db_fin_mecab_tokenizer(ctx);
|
||||
#endif
|
||||
grn_ctx_loader_clear(ctx);
|
||||
if (ctx->impl->parser) {
|
||||
grn_expr_parser_close(ctx);
|
||||
|
|
@ -1299,7 +1302,7 @@ grn_table_get_subrecs(grn_ctx *ctx, grn_obj *table, grn_id id,
|
|||
byte *psubrec = (byte *)ri->subrecs;
|
||||
uint32_t n_subrecs = (uint32_t)GRN_RSET_N_SUBRECS(ri);
|
||||
uint32_t limit = value_size / (GRN_RSET_SCORE_SIZE + subrec_size);
|
||||
if (limit > buf_size) {
|
||||
if ((int) limit > buf_size) {
|
||||
limit = buf_size;
|
||||
}
|
||||
if (limit > n_subrecs) {
|
||||
|
|
@ -1522,7 +1525,7 @@ grn_table_add(grn_ctx *ctx, grn_obj *table, const void *key, unsigned int key_si
|
|||
if (hooks) {
|
||||
// todo : grn_proc_ctx_open()
|
||||
grn_obj id_, flags_, oldvalue_, value_;
|
||||
grn_proc_ctx pctx = {{0}, hooks->proc, NULL, hooks, hooks, PROC_INIT, 4, 4};
|
||||
grn_proc_ctx pctx = {{0}, hooks->proc, NULL, hooks, hooks, PROC_INIT, 4, 4, {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}}};
|
||||
GRN_UINT32_INIT(&id_, 0);
|
||||
GRN_UINT32_INIT(&flags_, 0);
|
||||
GRN_TEXT_INIT(&oldvalue_, 0);
|
||||
|
|
@ -1748,7 +1751,7 @@ grn_table_get_key(grn_ctx *ctx, grn_obj *table, grn_id id, void *keybuf, int buf
|
|||
{
|
||||
grn_array *a = (grn_array *)table;
|
||||
if (a->obj.header.domain) {
|
||||
if (buf_size >= a->value_size) {
|
||||
if ((unsigned int) buf_size >= a->value_size) {
|
||||
r = grn_array_get_value(ctx, a, id, keybuf);
|
||||
} else {
|
||||
r = a->value_size;
|
||||
|
|
@ -1823,7 +1826,7 @@ call_delete_hook(grn_ctx *ctx, grn_obj *table, grn_id rid, const void *key, unsi
|
|||
if (hooks) {
|
||||
// todo : grn_proc_ctx_open()
|
||||
grn_obj id_, flags_, oldvalue_, value_;
|
||||
grn_proc_ctx pctx = {{0}, hooks->proc, NULL, hooks, hooks, PROC_INIT, 4, 4};
|
||||
grn_proc_ctx pctx = {{0}, hooks->proc, NULL, hooks, hooks, PROC_INIT, 4, 4, {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}}};
|
||||
GRN_UINT32_INIT(&id_, 0);
|
||||
GRN_UINT32_INIT(&flags_, 0);
|
||||
GRN_TEXT_INIT(&oldvalue_, GRN_OBJ_DO_SHALLOW_COPY);
|
||||
|
|
@ -2463,7 +2466,7 @@ grn_table_cursor_open(grn_ctx *ctx, grn_obj *table,
|
|||
if (offset < 0) {
|
||||
ERR(GRN_TOO_SMALL_OFFSET,
|
||||
"can't use negative offset with GRN_CURSOR_PREFIX: %d", offset);
|
||||
} else if (offset != 0 && offset >= table_size) {
|
||||
} else if (offset != 0 && offset >= (int) table_size) {
|
||||
ERR(GRN_TOO_LARGE_OFFSET,
|
||||
"offset is not less than table size: offset:%d, table_size:%d",
|
||||
offset, table_size);
|
||||
|
|
@ -5234,7 +5237,7 @@ grn_vector_get_element(grn_ctx *ctx, grn_obj *vector,
|
|||
ERR(GRN_INVALID_ARGUMENT, "invalid vector");
|
||||
goto exit;
|
||||
}
|
||||
if (vector->u.v.n_sections <= offset) {
|
||||
if ((unsigned int) vector->u.v.n_sections <= offset) {
|
||||
ERR(GRN_RANGE_ERROR, "offset out of range");
|
||||
goto exit;
|
||||
}
|
||||
|
|
@ -7140,7 +7143,7 @@ call_hook(grn_ctx *ctx, grn_obj *obj, grn_id id, grn_obj *value, int flags)
|
|||
if (hooks) {
|
||||
// todo : grn_proc_ctx_open()
|
||||
grn_obj id_, flags_;
|
||||
grn_proc_ctx pctx = {{0}, hooks->proc, NULL, hooks, hooks, PROC_INIT, 4, 4};
|
||||
grn_proc_ctx pctx = {{0}, hooks->proc, NULL, hooks, hooks, PROC_INIT, 4, 4, {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}}};
|
||||
GRN_UINT32_INIT(&id_, 0);
|
||||
GRN_UINT32_INIT(&flags_, 0);
|
||||
GRN_UINT32_SET(ctx, &id_, id);
|
||||
|
|
@ -7973,11 +7976,11 @@ grn_obj_get_values(grn_ctx *ctx, grn_obj *obj, grn_id offset, void **values)
|
|||
grn_obj *domain = grn_column_table(ctx, obj);
|
||||
if (domain) {
|
||||
int table_size = (int)grn_table_size(ctx, domain);
|
||||
if (0 < offset && offset <= table_size) {
|
||||
if (0 < offset && offset <= (grn_id) table_size) {
|
||||
grn_ra *ra = (grn_ra *)obj;
|
||||
void *p = grn_ra_ref(ctx, ra, offset);
|
||||
if (p) {
|
||||
if ((offset >> ra->element_width) == (table_size >> ra->element_width)) {
|
||||
if ((offset >> ra->element_width) == ((unsigned int) table_size >> ra->element_width)) {
|
||||
nrecords = (table_size & ra->element_mask) + 1 - (offset & ra->element_mask);
|
||||
} else {
|
||||
nrecords = ra->element_mask + 1 - (offset & ra->element_mask);
|
||||
|
|
@ -12578,7 +12581,7 @@ grn_column_find_index_data_column_equal(grn_ctx *ctx, grn_obj *obj,
|
|||
if (n < buf_size) {
|
||||
*ip++ = target;
|
||||
}
|
||||
if (n < n_index_data) {
|
||||
if ((unsigned int) n < n_index_data) {
|
||||
index_data[n].index = target;
|
||||
index_data[n].section = section;
|
||||
}
|
||||
|
|
@ -12640,7 +12643,7 @@ grn_column_find_index_data_column_match(grn_ctx *ctx, grn_obj *obj,
|
|||
if (n < buf_size) {
|
||||
*ip++ = target;
|
||||
}
|
||||
if (n < n_index_data) {
|
||||
if ((unsigned int) n < n_index_data) {
|
||||
index_data[n].index = target;
|
||||
index_data[n].section = section;
|
||||
}
|
||||
|
|
@ -12667,7 +12670,7 @@ grn_column_find_index_data_column_match(grn_ctx *ctx, grn_obj *obj,
|
|||
if (n < buf_size) {
|
||||
*ip++ = target;
|
||||
}
|
||||
if (n < n_index_data) {
|
||||
if ((unsigned int) n < n_index_data) {
|
||||
index_data[n].index = target;
|
||||
index_data[n].section = section;
|
||||
}
|
||||
|
|
@ -12721,7 +12724,7 @@ grn_column_find_index_data_column_range(grn_ctx *ctx, grn_obj *obj,
|
|||
if (n < buf_size) {
|
||||
*ip++ = target;
|
||||
}
|
||||
if (n < n_index_data) {
|
||||
if ((unsigned int) n < n_index_data) {
|
||||
index_data[n].index = target;
|
||||
index_data[n].section = section;
|
||||
}
|
||||
|
|
@ -12956,7 +12959,7 @@ grn_column_find_index_data_accessor_match(grn_ctx *ctx, grn_obj *obj,
|
|||
if (n < buf_size) {
|
||||
*ip++ = target;
|
||||
}
|
||||
if (n < n_index_data) {
|
||||
if ((unsigned int) n < n_index_data) {
|
||||
index_data[n].index = target;
|
||||
index_data[n].section = section;
|
||||
}
|
||||
|
|
@ -12982,7 +12985,7 @@ grn_column_find_index_data_accessor_match(grn_ctx *ctx, grn_obj *obj,
|
|||
if (n < buf_size) {
|
||||
*ip++ = index;
|
||||
}
|
||||
if (n < n_index_data) {
|
||||
if ((unsigned int) n < n_index_data) {
|
||||
index_data[n].index = index;
|
||||
index_data[n].section = section;
|
||||
}
|
||||
|
|
@ -13003,7 +13006,7 @@ grn_column_find_index_data_accessor_match(grn_ctx *ctx, grn_obj *obj,
|
|||
if (n < buf_size) {
|
||||
*ip++ = index;
|
||||
}
|
||||
if (n < n_index_data) {
|
||||
if ((unsigned int) n < n_index_data) {
|
||||
index_data[n].index = index;
|
||||
index_data[n].section = section;
|
||||
}
|
||||
|
|
@ -13614,7 +13617,7 @@ grn_table_sort_key_from_str(grn_ctx *ctx, const char *str, unsigned int str_size
|
|||
grn_rc
|
||||
grn_table_sort_key_close(grn_ctx *ctx, grn_table_sort_key *keys, unsigned int nkeys)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
if (keys) {
|
||||
for (i = 0; i < nkeys; i++) {
|
||||
grn_obj *key = keys[i].key;
|
||||
|
|
@ -14019,7 +14022,7 @@ grn_ctx_merge_temporary_open_space(grn_ctx *ctx)
|
|||
GRN_API_ENTER;
|
||||
|
||||
stack = &(ctx->impl->temporary_open_spaces.stack);
|
||||
if (GRN_BULK_VSIZE(stack) < sizeof(grn_obj) * 2) {
|
||||
if ((unsigned long) GRN_BULK_VSIZE(stack) < (unsigned long) sizeof(grn_obj) * 2) {
|
||||
ERR(GRN_INVALID_ARGUMENT,
|
||||
"[ctx][temporary-open-spaces][merge] "
|
||||
"merge requires at least two spaces");
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ grn_rc grn_tokenizers_init(void);
|
|||
grn_rc grn_tokenizers_fin(void);
|
||||
|
||||
grn_rc grn_db_init_mecab_tokenizer(grn_ctx *ctx);
|
||||
void grn_db_fin_mecab_tokenizer(grn_ctx *ctx);
|
||||
grn_rc grn_db_init_builtin_tokenizers(grn_ctx *ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
2
storage/mroonga/vendor/groonga/lib/proc.c
vendored
2
storage/mroonga/vendor/groonga/lib/proc.c
vendored
|
|
@ -989,7 +989,7 @@ parse_normalize_flags(grn_ctx *ctx, grn_obj *flag_names)
|
|||
}
|
||||
|
||||
#define CHECK_FLAG(name)\
|
||||
if (((names_end - names) >= (sizeof(#name) - 1)) &&\
|
||||
if (((unsigned long) (names_end - names) >= (unsigned long) (sizeof(#name) - 1)) && \
|
||||
(!memcmp(names, #name, sizeof(#name) - 1))) {\
|
||||
flags |= GRN_STRING_ ## name;\
|
||||
names += sizeof(#name) - 1;\
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ grn_proc_column_parse_flags(grn_ctx *ctx,
|
|||
|
||||
#define CHECK_FLAG(name) \
|
||||
name_size = strlen(#name); \
|
||||
if ((end - text) >= name_size && \
|
||||
if ((unsigned long) (end - text) >= (unsigned long) name_size && \
|
||||
memcmp(text, #name, name_size) == 0) { \
|
||||
flags |= GRN_OBJ_ ## name; \
|
||||
text += name_size; \
|
||||
|
|
|
|||
|
|
@ -495,7 +495,7 @@ dump_record(grn_ctx *ctx, grn_dumper *dumper,
|
|||
}
|
||||
}
|
||||
GRN_TEXT_PUTC(ctx, dumper->output, ']');
|
||||
if (GRN_TEXT_LEN(dumper->output) >= DUMP_FLUSH_THRESHOLD_SIZE) {
|
||||
if ((size_t) GRN_TEXT_LEN(dumper->output) >= DUMP_FLUSH_THRESHOLD_SIZE) {
|
||||
grn_ctx_output_flush(ctx, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ sequential_fuzzy_search(grn_ctx *ctx, grn_obj *table, grn_obj *column, grn_obj *
|
|||
key_length = grn_table_get_key(ctx, domain, rid, key_name, GRN_TABLE_MAX_KEY_SIZE);
|
||||
|
||||
if (!prefix_match_size ||
|
||||
(prefix_match_size > 0 && key_length >= prefix_match_size &&
|
||||
(prefix_match_size > 0 && key_length >= (int) prefix_match_size &&
|
||||
!memcmp(sx, key_name, prefix_match_size))) {
|
||||
distance = calc_edit_distance(ctx, sx, ex,
|
||||
key_name, key_name + key_length, flags);
|
||||
|
|
@ -250,7 +250,7 @@ sequential_fuzzy_search(grn_ctx *ctx, grn_obj *table, grn_obj *column, grn_obj *
|
|||
rid = GRN_RECORD_VALUE(&value);
|
||||
key_length = grn_table_get_key(ctx, domain, rid, key_name, GRN_TABLE_MAX_KEY_SIZE);
|
||||
if (!prefix_match_size ||
|
||||
(prefix_match_size > 0 && key_length >= prefix_match_size &&
|
||||
(prefix_match_size > 0 && key_length >= (int) prefix_match_size &&
|
||||
!memcmp(sx, key_name, prefix_match_size))) {
|
||||
distance = calc_edit_distance(ctx, sx, ex,
|
||||
key_name, key_name + key_length, flags);
|
||||
|
|
@ -277,7 +277,7 @@ sequential_fuzzy_search(grn_ctx *ctx, grn_obj *table, grn_obj *column, grn_obj *
|
|||
grn_obj_unlink(ctx, &value);
|
||||
|
||||
for (i = 0; i < heap->n_entries; i++) {
|
||||
if (max_expansion > 0 && i >= max_expansion) {
|
||||
if (max_expansion > 0 && (uint32_t) i >= max_expansion) {
|
||||
break;
|
||||
}
|
||||
{
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ grn_parse_table_group_calc_types(grn_ctx *ctx,
|
|||
}
|
||||
|
||||
#define CHECK_TABLE_GROUP_CALC_TYPE(name)\
|
||||
if (((calc_types_end - calc_types) >= (sizeof(#name) - 1)) &&\
|
||||
if (((unsigned long) (calc_types_end - calc_types) >= (unsigned long) (sizeof(#name) - 1)) && \
|
||||
(!memcmp(calc_types, #name, sizeof(#name) - 1))) {\
|
||||
flags |= GRN_TABLE_GROUP_CALC_ ## name;\
|
||||
calc_types += sizeof(#name) - 1;\
|
||||
|
|
@ -577,7 +577,7 @@ grn_columns_collect(grn_ctx *ctx,
|
|||
while (grn_table_cursor_next(ctx, cursor)) {
|
||||
void *key;
|
||||
char *variable_name;
|
||||
int variable_name_len;
|
||||
unsigned int variable_name_len;
|
||||
char *column_name;
|
||||
size_t column_name_len;
|
||||
void *value_raw;
|
||||
|
|
@ -1057,7 +1057,7 @@ grn_proc_expr_query_flags_parse(grn_ctx *ctx,
|
|||
}
|
||||
|
||||
#define CHECK_EXPR_FLAG(name) \
|
||||
if (((query_flags_end - query_flags) >= (sizeof(#name) - 1)) && \
|
||||
if (((unsigned long) (query_flags_end - query_flags) >= (unsigned long) (sizeof(#name) - 1)) && \
|
||||
(memcmp(query_flags, #name, sizeof(#name) - 1) == 0) && \
|
||||
(((query_flags_end - query_flags) == (sizeof(#name) - 1)) || \
|
||||
(query_flags[sizeof(#name) - 1] == '|') || \
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ command_table_create_parse_flags(grn_ctx *ctx,
|
|||
|
||||
#define CHECK_FLAG(name) \
|
||||
name_size = strlen(#name); \
|
||||
if ((end - nptr) >= name_size && \
|
||||
if ((unsigned long) (end - nptr) >= (unsigned long) name_size && \
|
||||
memcmp(nptr, #name, name_size) == 0) { \
|
||||
flags |= GRN_OBJ_ ## name; \
|
||||
nptr += name_size; \
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ parse_tokenize_flags(grn_ctx *ctx, grn_obj *flag_names)
|
|||
}
|
||||
|
||||
#define CHECK_FLAG(name)\
|
||||
if (((names_end - names) >= (sizeof(#name) - 1)) &&\
|
||||
if (((unsigned long) (names_end - names) >= (unsigned long) (sizeof(#name) - 1)) &&\
|
||||
(!memcmp(names, #name, sizeof(#name) - 1))) {\
|
||||
flags |= GRN_TOKEN_CURSOR_ ## name;\
|
||||
names += sizeof(#name) - 1;\
|
||||
|
|
|
|||
9
storage/mroonga/vendor/groonga/lib/store.c
vendored
9
storage/mroonga/vendor/groonga/lib/store.c
vendored
|
|
@ -349,7 +349,7 @@ static grn_ja *
|
|||
_grn_ja_create(grn_ctx *ctx, grn_ja *ja, const char *path,
|
||||
unsigned int max_element_size, uint32_t flags)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
grn_io *io;
|
||||
struct grn_ja_header *header;
|
||||
struct grn_ja_header_v2 *header_v2;
|
||||
|
|
@ -689,7 +689,7 @@ grn_ja_replace(grn_ctx *ctx, grn_ja *ja, grn_id id,
|
|||
return ctx->rc;
|
||||
}
|
||||
if (*pseg == JA_ESEG_VOID) {
|
||||
int i = 0;
|
||||
unsigned int i = 0;
|
||||
while (SEGMENTS_AT(ja, i)) {
|
||||
if (++i >= JA_N_DSEGMENTS) {
|
||||
ERR(GRN_NOT_ENOUGH_SPACE, "grn_ja file (%s) is full", ja->io->path);
|
||||
|
|
@ -750,8 +750,9 @@ grn_ja_alloc(grn_ctx *ctx, grn_ja *ja, grn_id id,
|
|||
iw->tiny_p = 0;
|
||||
if (grn_io_lock(ctx, ja->io, grn_lock_timeout)) { return ctx->rc; }
|
||||
if (element_size + sizeof(grn_id) > JA_SEGMENT_SIZE) {
|
||||
int i, j, n = (element_size + JA_SEGMENT_SIZE - 1) >> GRN_JA_W_SEGMENT;
|
||||
for (i = 0, j = -1; i < JA_N_DSEGMENTS; i++) {
|
||||
uint i;
|
||||
int j, n = (element_size + JA_SEGMENT_SIZE - 1) >> GRN_JA_W_SEGMENT;
|
||||
for (i = 0, j = -1; i < JA_N_DSEGMENTS; i++) {
|
||||
if (SEGMENTS_AT(ja, i)) {
|
||||
j = i;
|
||||
} else {
|
||||
|
|
|
|||
30
storage/mroonga/vendor/groonga/lib/tokenizers.c
vendored
30
storage/mroonga/vendor/groonga/lib/tokenizers.c
vendored
|
|
@ -797,6 +797,36 @@ grn_db_init_mecab_tokenizer(grn_ctx *ctx)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
grn_db_fin_mecab_tokenizer(grn_ctx *ctx)
|
||||
{
|
||||
switch (GRN_CTX_GET_ENCODING(ctx)) {
|
||||
case GRN_ENC_EUC_JP :
|
||||
case GRN_ENC_UTF8 :
|
||||
case GRN_ENC_SJIS :
|
||||
#if defined(GRN_EMBEDDED) && defined(GRN_WITH_MECAB)
|
||||
{
|
||||
GRN_PLUGIN_DECLARE_FUNCTIONS(tokenizers_mecab);
|
||||
GRN_PLUGIN_IMPL_NAME_TAGGED(fin, tokenizers_mecab)(ctx);
|
||||
}
|
||||
#else /* defined(GRN_EMBEDDED) && defined(GRN_WITH_MECAB) */
|
||||
{
|
||||
const char *mecab_plugin_name = "tokenizers/mecab";
|
||||
char *path;
|
||||
path = grn_plugin_find_path(ctx, mecab_plugin_name);
|
||||
if (path) {
|
||||
GRN_FREE(path);
|
||||
grn_plugin_unregister(ctx, mecab_plugin_name);
|
||||
}
|
||||
}
|
||||
#endif /* defined(GRN_EMBEDDED) && defined(GRN_WITH_MECAB) */
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#define DEF_TOKENIZER(name, init, next, fin, vars)\
|
||||
(grn_proc_create(ctx, (name), (sizeof(name) - 1),\
|
||||
GRN_PROC_TOKENIZER, (init), (next), (fin), 3, (vars)))
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ func_string_substring(grn_ctx *ctx, int n_args, grn_obj **args,
|
|||
start = p;
|
||||
} else {
|
||||
unsigned int char_length = 0;
|
||||
size_t n_chars = 0;
|
||||
int64_t n_chars = 0;
|
||||
|
||||
for (;
|
||||
p < end && (char_length = grn_charlen(ctx, p, end));
|
||||
|
|
@ -252,7 +252,7 @@ func_string_substring(grn_ctx *ctx, int n_args, grn_obj **args,
|
|||
|
||||
if (start && length > 0) {
|
||||
unsigned int char_length = 0;
|
||||
size_t n_chars = 0;
|
||||
int64_t n_chars = 0;
|
||||
|
||||
for (;
|
||||
p < end && (char_length = grn_charlen(ctx, p, end));
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
static unsigned int sole_mecab_init_counter = 0;
|
||||
static mecab_t *sole_mecab = NULL;
|
||||
static grn_plugin_mutex *sole_mecab_mutex = NULL;
|
||||
static grn_encoding sole_mecab_encoding = GRN_ENC_NONE;
|
||||
|
|
@ -563,6 +564,11 @@ check_mecab_dictionary_encoding(grn_ctx *ctx)
|
|||
grn_rc
|
||||
GRN_PLUGIN_INIT(grn_ctx *ctx)
|
||||
{
|
||||
++sole_mecab_init_counter;
|
||||
if (sole_mecab_init_counter > 1)
|
||||
{
|
||||
return GRN_SUCCESS;
|
||||
}
|
||||
{
|
||||
char env[GRN_ENV_BUFFER_SIZE];
|
||||
|
||||
|
|
@ -636,6 +642,11 @@ GRN_PLUGIN_REGISTER(grn_ctx *ctx)
|
|||
grn_rc
|
||||
GRN_PLUGIN_FIN(grn_ctx *ctx)
|
||||
{
|
||||
--sole_mecab_init_counter;
|
||||
if (sole_mecab_init_counter > 0)
|
||||
{
|
||||
return GRN_SUCCESS;
|
||||
}
|
||||
if (sole_mecab) {
|
||||
mecab_destroy(sole_mecab);
|
||||
sole_mecab = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue