[groonga-dev,00146] 25バイト以上のテキストに対してGRN_OP_EQUALが動かない

Back to archive index

Kouhei Sutou kou****@clear*****
2009年 7月 30日 (木) 23:22:01 JST


須藤です。

25バイト以上のテキストが入ったカラムに対してg式の
GRN_OP_EQUALがうまく動かないようです。

diff --git a/test/unit/core/test-expr.c b/test/unit/core/test-expr.c
index 26051cd..3eb0265 100644
--- a/test/unit/core/test-expr.c
+++ b/test/unit/core/test-expr.c
@@ -34,6 +34,7 @@ void test_expr_query(void);
 
 void test_table_select_equal(void);
 void test_table_select_equal_indexed(void);
+void test_table_select_equal_longer_than_24_bytes_column(void);
 void test_table_select_equal_table(void);
 void test_table_select_select(void);
 void test_table_select_search(void);
@@ -571,6 +572,41 @@ test_table_select_equal_indexed(void)
 }
 
 void
+test_table_select_equal_longer_than_24_bytes_column(void)
+{
+  grn_obj *cond, *v, *res, textbuf, intbuf;
+  GRN_TEXT_INIT(&textbuf, 0);
+  GRN_UINT32_INIT(&intbuf, 0);
+
+  prepare_data(&textbuf, &intbuf);
+
+  cut_assert_not_null((cond = grn_expr_create(&context, NULL, 0)));
+  v = grn_expr_add_var(&context, cond, NULL, 0);
+  GRN_RECORD_INIT(v, 0, grn_obj_id(&context, docs));
+  grn_expr_append_obj(&context, cond, v);
+  GRN_TEXT_SETS(&context, &textbuf, "body");
+  grn_expr_append_const(&context, cond, &textbuf);
+  grn_expr_append_op(&context, cond, GRN_OP_OBJ_GET_VALUE, 2);
+  GRN_TEXT_SETS(&context, &textbuf, "poyo moge hoge moge moge moge");
+  grn_expr_append_const(&context, cond, &textbuf);
+  grn_expr_append_op(&context, cond, GRN_OP_EQUAL, 2);
+  grn_expr_compile(&context, cond);
+
+  res = grn_table_create(&context, NULL, 0, NULL,
+                         GRN_TABLE_HASH_KEY|GRN_OBJ_WITH_SUBREC, docs, NULL);
+  cut_assert_not_null(res);
+
+  grn_test_assert(grn_table_select(&context, docs, cond, res, GRN_OP_OR));
+
+  cut_assert_equal_uint(1, grn_table_size(&context, res));
+
+  grn_test_assert(grn_obj_close(&context, res));
+  grn_test_assert(grn_obj_close(&context, cond));
+  grn_test_assert(grn_obj_close(&context, &textbuf));
+  grn_test_assert(grn_obj_close(&context, &intbuf));
+}
+
+void
 test_table_select_equal_table(void)
 {
   grn_obj *cond, *v, *res, text_buffer, int_buffer, record_buffer;


-- 
須藤 功平 <kou****@clear*****>
株式会社クリアコード (http://www.clear-code.com/)




groonga-dev メーリングリストの案内
Back to archive index