Sorry wrong extension
Regards
sachin
On Mon, Mar 28, 2016 at 9:09 PM, Sachin Setia
wrote:
> Hello Devlopers
> Hi this is sachin. I applied for gsoc 2016(applied by name sachin setiya)
> My topic was unique index for blob(MyISAM)
> But i already completed some part of it .it is working for blobs varchar
> for definitions like
> create table tbl(abc varchar(2000) , xyz blob ,unique(abc,xyz));
> I have corrected the table2myisam function .
> For documentation you can refer to my gsoc proposal
> If am doing wrong please let me know.
> I am attaching the patch file
> TODO
> Second thing which i need to do is
> to tweak check_definition function to correctly check for definition
> currently I am commenting the function code
> Regards
> sachin
>
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index dfce503..eda9dd6 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -3874,11 +3874,11 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO
*create_info,
if (f_is_geom(sql_field->pack_flag) && sql_field->geom_type ==
Field::GEOM_POINT)
column->length= MAX_LEN_GEOM_POINT_FIELD;
- if (!column->length)
- {
- my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0),
column->field_name.str);
- DBUG_RETURN(TRUE);
- }
+// if (!column->length) //work
+// {
+// my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0),
column->field_name.str);
+// DBUG_RETURN(TRUE);
+// }
}
#ifdef HAVE_SPATIAL
if (key->type == Key::SPATIAL)
@@ -3999,7 +3999,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO
*create_info,
if (key_part_length > file->max_key_part_length() &&
key->type != Key::FULLTEXT)
{
-key_part_length= file->max_key_part_length();
+//key_part_length= file->max_key_part_length(); //work
if (key->type == Key::MULTIPLE)
{
/* not a critical problem */
@@ -4011,8 +4011,13 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO
*create_info,
}
else
{
- my_error(ER_TOO_LONG_KEY, MYF(0), key_part_length);
- DBUG_RETURN(TRUE);
+ if(sql_field->sql_type==MYSQL_TYPE_VARCHAR){
+ //its ok we are going to use hash index
+ }else{
+ key_part_length= file->max_key_part_length();
+ my_error(ER_TOO_LONG_KEY, MYF(0), key_part_length);
+ DBUG_RETURN(TRUE);
+ }
}
}
key_part_info->length= (uint16) key_part_length;
@@ -4070,10 +4075,13 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO
*create_info,
if (key->type == Key::UNIQUE && !(key_info->flags & HA_NULL_PART_KEY))
unique_key=1;
key_info->key_length=(uint16) key_length;
-if (key_length > max_key_length && key->type != Key::FULLTEXT)
+if (key_length > max_key_length && key->type != Key::FULLTEXT
+ &&key->type!=Key::UNIQUE) //one more thing key should be varchar
+ //i frankly do not know how to check it may be FIELDFLAG_MAYBE_NULL
+ //will work //work
{
- my_error(ER_TOO_LONG_KEY,MYF(0),max_key_length);
- DBUG_RETURN(TRUE);
+// my_error(ER_TOO_LONG_KEY,MYF(0),max_key_length);
+// DBUG_RETURN(TRUE);
}
if (validate_comment_length(thd, &key->key_create_info.comment,
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 4284e22..6d6ebcb 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -402,6 +402,362 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out,
DBUG_RETURN(0);
}
+//work
+
+ typedef struct
+{
+ uint uniques; //total number of uniques
+ /*
+ * unique_keys contain array of chars where 1 means key is unique
+ * with zero length
+ * */
+ char * unique_keys;
+} uniques_keys_arr;
+/*
+ * Find unique keys in keys array
+ *
+ * */
+ //working
+static uniques_keys_arr *
+mysql_find_unique_keys(KEY *keys,uint number_of_keys){
+ //DBUG_ENTER("mysql_find_unique_keys");
+ uniques_keys_arr * u_arr = (uniques_keys_arr
*)my_malloc(sizeof(uniques_keys_arr),MYF(MY_WME));
+
+ if(!u_arr)
+ {
+return NULL;
+ }
+
+ u_arr->uniques=0;
+ u_arr->unique_keys = (char
*)my_malloc(sizeof(char)*number_of_keys,MYF(MY_WME));
+ char * temp = u_arr->unique_keys;
+
+ if(!u_arr->unique_keys)
+ {
+return NULL;
+ }
+
+ for(int i=0;i1000) //we need
+ //better logic
+ {
+ *temp=1;
+ u_arr->uniques++;
+ goto get_out;
+ }
+ }
+ get_out:{}
+ temp++;
+ }
+ return u_arr;
+}
+/*
+ Convert TABLE object to MyISAM key and column definition
+
+ SYNOPSIS
+table2myisam_with_uniquedef()
+ table_arg in TABLE object.
+ keydef_out outMyISAM key definition.
+ uniquedef_out out MyISAM unique key defination
+ recin