← Back to team overview

maria-developers team mailing list archive

Re: Gsoc 2016 Mdev 371 Unique index for blob

 

Thanks sir for your reply
I have done two thing
1. First commenting some code to remove the error we get when we try to
create unique blob
file=sql/sql_table.cc
line no=3877
/*
* Gsoc 2016
* I am implementing this so comment this stuff out
 */
//  if (!column->length)
//  {
//    my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0), column->field_name.str);
//    DBUG_RETURN(TRUE);
//  }


2. here I am assuming this thing for for just prototyping
Assumption My table will just contain two column first will be primary key
second will be unique blob
So basically what i am doing is create a custom unique key and passing it
to mi_create
Of course in real patching i will replace this code with logic like if i
have m unique blobs (i will find this using key_length ==0)
create m unique key array and pass it

file=storage/myisam/ha_myisam.cc
line no=2067
//some tweak in share for prototype
share->keys--;
share->uniques=1;
MI_UNIQUEDEF uniquedef;
MI_KEYDEF keydef_blob=*(keydef+1);
bzero((char*) &uniquedef,sizeof(uniquedef));
uniquedef.keysegs=1;
uniquedef.seg=keydef_blob.seg;
uniquedef.null_are_equal=1;

  /* TODO: Check that the following fn_format is really needed */
  error= mi_create(fn_format(buff, name, "", "",
                             MY_UNPACK_FILENAME|MY_APPEND_EXT),
                   share->keys, keydef,
                   record_count, recinfo,
                   1, &uniquedef,
                   &create_info, create_flags);

If i am doing it wrongly please let me know
Regards
sachin

On Wed, Mar 16, 2016 at 12:37 AM, Sergei Golubchik <serg@xxxxxxxxxxx> wrote:

> Hi, Sachin!
>
> On Mar 15, Sachin Setia wrote:
> >
> > I was doing prototype for this project as Mr Sergei Golubchik suggested
> >
> > "This task is about creating MI_UNIQUEDEF "uniques" instead of MI_KEYDEF
> > "keys" for long unique constraints."
> >
> > Here is my output
> >
> > MariaDB [sachin]> create table tbl(int_key int primary key , blob_key
> > blob unique);
> > Query OK, 0 rows affected (0.03 sec)
> >
> > MariaDB [sachin]> insert into tbl values(1,1);
> > Query OK, 1 row affected (0.01 sec)
> >
> > MariaDB [sachin]> insert into tbl values(2,1);
> > ERROR 1062 (23000): Duplicate entry '1' for key 'blob_key'
>
> Very cool!
>
> > Should i mail you the source code.Please let me know
> > Regards
> > sachin
>
> Sure! Please, do.
>
> Regards,
> Sergei
> Chief Architect MariaDB
> and security@xxxxxxxxxxx
>

Follow ups

References