[Groonga-commit] groonga/groonga at e8d3402 [master] table_remove: add a missing type check

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Mar 14 12:34:16 JST 2016


Kouhei Sutou	2016-03-14 12:34:16 +0900 (Mon, 14 Mar 2016)

  New Revision: e8d34024f9f65a46fe431e1ed0032e487d51689b
  https://github.com/groonga/groonga/commit/e8d34024f9f65a46fe431e1ed0032e487d51689b

  Message:
    table_remove: add a missing type check

  Added files:
    test/command/suite/table_remove/invalid/not_table.expected
    test/command/suite/table_remove/invalid/not_table.test
  Modified files:
    lib/proc/proc_table.c

  Modified: lib/proc/proc_table.c (+12 -1)
===================================================================
--- lib/proc/proc_table.c    2016-03-14 11:14:54 +0900 (4f7d38d)
+++ lib/proc/proc_table.c    2016-03-14 12:34:16 +0900 (68508ff)
@@ -481,7 +481,18 @@ command_table_remove(grn_ctx *ctx,
   table = grn_ctx_get(ctx,
                       GRN_TEXT_VALUE(name),
                       GRN_TEXT_LEN(name));
-  /* TODO: Add a check whether the object is really a table. */
+
+  if (!grn_obj_is_table(ctx, table)) {
+    GRN_PLUGIN_ERROR(ctx,
+                     GRN_INVALID_ARGUMENT,
+                     "[table][remove] not table: <%.*s>: <%s>",
+                     (int)GRN_TEXT_LEN(name),
+                     GRN_TEXT_VALUE(name),
+                     grn_obj_type_to_string(table->header.type));
+    grn_ctx_output_bool(ctx, GRN_FALSE);
+    return NULL;
+  }
+
   if (table) {
     grn_obj_remove(ctx, table);
   } else {

  Added: test/command/suite/table_remove/invalid/not_table.expected (+17 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/table_remove/invalid/not_table.expected    2016-03-14 12:34:16 +0900 (4dd7b9b)
@@ -0,0 +1,17 @@
+table_create Users TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Users age COLUMN_SCALAR UInt8
+[[0,0.0,0.0],true]
+table_remove Users.age
+[
+  [
+    [
+      -22,
+      0.0,
+      0.0
+    ],
+    "[table][remove] not table: <Users.age>: <column:fix_size>"
+  ],
+  false
+]
+#|e| [table][remove] not table: <Users.age>: <column:fix_size>

  Added: test/command/suite/table_remove/invalid/not_table.test (+4 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/table_remove/invalid/not_table.test    2016-03-14 12:34:16 +0900 (cb5679b)
@@ -0,0 +1,4 @@
+table_create Users TABLE_NO_KEY
+column_create Users age COLUMN_SCALAR UInt8
+
+table_remove Users.age
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index