Commit 7216c3b2 authored by ingo@mysql.com's avatar ingo@mysql.com

WL#1648 - Start/Stop Inserting Duplicates Into a Table

parent 1e0ccbd9
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
#include "heapdef.h" #include "heapdef.h"
static void heap_extra_keyflag(register HP_INFO *info,
enum ha_extra_function function);
/* set extra flags for database */ /* set extra flags for database */
int heap_extra(register HP_INFO *info, enum ha_extra_function function) 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) ...@@ -41,8 +45,37 @@ int heap_extra(register HP_INFO *info, enum ha_extra_function function)
case HA_EXTRA_READCHECK: case HA_EXTRA_READCHECK:
info->opt_flag|= READ_CHECK_USED; info->opt_flag|= READ_CHECK_USED;
break; break;
case HA_EXTRA_CHANGE_KEY_TO_UNIQUE:
case HA_EXTRA_CHANGE_KEY_TO_DUP:
heap_extra_keyflag(info, function);
break;
default: default:
break; break;
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} /* heap_extra */ } /* 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;
}
}
}
...@@ -141,7 +141,12 @@ enum ha_extra_function { ...@@ -141,7 +141,12 @@ enum ha_extra_function {
HA_EXTRA_RETRIEVE_PRIMARY_KEY, HA_EXTRA_RETRIEVE_PRIMARY_KEY,
HA_EXTRA_PREPARE_FOR_DELETE, HA_EXTRA_PREPARE_FOR_DELETE,
HA_EXTRA_PREPARE_FOR_UPDATE, /* Remove read cache if problems */ 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() */ /* The following is parameter to ha_panic() */
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
#include <sys/mman.h> #include <sys/mman.h>
#endif #endif
static void mi_extra_keyflag(MI_INFO *info, enum ha_extra_function function);
/* /*
Set options and buffers to optimize table handling 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) ...@@ -355,6 +358,10 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
case HA_EXTRA_PRELOAD_BUFFER_SIZE: case HA_EXTRA_PRELOAD_BUFFER_SIZE:
info->preload_buff_size= *((ulong *) extra_arg); info->preload_buff_size= *((ulong *) extra_arg);
break; 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_KEY_CACHE:
case HA_EXTRA_NO_KEY_CACHE: case HA_EXTRA_NO_KEY_CACHE:
default: default:
...@@ -367,3 +374,27 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) ...@@ -367,3 +374,27 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
} }
DBUG_RETURN(error); DBUG_RETURN(error);
} /* mi_extra */ } /* 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;
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment