null+****@clear*****
null+****@clear*****
2012年 1月 19日 (木) 15:55:06 JST
Kouhei Sutou 2012-01-19 15:55:06 +0900 (Thu, 19 Jan 2012) New Revision: 067346570af6dd06af62bf810e3d6d6471310a80 Log: grn_table_at: support grn_db. Modified files: lib/db.c test/unit/core/test-database.c Modified: lib/db.c (+6 -0) =================================================================== --- lib/db.c 2012-01-19 15:42:45 +0900 (397c752) +++ lib/db.c 2012-01-19 15:55:06 +0900 (16ca5d6) @@ -1312,6 +1312,12 @@ grn_table_at(grn_ctx *ctx, grn_obj *table, grn_id id) GRN_API_ENTER; if (table) { switch (table->header.type) { + case GRN_DB : + { + grn_db *db = (grn_db *)table; + id = grn_table_at(ctx, db->keys, id); + } + break; case GRN_TABLE_PAT_KEY : id = grn_pat_at(ctx, (grn_pat *)table, id); break; Modified: test/unit/core/test-database.c (+10 -0) =================================================================== --- test/unit/core/test-database.c 2012-01-19 15:42:45 +0900 (3c28af4) +++ test/unit/core/test-database.c 2012-01-19 15:55:06 +0900 (3f2cd53) @@ -32,6 +32,7 @@ void test_size(void); void test_expire_cache_on_recreate(void); void test_expression_lifetime_over_database(void); void test_get(void); +void test_at(void); static gchar *tmp_directory; @@ -295,3 +296,12 @@ test_get(void) short_text_type_name, strlen(short_text_type_name))); } + +void +test_at(void) +{ + database = grn_db_create(context, NULL, NULL); + grn_test_assert_equal_id(context, + GRN_DB_SHORT_TEXT, + grn_table_at(context, database, GRN_DB_SHORT_TEXT)); +}