Bug #22838 NDB INSERT fails on table with unique key for ERROR 1296
Submitted: 29 Sep 2006 18:21 Modified: 2 Nov 2006 9:43
Reporter: Todd Farmer (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:5.1.11-beta OS:Linux (Linux)
Assigned to: Jonas Oreland CPU Architecture:Any
Tags: 1296, cluster, ndb, tuple, unique key

[29 Sep 2006 18:21] Todd Farmer
Description:
NDB reporte an error when trying to insert into a table under certain conditions.  The error reported is:

ERROR 1296 (HY000): Got error 4205 'No Key attribute used to define tuple' from NDBCLUSTER

This happens consistently when the table against which the insert is being applied meets all of the following criteria:

1.  Table has no primary key.
2.  Table has a unqiue key on column(s) defined as NOT NULL.
3.  Unique key was added after table was created (using ALTER TABLE or CREATE UNIQUE KEY).

Existing possible workarounds include:

1.  Redefining the unique key as a primary key.
2.  Adding a new primary key column.
3.  Redefining the column(s) in the unique key to allow NULL values.
4.  Defining the unique key within the CREATE TABLE command.

How to repeat:
create database if not exists testing;
use testing;

drop table if exists ndb_test_unique;

create table ndb_test_unique
(
     FIRST                           INT NOT NULL
) engine=NDB;

CREATE UNIQUE INDEX ndb_test_unique_idx ON ndb_test_unique (FIRST);
# Will fail
insert into ndb_test_unique values (1);

drop table if exists ndb_test_unique;

create table ndb_test_unique
(
     FIRST                           INT NOT NULL
) engine=NDB;

ALTER TABLE ndb_test_unique ADD UNIQUE INDEX (FIRST);
# Will fail
insert into ndb_test_unique values (1);

Suggested fix:
Allow data to be inserted when the table meets the conditions listed above.
[29 Sep 2006 18:23] Todd Farmer
Test case script

Attachment: test_single.sql (application/vnd.oracle-isqlplus.script, text), 1.41 KiB.

[19 Oct 2006 14:16] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/13988

ChangeSet@1.2313, 2006-10-19 16:16:11+02:00, jonas@perch.ndb.mysql.com +1 -0
  ndb - bug#22838
    when doing create unique index which mysql will silently converts to PK, ndb is not informed
    so table will be useless.
  
    change so that we never do online add index wo/ primary key.
    this is not good, but it's better than a useless table
[20 Oct 2006 12:24] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/14058

ChangeSet@1.2308, 2006-10-20 14:24:20+02:00, jonas@perch.ndb.mysql.com +1 -0
  ndb - bug#22838
      when doing create unique index which mysql will silently converts to PK, ndb is not informed
      so table will be useless.
    
      change so that we never do online add index wo/ primary key.
      this is not good, but it's better than a useless table
[20 Oct 2006 12:37] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/14062

ChangeSet@1.2318, 2006-10-20 14:35:59+02:00, jonas@perch.ndb.mysql.com +1 -0
  ndb - bug#22838
      when doing create unique index which mysql will silently converts to PK, ndb is not informed
      so table will be useless.
    
      change so that we never do online add index wo/ primary key.
      this is not good, but it's better than a useless table
[25 Oct 2006 6:57] Jonas Oreland
pushed into 5.1-ndb
[1 Nov 2006 14:55] Jonas Oreland
pushed into 5.1.13
[2 Nov 2006 9:43] Jon Stephens
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 bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Documented bugfix for 5.1.13.