Re: [Maria-developers] GSoC 2016:Unique indexes for blobs

2016-03-15 Thread Sachin Setia
Hello everyone
@Shubham
As  I said i am just prototyping
This is not the final code
It is just poc to see whether if I send some unique key will mi_create work
fine or not as it is working fine in create_internal_tmp_table on following
query "select distinct(a2) from tbl"  where schema of tbl will be a1 int
primary key ,a2 blob

On Wed, Mar 16, 2016 at 9:18 AM, Shubham Barai 
wrote:

> Hello, Sergie!
>  I  tried to explore the source code from
> mi_create.c,ha_myisam.cc,sql/sql_table.cc,include/myisam.h,.and some
> other files.
> The main task is to create  MI_UNIQUEDEF "uniques" for long unique
> constraints.
> We have to consider all the cases where we need to create MI_UNIQUEDEF
> instead of MI_KEYDEF.
>
> It will include queries like
>create table table1 (blob_column blob,unique(blob_column) );
>create table table1 (a int,blob_column
> blob,unique(a,blob_column) );
>create table table1 (a int,blob_column1 blob,blob_column2
> blob,unique(blob_column1(300),blob_column2) );
> (key with multiple blob columns and one of the blob column specified with
> prefix length).
>
> I think we have to create  MI_UNIQUEDEF if any one of the columns in a
> key is a blob field without  prefix length.
>
> In sql/sql_table, mysql_prepare_create_table is the function which
> prepares the table and key structures for table creation in mi_create. It
> generates an error if any one of the blob fields in a key is specified
> without length.
> Currently, this task is limited to MyISAM, so if any other storage engine
> is selected, we have to generate the same error in
> mysql_prepare_create_table.
>
> In storage/myisam/ha_myisam.cc, table2myisam is a function which allocates
> and initializes myisam key and column definitions.The current function
> prototype of table2myisam is
>table2myisam(TABLE  *table_arg, MI_KEYDEF  **keydef_out,
> MI_COLUMNDEF **recinfo_out, uint records_out)
> We have to change it to
>table2myisam(TABLE  *table_arg,MI_KEYDEF  **keydef_out,MI_UNIQUEDEF **
> uniquedef_out,MI_COLUMNDEF  **recinfo_out,uint records_out)
>
> table2myisam initializes all the key definitions from table_arg->keyinfo.
> So we can  set  a new flag  (say uniquedef) in a keyinfo struct in
> mysql_prepare_create_table if any one of the key_part consists of blob
> field without prefix length.
> Later we can check the flag in table2myisam to see  if we want to create
> MI_KEYDEF or MI_UNIQUEDEF.
>
> Thanks,
> Shubham.
>
> On 5 March 2016 at 03:52, Sergei Golubchik  wrote:
>
>> Hi, Shubham!
>>
>> On Mar 03, Shubham Barai wrote:
>> >
>> > I am interested in the project "Unique indexes for blobs".I have read
>> the
>> > description of the project given on the link
>> > https://jira.mariadb.org/browse/MDEV-371.
>>
>> Great!
>>
>> > I want to know what exactly is the task for this project.Any help
>> > would be greatly appreciated
>>
>> See storage/myisam/mi_create.c. You see that a myisam table can have
>> keys (defined in MI_KEYDEF structure) and so-called "uniques" (defined
>> by MI_UNIQUEDEF).
>>
>> Keys have length limitation, keys can be unique (HA_NOSAME flag) or not
>> unique.
>>
>> "uniques" have no length limitation.
>>
>> When one creates a unique key from SQL:
>>
>>   CREATE TABLE ... (... UNIQUE KEY (...) ... )
>>
>> this will always create a key (MI_KEYDEF) in a MyISAM table. That's why
>> unique constraints in MyISAM have a limited length.
>>
>> This task is about creating MI_UNIQUEDEF "uniques" instead of MI_KEYDEF
>> "keys" for long unique constraints.
>>
>> Regards,
>> Sergei
>> Chief Architect MariaDB
>> and secur...@mariadb.org
>>
>
>
> ___
> Mailing list: https://launchpad.net/~maria-developers
> Post to : maria-developers@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~maria-developers
> More help   : https://help.launchpad.net/ListHelp
>
>
___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp


Re: [Maria-developers] GSoC 2016:Unique indexes for blobs

2016-03-15 Thread Shubham Barai
Hello, Sergie!
 I  tried to explore the source code from
mi_create.c,ha_myisam.cc,sql/sql_table.cc,include/myisam.h,.and some other
files.
The main task is to create  MI_UNIQUEDEF "uniques" for long unique
constraints.
We have to consider all the cases where we need to create MI_UNIQUEDEF
instead of MI_KEYDEF.

It will include queries like
   create table table1 (blob_column blob,unique(blob_column) );
   create table table1 (a int,blob_column
blob,unique(a,blob_column) );
   create table table1 (a int,blob_column1 blob,blob_column2
blob,unique(blob_column1(300),blob_column2) );
(key with multiple blob columns and one of the blob column specified with
prefix length).

I think we have to create  MI_UNIQUEDEF if any one of the columns in a key
is a blob field without  prefix length.

In sql/sql_table, mysql_prepare_create_table is the function which prepares
the table and key structures for table creation in mi_create. It generates
an error if any one of the blob fields in a key is specified without length.
Currently, this task is limited to MyISAM, so if any other storage engine
is selected, we have to generate the same error in
mysql_prepare_create_table.

In storage/myisam/ha_myisam.cc, table2myisam is a function which allocates
and initializes myisam key and column definitions.The current function
prototype of table2myisam is
   table2myisam(TABLE  *table_arg, MI_KEYDEF  **keydef_out,
MI_COLUMNDEF **recinfo_out, uint records_out)
We have to change it to
   table2myisam(TABLE  *table_arg,MI_KEYDEF  **keydef_out,MI_UNIQUEDEF **
uniquedef_out,MI_COLUMNDEF  **recinfo_out,uint records_out)

table2myisam initializes all the key definitions from table_arg->keyinfo.
So we can  set  a new flag  (say uniquedef) in a keyinfo struct in
mysql_prepare_create_table if any one of the key_part consists of blob
field without prefix length.
Later we can check the flag in table2myisam to see  if we want to create
MI_KEYDEF or MI_UNIQUEDEF.

Thanks,
Shubham.

On 5 March 2016 at 03:52, Sergei Golubchik  wrote:

> Hi, Shubham!
>
> On Mar 03, Shubham Barai wrote:
> >
> > I am interested in the project "Unique indexes for blobs".I have read the
> > description of the project given on the link
> > https://jira.mariadb.org/browse/MDEV-371.
>
> Great!
>
> > I want to know what exactly is the task for this project.Any help
> > would be greatly appreciated
>
> See storage/myisam/mi_create.c. You see that a myisam table can have
> keys (defined in MI_KEYDEF structure) and so-called "uniques" (defined
> by MI_UNIQUEDEF).
>
> Keys have length limitation, keys can be unique (HA_NOSAME flag) or not
> unique.
>
> "uniques" have no length limitation.
>
> When one creates a unique key from SQL:
>
>   CREATE TABLE ... (... UNIQUE KEY (...) ... )
>
> this will always create a key (MI_KEYDEF) in a MyISAM table. That's why
> unique constraints in MyISAM have a limited length.
>
> This task is about creating MI_UNIQUEDEF "uniques" instead of MI_KEYDEF
> "keys" for long unique constraints.
>
> Regards,
> Sergei
> Chief Architect MariaDB
> and secur...@mariadb.org
>
___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp


Re: [Maria-developers] Gsoc 2016 Mdev 371 Unique index for blob

2016-03-15 Thread Sachin Setia
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*) ,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, ,
   _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  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 secur...@mariadb.org
>
___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp


Re: [Maria-developers] Gsoc 2016 Mdev 371 Unique index for blob

2016-03-15 Thread Sergei Golubchik
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 secur...@mariadb.org

___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp


Re: [Maria-developers] Gsoc 2016 Mdev 371 Unique index for blob

2016-03-15 Thread Sachin Setia
Sorry one correction
@-- I am assuming that unique blob will have 0 zero key
@++ I am assuming that unique blob will have 0 zero key length
Regards
sachin

On Tue, Mar 15, 2016 at 11:02 PM, Sachin Setia 
wrote:

> Dear Developers,
>
> 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'
> MariaDB [sachin]> insert into tbl values(2,2);
> Query OK, 1 row affected (0.00 sec)
>
> MariaDB [sachin]> insert into tbl values(3,3);
> Query OK, 1 row affected (0.00 sec)
>
> MariaDB [sachin]> select * from tbl;
> +-+--+
> | int_key | blob_key |
> +-+--+
> |   1 | 1|
> |   2 | 2|
> |   3 | 3|
> +-+--+
> 3 rows in set (0.00 sec)
>
>
> I am assuming that unique blob will have 0 zero key .
> Should i mail you the source code.Please let me know
> Regards
> sachin
>
___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp


[Maria-developers] Gsoc 2016 Mdev 371 Unique index for blob

2016-03-15 Thread Sachin Setia
Dear Developers,

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'
MariaDB [sachin]> insert into tbl values(2,2);
Query OK, 1 row affected (0.00 sec)

MariaDB [sachin]> insert into tbl values(3,3);
Query OK, 1 row affected (0.00 sec)

MariaDB [sachin]> select * from tbl;
+-+--+
| int_key | blob_key |
+-+--+
|   1 | 1|
|   2 | 2|
|   3 | 3|
+-+--+
3 rows in set (0.00 sec)


I am assuming that unique blob will have 0 zero key .
Should i mail you the source code.Please let me know
Regards
sachin
___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp


[Maria-developers] NO PAD Collation for MariaDB

2016-03-15 Thread Melissa Rose
Hello everyone,

I am Melisa Rose from University of Leeds UK and I wish to contribute to
MariaDB under GSoC 2016. I am interested in the project involving adding NO
PAD collations to default character sets(MDEV-9711
).
Apparently, this project does not require thorough understanding of the
Server Internal code and the Instructions highlighted by Alexander Barkov
on how to implement this are straight forward.
I will be submitting a proposal for this project hoping i'm linked to the
assigned mentor soon.
Look forward to an awesome summer with MariaDB.

Kind regards,
Melisa Rose.
___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp


Re: [Maria-developers] Gsoc 2016 Mdev 371 Unique index for blob

2016-03-15 Thread Sergei Golubchik
Hi, Sachin!

First: please send questions like this to maria-developers@lists.launchpad.net
it's a public mailing list dedicated to MySQL and MariaDB internals, source
code, and related things. I am subscribed, so I'll see you mail there, and you
may be sure I will, because it won't be accidentally catched by my spam filter,
or sorted out in some obscure folder. Furthermore other subscribers will see
your question and could reply if I will be not available (e.g. I could be
travelling).
Thank you.

On Mar 14, Sachin Setia wrote:
> Thank you sir for your reply but my question is what this pack flag will do
> and basically what is pack record will you please suggest source file in
> which i can look into to get more understanding of pack length ,pack flag
> and pack record

There isn't much I can answer - your question is too generic.
"pack_flag" is a set of flags that is stored per field in the frm file
and it describes some aspects of the field.

Search for "pack_flag" in the source tree. If you ask a specific
question, I'll be able to provide a more detailed answer.

Regards,
Sergei
Chief Architect MariaDB
and secur...@mariadb.org

___
Mailing list: https://launchpad.net/~maria-developers
Post to : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp