summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--heap/hp_extra.c33
-rw-r--r--include/my_base.h7
-rw-r--r--myisam/mi_extra.c31
3 files changed, 70 insertions, 1 deletions
diff --git a/heap/hp_extra.c b/heap/hp_extra.c
index 46e3f529f34..dd41d6c5f19 100644
--- a/heap/hp_extra.c
+++ b/heap/hp_extra.c
@@ -21,6 +21,10 @@
#include "heapdef.h"
+static void heap_extra_keyflag(register HP_INFO *info,
+ enum ha_extra_function function);
+
+
/* set extra flags for database */
int heap_extra(register HP_INFO *info, enum ha_extra_function function)
@@ -41,8 +45,37 @@ int heap_extra(register HP_INFO *info, enum ha_extra_function function)
case HA_EXTRA_READCHECK:
info->opt_flag|= READ_CHECK_USED;
break;
+ case HA_EXTRA_CHANGE_KEY_TO_UNIQUE:
+ case HA_EXTRA_CHANGE_KEY_TO_DUP:
+ heap_extra_keyflag(info, function);
+ break;
default:
break;
}
DBUG_RETURN(0);
} /* heap_extra */
+
+
+/*
+ Start/Stop Inserting Duplicates Into a Table, WL#1648.
+ */
+static void heap_extra_keyflag(register HP_INFO *info,
+ enum ha_extra_function function)
+{
+ uint idx;
+
+ for (idx= 0; idx< info->s->keys; idx++)
+ {
+ switch (function) {
+ case HA_EXTRA_CHANGE_KEY_TO_UNIQUE:
+ info->s->keydef[idx].flag|= HA_NOSAME;
+ break;
+ case HA_EXTRA_CHANGE_KEY_TO_DUP:
+ info->s->keydef[idx].flag&= ~(HA_NOSAME);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
diff --git a/include/my_base.h b/include/my_base.h
index cfdab6a49ba..d23a70b8a55 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -141,7 +141,12 @@ enum ha_extra_function {
HA_EXTRA_RETRIEVE_PRIMARY_KEY,
HA_EXTRA_PREPARE_FOR_DELETE,
HA_EXTRA_PREPARE_FOR_UPDATE, /* Remove read cache if problems */
- HA_EXTRA_PRELOAD_BUFFER_SIZE /* Set buffer size for preloading */
+ HA_EXTRA_PRELOAD_BUFFER_SIZE, /* Set buffer size for preloading */
+ /*
+ On-the-fly switching between unique and non-unique key inserting.
+ */
+ HA_EXTRA_CHANGE_KEY_TO_UNIQUE,
+ HA_EXTRA_CHANGE_KEY_TO_DUP
};
/* The following is parameter to ha_panic() */
diff --git a/myisam/mi_extra.c b/myisam/mi_extra.c
index ce072d7d57e..4b011ca424f 100644
--- a/myisam/mi_extra.c
+++ b/myisam/mi_extra.c
@@ -19,6 +19,9 @@
#include <sys/mman.h>
#endif
+static void mi_extra_keyflag(MI_INFO *info, enum ha_extra_function function);
+
+
/*
Set options and buffers to optimize table handling
@@ -355,6 +358,10 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
case HA_EXTRA_PRELOAD_BUFFER_SIZE:
info->preload_buff_size= *((ulong *) extra_arg);
break;
+ case HA_EXTRA_CHANGE_KEY_TO_UNIQUE:
+ case HA_EXTRA_CHANGE_KEY_TO_DUP:
+ mi_extra_keyflag(info, function);
+ break;
case HA_EXTRA_KEY_CACHE:
case HA_EXTRA_NO_KEY_CACHE:
default:
@@ -367,3 +374,27 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
}
DBUG_RETURN(error);
} /* mi_extra */
+
+
+/*
+ Start/Stop Inserting Duplicates Into a Table, WL#1648.
+ */
+static void mi_extra_keyflag(MI_INFO *info, enum ha_extra_function function)
+{
+ uint idx;
+
+ for (idx= 0; idx< info->s->base.keys; idx++)
+ {
+ switch (function) {
+ case HA_EXTRA_CHANGE_KEY_TO_UNIQUE:
+ info->s->keyinfo[idx].flag|= HA_NOSAME;
+ break;
+ case HA_EXTRA_CHANGE_KEY_TO_DUP:
+ info->s->keyinfo[idx].flag&= ~(HA_NOSAME);
+ break;
+ default:
+ break;
+ }
+ }
+}
+