[Groonga-mysql-commit] mroonga/mroonga at 5b496ba [master] storage: work primary key update check for multiple column primary key again

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Feb 2 17:16:41 JST 2017


Kouhei Sutou	2017-02-02 17:16:41 +0900 (Thu, 02 Feb 2017)

  New Revision: 5b496ba02d8d003e875c7d833e5d3975dfdb08fc
  https://github.com/mroonga/mroonga/commit/5b496ba02d8d003e875c7d833e5d3975dfdb08fc

  Message:
    storage: work primary key update check for multiple column primary key again

  Modified files:
    ha_mroonga.cpp

  Modified: ha_mroonga.cpp (+18 -12)
===================================================================
--- ha_mroonga.cpp    2017-02-02 11:10:59 +0900 (0977dd9)
+++ ha_mroonga.cpp    2017-02-02 17:16:41 +0900 (7661776)
@@ -6468,7 +6468,7 @@ int ha_mroonga::storage_update_row(const uchar *old_data, uchar *new_data)
       bool is_pkey = false;
       bool on_duplicate_key_update =
         (inserting_with_update && ignoring_duplicated_key);
-      if (pkey_info && on_duplicate_key_update) {
+      if (pkey_info && !on_duplicate_key_update) {
         for (j = 0; j < KEY_N_KEY_PARTS(pkey_info); j++) {
           Field *pkey_field = pkey_info->key_part[j].field;
           if (strcmp(pkey_field->field_name, column_name.c_str()) == 0) {
@@ -6480,17 +6480,23 @@ int ha_mroonga::storage_update_row(const uchar *old_data, uchar *new_data)
 
       generic_store_bulk(field, &colbuf);
       if (is_pkey) {
-        char key[GRN_TABLE_MAX_KEY_SIZE];
-        int key_size;
-        key_size = grn_table_get_key(ctx,
-                                     grn_table,
-                                     record_id,
-                                     &key,
-                                     GRN_TABLE_MAX_KEY_SIZE);
-        bool is_same_value =
-          (GRN_BULK_VSIZE(&colbuf) == key_size &&
-           memcmp(key, GRN_BULK_HEAD(&colbuf), key_size) == 0);
-        if (!is_same_value && replacing_) {
+        bool is_multiple_column_index = KEY_N_KEY_PARTS(pkey_info) > 1;
+        bool is_same_value;
+        if (is_multiple_column_index) {
+          is_same_value = false;
+        } else {
+          char key[GRN_TABLE_MAX_KEY_SIZE];
+          int key_size;
+          key_size = grn_table_get_key(ctx,
+                                       grn_table,
+                                       record_id,
+                                       &key,
+                                       GRN_TABLE_MAX_KEY_SIZE);
+          is_same_value =
+            (GRN_BULK_VSIZE(&colbuf) == key_size &&
+             memcmp(key, GRN_BULK_HEAD(&colbuf), key_size) == 0);
+        }
+        if (!is_same_value && !replacing_) {
           char message[MRN_BUFFER_SIZE];
           snprintf(message, MRN_BUFFER_SIZE,
                    "data truncated for primary key column: <%s>",
-------------- next part --------------
HTML����������������������������...
다운로드 



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