null+****@clear*****
null+****@clear*****
2011年 8月 28日 (日) 18:11:59 JST
Kouhei Sutou 2011-08-28 09:11:59 +0000 (Sun, 28 Aug 2011)
New Revision: 845595ef8b587826e3a982a9288cf3652f1a77da
Log:
add GRN_CTX_PER_DB flag. fixes #1053
If GRN_CTX_PER_DB=yes environment variable is set,
GRN_CTX_PER_DB flags is set automatically.
Modified files:
include/groonga.h
lib/ctx.c
Modified: include/groonga.h (+1 -0)
===================================================================
--- include/groonga.h 2011-08-21 04:15:28 +0000 (b82525e)
+++ include/groonga.h 2011-08-28 09:11:59 +0000 (724de04)
@@ -206,6 +206,7 @@ struct _grn_ctx {
#define GRN_CTX_USE_QL (0x03)
#define GRN_CTX_BATCH_MODE (0x04)
+#define GRN_CTX_PER_DB (0x08)
GRN_API grn_rc grn_ctx_init(grn_ctx *ctx, int flags);
Modified: lib/ctx.c (+8 -0)
===================================================================
--- lib/ctx.c 2011-08-21 04:15:28 +0000 (e26f7a9)
+++ lib/ctx.c 2011-08-28 09:11:59 +0000 (70d012a)
@@ -532,6 +532,9 @@ grn_ctx_init(grn_ctx *ctx, int flags)
// if (ctx->stat != GRN_CTX_FIN) { return GRN_INVALID_ARGUMENT; }
ERRCLR(ctx);
ctx->flags = flags;
+ if (getenv("GRN_CTX_PER_DB") && strcmp(getenv("GRN_CTX_PER_DB"), "yes") == 0) {
+ ctx->flags |= GRN_CTX_PER_DB;
+ }
ctx->stat = GRN_QL_WAIT_EXPR;
ctx->encoding = grn_gctx.encoding;
ctx->seqno = 0;
@@ -637,6 +640,11 @@ grn_ctx_fin(grn_ctx *ctx)
});
}
grn_hash_close(ctx, ctx->impl->expr_vars);
+ if (ctx->impl->db && ctx->flags & GRN_CTX_PER_DB) {
+ grn_obj *db = ctx->impl->db;
+ ctx->impl->db = NULL;
+ grn_obj_close(ctx, db);
+ }
{
int i;
grn_io_mapinfo *mi;