diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index 56b2d2fb0f7feda12b35c7de454afa3d27fc31ed..0e7b039a5f97c953388d0257d639efe1090510b3 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -3,35 +3,25 @@ CREATE TABLE t1 ( pk1 INT NOT NULL PRIMARY KEY, attr1 INT NOT NULL ) ENGINE=ndbcluster; -INSERT INTO t1 VALUES (9410,9412),(9411,9413); +INSERT INTO t1 VALUES (9410,9412); SELECT pk1 FROM t1; pk1 9410 -9411 SELECT * FROM t1; pk1 attr1 9410 9412 -9411 9413 SELECT t1.* FROM t1; pk1 attr1 9410 9412 -9411 9413 UPDATE t1 SET attr1=1 WHERE pk1=9410; SELECT * FROM t1; pk1 attr1 9410 1 -9411 9413 UPDATE t1 SET pk1=2 WHERE attr1=1; +ERROR 42000: Table 't1' uses an extension that doesn't exist in this MySQL version SELECT * FROM t1; pk1 attr1 -2 1 -9411 9413 -UPDATE t1 SET pk1=2 WHERE attr1=9413; -ERROR 23000: Can't write; duplicate key in table 't1' -SELECT * FROM t1; -pk1 attr1 -2 1 -9411 9413 +9410 1 DELETE FROM t1; SELECT * FROM t1; pk1 attr1 diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index ed13b36bf16dc1ec8710a9b45f6bb68c27db0ce6..271357ed561de544abccb3c84c885dc6808d1505 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -17,7 +17,7 @@ CREATE TABLE t1 ( attr1 INT NOT NULL ) ENGINE=ndbcluster; -INSERT INTO t1 VALUES (9410,9412),(9411,9413); +INSERT INTO t1 VALUES (9410,9412); SELECT pk1 FROM t1; SELECT * FROM t1; @@ -27,16 +27,11 @@ SELECT t1.* FROM t1; UPDATE t1 SET attr1=1 WHERE pk1=9410; SELECT * FROM t1; -# Update pk +# Can't UPDATE PK! Test that correct error is returned +-- error 1112 UPDATE t1 SET pk1=2 WHERE attr1=1; SELECT * FROM t1; -# Try to set same pk -# 1022: Can't write; duplicate key in table 't1' --- error 1022 -UPDATE t1 SET pk1=2 WHERE attr1=9413; -SELECT * FROM t1; - # Delete the record DELETE FROM t1; SELECT * FROM t1; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index e88cbc0c4b3d5ab85c98e0fa1795d055d5dfd58f..5c5256cc6228c6429f3ea27f3b0b9ded17497472 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1174,30 +1174,8 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) /* Check for update of primary key and return error */ if ((table->primary_key != MAX_KEY) && (key_cmp(table->primary_key, old_data, new_data))) - { - DBUG_PRINT("info", ("primary key update, doing insert + delete")); - int insert_res = write_row(new_data); - if (!insert_res) - { - DBUG_PRINT("info", ("insert succeded")); - int delete_res = delete_row(old_data); - if (!delete_res) - { - DBUG_PRINT("info", ("insert + delete succeeded")); - DBUG_RETURN(0); - } - else - { - DBUG_PRINT("info", ("delete failed")); - DBUG_RETURN(delete_row(new_data)); - } - } - else - { - DBUG_PRINT("info", ("insert failed")); - DBUG_RETURN(insert_res); - } - } + DBUG_RETURN(HA_ERR_UNSUPPORTED); + if (cursor) { /* @@ -1650,8 +1628,10 @@ int ha_ndbcluster::rnd_init(bool scan) NdbResultSet *cursor= m_active_cursor; DBUG_ENTER("rnd_init"); DBUG_PRINT("enter", ("scan: %d", scan)); - // Check that cursor is not defined - if (cursor) + // Check if scan is to be restarted + if (cursor && scan) + cursor->restart(); + else DBUG_RETURN(1); index_init(table->primary_key); DBUG_RETURN(0);