[Groonga-commit] groonga/groonga at af0b7c6 [master] Don't unlink dynamic column in grn_table_sort_key_close

Back to archive index

Naoya Murakami null+****@clear*****
Tue May 10 17:28:26 JST 2016


Naoya Murakami	2016-05-10 17:28:26 +0900 (Tue, 10 May 2016)

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

  Merged fa64f12: Merge pull request #544 from naoa/donot-unlink-dynamic-column-in-sort-key-close

  Message:
    Don't unlink dynamic column in grn_table_sort_key_close

  Added files:
    test/command/suite/select/drilldown/labeled/column/stage/initial/drilldown.expected
    test/command/suite/select/drilldown/labeled/column/stage/initial/drilldown.test
  Modified files:
    lib/db.c

  Modified: lib/db.c (+5 -1)
===================================================================
--- lib/db.c    2016-05-10 16:48:49 +0900 (0558bb2)
+++ lib/db.c    2016-05-10 17:28:26 +0900 (4fb69c4)
@@ -12806,7 +12806,11 @@ grn_table_sort_key_close(grn_ctx *ctx, grn_table_sort_key *keys, unsigned int nk
   int i;
   if (keys) {
     for (i = 0; i < nkeys; i++) {
-      grn_obj_unlink(ctx, keys[i].key);
+      grn_obj *key = keys[i].key;
+      grn_id id = grn_obj_id(ctx, key);
+      if (!(id & GRN_OBJ_TMP_COLUMN)) {
+        grn_obj_unlink(ctx, key);
+      }
     }
     GRN_FREE(keys);
   }

  Added: test/command/suite/select/drilldown/labeled/column/stage/initial/drilldown.expected (+171 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/drilldown/labeled/column/stage/initial/drilldown.expected    2016-05-10 17:28:26 +0900 (7ea69e2)
@@ -0,0 +1,171 @@
+table_create Items TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Items price COLUMN_SCALAR UInt32
+[[0,0.0,0.0],true]
+table_create Shops TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Shops items COLUMN_VECTOR Items
+[[0,0.0,0.0],true]
+load --table Shops
+[
+{"_key": "Stationery store",  "items": ["Book", "Note", "Box", "Pen"]},
+{"_key": "Supermarket",       "items": ["Food", "Drink", "Pen"]},
+{"_key": "Convenience store", "items": ["Pen", "Note","Food", "Drink"]}
+]
+[[0,0.0,0.0],3]
+load --table Items
+[
+{"_key": "Book",  "price": 1000},
+{"_key": "Note",  "price": 1000},
+{"_key": "Box",   "price": 500},
+{"_key": "Pen",   "price": 500},
+{"_key": "Food",  "price": 500},
+{"_key": "Drink", "price": 300}
+]
+[[0,0.0,0.0],6]
+select Shops   --drilldown[label].keys items   --drilldown[label].sortby price   --drilldown[label].output_columns _key,_nsubrecs,price,price_with_tax   --drilldown[label].column[price_with_tax].stage initial   --drilldown[label].column[price_with_tax].type UInt32   --drilldown[label].column[price_with_tax].flags COLUMN_SCALAR   --drilldown[label].column[price_with_tax].value 'price * 1.08'   --drilldown[label2].table label   --drilldown[label2].keys price_with_tax
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        3
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "items",
+          "Items"
+        ]
+      ],
+      [
+        1,
+        "Stationery store",
+        [
+          "Book",
+          "Note",
+          "Box",
+          "Pen"
+        ]
+      ],
+      [
+        2,
+        "Supermarket",
+        [
+          "Food",
+          "Drink",
+          "Pen"
+        ]
+      ],
+      [
+        3,
+        "Convenience store",
+        [
+          "Pen",
+          "Note",
+          "Food",
+          "Drink"
+        ]
+      ]
+    ],
+    {
+      "label": [
+        [
+          6
+        ],
+        [
+          [
+            "_key",
+            "ShortText"
+          ],
+          [
+            "_nsubrecs",
+            "Int32"
+          ],
+          [
+            "price",
+            "UInt32"
+          ],
+          [
+            "price_with_tax",
+            "UInt32"
+          ]
+        ],
+        [
+          "Drink",
+          2,
+          300,
+          324
+        ],
+        [
+          "Food",
+          2,
+          500,
+          540
+        ],
+        [
+          "Pen",
+          3,
+          500,
+          540
+        ],
+        [
+          "Box",
+          1,
+          500,
+          540
+        ],
+        [
+          "Book",
+          1,
+          1000,
+          1080
+        ],
+        [
+          "Note",
+          2,
+          1000,
+          1080
+        ]
+      ],
+      "label2": [
+        [
+          3
+        ],
+        [
+          [
+            "_key",
+            "UInt32"
+          ],
+          [
+            "_nsubrecs",
+            "Int32"
+          ]
+        ],
+        [
+          1080,
+          2
+        ],
+        [
+          540,
+          3
+        ],
+        [
+          324,
+          1
+        ]
+      ]
+    }
+  ]
+]

  Added: test/command/suite/select/drilldown/labeled/column/stage/initial/drilldown.test (+33 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/drilldown/labeled/column/stage/initial/drilldown.test    2016-05-10 17:28:26 +0900 (2586cee)
@@ -0,0 +1,33 @@
+table_create Items TABLE_HASH_KEY ShortText
+column_create Items price COLUMN_SCALAR UInt32
+
+table_create Shops TABLE_HASH_KEY ShortText
+column_create Shops items COLUMN_VECTOR Items
+
+load --table Shops
+[
+{"_key": "Stationery store",  "items": ["Book", "Note", "Box", "Pen"]},
+{"_key": "Supermarket",       "items": ["Food", "Drink", "Pen"]},
+{"_key": "Convenience store", "items": ["Pen", "Note","Food", "Drink"]}
+]
+
+load --table Items
+[
+{"_key": "Book",  "price": 1000},
+{"_key": "Note",  "price": 1000},
+{"_key": "Box",   "price": 500},
+{"_key": "Pen",   "price": 500},
+{"_key": "Food",  "price": 500},
+{"_key": "Drink", "price": 300}
+]
+
+select Shops \
+  --drilldown[label].keys items \
+  --drilldown[label].sortby price \
+  --drilldown[label].output_columns _key,_nsubrecs,price,price_with_tax \
+  --drilldown[label].column[price_with_tax].stage initial \
+  --drilldown[label].column[price_with_tax].type UInt32 \
+  --drilldown[label].column[price_with_tax].flags COLUMN_SCALAR \
+  --drilldown[label].column[price_with_tax].value 'price * 1.08' \
+  --drilldown[label2].table label \
+  --drilldown[label2].keys price_with_tax
-------------- next part --------------
HTML����������������������������...
Download 



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