null+****@clear*****
null+****@clear*****
2011年 11月 22日 (火) 14:11:02 JST
Kouhei Sutou 2011-11-22 05:11:02 +0000 (Tue, 22 Nov 2011)
New Revision: 838851d6d29f90f47d4e510c353ddc3b47c560ac
Log:
fix columns aren't renamed bug in grn_table_rename(). fixes #1167
Modified files:
lib/db.c
test/unit/core/test-rename.c
Modified: lib/db.c (+5 -5)
===================================================================
--- lib/db.c 2011-11-22 04:57:48 +0000 (3780916)
+++ lib/db.c 2011-11-22 05:11:02 +0000 (dd15d26)
@@ -6186,11 +6186,11 @@ grn_table_rename(grn_ctx *ctx, grn_obj *table, const char *name, unsigned name_s
GRN_API_ENTER;
if (GRN_OBJ_TABLEP(table) && DB_OBJ(table)->id &&
!(DB_OBJ(table)->id & GRN_OBJ_TMP_OBJECT)) {
- if (!(rc = grn_obj_rename(ctx, table, name, name_size))) {
- grn_hash *cols;
- if ((cols = grn_hash_create(ctx, NULL, sizeof(grn_id), 0,
- GRN_OBJ_TABLE_HASH_KEY|GRN_HASH_TINY))) {
- if (grn_table_columns(ctx, table, "", 0, (grn_obj *)cols)) {
+ grn_hash *cols;
+ if ((cols = grn_hash_create(ctx, NULL, sizeof(grn_id), 0,
+ GRN_OBJ_TABLE_HASH_KEY|GRN_HASH_TINY))) {
+ if (grn_table_columns(ctx, table, "", 0, (grn_obj *)cols)) {
+ if (!(rc = grn_obj_rename(ctx, table, name, name_size))) {
grn_id *key;
char fullname[GRN_PAT_MAX_KEY_SIZE];
memcpy(fullname, name, name_size);
Modified: test/unit/core/test-rename.c (+1 -3)
===================================================================
--- test/unit/core/test-rename.c 2011-11-22 04:57:48 +0000 (6c163cf)
+++ test/unit/core/test-rename.c 2011-11-22 05:11:02 +0000 (40a3831)
@@ -87,8 +87,6 @@ test_table(void)
{
const gchar *actual;
- cut_omit("grn_table_rename() isn't implemented yet.");
-
assert_send_commands("table_create Sites TABLE_PAT_KEY ShortText\n"
"column_create Sites link COLUMN_SCALAR Sites\n"
"load --table Sites\n"
@@ -115,7 +113,7 @@ test_table(void)
cut_assert_equal_string("[[[3],"
"[[\"_id\",\"UInt32\"],"
"[\"_key\",\"ShortText\"],"
- "[\"link\",\"Sites\"]],"
+ "[\"link\",\"URLs\"]],"
"[1,\"groonga.org\",\"razil.jp\"],"
"[3,\"qwik.jp/senna/\",\"\"],"
"[2,\"razil.jp\",\"qwik.jp/senna/\"]]]",