Bug #8101 unique index and error 4209 while selecting
Submitted: 24 Jan 2005 7:01 Modified: 26 Jan 2005 12:10
Reporter: Abraham Jacob Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:4.1.9 OS:Linux (Linux)
Assigned to: Tomas Ulin CPU Architecture:Any

[24 Jan 2005 7:01] Abraham Jacob
Description:

   I have a cluster setup on 3 machines with 2 DB nodes and I was testing the cluster. I
have the following table and a unique index.

create table test(

        id integer not null auto_increment,
        month integer not null,
        year integer not null,
        code varchar( 2) not null,
        primary key ( id)
) engine=ndb;

create unique index idx_test on test( month, code, year);

and from mysql client I've executed following queries.

mysql> INSERT INTO test (month, year, code) VALUES (4,2004,'12');
Query OK, 1 row affected (0.01 sec)

mysql> INSERT INTO test (month, year, code) VALUES (5,2004,'12');
Query OK, 1 row affected (0.00 sec)

mysql> select * from test where code = '14'  and month = 4 and year = 2004;
ERROR 1296 (HY000): Got error 4209 'Length parameter in equal/setValue is incorrect' from ndbcluster

How to repeat:
create table test(

        id integer not null auto_increment,
        month integer not null,
        year integer not null,
        code varchar( 2) not null,
        primary key ( id)
) engine=ndb;

create unique index idx_test on test( month, code, year);
INSERT INTO test (month, year, code) VALUES (4,2004,'12');
INSERT INTO test (month, year, code) VALUES (5,2004,'12');

select * from test where code = '14'  and month = 4 and year = 2004;

Suggested fix:
recreating index like mentioned below solves this.
create unique index idx_test on test( month, year, code);

difference is the order of columns in index.
[26 Jan 2005 12:10] Tomas Ulin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html